1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
43 (autoload 'gnus-msg-mail "gnus-msg" nil t)
44 (autoload 'gnus-button-mailto "gnus-msg")
45 (autoload 'gnus-button-reply "gnus-msg" nil t)
47 (defgroup gnus-article nil
49 :link '(custom-manual "(gnus)The Article Buffer")
52 (defgroup gnus-article-treat nil
53 "Treating article parts."
54 :link '(custom-manual "(gnus)Article Hiding")
57 (defgroup gnus-article-hiding nil
58 "Hiding article parts."
59 :link '(custom-manual "(gnus)Article Hiding")
62 (defgroup gnus-article-highlight nil
63 "Article highlighting."
64 :link '(custom-manual "(gnus)Article Highlighting")
68 (defgroup gnus-article-signature nil
70 :link '(custom-manual "(gnus)Article Signature")
73 (defgroup gnus-article-headers nil
75 :link '(custom-manual "(gnus)Hiding Headers")
78 (defgroup gnus-article-washing nil
79 "Special commands on articles."
80 :link '(custom-manual "(gnus)Article Washing")
83 (defgroup gnus-article-emphasis nil
84 "Fontisizing articles."
85 :link '(custom-manual "(gnus)Article Fontisizing")
88 (defgroup gnus-article-saving nil
90 :link '(custom-manual "(gnus)Saving Articles")
93 (defgroup gnus-article-mime nil
94 "Worshiping the MIME wonder."
95 :link '(custom-manual "(gnus)Using MIME")
98 (defgroup gnus-article-buttons nil
99 "Pushable buttons in the article buffer."
100 :link '(custom-manual "(gnus)Article Buttons")
101 :group 'gnus-article)
103 (defgroup gnus-article-various nil
104 "Other article options."
105 :link '(custom-manual "(gnus)Misc Article")
106 :group 'gnus-article)
108 (defcustom gnus-ignored-headers
109 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
110 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
111 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
112 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
113 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
114 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face"
115 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
116 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
117 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
118 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
119 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
120 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
121 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
122 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
123 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
124 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
125 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
126 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
127 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
128 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
129 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
130 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
131 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
132 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
133 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
134 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
135 "^X-Received:" "^Content-length:" "X-precedence:"
136 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
137 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
138 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
139 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
140 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
141 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:"
142 "^X-Request-PGP:" "^X-Fingerprint:" "^X-WRIEnvto:" "^X-WRIEnvfrom:"
143 "^X-Virus-Scanned:" "^X-Delivery-Agent:" "^Posted-Date:" "^X-Gateway:"
144 "^X-Local-Origin:" "^X-Local-Destination:" "^X-UserInfo1:"
145 "^X-Received-Date:" "^X-Hashcash:")
146 "*All headers that start with this regexp will be hidden.
147 This variable can also be a list of regexps of headers to be ignored.
148 If `gnus-visible-headers' is non-nil, this variable will be ignored."
149 :type '(choice :custom-show nil
152 :group 'gnus-article-hiding)
154 (defcustom gnus-visible-headers
155 "^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:"
156 "*All headers that do not match this regexp will be hidden.
157 This variable can also be a list of regexp of headers to remain visible.
158 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
159 :type '(repeat :value-to-internal (lambda (widget value)
160 (custom-split-regexp-maybe value))
161 :match (lambda (widget value)
163 (widget-editable-list-match widget value)))
165 :group 'gnus-article-hiding)
167 (defcustom gnus-sorted-header-list
168 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
169 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
170 "*This variable is a list of regular expressions.
171 If it is non-nil, headers that match the regular expressions will
172 be placed first in the article buffer in the sequence specified by
174 :type '(repeat regexp)
175 :group 'gnus-article-hiding)
177 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
178 "Headers that are only to be displayed if they have interesting data.
179 Possible values in this list are:
181 'empty Headers with no content.
182 'newsgroups Newsgroup identical to Gnus group.
183 'to-address To identical to To-address.
184 'followup-to Followup-to identical to Newsgroups.
185 'reply-to Reply-to identical to From.
186 'date Date less than four days old.
187 'long-to To and/or Cc longer than 1024 characters.
188 'many-to Multiple To and/or Cc."
189 :type '(set (const :tag "Headers with no content." empty)
190 (const :tag "Newsgroups identical to Gnus group." newsgroups)
191 (const :tag "To identical to To-address." to-address)
192 (const :tag "Followup-to identical to Newsgroups." followup-to)
193 (const :tag "Reply-to identical to From." reply-to)
194 (const :tag "Date less than four days old." date)
195 (const :tag "To and/or Cc longer than 1024 characters." long-to)
196 (const :tag "Multiple To and/or Cc headers." many-to))
197 :group 'gnus-article-hiding)
199 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
200 "Regexp matching signature separator.
201 This can also be a list of regexps. In that case, it will be checked
202 from head to tail looking for a separator. Searches will be done from
203 the end of the buffer."
204 :type '(repeat string)
205 :group 'gnus-article-signature)
207 (defcustom gnus-signature-limit nil
208 "Provide a limit to what is considered a signature.
209 If it is a number, no signature may not be longer (in characters) than
210 that number. If it is a floating point number, no signature may be
211 longer (in lines) than that number. If it is a function, the function
212 will be called without any parameters, and if it returns nil, there is
213 no signature in the buffer. If it is a string, it will be used as a
214 regexp. If it matches, the text in question is not a signature."
215 :type '(choice (integer :value 200)
217 (function :value fun)
218 (regexp :value ".*"))
219 :group 'gnus-article-signature)
221 (defcustom gnus-hidden-properties '(invisible t intangible t)
222 "Property list to use for hiding text."
224 :group 'gnus-article-hiding)
226 ;; Fixme: This isn't the right thing for mixed graphical and and
227 ;; non-graphical frames in a session.
228 (defcustom gnus-article-x-face-command
229 (if (featurep 'xemacs)
230 (if (or (gnus-image-type-available-p 'xface)
231 (gnus-image-type-available-p 'pbm))
232 'gnus-display-x-face-in-from
233 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
234 (if (gnus-image-type-available-p 'pbm)
235 'gnus-display-x-face-in-from
236 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
238 "*String or function to be executed to display an X-Face header.
239 If it is a string, the command will be executed in a sub-shell
240 asynchronously. The compressed face will be piped to this command."
241 :type `(choice string
242 (function-item gnus-display-x-face-in-from)
246 :group 'gnus-article-washing)
248 (defcustom gnus-article-x-face-too-ugly nil
249 "Regexp matching posters whose face shouldn't be shown automatically."
250 :type '(choice regexp (const nil))
251 :group 'gnus-article-washing)
253 (defcustom gnus-article-banner-alist nil
254 "Banner alist for stripping.
256 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
258 :type '(repeat (cons symbol regexp))
259 :group 'gnus-article-washing)
261 (gnus-define-group-parameter
264 "Alist of regexps (to match group names) and banner."
265 :variable-group gnus-article-washing
267 '(choice :tag "Banner"
269 (const :tag "Remove signature" signature)
270 (symbol :tag "Item in `gnus-article-banner-alist'" none)
272 (const :tag "None" nil))
274 "If non-nil, specify how to remove `banners' from articles.
276 Symbol `signature' means to remove signatures delimited by
277 `gnus-signature-separator'. Any other symbol is used to look up a
278 regular expression to match the banner in `gnus-article-banner-alist'.
279 A string is used as a regular expression to match the banner
282 (defcustom gnus-article-address-banner-alist nil
283 "Alist of mail addresses and banners.
284 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
285 to match a mail address in the From: header, BANNER is one of a symbol
286 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
287 If ADDRESS matches author's mail address, it will remove things like
288 advertisements. For example:
290 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
294 (regexp :tag "Address")
295 (choice :tag "Banner" :value nil
296 (const :tag "Remove signature" signature)
297 (symbol :tag "Item in `gnus-article-banner-alist'" none)
299 (const :tag "None" nil))))
300 :group 'gnus-article-washing)
302 (defcustom gnus-emphasis-alist
304 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
309 ("_/" "/_" underline-italic)
310 ("_\\*" "\\*_" underline-bold)
311 ("\\*/" "/\\*" bold-italic)
312 ("_\\*/" "/\\*_" underline-bold-italic))))
316 (format format (car spec) (cadr spec))
317 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
319 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
320 2 3 gnus-emphasis-strikethru)
321 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
322 2 3 gnus-emphasis-underline)))
323 "*Alist that says how to fontify certain phrases.
324 Each item looks like this:
326 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
328 The first element is a regular expression to be matched. The second
329 is a number that says what regular expression grouping used to find
330 the entire emphasized word. The third is a number that says what
331 regexp grouping should be displayed and highlighted. The fourth
332 is the face used for highlighting."
333 :type '(repeat (list :value ("" 0 0 default)
335 (integer :tag "Match group")
336 (integer :tag "Emphasize group")
338 :group 'gnus-article-emphasis)
340 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
341 "A regexp to describe whitespace which should not be emphasized.
342 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
343 The former avoids underlining of leading and trailing whitespace,
344 and the latter avoids underlining any whitespace at all."
346 :group 'gnus-article-emphasis
349 (defface gnus-emphasis-bold '((t (:bold t)))
350 "Face used for displaying strong emphasized text (*word*)."
351 :group 'gnus-article-emphasis)
353 (defface gnus-emphasis-italic '((t (:italic t)))
354 "Face used for displaying italic emphasized text (/word/)."
355 :group 'gnus-article-emphasis)
357 (defface gnus-emphasis-underline '((t (:underline t)))
358 "Face used for displaying underlined emphasized text (_word_)."
359 :group 'gnus-article-emphasis)
361 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
362 "Face used for displaying underlined bold emphasized text (_*word*_)."
363 :group 'gnus-article-emphasis)
365 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
366 "Face used for displaying underlined italic emphasized text (_/word/_)."
367 :group 'gnus-article-emphasis)
369 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
370 "Face used for displaying bold italic emphasized text (/*word*/)."
371 :group 'gnus-article-emphasis)
373 (defface gnus-emphasis-underline-bold-italic
374 '((t (:bold t :italic t :underline t)))
375 "Face used for displaying underlined bold italic emphasized text.
376 Example: (_/*word*/_)."
377 :group 'gnus-article-emphasis)
379 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
380 "Face used for displaying strike-through text (-word-)."
381 :group 'gnus-article-emphasis)
383 (defface gnus-emphasis-highlight-words
384 '((t (:background "black" :foreground "yellow")))
385 "Face used for displaying highlighted words."
386 :group 'gnus-article-emphasis)
388 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
389 "Format for display of Date headers in article bodies.
390 See `format-time-string' for the possible values.
392 The variable can also be function, which should return a complete Date
393 header. The function is called with one argument, the time, which can
394 be fed to `format-time-string'."
395 :type '(choice string symbol)
396 :link '(custom-manual "(gnus)Article Date")
397 :group 'gnus-article-washing)
400 (autoload 'mail-extract-address-components "mail-extr"))
402 (defcustom gnus-save-all-headers t
403 "*If non-nil, don't remove any headers before saving."
404 :group 'gnus-article-saving
407 (defcustom gnus-prompt-before-saving 'always
408 "*This variable says how much prompting is to be done when saving articles.
409 If it is nil, no prompting will be done, and the articles will be
410 saved to the default files. If this variable is `always', each and
411 every article that is saved will be preceded by a prompt, even when
412 saving large batches of articles. If this variable is neither nil not
413 `always', there the user will be prompted once for a file name for
414 each invocation of the saving commands."
415 :group 'gnus-article-saving
416 :type '(choice (item always)
417 (item :tag "never" nil)
418 (sexp :tag "once" :format "%t\n" :value t)))
420 (defcustom gnus-saved-headers gnus-visible-headers
421 "Headers to keep if `gnus-save-all-headers' is nil.
422 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
423 If that variable is nil, however, all headers that match this regexp
424 will be kept while the rest will be deleted before saving."
425 :group 'gnus-article-saving
428 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
429 "A function to save articles in your favourite format.
430 The function must be interactively callable (in other words, it must
431 be an Emacs command).
433 Gnus provides the following functions:
435 * gnus-summary-save-in-rmail (Rmail format)
436 * gnus-summary-save-in-mail (Unix mail format)
437 * gnus-summary-save-in-folder (MH folder)
438 * gnus-summary-save-in-file (article format)
439 * gnus-summary-save-body-in-file (article body)
440 * gnus-summary-save-in-vm (use VM's folder format)
441 * gnus-summary-write-to-file (article format -- overwrite)."
442 :group 'gnus-article-saving
443 :type '(radio (function-item gnus-summary-save-in-rmail)
444 (function-item gnus-summary-save-in-mail)
445 (function-item gnus-summary-save-in-folder)
446 (function-item gnus-summary-save-in-file)
447 (function-item gnus-summary-save-body-in-file)
448 (function-item gnus-summary-save-in-vm)
449 (function-item gnus-summary-write-to-file)))
451 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
452 "A function generating a file name to save articles in Rmail format.
453 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
454 :group 'gnus-article-saving
457 (defcustom gnus-mail-save-name 'gnus-plain-save-name
458 "A function generating a file name to save articles in Unix mail format.
459 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
460 :group 'gnus-article-saving
463 (defcustom gnus-folder-save-name 'gnus-folder-save-name
464 "A function generating a file name to save articles in MH folder.
465 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
466 :group 'gnus-article-saving
469 (defcustom gnus-file-save-name 'gnus-numeric-save-name
470 "A function generating a file name to save articles in article format.
471 The function is called with NEWSGROUP, HEADERS, and optional
473 :group 'gnus-article-saving
476 (defcustom gnus-split-methods
477 '((gnus-article-archive-name)
478 (gnus-article-nndoc-name))
479 "*Variable used to suggest where articles are to be saved.
480 For instance, if you would like to save articles related to Gnus in
481 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
482 you could set this variable to something like:
484 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
485 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
487 This variable is an alist where the where the key is the match and the
488 value is a list of possible files to save in if the match is non-nil.
490 If the match is a string, it is used as a regexp match on the
491 article. If the match is a symbol, that symbol will be funcalled
492 from the buffer of the article to be saved with the newsgroup as the
493 parameter. If it is a list, it will be evaled in the same buffer.
495 If this form or function returns a string, this string will be used as
496 a possible file name; and if it returns a non-nil list, that list will
497 be used as possible file names."
498 :group 'gnus-article-saving
499 :type '(repeat (choice (list :value (fun) function)
500 (cons :value ("" "") regexp (repeat string))
503 (defcustom gnus-page-delimiter "^\^L"
504 "*Regexp describing what to use as article page delimiters.
505 The default value is \"^\^L\", which is a form linefeed at the
506 beginning of a line."
508 :group 'gnus-article-various)
510 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
511 "*The format specification for the article mode line.
512 See `gnus-summary-mode-line-format' for a closer description.
514 The following additional specs are available:
516 %w The article washing status.
517 %m The number of MIME parts in the article."
519 :group 'gnus-article-various)
521 (defcustom gnus-article-mode-hook nil
522 "*A hook for Gnus article mode."
524 :group 'gnus-article-various)
526 (when (featurep 'xemacs)
527 ;; Extracted from gnus-xmas-define in order to preserve user settings
528 (when (fboundp 'turn-off-scroll-in-place)
529 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
530 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
531 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
533 (defcustom gnus-article-menu-hook nil
534 "*Hook run after the creation of the article mode menu."
536 :group 'gnus-article-various)
538 (defcustom gnus-article-prepare-hook nil
539 "*A hook called after an article has been prepared in the article buffer."
541 :group 'gnus-article-various)
543 (defcustom gnus-article-hide-pgp-hook nil
544 "*A hook called after successfully hiding a PGP signature."
546 :group 'gnus-article-various)
548 (defcustom gnus-article-button-face 'bold
549 "Face used for highlighting buttons in the article buffer.
551 An article button is a piece of text that you can activate by pressing
552 `RET' or `mouse-2' above it."
554 :group 'gnus-article-buttons)
556 (defcustom gnus-article-mouse-face 'highlight
557 "Face used for mouse highlighting in the article buffer.
559 Article buttons will be displayed in this face when the cursor is
562 :group 'gnus-article-buttons)
564 (defcustom gnus-signature-face 'gnus-signature-face
565 "Face used for highlighting a signature in the article buffer.
566 Obsolete; use the face `gnus-signature-face' for customizations instead."
568 :group 'gnus-article-highlight
569 :group 'gnus-article-signature)
571 (defface gnus-signature-face
574 "Face used for highlighting a signature in the article buffer."
575 :group 'gnus-article-highlight
576 :group 'gnus-article-signature)
578 (defface gnus-header-from-face
581 (:foreground "spring green"))
584 (:foreground "red3"))
587 "Face used for displaying from headers."
588 :group 'gnus-article-headers
589 :group 'gnus-article-highlight)
591 (defface gnus-header-subject-face
594 (:foreground "SeaGreen3"))
597 (:foreground "red4"))
599 (:bold t :italic t)))
600 "Face used for displaying subject headers."
601 :group 'gnus-article-headers
602 :group 'gnus-article-highlight)
604 (defface gnus-header-newsgroups-face
607 (:foreground "yellow" :italic t))
610 (:foreground "MidnightBlue" :italic t))
613 "Face used for displaying newsgroups headers."
614 :group 'gnus-article-headers
615 :group 'gnus-article-highlight)
617 (defface gnus-header-name-face
620 (:foreground "SeaGreen"))
623 (:foreground "maroon"))
626 "Face used for displaying header names."
627 :group 'gnus-article-headers
628 :group 'gnus-article-highlight)
630 (defface gnus-header-content-face
633 (:foreground "forest green" :italic t))
636 (:foreground "indianred4" :italic t))
638 (:italic t))) "Face used for displaying header content."
639 :group 'gnus-article-headers
640 :group 'gnus-article-highlight)
642 (defcustom gnus-header-face-alist
643 '(("From" nil gnus-header-from-face)
644 ("Subject" nil gnus-header-subject-face)
645 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
646 ("" gnus-header-name-face gnus-header-content-face))
647 "*Controls highlighting of article header.
649 An alist of the form (HEADER NAME CONTENT).
651 HEADER is a regular expression which should match the name of an
652 header header and NAME and CONTENT are either face names or nil.
654 The name of each header field will be displayed using the face
655 specified by the first element in the list where HEADER match the
656 header name and NAME is non-nil. Similarly, the content will be
657 displayed by the first non-nil matching CONTENT face."
658 :group 'gnus-article-headers
659 :group 'gnus-article-highlight
660 :type '(repeat (list (regexp :tag "Header")
662 (item :tag "skip" nil)
663 (face :value default))
664 (choice :tag "Content"
665 (item :tag "skip" nil)
666 (face :value default)))))
668 (defcustom gnus-article-decode-hook
669 '(article-decode-charset article-decode-encoded-words
670 article-decode-group-name)
671 "*Hook run to decode charsets in articles."
672 :group 'gnus-article-headers
675 (defcustom gnus-display-mime-function 'gnus-display-mime
676 "Function to display MIME articles."
677 :group 'gnus-article-mime
680 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
681 "Function used to decode headers.")
683 (defvar gnus-article-dumbquotes-map
703 "Table for MS-to-Latin1 translation.")
705 (defcustom gnus-ignored-mime-types nil
706 "List of MIME types that should be ignored by Gnus."
708 :group 'gnus-article-mime
709 :type '(repeat regexp))
711 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
712 "List of MIME types that should not be given buttons when rendered inline.
713 See also `gnus-buttonized-mime-types' which may override this variable.
714 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
716 :group 'gnus-article-mime
717 :type '(repeat regexp))
719 (defcustom gnus-buttonized-mime-types nil
720 "List of MIME types that should be given buttons when rendered inline.
721 If set, this variable overrides `gnus-unbuttonized-mime-types'.
722 To see e.g. security buttons you could set this to
723 `(\"multipart/signed\")'.
724 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
726 :group 'gnus-article-mime
727 :type '(repeat regexp))
729 (defcustom gnus-inhibit-mime-unbuttonizing nil
730 "If non-nil, all MIME parts get buttons.
731 When nil (the default value), then some MIME parts do not get buttons,
732 as described by the variables `gnus-buttonized-mime-types' and
733 `gnus-unbuttonized-mime-types'."
737 (defcustom gnus-body-boundary-delimiter "_"
738 "String used to delimit header and body.
739 This variable is used by `gnus-article-treat-body-boundary' which can
740 be controlled by `gnus-treat-body-boundary'."
741 :group 'gnus-article-various
742 :type '(choice (item :tag "None" :value nil)
745 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
746 "Defines the location of the faces database.
747 For information on obtaining this database of pretty pictures, please
748 see http://www.cs.indiana.edu/picons/ftp/index.html"
749 :type '(repeat directory)
750 :link '(url-link :tag "download"
751 "http://www.cs.indiana.edu/picons/ftp/index.html")
752 :link '(custom-manual "(gnus)Picons")
755 (defun gnus-picons-installed-p ()
756 "Say whether picons are installed on your machine."
757 (let ((installed nil))
758 (dolist (database gnus-picon-databases)
759 (when (file-exists-p database)
763 (defcustom gnus-article-mime-part-function nil
764 "Function called with a MIME handle as the argument.
765 This is meant for people who want to do something automatic based
766 on parts -- for instance, adding Vcard info to a database."
767 :group 'gnus-article-mime
770 (defcustom gnus-mime-multipart-functions nil
771 "An alist of MIME types to functions to display them."
773 :group 'gnus-article-mime
776 (defcustom gnus-article-date-lapsed-new-header nil
777 "Whether the X-Sent and Date headers can coexist.
778 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
779 either replace the old \"Date:\" header (if this variable is nil), or
780 be added below it (otherwise)."
782 :group 'gnus-article-headers
785 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
786 "Function called with a MIME handle as the argument.
787 This is meant for people who want to view first matched part.
788 For `undisplayed-alternative' (default), the first undisplayed
789 part or alternative part is used. For `undisplayed', the first
790 undisplayed part is used. For a function, the first part which
791 the function return `t' is used. For `nil', the first part is
794 :group 'gnus-article-mime
796 (item :tag "first" :value nil)
797 (item :tag "undisplayed" :value undisplayed)
798 (item :tag "undisplayed or alternative"
799 :value undisplayed-alternative)
802 (defcustom gnus-mime-action-alist
803 '(("save to file" . gnus-mime-save-part)
804 ("save and strip" . gnus-mime-save-part-and-strip)
805 ("display as text" . gnus-mime-inline-part)
806 ("view the part" . gnus-mime-view-part)
807 ("pipe to command" . gnus-mime-pipe-part)
808 ("toggle display" . gnus-article-press-button)
809 ("toggle display" . gnus-article-view-part-as-charset)
810 ("view as type" . gnus-mime-view-part-as-type)
811 ("view internally" . gnus-mime-view-part-internally)
812 ("view externally" . gnus-mime-view-part-externally))
813 "An alist of actions that run on the MIME attachment."
814 :group 'gnus-article-mime
815 :type '(repeat (cons (string :tag "name")
819 ;;; The treatment variables
822 (defvar gnus-part-display-hook nil
823 "Hook called on parts that are to receive treatment.")
825 (defvar gnus-article-treat-custom
826 '(choice (const :tag "Off" nil)
828 (const :tag "Header" head)
829 (const :tag "Last" last)
830 (integer :tag "Less")
831 (repeat :tag "Groups" regexp)
832 (sexp :tag "Predicate")))
834 (defvar gnus-article-treat-head-custom
835 '(choice (const :tag "Off" nil)
836 (const :tag "Header" head)))
838 (defvar gnus-article-treat-types '("text/plain")
841 (defvar gnus-inhibit-treatment nil
842 "Whether to inhibit treatment.")
844 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
845 "Highlight the signature.
846 Valid values are nil, t, `head', `last', an integer or a predicate.
847 See Info node `(gnus)Customizing Articles'."
848 :group 'gnus-article-treat
849 :link '(custom-manual "(gnus)Customizing Articles")
850 :type gnus-article-treat-custom)
851 (put 'gnus-treat-highlight-signature 'highlight t)
853 (defcustom gnus-treat-buttonize 100000
855 Valid values are nil, t, `head', `last', an integer or a predicate.
856 See Info node `(gnus)Customizing Articles'."
857 :group 'gnus-article-treat
858 :link '(custom-manual "(gnus)Customizing Articles")
859 :type gnus-article-treat-custom)
860 (put 'gnus-treat-buttonize 'highlight t)
862 (defcustom gnus-treat-buttonize-head 'head
863 "Add buttons to the head.
864 Valid values are nil, t, `head', `last', an integer or a predicate.
865 See Info node `(gnus)Customizing Articles' for details."
866 :group 'gnus-article-treat
867 :link '(custom-manual "(gnus)Customizing Articles")
868 :type gnus-article-treat-head-custom)
869 (put 'gnus-treat-buttonize-head 'highlight t)
871 (defcustom gnus-treat-emphasize
872 (and (or window-system
874 (>= (string-to-number emacs-version) 21))
877 Valid values are nil, t, `head', `last', an integer or a predicate.
878 See Info node `(gnus)Customizing Articles' for details."
879 :group 'gnus-article-treat
880 :link '(custom-manual "(gnus)Customizing Articles")
881 :type gnus-article-treat-custom)
882 (put 'gnus-treat-emphasize 'highlight t)
884 (defcustom gnus-treat-strip-cr nil
885 "Remove carriage returns.
886 Valid values are nil, t, `head', `last', an integer or a predicate.
887 See Info node `(gnus)Customizing Articles' for details."
888 :group 'gnus-article-treat
889 :link '(custom-manual "(gnus)Customizing Articles")
890 :type gnus-article-treat-custom)
892 (defcustom gnus-treat-unsplit-urls nil
893 "Remove newlines from within URLs.
894 Valid values are nil, t, `head', `last', an integer or a predicate.
895 See Info node `(gnus)Customizing Articles' for details."
896 :group 'gnus-article-treat
897 :link '(custom-manual "(gnus)Customizing Articles")
898 :type gnus-article-treat-custom)
900 (defcustom gnus-treat-leading-whitespace nil
901 "Remove leading whitespace in headers.
902 Valid values are nil, t, `head', `last', an integer or a predicate.
903 See Info node `(gnus)Customizing Articles' for details."
904 :group 'gnus-article-treat
905 :link '(custom-manual "(gnus)Customizing Articles")
906 :type gnus-article-treat-custom)
908 (defcustom gnus-treat-hide-headers 'head
910 Valid values are nil, t, `head', `last', an integer or a predicate.
911 See Info node `(gnus)Customizing Articles' for details."
912 :group 'gnus-article-treat
913 :link '(custom-manual "(gnus)Customizing Articles")
914 :type gnus-article-treat-head-custom)
916 (defcustom gnus-treat-hide-boring-headers nil
917 "Hide boring headers.
918 Valid values are nil, t, `head', `last', an integer or a predicate.
919 See Info node `(gnus)Customizing Articles' for details."
920 :group 'gnus-article-treat
921 :link '(custom-manual "(gnus)Customizing Articles")
922 :type gnus-article-treat-head-custom)
924 (defcustom gnus-treat-hide-signature nil
926 Valid values are nil, t, `head', `last', an integer or a predicate.
927 See Info node `(gnus)Customizing Articles' for details."
928 :group 'gnus-article-treat
929 :link '(custom-manual "(gnus)Customizing Articles")
930 :type gnus-article-treat-custom)
932 (defcustom gnus-treat-fill-article nil
934 Valid values are nil, t, `head', `last', an integer or a predicate.
935 See Info node `(gnus)Customizing Articles' for details."
936 :group 'gnus-article-treat
937 :link '(custom-manual "(gnus)Customizing Articles")
938 :type gnus-article-treat-custom)
940 (defcustom gnus-treat-hide-citation nil
942 Valid values are nil, t, `head', `last', an integer or a predicate.
943 See Info node `(gnus)Customizing Articles' for details."
944 :group 'gnus-article-treat
945 :link '(custom-manual "(gnus)Customizing Articles")
946 :type gnus-article-treat-custom)
948 (defcustom gnus-treat-hide-citation-maybe nil
950 Valid values are nil, t, `head', `last', an integer or a predicate.
951 See Info node `(gnus)Customizing Articles' for details."
952 :group 'gnus-article-treat
953 :link '(custom-manual "(gnus)Customizing Articles")
954 :type gnus-article-treat-custom)
956 (defcustom gnus-treat-strip-list-identifiers 'head
957 "Strip list identifiers from `gnus-list-identifiers`.
958 Valid values are nil, t, `head', `last', an integer or a predicate.
959 See Info node `(gnus)Customizing Articles' for details."
961 :group 'gnus-article-treat
962 :link '(custom-manual "(gnus)Customizing Articles")
963 :type gnus-article-treat-custom)
965 (defcustom gnus-treat-strip-pgp t
966 "Strip PGP signatures.
967 Valid values are nil, t, `head', `last', an integer or a predicate.
968 See Info node `(gnus)Customizing Articles' for details."
969 :group 'gnus-article-treat
970 :link '(custom-manual "(gnus)Customizing Articles")
971 :type gnus-article-treat-custom)
973 (defcustom gnus-treat-strip-pem nil
974 "Strip PEM signatures.
975 Valid values are nil, t, `head', `last', an integer or a predicate.
976 See Info node `(gnus)Customizing Articles' for details."
977 :group 'gnus-article-treat
978 :link '(custom-manual "(gnus)Customizing Articles")
979 :type gnus-article-treat-custom)
981 (defcustom gnus-treat-strip-banner t
982 "Strip banners from articles.
983 The banner to be stripped is specified in the `banner' group parameter.
984 Valid values are nil, t, `head', `last', an integer or a predicate.
985 See Info node `(gnus)Customizing Articles' for details."
986 :group 'gnus-article-treat
987 :link '(custom-manual "(gnus)Customizing Articles")
988 :type gnus-article-treat-custom)
990 (defcustom gnus-treat-highlight-headers 'head
991 "Highlight the headers.
992 Valid values are nil, t, `head', `last', an integer or a predicate.
993 See Info node `(gnus)Customizing Articles' for details."
994 :group 'gnus-article-treat
995 :link '(custom-manual "(gnus)Customizing Articles")
996 :type gnus-article-treat-head-custom)
997 (put 'gnus-treat-highlight-headers 'highlight t)
999 (defcustom gnus-treat-highlight-citation t
1000 "Highlight cited text.
1001 Valid values are nil, t, `head', `last', an integer or a predicate.
1002 See Info node `(gnus)Customizing Articles' for details."
1003 :group 'gnus-article-treat
1004 :link '(custom-manual "(gnus)Customizing Articles")
1005 :type gnus-article-treat-custom)
1006 (put 'gnus-treat-highlight-citation 'highlight t)
1008 (defcustom gnus-treat-date-ut nil
1009 "Display the Date in UT (GMT).
1010 Valid values are nil, t, `head', `last', an integer or a predicate.
1011 See Info node `(gnus)Customizing Articles' for details."
1012 :group 'gnus-article-treat
1013 :link '(custom-manual "(gnus)Customizing Articles")
1014 :type gnus-article-treat-head-custom)
1016 (defcustom gnus-treat-date-local nil
1017 "Display the Date in the local timezone.
1018 Valid values are nil, t, `head', `last', an integer or a predicate.
1019 See Info node `(gnus)Customizing Articles' for details."
1020 :group 'gnus-article-treat
1021 :link '(custom-manual "(gnus)Customizing Articles")
1022 :type gnus-article-treat-head-custom)
1024 (defcustom gnus-treat-date-english nil
1025 "Display the Date in a format that can be read aloud in English.
1026 Valid values are nil, t, `head', `last', an integer or a predicate.
1027 See Info node `(gnus)Customizing Articles' for details."
1028 :group 'gnus-article-treat
1029 :link '(custom-manual "(gnus)Customizing Articles")
1030 :type gnus-article-treat-head-custom)
1032 (defcustom gnus-treat-date-lapsed nil
1033 "Display the Date header in a way that says how much time has elapsed.
1034 Valid values are nil, t, `head', `last', an integer or a predicate.
1035 See Info node `(gnus)Customizing Articles' for details."
1036 :group 'gnus-article-treat
1037 :link '(custom-manual "(gnus)Customizing Articles")
1038 :type gnus-article-treat-head-custom)
1040 (defcustom gnus-treat-date-original nil
1041 "Display the date in the original timezone.
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-iso8601 nil
1049 "Display the date in the ISO8601 format.
1050 Valid values are nil, t, `head', `last', an integer or a predicate.
1051 See Info node `(gnus)Customizing Articles' for details."
1053 :group 'gnus-article-treat
1054 :link '(custom-manual "(gnus)Customizing Articles")
1055 :type gnus-article-treat-head-custom)
1057 (defcustom gnus-treat-date-user-defined nil
1058 "Display the date in a user-defined format.
1059 The format is defined by the `gnus-article-time-format' variable.
1060 Valid values are nil, t, `head', `last', an integer or a predicate.
1061 See Info node `(gnus)Customizing Articles' for details."
1062 :group 'gnus-article-treat
1063 :link '(custom-manual "(gnus)Customizing Articles")
1064 :type gnus-article-treat-head-custom)
1066 (defcustom gnus-treat-strip-headers-in-body t
1067 "Strip the X-No-Archive header line from the beginning of the body.
1068 Valid values are nil, t, `head', `last', an integer or a predicate.
1069 See Info node `(gnus)Customizing Articles' for details."
1071 :group 'gnus-article-treat
1072 :link '(custom-manual "(gnus)Customizing Articles")
1073 :type gnus-article-treat-custom)
1075 (defcustom gnus-treat-strip-trailing-blank-lines nil
1076 "Strip trailing blank lines.
1077 Valid values are nil, t, `head', `last', an integer or a predicate.
1078 See Info node `(gnus)Customizing Articles' for details."
1079 :group 'gnus-article-treat
1080 :link '(custom-manual "(gnus)Customizing Articles")
1081 :type gnus-article-treat-custom)
1083 (defcustom gnus-treat-strip-leading-blank-lines nil
1084 "Strip leading blank lines.
1085 Valid values are nil, t, `head', `last', an integer or a predicate.
1086 See Info node `(gnus)Customizing Articles' for details."
1087 :group 'gnus-article-treat
1088 :link '(custom-manual "(gnus)Customizing Articles")
1089 :type gnus-article-treat-custom)
1091 (defcustom gnus-treat-strip-multiple-blank-lines nil
1092 "Strip multiple blank lines.
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-custom)
1099 (defcustom gnus-treat-unfold-headers 'head
1100 "Unfold folded header lines.
1101 Valid values are nil, t, `head', `last', an integer or a predicate.
1102 See Info node `(gnus)Customizing Articles' for details."
1103 :group 'gnus-article-treat
1104 :link '(custom-manual "(gnus)Customizing Articles")
1105 :type gnus-article-treat-custom)
1107 (defcustom gnus-treat-fold-headers nil
1109 Valid values are nil, t, `head', `last', an integer or a predicate.
1110 See Info node `(gnus)Customizing Articles' for details."
1111 :group 'gnus-article-treat
1112 :link '(custom-manual "(gnus)Customizing Articles")
1113 :type gnus-article-treat-custom)
1115 (defcustom gnus-treat-fold-newsgroups 'head
1116 "Fold the Newsgroups and Followup-To headers.
1117 Valid values are nil, t, `head', `last', an integer or a predicate.
1118 See Info node `(gnus)Customizing Articles' for details."
1119 :group 'gnus-article-treat
1120 :link '(custom-manual "(gnus)Customizing Articles")
1121 :type gnus-article-treat-custom)
1123 (defcustom gnus-treat-overstrike t
1124 "Treat overstrike highlighting.
1125 Valid values are nil, t, `head', `last', an integer or a predicate.
1126 See Info node `(gnus)Customizing Articles' for details."
1127 :group 'gnus-article-treat
1128 :link '(custom-manual "(gnus)Customizing Articles")
1129 :type gnus-article-treat-custom)
1130 (put 'gnus-treat-overstrike 'highlight t)
1132 (defcustom gnus-treat-display-xface
1133 (and (not noninteractive)
1134 (or (and (fboundp 'image-type-available-p)
1135 (image-type-available-p 'xbm)
1136 (string-match "^0x" (shell-command-to-string "uncompface")))
1137 (and (featurep 'xemacs)
1140 "Display X-Face headers.
1141 Valid values are nil, t, `head', `last', an integer or a predicate.
1142 See Info node `(gnus)Customizing Articles' and Info node
1143 `(gnus)X-Face' for details."
1144 :group 'gnus-article-treat
1146 :link '(custom-manual "(gnus)Customizing Articles")
1147 :link '(custom-manual "(gnus)X-Face")
1148 :type gnus-article-treat-head-custom)
1149 (put 'gnus-treat-display-xface 'highlight t)
1151 (defcustom gnus-treat-display-grey-xface
1152 (and (not noninteractive)
1153 (string-match "^0x" (shell-command-to-string "uncompface"))
1155 "Display grey X-Face headers.
1156 Valid values are nil, t."
1157 :group 'gnus-article-treat
1160 (put 'gnus-treat-display-grey-xface 'highlight t)
1162 (defcustom gnus-treat-display-smileys
1163 (if (or (and (featurep 'xemacs)
1165 (and (fboundp 'image-type-available-p)
1166 (image-type-available-p 'pbm)))
1169 Valid values are nil, t, `head', `last', an integer or a predicate.
1170 See Info node `(gnus)Customizing Articles' and Info node
1171 `(gnus)Smileys' for details."
1172 :group 'gnus-article-treat
1174 :link '(custom-manual "(gnus)Customizing Articles")
1175 :link '(custom-manual "(gnus)Smileys")
1176 :type gnus-article-treat-custom)
1177 (put 'gnus-treat-display-smileys 'highlight t)
1179 (defcustom gnus-treat-from-picon
1180 (if (and (gnus-image-type-available-p 'xpm)
1181 (gnus-picons-installed-p))
1183 "Display picons in the From header.
1184 Valid values are nil, t, `head', `last', an integer or a predicate.
1185 See Info node `(gnus)Customizing Articles' and Info node
1186 `(gnus)Picons' for details."
1187 :group 'gnus-article-treat
1189 :link '(custom-manual "(gnus)Customizing Articles")
1190 :link '(custom-manual "(gnus)Picons")
1191 :type gnus-article-treat-head-custom)
1192 (put 'gnus-treat-from-picon 'highlight t)
1194 (defcustom gnus-treat-mail-picon
1195 (if (and (gnus-image-type-available-p 'xpm)
1196 (gnus-picons-installed-p))
1198 "Display picons in To and Cc headers.
1199 Valid values are nil, t, `head', `last', an integer or a predicate.
1200 See Info node `(gnus)Customizing Articles' and Info node
1201 `(gnus)Picons' for details."
1202 :group 'gnus-article-treat
1204 :link '(custom-manual "(gnus)Customizing Articles")
1205 :link '(custom-manual "(gnus)Picons")
1206 :type gnus-article-treat-head-custom)
1207 (put 'gnus-treat-mail-picon 'highlight t)
1209 (defcustom gnus-treat-newsgroups-picon
1210 (if (and (gnus-image-type-available-p 'xpm)
1211 (gnus-picons-installed-p))
1213 "Display picons in the Newsgroups and Followup-To headers.
1214 Valid values are nil, t, `head', `last', an integer or a predicate.
1215 See Info node `(gnus)Customizing Articles' and Info node
1216 `(gnus)Picons' for details."
1217 :group 'gnus-article-treat
1219 :link '(custom-manual "(gnus)Customizing Articles")
1220 :link '(custom-manual "(gnus)Picons")
1221 :type gnus-article-treat-head-custom)
1222 (put 'gnus-treat-newsgroups-picon 'highlight t)
1224 (defcustom gnus-treat-body-boundary
1225 (if (or gnus-treat-newsgroups-picon
1226 gnus-treat-mail-picon
1227 gnus-treat-from-picon)
1229 "Draw a boundary at the end of the headers.
1230 Valid values are nil, t, `head', `last', an integer or a predicate.
1231 See Info node `(gnus)Customizing Articles' for details."
1233 :group 'gnus-article-treat
1234 :link '(custom-manual "(gnus)Customizing Articles")
1235 :type gnus-article-treat-custom)
1237 (defcustom gnus-treat-capitalize-sentences nil
1238 "Capitalize sentence-starting words.
1239 Valid values are nil, t, `head', `last', an integer or a predicate.
1240 See Info node `(gnus)Customizing Articles' for details."
1242 :group 'gnus-article-treat
1243 :link '(custom-manual "(gnus)Customizing Articles")
1244 :type gnus-article-treat-custom)
1246 (defcustom gnus-treat-wash-html nil
1248 Valid values are nil, t, `head', `last', an integer or a predicate.
1249 See Info node `(gnus)Customizing Articles' for details."
1250 :group 'gnus-article-treat
1251 :link '(custom-manual "(gnus)Customizing Articles")
1252 :type gnus-article-treat-custom)
1254 (defcustom gnus-treat-fill-long-lines nil
1256 Valid values are nil, t, `head', `last', an integer or a predicate.
1257 See Info node `(gnus)Customizing Articles' for details."
1258 :group 'gnus-article-treat
1259 :link '(custom-manual "(gnus)Customizing Articles")
1260 :type gnus-article-treat-custom)
1262 (defcustom gnus-treat-play-sounds nil
1264 Valid values are nil, t, `head', `last', an integer or a predicate.
1265 See Info node `(gnus)Customizing Articles' for details."
1267 :group 'gnus-article-treat
1268 :link '(custom-manual "(gnus)Customizing Articles")
1269 :type gnus-article-treat-custom)
1271 (defcustom gnus-treat-translate nil
1272 "Translate articles from one language to another.
1273 Valid values are nil, t, `head', `last', an integer or a predicate.
1274 See Info node `(gnus)Customizing Articles' for details."
1276 :group 'gnus-article-treat
1277 :link '(custom-manual "(gnus)Customizing Articles")
1278 :type gnus-article-treat-custom)
1280 (defcustom gnus-treat-x-pgp-sig nil
1282 To automatically treat X-PGP-Sig, set it to head.
1283 Valid values are nil, t, `head', `last', an integer or a predicate.
1284 See Info node `(gnus)Customizing Articles' for details."
1285 :group 'gnus-article-treat
1286 :group 'mime-security
1287 :link '(custom-manual "(gnus)Customizing Articles")
1288 :type gnus-article-treat-custom)
1290 (defvar gnus-article-encrypt-protocol-alist
1291 '(("PGP" . mml2015-self-encrypt)))
1293 ;; Set to nil if more than one protocol added to
1294 ;; gnus-article-encrypt-protocol-alist.
1295 (defcustom gnus-article-encrypt-protocol "PGP"
1296 "The protocol used for encrypt articles.
1297 It is a string, such as \"PGP\". If nil, ask user."
1299 :group 'mime-security)
1301 (defvar gnus-article-wash-function nil
1302 "Function used for converting HTML into text.")
1304 ;;; Internal variables
1306 (defvar gnus-english-month-names
1307 '("January" "February" "March" "April" "May" "June" "July" "August"
1308 "September" "October" "November" "December"))
1310 (defvar article-goto-body-goes-to-point-min-p nil)
1311 (defvar gnus-article-wash-types nil)
1312 (defvar gnus-article-emphasis-alist nil)
1313 (defvar gnus-article-image-alist nil)
1315 (defvar gnus-article-mime-handle-alist-1 nil)
1316 (defvar gnus-treatment-function-alist
1317 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1318 (gnus-treat-strip-banner gnus-article-strip-banner)
1319 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1320 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1321 (gnus-treat-buttonize gnus-article-add-buttons)
1322 (gnus-treat-fill-article gnus-article-fill-cited-article)
1323 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1324 (gnus-treat-strip-cr gnus-article-remove-cr)
1325 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1326 (gnus-treat-date-ut gnus-article-date-ut)
1327 (gnus-treat-date-local gnus-article-date-local)
1328 (gnus-treat-date-english gnus-article-date-english)
1329 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1330 (gnus-treat-date-original gnus-article-date-original)
1331 (gnus-treat-date-user-defined gnus-article-date-user)
1332 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1333 (gnus-treat-display-xface gnus-article-display-x-face)
1334 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1335 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1336 (gnus-treat-hide-signature gnus-article-hide-signature)
1337 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1338 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1339 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1340 (gnus-treat-strip-pem gnus-article-hide-pem)
1341 (gnus-treat-from-picon gnus-treat-from-picon)
1342 (gnus-treat-mail-picon gnus-treat-mail-picon)
1343 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1344 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1345 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1346 (gnus-treat-strip-trailing-blank-lines
1347 gnus-article-remove-trailing-blank-lines)
1348 (gnus-treat-strip-leading-blank-lines
1349 gnus-article-strip-leading-blank-lines)
1350 (gnus-treat-strip-multiple-blank-lines
1351 gnus-article-strip-multiple-blank-lines)
1352 (gnus-treat-overstrike gnus-article-treat-overstrike)
1353 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1354 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1355 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1356 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1357 (gnus-treat-display-smileys gnus-treat-smiley)
1358 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1359 (gnus-treat-wash-html gnus-article-wash-html)
1360 (gnus-treat-emphasize gnus-article-emphasize)
1361 (gnus-treat-hide-citation gnus-article-hide-citation)
1362 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1363 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1364 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1365 (gnus-treat-play-sounds gnus-earcon-display)))
1367 (defvar gnus-article-mime-handle-alist nil)
1368 (defvar article-lapsed-timer nil)
1369 (defvar gnus-article-current-summary nil)
1371 (defvar gnus-article-mode-syntax-table
1372 (let ((table (copy-syntax-table text-mode-syntax-table)))
1373 ;; This causes the citation match run O(2^n).
1374 ;; (modify-syntax-entry ?- "w" table)
1375 (modify-syntax-entry ?> ")<" table)
1376 (modify-syntax-entry ?< "(>" table)
1377 ;; make M-. in article buffers work for `foo' strings
1378 (modify-syntax-entry ?' " " table)
1379 (modify-syntax-entry ?` " " table)
1381 "Syntax table used in article mode buffers.
1382 Initialized from `text-mode-syntax-table.")
1384 (defvar gnus-save-article-buffer nil)
1386 (defvar gnus-article-mode-line-format-alist
1387 (nconc '((?w (gnus-article-wash-status) ?s)
1388 (?m (gnus-article-mime-part-status) ?s))
1389 gnus-summary-mode-line-format-alist))
1391 (defvar gnus-number-of-articles-to-be-saved nil)
1393 (defvar gnus-inhibit-hiding nil)
1395 ;;; Macros for dealing with the article buffer.
1397 (defmacro gnus-with-article-headers (&rest forms)
1399 (set-buffer gnus-article-buffer)
1401 (let ((buffer-read-only nil)
1402 (inhibit-point-motion-hooks t)
1403 (case-fold-search t))
1404 (article-narrow-to-head)
1407 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1408 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1410 (defmacro gnus-with-article-buffer (&rest forms)
1412 (set-buffer gnus-article-buffer)
1413 (let ((buffer-read-only nil))
1416 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1417 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1419 (defun gnus-article-goto-header (header)
1420 "Go to HEADER, which is a regular expression."
1421 (re-search-forward (concat "^\\(" header "\\):") nil t))
1423 (defsubst gnus-article-hide-text (b e props)
1424 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1425 (gnus-add-text-properties-when 'article-type nil b e props)
1426 (when (memq 'intangible props)
1428 (max (1- b) (point-min))
1429 b 'intangible (cddr (memq 'intangible props)))))
1431 (defsubst gnus-article-unhide-text (b e)
1432 "Remove hidden text properties from region between B and E."
1433 (remove-text-properties b e gnus-hidden-properties)
1434 (when (memq 'intangible gnus-hidden-properties)
1435 (put-text-property (max (1- b) (point-min))
1436 b 'intangible nil)))
1438 (defun gnus-article-hide-text-type (b e type)
1439 "Hide text of TYPE between B and E."
1440 (gnus-add-wash-type type)
1441 (gnus-article-hide-text
1442 b e (cons 'article-type (cons type gnus-hidden-properties))))
1444 (defun gnus-article-unhide-text-type (b e type)
1445 "Unhide text of TYPE between B and E."
1446 (gnus-delete-wash-type type)
1447 (remove-text-properties
1448 b e (cons 'article-type (cons type gnus-hidden-properties)))
1449 (when (memq 'intangible gnus-hidden-properties)
1450 (put-text-property (max (1- b) (point-min))
1451 b 'intangible nil)))
1453 (defun gnus-article-hide-text-of-type (type)
1454 "Hide text of TYPE in the current buffer."
1456 (let ((b (point-min))
1458 (while (setq b (text-property-any b e 'article-type type))
1459 (add-text-properties b (incf b) gnus-hidden-properties)))))
1461 (defun gnus-article-delete-text-of-type (type)
1462 "Delete text of TYPE in the current buffer."
1464 (let ((b (point-min)))
1465 (while (setq b (text-property-any b (point-max) 'article-type type))
1467 b (or (text-property-not-all b (point-max) 'article-type type)
1470 (defun gnus-article-delete-invisible-text ()
1471 "Delete all invisible text in the current buffer."
1473 (let ((b (point-min)))
1474 (while (setq b (text-property-any b (point-max) 'invisible t))
1476 b (or (text-property-not-all b (point-max) 'invisible t)
1479 (defun gnus-article-text-type-exists-p (type)
1480 "Say whether any text of type TYPE exists in the buffer."
1481 (text-property-any (point-min) (point-max) 'article-type type))
1483 (defsubst gnus-article-header-rank ()
1484 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1485 (let ((list gnus-sorted-header-list)
1488 (if (looking-at (car list))
1490 (setq list (cdr list))
1494 (defun article-hide-headers (&optional arg delete)
1495 "Hide unwanted headers and possibly sort them as well."
1497 ;; This function might be inhibited.
1498 (unless gnus-inhibit-hiding
1501 (let ((buffer-read-only nil)
1502 (case-fold-search t)
1503 (max (1+ (length gnus-sorted-header-list)))
1504 (ignored (when (not gnus-visible-headers)
1505 (cond ((stringp gnus-ignored-headers)
1506 gnus-ignored-headers)
1507 ((listp gnus-ignored-headers)
1508 (mapconcat 'identity gnus-ignored-headers
1511 (cond ((stringp gnus-visible-headers)
1512 gnus-visible-headers)
1513 ((and gnus-visible-headers
1514 (listp gnus-visible-headers))
1515 (mapconcat 'identity gnus-visible-headers "\\|"))))
1516 (inhibit-point-motion-hooks t)
1518 ;; First we narrow to just the headers.
1519 (article-narrow-to-head)
1520 ;; Hide any "From " lines at the beginning of (mail) articles.
1521 (while (looking-at "From ")
1524 (delete-region (point-min) (point)))
1525 ;; Then treat the rest of the header lines.
1526 ;; Then we use the two regular expressions
1527 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1528 ;; select which header lines is to remain visible in the
1530 (while (re-search-forward "^[^ \t:]*:" nil t)
1532 ;; Mark the rank of the header.
1534 (point) (1+ (point)) 'message-rank
1535 (if (or (and visible (looking-at visible))
1537 (not (looking-at ignored))))
1538 (gnus-article-header-rank)
1541 (message-sort-headers-1)
1542 (when (setq beg (text-property-any
1543 (point-min) (point-max) 'message-rank (+ 2 max)))
1544 ;; We delete the unwanted headers.
1545 (gnus-add-wash-type 'headers)
1546 (add-text-properties (point-min) (+ 5 (point-min))
1547 '(article-type headers dummy-invisible t))
1548 (delete-region beg (point-max))))))))
1550 (defun article-hide-boring-headers (&optional arg)
1551 "Toggle hiding of headers that aren't very interesting.
1552 If given a negative prefix, always show; if given a positive prefix,
1554 (interactive (gnus-article-hidden-arg))
1555 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1556 (not gnus-show-all-headers))
1559 (let ((buffer-read-only nil)
1560 (list gnus-boring-article-headers)
1561 (inhibit-point-motion-hooks t)
1563 (article-narrow-to-head)
1565 (setq elem (pop list))
1566 (goto-char (point-min))
1568 ;; Hide empty headers.
1570 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1572 (gnus-article-hide-text-type
1573 (progn (beginning-of-line) (point))
1576 (if (re-search-forward "^[^ \t]" nil t)
1580 ;; Hide boring Newsgroups header.
1581 ((eq elem 'newsgroups)
1582 (when (gnus-string-equal
1583 (gnus-fetch-field "newsgroups")
1584 (gnus-group-real-name
1585 (if (boundp 'gnus-newsgroup-name)
1588 (gnus-article-hide-header "newsgroups")))
1589 ((eq elem 'to-address)
1590 (let ((to (message-fetch-field "to"))
1592 (gnus-parameter-to-address
1593 (if (boundp 'gnus-newsgroup-name)
1594 gnus-newsgroup-name ""))))
1595 (when (and to to-address
1598 ;; only one address in To
1599 (nth 1 (mail-extract-address-components to))
1601 (gnus-article-hide-header "to"))))
1602 ((eq elem 'followup-to)
1603 (when (gnus-string-equal
1604 (message-fetch-field "followup-to")
1605 (message-fetch-field "newsgroups"))
1606 (gnus-article-hide-header "followup-to")))
1607 ((eq elem 'reply-to)
1608 (let ((from (message-fetch-field "from"))
1609 (reply-to (message-fetch-field "reply-to")))
1614 (nth 1 (mail-extract-address-components from))
1615 (nth 1 (mail-extract-address-components reply-to)))))
1616 (gnus-article-hide-header "reply-to"))))
1618 (let ((date (message-fetch-field "date")))
1620 (< (days-between (current-time-string) date)
1622 (gnus-article-hide-header "date"))))
1624 (let ((to (message-fetch-field "to"))
1625 (cc (message-fetch-field "cc")))
1626 (when (> (length to) 1024)
1627 (gnus-article-hide-header "to"))
1628 (when (> (length cc) 1024)
1629 (gnus-article-hide-header "cc"))))
1633 (goto-char (point-min))
1634 (while (re-search-forward "^to:" nil t)
1635 (setq to-count (1+ to-count)))
1636 (when (> to-count 1)
1637 (while (> to-count 0)
1638 (goto-char (point-min))
1640 (re-search-forward "^to:" nil nil to-count)
1642 (narrow-to-region (point) (point-max))
1643 (gnus-article-hide-header "to"))
1644 (setq to-count (1- to-count))))
1645 (goto-char (point-min))
1646 (while (re-search-forward "^cc:" nil t)
1647 (setq cc-count (1+ cc-count)))
1648 (when (> cc-count 1)
1649 (while (> cc-count 0)
1650 (goto-char (point-min))
1652 (re-search-forward "^cc:" nil nil cc-count)
1654 (narrow-to-region (point) (point-max))
1655 (gnus-article-hide-header "cc"))
1656 (setq cc-count (1- cc-count)))))))))))))
1658 (defun gnus-article-hide-header (header)
1660 (goto-char (point-min))
1661 (when (re-search-forward (concat "^" header ":") nil t)
1662 (gnus-article-hide-text-type
1663 (progn (beginning-of-line) (point))
1666 (if (re-search-forward "^[^ \t]" nil t)
1671 (defvar gnus-article-normalized-header-length 40
1672 "Length of normalized headers.")
1674 (defun article-normalize-headers ()
1675 "Make all header lines 40 characters long."
1677 (let ((buffer-read-only nil)
1681 (article-narrow-to-head)
1684 ((< (setq column (- (gnus-point-at-eol) (point)))
1685 gnus-article-normalized-header-length)
1687 (insert (make-string
1688 (- gnus-article-normalized-header-length column)
1690 ((> column gnus-article-normalized-header-length)
1691 (gnus-put-text-property
1693 (forward-char gnus-article-normalized-header-length)
1700 (forward-line 1))))))
1702 (defun article-treat-dumbquotes ()
1703 "Translate M****s*** sm*rtq**t*s into proper text.
1704 Note that this function guesses whether a character is a sm*rtq**t* or
1705 not, so it should only be used interactively.
1707 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1708 in an attempt to provide more quoting characters. If you see
1709 something like \\222 or \\264 where you're expecting some kind of
1710 apostrophe or quotation mark, then try this wash."
1712 (article-translate-strings gnus-article-dumbquotes-map))
1714 (defun article-translate-characters (from to)
1715 "Translate all characters in the body of the article according to FROM and TO.
1716 FROM is a string of characters to translate from; to is a string of
1717 characters to translate to."
1719 (when (article-goto-body)
1720 (let ((buffer-read-only nil)
1721 (x (make-string 225 ?x))
1723 (while (< (incf i) (length x))
1726 (while (< i (length from))
1727 (aset x (aref from i) (aref to i))
1729 (translate-region (point) (point-max) x)))))
1731 (defun article-translate-strings (map)
1732 "Translate all string in the body of the article according to MAP.
1733 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1735 (when (article-goto-body)
1736 (let ((buffer-read-only nil)
1738 (while (setq elem (pop map))
1740 (while (search-forward (car elem) nil t)
1741 (replace-match (cadr elem)))))))))
1743 (defun article-treat-overstrike ()
1744 "Translate overstrikes into bold text."
1747 (when (article-goto-body)
1748 (let ((buffer-read-only nil))
1749 (while (search-forward "\b" nil t)
1750 (let ((next (char-after))
1751 (previous (char-after (- (point) 2))))
1752 ;; We do the boldification/underlining by hiding the
1753 ;; overstrikes and putting the proper text property
1757 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1758 (put-text-property (point) (1+ (point)) 'face 'bold))
1760 (gnus-article-hide-text-type
1761 (1- (point)) (1+ (point)) 'overstrike)
1763 (- (point) 2) (1- (point)) 'face 'underline))
1765 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1767 (point) (1+ (point)) 'face 'underline)))))))))
1769 (defun gnus-article-treat-unfold-headers ()
1770 "Unfold folded message headers.
1771 Only the headers that fit into the current window width will be
1774 (gnus-with-article-headers
1778 (mail-header-narrow-to-field)
1779 (let ((header (buffer-substring (point-min) (point-max))))
1782 (goto-char (point-min))
1783 (while (re-search-forward "\n[\t ]" nil t)
1784 (replace-match " " t t)))
1785 (setq length (- (point-max) (point-min) 1)))
1786 (when (< length (window-width))
1787 (while (re-search-forward "\n[\t ]" nil t)
1788 (replace-match " " t t)))
1789 (goto-char (point-max)))))))
1791 (defun gnus-article-treat-fold-headers ()
1792 "Fold message headers."
1794 (gnus-with-article-headers
1797 (mail-header-narrow-to-field)
1798 (mail-header-fold-field)
1799 (goto-char (point-max))))))
1801 (defun gnus-treat-smiley ()
1802 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1804 (gnus-with-article-buffer
1805 (if (memq 'smiley gnus-article-wash-types)
1806 (gnus-delete-images 'smiley)
1808 (let ((images (smiley-region (point) (point-max))))
1810 (gnus-add-wash-type 'smiley)
1811 (dolist (image images)
1812 (gnus-add-image 'smiley image)))))))
1814 (defun gnus-article-remove-images ()
1815 "Remove all images from the article buffer."
1817 (gnus-with-article-buffer
1818 (dolist (elem gnus-article-image-alist)
1819 (gnus-delete-images (car elem)))))
1821 (defun gnus-article-treat-fold-newsgroups ()
1822 "Unfold folded message headers.
1823 Only the headers that fit into the current window width will be
1826 (gnus-with-article-headers
1827 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1829 (mail-header-narrow-to-field)
1830 (while (re-search-forward ", *" nil t)
1831 (replace-match ", " t t))
1832 (mail-header-fold-field)
1833 (goto-char (point-max))))))
1835 (defun gnus-article-treat-body-boundary ()
1836 "Place a boundary line at the end of the headers."
1838 (when (and gnus-body-boundary-delimiter
1839 (> (length gnus-body-boundary-delimiter) 0))
1840 (gnus-with-article-headers
1841 (goto-char (point-max))
1842 (let ((start (point)))
1843 (insert "X-Boundary: ")
1844 (gnus-add-text-properties start (point) '(invisible t intangible t))
1846 (while (>= (1- (window-width)) (length str))
1847 (setq str (concat str gnus-body-boundary-delimiter)))
1848 (substring str 0 (1- (window-width))))
1850 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1852 (defun article-fill-long-lines ()
1853 "Fill lines that are wider than the window width."
1856 (let ((buffer-read-only nil)
1857 (width (window-width (get-buffer-window (current-buffer)))))
1860 (let ((adaptive-fill-mode nil)) ;Why? -sm
1863 (when (>= (current-column) (min fill-column width))
1864 (narrow-to-region (min (1+ (point)) (point-max)) (gnus-point-at-bol))
1865 (let ((goback (point-marker)))
1866 (fill-paragraph nil)
1867 (goto-char (marker-position goback)))
1869 (forward-line 1)))))))
1871 (defun article-capitalize-sentences ()
1872 "Capitalize the first word in each sentence."
1875 (let ((buffer-read-only nil)
1876 (paragraph-start "^[\n\^L]"))
1880 (forward-sentence)))))
1882 (defun article-remove-cr ()
1883 "Remove trailing CRs and then translate remaining CRs into LFs."
1886 (let ((buffer-read-only nil))
1887 (goto-char (point-min))
1888 (while (re-search-forward "\r+$" nil t)
1889 (replace-match "" t t))
1890 (goto-char (point-min))
1891 (while (search-forward "\r" nil t)
1892 (replace-match "\n" t t)))))
1894 (defun article-remove-trailing-blank-lines ()
1895 "Remove all trailing blank lines from the article."
1898 (let ((buffer-read-only nil))
1899 (goto-char (point-max))
1903 (while (and (not (bobp))
1904 (looking-at "^[ \t]*$")
1905 (not (gnus-annotation-in-region-p
1906 (point) (gnus-point-at-eol))))
1911 (defun article-display-x-face (&optional force)
1912 "Look for an X-Face header and display it if present."
1913 (interactive (list 'force))
1914 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1915 (gnus-with-article-headers
1916 ;; Delete the old process, if any.
1917 (when (process-status "article-x-face")
1918 (delete-process "article-x-face"))
1919 (if (memq 'xface gnus-article-wash-types)
1920 ;; We have already displayed X-Faces, so we remove them
1922 (gnus-delete-images 'xface)
1924 (let (x-faces from face grey)
1926 (when (and wash-face-p
1928 (goto-char (point-min))
1929 (not (re-search-forward
1930 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
1931 (gnus-buffer-live-p gnus-original-article-buffer))
1932 ;; If type `W f', use gnus-original-article-buffer,
1933 ;; otherwise use the current buffer because displaying
1934 ;; RFC822 parts calls this function too.
1935 (set-buffer gnus-original-article-buffer))
1937 (mail-narrow-to-head)
1938 (if gnus-treat-display-grey-xface
1940 (while (gnus-article-goto-header "X-Face\\(-[0-9]+\\)?")
1941 (if (match-beginning 2)
1944 (push (cons (- (string-to-number (match-string 2)))
1945 (mail-header-field-value))
1947 (push (cons 0 (mail-header-field-value)) x-faces)))
1948 (dolist (x-face (prog1
1950 (sort x-faces 'car-less-than-car)
1952 (setq x-faces nil)))
1953 (push (cdr x-face) x-faces)))
1954 (while (gnus-article-goto-header "X-Face")
1955 (push (mail-header-field-value) x-faces)))
1956 (setq from (message-fetch-field "from"))))
1958 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
1961 (setq image (gnus-create-image xpm 'xpm t))
1962 (gnus-article-goto-header "from")
1964 (insert "From: [no `from' set]\n")
1966 (gnus-add-wash-type 'xface)
1967 (gnus-add-image 'xface image)
1968 (gnus-put-image image)))
1969 ;; Sending multiple EOFs to xv doesn't work, so we only do a
1970 ;; single external face.
1971 (when (stringp gnus-article-x-face-command)
1972 (setq x-faces (list (car x-faces))))
1973 (while (and (setq face (pop x-faces))
1974 gnus-article-x-face-command
1976 ;; Check whether this face is censored.
1977 (not gnus-article-x-face-too-ugly)
1978 (and gnus-article-x-face-too-ugly from
1979 (not (string-match gnus-article-x-face-too-ugly
1981 ;; We display the face.
1982 (if (symbolp gnus-article-x-face-command)
1983 ;; The command is a lisp function, so we call it.
1984 (if (gnus-functionp gnus-article-x-face-command)
1985 (funcall gnus-article-x-face-command face)
1986 (error "%s is not a function" gnus-article-x-face-command))
1987 ;; The command is a string, so we interpret the command
1988 ;; as a, well, command, and fork it off.
1989 (let ((process-connection-type nil))
1990 (process-kill-without-query
1992 "article-x-face" nil shell-file-name shell-command-switch
1993 gnus-article-x-face-command))
1996 (process-send-region "article-x-face"
1997 (point-min) (point-max)))
1998 (process-send-eof "article-x-face"))))))))))
2000 (defun article-decode-mime-words ()
2001 "Decode all MIME-encoded words in the article."
2004 (set-buffer gnus-article-buffer)
2005 (let ((inhibit-point-motion-hooks t)
2007 (mail-parse-charset gnus-newsgroup-charset)
2008 (mail-parse-ignored-charsets
2009 (save-excursion (set-buffer gnus-summary-buffer)
2010 gnus-newsgroup-ignored-charsets)))
2011 (mail-decode-encoded-word-region (point-min) (point-max)))))
2013 (defun article-decode-charset (&optional prompt)
2014 "Decode charset-encoded text in the article.
2015 If PROMPT (the prefix), prompt for a coding system to use."
2017 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2019 (mail-parse-charset gnus-newsgroup-charset)
2020 (mail-parse-ignored-charsets
2021 (save-excursion (condition-case nil
2022 (set-buffer gnus-summary-buffer)
2024 gnus-newsgroup-ignored-charsets))
2025 ct cte ctl charset format)
2028 (article-narrow-to-head)
2029 (setq ct (message-fetch-field "Content-Type" t)
2030 cte (message-fetch-field "Content-Transfer-Encoding" t)
2031 ctl (and ct (ignore-errors
2032 (mail-header-parse-content-type ct)))
2035 (mm-read-coding-system "Charset to decode: "))
2037 (mail-content-type-get ctl 'charset)))
2038 format (and ctl (mail-content-type-get ctl 'format)))
2040 (setq cte (mail-header-strip cte)))
2041 (if (and ctl (not (string-match "/" (car ctl))))
2043 (goto-char (point-max)))
2046 (narrow-to-region (point) (point-max))
2047 (when (and (eq mail-parse-charset 'gnus-decoded)
2048 (eq (mm-body-7-or-8) '8bit))
2049 ;; The text code could have been decoded.
2050 (setq charset mail-parse-charset))
2051 (when (and (or (not ctl)
2052 (equal (car ctl) "text/plain"))
2053 (not format)) ;; article with format will decode later.
2055 charset (and cte (intern (downcase
2056 (gnus-strip-whitespace cte))))
2059 (defun article-decode-encoded-words ()
2060 "Remove encoded-word encoding from headers."
2061 (let ((inhibit-point-motion-hooks t)
2062 (mail-parse-charset gnus-newsgroup-charset)
2063 (mail-parse-ignored-charsets
2064 (save-excursion (condition-case nil
2065 (set-buffer gnus-summary-buffer)
2067 gnus-newsgroup-ignored-charsets))
2070 (article-narrow-to-head)
2071 (funcall gnus-decode-header-function (point-min) (point-max)))))
2073 (defun article-decode-group-name ()
2074 "Decode group names in `Newsgroups:'."
2075 (let ((inhibit-point-motion-hooks t)
2077 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2078 (when (and (or gnus-group-name-charset-method-alist
2079 gnus-group-name-charset-group-alist)
2080 (gnus-buffer-live-p gnus-original-article-buffer))
2081 (when (nnmail-fetch-field "Newsgroups")
2082 (nnheader-replace-header "Newsgroups"
2083 (gnus-decode-newsgroups
2084 (with-current-buffer
2085 gnus-original-article-buffer
2086 (nnmail-fetch-field "Newsgroups"))
2087 gnus-newsgroup-name method)))
2088 (when (nnmail-fetch-field "Followup-To")
2089 (nnheader-replace-header "Followup-To"
2090 (gnus-decode-newsgroups
2091 (with-current-buffer
2092 gnus-original-article-buffer
2093 (nnmail-fetch-field "Followup-To"))
2094 gnus-newsgroup-name method))))))
2096 (defun article-de-quoted-unreadable (&optional force read-charset)
2097 "Translate a quoted-printable-encoded article.
2098 If FORCE, decode the article whether it is marked as quoted-printable
2100 If READ-CHARSET, ask for a coding system."
2101 (interactive (list 'force current-prefix-arg))
2103 (let ((buffer-read-only nil) type charset)
2104 (if (gnus-buffer-live-p gnus-original-article-buffer)
2105 (with-current-buffer gnus-original-article-buffer
2107 (gnus-fetch-field "content-transfer-encoding"))
2108 (let* ((ct (gnus-fetch-field "content-type"))
2111 (mail-header-parse-content-type ct)))))
2112 (setq charset (and ctl
2113 (mail-content-type-get ctl 'charset)))
2114 (if (stringp charset)
2115 (setq charset (intern (downcase charset)))))))
2117 (setq charset (mm-read-coding-system "Charset: " charset)))
2119 (setq charset gnus-newsgroup-charset))
2121 (and type (let ((case-fold-search t))
2122 (string-match "quoted-printable" type))))
2124 (quoted-printable-decode-region
2125 (point) (point-max) (mm-charset-to-coding-system charset))))))
2127 (defun article-de-base64-unreadable (&optional force read-charset)
2128 "Translate a base64 article.
2129 If FORCE, decode the article whether it is marked as base64 not.
2130 If READ-CHARSET, ask for a coding system."
2131 (interactive (list 'force current-prefix-arg))
2133 (let ((buffer-read-only nil) type charset)
2134 (if (gnus-buffer-live-p gnus-original-article-buffer)
2135 (with-current-buffer gnus-original-article-buffer
2137 (gnus-fetch-field "content-transfer-encoding"))
2138 (let* ((ct (gnus-fetch-field "content-type"))
2141 (mail-header-parse-content-type ct)))))
2142 (setq charset (and ctl
2143 (mail-content-type-get ctl 'charset)))
2144 (if (stringp charset)
2145 (setq charset (intern (downcase charset)))))))
2147 (setq charset (mm-read-coding-system "Charset: " charset)))
2149 (setq charset gnus-newsgroup-charset))
2151 (and type (let ((case-fold-search t))
2152 (string-match "base64" type))))
2155 (narrow-to-region (point) (point-max))
2156 (base64-decode-region (point-min) (point-max))
2157 (mm-decode-coding-region
2158 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2163 (defun article-decode-HZ ()
2164 "Translate a HZ-encoded article."
2168 (let ((buffer-read-only nil))
2169 (rfc1843-decode-region (point-min) (point-max)))))
2171 (defun article-unsplit-urls ()
2172 "Remove the newlines that some other mailers insert into URLs."
2175 (let ((buffer-read-only nil))
2176 (goto-char (point-min))
2177 (while (re-search-forward
2178 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2179 (replace-match "\\1\\3" t)))
2180 (when (and gnus-display-mime-function (interactive-p))
2181 (funcall gnus-display-mime-function))))
2184 (defun article-wash-html (&optional read-charset)
2185 "Format an HTML article.
2186 If READ-CHARSET, ask for a coding system."
2189 (let ((buffer-read-only nil)
2191 (when (gnus-buffer-live-p gnus-original-article-buffer)
2192 (with-current-buffer gnus-original-article-buffer
2193 (let* ((ct (gnus-fetch-field "content-type"))
2196 (mail-header-parse-content-type ct)))))
2197 (setq charset (and ctl
2198 (mail-content-type-get ctl 'charset)))
2199 (when (stringp charset)
2200 (setq charset (intern (downcase charset)))))))
2202 (setq charset (mm-read-coding-system "Charset: " charset)))
2204 (setq charset gnus-newsgroup-charset))
2206 (save-window-excursion
2208 (narrow-to-region (point) (point-max))
2209 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2210 (entry (assq func mm-text-html-washer-alist)))
2212 (setq func (cdr entry)))
2214 ((gnus-functionp func)
2217 (apply (car func) (cdr func))))))))))
2219 (defun gnus-article-wash-html-with-w3 ()
2220 "Wash the current buffer with w3."
2222 (let ((w3-strict-width (window-width))
2223 (url-standalone-mode t)
2224 (url-gateway-unplugged t)
2225 (w3-honor-stylesheets nil))
2227 (w3-region (point-min) (point-max))
2230 (defun gnus-article-wash-html-with-w3m ()
2231 "Wash the current buffer with emacs-w3m."
2234 (narrow-to-region (point) (point-max))
2235 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2238 (w3m-display-inline-images mm-inline-text-html-with-images)
2239 w3m-force-redisplay)
2240 (w3m-region (point-min) (point-max)))
2241 (when mm-inline-text-html-with-w3m-keymap
2242 (add-text-properties
2243 (point-min) (point-max)
2244 (nconc (mm-w3m-local-map-property)
2245 '(mm-inline-text-html-with-w3m t))))))
2247 (defun article-hide-list-identifiers ()
2248 "Remove list identifies from the Subject header.
2249 The `gnus-list-identifiers' variable specifies what to do."
2251 (let ((inhibit-point-motion-hooks t)
2252 (regexp (if (consp gnus-list-identifiers)
2253 (mapconcat 'identity gnus-list-identifiers " *\\|")
2254 gnus-list-identifiers))
2259 (article-narrow-to-head)
2260 (goto-char (point-min))
2261 (while (re-search-forward
2262 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2264 (delete-region (match-beginning 2) (match-end 0))
2265 (beginning-of-line))
2266 (when (re-search-forward
2267 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2268 (delete-region (match-beginning 1) (match-end 1))))))))
2270 (defun article-hide-pgp ()
2271 "Remove any PGP headers and signatures in the current article."
2275 (let ((inhibit-point-motion-hooks t)
2276 buffer-read-only beg end)
2278 ;; Hide the "header".
2279 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2280 (gnus-add-wash-type 'pgp)
2281 (delete-region (match-beginning 0) (match-end 0))
2282 ;; Remove armor headers (rfc2440 6.2)
2283 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2286 ;; Hide the actual signature.
2287 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2288 (setq end (1+ (match-beginning 0)))
2291 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2293 ;; Perhaps we shouldn't hide to the end of the buffer
2294 ;; if there is no end to the signature?
2296 ;; Hide "- " PGP quotation markers.
2298 (narrow-to-region beg end)
2299 (goto-char (point-min))
2300 (while (re-search-forward "^- " nil t)
2302 (match-beginning 0) (match-end 0)))
2304 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2306 (defun article-hide-pem (&optional arg)
2307 "Toggle hiding of any PEM headers and signatures in the current article.
2308 If given a negative prefix, always show; if given a positive prefix,
2310 (interactive (gnus-article-hidden-arg))
2311 (unless (gnus-article-check-hidden-text 'pem arg)
2313 (let (buffer-read-only end)
2314 (goto-char (point-min))
2315 ;; Hide the horrendously ugly "header".
2316 (when (and (search-forward
2317 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2319 (setq end (1+ (match-beginning 0))))
2320 (gnus-add-wash-type 'pem)
2321 (gnus-article-hide-text-type
2323 (if (search-forward "\n\n" nil t)
2327 ;; Hide the trailer as well
2328 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2330 (gnus-article-hide-text-type
2331 (match-beginning 0) (match-end 0) 'pem)))))))
2333 (defun article-strip-banner ()
2334 "Strip the banner specified by the `banner' group parameter."
2338 (let ((inhibit-point-motion-hooks t)
2339 (banner (gnus-parameter-banner gnus-newsgroup-name))
2340 (gnus-signature-limit nil)
2341 buffer-read-only beg end)
2342 (when (and gnus-article-address-banner-alist
2345 (let ((from (save-restriction
2347 (article-narrow-to-head)
2348 (mail-fetch-field "from"))))
2351 (caar (mail-header-parse-addresses from))))
2353 (dolist (pair gnus-article-address-banner-alist)
2354 (when (string-match (car pair) from)
2355 (throw 'found (cdr pair)))))))))
2359 ((eq banner 'signature)
2360 (when (gnus-article-narrow-to-signature)
2363 (delete-region (point) (point-max))))
2365 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2366 (while (re-search-forward banner nil t)
2367 (delete-region (match-beginning 0) (match-end 0)))))
2369 (while (re-search-forward banner nil t)
2370 (delete-region (match-beginning 0) (match-end 0))))))))))
2372 (defun article-babel ()
2373 "Translate article using an online translation service."
2377 (set-buffer gnus-article-buffer)
2378 (when (article-goto-body)
2379 (let* ((buffer-read-only nil)
2382 (orig (buffer-substring start end))
2383 (trans (babel-as-string orig)))
2385 (narrow-to-region start end)
2386 (delete-region start end)
2389 (defun article-hide-signature (&optional arg)
2390 "Hide the signature in the current article.
2391 If given a negative prefix, always show; if given a positive prefix,
2393 (interactive (gnus-article-hidden-arg))
2394 (unless (gnus-article-check-hidden-text 'signature arg)
2397 (let ((buffer-read-only nil))
2398 (when (gnus-article-narrow-to-signature)
2399 (gnus-article-hide-text-type
2400 (point-min) (point-max) 'signature))))))
2401 (gnus-set-mode-line 'article))
2403 (defun article-strip-headers-in-body ()
2404 "Strip offensive headers from bodies."
2408 (let ((case-fold-search t))
2409 (when (looking-at "x-no-archive:")
2410 (gnus-delete-line)))))
2412 (defun article-strip-leading-blank-lines ()
2413 "Remove all blank lines from the beginning of the article."
2416 (let ((inhibit-point-motion-hooks t)
2418 (when (article-goto-body)
2419 (while (and (not (eobp))
2420 (looking-at "[ \t]*$"))
2421 (gnus-delete-line))))))
2423 (defun article-narrow-to-head ()
2424 "Narrow the buffer to the head of the message.
2425 Point is left at the beginning of the narrowed-to region."
2427 (goto-char (point-min))
2428 (if (search-forward "\n\n" nil 1)
2431 (goto-char (point-min)))
2433 (defun article-goto-body ()
2434 "Place point at the start of the body."
2435 (goto-char (point-min))
2437 ;; This variable is only bound when dealing with separate
2439 (article-goto-body-goes-to-point-min-p
2441 ((search-forward "\n\n" nil t)
2444 (goto-char (point-max))
2447 (defun article-strip-multiple-blank-lines ()
2448 "Replace consecutive blank lines with one empty line."
2451 (let ((inhibit-point-motion-hooks t)
2453 ;; First make all blank lines empty.
2455 (while (re-search-forward "^[ \t]+$" nil t)
2456 (unless (gnus-annotation-in-region-p
2457 (match-beginning 0) (match-end 0))
2458 (replace-match "" nil t)))
2459 ;; Then replace multiple empty lines with a single empty line.
2461 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2462 (unless (gnus-annotation-in-region-p
2463 (match-beginning 0) (match-end 0))
2464 (delete-region (match-beginning 1) (match-end 1)))))))
2466 (defun article-strip-leading-space ()
2467 "Remove all white space from the beginning of the lines in the article."
2470 (let ((inhibit-point-motion-hooks t)
2473 (while (re-search-forward "^[ \t]+" nil t)
2474 (replace-match "" t t)))))
2476 (defun article-strip-trailing-space ()
2477 "Remove all white space from the end of the lines in the article."
2480 (let ((inhibit-point-motion-hooks t)
2483 (while (re-search-forward "[ \t]+$" nil t)
2484 (replace-match "" t t)))))
2486 (defun article-strip-blank-lines ()
2487 "Strip leading, trailing and multiple blank lines."
2489 (article-strip-leading-blank-lines)
2490 (article-remove-trailing-blank-lines)
2491 (article-strip-multiple-blank-lines))
2493 (defun article-strip-all-blank-lines ()
2494 "Strip all blank lines."
2497 (let ((inhibit-point-motion-hooks t)
2500 (while (re-search-forward "^[ \t]*\n" nil t)
2501 (replace-match "" t t)))))
2503 (defun gnus-article-narrow-to-signature ()
2504 "Narrow to the signature; return t if a signature is found, else nil."
2505 (let ((inhibit-point-motion-hooks t))
2506 (when (gnus-article-search-signature)
2508 ;; Check whether we have some limits to what we consider
2509 ;; to be a signature.
2510 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2511 (list gnus-signature-limit)))
2513 (while (setq limit (pop limits))
2514 (if (or (and (integerp limit)
2515 (< (- (point-max) (point)) limit))
2517 (< (count-lines (point) (point-max)) limit))
2518 (and (gnus-functionp limit)
2520 (and (stringp limit)
2521 (not (re-search-forward limit nil t))))
2522 () ; This limit did not succeed.
2526 (narrow-to-region (point) (point-max))
2529 (defun gnus-article-search-signature ()
2530 "Search the current buffer for the signature separator.
2531 Put point at the beginning of the signature separator."
2532 (let ((cur (point)))
2533 (goto-char (point-max))
2534 (if (if (stringp gnus-signature-separator)
2535 (re-search-backward gnus-signature-separator nil t)
2536 (let ((seps gnus-signature-separator))
2538 (not (re-search-backward (car seps) nil t)))
2545 (defun gnus-article-hidden-arg ()
2546 "Return the current prefix arg as a number, or 0 if no prefix."
2547 (list (if current-prefix-arg
2548 (prefix-numeric-value current-prefix-arg)
2551 (defun gnus-article-check-hidden-text (type arg)
2552 "Return nil if hiding is necessary.
2553 Arg can be nil or a number. nil and positive means hide, negative
2554 means show, 0 means toggle."
2557 (let ((hide (gnus-article-hidden-text-p type)))
2563 (gnus-article-show-hidden-text type)
2566 (if (eq hide 'hidden)
2568 (gnus-article-show-hidden-text type)
2572 (defun gnus-article-hidden-text-p (type)
2573 "Say whether the current buffer contains hidden text of type TYPE."
2574 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2576 (not (get-text-property pos 'invisible))
2577 (not (get-text-property pos 'dummy-invisible)))
2579 (text-property-any (1+ pos) (point-max) 'article-type type)))
2584 (defun gnus-article-show-hidden-text (type &optional dummy)
2585 "Show all hidden text of type TYPE.
2586 Originally it is hide instead of DUMMY."
2587 (let ((buffer-read-only nil)
2588 (inhibit-point-motion-hooks t))
2589 (gnus-remove-text-properties-when
2591 (point-min) (point-max)
2592 (cons 'article-type (cons type
2593 gnus-hidden-properties)))
2594 (gnus-delete-wash-type type)))
2596 (defconst article-time-units
2597 `((year . ,(* 365.25 24 60 60))
2598 (week . ,(* 7 24 60 60))
2599 (day . ,(* 24 60 60))
2603 "Mapping from time units to seconds.")
2605 (defun gnus-article-forward-header ()
2606 "Move point to the start of the next header.
2607 If the current header is a continuation header, this can be several
2612 (if (looking-at "[ \t]+[^ \t]")
2616 (defun article-date-ut (&optional type highlight header)
2617 "Convert DATE date to universal time in the current article.
2618 If TYPE is `local', convert to local time; if it is `lapsed', output
2619 how much time has lapsed since DATE. For `lapsed', the value of
2620 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2621 should replace the \"Date:\" one, or should be added below it."
2622 (interactive (list 'ut t))
2623 (let* ((header (or header
2624 (message-fetch-field "date")
2626 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2629 ((not gnus-article-date-lapsed-new-header)
2635 (date (if (vectorp header) (mail-header-date header)
2637 (inhibit-point-motion-hooks t)
2642 (article-narrow-to-head)
2643 (when (re-search-forward tdate-regexp nil t)
2644 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2645 date (or (get-text-property (gnus-point-at-bol)
2648 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2650 (when (and date (not (string= date "")))
2651 (goto-char (point-min))
2652 (let ((buffer-read-only nil))
2653 ;; Delete any old Date headers.
2654 (while (re-search-forward date-regexp nil t)
2656 (delete-region (progn (beginning-of-line) (point))
2657 (progn (gnus-article-forward-header)
2659 (delete-region (progn (beginning-of-line) (point))
2660 (progn (gnus-article-forward-header)
2663 (setq pos (point))))
2664 (when (and (not pos)
2665 (re-search-forward tdate-regexp nil t))
2669 (insert (article-make-date-line date (or type 'ut)))
2675 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2676 (put-text-property (match-beginning 1) (1+ (match-end 1))
2677 'original-date date)
2678 (put-text-property (match-beginning 1) (1+ (match-end 1))
2680 (put-text-property (match-beginning 2) (match-end 2)
2683 (defun article-make-date-line (date type)
2684 "Return a DATE line of TYPE."
2685 (unless (memq type '(local ut original user iso8601 lapsed english))
2686 (error "Unknown conversion type: %s" type))
2688 (let ((time (date-to-time date)))
2690 ;; Convert to the local timezone.
2692 (let ((tz (car (current-time-zone time))))
2693 (format "Date: %s %s%02d%02d" (current-time-string time)
2694 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2695 (/ (% (abs tz) 3600) 60))))
2696 ;; Convert to Universal Time.
2699 (current-time-string
2700 (let* ((e (parse-time-string date))
2701 (tm (apply 'encode-time e))
2703 (ls (- (cadr tm) (car (current-time-zone time)))))
2704 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2705 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2708 ;; Get the original date from the article.
2709 ((eq type 'original)
2710 (concat "Date: " (if (string-match "\n+$" date)
2711 (substring date 0 (match-beginning 0))
2713 ;; Let the user define the format.
2715 (let ((format (or (condition-case nil
2716 (with-current-buffer gnus-summary-buffer
2717 gnus-article-time-format)
2719 gnus-article-time-format)))
2720 (if (gnus-functionp format)
2721 (funcall format time)
2722 (concat "Date: " (format-time-string format time)))))
2725 (let ((tz (car (current-time-zone time))))
2728 (format-time-string "%Y%m%dT%H%M%S" time)
2729 (format "%s%02d%02d"
2730 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2731 (/ (% (abs tz) 3600) 60)))))
2732 ;; Do an X-Sent lapsed format.
2734 ;; If the date is seriously mangled, the timezone functions are
2735 ;; liable to bug out, so we ignore all errors.
2736 (let* ((now (current-time))
2737 (real-time (subtract-time now time))
2738 (real-sec (and real-time
2739 (+ (* (float (car real-time)) 65536)
2741 (sec (and real-time (abs real-sec)))
2751 ;; This is a bit convoluted, but basically we go
2752 ;; through the time units for years, weeks, etc,
2753 ;; and divide things to see whether that results
2754 ;; in positive answers.
2757 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2758 ;; The (remaining) seconds are too few to
2759 ;; be divided into this time unit.
2761 ;; It's big enough, so we output it.
2762 (setq sec (- sec (* num (cdr unit))))
2764 (concat (if prev ", " "") (int-to-string
2766 " " (symbol-name (car unit))
2767 (if (> num 1) "s" ""))
2769 article-time-units "")
2770 ;; If dates are odd, then it might appear like the
2771 ;; article was sent in the future.
2774 " in the future"))))))
2775 ;; Display the date in proper English
2777 (let ((dtime (decode-time time)))
2780 (number-to-string (nth 3 dtime))
2781 (let ((digit (% (nth 3 dtime) 10)))
2783 ((memq (nth 3 dtime) '(11 12 13)) "th")
2789 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2791 (number-to-string (nth 5 dtime))
2793 (format "%02d" (nth 2 dtime))
2795 (format "%02d" (nth 1 dtime)))))))
2797 (format "Date: %s (from Gnus)" date))))
2799 (defun article-date-local (&optional highlight)
2800 "Convert the current article date to the local timezone."
2801 (interactive (list t))
2802 (article-date-ut 'local highlight))
2804 (defun article-date-english (&optional highlight)
2805 "Convert the current article date to something that is proper English."
2806 (interactive (list t))
2807 (article-date-ut 'english highlight))
2809 (defun article-date-original (&optional highlight)
2810 "Convert the current article date to what it was originally.
2811 This is only useful if you have used some other date conversion
2812 function and want to see what the date was before converting."
2813 (interactive (list t))
2814 (article-date-ut 'original highlight))
2816 (defun article-date-lapsed (&optional highlight)
2817 "Convert the current article date to time lapsed since it was sent."
2818 (interactive (list t))
2819 (article-date-ut 'lapsed highlight))
2821 (defun article-update-date-lapsed ()
2822 "Function to be run from a timer to update the lapsed time line."
2823 (let (deactivate-mark)
2828 (set-buffer (window-buffer w))
2829 (when (eq major-mode 'gnus-article-mode)
2830 (goto-char (point-min))
2831 (when (re-search-forward "^X-Sent:" nil t)
2832 (article-date-lapsed t))))
2835 (defun gnus-start-date-timer (&optional n)
2836 "Start a timer to update the X-Sent header in the article buffers.
2837 The numerical prefix says how frequently (in seconds) the function
2842 (gnus-stop-date-timer)
2843 (setq article-lapsed-timer
2844 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2846 (defun gnus-stop-date-timer ()
2847 "Stop the X-Sent timer."
2849 (when article-lapsed-timer
2850 (nnheader-cancel-timer article-lapsed-timer)
2851 (setq article-lapsed-timer nil)))
2853 (defun article-date-user (&optional highlight)
2854 "Convert the current article date to the user-defined format.
2855 This format is defined by the `gnus-article-time-format' variable."
2856 (interactive (list t))
2857 (article-date-ut 'user highlight))
2859 (defun article-date-iso8601 (&optional highlight)
2860 "Convert the current article date to ISO8601."
2861 (interactive (list t))
2862 (article-date-ut 'iso8601 highlight))
2864 ;; (defun article-show-all ()
2865 ;; "Show all hidden text in the article buffer."
2868 ;; (let ((buffer-read-only nil))
2869 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2871 (defun article-remove-leading-whitespace ()
2872 "Remove excessive whitespace from all headers."
2876 (let ((buffer-read-only nil))
2877 (article-narrow-to-head)
2878 (goto-char (point-min))
2879 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2880 (delete-region (match-beginning 1) (match-end 1)))))))
2882 (defun article-emphasize (&optional arg)
2883 "Emphasize text according to `gnus-emphasis-alist'."
2884 (interactive (gnus-article-hidden-arg))
2885 (unless (gnus-article-check-hidden-text 'emphasis arg)
2889 (with-current-buffer gnus-summary-buffer
2890 gnus-article-emphasis-alist)
2892 gnus-emphasis-alist))
2893 (buffer-read-only nil)
2894 (props (append '(article-type emphasis)
2895 gnus-hidden-properties))
2896 regexp elem beg invisible visible face)
2899 (while (setq elem (pop alist))
2901 (setq regexp (car elem)
2902 invisible (nth 1 elem)
2903 visible (nth 2 elem)
2905 (while (re-search-forward regexp nil t)
2906 (when (and (match-beginning visible) (match-beginning invisible))
2907 (gnus-article-hide-text
2908 (match-beginning invisible) (match-end invisible) props)
2909 (gnus-article-unhide-text-type
2910 (match-beginning visible) (match-end visible) 'emphasis)
2911 (gnus-put-overlay-excluding-newlines
2912 (match-beginning visible) (match-end visible) 'face face)
2913 (gnus-add-wash-type 'emphasis)
2914 (goto-char (match-end invisible)))))))))
2916 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2917 "Setup newsgroup emphasis alist."
2918 (unless gnus-article-emphasis-alist
2919 (let ((name (and gnus-newsgroup-name
2920 (gnus-group-real-name gnus-newsgroup-name))))
2921 (make-local-variable 'gnus-article-emphasis-alist)
2922 (setq gnus-article-emphasis-alist
2924 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2925 (while (setq elem (pop alist))
2926 (when (and name (string-match (car elem) name))
2928 highlight (copy-sequence (cdr elem)))))
2930 (copy-sequence highlight-words)
2931 (if gnus-newsgroup-name
2932 (copy-sequence (gnus-group-find-parameter
2933 gnus-newsgroup-name 'highlight-words t)))
2934 gnus-emphasis-alist)))))
2937 (defvar gnus-summary-article-menu)
2938 (defvar gnus-summary-post-menu))
2940 ;;; Saving functions.
2942 (defun gnus-article-save (save-buffer file &optional num)
2943 "Save the currently selected article."
2944 (unless gnus-save-all-headers
2945 ;; Remove headers according to `gnus-saved-headers'.
2946 (let ((gnus-visible-headers
2947 (or gnus-saved-headers gnus-visible-headers))
2948 (gnus-article-buffer save-buffer))
2950 (set-buffer save-buffer)
2951 (article-hide-headers 1 t))))
2952 (save-window-excursion
2953 (if (not gnus-default-article-saver)
2954 (error "No default saver is defined")
2955 ;; !!! Magic! The saving functions all save
2956 ;; `gnus-save-article-buffer' (or so they think), but we
2957 ;; bind that variable to our save-buffer.
2958 (set-buffer gnus-article-buffer)
2959 (let* ((gnus-save-article-buffer save-buffer)
2962 ((not gnus-prompt-before-saving) 'default)
2963 ((eq gnus-prompt-before-saving 'always) nil)
2965 (gnus-number-of-articles-to-be-saved
2966 (when (eq gnus-prompt-before-saving t)
2968 (set-buffer gnus-article-current-summary)
2969 (funcall gnus-default-article-saver filename)))))
2971 (defun gnus-read-save-file-name (prompt &optional filename
2972 function group headers variable)
2974 (funcall function group headers (symbol-value variable)))
2979 ((eq filename 'default)
2985 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2988 (if (and gnus-number-of-articles-to-be-saved
2989 (> gnus-number-of-articles-to-be-saved 1))
2990 (format "these %d articles"
2991 gnus-number-of-articles-to-be-saved)
2994 ;; Let the split methods have their say.
2996 ;; No split name was found.
2999 (concat prompt " (default "
3000 (file-name-nondirectory default-name) ") ")
3001 (file-name-directory default-name)
3003 ;; A single group name is returned.
3004 ((stringp split-name)
3006 (funcall function split-name headers
3007 (symbol-value variable)))
3009 (concat prompt " (default "
3010 (file-name-nondirectory default-name) ") ")
3011 (file-name-directory default-name)
3013 ;; A single split name was found
3014 ((= 1 (length split-name))
3015 (let* ((name (expand-file-name
3017 gnus-article-save-directory))
3018 (dir (cond ((file-directory-p name)
3019 (file-name-as-directory name))
3020 ((file-exists-p name) name)
3021 (t gnus-article-save-directory))))
3023 (concat prompt " (default " name ") ")
3025 ;; A list of splits was found.
3027 (setq split-name (nreverse split-name))
3029 (let ((file-name-history
3030 (nconc split-name file-name-history)))
3034 (concat prompt " (`M-p' for defaults) ")
3035 gnus-article-save-directory
3037 gnus-article-save-directory)))
3038 (car (push result file-name-history)))))))
3039 ;; Create the directory.
3040 (gnus-make-directory (file-name-directory file))
3041 ;; If we have read a directory, we append the default file name.
3042 (when (file-directory-p file)
3043 (setq file (expand-file-name (file-name-nondirectory
3045 (file-name-as-directory file))))
3046 ;; Possibly translate some characters.
3047 (nnheader-translate-file-chars file))))))
3048 (gnus-make-directory (file-name-directory result))
3049 (set variable result)))
3051 (defun gnus-article-archive-name (group)
3052 "Return the first instance of an \"Archive-name\" in the current buffer."
3053 (let ((case-fold-search t))
3054 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3055 (nnheader-concat gnus-article-save-directory
3056 (match-string 1)))))
3058 (defun gnus-article-nndoc-name (group)
3059 "If GROUP is an nndoc group, return the name of the parent group."
3060 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3061 (gnus-group-get-parameter group 'save-article-group)))
3063 (defun gnus-summary-save-in-rmail (&optional filename)
3064 "Append this article to Rmail file.
3065 Optional argument FILENAME specifies file name.
3066 Directory to save to is default to `gnus-article-save-directory'."
3067 (setq filename (gnus-read-save-file-name
3068 "Save %s in rmail file:" filename
3069 gnus-rmail-save-name gnus-newsgroup-name
3070 gnus-current-headers 'gnus-newsgroup-last-rmail))
3071 (gnus-eval-in-buffer-window gnus-save-article-buffer
3075 (gnus-output-to-rmail filename))))
3078 (defun gnus-summary-save-in-mail (&optional filename)
3079 "Append this article to Unix mail file.
3080 Optional argument FILENAME specifies file name.
3081 Directory to save to is default to `gnus-article-save-directory'."
3082 (setq filename (gnus-read-save-file-name
3083 "Save %s in Unix mail file:" filename
3084 gnus-mail-save-name gnus-newsgroup-name
3085 gnus-current-headers 'gnus-newsgroup-last-mail))
3086 (gnus-eval-in-buffer-window gnus-save-article-buffer
3090 (if (and (file-readable-p filename)
3091 (mail-file-babyl-p filename))
3092 (rmail-output-to-rmail-file filename t)
3093 (gnus-output-to-mail filename)))))
3096 (defun gnus-summary-save-in-file (&optional filename overwrite)
3097 "Append this article to file.
3098 Optional argument FILENAME specifies file name.
3099 Directory to save to is default to `gnus-article-save-directory'."
3100 (setq filename (gnus-read-save-file-name
3101 "Save %s in file:" filename
3102 gnus-file-save-name gnus-newsgroup-name
3103 gnus-current-headers 'gnus-newsgroup-last-file))
3104 (gnus-eval-in-buffer-window gnus-save-article-buffer
3108 (when (and overwrite
3109 (file-exists-p filename))
3110 (delete-file filename))
3111 (gnus-output-to-file filename))))
3114 (defun gnus-summary-write-to-file (&optional filename)
3115 "Write this article to a file, overwriting it if the file exists.
3116 Optional argument FILENAME specifies file name.
3117 The directory to save in defaults to `gnus-article-save-directory'."
3118 (gnus-summary-save-in-file nil t))
3120 (defun gnus-summary-save-body-in-file (&optional filename)
3121 "Append this article body to a file.
3122 Optional argument FILENAME specifies file name.
3123 The directory to save in defaults to `gnus-article-save-directory'."
3124 (setq filename (gnus-read-save-file-name
3125 "Save %s body in file:" filename
3126 gnus-file-save-name gnus-newsgroup-name
3127 gnus-current-headers 'gnus-newsgroup-last-file))
3128 (gnus-eval-in-buffer-window gnus-save-article-buffer
3132 (when (article-goto-body)
3133 (narrow-to-region (point) (point-max)))
3134 (gnus-output-to-file filename))))
3137 (defun gnus-summary-save-in-pipe (&optional command)
3138 "Pipe this article to subprocess."
3140 (cond ((and (eq command 'default)
3141 gnus-last-shell-command)
3142 gnus-last-shell-command)
3147 "Shell command on %s: "
3148 (if (and gnus-number-of-articles-to-be-saved
3149 (> gnus-number-of-articles-to-be-saved 1))
3150 (format "these %d articles"
3151 gnus-number-of-articles-to-be-saved)
3153 gnus-last-shell-command))))
3154 (when (string-equal command "")
3155 (if gnus-last-shell-command
3156 (setq command gnus-last-shell-command)
3157 (error "A command is required")))
3158 (gnus-eval-in-buffer-window gnus-article-buffer
3161 (shell-command-on-region (point-min) (point-max) command nil)))
3162 (setq gnus-last-shell-command command))
3164 (defun gnus-summary-pipe-to-muttprint (&optional command)
3165 "Pipe this article to muttprint."
3166 (setq command (read-string
3167 "Print using command: " gnus-summary-muttprint-program
3168 nil gnus-summary-muttprint-program))
3169 (gnus-summary-save-in-pipe command))
3171 ;;; Article file names when saving.
3173 (defun gnus-capitalize-newsgroup (newsgroup)
3174 "Capitalize NEWSGROUP name."
3175 (when (not (zerop (length newsgroup)))
3176 (concat (char-to-string (upcase (aref newsgroup 0)))
3177 (substring newsgroup 1))))
3179 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3180 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3181 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3182 Otherwise, it is like ~/News/news/group/num."
3185 (concat (if (gnus-use-long-file-name 'not-save)
3186 (gnus-capitalize-newsgroup newsgroup)
3187 (gnus-newsgroup-directory-form newsgroup))
3188 "/" (int-to-string (mail-header-number headers)))
3189 gnus-article-save-directory)))
3191 (string-equal (file-name-directory default)
3192 (file-name-directory last-file))
3193 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3195 (or last-file default))))
3197 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3198 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3199 If variable `gnus-use-long-file-name' is non-nil, it is
3200 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3203 (concat (if (gnus-use-long-file-name 'not-save)
3205 (gnus-newsgroup-directory-form newsgroup))
3206 "/" (int-to-string (mail-header-number headers)))
3207 gnus-article-save-directory)))
3209 (string-equal (file-name-directory default)
3210 (file-name-directory last-file))
3211 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3213 (or last-file default))))
3215 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3216 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3217 If variable `gnus-use-long-file-name' is non-nil, it is
3218 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3221 (if (gnus-use-long-file-name 'not-save)
3224 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3226 gnus-article-save-directory)))
3228 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3229 "Generate file name from sender."
3230 (let ((from (mail-header-from headers)))
3232 (if (and from (string-match "\\([^ <]+\\)@" from))
3233 (match-string 1 from)
3235 gnus-article-save-directory)))
3237 (defun article-verify-x-pgp-sig ()
3240 (if (gnus-buffer-live-p gnus-original-article-buffer)
3241 (let ((sig (with-current-buffer gnus-original-article-buffer
3242 (gnus-fetch-field "X-PGP-Sig")))
3246 (mml2015-clear-verify-function))
3248 (insert-buffer gnus-original-article-buffer)
3249 (setq items (split-string sig))
3250 (message-narrow-to-head)
3251 (let ((inhibit-point-motion-hooks t)
3252 (case-fold-search t))
3253 ;; Don't verify multiple headers.
3254 (setq headers (mapconcat (lambda (header)
3256 (mail-fetch-field header) "\n"))
3257 (split-string (nth 1 items) ",") "")))
3258 (delete-region (point-min) (point-max))
3259 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3260 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3265 (if (looking-at "^-")
3268 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3269 (insert "Version: " (car items) "\n\n")
3270 (insert (mapconcat 'identity (cddr items) "\n"))
3271 (insert "\n-----END PGP SIGNATURE-----\n")
3272 (let ((mm-security-handle (list (format "multipart/signed"))))
3273 (mml2015-clean-buffer)
3274 (let ((coding-system-for-write (or gnus-newsgroup-charset
3276 (funcall (mml2015-clear-verify-function)))
3278 (or (mm-handle-multipart-ctl-parameter
3279 mm-security-handle 'gnus-details)
3280 (mm-handle-multipart-ctl-parameter
3281 mm-security-handle 'gnus-info)))))
3283 (let (buffer-read-only bface eface)
3285 (message-narrow-to-head)
3286 (goto-char (point-max))
3288 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3289 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3290 (message-remove-header "X-Gnus-PGP-Verify")
3291 (if (re-search-forward "^X-PGP-Sig:" nil t)
3293 (goto-char (point-max)))
3294 (narrow-to-region (point) (point))
3295 (insert "X-Gnus-PGP-Verify: " info "\n")
3296 (goto-char (point-min))
3299 (if (not (looking-at "^[ \t]"))
3303 (goto-char (point-min))
3304 (when (looking-at "\\([^:]+\\): *")
3305 (put-text-property (match-beginning 1) (1+ (match-end 1))
3307 (put-text-property (match-end 0) (point-max)
3308 'face eface)))))))))
3310 (defun article-verify-cancel-lock ()
3311 "Verify Cancel-Lock header."
3313 (if (gnus-buffer-live-p gnus-original-article-buffer)
3314 (canlock-verify gnus-original-article-buffer)))
3321 (setq afunc (car func)
3324 gfunc (intern (format "gnus-%s" func))))
3326 (when (fboundp afunc)
3327 `(lambda (&optional interactive &rest args)
3328 ,(documentation afunc t)
3329 (interactive (list t))
3331 (set-buffer gnus-article-buffer)
3333 (call-interactively ',afunc)
3334 (apply ',afunc args))))))))
3335 '(article-hide-headers
3336 article-verify-x-pgp-sig
3337 article-verify-cancel-lock
3338 article-hide-boring-headers
3339 article-treat-overstrike
3340 article-fill-long-lines
3341 article-capitalize-sentences
3343 article-remove-leading-whitespace
3344 article-display-x-face
3345 article-de-quoted-unreadable
3346 article-de-base64-unreadable
3349 article-unsplit-urls
3350 article-hide-list-identifiers
3352 article-strip-banner
3355 article-hide-signature
3356 article-strip-headers-in-body
3357 article-remove-trailing-blank-lines
3358 article-strip-leading-blank-lines
3359 article-strip-multiple-blank-lines
3360 article-strip-leading-space
3361 article-strip-trailing-space
3362 article-strip-blank-lines
3363 article-strip-all-blank-lines
3365 article-date-english
3366 article-date-iso8601
3367 article-date-original
3369 article-decode-mime-words
3370 article-decode-charset
3371 article-decode-encoded-words
3375 article-treat-dumbquotes
3376 article-normalize-headers
3377 ;; (article-show-all . gnus-article-show-all-headers)
3381 ;;; Gnus article mode
3384 (put 'gnus-article-mode 'mode-class 'special)
3386 (set-keymap-parent gnus-article-mode-map widget-keymap)
3388 (gnus-define-keys gnus-article-mode-map
3389 " " gnus-article-goto-next-page
3390 "\177" gnus-article-goto-prev-page
3391 [delete] gnus-article-goto-prev-page
3392 [backspace] gnus-article-goto-prev-page
3393 "\C-c^" gnus-article-refer-article
3394 "h" gnus-article-show-summary
3395 "s" gnus-article-show-summary
3396 "\C-c\C-m" gnus-article-mail
3397 "?" gnus-article-describe-briefly
3398 "e" gnus-summary-edit-article
3399 "<" beginning-of-buffer
3401 "\C-c\C-i" gnus-info-find-node
3403 "R" gnus-article-reply-with-original
3404 "F" gnus-article-followup-with-original
3405 "\C-hk" gnus-article-describe-key
3406 "\C-hc" gnus-article-describe-key-briefly
3408 "\C-d" gnus-article-read-summary-keys
3409 "\M-*" gnus-article-read-summary-keys
3410 "\M-#" gnus-article-read-summary-keys
3411 "\M-^" gnus-article-read-summary-keys
3412 "\M-g" gnus-article-read-summary-keys)
3414 (substitute-key-definition
3415 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3417 (defun gnus-article-make-menu-bar ()
3418 (unless (boundp 'gnus-article-commands-menu)
3419 (gnus-summary-make-menu-bar))
3420 (gnus-turn-off-edit-menu 'article)
3421 (unless (boundp 'gnus-article-article-menu)
3423 gnus-article-article-menu gnus-article-mode-map ""
3425 ["Scroll forwards" gnus-article-goto-next-page t]
3426 ["Scroll backwards" gnus-article-goto-prev-page t]
3427 ["Show summary" gnus-article-show-summary t]
3428 ["Fetch Message-ID at point" gnus-article-refer-article t]
3429 ["Mail to address at point" gnus-article-mail t]
3430 ["Send a bug report" gnus-bug t]))
3433 gnus-article-treatment-menu gnus-article-mode-map ""
3434 ;; Fixme: this should use :active (and maybe :visible).
3436 ["Hide headers" gnus-article-hide-headers t]
3437 ["Hide signature" gnus-article-hide-signature t]
3438 ["Hide citation" gnus-article-hide-citation t]
3439 ["Treat overstrike" gnus-article-treat-overstrike t]
3440 ["Remove carriage return" gnus-article-remove-cr t]
3441 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3442 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3443 ["Remove base64" gnus-article-de-base64-unreadable t]
3444 ["Treat html" gnus-article-wash-html t]
3445 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3446 ["Decode HZ" gnus-article-decode-HZ t]))
3448 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3450 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3452 (gnus-run-hooks 'gnus-article-menu-hook)))
3454 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3457 (defun gnus-article-mode ()
3458 "Major mode for displaying an article.
3460 All normal editing commands are switched off.
3462 The following commands are available in addition to all summary mode
3464 \\<gnus-article-mode-map>
3465 \\[gnus-article-next-page]\t Scroll the article one page forwards
3466 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3467 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3468 \\[gnus-article-show-summary]\t Display the summary buffer
3469 \\[gnus-article-mail]\t Send a reply to the address near point
3470 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3471 \\[gnus-info-find-node]\t Go to the Gnus info node"
3473 (gnus-simplify-mode-line)
3474 (setq mode-name "Article")
3475 (setq major-mode 'gnus-article-mode)
3476 (make-local-variable 'minor-mode-alist)
3477 (use-local-map gnus-article-mode-map)
3478 (when (gnus-visual-p 'article-menu 'menu)
3479 (gnus-article-make-menu-bar))
3480 (gnus-update-format-specifications nil 'article-mode)
3481 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3482 (make-local-variable 'gnus-page-broken)
3483 (make-local-variable 'gnus-button-marker-list)
3484 (make-local-variable 'gnus-article-current-summary)
3485 (make-local-variable 'gnus-article-mime-handles)
3486 (make-local-variable 'gnus-article-decoded-p)
3487 (make-local-variable 'gnus-article-mime-handle-alist)
3488 (make-local-variable 'gnus-article-wash-types)
3489 (make-local-variable 'gnus-article-image-alist)
3490 (make-local-variable 'gnus-article-charset)
3491 (make-local-variable 'gnus-article-ignored-charsets)
3492 (gnus-set-default-directory)
3493 (buffer-disable-undo)
3494 (setq buffer-read-only t)
3495 (set-syntax-table gnus-article-mode-syntax-table)
3496 (mm-enable-multibyte)
3497 (gnus-run-hooks 'gnus-article-mode-hook))
3499 (defun gnus-article-setup-buffer ()
3500 "Initialize the article buffer."
3501 (let* ((name (if gnus-single-article-buffer "*Article*"
3502 (concat "*Article " gnus-newsgroup-name "*")))
3504 (progn (string-match "\\*Article" name)
3505 (concat " *Original Article"
3506 (substring name (match-end 0))))))
3507 (setq gnus-article-buffer name)
3508 (setq gnus-original-article-buffer original)
3509 (setq gnus-article-mime-handle-alist nil)
3510 ;; This might be a variable local to the summary buffer.
3511 (unless gnus-single-article-buffer
3513 (set-buffer gnus-summary-buffer)
3514 (setq gnus-article-buffer name)
3515 (setq gnus-original-article-buffer original)
3516 (gnus-set-global-variables)))
3517 (gnus-article-setup-highlight-words)
3518 ;; Init original article buffer.
3520 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3521 (mm-enable-multibyte)
3522 (setq major-mode 'gnus-original-article-mode)
3523 (make-local-variable 'gnus-original-article))
3524 (if (get-buffer name)
3527 (when (and gnus-article-edit-mode
3530 (y-or-n-p "Article mode edit in progress; discard? ")))
3531 (error "Action aborted"))
3532 (set (make-local-variable 'gnus-article-edit-mode) nil)
3533 (when gnus-article-mime-handles
3534 (mm-destroy-parts gnus-article-mime-handles)
3535 (setq gnus-article-mime-handles nil))
3536 ;; Set it to nil in article-buffer!
3537 (setq gnus-article-mime-handle-alist nil)
3538 (buffer-disable-undo)
3539 (setq buffer-read-only t)
3540 (unless (eq major-mode 'gnus-article-mode)
3541 (gnus-article-mode))
3544 (set-buffer (gnus-get-buffer-create name))
3546 (make-local-variable 'gnus-summary-buffer)
3547 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3548 (current-buffer)))))
3550 ;; Set article window start at LINE, where LINE is the number of lines
3551 ;; from the head of the article.
3552 (defun gnus-article-set-window-start (&optional line)
3554 (gnus-get-buffer-window gnus-article-buffer t)
3556 (set-buffer gnus-article-buffer)
3557 (goto-char (point-min))
3560 (gnus-message 6 "Moved to bookmark")
3561 (search-forward "\n\n" nil t)
3565 (defun gnus-article-prepare (article &optional all-headers header)
3566 "Prepare ARTICLE in article mode buffer.
3567 ARTICLE should either be an article number or a Message-ID.
3568 If ARTICLE is an id, HEADER should be the article headers.
3569 If ALL-HEADERS is non-nil, no headers are hidden."
3571 ;; Make sure we start in a summary buffer.
3572 (unless (eq major-mode 'gnus-summary-mode)
3573 (set-buffer gnus-summary-buffer))
3574 (setq gnus-summary-buffer (current-buffer))
3575 (let* ((gnus-article (if header (mail-header-number header) article))
3576 (summary-buffer (current-buffer))
3577 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3578 (group gnus-newsgroup-name)
3581 (gnus-article-setup-buffer)
3582 (set-buffer gnus-article-buffer)
3583 ;; Deactivate active regions.
3584 (when (and (boundp 'transient-mark-mode)
3585 transient-mark-mode)
3586 (setq mark-active nil))
3587 (if (not (setq result (let ((buffer-read-only nil))
3588 (gnus-request-article-this-buffer
3590 ;; There is no such article.
3592 (when (and (numberp article)
3593 (not (memq article gnus-newsgroup-sparse)))
3594 (setq gnus-article-current
3595 (cons gnus-newsgroup-name article))
3596 (set-buffer gnus-summary-buffer)
3597 (setq gnus-current-article article)
3598 (if (memq article gnus-newsgroup-undownloaded)
3600 (gnus-summary-set-agent-mark article)
3601 (message "Message marked for downloading"))
3602 (gnus-summary-mark-article article gnus-canceled-mark)
3603 (unless (memq article gnus-newsgroup-sparse)
3604 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3605 (if (or (eq result 'pseudo)
3606 (eq result 'nneething))
3609 (set-buffer summary-buffer)
3610 (push article gnus-newsgroup-history)
3611 (setq gnus-last-article gnus-current-article
3612 gnus-current-article 0
3613 gnus-current-headers nil
3614 gnus-article-current nil)
3615 (if (eq result 'nneething)
3616 (gnus-configure-windows 'summary)
3617 (gnus-configure-windows 'article))
3618 (gnus-set-global-variables))
3619 (let ((gnus-article-mime-handle-alist-1
3620 gnus-article-mime-handle-alist))
3621 (gnus-set-mode-line 'article)))
3622 ;; The result from the `request' was an actual article -
3623 ;; or at least some text that is now displayed in the
3625 (when (and (numberp article)
3626 (not (eq article gnus-current-article)))
3627 ;; Seems like a new article has been selected.
3628 ;; `gnus-current-article' must be an article number.
3630 (set-buffer summary-buffer)
3631 (push article gnus-newsgroup-history)
3632 (setq gnus-last-article gnus-current-article
3633 gnus-current-article article
3634 gnus-current-headers
3635 (gnus-summary-article-header gnus-current-article)
3636 gnus-article-current
3637 (cons gnus-newsgroup-name gnus-current-article))
3638 (unless (vectorp gnus-current-headers)
3639 (setq gnus-current-headers nil))
3640 (gnus-summary-goto-subject gnus-current-article)
3641 (when (gnus-summary-show-thread)
3642 ;; If the summary buffer really was folded, the
3643 ;; previous goto may not actually have gone to
3644 ;; the right article, but the thread root instead.
3646 (gnus-summary-goto-subject gnus-current-article))
3647 (gnus-run-hooks 'gnus-mark-article-hook)
3648 (gnus-set-mode-line 'summary)
3649 (when (gnus-visual-p 'article-highlight 'highlight)
3650 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3651 ;; Set the global newsgroup variables here.
3652 (gnus-set-global-variables)
3653 (setq gnus-have-all-headers
3654 (or all-headers gnus-show-all-headers))))
3656 (gnus-configure-windows 'article))
3657 (when (or (numberp article)
3659 (gnus-article-prepare-display)
3661 (goto-char (point-min))
3662 (setq gnus-page-broken
3663 (when gnus-break-pages
3664 (gnus-narrow-to-page)
3666 (let ((gnus-article-mime-handle-alist-1
3667 gnus-article-mime-handle-alist))
3668 (gnus-set-mode-line 'article))
3672 (set-window-point (get-buffer-window (current-buffer)) (point))
3673 (gnus-configure-windows 'article)
3677 (defun gnus-article-prepare-display ()
3678 "Make the current buffer look like a nice article."
3679 ;; Hooks for getting information from the article.
3680 ;; This hook must be called before being narrowed.
3681 (let ((gnus-article-buffer (current-buffer))
3683 (unless (eq major-mode 'gnus-article-mode)
3684 (gnus-article-mode))
3685 (setq buffer-read-only nil
3686 gnus-article-wash-types nil
3687 gnus-article-image-alist nil)
3688 (gnus-run-hooks 'gnus-tmp-internal-hook)
3689 (when gnus-display-mime-function
3690 (funcall gnus-display-mime-function))
3691 (gnus-run-hooks 'gnus-article-prepare-hook)))
3694 ;;; Gnus MIME viewing functions
3697 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3698 "Format of the MIME buttons.
3700 Valid specifiers include:
3702 %T MIME type, along with additional info
3703 %n The `name' parameter
3704 %d The description, if any
3705 %l The length of the encoded part
3706 %p The part identifier number
3707 %e Dots if the part isn't displayed
3709 General format specifiers can also be used. See Info node
3710 `(gnus)Formatting Variables'.")
3712 (defvar gnus-mime-button-line-format-alist
3713 '((?t gnus-tmp-type ?s)
3714 (?T gnus-tmp-type-long ?s)
3715 (?n gnus-tmp-name ?s)
3716 (?d gnus-tmp-description ?s)
3718 (?l gnus-tmp-length ?d)
3719 (?e gnus-tmp-dots ?s)))
3721 (defvar gnus-mime-button-commands
3722 '((gnus-article-press-button "\r" "Toggle Display")
3723 (gnus-mime-view-part "v" "View Interactively...")
3724 (gnus-mime-view-part-as-type "t" "View As Type...")
3725 (gnus-mime-view-part-as-charset "C" "View As charset...")
3726 (gnus-mime-save-part "o" "Save...")
3727 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3728 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3729 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3730 (gnus-mime-view-part-internally "E" "View Internally")
3731 (gnus-mime-view-part-externally "e" "View Externally")
3732 (gnus-mime-print-part "p" "Print")
3733 (gnus-mime-pipe-part "|" "Pipe To Command...")
3734 (gnus-mime-action-on-part "." "Take action on the part")))
3736 (defun gnus-article-mime-part-status ()
3737 (if gnus-article-mime-handle-alist-1
3738 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3740 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3743 (defvar gnus-mime-button-map
3744 (let ((map (make-sparse-keymap)))
3745 (unless (>= (string-to-number emacs-version) 21)
3746 ;; XEmacs doesn't care.
3747 (set-keymap-parent map gnus-article-mode-map))
3748 (define-key map gnus-mouse-2 'gnus-article-push-button)
3749 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3750 (dolist (c gnus-mime-button-commands)
3751 (define-key map (cadr c) (car c)))
3754 (defun gnus-mime-button-menu (event)
3755 "Construct a context-sensitive menu of MIME commands."
3757 (save-window-excursion
3758 (let ((pos (event-start event)))
3759 (select-window (posn-window pos))
3760 (goto-char (posn-point pos))
3761 (gnus-article-check-buffer)
3762 (let ((response (x-popup-menu
3764 ("" ,@(mapcar (lambda (c)
3765 (cons (caddr c) (car c)))
3766 gnus-mime-button-commands))))))
3768 (call-interactively response))))))
3770 (defun gnus-mime-view-all-parts (&optional handles)
3771 "View all the MIME parts."
3773 (save-current-buffer
3774 (set-buffer gnus-article-buffer)
3775 (let ((handles (or handles gnus-article-mime-handles))
3776 (mail-parse-charset gnus-newsgroup-charset)
3777 (mail-parse-ignored-charsets
3778 (with-current-buffer gnus-summary-buffer
3779 gnus-newsgroup-ignored-charsets)))
3781 (mm-remove-parts handles)
3782 (goto-char (point-min))
3783 (or (search-forward "\n\n") (goto-char (point-max)))
3784 (let (buffer-read-only)
3785 (delete-region (point) (point-max))
3786 (mm-display-parts handles))))))
3788 (defun gnus-mime-save-part-and-strip ()
3789 "Save the MIME part under point then replace it with an external body."
3791 (gnus-article-check-buffer)
3792 (let* ((data (get-text-property (point) 'gnus-data))
3794 (handles gnus-article-mime-handles))
3795 (if (mm-multiple-handles gnus-article-mime-handles)
3796 (error "This function is not implemented"))
3797 (setq file (and data (mm-save-part data)))
3799 (with-current-buffer (mm-handle-buffer data)
3801 (insert "Content-Type: " (mm-handle-media-type data))
3802 (mml-insert-parameter-string (cdr (mm-handle-type data))
3805 (insert "Content-ID: " (message-make-message-id) "\n")
3806 (insert "Content-Transfer-Encoding: binary\n")
3809 (cdr (mm-make-handle nil
3810 `("message/external-body"
3811 (access-type . "LOCAL-FILE")
3813 (set-buffer gnus-summary-buffer)
3814 (gnus-article-edit-article
3817 (let ((mail-parse-charset (or gnus-article-charset
3818 ',gnus-newsgroup-charset))
3819 (mail-parse-ignored-charsets
3820 (or gnus-article-ignored-charsets
3821 ',gnus-newsgroup-ignored-charsets))
3822 (mbl mml-buffer-list))
3823 (setq mml-buffer-list nil)
3824 (insert-buffer gnus-original-article-buffer)
3825 (mime-to-mml ',handles)
3826 (setq gnus-article-mime-handles nil)
3827 (let ((mbl1 mml-buffer-list))
3828 (setq mml-buffer-list mbl)
3829 (set (make-local-variable 'mml-buffer-list) mbl1))
3830 ;; LOCAL argument of add-hook differs between GNU Emacs
3831 ;; and XEmacs. make-local-hook makes sure they are local.
3832 (make-local-hook 'kill-buffer-hook)
3833 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3834 `(lambda (no-highlight)
3835 (let ((mail-parse-charset (or gnus-article-charset
3836 ',gnus-newsgroup-charset))
3837 (message-options message-options)
3838 (message-options-set-recipient)
3839 (mail-parse-ignored-charsets
3840 (or gnus-article-ignored-charsets
3841 ',gnus-newsgroup-ignored-charsets)))
3843 (mml-destroy-buffers)
3844 (remove-hook 'kill-buffer-hook
3845 'mml-destroy-buffers t)
3846 (kill-local-variable 'mml-buffer-list))
3847 (gnus-summary-edit-article-done
3848 ,(or (mail-header-references gnus-current-headers) "")
3849 ,(gnus-group-read-only-p)
3850 ,gnus-summary-buffer no-highlight))))))
3852 (defun gnus-mime-save-part ()
3853 "Save the MIME part under point."
3855 (gnus-article-check-buffer)
3856 (let ((data (get-text-property (point) 'gnus-data)))
3858 (mm-save-part data))))
3860 (defun gnus-mime-pipe-part ()
3861 "Pipe the MIME part under point to a process."
3863 (gnus-article-check-buffer)
3864 (let ((data (get-text-property (point) 'gnus-data)))
3866 (mm-pipe-part data))))
3868 (defun gnus-mime-view-part ()
3869 "Interactively choose a viewing method for the MIME part under point."
3871 (gnus-article-check-buffer)
3872 (let ((data (get-text-property (point) 'gnus-data)))
3874 (setq gnus-article-mime-handles
3876 gnus-article-mime-handles (setq data (copy-sequence data))))
3877 (mm-interactively-view-part data))))
3879 (defun gnus-mime-view-part-as-type-internal ()
3880 (gnus-article-check-buffer)
3881 (let* ((name (mail-content-type-get
3882 (mm-handle-type (get-text-property (point) 'gnus-data))
3884 (def-type (and name (mm-default-file-encoding name))))
3885 (and def-type (cons def-type 0))))
3887 (defun gnus-mime-view-part-as-type (&optional mime-type)
3888 "Choose a MIME media type, and view the part as such."
3891 (setq mime-type (completing-read
3892 "View as MIME type: "
3893 (mapcar #'list (mailcap-mime-types))
3895 (gnus-mime-view-part-as-type-internal))))
3896 (gnus-article-check-buffer)
3897 (let ((handle (get-text-property (point) 'gnus-data)))
3900 (mm-make-handle (mm-handle-buffer handle)
3901 (cons mime-type (cdr (mm-handle-type handle)))
3902 (mm-handle-encoding handle)
3903 (mm-handle-undisplayer handle)
3904 (mm-handle-disposition handle)
3905 (mm-handle-description handle)
3907 (mm-handle-id handle)))
3908 (setq gnus-article-mime-handles
3909 (mm-merge-handles gnus-article-mime-handles handle))
3910 (gnus-mm-display-part handle))))
3913 (require 'jka-compr))
3915 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
3916 ;; emacs can do that itself.
3918 (defun gnus-mime-jka-compr-maybe-uncompress ()
3919 "Uncompress the current buffer if `auto-compression-mode' is enabled.
3920 The uncompress method used is derived from `buffer-file-name'."
3921 (when (and (fboundp 'jka-compr-installed-p)
3922 (jka-compr-installed-p))
3923 (let ((info (jka-compr-get-compression-info buffer-file-name)))
3925 (let ((basename (file-name-nondirectory buffer-file-name))
3926 (args (jka-compr-info-uncompress-args info))
3927 (prog (jka-compr-info-uncompress-program info))
3928 (message (jka-compr-info-uncompress-message info))
3929 (err-file (jka-compr-make-temp-name)))
3931 (message "%s %s..." message basename))
3933 (unless (memq (apply 'call-process-region
3934 (point-min) (point-max)
3936 t (list t err-file) nil
3938 jka-compr-acceptable-retval-list)
3939 (jka-compr-error prog args basename message err-file))
3940 (jka-compr-delete-temp-file err-file)))))))
3942 (defun gnus-mime-copy-part (&optional handle)
3943 "Put the MIME part under point into a new buffer."
3945 (gnus-article-check-buffer)
3946 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3947 (contents (and handle (mm-get-part handle)))
3949 (file-name-nondirectory
3951 (mail-content-type-get (mm-handle-type handle) 'name)
3952 (mail-content-type-get (mm-handle-disposition handle)
3955 (buffer (and base (generate-new-buffer base))))
3957 (switch-to-buffer buffer)
3959 ;; We do it this way to make `normal-mode' set the appropriate mode.
3962 (setq buffer-file-name (expand-file-name base))
3963 (gnus-mime-jka-compr-maybe-uncompress)
3965 (setq buffer-file-name nil))
3966 (goto-char (point-min)))))
3968 (defun gnus-mime-print-part (&optional handle filename)
3969 "Print the MIME part under point."
3970 (interactive (list nil (ps-print-preprint current-prefix-arg)))
3971 (gnus-article-check-buffer)
3972 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3973 (contents (and handle (mm-get-part handle)))
3974 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
3975 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
3980 (with-temp-file file
3982 (call-process shell-file-name nil
3983 (generate-new-buffer " *mm*")
3985 shell-command-switch
3987 printer file (mm-handle-type handle))))
3991 (gnus-print-buffer))
3992 (ps-despool filename)))))
3994 (defun gnus-mime-inline-part (&optional handle arg)
3995 "Insert the MIME part under point into the current buffer."
3996 (interactive (list nil current-prefix-arg))
3997 (gnus-article-check-buffer)
3998 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4003 (if (and (not arg) (mm-handle-undisplayer handle))
4004 (mm-remove-part handle)
4005 (setq contents (mm-get-part handle))
4008 (setq charset (or (mail-content-type-get
4009 (mm-handle-type handle) 'charset)
4010 gnus-newsgroup-charset)))
4012 (if (mm-handle-undisplayer handle)
4013 (mm-remove-part handle))
4016 gnus-summary-show-article-charset-alist))
4017 (mm-read-coding-system "Charset: ")))))
4019 (mm-insert-inline handle
4021 (setq charset (mm-charset-to-coding-system
4023 (not (eq charset 'ascii)))
4024 (mm-decode-coding-string contents charset)
4028 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4029 "Insert the MIME part under point into the current buffer using the
4031 (interactive (list nil current-prefix-arg))
4032 (gnus-article-check-buffer)
4033 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4038 (if (mm-handle-undisplayer handle)
4039 (mm-remove-part handle))
4040 (let ((gnus-newsgroup-charset
4042 gnus-summary-show-article-charset-alist))
4043 (mm-read-coding-system "Charset: ")))
4044 (gnus-newsgroup-ignored-charsets 'gnus-all))
4045 (gnus-article-press-button)))))
4047 (defun gnus-mime-view-part-externally (&optional handle)
4048 "View the MIME part under point with an external viewer."
4050 (gnus-article-check-buffer)
4051 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4052 (mm-user-display-methods nil)
4053 (mm-inlined-types nil)
4054 (mail-parse-charset gnus-newsgroup-charset)
4055 (mail-parse-ignored-charsets
4056 (save-excursion (set-buffer gnus-summary-buffer)
4057 gnus-newsgroup-ignored-charsets)))
4059 (if (mm-handle-undisplayer handle)
4060 (mm-remove-part handle)
4061 (mm-display-part handle)))))
4063 (defun gnus-mime-view-part-internally (&optional handle)
4064 "View the MIME part under point with an internal viewer.
4065 If no internal viewer is available, use an external viewer."
4067 (gnus-article-check-buffer)
4068 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4069 (mm-inlined-types '(".*"))
4070 (mm-inline-large-images t)
4071 (mail-parse-charset gnus-newsgroup-charset)
4072 (mail-parse-ignored-charsets
4073 (save-excursion (set-buffer gnus-summary-buffer)
4074 gnus-newsgroup-ignored-charsets)))
4076 (if (mm-handle-undisplayer handle)
4077 (mm-remove-part handle)
4078 (mm-display-part handle)))))
4080 (defun gnus-mime-action-on-part (&optional action)
4081 "Do something with the MIME attachment at \(point\)."
4083 (list (completing-read "Action: " gnus-mime-action-alist)))
4084 (gnus-article-check-buffer)
4085 (let ((action-pair (assoc action gnus-mime-action-alist)))
4087 (funcall (cdr action-pair)))))
4089 (defun gnus-article-part-wrapper (n function)
4090 (save-current-buffer
4091 (set-buffer gnus-article-buffer)
4092 (when (> n (length gnus-article-mime-handle-alist))
4093 (error "No such part"))
4094 (gnus-article-goto-part n)
4095 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4096 (funcall function handle))))
4098 (defun gnus-article-pipe-part (n)
4099 "Pipe MIME part N, which is the numerical prefix."
4101 (gnus-article-part-wrapper n 'mm-pipe-part))
4103 (defun gnus-article-save-part (n)
4104 "Save MIME part N, which is the numerical prefix."
4106 (gnus-article-part-wrapper n 'mm-save-part))
4108 (defun gnus-article-interactively-view-part (n)
4109 "View MIME part N interactively, which is the numerical prefix."
4111 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4113 (defun gnus-article-copy-part (n)
4114 "Copy MIME part N, which is the numerical prefix."
4116 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4118 (defun gnus-article-view-part-as-charset (n)
4119 "Copy MIME part N, which is the numerical prefix."
4121 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4123 (defun gnus-article-view-part-externally (n)
4124 "View MIME part N externally, which is the numerical prefix."
4126 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4128 (defun gnus-article-inline-part (n)
4129 "Inline MIME part N, which is the numerical prefix."
4131 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4133 (defun gnus-article-mime-match-handle-first (condition)
4135 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4136 (while (setq ihandle (pop alist))
4138 ((functionp condition)
4139 (funcall condition (cdr ihandle)))
4140 ((eq condition 'undisplayed)
4141 (not (or (mm-handle-undisplayer (cdr ihandle))
4142 (equal (mm-handle-media-type (cdr ihandle))
4143 "multipart/alternative"))))
4144 ((eq condition 'undisplayed-alternative)
4145 (not (mm-handle-undisplayer (cdr ihandle))))
4147 (gnus-article-goto-part (car ihandle))
4148 (or (not n) (< (car ihandle) n)))
4149 (setq n (car ihandle))))
4153 (defun gnus-article-view-part (&optional n)
4154 "View MIME part N, which is the numerical prefix."
4156 (save-current-buffer
4157 (set-buffer gnus-article-buffer)
4158 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4159 gnus-article-mime-match-handle-function)))
4160 (when (> n (length gnus-article-mime-handle-alist))
4161 (error "No such part"))
4162 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4163 (when (gnus-article-goto-part n)
4164 (if (equal (car handle) "multipart/alternative")
4165 (gnus-article-press-button)
4166 (when (eq (gnus-mm-display-part handle) 'internal)
4167 (gnus-set-window-start)))))))
4169 (defsubst gnus-article-mime-total-parts ()
4170 (if (bufferp (car gnus-article-mime-handles))
4172 (1- (length gnus-article-mime-handles))))
4174 (defun gnus-mm-display-part (handle)
4175 "Display HANDLE and fix MIME button."
4176 (let ((id (get-text-property (point) 'gnus-part))
4181 (let ((window (selected-window))
4182 (mail-parse-charset gnus-newsgroup-charset)
4183 (mail-parse-ignored-charsets
4184 (if (gnus-buffer-live-p gnus-summary-buffer)
4186 (set-buffer gnus-summary-buffer)
4187 gnus-newsgroup-ignored-charsets)
4191 (let ((win (gnus-get-buffer-window (current-buffer) t))
4194 (select-window win))
4197 (if (mm-handle-displayed-p handle)
4198 ;; This will remove the part.
4199 (mm-display-part handle)
4201 (narrow-to-region (point)
4202 (if (eobp) (point) (1+ (point))))
4203 (mm-display-part handle)
4204 ;; We narrow to the part itself and
4205 ;; then call the treatment functions.
4206 (goto-char (point-min))
4208 (narrow-to-region (point) (point-max))
4211 (gnus-article-mime-total-parts)
4212 (mm-handle-media-type handle)))))
4213 (if (window-live-p window)
4214 (select-window window)))))
4216 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4217 (gnus-insert-mime-button
4218 handle id (list (mm-handle-displayed-p handle)))
4219 (goto-char point))))
4221 (defun gnus-article-goto-part (n)
4222 "Go to MIME part N."
4223 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4225 (goto-char point))))
4227 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4228 (let ((gnus-tmp-name
4229 (or (mail-content-type-get (mm-handle-type handle) 'name)
4230 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4231 (mail-content-type-get (mm-handle-type handle) 'url)
4233 (gnus-tmp-type (mm-handle-media-type handle))
4234 (gnus-tmp-description
4235 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4238 (if (if displayed (car displayed)
4239 (mm-handle-displayed-p handle))
4241 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4243 gnus-tmp-type-long b e)
4244 (when (string-match ".*/" gnus-tmp-name)
4245 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4246 (setq gnus-tmp-type-long (concat gnus-tmp-type
4247 (and (not (equal gnus-tmp-name ""))
4248 (concat "; " gnus-tmp-name))))
4249 (unless (equal gnus-tmp-description "")
4250 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4255 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4256 `(,@(gnus-local-map-property gnus-mime-button-map)
4257 gnus-callback gnus-mm-display-part
4258 gnus-part ,gnus-tmp-id
4259 article-type annotation
4262 (widget-convert-button
4265 :action 'gnus-widget-press-button
4266 :button-keymap gnus-mime-button-map
4268 (lambda (widget/window &optional overlay pos)
4269 ;; Needed to properly clear the message due to a bug in
4270 ;; wid-edit (XEmacs only).
4271 (if (boundp 'help-echo-owns-message)
4272 (setq help-echo-owns-message t))
4274 "%S: %s the MIME part; %S: more options"
4275 (aref gnus-mouse-2 0)
4276 ;; XEmacs will get a single widget arg; Emacs 21 will get
4277 ;; window, overlay, position.
4278 (if (mm-handle-displayed-p
4280 (with-current-buffer (gnus-overlay-buffer overlay)
4281 (widget-get (widget-at (gnus-overlay-start overlay))
4283 (widget-get widget/window :mime-handle)))
4285 (aref gnus-down-mouse-3 0))))))
4287 (defun gnus-widget-press-button (elems el)
4288 (goto-char (widget-get elems :from))
4289 (gnus-article-press-button))
4291 (defvar gnus-displaying-mime nil)
4293 (defun gnus-display-mime (&optional ihandles)
4294 "Display the MIME parts."
4296 (save-selected-window
4297 (let ((window (get-buffer-window gnus-article-buffer))
4300 (select-window window)
4301 ;; We have to do this since selecting the window
4302 ;; may change the point. So we set the window point.
4303 (set-window-point window point)))
4304 (let* ((handles (or ihandles (mm-dissect-buffer
4305 nil gnus-article-loose-mime)
4307 buffer-read-only handle name type b e display)
4308 (when (and (not ihandles)
4309 (not gnus-displaying-mime))
4310 ;; Top-level call; we clean up.
4311 (when gnus-article-mime-handles
4312 (mm-destroy-parts gnus-article-mime-handles)
4313 (setq gnus-article-mime-handle-alist nil));; A trick.
4314 (setq gnus-article-mime-handles handles)
4315 ;; We allow users to glean info from the handles.
4316 (when gnus-article-mime-part-function
4317 (gnus-mime-part-function handles)))
4319 (or (not (stringp (car handles)))
4322 (when (and (not ihandles)
4323 (not gnus-displaying-mime))
4324 ;; Clean up for mime parts.
4326 (delete-region (point) (point-max)))
4327 (let ((gnus-displaying-mime t))
4328 (gnus-mime-display-part handles)))
4331 (narrow-to-region (point) (point-max))
4332 (gnus-treat-article nil 1 1)
4335 ;; Highlight the headers.
4339 (narrow-to-region (point-min) (point))
4340 (gnus-treat-article 'head))))))))
4342 (defvar gnus-mime-display-multipart-as-mixed nil)
4343 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4344 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4346 (defun gnus-mime-display-part (handle)
4349 ((not (stringp (car handle)))
4350 (gnus-mime-display-single handle))
4351 ;; User-defined multipart
4352 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4353 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4355 ;; multipart/alternative
4356 ((and (equal (car handle) "multipart/alternative")
4357 (not (or gnus-mime-display-multipart-as-mixed
4358 gnus-mime-display-multipart-alternative-as-mixed)))
4359 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4360 (push (cons id handle) gnus-article-mime-handle-alist)
4361 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4362 ;; multipart/related
4363 ((and (equal (car handle) "multipart/related")
4364 (not (or gnus-mime-display-multipart-as-mixed
4365 gnus-mime-display-multipart-related-as-mixed)))
4366 ;;;!!!We should find the start part, but we just default
4367 ;;;!!!to the first part.
4368 ;;(gnus-mime-display-part (cadr handle))
4369 ;;;!!! Most multipart/related is an HTML message plus images.
4370 ;;;!!! Unfortunately we are unable to let W3 display those
4371 ;;;!!! included images, so we just display it as a mixed multipart.
4372 ;;(gnus-mime-display-mixed (cdr handle))
4373 ;;;!!! No, w3 can display everything just fine.
4374 (gnus-mime-display-part (cadr handle)))
4375 ((equal (car handle) "multipart/signed")
4376 (gnus-add-wash-type 'signed)
4377 (gnus-mime-display-security handle))
4378 ((equal (car handle) "multipart/encrypted")
4379 (gnus-add-wash-type 'encrypted)
4380 (gnus-mime-display-security handle))
4381 ;; Other multiparts are handled like multipart/mixed.
4383 (gnus-mime-display-mixed (cdr handle)))))
4385 (defun gnus-mime-part-function (handles)
4386 (if (stringp (car handles))
4387 (mapcar 'gnus-mime-part-function (cdr handles))
4388 (funcall gnus-article-mime-part-function handles)))
4390 (defun gnus-mime-display-mixed (handles)
4391 (mapcar 'gnus-mime-display-part handles))
4393 (defun gnus-mime-display-single (handle)
4394 (let ((type (mm-handle-media-type handle))
4395 (ignored gnus-ignored-mime-types)
4402 (when (string-match (pop ignored) type)
4403 (throw 'ignored nil)))
4404 (if (and (setq not-attachment
4405 (and (not (mm-inline-override-p handle))
4406 (or (not (mm-handle-disposition handle))
4407 (equal (car (mm-handle-disposition handle))
4409 (mm-attachment-override-p handle))))
4410 (mm-automatic-display-p handle)
4412 (mm-inlinable-p handle)
4413 (mm-inlined-p handle))
4414 (mm-automatic-external-display-p type)))
4416 (when (equal (mm-handle-media-supertype handle) "text")
4418 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4420 (push (cons id handle) gnus-article-mime-handle-alist)
4421 (when (or (not display)
4422 (not (gnus-unbuttonized-mime-type-p type)))
4423 ;(gnus-article-insert-newline)
4424 (gnus-insert-mime-button
4425 handle id (list (or display (and not-attachment text))))
4426 (gnus-article-insert-newline)
4427 ;(gnus-article-insert-newline)
4428 ;; Remember modify the number of forward lines.
4436 (let ((mail-parse-charset gnus-newsgroup-charset)
4437 (mail-parse-ignored-charsets
4438 (save-excursion (condition-case ()
4439 (set-buffer gnus-summary-buffer)
4441 gnus-newsgroup-ignored-charsets)))
4442 (mm-display-part handle t))
4443 (goto-char (point-max)))
4444 ((and text not-attachment)
4448 (gnus-article-insert-newline)
4449 (mm-insert-inline handle (mm-get-part handle))
4450 (goto-char (point-max))))
4454 (narrow-to-region beg (point))
4457 (gnus-article-mime-total-parts)
4458 (mm-handle-media-type handle)))))))))
4460 (defun gnus-unbuttonized-mime-type-p (type)
4461 "Say whether TYPE is to be unbuttonized."
4462 (unless gnus-inhibit-mime-unbuttonizing
4464 (let ((types gnus-unbuttonized-mime-types))
4466 (when (string-match (pop types) type)
4467 (throw 'found t)))))
4469 (let ((types gnus-buttonized-mime-types))
4471 (when (string-match (pop types) type)
4472 (throw 'found t)))))))))
4474 (defun gnus-article-insert-newline ()
4475 "Insert a newline, but mark it as undeletable."
4476 (gnus-put-text-property
4477 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4479 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4480 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4483 handle buffer-read-only from props begend not-pref)
4484 (save-window-excursion
4487 (narrow-to-region (car ibegend)
4490 (goto-char (car ibegend))
4493 (delete-region (point-min) (point-max))
4494 (mm-remove-parts handles))
4495 (setq begend (list (point-marker)))
4497 (unless (setq not-pref (cadr (member preferred ihandles)))
4498 (setq not-pref (car ihandles)))
4501 (not (gnus-unbuttonized-mime-type-p
4502 "multipart/alternative")))
4503 (gnus-add-text-properties
4506 (insert (format "%d. " id))
4510 (unless ,(not ibegend)
4511 (setq gnus-article-mime-handle-alist
4512 ',gnus-article-mime-handle-alist))
4513 (gnus-mime-display-alternative
4514 ',ihandles ',not-pref ',begend ,id))
4515 ,@(gnus-local-map-property gnus-mime-button-map)
4516 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4517 face ,gnus-article-button-face
4520 (widget-convert-button 'link from (point)
4521 :action 'gnus-widget-press-button
4522 :button-keymap gnus-widget-button-keymap)
4524 (while (setq handle (pop handles))
4525 (gnus-add-text-properties
4528 (insert (format "(%c) %-18s"
4529 (if (equal handle preferred) ?* ? )
4530 (mm-handle-media-type handle)))
4534 (unless ,(not ibegend)
4535 (setq gnus-article-mime-handle-alist
4536 ',gnus-article-mime-handle-alist))
4537 (gnus-mime-display-alternative
4538 ',ihandles ',handle ',begend ,id))
4539 ,@(gnus-local-map-property gnus-mime-button-map)
4540 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4541 face ,gnus-article-button-face
4544 (widget-convert-button 'link from (point)
4545 :action 'gnus-widget-press-button
4546 :button-keymap gnus-widget-button-keymap)
4550 (if (stringp (car preferred))
4551 (gnus-display-mime preferred)
4552 (let ((mail-parse-charset gnus-newsgroup-charset)
4553 (mail-parse-ignored-charsets
4554 (save-excursion (set-buffer gnus-summary-buffer)
4555 gnus-newsgroup-ignored-charsets)))
4556 (mm-display-part preferred)
4560 (narrow-to-region (car begend) (point-max))
4562 nil (length gnus-article-mime-handle-alist)
4563 (gnus-article-mime-total-parts)
4564 (mm-handle-media-type handle))))))
4565 (goto-char (point-max))
4566 (setcdr begend (point-marker)))))
4568 (goto-char point))))
4570 (defconst gnus-article-wash-status-strings
4571 (let ((alist '((cite "c" "Possible hidden citation text"
4572 " " "All citation text visible")
4573 (headers "h" "Hidden headers"
4574 " " "All headers visible.")
4575 (pgp "p" "Encrypted or signed message status hidden"
4576 " " "No hidden encryption nor digital signature status")
4577 (signature "s" "Signature has been hidden"
4578 " " "Signature is visible")
4579 (overstrike "o" "Overstrike (^H) characters applied"
4580 " " "No overstrike characters applied")
4581 (emphasis "e" "/*_Emphasis_*/ characters applied"
4582 " " "No /*_emphasis_*/ characters applied")))
4584 (dolist (entry alist result)
4585 (let ((key (nth 0 entry))
4586 (on (copy-sequence (nth 1 entry)))
4587 (on-help (nth 2 entry))
4588 (off (copy-sequence (nth 3 entry)))
4589 (off-help (nth 4 entry)))
4590 (put-text-property 0 1 'help-echo on-help on)
4591 (put-text-property 0 1 'help-echo off-help off)
4592 (push (list key on off) result))))
4593 "Alist of strings describing wash status in the mode line.
4594 Each entry has the form (KEY ON OF), where the KEY is a symbol
4595 representing the particular washing function, ON is the string to use
4596 in the article mode line when the washing function is active, and OFF
4597 is the string to use when it is inactive.")
4599 (defun gnus-article-wash-status-entry (key value)
4600 (let ((entry (assoc key gnus-article-wash-status-strings)))
4601 (if value (nth 1 entry) (nth 2 entry))))
4603 (defun gnus-article-wash-status ()
4604 "Return a string which display status of article washing."
4606 (set-buffer gnus-article-buffer)
4607 (let ((cite (memq 'cite gnus-article-wash-types))
4608 (headers (memq 'headers gnus-article-wash-types))
4609 (boring (memq 'boring-headers gnus-article-wash-types))
4610 (pgp (memq 'pgp gnus-article-wash-types))
4611 (pem (memq 'pem gnus-article-wash-types))
4612 (signed (memq 'signed gnus-article-wash-types))
4613 (encrypted (memq 'encrypted gnus-article-wash-types))
4614 (signature (memq 'signature gnus-article-wash-types))
4615 (overstrike (memq 'overstrike gnus-article-wash-types))
4616 (emphasis (memq 'emphasis gnus-article-wash-types)))
4618 (gnus-article-wash-status-entry 'cite cite)
4619 (gnus-article-wash-status-entry 'headers (or headers boring))
4620 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4621 (gnus-article-wash-status-entry 'signature signature)
4622 (gnus-article-wash-status-entry 'overstrike overstrike)
4623 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4625 (defun gnus-add-wash-type (type)
4626 "Add a washing of TYPE to the current status."
4627 (add-to-list 'gnus-article-wash-types type))
4629 (defun gnus-delete-wash-type (type)
4630 "Add a washing of TYPE to the current status."
4631 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4633 (defun gnus-add-image (category image)
4634 "Add IMAGE of CATEGORY to the list of displayed images."
4635 (let ((entry (assq category gnus-article-image-alist)))
4637 (setq entry (list category))
4638 (push entry gnus-article-image-alist))
4639 (nconc entry (list image))))
4641 (defun gnus-delete-images (category)
4642 "Delete all images in CATEGORY."
4643 (let ((entry (assq category gnus-article-image-alist)))
4644 (dolist (image (cdr entry))
4645 (gnus-remove-image image))
4646 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4647 (gnus-delete-wash-type category)))
4649 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4651 (defun gnus-article-maybe-hide-headers ()
4652 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4653 Provided for backwards compatibility."
4654 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4655 (not (save-excursion (set-buffer gnus-summary-buffer)
4656 gnus-have-all-headers)))
4657 (not gnus-inhibit-hiding))
4658 (gnus-article-hide-headers)))
4662 (defun gnus-output-to-file (file-name)
4663 "Append the current article to a file named FILE-NAME."
4664 (let ((artbuf (current-buffer)))
4666 (insert-buffer-substring artbuf)
4667 ;; Append newline at end of the buffer as separator, and then
4669 (goto-char (point-max))
4671 (let ((file-name-coding-system nnmail-pathname-coding-system))
4672 (mm-append-to-file (point-min) (point-max) file-name))
4675 (defun gnus-narrow-to-page (&optional arg)
4676 "Narrow the article buffer to a page.
4677 If given a numerical ARG, move forward ARG pages."
4679 (setq arg (if arg (prefix-numeric-value arg) 0))
4681 (set-buffer gnus-article-buffer)
4682 (goto-char (point-min))
4684 ;; Remove any old next/prev buttons.
4685 (when (gnus-visual-p 'page-marker)
4686 (let ((buffer-read-only nil))
4687 (gnus-remove-text-with-property 'gnus-prev)
4688 (gnus-remove-text-with-property 'gnus-next)))
4691 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4693 (re-search-forward page-delimiter nil 'move arg)))
4694 (goto-char (match-end 0)))
4697 (if (re-search-forward page-delimiter nil 'move)
4700 (when (and (gnus-visual-p 'page-marker)
4701 (not (= (point-min) 1)))
4703 (goto-char (point-min))
4704 (gnus-insert-prev-page-button)))
4705 (when (and (gnus-visual-p 'page-marker)
4706 (< (+ (point-max) 2) (buffer-size)))
4708 (goto-char (point-max))
4709 (gnus-insert-next-page-button)))))
4711 ;; Article mode commands
4713 (defun gnus-article-goto-next-page ()
4714 "Show the next page of the article."
4716 (when (gnus-article-next-page)
4717 (goto-char (point-min))
4718 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4720 (defun gnus-article-goto-prev-page ()
4721 "Show the next page of the article."
4723 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4724 (gnus-article-prev-page nil)))
4726 (defun gnus-article-next-page (&optional lines)
4727 "Show the next page of the current article.
4728 If end of article, return non-nil. Otherwise return nil.
4729 Argument LINES specifies lines to be scrolled up."
4731 (move-to-window-line -1)
4734 (and (pos-visible-in-window-p) ;Not continuation line.
4735 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
4736 ;; Nothing in this page.
4737 (if (or (not gnus-page-broken)
4740 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4742 (gnus-narrow-to-page 1) ;Go to next page.
4744 ;; More in this page.
4745 (let ((scroll-in-place nil))
4749 ;; Long lines may cause an end-of-buffer error.
4750 (goto-char (point-max)))))
4751 (move-to-window-line 0)
4754 (defun gnus-article-prev-page (&optional lines)
4755 "Show previous page of current article.
4756 Argument LINES specifies lines to be scrolled down."
4758 (move-to-window-line 0)
4759 (if (and gnus-page-broken
4761 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4763 (gnus-narrow-to-page -1) ;Go to previous page.
4764 (goto-char (point-max))
4766 (let ((scroll-in-place nil))
4770 (beginning-of-buffer
4771 (goto-char (point-min))))
4772 (move-to-window-line 0)))))
4774 (defun gnus-article-refer-article ()
4775 "Read article specified by message-id around point."
4777 (let ((point (point)))
4778 (search-forward ">" nil t) ;Move point to end of "<....>".
4779 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4780 (let ((message-id (match-string 1)))
4782 (set-buffer gnus-summary-buffer)
4783 (gnus-summary-refer-article message-id))
4785 (error "No references around point"))))
4787 (defun gnus-article-show-summary ()
4788 "Reconfigure windows to show summary buffer."
4790 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4791 (error "There is no summary buffer for this article buffer")
4792 (gnus-article-set-globals)
4793 (gnus-configure-windows 'article)
4794 (gnus-summary-goto-subject gnus-current-article)
4795 (gnus-summary-position-point)))
4797 (defun gnus-article-describe-briefly ()
4798 "Describe article mode commands briefly."
4800 (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")))
4802 (defun gnus-article-summary-command ()
4803 "Execute the last keystroke in the summary buffer."
4805 (let ((obuf (current-buffer))
4806 (owin (current-window-configuration))
4808 (switch-to-buffer gnus-article-current-summary 'norecord)
4809 (setq func (lookup-key (current-local-map) (this-command-keys)))
4810 (call-interactively func)
4812 (set-window-configuration owin)
4813 (set-window-point (get-buffer-window (current-buffer)) (point))))
4815 (defun gnus-article-summary-command-nosave ()
4816 "Execute the last keystroke in the summary buffer."
4819 (pop-to-buffer gnus-article-current-summary 'norecord)
4820 (setq func (lookup-key (current-local-map) (this-command-keys)))
4821 (call-interactively func)))
4823 (defun gnus-article-check-buffer ()
4824 "Beep if not in an article buffer."
4825 (unless (equal major-mode 'gnus-article-mode)
4826 (error "Command invoked outside of a Gnus article buffer")))
4828 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4829 "Read a summary buffer key sequence and execute it from the article buffer."
4831 (gnus-article-check-buffer)
4833 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4834 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4835 "=" "^" "\M-^" "|"))
4841 '("n" "Gn" "p" "Gp"))
4844 (set-buffer gnus-article-current-summary)
4845 (let (gnus-pick-mode)
4846 (push (or key last-command-event) unread-command-events)
4847 (setq keys (if (featurep 'xemacs)
4848 (events-to-keys (read-key-sequence nil))
4849 (read-key-sequence nil)))))
4853 (if (or (member keys nosaves)
4854 (member keys nosave-but-article)
4855 (member keys nosave-in-article))
4857 (save-window-excursion
4858 (pop-to-buffer gnus-article-current-summary 'norecord)
4859 ;; We disable the pick minor mode commands.
4860 (let (gnus-pick-mode)
4861 (setq func (lookup-key (current-local-map) keys))))
4865 (unless (member keys nosave-in-article)
4866 (set-buffer gnus-article-current-summary))
4867 (call-interactively func)
4868 (setq new-sum-point (point)))
4869 (when (member keys nosave-but-article)
4870 (pop-to-buffer gnus-article-buffer 'norecord)))
4871 ;; These commands should restore window configuration.
4872 (let ((obuf (current-buffer))
4873 (owin (current-window-configuration))
4875 (summary gnus-article-current-summary)
4876 func in-buffer selected)
4877 (if not-restore-window
4878 (pop-to-buffer summary 'norecord)
4879 (switch-to-buffer summary 'norecord))
4880 (setq in-buffer (current-buffer))
4881 ;; We disable the pick minor mode commands.
4882 (if (and (setq func (let (gnus-pick-mode)
4883 (lookup-key (current-local-map) keys)))
4886 (call-interactively func)
4887 (setq new-sum-point (point))
4888 (when (eq in-buffer (current-buffer))
4889 (setq selected (gnus-summary-select-article))
4891 (unless not-restore-window
4892 (set-window-configuration owin))
4893 (when (eq selected 'old)
4895 (set-window-start (get-buffer-window (current-buffer))
4897 (set-window-point (get-buffer-window (current-buffer))
4899 (let ((win (get-buffer-window gnus-article-current-summary)))
4901 (set-window-point win new-sum-point)))) )
4902 (switch-to-buffer gnus-article-buffer)
4905 (defun gnus-article-describe-key (key)
4906 "Display documentation of the function invoked by KEY. KEY is a string."
4907 (interactive "kDescribe key: ")
4908 (gnus-article-check-buffer)
4909 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4911 (set-buffer gnus-article-current-summary)
4912 (let (gnus-pick-mode)
4913 (if (featurep 'xemacs)
4915 (push (elt key 0) unread-command-events)
4916 (setq key (events-to-keys
4917 (read-key-sequence "Describe key: "))))
4918 (setq unread-command-events
4920 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4921 (string-to-list key)))
4922 (setq key (read-key-sequence "Describe key: "))))
4924 (describe-key key)))
4926 (defun gnus-article-describe-key-briefly (key &optional insert)
4927 "Display documentation of the function invoked by KEY. KEY is a string."
4928 (interactive "kDescribe key: \nP")
4929 (gnus-article-check-buffer)
4930 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4932 (set-buffer gnus-article-current-summary)
4933 (let (gnus-pick-mode)
4934 (if (featurep 'xemacs)
4936 (push (elt key 0) unread-command-events)
4937 (setq key (events-to-keys
4938 (read-key-sequence "Describe key: "))))
4939 (setq unread-command-events
4941 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4942 (string-to-list key)))
4943 (setq key (read-key-sequence "Describe key: "))))
4944 (describe-key-briefly key insert))
4945 (describe-key-briefly key insert)))
4947 (defun gnus-article-reply-with-original (&optional wide)
4948 "Start composing a reply mail to the current message.
4949 The text in the region will be yanked. If the region isn't active,
4950 the entire article will be yanked."
4952 (let ((article (cdr gnus-article-current)) cont)
4954 (with-current-buffer gnus-summary-buffer
4955 (gnus-summary-reply (list (list article)) wide))
4956 (setq cont (buffer-substring (point) (mark t)))
4957 ;; Deactivate active regions.
4958 (when (and (boundp 'transient-mark-mode)
4959 transient-mark-mode)
4960 (setq mark-active nil))
4961 (with-current-buffer gnus-summary-buffer
4963 (list (list article cont)) wide)))))
4965 (defun gnus-article-followup-with-original ()
4966 "Compose a followup to the current article.
4967 The text in the region will be yanked. If the region isn't active,
4968 the entire article will be yanked."
4970 (let ((article (cdr gnus-article-current)) cont)
4972 (with-current-buffer gnus-summary-buffer
4973 (gnus-summary-followup (list (list article))))
4974 (setq cont (buffer-substring (point) (mark t)))
4975 ;; Deactivate active regions.
4976 (when (and (boundp 'transient-mark-mode)
4977 transient-mark-mode)
4978 (setq mark-active nil))
4979 (with-current-buffer gnus-summary-buffer
4980 (gnus-summary-followup
4981 (list (list article cont)))))))
4983 (defun gnus-article-hide (&optional arg force)
4984 "Hide all the gruft in the current article.
4985 This means that PGP stuff, signatures, cited text and (some)
4986 headers will be hidden.
4987 If given a prefix, show the hidden text instead."
4988 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4989 (gnus-article-hide-headers arg)
4990 (gnus-article-hide-list-identifiers arg)
4991 (gnus-article-hide-pgp arg)
4992 (gnus-article-hide-citation-maybe arg force)
4993 (gnus-article-hide-signature arg))
4995 (defun gnus-article-maybe-highlight ()
4996 "Do some article highlighting if article highlighting is requested."
4997 (when (gnus-visual-p 'article-highlight 'highlight)
4998 (gnus-article-highlight-some)))
5000 (defun gnus-check-group-server ()
5001 ;; Make sure the connection to the server is alive.
5002 (unless (gnus-server-opened
5003 (gnus-find-method-for-group gnus-newsgroup-name))
5004 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5005 (gnus-request-group gnus-newsgroup-name t)))
5008 (autoload 'nneething-get-file-name "nneething"))
5010 (defun gnus-request-article-this-buffer (article group)
5011 "Get an article and insert it into this buffer."
5012 (let (do-update-line sparse-header)
5016 (gnus-kill-all-overlays)
5017 (setq group (or group gnus-newsgroup-name))
5019 ;; Using `gnus-request-article' directly will insert the article into
5020 ;; `nntp-server-buffer' - so we'll save some time by not having to
5021 ;; copy it from the server buffer into the article buffer.
5023 ;; We only request an article by message-id when we do not have the
5024 ;; headers for it, so we'll have to get those.
5025 (when (stringp article)
5026 (gnus-read-header article))
5028 ;; If the article number is negative, that means that this article
5029 ;; doesn't belong in this newsgroup (possibly), so we find its
5030 ;; message-id and request it by id instead of number.
5031 (when (and (numberp article)
5033 (get-buffer gnus-summary-buffer)
5034 (gnus-buffer-exists-p gnus-summary-buffer))
5036 (set-buffer gnus-summary-buffer)
5037 (let ((header (gnus-summary-article-header article)))
5040 ((memq article gnus-newsgroup-sparse)
5041 ;; This is a sparse gap article.
5042 (setq do-update-line article)
5043 (setq article (mail-header-id header))
5044 (setq sparse-header (gnus-read-header article))
5045 (setq gnus-newsgroup-sparse
5046 (delq article gnus-newsgroup-sparse)))
5048 ;; It's a real article.
5049 (setq article (mail-header-id header)))
5051 ;; It is an extracted pseudo-article.
5052 (setq article 'pseudo)
5053 (gnus-request-pseudo-article header))))
5055 (let ((method (gnus-find-method-for-group
5056 gnus-newsgroup-name)))
5057 (when (and (eq (car method) 'nneething)
5059 (let ((dir (nneething-get-file-name
5060 (mail-header-id header))))
5061 (when (and (stringp dir)
5062 (file-directory-p dir))
5063 (setq article 'nneething)
5064 (gnus-group-enter-directory dir))))))))
5067 ;; Refuse to select canceled articles.
5068 ((and (numberp article)
5070 (get-buffer gnus-summary-buffer)
5071 (gnus-buffer-exists-p gnus-summary-buffer)
5072 (eq (cdr (save-excursion
5073 (set-buffer gnus-summary-buffer)
5074 (assq article gnus-newsgroup-reads)))
5075 gnus-canceled-mark))
5077 ;; We first check `gnus-original-article-buffer'.
5078 ((and (get-buffer gnus-original-article-buffer)
5081 (set-buffer gnus-original-article-buffer)
5082 (and (equal (car gnus-original-article) group)
5083 (eq (cdr gnus-original-article) article))))
5084 (insert-buffer-substring gnus-original-article-buffer)
5086 ;; Check the backlog.
5087 ((and gnus-keep-backlog
5088 (gnus-backlog-request-article group article (current-buffer)))
5090 ;; Check asynchronous pre-fetch.
5091 ((gnus-async-request-fetched-article group article (current-buffer))
5092 (gnus-async-prefetch-next group article gnus-summary-buffer)
5093 (when (and (numberp article) gnus-keep-backlog)
5094 (gnus-backlog-enter-article group article (current-buffer)))
5097 ((and gnus-use-cache
5099 (gnus-cache-request-article article group))
5101 ;; Check the agent cache.
5102 ((and gnus-agent gnus-agent-cache gnus-plugged
5104 (gnus-agent-request-article article group))
5106 ;; Get the article and put into the article buffer.
5107 ((or (stringp article)
5109 (let ((gnus-override-method gnus-override-method)
5110 (methods (and (stringp article)
5111 gnus-refer-article-method))
5112 (backend (car (gnus-find-method-for-group
5113 gnus-newsgroup-name)))
5115 (buffer-read-only nil))
5116 (if (or (not (listp methods))
5117 (and (symbolp (car methods))
5118 (assq (car methods) nnoo-definition-alist)))
5119 (setq methods (list methods)))
5120 (when (and (null gnus-override-method)
5122 (setq gnus-override-method (pop methods)))
5124 (when (eq gnus-override-method 'current)
5125 (setq gnus-override-method
5126 (with-current-buffer gnus-summary-buffer
5127 gnus-current-select-method)))
5129 (gnus-kill-all-overlays)
5130 (let ((gnus-newsgroup-name group))
5131 (gnus-check-group-server))
5133 ((gnus-request-article article group (current-buffer))
5134 (when (numberp article)
5135 (gnus-async-prefetch-next group article
5136 gnus-summary-buffer)
5137 (when gnus-keep-backlog
5138 (gnus-backlog-enter-article
5139 group article (current-buffer))))
5140 (setq result 'article))
5142 (setq gnus-override-method (pop methods)))
5143 ((not (string-match "^400 "
5144 (nnheader-get-report backend)))
5145 ;; If we get 400 server disconnect, reconnect and
5146 ;; retry; otherwise, assume the article has expired.
5147 (setq result 'done))))
5148 (and (eq result 'article) 'article)))
5152 ;; Associate this article with the current summary buffer.
5153 (setq gnus-article-current-summary gnus-summary-buffer)
5155 ;; Take the article from the original article buffer
5156 ;; and place it in the buffer it's supposed to be in.
5157 (when (and (get-buffer gnus-article-buffer)
5158 (equal (buffer-name (current-buffer))
5159 (buffer-name (get-buffer gnus-article-buffer))))
5161 (if (get-buffer gnus-original-article-buffer)
5162 (set-buffer gnus-original-article-buffer)
5163 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5164 (buffer-disable-undo)
5165 (setq major-mode 'gnus-original-article-mode)
5166 (setq buffer-read-only t))
5167 (let (buffer-read-only)
5169 (insert-buffer-substring gnus-article-buffer))
5170 (setq gnus-original-article (cons group article)))
5173 (run-hooks 'gnus-article-decode-hook)
5174 ;; Mark article as decoded or not.
5175 (setq gnus-article-decoded-p gnus-article-decode-hook))
5177 ;; Update sparse articles.
5178 (when (and do-update-line
5179 (or (numberp article)
5181 (let ((buf (current-buffer)))
5182 (set-buffer gnus-summary-buffer)
5183 (gnus-summary-update-article do-update-line sparse-header)
5184 (gnus-summary-goto-subject do-update-line nil t)
5185 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5187 (set-buffer buf))))))
5193 (defcustom gnus-article-edit-mode-hook nil
5194 "Hook run in article edit mode buffers."
5195 :group 'gnus-article-various
5198 (defvar gnus-article-edit-done-function nil)
5200 (defvar gnus-article-edit-mode-map nil)
5201 (defvar gnus-article-edit-mode nil)
5203 ;; Should we be using derived.el for this?
5204 (unless gnus-article-edit-mode-map
5205 (setq gnus-article-edit-mode-map (make-keymap))
5206 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5208 (gnus-define-keys gnus-article-edit-mode-map
5209 "\C-c?" describe-mode
5210 "\C-c\C-c" gnus-article-edit-done
5211 "\C-c\C-k" gnus-article-edit-exit
5212 "\C-c\C-f\C-t" message-goto-to
5213 "\C-c\C-f\C-o" message-goto-from
5214 "\C-c\C-f\C-b" message-goto-bcc
5215 ;;"\C-c\C-f\C-w" message-goto-fcc
5216 "\C-c\C-f\C-c" message-goto-cc
5217 "\C-c\C-f\C-s" message-goto-subject
5218 "\C-c\C-f\C-r" message-goto-reply-to
5219 "\C-c\C-f\C-n" message-goto-newsgroups
5220 "\C-c\C-f\C-d" message-goto-distribution
5221 "\C-c\C-f\C-f" message-goto-followup-to
5222 "\C-c\C-f\C-m" message-goto-mail-followup-to
5223 "\C-c\C-f\C-k" message-goto-keywords
5224 "\C-c\C-f\C-u" message-goto-summary
5225 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5226 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5227 "\C-c\C-b" message-goto-body
5228 "\C-c\C-i" message-goto-signature
5230 "\C-c\C-t" message-insert-to
5231 "\C-c\C-n" message-insert-newsgroups
5232 "\C-c\C-o" message-sort-headers
5233 "\C-c\C-e" message-elide-region
5234 "\C-c\C-v" message-delete-not-region
5235 "\C-c\C-z" message-kill-to-signature
5236 "\M-\r" message-newline-and-reformat
5237 "\C-c\C-a" mml-attach-file
5238 "\C-a" message-beginning-of-line
5240 "\M-;" comment-region)
5242 (gnus-define-keys (gnus-article-edit-wash-map
5243 "\C-c\C-w" gnus-article-edit-mode-map)
5244 "f" gnus-article-edit-full-stops))
5247 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5249 ["Fetch To" message-insert-to t]
5250 ["Fetch Newsgroups" message-insert-newsgroups t]
5252 ["To" message-goto-to t]
5253 ["From" message-goto-from t]
5254 ["Subject" message-goto-subject t]
5255 ["Cc" message-goto-cc t]
5256 ["Reply-To" message-goto-reply-to t]
5257 ["Summary" message-goto-summary t]
5258 ["Keywords" message-goto-keywords t]
5259 ["Newsgroups" message-goto-newsgroups t]
5260 ["Followup-To" message-goto-followup-to t]
5261 ["Mail-Followup-To" message-goto-mail-followup-to t]
5262 ["Distribution" message-goto-distribution t]
5263 ["Body" message-goto-body t]
5264 ["Signature" message-goto-signature t]))
5266 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5267 "Major mode for editing articles.
5268 This is an extended text-mode.
5270 \\{gnus-article-edit-mode-map}"
5271 (make-local-variable 'gnus-article-edit-done-function)
5272 (make-local-variable 'gnus-prev-winconf)
5273 (set (make-local-variable 'font-lock-defaults)
5274 '(message-font-lock-keywords t))
5275 (set (make-local-variable 'mail-header-separator) "")
5276 (set (make-local-variable 'gnus-article-edit-mode) t)
5277 (easy-menu-add message-mode-field-menu message-mode-map)
5279 (setq buffer-read-only nil)
5280 (buffer-enable-undo)
5283 (defun gnus-article-edit (&optional force)
5284 "Edit the current article.
5285 This will have permanent effect only in mail groups.
5286 If FORCE is non-nil, allow editing of articles even in read-only
5289 (when (and (not force)
5290 (gnus-group-read-only-p))
5291 (error "The current newsgroup does not support article editing"))
5292 (gnus-article-date-original)
5293 (gnus-article-edit-article
5295 `(lambda (no-highlight)
5297 (gnus-summary-edit-article-done
5298 ,(or (mail-header-references gnus-current-headers) "")
5299 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5301 (defun gnus-article-edit-article (start-func exit-func)
5302 "Start editing the contents of the current article buffer."
5303 (let ((winconf (current-window-configuration)))
5304 (set-buffer gnus-article-buffer)
5305 (gnus-article-edit-mode)
5306 (funcall start-func)
5307 (set-buffer-modified-p nil)
5308 (gnus-configure-windows 'edit-article)
5309 (setq gnus-article-edit-done-function exit-func)
5310 (setq gnus-prev-winconf winconf)
5311 (gnus-message 6 "C-c C-c to end edits")))
5313 (defun gnus-article-edit-done (&optional arg)
5314 "Update the article edits and exit."
5316 (let ((func gnus-article-edit-done-function)
5317 (buf (current-buffer))
5318 (start (window-start))
5320 (winconf gnus-prev-winconf))
5321 (widen) ;; Widen it in case that users narrowed the buffer.
5324 ;; The cache and backlog have to be flushed somewhat.
5325 (when gnus-keep-backlog
5326 (gnus-backlog-remove-article
5327 (car gnus-article-current) (cdr gnus-article-current)))
5328 ;; Flush original article as well.
5330 (when (get-buffer gnus-original-article-buffer)
5331 (set-buffer gnus-original-article-buffer)
5332 (setq gnus-original-article nil)))
5333 (when gnus-use-cache
5334 (gnus-cache-update-article
5335 (car gnus-article-current) (cdr gnus-article-current)))
5336 ;; We remove all text props from the article buffer.
5337 (kill-all-local-variables)
5338 (gnus-set-text-properties (point-min) (point-max) nil)
5340 (set-window-configuration winconf)
5342 (set-window-start (get-buffer-window buf) start)
5343 (set-window-point (get-buffer-window buf) (point))))
5345 (defun gnus-article-edit-exit ()
5346 "Exit the article editing without updating."
5348 (when (or (not (buffer-modified-p))
5349 (yes-or-no-p "Article modified; kill anyway? "))
5350 (let ((curbuf (current-buffer))
5352 (window-start (window-start)))
5354 (if (gnus-buffer-live-p gnus-original-article-buffer)
5355 (insert-buffer gnus-original-article-buffer))
5356 (let ((winconf gnus-prev-winconf))
5357 (kill-all-local-variables)
5359 (set-window-configuration winconf)
5360 ;; Tippy-toe some to make sure that point remains where it was.
5361 (save-current-buffer
5363 (set-window-start (get-buffer-window (current-buffer)) window-start)
5366 (defun gnus-article-edit-full-stops ()
5367 "Interactively repair spacing at end of sentences."
5370 (goto-char (point-min))
5371 (search-forward-regexp "^$" nil t)
5372 (let ((case-fold-search nil))
5373 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5376 ;;; Article highlights
5379 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5381 ;;; Internal Variables:
5383 (defcustom gnus-button-url-regexp
5384 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5385 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~`%&*+|\\/:;.,[:word:]]+[-a-z0-9_=#$@~`%&*+|\\/[:word:]]\\)"
5386 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~`%&*+|\\/]\\|\\w\\)\\)")
5387 "Regular expression that matches URLs."
5388 :group 'gnus-article-buttons
5391 (defcustom gnus-button-valid-fqdn-regexp
5392 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
5394 "\\([a-z][a-z]" ;; two letter country TDLs
5395 "\\|biz\\|com\\|edu\\|gov\\|int\\|mil\\|net\\|org"
5396 "\\|aero\\|coop\\|info\\|name\\|museum"
5397 "\\|arpa\\|pro\\|uucp\\|bitnet\\|bofh" ;; old style?
5399 "Regular expression that matches a valid FQDN."
5400 :group 'gnus-article-buttons
5403 (defcustom gnus-button-man-handler 'manual-entry
5404 "Function to use for displaying man pages.
5405 The function must take at least one argument with a string naming the
5407 :type '(choice (function-item :tag "Man" manual-entry)
5408 (function-item :tag "Woman" woman)
5409 (function :tag "Other"))
5410 :group 'gnus-article-buttons)
5412 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5413 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5414 If the default site is too slow, try to find a CTAN mirror, see
5415 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5416 the variable `gnus-button-handle-ctan'."
5417 :group 'gnus-article-buttons
5418 :link '(custom-manual "(gnus)Group Parameters")
5419 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5420 (const "http://tug.ctan.org/tex-archive/")
5421 (const "http://www.dante.de/CTAN/")
5422 (string :tag "Other")))
5424 (defcustom gnus-button-ctan-handler 'browse-url
5425 "Function to use for displaying CTAN links.
5426 The function must take one argument, the string naming the URL."
5427 :type '(choice (function-item :tag "Browse Url" browse-url)
5428 (function :tag "Other"))
5429 :group 'gnus-article-buttons)
5431 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5432 "Bogus strings removed from CTAN URLs."
5433 :group 'gnus-article-buttons
5434 :type '(choice (const "^/?tex-archive/\\|/")
5435 (regexp :tag "Other")))
5437 (defcustom gnus-button-mid-or-mail-regexp
5438 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
5439 gnus-button-valid-fqdn-regexp
5441 "Regular expression that matches a message ID or a mail address."
5442 :group 'gnus-article-buttons
5445 (defcustom gnus-button-prefer-mid-or-mail 'guess
5446 "What to do when the button on a string as \"foo123@bar.com\" is pushed.
5447 Strings like this can be either a message ID or a mail address. If the
5448 variable is set to the symbol `ask', query the user what do do. If it is the
5449 symbol `guess', Gnus will do a guess and query the user what do do if it is
5450 ambiguous. See the variable `gnus-button-guessed-mid-regexp' for details
5451 concerning the guessing. If it is one of the sybols `mid' or `mail', Gnus
5452 will always assume that the string is a message ID or a mail address,
5454 ;; FIXME: doc-string could/should be improved.
5455 :group 'gnus-article-buttons
5456 :type '(choice (const ask)
5461 (defcustom gnus-button-guessed-mid-regexp
5463 "^<?\\(slrn\\|Pine\\.\\)"
5464 "\\|\\.fsf@\\|\\.fsf_-_@\\|\\.ln@"
5465 "\\|@4ax\\.com\\|@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de"
5466 "\\|^<?.*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*@")
5467 "Regular expression that matches message IDs and not mail addresses."
5468 ;; TODO: Incorporate more matches from
5469 ;; <URL:http://piology.org/perl/id-or-mail.pl.html>. I.e. translate the
5470 ;; Perl-REs to Elisp-REs.
5471 :group 'gnus-article-buttons
5474 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5475 (let* ((pref gnus-button-prefer-mid-or-mail)
5476 (url-mid (concat "news" ":" mid-or-mail))
5477 (url-mailto (concat "mailto" ":" mid-or-mail)))
5478 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5479 ;; If it looks like a MID (well known readers or servers) use 'mid,
5480 ;; otherwise 'ask the user.
5481 (if (eq pref 'guess)
5482 (if (string-match gnus-button-guessed-mid-regexp mid-or-mail)
5486 (save-window-excursion
5487 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5490 (cond ((eq pref 'mid)
5491 (gnus-message 9 "calling `gnus-button-handle-news' %s" url-mid)
5492 (gnus-button-handle-news url-mid))
5494 (gnus-message 9 "calling `gnus-url-mailto' %s" url-mailto)
5495 (gnus-url-mailto url-mailto)))))
5497 (defun gnus-button-handle-custom (url)
5498 "Follow a Custom URL."
5499 (customize-apropos (gnus-url-unhex-string url)))
5501 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5503 (defun gnus-button-handle-describe-function (url)
5504 "Call describe-function when pushing the corresponding URL button."
5507 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5509 (defun gnus-button-handle-describe-variable (url)
5510 "Call describe-variable when pushing the corresponding URL button."
5513 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5515 ;; FIXME: Is is possible to implement this? Else it should be removed here
5516 ;; and in `gnus-button-alist'.
5517 (defun gnus-button-handle-describe-key (url)
5518 "Call describe-key when pushing the corresponding URL button."
5519 (error "not implemented"))
5521 (defun gnus-button-handle-apropos (url)
5522 "Call apropos when pushing the corresponding URL button."
5523 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5525 (defun gnus-button-handle-apropos-command (url)
5526 "Call apropos when pushing the corresponding URL button."
5528 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5530 (defun gnus-button-handle-apropos-variable (url)
5531 "Call apropos when pushing the corresponding URL button."
5533 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5534 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5536 (defun gnus-button-handle-apropos-documentation (url)
5537 "Call apropos when pushing the corresponding URL button."
5539 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
5540 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5542 (defun gnus-button-handle-ctan (url)
5543 "Call `browse-url' when pushing a CTAN URL button."
5545 gnus-button-ctan-handler
5548 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
5550 (defcustom gnus-button-tex-level 5
5551 "*Integer that says how many TeX-related buttons Gnus will show.
5552 The higher the number, the more buttons will appear and the more false
5553 positives are possible. Note that you can set this variable local to
5554 specifific groups. Setting it higher in TeX groups is probably a good idea.
5555 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5556 how to set variables in specific groups."
5557 :group 'gnus-article-buttons
5558 :link '(custom-manual "(gnus)Group Parameters")
5561 (defcustom gnus-button-man-level 5
5562 "*Integer that says how many man-related buttons Gnus will show.
5563 The higher the number, the more buttons will appear and the more false
5564 positives are possible. Note that you can set this variable local to
5565 specifific groups. Setting it higher in Unix groups is probably a good idea.
5566 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5567 how to set variables in specific groups."
5568 :group 'gnus-article-buttons
5569 :link '(custom-manual "(gnus)Group Parameters")
5572 (defcustom gnus-button-emacs-level 5
5573 "*Integer that says how many emacs-related buttons Gnus will show.
5574 The higher the number, the more buttons will appear and the more false
5575 positives are possible. Note that you can set this variable local to
5576 specifific groups. Setting it higher in Emacs or Gnus related groups is
5577 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
5578 `gnus-parameters' on how to set variables in specific groups."
5579 :group 'gnus-article-buttons
5580 :link '(custom-manual "(gnus)Group Parameters")
5583 (defcustom gnus-button-mail-level 5
5584 "*Integer that says how many buttons for message IDs or mail addresses will appear.
5585 The higher the number, the more buttons will appear and the more false
5586 positives are possible."
5587 :group 'gnus-article-buttons
5590 (defcustom gnus-button-alist
5591 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5592 0 t gnus-button-handle-news 3)
5593 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5594 gnus-button-handle-news 2)
5595 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5597 gnus-button-fetch-group 4)
5598 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5599 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5600 t gnus-button-message-id 3)
5601 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5602 ("mailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5603 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5605 ("\\bCTAN:[ \t\n]*\\([^>)!;:,\n\t ]*\\)" 0 (>= gnus-button-tex-level 1)
5606 gnus-button-handle-ctan 1)
5608 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5609 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2)
5611 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5612 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
5613 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5614 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
5615 ;; Emacs help commands
5616 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5617 ;; regexp doesn't match arguments containing ` '.
5618 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
5619 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5620 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
5621 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5622 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
5623 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5624 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
5625 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5626 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
5627 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5628 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
5629 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+" 0
5630 ;; this regexp needs to be fixed!
5631 (>= gnus-button-emacs-level 9) gnus-button-handle-describe-key 2)
5632 ;; This is how URLs _should_ be embedded in text...
5633 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5635 (gnus-button-url-regexp 0 t browse-url 0)
5637 ("\\b\\([a-z][a-z]+\\)([1-9])\\W" 0
5638 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
5639 gnus-button-handle-man 1)
5640 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
5641 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W" 0
5642 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
5643 gnus-button-handle-man 1)
5644 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
5645 ;; SoWWWAnchor(3iv), XSelectInput(3X11)
5646 ("\\b\\([a-z][-_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W" 0
5647 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
5648 ;; MID or mail: To avoid too many false positives we don't try to catch
5649 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
5650 ;; at least one dot. TLD must contain two or three chars or be a know TLD
5651 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
5652 ;; so that non-ambiguous entries (see above) match first.
5653 (gnus-button-mid-or-mail-regexp
5654 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1))
5655 "*Alist of regexps matching buttons in article bodies.
5657 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5658 REGEXP: is the string (case insensitive) matching text around the button (can
5659 also be lisp expression evaluating to a string),
5660 BUTTON: is the number of the regexp grouping actually matching the button,
5661 FORM: is a lisp expression which must eval to true for the button to
5663 CALLBACK: is the function to call when the user push this button, and each
5664 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5666 CALLBACK can also be a variable, in that case the value of that
5667 variable it the real callback function."
5668 :group 'gnus-article-buttons
5669 :type '(repeat (list (choice regexp variable)
5670 (integer :tag "Button")
5672 (function :tag "Callback")
5675 (integer :tag "Regexp group")))))
5677 (defcustom gnus-header-button-alist
5678 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5679 0 t gnus-button-message-id 0)
5680 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5681 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5682 0 t gnus-button-mailto 0)
5683 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
5684 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
5685 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
5686 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5687 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5688 gnus-button-message-id 3))
5689 "*Alist of headers and regexps to match buttons in article heads.
5691 This alist is very similar to `gnus-button-alist', except that each
5692 alist has an additional HEADER element first in each entry:
5694 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5696 HEADER is a regexp to match a header. For a fuller explanation, see
5697 `gnus-button-alist'."
5698 :group 'gnus-article-buttons
5699 :group 'gnus-article-headers
5700 :type '(repeat (list (regexp :tag "Header")
5702 (integer :tag "Button")
5704 (function :tag "Callback")
5707 (integer :tag "Regexp group")))))
5709 (defvar gnus-button-regexp nil)
5710 (defvar gnus-button-marker-list nil)
5711 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5713 (defvar gnus-button-last nil)
5714 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5718 (defun gnus-article-push-button (event)
5719 "Check text under the mouse pointer for a callback function.
5720 If the text under the mouse pointer has a `gnus-callback' property,
5721 call it with the value of the `gnus-data' text property."
5723 (set-buffer (window-buffer (posn-window (event-start event))))
5724 (let* ((pos (posn-point (event-start event)))
5725 (data (get-text-property pos 'gnus-data))
5726 (fun (get-text-property pos 'gnus-callback)))
5729 (funcall fun data))))
5731 (defun gnus-article-press-button ()
5732 "Check text at point for a callback function.
5733 If the text at point has a `gnus-callback' property,
5734 call it with the value of the `gnus-data' text property."
5736 (let* ((data (get-text-property (point) 'gnus-data))
5737 (fun (get-text-property (point) 'gnus-callback)))
5739 (funcall fun data))))
5741 (defun gnus-article-highlight (&optional force)
5742 "Highlight current article.
5743 This function calls `gnus-article-highlight-headers',
5744 `gnus-article-highlight-citation',
5745 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5746 do the highlighting. See the documentation for those functions."
5747 (interactive (list 'force))
5748 (gnus-article-highlight-headers)
5749 (gnus-article-highlight-citation force)
5750 (gnus-article-highlight-signature)
5751 (gnus-article-add-buttons force)
5752 (gnus-article-add-buttons-to-head))
5754 (defun gnus-article-highlight-some (&optional force)
5755 "Highlight current article.
5756 This function calls `gnus-article-highlight-headers',
5757 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5758 do the highlighting. See the documentation for those functions."
5759 (interactive (list 'force))
5760 (gnus-article-highlight-headers)
5761 (gnus-article-highlight-signature)
5762 (gnus-article-add-buttons))
5764 (defun gnus-article-highlight-headers ()
5765 "Highlight article headers as specified by `gnus-header-face-alist'."
5768 (set-buffer gnus-article-buffer)
5770 (let ((alist gnus-header-face-alist)
5771 (buffer-read-only nil)
5772 (case-fold-search t)
5773 (inhibit-point-motion-hooks t)
5774 entry regexp header-face field-face from hpoints fpoints)
5775 (article-narrow-to-head)
5776 (while (setq entry (pop alist))
5777 (goto-char (point-min))
5778 (setq regexp (concat "^\\("
5779 (if (string-equal "" (nth 0 entry))
5783 header-face (nth 1 entry)
5784 field-face (nth 2 entry))
5785 (while (and (re-search-forward regexp nil t)
5789 (unless (search-forward ":" nil t)
5791 (when (and header-face
5792 (not (memq (point) hpoints)))
5793 (push (point) hpoints)
5794 (gnus-put-text-property from (point) 'face header-face))
5795 (when (and field-face
5796 (not (memq (setq from (point)) fpoints)))
5798 (if (re-search-forward "^[^ \t]" nil t)
5800 (goto-char (point-max)))
5801 (gnus-put-text-property from (point) 'face field-face))))))))
5803 (defun gnus-article-highlight-signature ()
5804 "Highlight the signature in an article.
5805 It does this by highlighting everything after
5806 `gnus-signature-separator' using `gnus-signature-face'."
5809 (set-buffer gnus-article-buffer)
5810 (let ((buffer-read-only nil)
5811 (inhibit-point-motion-hooks t))
5813 (when (and gnus-signature-face
5814 (gnus-article-narrow-to-signature))
5815 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5816 'face gnus-signature-face)
5818 (gnus-article-search-signature)
5819 (let ((start (match-beginning 0))
5820 (end (set-marker (make-marker) (1+ (match-end 0)))))
5821 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5824 (defun gnus-button-in-region-p (b e prop)
5825 "Say whether PROP exists in the region."
5826 (text-property-not-all b e prop nil))
5828 (defun gnus-article-add-buttons (&optional force)
5829 "Find external references in the article and make buttons of them.
5830 \"External references\" are things like Message-IDs and URLs, as
5831 specified by `gnus-button-alist'."
5832 (interactive (list 'force))
5834 (set-buffer gnus-article-buffer)
5835 (let ((buffer-read-only nil)
5836 (inhibit-point-motion-hooks t)
5837 (case-fold-search t)
5838 (alist gnus-button-alist)
5840 ;; Remove all old markers.
5841 (let (marker entry new-list)
5842 (while (setq marker (pop gnus-button-marker-list))
5843 (if (or (< marker (point-min)) (>= marker (point-max)))
5844 (push marker new-list)
5846 (when (setq entry (gnus-button-entry))
5847 (put-text-property (match-beginning (nth 1 entry))
5848 (match-end (nth 1 entry))
5849 'gnus-callback nil))
5850 (set-marker marker nil)))
5851 (setq gnus-button-marker-list new-list))
5852 ;; We skip the headers.
5855 (while (setq entry (pop alist))
5856 (setq regexp (eval (car entry)))
5858 (while (re-search-forward regexp nil t)
5859 (let* ((start (and entry (match-beginning (nth 1 entry))))
5860 (end (and entry (match-end (nth 1 entry))))
5861 (from (match-beginning 0)))
5862 (when (and (or (eq t (nth 2 entry))
5863 (eval (nth 2 entry)))
5864 (not (gnus-button-in-region-p
5865 start end 'gnus-callback)))
5866 ;; That optional form returned non-nil, so we add the
5868 (gnus-article-add-button
5869 start end 'gnus-button-push
5870 (car (push (set-marker (make-marker) from)
5871 gnus-button-marker-list))))))))))
5873 ;; Add buttons to the head of an article.
5874 (defun gnus-article-add-buttons-to-head ()
5875 "Add buttons to the head of the article."
5878 (set-buffer gnus-article-buffer)
5880 (let ((buffer-read-only nil)
5881 (inhibit-point-motion-hooks t)
5882 (case-fold-search t)
5883 (alist gnus-header-button-alist)
5885 (article-narrow-to-head)
5887 ;; Each alist entry.
5888 (setq entry (car alist)
5890 (goto-char (point-min))
5891 (while (re-search-forward (car entry) nil t)
5892 ;; Each header matching the entry.
5893 (setq beg (match-beginning 0))
5894 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5895 (match-beginning 0))
5898 (while (re-search-forward (eval (nth 1 entry)) end t)
5899 ;; Each match within a header.
5900 (let* ((entry (cdr entry))
5901 (start (match-beginning (nth 1 entry)))
5902 (end (match-end (nth 1 entry)))
5903 (form (nth 2 entry)))
5904 (goto-char (match-end 0))
5906 (gnus-article-add-button
5907 start end (nth 3 entry)
5908 (buffer-substring (match-beginning (nth 4 entry))
5909 (match-end (nth 4 entry)))))))
5910 (goto-char end)))))))
5912 ;;; External functions:
5914 (defun gnus-article-add-button (from to fun &optional data)
5915 "Create a button between FROM and TO with callback FUN and data DATA."
5916 (when gnus-article-button-face
5917 (gnus-overlay-put (gnus-make-overlay from to)
5918 'face gnus-article-button-face))
5919 (gnus-add-text-properties
5921 (nconc (and gnus-article-mouse-face
5922 (list gnus-mouse-face-prop gnus-article-mouse-face))
5923 (list 'gnus-callback fun)
5924 (and data (list 'gnus-data data))))
5925 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5926 :button-keymap gnus-widget-button-keymap))
5928 ;;; Internal functions:
5930 (defun gnus-article-set-globals ()
5932 (set-buffer gnus-summary-buffer)
5933 (gnus-set-global-variables)))
5935 (defun gnus-signature-toggle (end)
5937 (set-buffer gnus-article-buffer)
5938 (let ((buffer-read-only nil)
5939 (inhibit-point-motion-hooks t))
5940 (if (text-property-any end (point-max) 'article-type 'signature)
5942 (gnus-delete-wash-type 'signature)
5943 (gnus-remove-text-properties-when
5944 'article-type 'signature end (point-max)
5945 (cons 'article-type (cons 'signature
5946 gnus-hidden-properties))))
5947 (gnus-add-wash-type 'signature)
5948 (gnus-add-text-properties-when
5949 'article-type nil end (point-max)
5950 (cons 'article-type (cons 'signature
5951 gnus-hidden-properties)))))
5952 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5953 (gnus-set-mode-line 'article))))
5955 (defun gnus-button-entry ()
5956 ;; Return the first entry in `gnus-button-alist' matching this place.
5957 (let ((alist gnus-button-alist)
5960 (setq entry (pop alist))
5961 (if (looking-at (eval (car entry)))
5966 (defun gnus-button-push (marker)
5967 ;; Push button starting at MARKER.
5970 (let* ((entry (gnus-button-entry))
5971 (inhibit-point-motion-hooks t)
5973 (args (mapcar (lambda (group)
5974 (let ((string (match-string group)))
5975 (gnus-set-text-properties
5976 0 (length string) nil string)
5983 (fboundp (symbol-value fun)))
5984 (apply (symbol-value fun) args))
5986 (gnus-message 1 "You must define `%S' to use this button"
5987 (cons fun args)))))))
5989 (defun gnus-parse-news-url (url)
5990 (let (scheme server group message-id articles)
5993 (goto-char (point-min))
5994 (when (looking-at "\\([A-Za-z]+\\):")
5995 (setq scheme (match-string 1))
5996 (goto-char (match-end 0)))
5997 (when (looking-at "//\\([^/]+\\)/")
5998 (setq server (match-string 1))
5999 (goto-char (match-end 0)))
6002 ((looking-at "\\(.*@.*\\)")
6003 (setq message-id (match-string 1)))
6004 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6005 (setq group (match-string 1)
6006 articles (split-string (match-string 2) "-")))
6007 ((looking-at "\\([^/]+\\)/?")
6008 (setq group (match-string 1)))
6010 (error "Unknown news URL syntax"))))
6011 (list scheme server group message-id articles)))
6013 (defun gnus-button-handle-news (url)
6015 (destructuring-bind (scheme server group message-id articles)
6016 (gnus-parse-news-url url)
6020 (set-buffer gnus-summary-buffer)
6022 (let ((gnus-refer-article-method (list (list 'nntp server))))
6023 (gnus-summary-refer-article message-id))
6024 (gnus-summary-refer-article message-id))))
6026 (gnus-button-fetch-group url)))))
6028 (defun gnus-button-handle-man (url)
6030 (funcall gnus-button-man-handler url))
6032 (defun gnus-button-handle-info (url)
6033 "Fetch an info URL."
6035 "^\\([^:/]+\\)?/\\(.*\\)"
6037 (gnus-info-find-node
6038 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6041 (gnus-url-unhex-string (match-string 2 url))))
6042 (error "Can't parse %s" url)))
6044 (defun gnus-button-message-id (message-id)
6047 (set-buffer gnus-summary-buffer)
6048 (gnus-summary-refer-article message-id)))
6050 (defun gnus-button-fetch-group (address)
6051 "Fetch GROUP specified by ADDRESS."
6052 (if (not (string-match "[:/]" address))
6053 ;; This is just a simple group url.
6054 (gnus-group-read-ephemeral-group address gnus-select-method)
6057 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6059 (error "Can't parse %s" address)
6060 (gnus-group-read-ephemeral-group
6061 (match-string 4 address)
6062 `(nntp ,(match-string 1 address)
6063 (nntp-address ,(match-string 1 address))
6064 (nntp-port-number ,(if (match-end 3)
6065 (match-string 3 address)
6068 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6070 (defun gnus-url-parse-query-string (query &optional downcase)
6071 (let (retval pairs cur key val)
6072 (setq pairs (split-string query "&"))
6074 (setq cur (car pairs)
6076 (if (not (string-match "=" cur))
6078 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6079 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6081 (setq key (downcase key)))
6082 (setq cur (assoc key retval))
6084 (setcdr cur (cons val (cdr cur)))
6085 (setq retval (cons (list key val) retval)))))
6088 (defun gnus-url-mailto (url)
6089 ;; Send mail to someone
6090 (when (string-match "mailto:/*\\(.*\\)" url)
6091 (setq url (substring url (match-beginning 1) nil)))
6092 (let (to args subject func)
6093 (if (string-match (regexp-quote "?") url)
6094 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6095 args (gnus-url-parse-query-string
6096 (substring url (match-end 0) nil) t))
6097 (setq to (gnus-url-unhex-string url)))
6098 (setq args (cons (list "to" to) args)
6099 subject (cdr-safe (assoc "subject" args)))
6102 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6105 (message-position-on-field (caar args)))
6106 (insert (mapconcat 'identity (cdar args) ", "))
6107 (setq args (cdr args)))
6110 (message-goto-subject))))
6112 (defun gnus-button-embedded-url (address)
6113 "Activate ADDRESS with `browse-url'."
6114 (browse-url (gnus-strip-whitespace address)))
6116 ;;; Next/prev buttons in the article buffer.
6118 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6119 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6121 (defvar gnus-prev-page-map
6122 (let ((map (make-sparse-keymap)))
6123 (unless (>= emacs-major-version 21)
6124 ;; XEmacs doesn't care.
6125 (set-keymap-parent map gnus-article-mode-map))
6126 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6127 (define-key map "\r" 'gnus-button-prev-page)
6130 (defun gnus-insert-prev-page-button ()
6132 (buffer-read-only nil))
6134 gnus-prev-page-line-format nil
6135 `(,@(gnus-local-map-property gnus-prev-page-map)
6137 gnus-callback gnus-article-button-prev-page
6138 article-type annotation))
6139 (widget-convert-button
6141 :action 'gnus-button-prev-page
6142 :button-keymap gnus-prev-page-map)))
6144 (defvar gnus-prev-page-map
6145 (let ((map (make-sparse-keymap)))
6146 (unless (>= emacs-major-version 21)
6147 ;; XEmacs doesn't care.
6148 (set-keymap-parent map gnus-article-mode-map))
6149 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6150 (define-key map "\r" 'gnus-button-prev-page)
6153 (defvar gnus-next-page-map
6154 (let ((map (make-sparse-keymap)))
6155 (unless (>= emacs-major-version 21)
6156 ;; XEmacs doesn't care.
6157 (set-keymap-parent map gnus-article-mode-map))
6158 (define-key map gnus-mouse-2 'gnus-button-next-page)
6159 (define-key map "\r" 'gnus-button-next-page)
6162 (defun gnus-button-next-page (&optional args more-args)
6163 "Go to the next page."
6165 (let ((win (selected-window)))
6166 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6167 (gnus-article-next-page)
6168 (select-window win)))
6170 (defun gnus-button-prev-page (&optional args more-args)
6171 "Go to the prev page."
6173 (let ((win (selected-window)))
6174 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6175 (gnus-article-prev-page)
6176 (select-window win)))
6178 (defun gnus-insert-next-page-button ()
6180 (buffer-read-only nil))
6181 (gnus-eval-format gnus-next-page-line-format nil
6182 `(,@(gnus-local-map-property gnus-next-page-map)
6184 gnus-callback gnus-article-button-next-page
6185 article-type annotation))
6186 (widget-convert-button
6188 :action 'gnus-button-next-page
6189 :button-keymap gnus-next-page-map)))
6191 (defun gnus-article-button-next-page (arg)
6192 "Go to the next page."
6194 (let ((win (selected-window)))
6195 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6196 (gnus-article-next-page)
6197 (select-window win)))
6199 (defun gnus-article-button-prev-page (arg)
6200 "Go to the prev page."
6202 (let ((win (selected-window)))
6203 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6204 (gnus-article-prev-page)
6205 (select-window win)))
6207 (defvar gnus-decode-header-methods
6208 '(mail-decode-encoded-word-region)
6209 "List of methods used to decode headers.
6211 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6212 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6213 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6214 whose names match REGEXP.
6217 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6218 mail-decode-encoded-word-region
6219 (\"chinese\" . rfc1843-decode-region))
6222 (defvar gnus-decode-header-methods-cache nil)
6224 (defun gnus-multi-decode-header (start end)
6225 "Apply the functions from `gnus-encoded-word-methods' that match."
6226 (unless (and gnus-decode-header-methods-cache
6227 (eq gnus-newsgroup-name
6228 (car gnus-decode-header-methods-cache)))
6229 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6232 (nconc gnus-decode-header-methods-cache (list x))
6233 (if (and gnus-newsgroup-name
6234 (string-match (car x) gnus-newsgroup-name))
6235 (nconc gnus-decode-header-methods-cache
6237 gnus-decode-header-methods))
6238 (let ((xlist gnus-decode-header-methods-cache))
6241 (narrow-to-region start end)
6243 (funcall (pop xlist) (point-min) (point-max))))))
6246 ;;; Treatment top-level handling.
6249 (defun gnus-treat-article (condition &optional part-number total-parts type)
6250 (let ((length (- (point-max) (point-min)))
6251 (alist gnus-treatment-function-alist)
6252 (article-goto-body-goes-to-point-min-p t)
6256 (let ((list gnus-article-treat-types))
6258 (when (string-match (pop list) type)
6259 (throw 'found t)))))))
6260 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6262 (gnus-run-hooks 'gnus-part-display-hook)
6263 (dolist (elem alist)
6266 (when (gnus-buffer-live-p gnus-summary-buffer)
6267 (set-buffer gnus-summary-buffer))
6268 (symbol-value (car elem))))
6269 (when (and (or (consp val)
6271 (gnus-treat-predicate val)
6272 (or (not (get (car elem) 'highlight))
6275 (funcall (cadr elem)))))))
6277 ;; Dynamic variables.
6279 (defvar part-number)
6280 (defvar total-parts)
6285 (defun gnus-treat-predicate (val)
6292 (stringp (car val)))
6293 (apply 'gnus-or (mapcar `(lambda (s)
6294 (string-match s ,(or gnus-newsgroup-name "")))
6297 (let ((pred (pop val)))
6300 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6302 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6304 (not (gnus-treat-predicate (car val))))
6306 (equal (car val) type))
6308 (error "%S is not a valid predicate" pred)))))
6314 (eq part-number total-parts))
6318 (error "%S is not a valid value" val))))
6320 (defun gnus-article-encrypt-body (protocol &optional n)
6321 "Encrypt the article body."
6324 (or gnus-article-encrypt-protocol
6325 (completing-read "Encrypt protocol: "
6326 gnus-article-encrypt-protocol-alist
6328 current-prefix-arg))
6329 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6331 (error (format "Can't find the encrypt protocol %s" protocol)))
6332 (if (member gnus-newsgroup-name '("nndraft:delayed"
6335 (error "Can't encrypt the article in group %s"
6336 gnus-newsgroup-name))
6337 (gnus-summary-iterate n
6339 (set-buffer gnus-summary-buffer)
6340 (let ((mail-parse-charset gnus-newsgroup-charset)
6341 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6342 (summary-buffer gnus-summary-buffer)
6344 (gnus-set-global-variables)
6345 (when (gnus-group-read-only-p)
6346 (error "The current newsgroup does not support article encrypt"))
6347 (gnus-summary-show-article t)
6349 (or (mail-header-references gnus-current-headers) ""))
6350 (set-buffer gnus-article-buffer)
6351 (let* ((buffer-read-only nil)
6353 (mapcar (lambda (field)
6354 (and (save-restriction
6355 (message-narrow-to-head)
6356 (goto-char (point-min))
6357 (search-forward field nil t))
6359 (message-narrow-to-field)
6360 (buffer-substring (point-min) (point-max))
6361 (delete-region (point-min) (point-max))
6363 '("Content-Type:" "Content-Transfer-Encoding:"
6364 "Content-Disposition:"))))
6365 (message-narrow-to-head)
6366 (message-remove-header "MIME-Version")
6367 (goto-char (point-max))
6368 (setq point (point))
6369 (insert (apply 'concat headers))
6371 (narrow-to-region point (point-max))
6372 (let ((message-options message-options))
6373 (message-options-set 'message-sender user-mail-address)
6374 (message-options-set 'message-recipients user-mail-address)
6375 (message-options-set 'message-sign-encrypt 'not)
6377 (goto-char (point-min))
6378 (insert "MIME-Version: 1.0\n")
6380 (gnus-summary-edit-article-done
6381 references nil summary-buffer t))
6382 (when gnus-keep-backlog
6383 (gnus-backlog-remove-article
6384 (car gnus-article-current) (cdr gnus-article-current)))
6386 (when (get-buffer gnus-original-article-buffer)
6387 (set-buffer gnus-original-article-buffer)
6388 (setq gnus-original-article nil)))
6389 (when gnus-use-cache
6390 (gnus-cache-update-article
6391 (car gnus-article-current) (cdr gnus-article-current))))))))
6393 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6394 "The following specs can be used:
6395 %t The security MIME type
6398 %D Details if button is pressed")
6400 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6401 "The following specs can be used:
6402 %t The security MIME type
6405 %D Details if button is pressed")
6407 (defvar gnus-mime-security-button-line-format-alist
6408 '((?t gnus-tmp-type ?s)
6409 (?i gnus-tmp-info ?s)
6410 (?d gnus-tmp-details ?s)
6411 (?D gnus-tmp-pressed-details ?s)))
6413 (defvar gnus-mime-security-button-map
6414 (let ((map (make-sparse-keymap)))
6415 (unless (>= (string-to-number emacs-version) 21)
6416 (set-keymap-parent map gnus-article-mode-map))
6417 (define-key map gnus-mouse-2 'gnus-article-push-button)
6418 (define-key map "\r" 'gnus-article-press-button)
6421 (defvar gnus-mime-security-details-buffer nil)
6423 (defvar gnus-mime-security-button-pressed nil)
6425 (defvar gnus-mime-security-show-details-inline t
6426 "If non-nil, show details in the article buffer.")
6428 (defun gnus-mime-security-verify-or-decrypt (handle)
6429 (mm-remove-parts (cdr handle))
6430 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6431 point buffer-read-only)
6433 (goto-char (car region)))
6435 (narrow-to-region (point) (point))
6436 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6437 (let* ((mm-verify-option 'known)
6438 (mm-decrypt-option 'known)
6439 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6440 (unless (eq nparts (cdr handle))
6441 (mm-destroy-parts (cdr handle))
6442 (setcdr handle nparts))))
6443 (setq point (point))
6444 (gnus-mime-display-security handle)
6445 (goto-char (point-max)))
6447 (delete-region (point) (cdr region))
6448 (set-marker (car region) nil)
6449 (set-marker (cdr region) nil))
6452 (defun gnus-mime-security-show-details (handle)
6453 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6455 (if gnus-mime-security-show-details-inline
6456 (let ((gnus-mime-security-button-pressed t)
6457 (gnus-mime-security-button-line-format
6458 (get-text-property (point) 'gnus-line-format))
6461 (while (eq (get-text-property (point) 'gnus-line-format)
6462 gnus-mime-security-button-line-format)
6466 (narrow-to-region (point) (point))
6467 (gnus-insert-mime-security-button handle))
6468 (delete-region (point)
6469 (or (text-property-not-all
6472 gnus-mime-security-button-line-format)
6474 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6475 (with-current-buffer gnus-mime-security-details-buffer
6478 (setq gnus-mime-security-details-buffer
6479 (gnus-get-buffer-create "*MIME Security Details*")))
6480 (with-current-buffer gnus-mime-security-details-buffer
6482 (goto-char (point-min)))
6483 (pop-to-buffer gnus-mime-security-details-buffer))
6484 (gnus-message 5 "No details."))))
6486 (defun gnus-mime-security-press-button (handle)
6487 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6488 (gnus-mime-security-show-details handle)
6489 (gnus-mime-security-verify-or-decrypt handle)))
6491 (defun gnus-insert-mime-security-button (handle &optional displayed)
6492 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6495 (or (nth 2 (assoc protocol mm-verify-function-alist))
6496 (nth 2 (assoc protocol mm-decrypt-function-alist))
6498 (if (equal (car handle) "multipart/signed")
6499 " Signed" " Encrypted")
6502 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6505 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6506 gnus-tmp-pressed-details
6508 (setq gnus-tmp-details
6509 (if gnus-tmp-details
6510 (concat "\n" gnus-tmp-details) ""))
6511 (setq gnus-tmp-pressed-details
6512 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6517 gnus-mime-security-button-line-format
6518 gnus-mime-security-button-line-format-alist
6519 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6520 gnus-callback gnus-mime-security-press-button
6521 gnus-line-format ,gnus-mime-security-button-line-format
6522 article-type annotation
6525 (widget-convert-button
6528 :action 'gnus-widget-press-button
6529 :button-keymap gnus-mime-security-button-map
6531 (lambda (widget/window &optional overlay pos)
6532 ;; Needed to properly clear the message due to a bug in
6533 ;; wid-edit (XEmacs only).
6534 (if (boundp 'help-echo-owns-message)
6535 (setq help-echo-owns-message t))
6538 (aref gnus-mouse-2 0))))))
6540 (defun gnus-mime-display-security (handle)
6542 (narrow-to-region (point) (point))
6543 (unless (gnus-unbuttonized-mime-type-p (car handle))
6544 (gnus-insert-mime-security-button handle))
6545 (gnus-mime-display-mixed (cdr handle))
6548 (unless (gnus-unbuttonized-mime-type-p (car handle))
6549 (let ((gnus-mime-security-button-line-format
6550 gnus-mime-security-button-end-line-format))
6551 (gnus-insert-mime-security-button handle)))
6552 (mm-set-handle-multipart-parameter
6554 (cons (set-marker (make-marker) (point-min))
6555 (set-marker (make-marker) (point-max))))))
6561 (run-hooks 'gnus-art-load-hook)
6563 ;;; gnus-art.el ends here