1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval-when-compile (require 'cl))
32 (eval-when-compile (require 'static))
44 ;; Avoid byte-compile warnings.
53 (autoload 'gnus-msg-mail "gnus-msg" nil t)
54 (autoload 'gnus-button-mailto "gnus-msg")
55 (autoload 'gnus-button-reply "gnus-msg" nil t)
57 (defgroup gnus-article nil
59 :link '(custom-manual "(gnus)The Article Buffer")
62 (defgroup gnus-article-treat nil
63 "Treating article parts."
64 :link '(custom-manual "(gnus)Article Hiding")
67 (defgroup gnus-article-hiding nil
68 "Hiding article parts."
69 :link '(custom-manual "(gnus)Article Hiding")
72 (defgroup gnus-article-highlight nil
73 "Article highlighting."
74 :link '(custom-manual "(gnus)Article Highlighting")
78 (defgroup gnus-article-signature nil
80 :link '(custom-manual "(gnus)Article Signature")
83 (defgroup gnus-article-headers nil
85 :link '(custom-manual "(gnus)Hiding Headers")
88 (defgroup gnus-article-washing nil
89 "Special commands on articles."
90 :link '(custom-manual "(gnus)Article Washing")
93 (defgroup gnus-article-emphasis nil
94 "Fontisizing articles."
95 :link '(custom-manual "(gnus)Article Fontisizing")
98 (defgroup gnus-article-saving nil
100 :link '(custom-manual "(gnus)Saving Articles")
101 :group 'gnus-article)
103 (defgroup gnus-article-mime nil
104 "Worshiping the MIME wonder."
105 :link '(custom-manual "(gnus)Using MIME")
106 :group 'gnus-article)
108 (defgroup gnus-article-buttons nil
109 "Pushable buttons in the article buffer."
110 :link '(custom-manual "(gnus)Article Buttons")
111 :group 'gnus-article)
113 (defgroup gnus-article-various nil
114 "Other article options."
115 :link '(custom-manual "(gnus)Misc Article")
116 :group 'gnus-article)
118 (defcustom gnus-ignored-headers
119 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
120 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
121 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
122 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
123 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
124 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face"
125 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
126 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
127 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
128 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
129 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
130 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
131 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
132 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
133 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
134 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
135 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
136 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
137 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
138 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
139 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
140 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
141 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
142 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
143 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
144 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
145 "^X-Received:" "^Content-length:" "X-precedence:"
146 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
147 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
148 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
149 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
150 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
151 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:"
152 "^X-Request-PGP:" "^X-Fingerprint:" "^X-WRIEnvto:" "^X-WRIEnvfrom:"
153 "^X-Virus-Scanned:" "^X-Delivery-Agent:" "^Posted-Date:" "^X-Gateway:"
154 "^X-Local-Origin:" "^X-Local-Destination:" "^X-UserInfo1:"
156 "*All headers that start with this regexp will be hidden.
157 This variable can also be a list of regexps of headers to be ignored.
158 If `gnus-visible-headers' is non-nil, this variable will be ignored."
159 :type '(choice :custom-show nil
162 :group 'gnus-article-hiding)
164 (defcustom gnus-visible-headers
165 "^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:"
166 "*All headers that do not match this regexp will be hidden.
167 This variable can also be a list of regexp of headers to remain visible.
168 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
169 :type '(repeat :value-to-internal (lambda (widget value)
170 (custom-split-regexp-maybe value))
171 :match (lambda (widget value)
173 (widget-editable-list-match widget value)))
175 :group 'gnus-article-hiding)
177 (defcustom gnus-sorted-header-list
178 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
179 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
180 "*This variable is a list of regular expressions.
181 If it is non-nil, headers that match the regular expressions will
182 be placed first in the article buffer in the sequence specified by
184 :type '(repeat regexp)
185 :group 'gnus-article-hiding)
187 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
188 "Headers that are only to be displayed if they have interesting data.
189 Possible values in this list are:
191 'empty Headers with no content.
192 'newsgroups Newsgroup identical to Gnus group.
193 'to-address To identical to To-address.
194 'followup-to Followup-to identical to Newsgroups.
195 'reply-to Reply-to identical to From.
196 'date Date less than four days old.
197 'long-to To and/or Cc longer than 1024 characters.
198 'many-to Multiple To and/or Cc."
199 :type '(set (const :tag "Headers with no content." empty)
200 (const :tag "Newsgroups identical to Gnus group." newsgroups)
201 (const :tag "To identical to To-address." to-address)
202 (const :tag "Followup-to identical to Newsgroups." followup-to)
203 (const :tag "Reply-to identical to From." reply-to)
204 (const :tag "Date less than four days old." date)
205 (const :tag "To and/or Cc longer than 1024 characters." long-to)
206 (const :tag "Multiple To and/or Cc headers." many-to))
207 :group 'gnus-article-hiding)
209 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
210 "Regexp matching signature separator.
211 This can also be a list of regexps. In that case, it will be checked
212 from head to tail looking for a separator. Searches will be done from
213 the end of the buffer."
214 :type '(repeat string)
215 :group 'gnus-article-signature)
217 (defcustom gnus-signature-limit nil
218 "Provide a limit to what is considered a signature.
219 If it is a number, no signature may not be longer (in characters) than
220 that number. If it is a floating point number, no signature may be
221 longer (in lines) than that number. If it is a function, the function
222 will be called without any parameters, and if it returns nil, there is
223 no signature in the buffer. If it is a string, it will be used as a
224 regexp. If it matches, the text in question is not a signature."
225 :type '(choice (integer :value 200)
227 (function :value fun)
228 (regexp :value ".*"))
229 :group 'gnus-article-signature)
231 (defcustom gnus-hidden-properties '(invisible t intangible t)
232 "Property list to use for hiding text."
234 :group 'gnus-article-hiding)
236 ;; Fixme: This isn't the right thing for mixed graphical and and
237 ;; non-graphical frames in a session.
238 (defcustom gnus-article-x-face-command
241 (if (or (gnus-image-type-available-p 'xface)
242 (gnus-image-type-available-p 'pbm))
243 'gnus-display-x-face-in-from
244 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
245 ((and (fboundp 'image-type-available-p)
246 (module-installed-p 'x-face-e21))
247 'x-face-decode-message-header)
248 ((gnus-image-type-available-p 'pbm)
249 'gnus-display-x-face-in-from)
251 (module-installed-p 'x-face-mule))
252 'x-face-mule-gnus-article-display-x-face)
254 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
256 "*String or function to be executed to display an X-Face header.
257 If it is a string, the command will be executed in a sub-shell
258 asynchronously. The compressed face will be piped to this command."
260 ,@(let (x-face-e21 x-face-mule)
261 (if (featurep 'xemacs)
263 (setq x-face-e21 (module-installed-p 'x-face-e21)
264 x-face-mule (module-installed-p 'x-face-mule)))
268 (if (or (gnus-image-type-available-p 'xface)
269 (gnus-image-type-available-p 'pbm))
270 '(function-item gnus-display-x-face-in-from))
272 (fboundp 'image-type-available-p))
274 :tag "x-face-decode-message-header (x-face-e21)"
275 x-face-decode-message-header))
278 x-face-mule-gnus-article-display-x-face))
281 :group 'gnus-article-washing)
283 (defcustom gnus-article-x-face-too-ugly nil
284 "Regexp matching posters whose face shouldn't be shown automatically."
285 :type '(choice regexp (const nil))
286 :group 'gnus-article-washing)
288 (defcustom gnus-article-banner-alist nil
289 "Banner alist for stripping.
291 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
293 :type '(repeat (cons symbol regexp))
294 :group 'gnus-article-washing)
296 (gnus-define-group-parameter
299 "Alist of regexps (to match group names) and banner."
300 :variable-group gnus-article-washing
302 '(choice :tag "Banner"
304 (const :tag "Remove signature" signature)
305 (symbol :tag "Item in `gnus-article-banner-alist'" none)
307 (const :tag "None" nil))
309 "If non-nil, specify how to remove `banners' from articles.
311 Symbol `signature' means to remove signatures delimited by
312 `gnus-signature-separator'. Any other symbol is used to look up a
313 regular expression to match the banner in `gnus-article-banner-alist'.
314 A string is used as a regular expression to match the banner
317 (defcustom gnus-emphasis-alist
319 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
324 ("_/" "/_" underline-italic)
325 ("_\\*" "\\*_" underline-bold)
326 ("\\*/" "/\\*" bold-italic)
327 ("_\\*/" "/\\*_" underline-bold-italic))))
331 (format format (car spec) (car (cdr spec)))
332 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
334 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
335 2 3 gnus-emphasis-underline)))
336 "*Alist that says how to fontify certain phrases.
337 Each item looks like this:
339 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
341 The first element is a regular expression to be matched. The second
342 is a number that says what regular expression grouping used to find
343 the entire emphasized word. The third is a number that says what
344 regexp grouping should be displayed and highlighted. The fourth
345 is the face used for highlighting."
346 :type '(repeat (list :value ("" 0 0 default)
348 (integer :tag "Match group")
349 (integer :tag "Emphasize group")
351 :group 'gnus-article-emphasis)
353 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
354 "A regexp to describe whitespace which should not be emphasized.
355 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
356 The former avoids underlining of leading and trailing whitespace,
357 and the latter avoids underlining any whitespace at all."
359 :group 'gnus-article-emphasis
362 (defface gnus-emphasis-bold '((t (:bold t)))
363 "Face used for displaying strong emphasized text (*word*)."
364 :group 'gnus-article-emphasis)
366 (defface gnus-emphasis-italic '((t (:italic t)))
367 "Face used for displaying italic emphasized text (/word/)."
368 :group 'gnus-article-emphasis)
370 (defface gnus-emphasis-underline '((t (:underline t)))
371 "Face used for displaying underlined emphasized text (_word_)."
372 :group 'gnus-article-emphasis)
374 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
375 "Face used for displaying underlined bold emphasized text (_*word*_)."
376 :group 'gnus-article-emphasis)
378 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
379 "Face used for displaying underlined italic emphasized text (_/word/_)."
380 :group 'gnus-article-emphasis)
382 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
383 "Face used for displaying bold italic emphasized text (/*word*/)."
384 :group 'gnus-article-emphasis)
386 (defface gnus-emphasis-underline-bold-italic
387 '((t (:bold t :italic t :underline t)))
388 "Face used for displaying underlined bold italic emphasized text.
389 Esample: (_/*word*/_)."
390 :group 'gnus-article-emphasis)
392 (defface gnus-emphasis-highlight-words
393 '((t (:background "black" :foreground "yellow")))
394 "Face used for displaying highlighted words."
395 :group 'gnus-article-emphasis)
397 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
398 "Format for display of Date headers in article bodies.
399 See `format-time-string' for the possible values.
401 The variable can also be function, which should return a complete Date
402 header. The function is called with one argument, the time, which can
403 be fed to `format-time-string'."
404 :type '(choice string symbol)
405 :link '(custom-manual "(gnus)Article Date")
406 :group 'gnus-article-washing)
409 (autoload 'mail-extract-address-components "mail-extr"))
411 (defcustom gnus-save-all-headers t
412 "*If non-nil, don't remove any headers before saving."
413 :group 'gnus-article-saving
416 (defcustom gnus-prompt-before-saving 'always
417 "*This variable says how much prompting is to be done when saving articles.
418 If it is nil, no prompting will be done, and the articles will be
419 saved to the default files. If this variable is `always', each and
420 every article that is saved will be preceded by a prompt, even when
421 saving large batches of articles. If this variable is neither nil not
422 `always', there the user will be prompted once for a file name for
423 each invocation of the saving commands."
424 :group 'gnus-article-saving
425 :type '(choice (item always)
426 (item :tag "never" nil)
427 (sexp :tag "once" :format "%t\n" :value t)))
429 (defcustom gnus-saved-headers gnus-visible-headers
430 "Headers to keep if `gnus-save-all-headers' is nil.
431 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
432 If that variable is nil, however, all headers that match this regexp
433 will be kept while the rest will be deleted before saving."
434 :group 'gnus-article-saving
437 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
438 "A function to save articles in your favourite format.
439 The function must be interactively callable (in other words, it must
440 be an Emacs command).
442 Gnus provides the following functions:
444 * gnus-summary-save-in-rmail (Rmail format)
445 * gnus-summary-save-in-mail (Unix mail format)
446 * gnus-summary-save-in-folder (MH folder)
447 * gnus-summary-save-in-file (article format)
448 * gnus-summary-save-body-in-file (article body)
449 * gnus-summary-save-in-vm (use VM's folder format)
450 * gnus-summary-write-to-file (article format -- overwrite)."
451 :group 'gnus-article-saving
452 :type '(radio (function-item gnus-summary-save-in-rmail)
453 (function-item gnus-summary-save-in-mail)
454 (function-item gnus-summary-save-in-folder)
455 (function-item gnus-summary-save-in-file)
456 (function-item gnus-summary-save-body-in-file)
457 (function-item gnus-summary-save-in-vm)
458 (function-item gnus-summary-write-to-file)))
460 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
461 "A function generating a file name to save articles in Rmail format.
462 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
463 :group 'gnus-article-saving
466 (defcustom gnus-mail-save-name 'gnus-plain-save-name
467 "A function generating a file name to save articles in Unix mail format.
468 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
469 :group 'gnus-article-saving
472 (defcustom gnus-folder-save-name 'gnus-folder-save-name
473 "A function generating a file name to save articles in MH folder.
474 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
475 :group 'gnus-article-saving
478 (defcustom gnus-file-save-name 'gnus-numeric-save-name
479 "A function generating a file name to save articles in article format.
480 The function is called with NEWSGROUP, HEADERS, and optional
482 :group 'gnus-article-saving
485 (defcustom gnus-split-methods
486 '((gnus-article-archive-name)
487 (gnus-article-nndoc-name))
488 "*Variable used to suggest where articles are to be saved.
489 For instance, if you would like to save articles related to Gnus in
490 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
491 you could set this variable to something like:
493 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
494 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
496 This variable is an alist where the where the key is the match and the
497 value is a list of possible files to save in if the match is non-nil.
499 If the match is a string, it is used as a regexp match on the
500 article. If the match is a symbol, that symbol will be funcalled
501 from the buffer of the article to be saved with the newsgroup as the
502 parameter. If it is a list, it will be evaled in the same buffer.
504 If this form or function returns a string, this string will be used as
505 a possible file name; and if it returns a non-nil list, that list will
506 be used as possible file names."
507 :group 'gnus-article-saving
508 :type '(repeat (choice (list :value (fun) function)
509 (cons :value ("" "") regexp (repeat string))
512 (defcustom gnus-article-display-method-for-mime
513 'gnus-article-display-mime-message
514 "Function to display a MIME message.
515 The function is called from the article buffer."
516 :group 'gnus-article-mime
519 (defcustom gnus-article-display-method-for-traditional
520 'gnus-article-display-traditional-message
521 "*Function to display a traditional message.
522 The function is called from the article buffer."
523 :group 'gnus-article-mime
526 (defcustom gnus-page-delimiter "^\^L"
527 "*Regexp describing what to use as article page delimiters.
528 The default value is \"^\^L\", which is a form linefeed at the
529 beginning of a line."
531 :group 'gnus-article-various)
533 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
534 "*The format specification for the article mode line.
535 See `gnus-summary-mode-line-format' for a closer description.
537 The following additional specs are available:
539 %w The article washing status.
540 %m The number of MIME parts in the article."
542 :group 'gnus-article-various)
544 (defcustom gnus-article-mode-hook nil
545 "*A hook for Gnus article mode."
547 :group 'gnus-article-various)
549 (when (featurep 'xemacs)
550 ;; Extracted from gnus-xmas-define in order to preserve user settings
551 (when (fboundp 'turn-off-scroll-in-place)
552 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
553 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
554 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
556 (defcustom gnus-article-menu-hook nil
557 "*Hook run after the creation of the article mode menu."
559 :group 'gnus-article-various)
561 (defcustom gnus-article-prepare-hook nil
562 "*A hook called after an article has been prepared in the article buffer."
564 :group 'gnus-article-various)
566 (defcustom gnus-article-hide-pgp-hook nil
567 "*A hook called after successfully hiding a PGP signature."
569 :group 'gnus-article-various)
571 (defcustom gnus-article-button-face 'bold
572 "Face used for highlighting buttons in the article buffer.
574 An article button is a piece of text that you can activate by pressing
575 `RET' or `mouse-2' above it."
577 :group 'gnus-article-buttons)
579 (defcustom gnus-article-mouse-face 'highlight
580 "Face used for mouse highlighting in the article buffer.
582 Article buttons will be displayed in this face when the cursor is
585 :group 'gnus-article-buttons)
587 (defcustom gnus-signature-face 'gnus-signature-face
588 "Face used for highlighting a signature in the article buffer.
589 Obsolete; use the face `gnus-signature-face' for customizations instead."
591 :group 'gnus-article-highlight
592 :group 'gnus-article-signature)
594 (defface gnus-signature-face
597 "Face used for highlighting a signature in the article buffer."
598 :group 'gnus-article-highlight
599 :group 'gnus-article-signature)
601 (defface gnus-header-from-face
604 (:foreground "spring green"))
607 (:foreground "red3"))
610 "Face used for displaying from headers."
611 :group 'gnus-article-headers
612 :group 'gnus-article-highlight)
614 (defface gnus-header-subject-face
617 (:foreground "SeaGreen3"))
620 (:foreground "red4"))
622 (:bold t :italic t)))
623 "Face used for displaying subject headers."
624 :group 'gnus-article-headers
625 :group 'gnus-article-highlight)
627 (defface gnus-header-newsgroups-face
630 (:foreground "yellow" :italic t))
633 (:foreground "MidnightBlue" :italic t))
636 "Face used for displaying newsgroups headers."
637 :group 'gnus-article-headers
638 :group 'gnus-article-highlight)
640 (defface gnus-header-name-face
643 (:foreground "SeaGreen"))
646 (:foreground "maroon"))
649 "Face used for displaying header names."
650 :group 'gnus-article-headers
651 :group 'gnus-article-highlight)
653 (defface gnus-header-content-face
656 (:foreground "forest green" :italic t))
659 (:foreground "indianred4" :italic t))
662 "Face used for displaying header content."
663 :group 'gnus-article-headers
664 :group 'gnus-article-highlight)
666 (defcustom gnus-header-face-alist
667 '(("From" nil gnus-header-from-face)
668 ("Subject" nil gnus-header-subject-face)
669 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
670 ("" gnus-header-name-face gnus-header-content-face))
671 "*Controls highlighting of article header.
673 An alist of the form (HEADER NAME CONTENT).
675 HEADER is a regular expression which should match the name of an
676 header header and NAME and CONTENT are either face names or nil.
678 The name of each header field will be displayed using the face
679 specified by the first element in the list where HEADER match the
680 header name and NAME is non-nil. Similarly, the content will be
681 displayed by the first non-nil matching CONTENT face."
682 :group 'gnus-article-headers
683 :group 'gnus-article-highlight
684 :type '(repeat (list (regexp :tag "Header")
686 (item :tag "skip" nil)
687 (face :value default))
688 (choice :tag "Content"
689 (item :tag "skip" nil)
690 (face :value default)))))
692 (defcustom gnus-article-decode-hook nil
693 "*Hook run to decode charsets in articles."
694 :group 'gnus-article-headers
697 (defcustom gnus-display-mime-function 'gnus-display-mime
698 "Function to display MIME articles."
699 :group 'gnus-article-mime
702 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
703 "Function used to decode headers.")
705 (defvar gnus-article-dumbquotes-map
724 "Table for MS-to-Latin1 translation.")
726 (defcustom gnus-ignored-mime-types nil
727 "List of MIME types that should be ignored by Gnus."
729 :group 'gnus-article-mime
730 :type '(repeat regexp))
732 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
733 "List of MIME types that should not be given buttons when rendered inline.
734 See also `gnus-buttonized-mime-types' which may override this variable."
736 :group 'gnus-article-mime
737 :type '(repeat regexp))
739 (defcustom gnus-buttonized-mime-types nil
740 "List of MIME types that should be given buttons when rendered inline.
741 If set, this variable overrides `gnus-unbuttonized-mime-types'.
742 To see e.g. security buttons you could set this to
743 `(\"multipart/signed\")'."
745 :group 'gnus-article-mime
746 :type '(repeat regexp))
748 (defcustom gnus-body-boundary-delimiter "_"
749 "String used to delimit header and body.
750 This variable is used by `gnus-article-treat-body-boundary' which can
751 be controlled by `gnus-treat-body-boundary'."
752 :group 'gnus-article-various
753 :type '(choice (item :tag "None" :value nil)
756 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
757 "*Defines the location of the faces database.
758 For information on obtaining this database of pretty pictures, please
759 see http://www.cs.indiana.edu/picons/ftp/index.html"
763 (defun gnus-picons-installed-p ()
764 "Say whether picons are installed on your machine."
765 (let ((installed nil))
766 (dolist (database gnus-picon-databases)
767 (when (file-exists-p database)
771 (defcustom gnus-article-mime-part-function nil
772 "Function called with a MIME handle as the argument.
773 This is meant for people who want to do something automatic based
774 on parts -- for instance, adding Vcard info to a database."
775 :group 'gnus-article-mime
778 (defcustom gnus-mime-multipart-functions nil
779 "An alist of MIME types to functions to display them."
781 :group 'gnus-article-mime
784 (defcustom gnus-article-date-lapsed-new-header nil
785 "Whether the X-Sent and Date headers can coexist.
786 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
787 either replace the old \"Date:\" header (if this variable is nil), or
788 be added below it (otherwise)."
790 :group 'gnus-article-headers
793 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
794 "Function called with a MIME handle as the argument.
795 This is meant for people who want to view first matched part.
796 For `undisplayed-alternative' (default), the first undisplayed
797 part or alternative part is used. For `undisplayed', the first
798 undisplayed part is used. For a function, the first part which
799 the function return `t' is used. For `nil', the first part is
802 :group 'gnus-article-mime
804 (item :tag "first" :value nil)
805 (item :tag "undisplayed" :value undisplayed)
806 (item :tag "undisplayed or alternative"
807 :value undisplayed-alternative)
810 (defcustom gnus-mime-action-alist
811 '(("save to file" . gnus-mime-save-part)
812 ("save and strip" . gnus-mime-save-part-and-strip)
813 ("display as text" . gnus-mime-inline-part)
814 ("view the part" . gnus-mime-view-part)
815 ("pipe to command" . gnus-mime-pipe-part)
816 ("toggle display" . gnus-article-press-button)
817 ("toggle display" . gnus-article-view-part-as-charset)
818 ("view as type" . gnus-mime-view-part-as-type)
819 ("internalize type" . gnus-mime-internalize-part)
820 ("externalize type" . gnus-mime-externalize-part))
821 "An alist of actions that run on the MIME attachment."
822 :group 'gnus-article-mime
823 :type '(repeat (cons (string :tag "name")
826 (defcustom gnus-mime-action-alist
827 '(("save to file" . gnus-mime-save-part)
828 ("display as text" . gnus-mime-inline-part)
829 ("view the part" . gnus-mime-view-part)
830 ("pipe to command" . gnus-mime-pipe-part)
831 ("toggle display" . gnus-article-press-button)
832 ("view as type" . gnus-mime-view-part-as-type)
833 ("internalize type" . gnus-mime-internalize-part)
834 ("externalize type" . gnus-mime-externalize-part))
835 "An alist of actions that run on the MIME attachment."
837 :group 'gnus-article-mime
838 :type '(repeat (cons (string :tag "name")
842 ;;; The treatment variables
845 (defvar gnus-part-display-hook nil
846 "Hook called on parts that are to receive treatment.")
848 (defvar gnus-article-treat-custom
849 '(choice (const :tag "Off" nil)
851 (const :tag "Header" head)
852 (const :tag "Last" last)
853 (const :tag "Mime" mime)
854 (integer :tag "Less")
855 (repeat :tag "Groups" regexp)
856 (sexp :tag "Predicate")))
858 (defvar gnus-article-treat-head-custom
859 '(choice (const :tag "Off" nil)
860 (const :tag "Header" head)))
862 (defvar gnus-article-treat-types '("text/plain")
865 (defvar gnus-inhibit-treatment nil
866 "Whether to inhibit treatment.")
868 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
869 "Highlight the signature.
870 Valid values are nil, t, `head', `last', an integer or a predicate.
871 See Info node `(gnus)Customizing Articles'."
872 :group 'gnus-article-treat
873 :type gnus-article-treat-custom)
874 (put 'gnus-treat-highlight-signature 'highlight t)
876 (defcustom gnus-treat-buttonize 100000
878 Valid values are nil, t, `head', `last', an integer or a predicate.
879 See Info node `(gnus)Customizing Articles'."
880 :group 'gnus-article-treat
881 :type gnus-article-treat-custom)
882 (put 'gnus-treat-buttonize 'highlight t)
884 (defcustom gnus-treat-buttonize-head 'head
885 "Add buttons to the head.
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 :type gnus-article-treat-head-custom)
890 (put 'gnus-treat-buttonize-head 'highlight t)
892 (defcustom gnus-treat-emphasize
893 (and (or window-system
895 (>= (string-to-number emacs-version) 21))
898 Valid values are nil, t, `head', `last', an integer or a predicate.
899 See Info node `(gnus)Customizing Articles' for details."
900 :group 'gnus-article-treat
901 :type gnus-article-treat-custom)
902 (put 'gnus-treat-emphasize 'highlight t)
904 (defcustom gnus-treat-strip-cr nil
905 "Remove carriage returns.
906 Valid values are nil, t, `head', `last', an integer or a predicate.
907 See Info node `(gnus)Customizing Articles' for details."
908 :group 'gnus-article-treat
909 :type gnus-article-treat-custom)
911 (defcustom gnus-treat-unsplit-urls nil
912 "Remove newlines from within URLs.
913 Valid values are nil, t, `head', `last', an integer or a predicate.
914 See Info node `(gnus)Customizing Articles' for details."
915 :group 'gnus-article-treat
916 :type gnus-article-treat-custom)
918 (defcustom gnus-treat-leading-whitespace nil
919 "Remove leading whitespace in headers.
920 Valid values are nil, t, `head', `last', an integer or a predicate.
921 See Info node `(gnus)Customizing Articles' for details."
922 :group 'gnus-article-treat
923 :type gnus-article-treat-custom)
925 (defcustom gnus-treat-hide-headers 'head
927 Valid values are nil, t, `head', `last', an integer or a predicate.
928 See Info node `(gnus)Customizing Articles' for details."
929 :group 'gnus-article-treat
930 :type gnus-article-treat-head-custom)
932 (defcustom gnus-treat-hide-boring-headers nil
933 "Hide boring headers.
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 :type gnus-article-treat-head-custom)
939 (defcustom gnus-treat-hide-signature nil
941 Valid values are nil, t, `head', `last', an integer or a predicate.
942 See Info node `(gnus)Customizing Articles' for details."
943 :group 'gnus-article-treat
944 :type gnus-article-treat-custom)
946 (defcustom gnus-treat-fill-article nil
948 Valid values are nil, t, `head', `last', an integer or a predicate.
949 See Info node `(gnus)Customizing Articles' for details."
950 :group 'gnus-article-treat
951 :type gnus-article-treat-custom)
953 (defcustom gnus-treat-hide-citation nil
955 Valid values are nil, t, `head', `last', an integer or a predicate.
956 See Info node `(gnus)Customizing Articles' for details."
957 :group 'gnus-article-treat
958 :type gnus-article-treat-custom)
960 (defcustom gnus-treat-hide-citation-maybe nil
962 Valid values are nil, t, `head', `last', an integer or a predicate.
963 See Info node `(gnus)Customizing Articles' for details."
964 :group 'gnus-article-treat
965 :type gnus-article-treat-custom)
967 (defcustom gnus-treat-strip-list-identifiers 'head
968 "Strip list identifiers from `gnus-list-identifiers`.
969 Valid values are nil, t, `head', `last', an integer or a predicate.
970 See Info node `(gnus)Customizing Articles' for details."
972 :group 'gnus-article-treat
973 :type gnus-article-treat-custom)
975 (defcustom gnus-treat-strip-pgp t
976 "Strip PGP signatures.
977 Valid values are nil, t, `head', `last', an integer or a predicate.
978 See Info node `(gnus)Customizing Articles' for details."
979 :group 'gnus-article-treat
980 :type gnus-article-treat-custom)
982 (defcustom gnus-treat-strip-pem nil
983 "Strip PEM signatures.
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 :type gnus-article-treat-custom)
989 (defcustom gnus-treat-strip-banner t
990 "Strip banners from articles.
991 The banner to be stripped is specified in the `banner' group parameter.
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 :type gnus-article-treat-custom)
997 (defcustom gnus-treat-highlight-headers 'head
998 "Highlight the headers.
999 Valid values are nil, t, `head', `last', an integer or a predicate.
1000 See Info node `(gnus)Customizing Articles' for details."
1001 :group 'gnus-article-treat
1002 :type gnus-article-treat-head-custom)
1003 (put 'gnus-treat-highlight-headers 'highlight t)
1005 (defcustom gnus-treat-highlight-citation t
1006 "Highlight cited text.
1007 Valid values are nil, t, `head', `last', an integer or a predicate.
1008 See Info node `(gnus)Customizing Articles' for details."
1009 :group 'gnus-article-treat
1010 :type gnus-article-treat-custom)
1011 (put 'gnus-treat-highlight-citation 'highlight t)
1013 (defcustom gnus-treat-date-ut nil
1014 "Display the Date in UT (GMT).
1015 Valid values are nil, t, `head', `last', an integer or a predicate.
1016 See Info node `(gnus)Customizing Articles' for details."
1017 :group 'gnus-article-treat
1018 :type gnus-article-treat-head-custom)
1020 (defcustom gnus-treat-date-local nil
1021 "Display the Date in the local timezone.
1022 Valid values are nil, t, `head', `last', an integer or a predicate.
1023 See Info node `(gnus)Customizing Articles' for details."
1024 :group 'gnus-article-treat
1025 :type gnus-article-treat-head-custom)
1027 (defcustom gnus-treat-date-english nil
1028 "Display the Date in a format that can be read aloud in English.
1029 Valid values are nil, t, `head', `last', an integer or a predicate.
1030 See Info node `(gnus)Customizing Articles' for details."
1031 :group 'gnus-article-treat
1032 :type gnus-article-treat-head-custom)
1034 (defcustom gnus-treat-date-lapsed nil
1035 "Display the Date header in a way that says how much time has elapsed.
1036 Valid values are nil, t, `head', `last', an integer or a predicate.
1037 See Info node `(gnus)Customizing Articles' for details."
1038 :group 'gnus-article-treat
1039 :type gnus-article-treat-head-custom)
1041 (defcustom gnus-treat-date-original nil
1042 "Display the date in the original timezone.
1043 Valid values are nil, t, `head', `last', an integer or a predicate.
1044 See Info node `(gnus)Customizing Articles' for details."
1045 :group 'gnus-article-treat
1046 :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 :type gnus-article-treat-head-custom)
1056 (defcustom gnus-treat-date-user-defined nil
1057 "Display the date in a user-defined format.
1058 The format is defined by the `gnus-article-time-format' variable.
1059 Valid values are nil, t, `head', `last', an integer or a predicate.
1060 See Info node `(gnus)Customizing Articles' for details."
1061 :group 'gnus-article-treat
1062 :type gnus-article-treat-head-custom)
1064 (defcustom gnus-treat-strip-headers-in-body t
1065 "Strip the X-No-Archive header line from the beginning of the body.
1066 Valid values are nil, t, `head', `last', an integer or a predicate.
1067 See Info node `(gnus)Customizing Articles' for details."
1069 :group 'gnus-article-treat
1070 :type gnus-article-treat-custom)
1072 (defcustom gnus-treat-strip-trailing-blank-lines nil
1073 "Strip trailing blank lines.
1074 Valid values are nil, t, `head', `last', an integer or a predicate.
1075 See Info node `(gnus)Customizing Articles' for details."
1076 :group 'gnus-article-treat
1077 :type gnus-article-treat-custom)
1079 (defcustom gnus-treat-strip-leading-blank-lines nil
1080 "Strip leading blank lines.
1081 Valid values are nil, t, `head', `last', an integer or a predicate.
1082 See Info node `(gnus)Customizing Articles' for details."
1083 :group 'gnus-article-treat
1084 :type gnus-article-treat-custom)
1086 (defcustom gnus-treat-strip-multiple-blank-lines nil
1087 "Strip multiple blank lines.
1088 Valid values are nil, t, `head', `last', an integer or a predicate.
1089 See Info node `(gnus)Customizing Articles' for details."
1090 :group 'gnus-article-treat
1091 :type gnus-article-treat-custom)
1093 (defcustom gnus-treat-unfold-headers 'head
1094 "Unfold folded header lines.
1095 Valid values are nil, t, `head', `last', an integer or a predicate.
1096 See Info node `(gnus)Customizing Articles' for details."
1097 :group 'gnus-article-treat
1098 :type gnus-article-treat-custom)
1100 (defcustom gnus-treat-fold-headers nil
1102 Valid values are nil, t, `head', `last', an integer or a predicate.
1103 See Info node `(gnus)Customizing Articles' for details."
1104 :group 'gnus-article-treat
1105 :type gnus-article-treat-custom)
1107 (defcustom gnus-treat-fold-newsgroups 'head
1108 "Fold the Newsgroups and Followup-To headers.
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 :type gnus-article-treat-custom)
1114 (defcustom gnus-treat-overstrike t
1115 "Treat overstrike highlighting.
1116 Valid values are nil, t, `head', `last', an integer or a predicate.
1117 See Info node `(gnus)Customizing Articles' for details."
1118 :group 'gnus-article-treat
1119 :type gnus-article-treat-custom)
1120 (put 'gnus-treat-overstrike 'highlight t)
1122 (defcustom gnus-treat-display-xface
1123 (and (not noninteractive)
1124 (or (and (fboundp 'image-type-available-p)
1125 (image-type-available-p 'xbm)
1126 (string-match "^0x" (shell-command-to-string "uncompface")))
1127 (and (featurep 'xemacs)
1129 (eq 'x-face-mule-gnus-article-display-x-face
1130 gnus-article-x-face-command))
1132 "Display X-Face headers.
1133 Valid values are nil, t, `head', `last', an integer or a predicate.
1134 See Info node `(gnus)Customizing Articles' and Info node
1135 `(gnus)X-Face' for details."
1136 :group 'gnus-article-treat
1138 :type gnus-article-treat-head-custom)
1139 (put 'gnus-treat-display-xface 'highlight t)
1141 (defcustom gnus-article-should-use-smiley-mule
1142 (not (or (featurep 'xemacs)
1143 (gnus-image-type-available-p 'xpm)
1144 (gnus-image-type-available-p 'pbm)))
1145 "If non-nil, gnus uses `smiley-mule' for displaying smileys rather than
1146 `smiley'. It defaults to t when Emacs 20 or earlier is running.
1147 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1148 even if you are using Emacs 21+. It has no effect on XEmacs."
1149 :group 'gnus-article-various
1151 :get (lambda (symbol)
1152 (and (default-value symbol)
1153 (not (featurep 'xemacs))
1154 (module-installed-p 'smiley-mule)
1156 :set (lambda (symbol value)
1157 (set-default symbol (and value
1158 (not (featurep 'xemacs))
1159 (module-installed-p 'smiley-mule)
1162 (defvar gnus-article-smiley-mule-loaded-p nil
1163 "Internal variable used to say whether `smiley-mule' is loaded (whether
1164 smiley functions are not overridden by `smiley').")
1166 (defcustom gnus-treat-display-grey-xface
1167 (and (not noninteractive)
1168 (or (featurep 'xemacs)
1169 (and (fboundp 'display-images-p)
1170 (display-images-p)))
1171 (string-match "^0x" (shell-command-to-string "uncompface"))
1173 "Display grey X-Face headers.
1174 Valid values are nil, t."
1175 :group 'gnus-article-treat
1178 (put 'gnus-treat-display-grey-xface 'highlight t)
1180 (defcustom gnus-treat-display-smileys
1181 (if (or (and (featurep 'xemacs)
1183 (gnus-image-type-available-p 'xpm)
1184 (gnus-image-type-available-p 'pbm)
1185 (and (not (featurep 'xemacs))
1187 (module-installed-p 'smiley-mule)))
1191 Valid values are nil, t, `head', `last', an integer or a predicate.
1192 See Info node `(gnus)Customizing Articles' and Info node
1193 `(gnus)Smileys' for details."
1194 :group 'gnus-article-treat
1196 :type gnus-article-treat-custom)
1197 (put 'gnus-treat-display-smileys 'highlight t)
1199 (defcustom gnus-treat-from-picon
1200 (if (and (gnus-image-type-available-p 'xpm)
1201 (gnus-picons-installed-p))
1203 "Display picons in the From header.
1204 Valid values are nil, t, `head', `last', an integer or a predicate.
1205 See Info node `(gnus)Customizing Articles' and Info node
1206 `(gnus)Picons' for details."
1207 :group 'gnus-article-treat
1208 :type gnus-article-treat-head-custom)
1209 (put 'gnus-treat-from-picon 'highlight t)
1211 (defcustom gnus-treat-mail-picon
1212 (if (and (gnus-image-type-available-p 'xpm)
1213 (gnus-picons-installed-p))
1215 "Display picons in To and Cc headers.
1216 Valid values are nil, t, `head', `last', an integer or a predicate.
1217 See Info node `(gnus)Customizing Articles' and Info node
1218 `(gnus)Picons' for details."
1219 :group 'gnus-article-treat
1220 :type gnus-article-treat-head-custom)
1221 (put 'gnus-treat-mail-picon 'highlight t)
1223 (defcustom gnus-treat-newsgroups-picon
1224 (if (and (gnus-image-type-available-p 'xpm)
1225 (gnus-picons-installed-p))
1227 "Display picons in the Newsgroups and Followup-To headers.
1228 Valid values are nil, t, `head', `last', an integer or a predicate.
1229 See Info node `(gnus)Customizing Articles' and Info node
1230 `(gnus)Picons' for details."
1231 :group 'gnus-article-treat
1232 :type gnus-article-treat-head-custom)
1233 (put 'gnus-treat-newsgroups-picon 'highlight t)
1235 (defcustom gnus-treat-body-boundary
1236 (if (or gnus-treat-newsgroups-picon
1237 gnus-treat-mail-picon
1238 gnus-treat-from-picon)
1240 "Draw a boundary at the end of the headers.
1241 Valid values are nil, t, `head', `last', an integer or a predicate.
1242 See Info node `(gnus)Customizing Articles' for details."
1244 :group 'gnus-article-treat
1245 :type gnus-article-treat-custom)
1247 (defcustom gnus-treat-capitalize-sentences nil
1248 "Capitalize sentence-starting words.
1249 Valid values are nil, t, `head', `last', an integer or a predicate.
1250 See Info node `(gnus)Customizing Articles' for details."
1252 :group 'gnus-article-treat
1253 :type gnus-article-treat-custom)
1255 (defcustom gnus-treat-fill-long-lines nil
1257 Valid values are nil, t, `head', `last', an integer or a predicate.
1258 See Info node `(gnus)Customizing Articles' for details."
1259 :group 'gnus-article-treat
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 :type gnus-article-treat-custom)
1270 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1271 "Decode an article as `default-mime-charset'. For instance, if you want to
1272 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1273 you could set this variable to something like: nil for don't decode, t for
1274 decode the body, '(or header t) for the whole article, etc."
1275 :group 'gnus-article-treat
1276 :type '(radio (const :tag "Off" nil)
1277 (const :tag "Decode body" t)
1278 (const :tag "Decode all" (or head t))))
1280 (defcustom gnus-treat-translate nil
1281 "Translate articles from one language to another.
1282 Valid values are nil, t, `head', `last', an integer or a predicate.
1283 See Info node `(gnus)Customizing Articles' for details."
1285 :group 'gnus-article-treat
1286 :type gnus-article-treat-custom)
1288 (defcustom gnus-treat-x-pgp-sig nil
1290 To automatically treat X-PGP-Sig, set it to head.
1291 Valid values are nil, t, `head', `last', an integer or a predicate.
1292 See Info node `(gnus)Customizing Articles' for details."
1293 :group 'gnus-article-treat
1294 :group 'mime-security
1295 :type gnus-article-treat-custom)
1297 (defvar gnus-article-encrypt-protocol-alist
1298 '(("PGP" . mml2015-self-encrypt)))
1300 ;; Set to nil if more than one protocol added to
1301 ;; gnus-article-encrypt-protocol-alist.
1302 (defcustom gnus-article-encrypt-protocol "PGP"
1303 "The protocol used for encrypt articles.
1304 It is a string, such as \"PGP\". If nil, ask user."
1306 :group 'mime-security)
1308 (defvar gnus-article-wash-function nil
1309 "Function used for converting HTML into text.")
1311 ;;; Internal variables
1313 (defvar gnus-english-month-names
1314 '("January" "February" "March" "April" "May" "June" "July" "August"
1315 "September" "October" "November" "December"))
1317 (defvar article-goto-body-goes-to-point-min-p nil)
1318 (defvar gnus-article-wash-types nil)
1319 (defvar gnus-article-emphasis-alist nil)
1320 (defvar gnus-article-image-alist nil)
1322 (defvar gnus-article-mime-handle-alist-1 nil)
1323 (defvar gnus-treatment-function-alist
1324 '((gnus-treat-decode-article-as-default-mime-charset
1325 gnus-article-decode-article-as-default-mime-charset)
1326 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1327 (gnus-treat-strip-banner gnus-article-strip-banner)
1328 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1329 (gnus-treat-buttonize gnus-article-add-buttons)
1330 (gnus-treat-fill-article gnus-article-fill-cited-article)
1331 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1332 (gnus-treat-strip-cr gnus-article-remove-cr)
1333 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1334 (gnus-treat-date-ut gnus-article-date-ut)
1335 (gnus-treat-date-local gnus-article-date-local)
1336 (gnus-treat-date-english gnus-article-date-english)
1337 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1338 (gnus-treat-date-original gnus-article-date-original)
1339 (gnus-treat-date-user-defined gnus-article-date-user)
1340 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1341 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1342 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1343 (gnus-treat-hide-signature gnus-article-hide-signature)
1344 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1345 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1346 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1347 (gnus-treat-strip-pem gnus-article-hide-pem)
1348 (gnus-treat-from-picon gnus-treat-from-picon)
1349 (gnus-treat-mail-picon gnus-treat-mail-picon)
1350 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1351 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1352 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1353 (gnus-treat-strip-trailing-blank-lines
1354 gnus-article-remove-trailing-blank-lines)
1355 (gnus-treat-strip-leading-blank-lines
1356 gnus-article-strip-leading-blank-lines)
1357 (gnus-treat-strip-multiple-blank-lines
1358 gnus-article-strip-multiple-blank-lines)
1359 (gnus-treat-overstrike gnus-article-treat-overstrike)
1360 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1361 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1362 ;; Displaying X-Face should be done after unfolding headers
1363 ;; to protect bitmap lines.
1364 (gnus-treat-display-xface gnus-article-display-x-face)
1365 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1366 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1367 (gnus-treat-display-smileys gnus-treat-smiley)
1368 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1369 (gnus-treat-emphasize gnus-article-emphasize)
1370 (gnus-treat-hide-citation gnus-article-hide-citation)
1371 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1372 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1373 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1374 (gnus-treat-play-sounds gnus-earcon-display)))
1376 (defvar gnus-article-mime-handle-alist nil)
1377 (defvar article-lapsed-timer nil)
1378 (defvar gnus-article-current-summary nil)
1380 (defvar gnus-article-mode-syntax-table
1381 (let ((table (copy-syntax-table text-mode-syntax-table)))
1382 ;; This causes the citation match run O(2^n).
1383 ;; (modify-syntax-entry ?- "w" table)
1384 (modify-syntax-entry ?> ")" table)
1385 (modify-syntax-entry ?< "(" table)
1387 "Syntax table used in article mode buffers.
1388 Initialized from `text-mode-syntax-table.")
1390 (defvar gnus-save-article-buffer nil)
1392 (defvar gnus-article-mode-line-format-alist
1393 (nconc '((?w (gnus-article-wash-status) ?s)
1394 (?m (gnus-article-mime-part-status) ?s))
1395 gnus-summary-mode-line-format-alist))
1397 (defvar gnus-number-of-articles-to-be-saved nil)
1399 (defvar gnus-inhibit-hiding nil)
1401 ;;; Macros for dealing with the article buffer.
1403 (defmacro gnus-with-article-headers (&rest forms)
1405 (set-buffer gnus-article-buffer)
1407 (let ((buffer-read-only nil)
1408 (inhibit-point-motion-hooks t)
1409 (case-fold-search t))
1410 (article-narrow-to-head)
1413 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1414 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1416 (defmacro gnus-with-article-buffer (&rest forms)
1418 (set-buffer gnus-article-buffer)
1419 (let ((buffer-read-only nil))
1422 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1423 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1425 (defun gnus-article-goto-header (header)
1426 "Go to HEADER, which is a regular expression."
1427 (re-search-forward (concat "^\\(" header "\\):") nil t))
1429 (defsubst gnus-article-hide-text (b e props)
1430 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1431 (gnus-add-text-properties-when 'article-type nil b e props)
1432 (when (memq 'intangible props)
1434 (max (1- b) (point-min))
1435 b 'intangible (cddr (memq 'intangible props)))))
1437 (defsubst gnus-article-unhide-text (b e)
1438 "Remove hidden text properties from region between B and E."
1439 (remove-text-properties b e gnus-hidden-properties)
1440 (when (memq 'intangible gnus-hidden-properties)
1441 (put-text-property (max (1- b) (point-min))
1442 b 'intangible nil)))
1444 (defun gnus-article-hide-text-type (b e type)
1445 "Hide text of TYPE between B and E."
1446 (gnus-add-wash-type type)
1447 (gnus-article-hide-text
1448 b e (cons 'article-type (cons type gnus-hidden-properties))))
1450 (defun gnus-article-unhide-text-type (b e type)
1451 "Unhide text of TYPE between B and E."
1452 (gnus-delete-wash-type type)
1453 (remove-text-properties
1454 b e (cons 'article-type (cons type gnus-hidden-properties)))
1455 (when (memq 'intangible gnus-hidden-properties)
1456 (put-text-property (max (1- b) (point-min))
1457 b 'intangible nil)))
1459 (defun gnus-article-hide-text-of-type (type)
1460 "Hide text of TYPE in the current buffer."
1462 (let ((b (point-min))
1464 (while (setq b (text-property-any b e 'article-type type))
1465 (add-text-properties b (incf b) gnus-hidden-properties)))))
1467 (defun gnus-article-delete-text-of-type (type)
1468 "Delete text of TYPE in the current buffer."
1470 (let ((b (point-min)))
1471 (while (setq b (text-property-any b (point-max) 'article-type type))
1473 b (or (text-property-not-all b (point-max) 'article-type type)
1476 (defun gnus-article-delete-invisible-text ()
1477 "Delete all invisible text in the current buffer."
1479 (let ((b (point-min)))
1480 (while (setq b (text-property-any b (point-max) 'invisible t))
1482 b (or (text-property-not-all b (point-max) 'invisible t)
1485 (defun gnus-article-text-type-exists-p (type)
1486 "Say whether any text of type TYPE exists in the buffer."
1487 (text-property-any (point-min) (point-max) 'article-type type))
1489 (defsubst gnus-article-header-rank ()
1490 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1491 (let ((list gnus-sorted-header-list)
1494 (when (looking-at (car list))
1496 (setq list (cdr list))
1500 (defun article-hide-headers (&optional arg delete)
1501 "Hide unwanted headers and possibly sort them as well."
1502 (interactive (gnus-article-hidden-arg))
1503 ;; Lars said that this function might be inhibited.
1504 (if (gnus-article-check-hidden-text 'headers arg)
1506 ;; Show boring headers as well.
1507 (gnus-article-show-hidden-text 'boring-headers)
1508 (when (eq 1 (point-min))
1509 (set-window-start (get-buffer-window (current-buffer)) 1)))
1510 (unless gnus-inhibit-hiding
1513 (let ((inhibit-read-only t)
1514 (case-fold-search t)
1515 (max (1+ (length gnus-sorted-header-list)))
1516 (ignored (when (not gnus-visible-headers)
1517 (cond ((stringp gnus-ignored-headers)
1518 gnus-ignored-headers)
1519 ((listp gnus-ignored-headers)
1520 (mapconcat 'identity gnus-ignored-headers
1523 (cond ((stringp gnus-visible-headers)
1524 gnus-visible-headers)
1525 ((and gnus-visible-headers
1526 (listp gnus-visible-headers))
1527 (mapconcat 'identity gnus-visible-headers "\\|"))))
1528 (inhibit-point-motion-hooks t)
1530 ;; First we narrow to just the headers.
1531 (article-narrow-to-head)
1532 ;; Hide any "From " lines at the beginning of (mail) articles.
1533 (while (looking-at "From ")
1537 (delete-region (point-min) (point))
1538 (gnus-article-hide-text (point-min) (point)
1539 (nconc (list 'article-type 'headers)
1540 gnus-hidden-properties))))
1541 ;; Then treat the rest of the header lines.
1542 ;; Then we use the two regular expressions
1543 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1544 ;; select which header lines is to remain visible in the
1546 (while (re-search-forward "^[^ \t:]*:" nil t)
1548 ;; Mark the rank of the header.
1550 (point) (1+ (point)) 'message-rank
1551 (if (or (and visible (looking-at visible))
1553 (not (looking-at ignored))))
1554 (gnus-article-header-rank)
1557 (message-sort-headers-1)
1558 (when (setq beg (text-property-any
1559 (point-min) (point-max) 'message-rank (+ 2 max)))
1560 ;; We delete or make invisible the unwanted headers.
1561 (gnus-add-wash-type 'headers)
1564 (add-text-properties
1565 (point-min) (+ 5 (point-min))
1566 '(article-type headers dummy-invisible t))
1567 (delete-region beg (point-max)))
1568 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1570 (defun article-hide-boring-headers (&optional arg)
1571 "Toggle hiding of headers that aren't very interesting.
1572 If given a negative prefix, always show; if given a positive prefix,
1574 (interactive (gnus-article-hidden-arg))
1575 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1576 (not gnus-show-all-headers))
1579 (let ((buffer-read-only nil)
1580 (list gnus-boring-article-headers)
1581 (inhibit-point-motion-hooks t)
1583 (article-narrow-to-head)
1585 (setq elem (pop list))
1586 (goto-char (point-min))
1588 ;; Hide empty headers.
1590 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1592 (gnus-article-hide-text-type
1593 (progn (beginning-of-line) (point))
1596 (if (re-search-forward "^[^ \t]" nil t)
1600 ;; Hide boring Newsgroups header.
1601 ((eq elem 'newsgroups)
1602 (when (gnus-string-equal
1603 (gnus-fetch-field "newsgroups")
1604 (gnus-group-real-name
1605 (if (boundp 'gnus-newsgroup-name)
1608 (gnus-article-hide-header "newsgroups")))
1609 ((eq elem 'to-address)
1610 (let ((to (message-fetch-field "to"))
1612 (gnus-parameter-to-address
1613 (if (boundp 'gnus-newsgroup-name)
1614 gnus-newsgroup-name ""))))
1615 (when (and to to-address
1618 ;; only one address in To
1619 (nth 1 (mail-extract-address-components to))
1621 (gnus-article-hide-header "to"))))
1622 ((eq elem 'followup-to)
1623 (when (gnus-string-equal
1624 (message-fetch-field "followup-to")
1625 (message-fetch-field "newsgroups"))
1626 (gnus-article-hide-header "followup-to")))
1627 ((eq elem 'reply-to)
1628 (let ((from (message-fetch-field "from"))
1629 (reply-to (message-fetch-field "reply-to")))
1634 (nth 1 (mail-extract-address-components from))
1635 (nth 1 (mail-extract-address-components reply-to)))))
1636 (gnus-article-hide-header "reply-to"))))
1638 (let ((date (message-fetch-field "date")))
1640 (< (days-between (current-time-string) date)
1642 (gnus-article-hide-header "date"))))
1644 (let ((to (message-fetch-field "to"))
1645 (cc (message-fetch-field "cc")))
1646 (when (> (length to) 1024)
1647 (gnus-article-hide-header "to"))
1648 (when (> (length cc) 1024)
1649 (gnus-article-hide-header "cc"))))
1653 (goto-char (point-min))
1654 (while (re-search-forward "^to:" nil t)
1655 (setq to-count (1+ to-count)))
1656 (when (> to-count 1)
1657 (while (> to-count 0)
1658 (goto-char (point-min))
1660 (re-search-forward "^to:" nil nil to-count)
1662 (narrow-to-region (point) (point-max))
1663 (gnus-article-hide-header "to"))
1664 (setq to-count (1- to-count))))
1665 (goto-char (point-min))
1666 (while (re-search-forward "^cc:" nil t)
1667 (setq cc-count (1+ cc-count)))
1668 (when (> cc-count 1)
1669 (while (> cc-count 0)
1670 (goto-char (point-min))
1672 (re-search-forward "^cc:" nil nil cc-count)
1674 (narrow-to-region (point) (point-max))
1675 (gnus-article-hide-header "cc"))
1676 (setq cc-count (1- cc-count)))))))))))))
1678 (defun gnus-article-hide-header (header)
1680 (goto-char (point-min))
1681 (when (re-search-forward (concat "^" header ":") nil t)
1682 (gnus-article-hide-text-type
1683 (progn (beginning-of-line) (point))
1686 (if (re-search-forward "^[^ \t]" nil t)
1691 (defun article-toggle-headers (&optional arg)
1692 "Toggle hiding of headers. If given a negative prefix, always show;
1693 if given a positive prefix, always hide."
1694 (interactive (gnus-article-hidden-arg))
1695 (let ((force (when (numberp arg)
1696 (cond ((> arg 0) 'always-hide)
1697 ((< arg 0) 'always-show))))
1698 (window (get-buffer-window gnus-article-buffer))
1699 (header-end (point-min))
1700 header-start field-end field-start
1701 (inhibit-point-motion-hooks t)
1702 (inhibit-read-only t))
1705 (while (and (setq header-start
1706 (text-property-any header-end (point-max)
1707 'article-treated-header t))
1709 (text-property-not-all header-start (point-max)
1710 'article-treated-header t)))
1711 (setq field-end header-start)
1713 (;; Hide exposed invisible fields.
1714 (and (not (eq 'always-show force))
1716 (text-property-any field-end header-end
1717 'exposed-invisible-field t)))
1718 (while (and field-start
1719 (setq field-end (text-property-not-all
1720 field-start header-end
1721 'exposed-invisible-field t)))
1722 (add-text-properties field-start field-end gnus-hidden-properties)
1723 (setq field-start (text-property-any field-end header-end
1724 'exposed-invisible-field t)))
1725 (put-text-property header-start header-end
1726 'exposed-invisible-field nil))
1727 (;; Expose invisible fields.
1728 (and (not (eq 'always-hide force))
1730 (text-property-any field-end header-end 'invisible t)))
1731 (while (and field-start
1732 (setq field-end (text-property-not-all
1733 field-start header-end
1735 ;; If the invisible text is not terminated with newline, we
1736 ;; won't expose it. Because it may be created by x-face-mule.
1737 ;; BTW, XEmacs sometimes fail in putting an invisible text
1738 ;; property with `gnus-article-hide-text' (really?). In that
1739 ;; case, the invisible text might be started from the middle of
1740 ;; a line, so we will expose the sort of thing.
1741 (when (or (not (or (eq header-start field-start)
1742 (eq ?\n (char-before field-start))))
1743 (eq ?\n (char-before field-end))
1744 ;; Expose a boundary line anyway.
1747 (buffer-substring (max (- field-end 13) header-start)
1749 (remove-text-properties field-start field-end
1750 gnus-hidden-properties)
1751 (put-text-property field-start field-end
1752 'exposed-invisible-field t))
1753 (setq field-start (text-property-any field-end header-end
1756 (not (eq 'always-show force))
1757 (narrow-to-region header-start header-end)
1758 (article-hide-headers)
1759 ;; Re-display X-Face image under XEmacs.
1760 (when (and (featurep 'xemacs)
1761 (gnus-functionp gnus-article-x-face-command))
1762 (let ((func (cadr (assq 'gnus-treat-display-xface
1763 gnus-treatment-function-alist)))
1765 (when (and (not gnus-inhibit-treatment)
1767 (gnus-treat-predicate gnus-treat-display-xface))
1769 (put-text-property header-start header-end 'read-only nil))))
1772 (goto-char (point-min))
1774 (set-window-start window (point-min))))))
1776 (defvar gnus-article-normalized-header-length 40
1777 "Length of normalized headers.")
1779 (defun article-normalize-headers ()
1780 "Make all header lines 40 characters long."
1782 (let ((buffer-read-only nil)
1786 (article-narrow-to-head)
1789 ((< (setq column (- (gnus-point-at-eol) (point)))
1790 gnus-article-normalized-header-length)
1792 (insert (make-string
1793 (- gnus-article-normalized-header-length column)
1795 ((> column gnus-article-normalized-header-length)
1796 (gnus-put-text-property
1798 (forward-char gnus-article-normalized-header-length)
1805 (forward-line 1))))))
1807 (defun article-treat-dumbquotes ()
1808 "Translate M****s*** sm*rtq**t*s into proper text.
1809 Note that this function guesses whether a character is a sm*rtq**t* or
1810 not, so it should only be used interactively.
1812 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1813 in an attempt to provide more quoting characters. If you see
1814 something like \\222 or \\264 where you're expecting some kind of
1815 apostrophe or quotation mark, then try this wash."
1817 (article-translate-strings gnus-article-dumbquotes-map))
1819 (defun article-translate-characters (from to)
1820 "Translate all characters in the body of the article according to FROM and TO.
1821 FROM is a string of characters to translate from; to is a string of
1822 characters to translate to."
1824 (when (article-goto-body)
1825 (let ((buffer-read-only nil)
1826 (x (make-string 225 ?x))
1828 (while (< (incf i) (length x))
1831 (while (< i (length from))
1832 (aset x (aref from i) (aref to i))
1834 (translate-region (point) (point-max) x)))))
1836 (defun article-translate-strings (map)
1837 "Translate all string in the body of the article according to MAP.
1838 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1840 (when (article-goto-body)
1841 (let ((buffer-read-only nil)
1843 (while (setq elem (pop map))
1845 (while (search-forward (car elem) nil t)
1846 (replace-match (cadr elem)))))))))
1848 (defun article-treat-overstrike ()
1849 "Translate overstrikes into bold text."
1852 (when (article-goto-body)
1853 (let ((buffer-read-only nil))
1854 (while (search-forward "\b" nil t)
1855 (let ((next (char-after))
1859 previous (char-after))
1863 ;; We do the boldification/underlining by hiding the
1864 ;; overstrikes and putting the proper text property
1868 (gnus-article-hide-text-type start (point) 'overstrike)
1869 (put-text-property (point) end 'face 'bold))
1871 (gnus-article-hide-text-type
1872 (1- (point)) (1+ (point)) 'overstrike)
1874 start (1- (point)) 'face 'underline))
1876 (gnus-article-hide-text-type start (point) 'overstrike)
1878 (point) end 'face 'underline)))))))))
1880 (defun gnus-article-treat-unfold-headers ()
1881 "Unfold folded message headers.
1882 Only the headers that fit into the current window width will be
1885 (gnus-with-article-headers
1889 (mail-header-narrow-to-field)
1890 (let ((header (buffer-substring (point-min) (point-max))))
1893 (goto-char (point-min))
1894 (while (re-search-forward "\n[\t ]" nil t)
1895 (replace-match " " t t)))
1896 (setq length (- (point-max) (point-min) 1)))
1897 (when (< length (window-width))
1898 (while (re-search-forward "\n[\t ]" nil t)
1899 (replace-match " " t t)))
1900 (goto-char (point-max)))))))
1902 (defun gnus-article-treat-fold-headers ()
1903 "Fold message headers."
1905 (gnus-with-article-headers
1908 (mail-header-narrow-to-field)
1909 (mail-header-fold-field)
1910 (goto-char (point-max))))))
1912 (defun gnus-treat-smiley ()
1913 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1915 (unless (featurep 'xemacs)
1916 (when (and (>= emacs-major-version 21)
1917 (not gnus-article-should-use-smiley-mule)
1918 gnus-article-smiley-mule-loaded-p)
1919 (load "smiley" nil t)
1920 (setq gnus-article-smiley-mule-loaded-p nil))
1921 (when (and gnus-article-should-use-smiley-mule
1922 (not gnus-article-smiley-mule-loaded-p))
1923 (load "smiley-mule" nil t)
1924 (setq gnus-article-smiley-mule-loaded-p t)))
1925 (gnus-with-article-buffer
1926 (if (memq 'smiley gnus-article-wash-types)
1927 (gnus-delete-images 'smiley)
1929 (let ((images (smiley-region (point) (point-max))))
1931 (gnus-add-wash-type 'smiley)
1932 (dolist (image images)
1933 (gnus-add-image 'smiley image)))))))
1935 (defun gnus-article-remove-images ()
1936 "Remove all images from the article buffer."
1938 (gnus-with-article-buffer
1939 (dolist (elem gnus-article-image-alist)
1940 (gnus-delete-images (car elem)))))
1942 (defun gnus-article-treat-fold-newsgroups ()
1943 "Unfold folded message headers.
1944 Only the headers that fit into the current window width will be
1947 (gnus-with-article-headers
1948 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1950 (mail-header-narrow-to-field)
1951 (while (re-search-forward ", *" nil t)
1952 (replace-match ", " t t))
1953 (mail-header-fold-field)
1954 (goto-char (point-max))))))
1956 (defun gnus-article-treat-body-boundary ()
1957 "Place a boundary line at the end of the headers."
1959 (when (and gnus-body-boundary-delimiter
1960 (> (length gnus-body-boundary-delimiter) 0))
1961 (gnus-with-article-headers
1962 (goto-char (point-max))
1963 (let ((start (point)))
1964 (insert "X-Boundary: ")
1965 (gnus-add-text-properties start (point) '(invisible t intangible t))
1967 (while (>= (1- (window-width)) (length str))
1968 (setq str (concat str gnus-body-boundary-delimiter)))
1969 (substring str 0 (1- (window-width))))
1971 (gnus-add-text-properties start (point) '(gnus-decoration 'header))))))
1973 (defun article-fill-long-lines ()
1974 "Fill lines that are wider than the window width."
1977 (let ((buffer-read-only nil)
1978 (width (window-width (get-buffer-window (current-buffer)))))
1981 (let ((adaptive-fill-mode nil)) ;Why? -sm
1984 (when (>= (current-column) (min fill-column width))
1985 (narrow-to-region (point) (gnus-point-at-bol))
1986 (fill-paragraph nil)
1987 (goto-char (point-max))
1989 (forward-line 1)))))))
1991 (defun article-capitalize-sentences ()
1992 "Capitalize the first word in each sentence."
1995 (let ((buffer-read-only nil)
1996 (paragraph-start "^[\n\^L]"))
2000 (forward-sentence)))))
2002 (defun article-remove-cr ()
2003 "Remove trailing CRs and then translate remaining CRs into LFs."
2006 (let ((buffer-read-only nil))
2007 (goto-char (point-min))
2008 (while (re-search-forward "\r+$" nil t)
2009 (replace-match "" t t))
2010 (goto-char (point-min))
2011 (while (search-forward "\r" nil t)
2012 (replace-match "\n" t t)))))
2014 (defun article-remove-trailing-blank-lines ()
2015 "Remove all trailing blank lines from the article."
2018 (let ((buffer-read-only nil))
2019 (goto-char (point-max))
2023 (while (and (not (bobp))
2024 (looking-at "^[ \t]*$")
2025 (not (gnus-annotation-in-region-p
2026 (point) (gnus-point-at-eol))))
2031 (defun article-display-x-face (&optional force)
2032 "Look for an X-Face header and display it if present."
2033 (interactive (list 'force))
2034 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2035 (gnus-with-article-headers
2036 ;; Delete the old process, if any.
2037 (when (process-status "article-x-face")
2038 (delete-process "article-x-face"))
2039 (if (memq 'xface gnus-article-wash-types)
2040 ;; We have already displayed X-Faces, so we remove them
2042 (gnus-delete-images 'xface)
2044 (let (x-faces from face grey)
2046 (when (and wash-face-p
2048 (goto-char (point-min))
2049 (not (re-search-forward
2050 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2051 (gnus-buffer-live-p gnus-original-article-buffer))
2052 ;; If type `W f', use gnus-original-article-buffer,
2053 ;; otherwise use the current buffer because displaying
2054 ;; RFC822 parts calls this function too.
2055 (set-buffer gnus-original-article-buffer))
2057 (mail-narrow-to-head)
2058 (if gnus-treat-display-grey-xface
2060 (while (gnus-article-goto-header "X-Face\\(-[0-9]+\\)?")
2061 (if (match-beginning 2)
2064 (push (cons (- (string-to-number (match-string 2)))
2065 (mail-header-field-value))
2067 (push (cons 0 (mail-header-field-value)) x-faces)))
2068 (dolist (x-face (prog1
2069 (sort x-faces 'car-less-than-car)
2070 (setq x-faces nil)))
2071 (push (cdr x-face) x-faces)))
2072 (while (gnus-article-goto-header "X-Face")
2073 (push (mail-header-field-value) x-faces)))
2074 (setq from (message-fetch-field "from"))))
2076 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
2079 (setq image (gnus-create-image xpm 'xpm t))
2080 (gnus-article-goto-header "from")
2082 (insert "From: [no `from' set]\n")
2084 (gnus-add-wash-type 'xface)
2085 (gnus-add-image 'xface image)
2086 (gnus-put-image image)))
2087 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2088 ;; single external face.
2089 (when (stringp gnus-article-x-face-command)
2090 (setq x-faces (list (car x-faces))))
2091 (while (and (setq face (pop x-faces))
2092 gnus-article-x-face-command
2094 ;; Check whether this face is censored.
2095 (not gnus-article-x-face-too-ugly)
2096 (and gnus-article-x-face-too-ugly from
2097 (not (string-match gnus-article-x-face-too-ugly
2099 ;; We display the face.
2100 (if (symbolp gnus-article-x-face-command)
2101 ;; The command is a lisp function, so we call it.
2102 (if (gnus-functionp gnus-article-x-face-command)
2103 (funcall gnus-article-x-face-command face)
2104 (error "%s is not a function" gnus-article-x-face-command))
2105 ;; The command is a string, so we interpret the command
2106 ;; as a, well, command, and fork it off.
2107 (let ((process-connection-type nil))
2108 (process-kill-without-query
2110 "article-x-face" nil shell-file-name shell-command-switch
2111 gnus-article-x-face-command))
2114 (process-send-region "article-x-face"
2115 (point-min) (point-max)))
2116 (process-send-eof "article-x-face"))))))))))
2118 (defun article-decode-mime-words ()
2119 "Decode all MIME-encoded words in the article."
2122 (set-buffer gnus-article-buffer)
2123 (let ((inhibit-point-motion-hooks t)
2125 (mail-parse-charset gnus-newsgroup-charset)
2126 (mail-parse-ignored-charsets
2127 (save-excursion (set-buffer gnus-summary-buffer)
2128 gnus-newsgroup-ignored-charsets)))
2129 (mail-decode-encoded-word-region (point-min) (point-max)))))
2131 (defun article-decode-charset (&optional prompt)
2132 "Decode charset-encoded text in the article.
2133 If PROMPT (the prefix), prompt for a coding system to use."
2135 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2137 (mail-parse-charset gnus-newsgroup-charset)
2138 (mail-parse-ignored-charsets
2139 (save-excursion (condition-case nil
2140 (set-buffer gnus-summary-buffer)
2142 gnus-newsgroup-ignored-charsets))
2143 ct cte ctl charset format)
2146 (article-narrow-to-head)
2147 (setq ct (message-fetch-field "Content-Type" t)
2148 cte (message-fetch-field "Content-Transfer-Encoding" t)
2149 ctl (and ct (ignore-errors
2150 (mail-header-parse-content-type ct)))
2153 (mm-read-coding-system "Charset to decode: "))
2155 (mail-content-type-get ctl 'charset)))
2156 format (and ctl (mail-content-type-get ctl 'format)))
2158 (setq cte (mail-header-strip cte)))
2159 (if (and ctl (not (string-match "/" (car ctl))))
2161 (goto-char (point-max)))
2164 (narrow-to-region (point) (point-max))
2165 (when (and (eq mail-parse-charset 'gnus-decoded)
2166 (eq (mm-body-7-or-8) '8bit))
2167 ;; The text code could have been decoded.
2168 (setq charset mail-parse-charset))
2169 (when (and (or (not ctl)
2170 (equal (car ctl) "text/plain"))
2171 (not format)) ;; article with format will decode later.
2173 charset (and cte (intern (downcase
2174 (gnus-strip-whitespace cte))))
2177 (defun article-decode-encoded-words ()
2178 "Remove encoded-word encoding from headers."
2179 (let (buffer-read-only)
2180 (let ((charset (save-excursion
2181 (set-buffer gnus-summary-buffer)
2182 default-mime-charset)))
2183 (mime-decode-header-in-buffer charset))))
2185 (defun article-decode-group-name ()
2186 "Decode group names in `Newsgroups:'."
2187 (let ((inhibit-point-motion-hooks t)
2189 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2190 (when (and (or gnus-group-name-charset-method-alist
2191 gnus-group-name-charset-group-alist)
2192 (gnus-buffer-live-p gnus-original-article-buffer))
2193 (when (nnmail-fetch-field "Newsgroups")
2194 (nnheader-replace-header "Newsgroups"
2195 (gnus-decode-newsgroups
2196 (with-current-buffer
2197 gnus-original-article-buffer
2198 (nnmail-fetch-field "Newsgroups"))
2199 gnus-newsgroup-name method)))
2200 (when (nnmail-fetch-field "Followup-To")
2201 (nnheader-replace-header "Followup-To"
2202 (gnus-decode-newsgroups
2203 (with-current-buffer
2204 gnus-original-article-buffer
2205 (nnmail-fetch-field "Followup-To"))
2206 gnus-newsgroup-name method))))))
2208 (defun article-de-quoted-unreadable (&optional force read-charset)
2209 "Translate a quoted-printable-encoded article.
2210 If FORCE, decode the article whether it is marked as quoted-printable
2212 If READ-CHARSET, ask for a coding system."
2213 (interactive (list 'force current-prefix-arg))
2215 (let ((buffer-read-only nil) type charset)
2216 (if (gnus-buffer-live-p gnus-original-article-buffer)
2217 (with-current-buffer gnus-original-article-buffer
2219 (gnus-fetch-field "content-transfer-encoding"))
2220 (let* ((ct (gnus-fetch-field "content-type"))
2223 (mail-header-parse-content-type ct)))))
2224 (setq charset (and ctl
2225 (mail-content-type-get ctl 'charset)))
2226 (if (stringp charset)
2227 (setq charset (intern (downcase charset)))))))
2229 (setq charset (mm-read-coding-system "Charset: " charset)))
2231 (setq charset gnus-newsgroup-charset))
2233 (and type (let ((case-fold-search t))
2234 (string-match "quoted-printable" type))))
2236 (quoted-printable-decode-region
2237 (point) (point-max) (mm-charset-to-coding-system charset))))))
2239 (defun article-de-base64-unreadable (&optional force read-charset)
2240 "Translate a base64 article.
2241 If FORCE, decode the article whether it is marked as base64 not.
2242 If READ-CHARSET, ask for a coding system."
2243 (interactive (list 'force current-prefix-arg))
2245 (let ((buffer-read-only nil) type charset)
2246 (if (gnus-buffer-live-p gnus-original-article-buffer)
2247 (with-current-buffer gnus-original-article-buffer
2249 (gnus-fetch-field "content-transfer-encoding"))
2250 (let* ((ct (gnus-fetch-field "content-type"))
2253 (mail-header-parse-content-type ct)))))
2254 (setq charset (and ctl
2255 (mail-content-type-get ctl 'charset)))
2256 (if (stringp charset)
2257 (setq charset (intern (downcase charset)))))))
2259 (setq charset (mm-read-coding-system "Charset: " charset)))
2261 (setq charset gnus-newsgroup-charset))
2263 (and type (let ((case-fold-search t))
2264 (string-match "base64" type))))
2267 (narrow-to-region (point) (point-max))
2268 (base64-decode-region (point-min) (point-max))
2269 (mm-decode-coding-region
2270 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2275 (defun article-decode-HZ ()
2276 "Translate a HZ-encoded article."
2280 (let ((buffer-read-only nil))
2281 (rfc1843-decode-region (point-min) (point-max)))))
2283 (defun article-unsplit-urls ()
2284 "Remove the newlines that some other mailers insert into URLs."
2287 (let ((buffer-read-only nil))
2288 (goto-char (point-min))
2289 (while (re-search-forward
2290 "^\\(\\(https?\\|ftp\\)://\\S-+\\)\n\\(\\S-+\\)" nil t)
2291 (replace-match "\\1\\3" t)))))
2293 (defun article-wash-html (&optional read-charset)
2294 "Format an html article.
2295 If READ-CHARSET, ask for a coding system."
2298 (let ((buffer-read-only nil)
2300 (if (gnus-buffer-live-p gnus-original-article-buffer)
2301 (with-current-buffer gnus-original-article-buffer
2302 (let* ((ct (gnus-fetch-field "content-type"))
2305 (mail-header-parse-content-type ct)))))
2306 (setq charset (and ctl
2307 (mail-content-type-get ctl 'charset)))
2308 (if (stringp charset)
2309 (setq charset (intern (downcase charset)))))))
2311 (setq charset (mm-read-coding-system "Charset: " charset)))
2313 (setq charset gnus-newsgroup-charset))
2315 (save-window-excursion
2317 (narrow-to-region (point) (point-max))
2318 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2319 (entry (assq func mm-text-html-washer-alist)))
2321 (setq func (cdr entry)))
2323 ((gnus-functionp func)
2326 (apply (car func) (cdr func))))))))))
2328 (defun gnus-article-wash-html-with-w3 ()
2329 "Wash the current buffer with w3."
2331 (let ((w3-strict-width (window-width))
2332 (url-standalone-mode t)
2333 (url-gateway-unplugged t)
2334 (w3-honor-stylesheets nil)
2335 (w3-delay-image-loads t))
2337 (w3-region (point-min) (point-max))
2340 (defun gnus-article-wash-html-with-w3m ()
2341 "Wash the current buffer with emacs-w3m."
2344 (narrow-to-region (point) (point-max))
2345 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2348 (w3m-display-inline-images mm-inline-text-html-with-images)
2349 w3m-force-redisplay)
2350 (w3m-region (point-min) (point-max)))
2351 (when mm-inline-text-html-with-w3m-keymap
2352 (add-text-properties
2353 (point-min) (point-max)
2354 (append '(mm-inline-text-html-with-w3m t)
2355 (gnus-local-map-property mm-w3m-mode-map))))))
2357 (defun article-hide-list-identifiers ()
2358 "Remove list identifies from the Subject header.
2359 The `gnus-list-identifiers' variable specifies what to do."
2361 (let ((inhibit-point-motion-hooks t)
2362 (regexp (if (consp gnus-list-identifiers)
2363 (mapconcat 'identity gnus-list-identifiers " *\\|")
2364 gnus-list-identifiers))
2369 (article-narrow-to-head)
2370 (goto-char (point-min))
2371 (while (re-search-forward
2372 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2374 (delete-region (match-beginning 2) (match-end 0))
2375 (beginning-of-line))
2376 (when (re-search-forward
2377 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2378 (delete-region (match-beginning 1) (match-end 1))))))))
2380 (defun article-hide-pgp ()
2381 "Remove any PGP headers and signatures in the current article."
2385 (let ((inhibit-point-motion-hooks t)
2386 buffer-read-only beg end)
2388 ;; Hide the "header".
2389 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2390 (gnus-add-wash-type 'pgp)
2391 (delete-region (match-beginning 0) (match-end 0))
2392 ;; Remove armor headers (rfc2440 6.2)
2393 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2396 ;; Hide the actual signature.
2397 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2398 (setq end (1+ (match-beginning 0)))
2401 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2403 ;; Perhaps we shouldn't hide to the end of the buffer
2404 ;; if there is no end to the signature?
2406 ;; Hide "- " PGP quotation markers.
2408 (narrow-to-region beg end)
2409 (goto-char (point-min))
2410 (while (re-search-forward "^- " nil t)
2412 (match-beginning 0) (match-end 0)))
2414 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2416 (defun article-hide-pem (&optional arg)
2417 "Toggle hiding of any PEM headers and signatures in the current article.
2418 If given a negative prefix, always show; if given a positive prefix,
2420 (interactive (gnus-article-hidden-arg))
2421 (unless (gnus-article-check-hidden-text 'pem arg)
2423 (let (buffer-read-only end)
2424 (goto-char (point-min))
2425 ;; Hide the horrendously ugly "header".
2426 (when (and (search-forward
2427 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2429 (setq end (1+ (match-beginning 0))))
2430 (gnus-add-wash-type 'pem)
2431 (gnus-article-hide-text-type
2433 (if (search-forward "\n\n" nil t)
2437 ;; Hide the trailer as well
2438 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2440 (gnus-article-hide-text-type
2441 (match-beginning 0) (match-end 0) 'pem)))))))
2443 (defun article-strip-banner ()
2444 "Strip the banner specified by the `banner' group parameter."
2448 (let ((inhibit-point-motion-hooks t)
2449 (banner (gnus-parameter-banner gnus-newsgroup-name))
2450 (gnus-signature-limit nil)
2451 buffer-read-only beg end)
2455 ((eq banner 'signature)
2456 (when (gnus-article-narrow-to-signature)
2459 (delete-region (point) (point-max))))
2461 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2462 (while (re-search-forward banner nil t)
2463 (delete-region (match-beginning 0) (match-end 0)))))
2465 (while (re-search-forward banner nil t)
2466 (delete-region (match-beginning 0) (match-end 0))))))))))
2468 (defun article-babel ()
2469 "Translate article using an online translation service."
2473 (set-buffer gnus-article-buffer)
2474 (when (article-goto-body)
2475 (let* ((buffer-read-only nil)
2478 (orig (buffer-substring start end))
2479 (trans (babel-as-string orig)))
2481 (narrow-to-region start end)
2482 (delete-region start end)
2485 (defun article-hide-signature (&optional arg)
2486 "Hide the signature in the current article.
2487 If given a negative prefix, always show; if given a positive prefix,
2489 (interactive (gnus-article-hidden-arg))
2495 (article-goto-body))
2496 (goto-char (point-min)))
2497 (unless (gnus-article-check-hidden-text 'signature arg)
2498 (let ((buffer-read-only nil)
2500 (while (setq button (text-property-any button (point-max)
2502 'gnus-signature-toggle))
2503 (setq button (text-property-not-all button (point-max)
2505 'gnus-signature-toggle))
2506 (when (and button (not (eobp)))
2507 (gnus-article-hide-text-type
2509 (next-single-property-change (1+ button) 'mime-view-entity
2512 (gnus-set-mode-line 'article))
2514 (defun article-strip-headers-in-body ()
2515 "Strip offensive headers from bodies."
2519 (let ((case-fold-search t))
2520 (when (looking-at "x-no-archive:")
2521 (gnus-delete-line)))))
2523 (defun article-strip-leading-blank-lines ()
2524 "Remove all blank lines from the beginning of the article."
2527 (let ((inhibit-point-motion-hooks t)
2529 (when (article-goto-body)
2530 (while (and (not (eobp))
2531 (looking-at "[ \t]*$"))
2532 (gnus-delete-line))))))
2534 (defun article-narrow-to-head ()
2535 "Narrow the buffer to the head of the message.
2536 Point is left at the beginning of the narrowed-to region."
2538 (goto-char (point-min))
2539 (if (search-forward "\n\n" nil 1)
2542 (goto-char (point-min)))
2544 (defun article-goto-body ()
2545 "Place point at the start of the body."
2546 (goto-char (point-min))
2548 ;; This variable is only bound when dealing with separate
2550 (article-goto-body-goes-to-point-min-p
2552 ((search-forward "\n\n" nil t)
2555 (goto-char (point-max))
2558 (defun article-strip-multiple-blank-lines ()
2559 "Replace consecutive blank lines with one empty line."
2562 (let ((inhibit-point-motion-hooks t)
2564 ;; First make all blank lines empty.
2566 (while (re-search-forward "^[ \t]+$" nil t)
2567 (unless (gnus-annotation-in-region-p
2568 (match-beginning 0) (match-end 0))
2569 (replace-match "" nil t)))
2570 ;; Then replace multiple empty lines with a single empty line.
2572 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2573 (unless (gnus-annotation-in-region-p
2574 (match-beginning 0) (match-end 0))
2575 (delete-region (match-beginning 1) (match-end 1)))))))
2577 (defun article-strip-leading-space ()
2578 "Remove all white space from the beginning of the lines in the article."
2581 (let ((inhibit-point-motion-hooks t)
2584 (while (re-search-forward "^[ \t]+" nil t)
2585 (replace-match "" t t)))))
2587 (defun article-strip-trailing-space ()
2588 "Remove all white space from the end of the lines in the article."
2591 (let ((inhibit-point-motion-hooks t)
2594 (while (re-search-forward "[ \t]+$" nil t)
2595 (replace-match "" t t)))))
2597 (defun article-strip-blank-lines ()
2598 "Strip leading, trailing and multiple blank lines."
2600 (article-strip-leading-blank-lines)
2601 (article-remove-trailing-blank-lines)
2602 (article-strip-multiple-blank-lines))
2604 (defun article-strip-all-blank-lines ()
2605 "Strip all blank lines."
2608 (let ((inhibit-point-motion-hooks t)
2611 (while (re-search-forward "^[ \t]*\n" nil t)
2612 (replace-match "" t t)))))
2614 (defun gnus-article-narrow-to-signature ()
2615 "Narrow to the signature; return t if a signature is found, else nil."
2616 (let ((inhibit-point-motion-hooks t))
2617 (when (gnus-article-search-signature)
2619 ;; Check whether we have some limits to what we consider
2620 ;; to be a signature.
2621 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2622 (list gnus-signature-limit)))
2624 (while (setq limit (pop limits))
2625 (if (or (and (integerp limit)
2626 (< (- (point-max) (point)) limit))
2628 (< (count-lines (point) (point-max)) limit))
2629 (and (gnus-functionp limit)
2631 (and (stringp limit)
2632 (not (re-search-forward limit nil t))))
2633 () ; This limit did not succeed.
2637 (narrow-to-region (point) (point-max))
2640 (defun gnus-article-search-signature ()
2641 "Search the current buffer for the signature separator.
2642 Put point at the beginning of the signature separator."
2643 (let ((cur (point)))
2644 (goto-char (point-max))
2645 (if (if (stringp gnus-signature-separator)
2646 (re-search-backward gnus-signature-separator nil t)
2647 (let ((seps gnus-signature-separator))
2649 (not (re-search-backward (car seps) nil t)))
2656 (defun gnus-article-hidden-arg ()
2657 "Return the current prefix arg as a number, or 0 if no prefix."
2658 (list (if current-prefix-arg
2659 (prefix-numeric-value current-prefix-arg)
2662 (defun gnus-article-check-hidden-text (type arg)
2663 "Return nil if hiding is necessary.
2664 Arg can be nil or a number. nil and positive means hide, negative
2665 means show, 0 means toggle."
2668 (let ((hide (gnus-article-hidden-text-p type)))
2674 (gnus-article-show-hidden-text type)
2677 (if (eq hide 'hidden)
2679 (gnus-article-show-hidden-text type)
2683 (defun gnus-article-hidden-text-p (type)
2684 "Say whether the current buffer contains hidden text of type TYPE."
2685 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2687 (not (get-text-property pos 'invisible))
2688 (not (get-text-property pos 'dummy-invisible)))
2690 (text-property-any (1+ pos) (point-max) 'article-type type)))
2695 (defun gnus-article-show-hidden-text (type &optional dummy)
2696 "Show all hidden text of type TYPE.
2697 Originally it is hide instead of DUMMY."
2698 (let ((buffer-read-only nil)
2699 (inhibit-point-motion-hooks t))
2700 (gnus-remove-text-properties-when
2702 (point-min) (point-max)
2703 (cons 'article-type (cons type
2704 gnus-hidden-properties)))
2705 (gnus-delete-wash-type type)))
2707 (defconst article-time-units
2708 `((year . ,(* 365.25 24 60 60))
2709 (week . ,(* 7 24 60 60))
2710 (day . ,(* 24 60 60))
2714 "Mapping from time units to seconds.")
2716 (defun article-date-ut (&optional type highlight header)
2717 "Convert DATE date to universal time in the current article.
2718 If TYPE is `local', convert to local time; if it is `lapsed', output
2719 how much time has lapsed since DATE. For `lapsed', the value of
2720 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2721 should replace the \"Date:\" one, or should be added below it."
2722 (interactive (list 'ut t))
2723 (let* ((header (or header
2724 (and (eq 1 (point-min))
2725 (mail-header-date (save-excursion
2726 (set-buffer gnus-summary-buffer)
2727 gnus-current-headers)))
2728 (message-fetch-field "date")
2730 (date (if (vectorp header) (mail-header-date header)
2732 (inhibit-point-motion-hooks t)
2733 bface eface date-pos)
2734 (when (and date (not (string= date "")))
2737 (article-narrow-to-head)
2738 (when (or (and (eq type 'lapsed)
2739 gnus-article-date-lapsed-new-header
2740 ;; Attempt to get the face of X-Sent first.
2741 (re-search-forward "^X-Sent:[ \t]" nil t))
2742 (re-search-forward "^Date:[ \t]" nil t)
2743 ;; If Date is missing, try again for X-Sent.
2744 (re-search-forward "^X-Sent:[ \t]" nil t))
2745 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2746 date (or (get-text-property (gnus-point-at-bol)
2749 eface (get-text-property (1- (gnus-point-at-eol))
2751 (let ((buffer-read-only nil))
2752 ;; Delete any old X-Sent headers.
2753 (when (setq date-pos
2754 (text-property-any (point-min) (point-max)
2755 'article-date-lapsed t))
2756 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2757 (delete-region (match-beginning 0)
2758 (progn (forward-line 1) (point))))
2759 (goto-char (point-min))
2760 ;; Delete any old Date headers.
2761 (while (re-search-forward "^Date:[ \t]" nil t)
2763 (setq date-pos (match-beginning 0)))
2764 (unless (and (eq type 'lapsed)
2765 gnus-article-date-lapsed-new-header)
2766 (delete-region (match-beginning 0)
2767 (progn (message-next-header) (point)))))
2770 (goto-char date-pos)
2772 ;; Possibly, Date has been deleted.
2774 (when (and (eq type 'lapsed)
2775 gnus-article-date-lapsed-new-header
2776 (looking-at "Date:"))
2778 (goto-char (point-min)))
2779 (insert (article-make-date-line date type))
2780 (when (eq type 'lapsed)
2781 (put-text-property (gnus-point-at-bol) (point)
2782 'article-date-lapsed t))
2786 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2787 (put-text-property (match-beginning 1) (1+ (match-end 1))
2788 'original-date date)
2789 (put-text-property (match-beginning 1) (1+ (match-end 1))
2791 (put-text-property (match-beginning 2) (match-end 2)
2794 (defun article-make-date-line (date type)
2795 "Return a DATE line of TYPE."
2796 (unless (memq type '(local ut original user iso8601 lapsed english))
2797 (error "Unknown conversion type: %s" type))
2799 (let ((time (date-to-time date)))
2801 ;; Convert to the local timezone.
2803 (let ((tz (car (current-time-zone time))))
2804 (format "Date: %s %s%02d%02d" (current-time-string time)
2805 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2806 (/ (% (abs tz) 3600) 60))))
2807 ;; Convert to Universal Time.
2810 (current-time-string
2811 (let* ((e (parse-time-string date))
2812 (tm (apply 'encode-time e))
2814 (ls (- (cadr tm) (car (current-time-zone time)))))
2815 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2816 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2819 ;; Get the original date from the article.
2820 ((eq type 'original)
2821 (concat "Date: " (if (string-match "\n+$" date)
2822 (substring date 0 (match-beginning 0))
2824 ;; Let the user define the format.
2826 (if (gnus-functionp gnus-article-time-format)
2827 (funcall gnus-article-time-format time)
2830 (format-time-string gnus-article-time-format time))))
2833 (let ((tz (car (current-time-zone time))))
2836 (format-time-string "%Y%m%dT%H%M%S" time)
2837 (format "%s%02d%02d"
2838 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2839 (/ (% (abs tz) 3600) 60)))))
2840 ;; Do an X-Sent lapsed format.
2842 ;; If the date is seriously mangled, the timezone functions are
2843 ;; liable to bug out, so we ignore all errors.
2844 (let* ((now (current-time))
2845 (real-time (subtract-time now time))
2846 (real-sec (and real-time
2847 (+ (* (float (car real-time)) 65536)
2849 (sec (and real-time (abs real-sec)))
2859 ;; This is a bit convoluted, but basically we go
2860 ;; through the time units for years, weeks, etc,
2861 ;; and divide things to see whether that results
2862 ;; in positive answers.
2865 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2866 ;; The (remaining) seconds are too few to
2867 ;; be divided into this time unit.
2869 ;; It's big enough, so we output it.
2870 (setq sec (- sec (* num (cdr unit))))
2872 (concat (if prev ", " "") (int-to-string
2874 " " (symbol-name (car unit))
2875 (if (> num 1) "s" ""))
2877 article-time-units "")
2878 ;; If dates are odd, then it might appear like the
2879 ;; article was sent in the future.
2882 " in the future"))))))
2883 ;; Display the date in proper English
2885 (let ((dtime (decode-time time)))
2888 (number-to-string (nth 3 dtime))
2889 (let ((digit (% (nth 3 dtime) 10)))
2891 ((memq (nth 3 dtime) '(11 12 13)) "th")
2897 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2899 (number-to-string (nth 5 dtime))
2901 (format "%02d" (nth 2 dtime))
2903 (format "%02d" (nth 1 dtime)))))))
2905 (format "Date: %s (from Oort)" date))))
2907 (defun article-date-local (&optional highlight)
2908 "Convert the current article date to the local timezone."
2909 (interactive (list t))
2910 (article-date-ut 'local highlight))
2912 (defun article-date-english (&optional highlight)
2913 "Convert the current article date to something that is proper English."
2914 (interactive (list t))
2915 (article-date-ut 'english highlight))
2917 (defun article-date-original (&optional highlight)
2918 "Convert the current article date to what it was originally.
2919 This is only useful if you have used some other date conversion
2920 function and want to see what the date was before converting."
2921 (interactive (list t))
2922 (article-date-ut 'original highlight))
2924 (defun article-date-lapsed (&optional highlight)
2925 "Convert the current article date to time lapsed since it was sent."
2926 (interactive (list t))
2927 (article-date-ut 'lapsed highlight))
2929 (defun article-update-date-lapsed ()
2930 "Function to be run from a timer to update the lapsed time line."
2931 (let (deactivate-mark)
2936 (set-buffer (window-buffer w))
2937 (when (eq major-mode 'gnus-article-mode)
2938 (goto-char (point-min))
2939 (when (re-search-forward "^X-Sent:" nil t)
2940 (article-date-lapsed t))))
2943 (defun gnus-start-date-timer (&optional n)
2944 "Start a timer to update the X-Sent header in the article buffers.
2945 The numerical prefix says how frequently (in seconds) the function
2950 (gnus-stop-date-timer)
2951 (setq article-lapsed-timer
2952 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2954 (defun gnus-stop-date-timer ()
2955 "Stop the X-Sent timer."
2957 (when article-lapsed-timer
2958 (nnheader-cancel-timer article-lapsed-timer)
2959 (setq article-lapsed-timer nil)))
2961 (defun article-date-user (&optional highlight)
2962 "Convert the current article date to the user-defined format.
2963 This format is defined by the `gnus-article-time-format' variable."
2964 (interactive (list t))
2965 (article-date-ut 'user highlight))
2967 (defun article-date-iso8601 (&optional highlight)
2968 "Convert the current article date to ISO8601."
2969 (interactive (list t))
2970 (article-date-ut 'iso8601 highlight))
2972 ;; (defun article-show-all ()
2973 ;; "Show all hidden text in the article buffer."
2977 ;; (let ((buffer-read-only nil))
2978 ;; (gnus-article-unhide-text (point-min) (point-max))
2979 ;; (gnus-remove-text-with-property 'gnus-prev)
2980 ;; (gnus-remove-text-with-property 'gnus-next))))
2982 (defun article-show-all-headers ()
2983 "Show all hidden headers in the article buffer."
2988 (article-narrow-to-head)
2989 (let ((buffer-read-only nil))
2990 (gnus-article-unhide-text (point-min) (point-max))))))
2992 (defun article-remove-leading-whitespace ()
2993 "Remove excessive whitespace from all headers."
2997 (let ((buffer-read-only nil))
2998 (article-narrow-to-head)
2999 (goto-char (point-min))
3000 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3001 (delete-region (match-beginning 1) (match-end 1)))))))
3003 (defun article-emphasize (&optional arg)
3004 "Emphasize text according to `gnus-emphasis-alist'."
3005 (interactive (gnus-article-hidden-arg))
3006 (unless (gnus-article-check-hidden-text 'emphasis arg)
3010 (with-current-buffer gnus-summary-buffer
3011 gnus-article-emphasis-alist)
3013 gnus-emphasis-alist))
3014 (buffer-read-only nil)
3015 (props (append '(article-type emphasis)
3016 gnus-hidden-properties))
3017 regexp elem beg invisible visible face)
3020 (while (setq elem (pop alist))
3022 (setq regexp (car elem)
3023 invisible (nth 1 elem)
3024 visible (nth 2 elem)
3026 (while (re-search-forward regexp nil t)
3027 (when (and (match-beginning visible) (match-beginning invisible))
3028 (gnus-article-hide-text
3029 (match-beginning invisible) (match-end invisible) props)
3030 (gnus-article-unhide-text-type
3031 (match-beginning visible) (match-end visible) 'emphasis)
3032 (gnus-put-overlay-excluding-newlines
3033 (match-beginning visible) (match-end visible) 'face face)
3034 (gnus-add-wash-type 'emphasis)
3035 (goto-char (match-end invisible)))))))))
3037 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3038 "Setup newsgroup emphasis alist."
3039 (unless gnus-article-emphasis-alist
3040 (let ((name (and gnus-newsgroup-name
3041 (gnus-group-real-name gnus-newsgroup-name))))
3042 (make-local-variable 'gnus-article-emphasis-alist)
3043 (setq gnus-article-emphasis-alist
3045 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3046 (while (setq elem (pop alist))
3047 (when (and name (string-match (car elem) name))
3049 highlight (copy-sequence (cdr elem)))))
3051 (copy-sequence highlight-words)
3052 (if gnus-newsgroup-name
3053 (copy-sequence (gnus-group-find-parameter
3054 gnus-newsgroup-name 'highlight-words t)))
3055 gnus-emphasis-alist)))))
3058 (defvar gnus-summary-article-menu)
3059 (defvar gnus-summary-post-menu))
3061 ;;; Saving functions.
3063 (defun gnus-article-save (save-buffer file &optional num)
3064 "Save the currently selected article."
3065 (unless gnus-save-all-headers
3066 ;; Remove headers according to `gnus-saved-headers'.
3067 (let ((gnus-visible-headers
3068 (or gnus-saved-headers gnus-visible-headers))
3069 (gnus-article-buffer save-buffer))
3071 (set-buffer save-buffer)
3072 (article-hide-headers 1 t))))
3073 (save-window-excursion
3074 (if (not gnus-default-article-saver)
3075 (error "No default saver is defined")
3076 ;; !!! Magic! The saving functions all save
3077 ;; `gnus-save-article-buffer' (or so they think), but we
3078 ;; bind that variable to our save-buffer.
3079 (set-buffer gnus-article-buffer)
3080 (let* ((gnus-save-article-buffer save-buffer)
3083 ((not gnus-prompt-before-saving) 'default)
3084 ((eq gnus-prompt-before-saving 'always) nil)
3086 (gnus-number-of-articles-to-be-saved
3087 (when (eq gnus-prompt-before-saving t)
3089 (set-buffer gnus-article-current-summary)
3090 (funcall gnus-default-article-saver filename)))))
3092 (defun gnus-read-save-file-name (prompt &optional filename
3093 function group headers variable)
3095 (funcall function group headers (symbol-value variable)))
3100 ((eq filename 'default)
3106 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3109 (if (and gnus-number-of-articles-to-be-saved
3110 (> gnus-number-of-articles-to-be-saved 1))
3111 (format "these %d articles"
3112 gnus-number-of-articles-to-be-saved)
3115 ;; Let the split methods have their say.
3117 ;; No split name was found.
3120 (concat prompt " (default "
3121 (file-name-nondirectory default-name) ") ")
3122 (file-name-directory default-name)
3124 ;; A single group name is returned.
3125 ((stringp split-name)
3127 (funcall function split-name headers
3128 (symbol-value variable)))
3130 (concat prompt " (default "
3131 (file-name-nondirectory default-name) ") ")
3132 (file-name-directory default-name)
3134 ;; A single split name was found
3135 ((= 1 (length split-name))
3136 (let* ((name (expand-file-name
3138 gnus-article-save-directory))
3139 (dir (cond ((file-directory-p name)
3140 (file-name-as-directory name))
3141 ((file-exists-p name) name)
3142 (t gnus-article-save-directory))))
3144 (concat prompt " (default " name ") ")
3146 ;; A list of splits was found.
3148 (setq split-name (nreverse split-name))
3150 (let ((file-name-history
3151 (nconc split-name file-name-history)))
3155 (concat prompt " (`M-p' for defaults) ")
3156 gnus-article-save-directory
3158 gnus-article-save-directory)))
3159 (car (push result file-name-history)))))))
3160 ;; Create the directory.
3161 (gnus-make-directory (file-name-directory file))
3162 ;; If we have read a directory, we append the default file name.
3163 (when (file-directory-p file)
3164 (setq file (expand-file-name (file-name-nondirectory
3166 (file-name-as-directory file))))
3167 ;; Possibly translate some characters.
3168 (nnheader-translate-file-chars file))))))
3169 (gnus-make-directory (file-name-directory result))
3170 (set variable result)))
3172 (defun gnus-article-archive-name (group)
3173 "Return the first instance of an \"Archive-name\" in the current buffer."
3174 (let ((case-fold-search t))
3175 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3176 (nnheader-concat gnus-article-save-directory
3177 (match-string 1)))))
3179 (defun gnus-article-nndoc-name (group)
3180 "If GROUP is an nndoc group, return the name of the parent group."
3181 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3182 (gnus-group-get-parameter group 'save-article-group)))
3184 (defun gnus-summary-save-in-rmail (&optional filename)
3185 "Append this article to Rmail file.
3186 Optional argument FILENAME specifies file name.
3187 Directory to save to is default to `gnus-article-save-directory'."
3188 (setq filename (gnus-read-save-file-name
3189 "Save %s in rmail file:" filename
3190 gnus-rmail-save-name gnus-newsgroup-name
3191 gnus-current-headers 'gnus-newsgroup-last-rmail))
3192 (gnus-eval-in-buffer-window gnus-save-article-buffer
3196 (gnus-output-to-rmail filename))))
3199 (defun gnus-summary-save-in-mail (&optional filename)
3200 "Append this article to Unix mail file.
3201 Optional argument FILENAME specifies file name.
3202 Directory to save to is default to `gnus-article-save-directory'."
3203 (setq filename (gnus-read-save-file-name
3204 "Save %s in Unix mail file:" filename
3205 gnus-mail-save-name gnus-newsgroup-name
3206 gnus-current-headers 'gnus-newsgroup-last-mail))
3207 (gnus-eval-in-buffer-window gnus-save-article-buffer
3211 (if (and (file-readable-p filename)
3212 (mail-file-babyl-p filename))
3213 (rmail-output-to-rmail-file filename t)
3214 (gnus-output-to-mail filename)))))
3217 (defun gnus-summary-save-in-file (&optional filename overwrite)
3218 "Append this article to file.
3219 Optional argument FILENAME specifies file name.
3220 Directory to save to is default to `gnus-article-save-directory'."
3221 (setq filename (gnus-read-save-file-name
3222 "Save %s in file:" filename
3223 gnus-file-save-name gnus-newsgroup-name
3224 gnus-current-headers 'gnus-newsgroup-last-file))
3225 (gnus-eval-in-buffer-window gnus-save-article-buffer
3229 (when (and overwrite
3230 (file-exists-p filename))
3231 (delete-file filename))
3232 (gnus-output-to-file filename))))
3235 (defun gnus-summary-write-to-file (&optional filename)
3236 "Write this article to a file, overwriting it if the file exists.
3237 Optional argument FILENAME specifies file name.
3238 The directory to save in defaults to `gnus-article-save-directory'."
3239 (gnus-summary-save-in-file nil t))
3241 (defun gnus-summary-save-body-in-file (&optional filename)
3242 "Append this article body to a file.
3243 Optional argument FILENAME specifies file name.
3244 The directory to save in defaults to `gnus-article-save-directory'."
3245 (setq filename (gnus-read-save-file-name
3246 "Save %s body in file:" filename
3247 gnus-file-save-name gnus-newsgroup-name
3248 gnus-current-headers 'gnus-newsgroup-last-file))
3249 (gnus-eval-in-buffer-window gnus-save-article-buffer
3253 (when (article-goto-body)
3254 (narrow-to-region (point) (point-max)))
3255 (gnus-output-to-file filename))))
3258 (defun gnus-summary-save-in-pipe (&optional command)
3259 "Pipe this article to subprocess."
3261 (cond ((and (eq command 'default)
3262 gnus-last-shell-command)
3263 gnus-last-shell-command)
3268 "Shell command on %s: "
3269 (if (and gnus-number-of-articles-to-be-saved
3270 (> gnus-number-of-articles-to-be-saved 1))
3271 (format "these %d articles"
3272 gnus-number-of-articles-to-be-saved)
3274 gnus-last-shell-command))))
3275 (when (string-equal command "")
3276 (if gnus-last-shell-command
3277 (setq command gnus-last-shell-command)
3278 (error "A command is required")))
3279 (gnus-eval-in-buffer-window gnus-article-buffer
3282 (shell-command-on-region (point-min) (point-max) command nil)))
3283 (setq gnus-last-shell-command command))
3285 (defun gnus-summary-pipe-to-muttprint (&optional command)
3286 "Pipe this article to muttprint."
3287 (setq command (read-string
3288 "Print using command: " gnus-summary-muttprint-program
3289 nil gnus-summary-muttprint-program))
3290 (gnus-summary-save-in-pipe command))
3292 ;;; Article file names when saving.
3294 (defun gnus-capitalize-newsgroup (newsgroup)
3295 "Capitalize NEWSGROUP name."
3296 (when (not (zerop (length newsgroup)))
3297 (concat (char-to-string (upcase (aref newsgroup 0)))
3298 (substring newsgroup 1))))
3300 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3301 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3302 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3303 Otherwise, it is like ~/News/news/group/num."
3306 (concat (if (gnus-use-long-file-name 'not-save)
3307 (gnus-capitalize-newsgroup newsgroup)
3308 (gnus-newsgroup-directory-form newsgroup))
3309 "/" (int-to-string (mail-header-number headers)))
3310 gnus-article-save-directory)))
3312 (string-equal (file-name-directory default)
3313 (file-name-directory last-file))
3314 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3316 (or last-file default))))
3318 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3319 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3320 If variable `gnus-use-long-file-name' is non-nil, it is
3321 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3324 (concat (if (gnus-use-long-file-name 'not-save)
3326 (gnus-newsgroup-directory-form newsgroup))
3327 "/" (int-to-string (mail-header-number headers)))
3328 gnus-article-save-directory)))
3330 (string-equal (file-name-directory default)
3331 (file-name-directory last-file))
3332 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3334 (or last-file default))))
3336 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3337 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3338 If variable `gnus-use-long-file-name' is non-nil, it is
3339 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3342 (if (gnus-use-long-file-name 'not-save)
3345 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3347 gnus-article-save-directory)))
3349 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3350 "Generate file name from sender."
3351 (let ((from (mail-header-from headers)))
3353 (if (and from (string-match "\\([^ <]+\\)@" from))
3354 (match-string 1 from)
3356 gnus-article-save-directory)))
3358 (defun article-verify-x-pgp-sig ()
3361 (if (gnus-buffer-live-p gnus-original-article-buffer)
3362 (let ((sig (with-current-buffer gnus-original-article-buffer
3363 (gnus-fetch-field "X-PGP-Sig")))
3367 (mml2015-clear-verify-function))
3369 (insert-buffer gnus-original-article-buffer)
3370 (setq items (split-string sig))
3371 (message-narrow-to-head)
3372 (let ((inhibit-point-motion-hooks t)
3373 (case-fold-search t))
3374 ;; Don't verify multiple headers.
3375 (setq headers (mapconcat (lambda (header)
3377 (mail-fetch-field header) "\n"))
3378 (split-string (nth 1 items) ",") "")))
3379 (delete-region (point-min) (point-max))
3380 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3381 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3386 (if (looking-at "^-")
3389 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3390 (insert "Version: " (car items) "\n\n")
3391 (insert (mapconcat 'identity (cddr items) "\n"))
3392 (insert "\n-----END PGP SIGNATURE-----\n")
3393 (let ((mm-security-handle (list (format "multipart/signed"))))
3394 (mml2015-clean-buffer)
3395 (let ((coding-system-for-write (or gnus-newsgroup-charset
3397 (funcall (mml2015-clear-verify-function)))
3399 (or (mm-handle-multipart-ctl-parameter
3400 mm-security-handle 'gnus-details)
3401 (mm-handle-multipart-ctl-parameter
3402 mm-security-handle 'gnus-info)))))
3404 (let (buffer-read-only bface eface)
3406 (message-narrow-to-head)
3407 (goto-char (point-max))
3409 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3410 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3411 (message-remove-header "X-Gnus-PGP-Verify")
3412 (if (re-search-forward "^X-PGP-Sig:" nil t)
3414 (goto-char (point-max)))
3415 (narrow-to-region (point) (point))
3416 (insert "X-Gnus-PGP-Verify: " info "\n")
3417 (goto-char (point-min))
3420 (if (not (looking-at "^[ \t]"))
3424 (goto-char (point-min))
3425 (when (looking-at "\\([^:]+\\): *")
3426 (put-text-property (match-beginning 1) (1+ (match-end 1))
3428 (put-text-property (match-end 0) (point-max)
3429 'face eface)))))))))
3431 (defun article-verify-cancel-lock ()
3432 "Verify Cancel-Lock header."
3434 (if (gnus-buffer-live-p gnus-original-article-buffer)
3435 (canlock-verify gnus-original-article-buffer)))
3442 (setq afunc (car func)
3445 gfunc (intern (format "gnus-%s" func))))
3447 (when (fboundp afunc)
3448 `(lambda (&optional interactive &rest args)
3449 ,(documentation afunc t)
3450 (interactive (list t))
3452 (set-buffer gnus-article-buffer)
3454 (call-interactively ',afunc)
3455 (apply ',afunc args))))))))
3456 '(article-hide-headers
3457 article-verify-x-pgp-sig
3458 article-verify-cancel-lock
3459 article-hide-boring-headers
3460 article-toggle-headers
3461 article-treat-overstrike
3462 article-fill-long-lines
3463 article-capitalize-sentences
3465 article-remove-leading-whitespace
3466 article-display-x-face
3467 article-de-quoted-unreadable
3468 article-de-base64-unreadable
3471 article-unsplit-urls
3472 article-hide-list-identifiers
3474 article-strip-banner
3477 article-hide-signature
3478 article-strip-headers-in-body
3479 article-remove-trailing-blank-lines
3480 article-strip-leading-blank-lines
3481 article-strip-multiple-blank-lines
3482 article-strip-leading-space
3483 article-strip-trailing-space
3484 article-strip-blank-lines
3485 article-strip-all-blank-lines
3487 article-date-english
3488 article-date-iso8601
3489 article-date-original
3491 article-decode-mime-words
3492 article-decode-charset
3493 article-decode-encoded-words
3497 article-treat-dumbquotes
3498 article-normalize-headers
3499 (article-show-all-headers . gnus-article-show-all-headers)
3500 ;; (article-show-all . gnus-article-show-all)
3504 ;;; Gnus article mode
3507 (put 'gnus-article-mode 'mode-class 'special)
3509 (gnus-define-keys gnus-article-mode-map
3510 " " gnus-article-goto-next-page
3511 "\177" gnus-article-goto-prev-page
3512 [delete] gnus-article-goto-prev-page
3513 [backspace] gnus-article-goto-prev-page
3514 "\C-c^" gnus-article-refer-article
3515 "h" gnus-article-show-summary
3516 "s" gnus-article-show-summary
3517 "\C-c\C-m" gnus-article-mail
3518 "?" gnus-article-describe-briefly
3519 "e" gnus-summary-edit-article
3520 "<" beginning-of-buffer
3522 "\C-c\C-i" gnus-info-find-node
3524 "R" gnus-article-reply-with-original
3525 "F" gnus-article-followup-with-original
3526 "\C-hk" gnus-article-describe-key
3527 "\C-hc" gnus-article-describe-key-briefly
3529 "\C-d" gnus-article-read-summary-keys
3530 "\M-*" gnus-article-read-summary-keys
3531 "\M-#" gnus-article-read-summary-keys
3532 "\M-^" gnus-article-read-summary-keys
3533 "\M-g" gnus-article-read-summary-keys)
3535 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3539 (push (char-to-string key) keys)
3541 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3542 (setq key (car elem))
3543 (when (and (> (length key) 0)
3544 (not (eq 'menu-bar (aref key 0)))
3545 (symbolp (lookup-key gnus-summary-mode-map key)))
3548 (unless (lookup-key gnus-article-mode-map key)
3549 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3551 (defun gnus-article-make-menu-bar ()
3552 (unless (boundp 'gnus-article-commands-menu)
3553 (gnus-summary-make-menu-bar))
3554 (gnus-turn-off-edit-menu 'article)
3555 (unless (boundp 'gnus-article-article-menu)
3557 gnus-article-article-menu gnus-article-mode-map ""
3559 ["Scroll forwards" gnus-article-goto-next-page t]
3560 ["Scroll backwards" gnus-article-goto-prev-page t]
3561 ["Show summary" gnus-article-show-summary t]
3562 ["Fetch Message-ID at point" gnus-article-refer-article t]
3563 ["Mail to address at point" gnus-article-mail t]
3564 ["Send a bug report" gnus-bug t]))
3567 gnus-article-treatment-menu gnus-article-mode-map ""
3568 ;; Fixme: this should use :active (and maybe :visible).
3570 ["Hide headers" gnus-article-toggle-headers t]
3571 ["Hide signature" gnus-article-hide-signature t]
3572 ["Hide citation" gnus-article-hide-citation t]
3573 ["Treat overstrike" gnus-article-treat-overstrike t]
3574 ["Remove carriage return" gnus-article-remove-cr t]
3575 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3576 ["Treat html" gnus-article-wash-html t]
3577 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3578 ["Decode HZ" gnus-article-decode-HZ t]))
3580 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3582 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3584 (gnus-run-hooks 'gnus-article-menu-hook)))
3586 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3589 (defun gnus-article-mode ()
3590 "Major mode for displaying an article.
3592 All normal editing commands are switched off.
3594 The following commands are available in addition to all summary mode
3596 \\<gnus-article-mode-map>
3597 \\[gnus-article-next-page]\t Scroll the article one page forwards
3598 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3599 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3600 \\[gnus-article-show-summary]\t Display the summary buffer
3601 \\[gnus-article-mail]\t Send a reply to the address near point
3602 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3603 \\[gnus-info-find-node]\t Go to the Gnus info node"
3605 (gnus-simplify-mode-line)
3606 (setq mode-name "Article")
3607 (setq major-mode 'gnus-article-mode)
3608 (make-local-variable 'minor-mode-alist)
3609 (unless (assq 'gnus-show-mime minor-mode-alist)
3610 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3611 (use-local-map gnus-article-mode-map)
3612 (when (gnus-visual-p 'article-menu 'menu)
3613 (gnus-article-make-menu-bar))
3614 (gnus-update-format-specifications nil 'article-mode)
3615 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3616 (make-local-variable 'gnus-page-broken)
3617 (make-local-variable 'gnus-button-marker-list)
3618 (make-local-variable 'gnus-article-current-summary)
3619 (make-local-variable 'gnus-article-mime-handles)
3620 (make-local-variable 'gnus-article-decoded-p)
3621 (make-local-variable 'gnus-article-mime-handle-alist)
3622 (make-local-variable 'gnus-article-wash-types)
3623 (make-local-variable 'gnus-article-image-alist)
3624 (make-local-variable 'gnus-article-charset)
3625 (make-local-variable 'gnus-article-ignored-charsets)
3626 (gnus-set-default-directory)
3627 (buffer-disable-undo)
3628 (setq buffer-read-only t)
3629 (set-syntax-table gnus-article-mode-syntax-table)
3630 (gnus-run-hooks 'gnus-article-mode-hook))
3632 (defun gnus-article-setup-buffer ()
3633 "Initialize the article buffer."
3634 (let* ((name (if gnus-single-article-buffer "*Article*"
3635 (concat "*Article " gnus-newsgroup-name "*")))
3637 (progn (string-match "\\*Article" name)
3638 (concat " *Original Article"
3639 (substring name (match-end 0))))))
3640 (setq gnus-article-buffer name)
3641 (setq gnus-original-article-buffer original)
3642 (setq gnus-article-mime-handle-alist nil)
3643 ;; This might be a variable local to the summary buffer.
3644 (unless gnus-single-article-buffer
3646 (set-buffer gnus-summary-buffer)
3647 (setq gnus-article-buffer name)
3648 (setq gnus-original-article-buffer original)
3649 (gnus-set-global-variables)))
3650 (gnus-article-setup-highlight-words)
3651 ;; Init original article buffer.
3653 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3654 (set-buffer-multibyte t)
3655 (setq major-mode 'gnus-original-article-mode)
3656 (make-local-variable 'gnus-original-article))
3657 (if (get-buffer name)
3660 (buffer-disable-undo)
3661 (setq buffer-read-only t)
3662 (unless (eq major-mode 'gnus-article-mode)
3663 (gnus-article-mode))
3666 (set-buffer (gnus-get-buffer-create name))
3668 (make-local-variable 'gnus-summary-buffer)
3669 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3670 (current-buffer)))))
3672 ;; Set article window start at LINE, where LINE is the number of lines
3673 ;; from the head of the article.
3674 (defun gnus-article-set-window-start (&optional line)
3676 (gnus-get-buffer-window gnus-article-buffer t)
3678 (set-buffer gnus-article-buffer)
3679 (goto-char (point-min))
3682 (gnus-message 6 "Moved to bookmark")
3683 (search-forward "\n\n" nil t)
3687 ;;; @@ article filters
3690 (defun gnus-article-display-mime-message ()
3691 "Article display method for MIME message."
3692 ;; called from `gnus-original-article-buffer'.
3693 (let (charset all-headers)
3694 (with-current-buffer gnus-summary-buffer
3695 (setq charset default-mime-charset
3696 all-headers gnus-have-all-headers))
3697 (make-local-variable 'default-mime-charset)
3698 (setq default-mime-charset charset)
3699 (with-current-buffer (get-buffer-create gnus-article-buffer)
3700 (make-local-variable 'default-mime-charset)
3701 (setq default-mime-charset charset))
3702 (mime-display-message mime-message-structure
3703 gnus-article-buffer nil gnus-article-mode-map)
3705 (gnus-article-hide-headers nil -1)))
3706 (run-hooks 'gnus-mime-article-prepare-hook))
3708 (defun gnus-article-display-traditional-message ()
3709 "Article display method for traditional message."
3710 (set-buffer gnus-article-buffer)
3711 (let (buffer-read-only)
3713 (insert-buffer-substring gnus-original-article-buffer)))
3715 (defun gnus-article-make-full-mail-header (&optional number charset)
3716 "Create a new mail header structure in a raw article buffer."
3717 (unless (and number charset)
3718 (save-current-buffer
3719 (set-buffer gnus-summary-buffer)
3721 (setq number (or (cdr gnus-article-current) 0)))
3723 (setq charset (or default-mime-charset 'x-ctext)))))
3724 (goto-char (point-min))
3725 (let ((header-end (if (search-forward "\n\n" nil t)
3727 (goto-char (point-max))))
3728 (chars (- (point-max) (point)))
3729 (lines (count-lines (point) (point-max)))
3730 (default-mime-charset charset)
3732 (narrow-to-region (point-min) header-end)
3733 (setq xref (std11-fetch-field "xref"))
3735 (make-full-mail-header
3737 (std11-fetch-field "subject")
3738 (std11-fetch-field "from")
3739 (std11-fetch-field "date")
3740 (std11-fetch-field "message-id")
3741 (std11-fetch-field "references")
3744 (when xref (concat "Xref: " xref)))
3747 (defun gnus-article-prepare (article &optional all-headers header)
3748 "Prepare ARTICLE in article mode buffer.
3749 ARTICLE should either be an article number or a Message-ID.
3750 If ARTICLE is an id, HEADER should be the article headers.
3751 If ALL-HEADERS is non-nil, no headers are hidden."
3753 ;; Make sure we start in a summary buffer.
3754 (unless (eq major-mode 'gnus-summary-mode)
3755 (set-buffer gnus-summary-buffer))
3756 (setq gnus-summary-buffer (current-buffer))
3757 (let* ((gnus-article (if header (mail-header-number header) article))
3758 (summary-buffer (current-buffer))
3759 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3760 (group gnus-newsgroup-name)
3763 (gnus-article-setup-buffer)
3764 (set-buffer gnus-article-buffer)
3765 ;; Deactivate active regions.
3766 (when (and (boundp 'transient-mark-mode)
3767 transient-mark-mode)
3768 (setq mark-active nil))
3769 (if (not (setq result (let ((buffer-read-only nil))
3770 (gnus-request-article-this-buffer
3772 ;; There is no such article.
3774 (when (and (numberp article)
3775 (not (memq article gnus-newsgroup-sparse)))
3776 (setq gnus-article-current
3777 (cons gnus-newsgroup-name article))
3778 (set-buffer gnus-summary-buffer)
3779 (setq gnus-current-article article)
3780 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3782 (gnus-summary-set-agent-mark article)
3783 (message "Message marked for downloading"))
3784 (gnus-summary-mark-article article gnus-canceled-mark)
3785 (unless (memq article gnus-newsgroup-sparse)
3786 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3787 (if (or (eq result 'pseudo)
3788 (eq result 'nneething))
3791 (set-buffer summary-buffer)
3792 (push article gnus-newsgroup-history)
3793 (setq gnus-last-article gnus-current-article
3794 gnus-current-article 0
3795 gnus-current-headers nil
3796 gnus-article-current nil)
3797 (if (eq result 'nneething)
3798 (gnus-configure-windows 'summary)
3799 (gnus-configure-windows 'article))
3800 (gnus-set-global-variables))
3801 (let ((gnus-article-mime-handle-alist-1
3802 gnus-article-mime-handle-alist))
3803 (gnus-set-mode-line 'article)))
3804 ;; The result from the `request' was an actual article -
3805 ;; or at least some text that is now displayed in the
3807 (when (and (numberp article)
3808 (not (eq article gnus-current-article)))
3809 ;; Seems like a new article has been selected.
3810 ;; `gnus-current-article' must be an article number.
3812 (set-buffer summary-buffer)
3813 (push article gnus-newsgroup-history)
3814 (setq gnus-last-article gnus-current-article
3815 gnus-current-article article
3816 gnus-current-headers
3817 (gnus-summary-article-header gnus-current-article)
3818 gnus-article-current
3819 (cons gnus-newsgroup-name gnus-current-article))
3820 (unless (vectorp gnus-current-headers)
3821 (setq gnus-current-headers nil))
3822 (gnus-summary-goto-subject gnus-current-article)
3823 (when (gnus-summary-show-thread)
3824 ;; If the summary buffer really was folded, the
3825 ;; previous goto may not actually have gone to
3826 ;; the right article, but the thread root instead.
3828 (gnus-summary-goto-subject gnus-current-article))
3829 (gnus-run-hooks 'gnus-mark-article-hook)
3830 (gnus-set-mode-line 'summary)
3831 (when (gnus-visual-p 'article-highlight 'highlight)
3832 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3833 ;; Set the global newsgroup variables here.
3834 (gnus-set-global-variables)
3835 (setq gnus-have-all-headers
3836 (or all-headers gnus-show-all-headers))))
3838 (gnus-configure-windows 'article))
3839 (when (or (numberp article)
3841 (gnus-article-prepare-display)
3843 (goto-char (point-min))
3844 (setq gnus-page-broken
3845 (when gnus-break-pages
3846 (gnus-narrow-to-page)
3848 (let ((gnus-article-mime-handle-alist-1
3849 gnus-article-mime-handle-alist))
3850 (gnus-set-mode-line 'article))
3852 (set-window-point (get-buffer-window (current-buffer)) (point))
3853 (gnus-configure-windows 'article)
3856 (defun gnus-article-prepare-mime-display (&optional number)
3857 (goto-char (point-min))
3858 (when (re-search-forward "^[^\t ]+:" nil t)
3859 (goto-char (match-beginning 0)))
3860 (let ((entity (if (eq 1 (point-min))
3861 (get-text-property 1 'mime-view-entity)
3862 (get-text-property (point) 'mime-view-entity)))
3863 last-entity child-entity next type)
3864 (setq child-entity (mime-entity-children entity))
3866 (setq last-entity (nth (1- (length child-entity))
3868 (setq last-entity entity))
3870 (narrow-to-region (point)
3871 (if (search-forward "\n\n" nil t)
3874 (gnus-treat-article 'head)
3875 (put-text-property (point-min) (point-max) 'article-treated-header t)
3876 (goto-char (point-max)))
3877 (while (and (not (eobp)) entity)
3878 (setq next (set-marker
3880 (next-single-property-change (point) 'mime-view-entity
3882 (let ((types (mime-entity-content-type entity)))
3883 (while (eq 'multipart (mime-content-type-primary-type types))
3884 (setq entity (car (mime-entity-children entity))
3885 types (mime-entity-content-type entity)))
3887 (setq type (format "%s/%s"
3888 (mime-content-type-primary-type types)
3889 (mime-content-type-subtype types)))))
3890 (if (string-equal type "message/rfc822")
3893 (let ((children (mime-entity-children entity))
3896 (setq last-children (nth (1- (length children)) children))
3899 (not (eq last-children
3900 (get-text-property next 'mime-view-entity)))
3902 (next-single-property-change next
3904 nil (point-max)))))))
3905 (setq next (next-single-property-change next 'mime-view-entity
3908 (narrow-to-region (point) next)
3909 (gnus-article-prepare-mime-display)
3910 (goto-char (point-max)))
3911 (setq entity (get-text-property (point) 'mime-view-entity)))
3913 (narrow-to-region (point) next)
3914 ;; Kludge. We have to count true number, but for now,
3915 ;; part number is here only to achieve `last'.
3916 (gnus-treat-article nil 1
3917 (if (eq entity last-entity)
3920 (goto-char (point-max)))
3921 (setq entity (get-text-property next 'mime-view-entity))))))
3924 (defun gnus-article-prepare-display ()
3925 "Make the current buffer look like a nice article."
3926 (let ((gnus-article-buffer (current-buffer))
3928 (unless (eq major-mode 'gnus-article-mode)
3929 (gnus-article-mode))
3930 (setq buffer-read-only nil
3931 gnus-button-marker-list nil
3932 gnus-article-wash-types nil
3933 gnus-article-image-alist nil)
3936 (static-if (featurep 'xemacs)
3937 (map-extents (lambda (extent maparg) (delete-extent extent)))
3938 (let ((lists (overlay-lists)))
3939 (dolist (overlay (nconc (car lists) (cdr lists)))
3940 (delete-overlay overlay)))))
3941 (gnus-run-hooks 'gnus-tmp-internal-hook))
3942 (set-buffer gnus-original-article-buffer)
3944 (setq mime-message-structure gnus-current-headers)
3945 (mime-buffer-entity-set-buffer-internal mime-message-structure
3946 gnus-original-article-buffer)
3947 (mime-entity-set-representation-type-internal mime-message-structure
3948 'mime-buffer-entity)
3949 (luna-send mime-message-structure 'initialize-instance
3950 mime-message-structure)
3952 (let (mime-display-header-hook mime-display-text/plain-hook)
3953 (funcall gnus-article-display-method-for-mime))
3954 (funcall gnus-article-display-method-for-traditional))
3955 ;; Call the treatment functions.
3956 (let ((inhibit-read-only t))
3960 (gnus-article-prepare-mime-display)
3961 (narrow-to-region (goto-char (point-min))
3962 (if (search-forward "\n\n" nil t)
3965 (gnus-treat-article 'head)
3966 (put-text-property (point-min) (point-max) 'article-treated-header t)
3967 (goto-char (point-max))
3969 (narrow-to-region (point) (point-max))
3970 (gnus-treat-article nil))
3971 (put-text-property (point-min) (point-max) 'read-only nil)))
3972 (gnus-run-hooks 'gnus-article-prepare-hook))
3974 (defun gnus-article-decode-article-as-default-mime-charset ()
3975 "Decode an article as `default-mime-charset'. It won't work if the
3976 value of the variable `gnus-show-mime' is non-nil."
3977 (unless gnus-show-mime
3978 (set (make-local-variable 'default-mime-charset)
3979 (with-current-buffer gnus-summary-buffer
3980 default-mime-charset))
3981 (decode-mime-charset-region (point-min) (point-max)
3982 default-mime-charset)))
3985 ;;; Gnus MIME viewing functions
3988 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3989 "Format of the MIME buttons.
3991 Valid specifiers include:
3993 %T MIME type, along with additional info
3994 %n The `name' parameter
3995 %d The description, if any
3996 %l The length of the encoded part
3997 %p The part identifier number
3998 %e Dots if the part isn't displayed
4000 General format specifiers can also be used. See
4001 (gnus)Formatting Variables.")
4003 (defvar gnus-mime-button-line-format-alist
4004 '((?t gnus-tmp-type ?s)
4005 (?T gnus-tmp-type-long ?s)
4006 (?n gnus-tmp-name ?s)
4007 (?d gnus-tmp-description ?s)
4009 (?l gnus-tmp-length ?d)
4010 (?e gnus-tmp-dots ?s)))
4012 (defvar gnus-mime-button-commands
4013 '((gnus-article-press-button "\r" "Toggle Display")
4014 (gnus-mime-view-part "v" "View Interactively...")
4015 (gnus-mime-view-part-as-type "t" "View As Type...")
4016 (gnus-mime-view-part-as-charset "C" "View As charset...")
4017 (gnus-mime-save-part "o" "Save...")
4018 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4019 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4020 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4021 (gnus-mime-internalize-part "E" "View Internally")
4022 (gnus-mime-externalize-part "e" "View Externally")
4023 (gnus-mime-print-part "p" "Print")
4024 (gnus-mime-pipe-part "|" "Pipe To Command...")
4025 (gnus-mime-action-on-part "." "Take action on the part")))
4027 (defun gnus-article-mime-part-status ()
4028 (with-current-buffer gnus-article-buffer
4029 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4032 (setq children (mime-entity-children entity))
4033 (setq children (length children)))
4036 (format " (%d parts)" children))
4039 (defvar gnus-mime-button-map
4040 (let ((map (make-sparse-keymap)))
4041 (unless (>= (string-to-number emacs-version) 21)
4042 ;; XEmacs doesn't care.
4043 (set-keymap-parent map gnus-article-mode-map))
4044 (define-key map gnus-mouse-2 'gnus-article-push-button)
4045 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4046 (dolist (c gnus-mime-button-commands)
4047 (define-key map (cadr c) (car c)))
4050 (defun gnus-mime-button-menu (event)
4051 "Construct a context-sensitive menu of MIME commands."
4053 (save-window-excursion
4054 (let ((pos (event-start event)))
4055 (select-window (posn-window pos))
4056 (goto-char (posn-point pos))
4057 (gnus-article-check-buffer)
4058 (let ((response (x-popup-menu
4060 ("" ,@(mapcar (lambda (c)
4061 (cons (caddr c) (car c)))
4062 gnus-mime-button-commands))))))
4064 (call-interactively response))))))
4066 (defun gnus-mime-view-all-parts (&optional handles)
4067 "View all the MIME parts."
4069 (save-current-buffer
4070 (set-buffer gnus-article-buffer)
4071 (let ((handles (or handles gnus-article-mime-handles))
4072 (mail-parse-charset gnus-newsgroup-charset)
4073 (mail-parse-ignored-charsets
4074 (with-current-buffer gnus-summary-buffer
4075 gnus-newsgroup-ignored-charsets)))
4077 (mm-remove-parts handles)
4078 (goto-char (point-min))
4079 (or (search-forward "\n\n") (goto-char (point-max)))
4080 (let (buffer-read-only)
4081 (delete-region (point) (point-max))
4082 (mm-display-parts handles))))))
4084 (defun gnus-mime-save-part-and-strip ()
4085 "Save the MIME part under point then replace it with an external body."
4087 (gnus-article-check-buffer)
4088 (let* ((data (get-text-property (point) 'gnus-data))
4090 (handles gnus-article-mime-handles))
4091 (if (mm-multiple-handles gnus-article-mime-handles)
4092 (error "This function is not implemented"))
4093 (setq file (and data (mm-save-part data)))
4095 (with-current-buffer (mm-handle-buffer data)
4097 (insert "Content-Type: " (mm-handle-media-type data))
4098 (mml-insert-parameter-string (cdr (mm-handle-type data))
4101 (insert "Content-ID: " (message-make-message-id) "\n")
4102 (insert "Content-Transfer-Encoding: binary\n")
4105 (cdr (mm-make-handle nil
4106 `("message/external-body"
4107 (access-type . "LOCAL-FILE")
4109 (set-buffer gnus-summary-buffer)
4110 (gnus-article-edit-article
4113 (let ((mail-parse-charset (or gnus-article-charset
4114 ',gnus-newsgroup-charset))
4115 (mail-parse-ignored-charsets
4116 (or gnus-article-ignored-charsets
4117 ',gnus-newsgroup-ignored-charsets))
4118 (mbl mml-buffer-list))
4119 (setq mml-buffer-list nil)
4120 (insert-buffer gnus-original-article-buffer)
4121 (mime-to-mml ',handles)
4122 (setq gnus-article-mime-handles nil)
4123 (let ((mbl1 mml-buffer-list))
4124 (setq mml-buffer-list mbl)
4125 (set (make-local-variable 'mml-buffer-list) mbl1))
4126 ;; LOCAL argument of add-hook differs between GNU Emacs
4127 ;; and XEmacs. make-local-hook makes sure they are local.
4128 (make-local-hook 'kill-buffer-hook)
4129 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4130 `(lambda (no-highlight)
4131 (let ((mail-parse-charset (or gnus-article-charset
4132 ',gnus-newsgroup-charset))
4133 (message-options message-options)
4134 (message-options-set-recipient)
4135 (mail-parse-ignored-charsets
4136 (or gnus-article-ignored-charsets
4137 ',gnus-newsgroup-ignored-charsets)))
4139 (mml-destroy-buffers)
4140 (remove-hook 'kill-buffer-hook
4141 'mml-destroy-buffers t)
4142 (kill-local-variable 'mml-buffer-list))
4143 (gnus-summary-edit-article-done
4144 ,(or (mail-header-references gnus-current-headers) "")
4145 ,(gnus-group-read-only-p)
4146 ,gnus-summary-buffer no-highlight))))))
4148 (defun gnus-mime-save-part ()
4149 "Save the MIME part under point."
4151 (gnus-article-check-buffer)
4152 (let ((data (get-text-property (point) 'gnus-data)))
4154 (mm-save-part data))))
4156 (defun gnus-mime-pipe-part ()
4157 "Pipe the MIME part under point to a process."
4159 (gnus-article-check-buffer)
4160 (let ((data (get-text-property (point) 'gnus-data)))
4162 (mm-pipe-part data))))
4164 (defun gnus-mime-view-part ()
4165 "Interactively choose a viewing method for the MIME part under point."
4167 (gnus-article-check-buffer)
4168 (let ((data (get-text-property (point) 'gnus-data)))
4170 (setq gnus-article-mime-handles
4172 gnus-article-mime-handles (setq data (copy-sequence data))))
4173 (mm-interactively-view-part data))))
4175 (defun gnus-mime-view-part-as-type-internal ()
4176 (gnus-article-check-buffer)
4177 (let* ((name (mail-content-type-get
4178 (mm-handle-type (get-text-property (point) 'gnus-data))
4180 (def-type (and name (mm-default-file-encoding name))))
4181 (and def-type (cons def-type 0))))
4183 (defun gnus-mime-view-part-as-type (&optional mime-type)
4184 "Choose a MIME media type, and view the part as such."
4187 (setq mime-type (completing-read
4188 "View as MIME type: "
4189 (mapcar #'list (mailcap-mime-types))
4191 (gnus-mime-view-part-as-type-internal))))
4192 (gnus-article-check-buffer)
4193 (let ((handle (get-text-property (point) 'gnus-data)))
4196 (mm-make-handle (mm-handle-buffer handle)
4197 (cons mime-type (cdr (mm-handle-type handle)))
4198 (mm-handle-encoding handle)
4199 (mm-handle-undisplayer handle)
4200 (mm-handle-disposition handle)
4201 (mm-handle-description handle)
4203 (mm-handle-id handle)))
4204 (setq gnus-article-mime-handles
4205 (mm-merge-handles gnus-article-mime-handles handle))
4206 (gnus-mm-display-part handle))))
4208 (defun gnus-mime-copy-part (&optional handle)
4209 "Put the MIME part under point into a new buffer."
4211 (gnus-article-check-buffer)
4212 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4213 (contents (and handle (mm-get-part handle)))
4215 (file-name-nondirectory
4217 (mail-content-type-get (mm-handle-type handle) 'name)
4218 (mail-content-type-get (mm-handle-type handle)
4221 (buffer (and base (generate-new-buffer base))))
4223 (switch-to-buffer buffer)
4225 ;; We do it this way to make `normal-mode' set the appropriate mode.
4228 (setq buffer-file-name (expand-file-name base))
4230 (setq buffer-file-name nil))
4231 (goto-char (point-min)))))
4233 (defun gnus-mime-print-part (&optional handle filename)
4234 "Print the MIME part under point."
4235 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4236 (gnus-article-check-buffer)
4237 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4238 (contents (and handle (mm-get-part handle)))
4239 (file (make-temp-name (expand-file-name "mm." mm-tmp-directory)))
4240 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
4245 (with-temp-file file
4247 (call-process shell-file-name nil
4248 (generate-new-buffer " *mm*")
4250 shell-command-switch
4252 printer file (mm-handle-type handle))))
4256 (gnus-print-buffer))
4257 (ps-despool filename)))))
4259 (defun gnus-mime-inline-part (&optional handle arg)
4260 "Insert the MIME part under point into the current buffer."
4261 (interactive (list nil current-prefix-arg))
4262 (gnus-article-check-buffer)
4263 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4268 (if (and (not arg) (mm-handle-undisplayer handle))
4269 (mm-remove-part handle)
4270 (setq contents (mm-get-part handle))
4273 (setq charset (or (mail-content-type-get
4274 (mm-handle-type handle) 'charset)
4275 gnus-newsgroup-charset)))
4277 (if (mm-handle-undisplayer handle)
4278 (mm-remove-part handle))
4281 gnus-summary-show-article-charset-alist))
4282 (mm-read-coding-system "Charset: ")))))
4284 (mm-insert-inline handle
4286 (setq charset (mm-charset-to-coding-system
4288 (not (eq charset 'ascii)))
4289 (mm-decode-coding-string contents charset)
4293 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4294 "Insert the MIME part under point into the current buffer using the
4296 (interactive (list nil current-prefix-arg))
4297 (gnus-article-check-buffer)
4298 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4303 (if (mm-handle-undisplayer handle)
4304 (mm-remove-part handle))
4305 (let ((gnus-newsgroup-charset
4307 gnus-summary-show-article-charset-alist))
4308 (mm-read-coding-system "Charset: ")))
4309 (gnus-newsgroup-ignored-charsets 'gnus-all))
4310 (gnus-article-press-button)))))
4312 (defun gnus-mime-externalize-part (&optional handle)
4313 "View the MIME part under point with an external viewer."
4315 (gnus-article-check-buffer)
4316 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4317 (mm-user-display-methods nil)
4318 (mm-inlined-types nil)
4319 (mail-parse-charset gnus-newsgroup-charset)
4320 (mail-parse-ignored-charsets
4321 (save-excursion (set-buffer gnus-summary-buffer)
4322 gnus-newsgroup-ignored-charsets)))
4324 (if (mm-handle-undisplayer handle)
4325 (mm-remove-part handle)
4326 (mm-display-part handle)))))
4328 (defun gnus-mime-internalize-part (&optional handle)
4329 "View the MIME part under point with an internal viewer.
4330 If no internal viewer is available, use an external viewer."
4332 (gnus-article-check-buffer)
4333 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4334 (mm-inlined-types '(".*"))
4335 (mm-inline-large-images t)
4336 (mail-parse-charset gnus-newsgroup-charset)
4337 (mail-parse-ignored-charsets
4338 (save-excursion (set-buffer gnus-summary-buffer)
4339 gnus-newsgroup-ignored-charsets)))
4341 (if (mm-handle-undisplayer handle)
4342 (mm-remove-part handle)
4343 (mm-display-part handle)))))
4345 (defun gnus-mime-action-on-part (&optional action)
4346 "Do something with the MIME attachment at \(point\)."
4348 (list (completing-read "Action: " gnus-mime-action-alist)))
4349 (gnus-article-check-buffer)
4350 (let ((action-pair (assoc action gnus-mime-action-alist)))
4352 (funcall (cdr action-pair)))))
4354 (defun gnus-article-part-wrapper (n function)
4355 (save-current-buffer
4356 (set-buffer gnus-article-buffer)
4357 (when (> n (length gnus-article-mime-handle-alist))
4358 (error "No such part"))
4359 (gnus-article-goto-part n)
4360 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4361 (funcall function handle))))
4363 (defun gnus-article-pipe-part (n)
4364 "Pipe MIME part N, which is the numerical prefix."
4366 (gnus-article-part-wrapper n 'mm-pipe-part))
4368 (defun gnus-article-save-part (n)
4369 "Save MIME part N, which is the numerical prefix."
4371 (gnus-article-part-wrapper n 'mm-save-part))
4373 (defun gnus-article-interactively-view-part (n)
4374 "View MIME part N interactively, which is the numerical prefix."
4376 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4378 (defun gnus-article-copy-part (n)
4379 "Copy MIME part N, which is the numerical prefix."
4381 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4383 (defun gnus-article-view-part-as-charset (n)
4384 "Copy MIME part N, which is the numerical prefix."
4386 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4388 (defun gnus-article-externalize-part (n)
4389 "View MIME part N externally, which is the numerical prefix."
4391 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
4393 (defun gnus-article-inline-part (n)
4394 "Inline MIME part N, which is the numerical prefix."
4396 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4398 (defun gnus-article-mime-match-handle-first (condition)
4400 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4401 (while (setq ihandle (pop alist))
4403 ((functionp condition)
4404 (funcall condition (cdr ihandle)))
4405 ((eq condition 'undisplayed)
4406 (not (or (mm-handle-undisplayer (cdr ihandle))
4407 (equal (mm-handle-media-type (cdr ihandle))
4408 "multipart/alternative"))))
4409 ((eq condition 'undisplayed-alternative)
4410 (not (mm-handle-undisplayer (cdr ihandle))))
4412 (gnus-article-goto-part (car ihandle))
4413 (or (not n) (< (car ihandle) n)))
4414 (setq n (car ihandle))))
4418 (defun gnus-article-view-part (&optional n)
4419 "View MIME part N, which is the numerical prefix."
4421 (save-current-buffer
4422 (set-buffer gnus-article-buffer)
4423 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4424 gnus-article-mime-match-handle-function)))
4425 (when (> n (length gnus-article-mime-handle-alist))
4426 (error "No such part"))
4427 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4428 (when (gnus-article-goto-part n)
4429 (if (equal (car handle) "multipart/alternative")
4430 (gnus-article-press-button)
4431 (when (eq (gnus-mm-display-part handle) 'internal)
4432 (gnus-set-window-start)))))))
4434 (defsubst gnus-article-mime-total-parts ()
4435 (if (bufferp (car gnus-article-mime-handles))
4437 (1- (length gnus-article-mime-handles))))
4439 (defun gnus-mm-display-part (handle)
4440 "Display HANDLE and fix MIME button."
4441 (let ((id (get-text-property (point) 'gnus-part))
4446 (let ((window (selected-window))
4447 (mail-parse-charset gnus-newsgroup-charset)
4448 (mail-parse-ignored-charsets
4449 (if (gnus-buffer-live-p gnus-summary-buffer)
4451 (set-buffer gnus-summary-buffer)
4452 gnus-newsgroup-ignored-charsets)
4456 (let ((win (gnus-get-buffer-window (current-buffer) t))
4459 (select-window win))
4462 (if (mm-handle-displayed-p handle)
4463 ;; This will remove the part.
4464 (mm-display-part handle)
4466 (narrow-to-region (point)
4467 (if (eobp) (point) (1+ (point))))
4468 (mm-display-part handle)
4469 ;; We narrow to the part itself and
4470 ;; then call the treatment functions.
4471 (goto-char (point-min))
4473 (narrow-to-region (point) (point-max))
4476 (gnus-article-mime-total-parts)
4477 (mm-handle-media-type handle)))))
4478 (if (window-live-p window)
4479 (select-window window)))))
4481 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4482 (gnus-insert-mime-button
4483 handle id (list (mm-handle-displayed-p handle)))
4484 (goto-char point))))
4486 (defun gnus-article-goto-part (n)
4487 "Go to MIME part N."
4488 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4490 (goto-char point))))
4492 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4493 (let ((gnus-tmp-name
4494 (or (mail-content-type-get (mm-handle-type handle) 'name)
4495 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4496 (mail-content-type-get (mm-handle-type handle) 'url)
4498 (gnus-tmp-type (mm-handle-media-type handle))
4499 (gnus-tmp-description
4500 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4503 (if (if displayed (car displayed)
4504 (mm-handle-displayed-p handle))
4506 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4508 gnus-tmp-type-long b e)
4509 (when (string-match ".*/" gnus-tmp-name)
4510 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4511 (setq gnus-tmp-type-long (concat gnus-tmp-type
4512 (and (not (equal gnus-tmp-name ""))
4513 (concat "; " gnus-tmp-name))))
4514 (unless (equal gnus-tmp-description "")
4515 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4520 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4521 `(,@(gnus-local-map-property gnus-mime-button-map)
4522 gnus-callback gnus-mm-display-part
4523 gnus-part ,gnus-tmp-id
4524 article-type annotation
4527 (widget-convert-button
4530 :action 'gnus-widget-press-button
4531 :button-keymap gnus-mime-button-map
4533 (lambda (widget/window &optional overlay pos)
4534 ;; Needed to properly clear the message due to a bug in
4535 ;; wid-edit (XEmacs only).
4536 (if (boundp 'help-echo-owns-message)
4537 (setq help-echo-owns-message t))
4539 "%S: %s the MIME part; %S: more options"
4540 (aref gnus-mouse-2 0)
4541 ;; XEmacs will get a single widget arg; Emacs 21 will get
4542 ;; window, overlay, position.
4543 (if (mm-handle-displayed-p
4545 (with-current-buffer (gnus-overlay-buffer overlay)
4546 (widget-get (widget-at (gnus-overlay-start overlay))
4548 (widget-get widget/window :mime-handle)))
4550 (aref gnus-down-mouse-3 0))))))
4552 (defun gnus-widget-press-button (elems el)
4553 (goto-char (widget-get elems :from))
4554 (gnus-article-press-button))
4556 (defvar gnus-displaying-mime nil)
4558 (defun gnus-display-mime (&optional ihandles)
4559 "Display the MIME parts."
4561 (save-selected-window
4562 (let ((window (get-buffer-window gnus-article-buffer))
4565 (select-window window)
4566 ;; We have to do this since selecting the window
4567 ;; may change the point. So we set the window point.
4568 (set-window-point window point)))
4569 (let* ((handles (or ihandles (mm-dissect-buffer
4570 gnus-article-no-strict-mime)
4572 buffer-read-only handle name type b e display)
4573 (when (and (not ihandles)
4574 (not gnus-displaying-mime))
4575 ;; Top-level call; we clean up.
4576 (when gnus-article-mime-handles
4577 (mm-destroy-parts gnus-article-mime-handles)
4578 (setq gnus-article-mime-handle-alist nil));; A trick.
4579 (setq gnus-article-mime-handles handles)
4580 ;; We allow users to glean info from the handles.
4581 (when gnus-article-mime-part-function
4582 (gnus-mime-part-function handles)))
4584 (or (not (stringp (car handles)))
4587 (when (and (not ihandles)
4588 (not gnus-displaying-mime))
4589 ;; Clean up for mime parts.
4591 (delete-region (point) (point-max)))
4592 (let ((gnus-displaying-mime t))
4593 (gnus-mime-display-part handles)))
4596 (narrow-to-region (point) (point-max))
4597 (gnus-treat-article nil 1 1)
4600 ;; Highlight the headers.
4604 (narrow-to-region (point-min) (point))
4605 (gnus-treat-article 'head))))))))
4607 (defvar gnus-mime-display-multipart-as-mixed nil)
4608 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4609 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4611 (defun gnus-mime-display-part (handle)
4614 ((not (stringp (car handle)))
4615 (gnus-mime-display-single handle))
4616 ;; User-defined multipart
4617 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4618 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4620 ;; multipart/alternative
4621 ((and (equal (car handle) "multipart/alternative")
4622 (not (or gnus-mime-display-multipart-as-mixed
4623 gnus-mime-display-multipart-alternative-as-mixed)))
4624 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4625 (push (cons id handle) gnus-article-mime-handle-alist)
4626 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4627 ;; multipart/related
4628 ((and (equal (car handle) "multipart/related")
4629 (not (or gnus-mime-display-multipart-as-mixed
4630 gnus-mime-display-multipart-related-as-mixed)))
4631 ;;;!!!We should find the start part, but we just default
4632 ;;;!!!to the first part.
4633 ;;(gnus-mime-display-part (cadr handle))
4634 ;;;!!! Most multipart/related is an HTML message plus images.
4635 ;;;!!! Unfortunately we are unable to let W3 display those
4636 ;;;!!! included images, so we just display it as a mixed multipart.
4637 ;;(gnus-mime-display-mixed (cdr handle))
4638 ;;;!!! No, w3 can display everything just fine.
4639 (gnus-mime-display-part (cadr handle)))
4640 ((equal (car handle) "multipart/signed")
4641 (gnus-add-wash-type 'signed)
4642 (gnus-mime-display-security handle))
4643 ((equal (car handle) "multipart/encrypted")
4644 (gnus-add-wash-type 'encrypted)
4645 (gnus-mime-display-security handle))
4646 ;; Other multiparts are handled like multipart/mixed.
4648 (gnus-mime-display-mixed (cdr handle)))))
4650 (defun gnus-mime-part-function (handles)
4651 (if (stringp (car handles))
4652 (mapcar 'gnus-mime-part-function (cdr handles))
4653 (funcall gnus-article-mime-part-function handles)))
4655 (defun gnus-mime-display-mixed (handles)
4656 (mapcar 'gnus-mime-display-part handles))
4658 (defun gnus-mime-display-single (handle)
4659 (let ((type (mm-handle-media-type handle))
4660 (ignored gnus-ignored-mime-types)
4667 (when (string-match (pop ignored) type)
4668 (throw 'ignored nil)))
4669 (if (and (setq not-attachment
4670 (and (not (mm-inline-override-p handle))
4671 (or (not (mm-handle-disposition handle))
4672 (equal (car (mm-handle-disposition handle))
4674 (mm-attachment-override-p handle))))
4675 (mm-automatic-display-p handle)
4677 (mm-inlinable-p handle)
4678 (mm-inlined-p handle))
4679 (mm-automatic-external-display-p type)))
4681 (when (equal (mm-handle-media-supertype handle) "text")
4683 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4685 (push (cons id handle) gnus-article-mime-handle-alist)
4686 (when (or (not display)
4687 (not (gnus-unbuttonized-mime-type-p type)))
4688 ;(gnus-article-insert-newline)
4689 (gnus-insert-mime-button
4690 handle id (list (or display (and not-attachment text))))
4691 (gnus-article-insert-newline)
4692 ;(gnus-article-insert-newline)
4693 ;; Remember modify the number of forward lines.
4701 (let ((mail-parse-charset gnus-newsgroup-charset)
4702 (mail-parse-ignored-charsets
4703 (save-excursion (condition-case ()
4704 (set-buffer gnus-summary-buffer)
4706 gnus-newsgroup-ignored-charsets)))
4707 (mm-display-part handle t))
4708 (goto-char (point-max)))
4709 ((and text not-attachment)
4713 (gnus-article-insert-newline)
4714 (mm-insert-inline handle (mm-get-part handle))
4715 (goto-char (point-max))))
4719 (narrow-to-region beg (point))
4722 (gnus-article-mime-total-parts)
4723 (mm-handle-media-type handle)))))))))
4725 (defun gnus-unbuttonized-mime-type-p (type)
4726 "Say whether TYPE is to be unbuttonized."
4727 (unless gnus-inhibit-mime-unbuttonizing
4729 (let ((types gnus-unbuttonized-mime-types))
4731 (when (string-match (pop types) type)
4732 (throw 'found t)))))
4734 (let ((types gnus-buttonized-mime-types))
4736 (when (string-match (pop types) type)
4737 (throw 'found t)))))))))
4739 (defun gnus-article-insert-newline ()
4740 "Insert a newline, but mark it as undeletable."
4741 (gnus-put-text-property
4742 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4744 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4745 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4748 handle buffer-read-only from props begend not-pref)
4749 (save-window-excursion
4752 (narrow-to-region (car ibegend)
4755 (goto-char (car ibegend))
4758 (delete-region (point-min) (point-max))
4759 (mm-remove-parts handles))
4760 (setq begend (list (point-marker)))
4762 (unless (setq not-pref (cadr (member preferred ihandles)))
4763 (setq not-pref (car ihandles)))
4766 (not (gnus-unbuttonized-mime-type-p
4767 "multipart/alternative")))
4768 (gnus-add-text-properties
4771 (insert (format "%d. " id))
4775 (unless ,(not ibegend)
4776 (setq gnus-article-mime-handle-alist
4777 ',gnus-article-mime-handle-alist))
4778 (gnus-mime-display-alternative
4779 ',ihandles ',not-pref ',begend ,id))
4780 ,@(gnus-local-map-property gnus-mime-button-map)
4781 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4782 face ,gnus-article-button-face
4785 (widget-convert-button 'link from (point)
4786 :action 'gnus-widget-press-button
4787 :button-keymap gnus-widget-button-keymap)
4789 (while (setq handle (pop handles))
4790 (gnus-add-text-properties
4793 (insert (format "(%c) %-18s"
4794 (if (equal handle preferred) ?* ? )
4795 (mm-handle-media-type handle)))
4799 (unless ,(not ibegend)
4800 (setq gnus-article-mime-handle-alist
4801 ',gnus-article-mime-handle-alist))
4802 (gnus-mime-display-alternative
4803 ',ihandles ',handle ',begend ,id))
4804 ,@(gnus-local-map-property gnus-mime-button-map)
4805 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4806 face ,gnus-article-button-face
4809 (widget-convert-button 'link from (point)
4810 :action 'gnus-widget-press-button
4811 :button-keymap gnus-widget-button-keymap)
4815 (if (stringp (car preferred))
4816 (gnus-display-mime preferred)
4817 (let ((mail-parse-charset gnus-newsgroup-charset)
4818 (mail-parse-ignored-charsets
4819 (save-excursion (set-buffer gnus-summary-buffer)
4820 gnus-newsgroup-ignored-charsets)))
4821 (mm-display-part preferred)
4825 (narrow-to-region (car begend) (point-max))
4827 nil (length gnus-article-mime-handle-alist)
4828 (gnus-article-mime-total-parts)
4829 (mm-handle-media-type handle))))))
4830 (goto-char (point-max))
4831 (setcdr begend (point-marker)))))
4833 (goto-char point))))
4835 (defconst gnus-article-wash-status-strings
4836 (let ((alist '((cite "c" "Possible hidden citation text"
4837 " " "All citation text visible")
4838 (headers "h" "Hidden headers"
4839 " " "All headers visible.")
4840 (pgp "p" "Encrypted or signed message status hidden"
4841 " " "No hidden encryption nor digital signature status")
4842 (signature "s" "Signature has been hidden"
4843 " " "Signature is visible")
4844 (overstrike "o" "Overstrike (^H) characters applied"
4845 " " "No overstrike characters applied")
4846 (gnus-show-mime "m" "Mime processing is activated"
4847 " " "Mime processing is not activated")
4848 (emphasis "e" "/*_Emphasis_*/ characters applied"
4849 " " "No /*_emphasis_*/ characters applied")))
4851 (dolist (entry alist result)
4852 (let ((key (nth 0 entry))
4853 (on (copy-sequence (nth 1 entry)))
4854 (on-help (nth 2 entry))
4855 (off (copy-sequence (nth 3 entry)))
4856 (off-help (nth 4 entry)))
4857 (put-text-property 0 1 'help-echo on-help on)
4858 (put-text-property 0 1 'help-echo off-help off)
4859 (push (list key on off) result))))
4860 "Alist of strings describing wash status in the mode line.
4861 Each entry has the form (KEY ON OF), where the KEY is a symbol
4862 representing the particular washing function, ON is the string to use
4863 in the article mode line when the washing function is active, and OFF
4864 is the string to use when it is inactive.")
4866 (defun gnus-article-wash-status-entry (key value)
4867 (let ((entry (assoc key gnus-article-wash-status-strings)))
4868 (if value (nth 1 entry) (nth 2 entry))))
4870 (defun gnus-article-wash-status ()
4871 "Return a string which display status of article washing."
4873 (set-buffer gnus-article-buffer)
4874 (let ((cite (memq 'cite gnus-article-wash-types))
4875 (headers (memq 'headers gnus-article-wash-types))
4876 (boring (memq 'boring-headers gnus-article-wash-types))
4877 (pgp (memq 'pgp gnus-article-wash-types))
4878 (pem (memq 'pem gnus-article-wash-types))
4879 (signed (memq 'signed gnus-article-wash-types))
4880 (encrypted (memq 'encrypted gnus-article-wash-types))
4881 (signature (memq 'signature gnus-article-wash-types))
4882 (overstrike (memq 'overstrike gnus-article-wash-types))
4883 (emphasis (memq 'emphasis gnus-article-wash-types)))
4885 (gnus-article-wash-status-entry 'cite cite)
4886 (gnus-article-wash-status-entry 'headers (or headers boring))
4887 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4888 (gnus-article-wash-status-entry 'signature signature)
4889 (gnus-article-wash-status-entry 'overstrike overstrike)
4890 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
4891 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4893 (defun gnus-add-wash-type (type)
4894 "Add a washing of TYPE to the current status."
4895 (add-to-list 'gnus-article-wash-types type))
4897 (defun gnus-delete-wash-type (type)
4898 "Add a washing of TYPE to the current status."
4899 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4901 (defun gnus-add-image (category image)
4902 "Add IMAGE of CATEGORY to the list of displayed images."
4903 (let ((entry (assq category gnus-article-image-alist)))
4905 (setq entry (list category))
4906 (push entry gnus-article-image-alist))
4907 (nconc entry (list image))))
4909 (defun gnus-delete-images (category)
4910 "Delete all images in CATEGORY."
4911 (let ((entry (assq category gnus-article-image-alist)))
4912 (dolist (image (cdr entry))
4913 (gnus-remove-image image))
4914 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4915 (gnus-delete-wash-type category)))
4917 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4919 (defun gnus-article-maybe-hide-headers ()
4920 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4921 Provided for backwards compatibility."
4922 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4923 (not (save-excursion (set-buffer gnus-summary-buffer)
4924 gnus-have-all-headers)))
4925 (not gnus-inhibit-hiding))
4926 (gnus-article-hide-headers)))
4930 (defun gnus-output-to-file (file-name)
4931 "Append the current article to a file named FILE-NAME."
4932 (let ((artbuf (current-buffer)))
4934 (insert-buffer-substring artbuf)
4935 ;; Append newline at end of the buffer as separator, and then
4937 (goto-char (point-max))
4939 (let ((file-name-coding-system nnmail-pathname-coding-system)
4940 (pathname-coding-system nnmail-pathname-coding-system))
4941 (write-region-as-binary (point-min) (point-max) file-name 'append))
4944 (defun gnus-narrow-to-page (&optional arg)
4945 "Narrow the article buffer to a page.
4946 If given a numerical ARG, move forward ARG pages."
4948 (setq arg (if arg (prefix-numeric-value arg) 0))
4950 (set-buffer gnus-article-buffer)
4951 (goto-char (point-min))
4953 ;; Remove any old next/prev buttons.
4954 (when (gnus-visual-p 'page-marker)
4955 (let ((buffer-read-only nil))
4956 (gnus-remove-text-with-property 'gnus-prev)
4957 (gnus-remove-text-with-property 'gnus-next)))
4960 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4962 (re-search-forward page-delimiter nil 'move arg)))
4963 (goto-char (match-end 0)))
4966 (if (re-search-forward page-delimiter nil 'move)
4969 (when (and (gnus-visual-p 'page-marker)
4970 (not (= (point-min) 1)))
4972 (goto-char (point-min))
4973 (gnus-insert-prev-page-button)))
4974 (when (and (gnus-visual-p 'page-marker)
4975 (< (+ (point-max) 2) (buffer-size)))
4977 (goto-char (point-max))
4978 (gnus-insert-next-page-button)))))
4980 ;; Article mode commands
4982 (defun gnus-article-goto-next-page ()
4983 "Show the next page of the article."
4985 (when (gnus-article-next-page)
4986 (goto-char (point-min))
4987 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4989 (defun gnus-article-goto-prev-page ()
4990 "Show the next page of the article."
4992 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4993 (gnus-article-prev-page nil)))
4995 (defun gnus-article-next-page (&optional lines)
4996 "Show the next page of the current article.
4997 If end of article, return non-nil. Otherwise return nil.
4998 Argument LINES specifies lines to be scrolled up."
5000 (let ((start (window-start))
5001 end-of-buffer end-of-page)
5003 (move-to-window-line -1)
5004 (if (<= (point) start)
5007 (setq start (point)))
5010 (unless (or (cond ((eq (1+ (buffer-size)) (point))
5011 (and (pos-visible-in-window-p)
5012 (setq end-of-buffer t)))
5014 (setq end-of-page t)))
5016 (move-to-window-line lines)
5017 (unless (search-backward "\n\n" nil t)
5018 (setq start (point)))))
5019 (cond (end-of-buffer t)
5021 (gnus-narrow-to-page 1)
5025 (set-window-start (selected-window) start)
5026 (let (window-pixel-scroll-increment)
5030 (defun gnus-article-prev-page (&optional lines)
5031 "Show previous page of current article.
5032 Argument LINES specifies lines to be scrolled down."
5034 (let (beginning-of-buffer beginning-of-page)
5036 (move-to-window-line 0)
5037 (cond ((eq 1 (point))
5038 (setq beginning-of-buffer t))
5040 (setq beginning-of-page t))))
5041 (cond (beginning-of-buffer)
5043 (gnus-narrow-to-page -1))
5046 (let (window-pixel-scroll-increment)
5047 (scroll-down lines))
5048 (beginning-of-buffer
5049 (goto-char (point-min))))))))
5051 (defun gnus-article-refer-article ()
5052 "Read article specified by message-id around point."
5054 (let ((point (point)))
5055 (search-forward ">" nil t) ;Move point to end of "<....>".
5056 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
5057 (let ((message-id (match-string 1)))
5059 (set-buffer gnus-summary-buffer)
5060 (gnus-summary-refer-article message-id))
5062 (error "No references around point"))))
5064 (defun gnus-article-show-summary ()
5065 "Reconfigure windows to show summary buffer."
5067 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5068 (error "There is no summary buffer for this article buffer")
5069 (gnus-article-set-globals)
5070 (gnus-configure-windows 'article)
5071 (gnus-summary-goto-subject gnus-current-article)
5072 (gnus-summary-position-point)))
5074 (defun gnus-article-describe-briefly ()
5075 "Describe article mode commands briefly."
5077 (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")))
5079 (defun gnus-article-summary-command ()
5080 "Execute the last keystroke in the summary buffer."
5082 (let ((obuf (current-buffer))
5083 (owin (current-window-configuration))
5085 (switch-to-buffer gnus-article-current-summary 'norecord)
5086 (setq func (lookup-key (current-local-map) (this-command-keys)))
5087 (call-interactively func)
5089 (set-window-configuration owin)
5090 (set-window-point (get-buffer-window (current-buffer)) (point))))
5092 (defun gnus-article-summary-command-nosave ()
5093 "Execute the last keystroke in the summary buffer."
5096 (pop-to-buffer gnus-article-current-summary 'norecord)
5097 (setq func (lookup-key (current-local-map) (this-command-keys)))
5098 (call-interactively func)))
5100 (defun gnus-article-check-buffer ()
5101 "Beep if not in an article buffer."
5102 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5103 (error "Command invoked outside of a Gnus article buffer")))
5105 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5106 "Read a summary buffer key sequence and execute it from the article buffer."
5108 (gnus-article-check-buffer)
5110 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5111 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5112 "=" "^" "\M-^" "|"))
5118 '("n" "Gn" "p" "Gp"))
5121 (set-buffer gnus-article-current-summary)
5122 (let (gnus-pick-mode)
5123 (push (or key last-command-event) unread-command-events)
5124 (setq keys (static-if (featurep 'xemacs)
5125 (events-to-keys (read-key-sequence nil))
5126 (read-key-sequence nil)))))
5129 (if (or (member keys nosaves)
5130 (member keys nosave-but-article)
5131 (member keys nosave-in-article))
5133 (save-window-excursion
5134 (pop-to-buffer gnus-article-current-summary 'norecord)
5135 ;; We disable the pick minor mode commands.
5136 (let (gnus-pick-mode)
5137 (setq func (lookup-key (current-local-map) keys))))
5141 (unless (member keys nosave-in-article)
5142 (set-buffer gnus-article-current-summary))
5143 (call-interactively func)
5144 (setq new-sum-point (point)))
5145 (when (member keys nosave-but-article)
5146 (pop-to-buffer gnus-article-buffer 'norecord)))
5147 ;; These commands should restore window configuration.
5148 (let ((obuf (current-buffer))
5149 (owin (current-window-configuration))
5151 (summary gnus-article-current-summary)
5152 func in-buffer selected)
5153 (if not-restore-window
5154 (pop-to-buffer summary 'norecord)
5155 (switch-to-buffer summary 'norecord))
5156 (setq in-buffer (current-buffer))
5157 ;; We disable the pick minor mode commands.
5158 (if (and (setq func (let (gnus-pick-mode)
5159 (lookup-key (current-local-map) keys)))
5162 (call-interactively func)
5163 (setq new-sum-point (point))
5164 (when (eq in-buffer (current-buffer))
5165 (setq selected (gnus-summary-select-article))
5167 (unless not-restore-window
5168 (set-window-configuration owin))
5169 (when (eq selected 'old)
5171 (set-window-start (get-buffer-window (current-buffer))
5173 (set-window-point (get-buffer-window (current-buffer))
5175 (let ((win (get-buffer-window gnus-article-current-summary)))
5177 (set-window-point win new-sum-point)))) )
5178 (switch-to-buffer gnus-article-buffer)
5181 (defun gnus-article-describe-key (key)
5182 "Display documentation of the function invoked by KEY. KEY is a string."
5183 (interactive "kDescribe key: ")
5184 (gnus-article-check-buffer)
5185 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5187 (set-buffer gnus-article-current-summary)
5188 (let (gnus-pick-mode)
5189 (if (featurep 'xemacs)
5191 (push (elt key 0) unread-command-events)
5192 (setq key (events-to-keys
5193 (read-key-sequence "Describe key: "))))
5194 (setq unread-command-events
5196 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5198 (setq key (read-key-sequence "Describe key: "))))
5200 (describe-key key)))
5202 (defun gnus-article-describe-key-briefly (key &optional insert)
5203 "Display documentation of the function invoked by KEY. KEY is a string."
5204 (interactive "kDescribe key: \nP")
5205 (gnus-article-check-buffer)
5206 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5208 (set-buffer gnus-article-current-summary)
5209 (let (gnus-pick-mode)
5210 (if (featurep 'xemacs)
5212 (push (elt key 0) unread-command-events)
5213 (setq key (events-to-keys
5214 (read-key-sequence "Describe key: "))))
5215 (setq unread-command-events
5217 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5219 (setq key (read-key-sequence "Describe key: "))))
5220 (describe-key-briefly key insert))
5221 (describe-key-briefly key insert)))
5223 (defun gnus-article-reply-with-original (&optional wide)
5224 "Start composing a reply mail to the current message.
5225 The text in the region will be yanked. If the region isn't active,
5226 the entire article will be yanked."
5228 (let ((article (cdr gnus-article-current)) cont)
5230 (gnus-summary-reply (list (list article)) wide)
5231 (setq cont (buffer-substring (point) (mark t)))
5232 ;; Deactivate active regions.
5233 (when (and (boundp 'transient-mark-mode)
5234 transient-mark-mode)
5235 (setq mark-active nil))
5237 (list (list article cont)) wide))))
5239 (defun gnus-article-followup-with-original ()
5240 "Compose a followup to the current article.
5241 The text in the region will be yanked. If the region isn't active,
5242 the entire article will be yanked."
5244 (let ((article (cdr gnus-article-current))
5247 (gnus-summary-followup (list (list article)))
5248 (setq cont (buffer-substring (point) (mark t)))
5249 ;; Deactivate active regions.
5250 (when (and (boundp 'transient-mark-mode)
5251 transient-mark-mode)
5252 (setq mark-active nil))
5253 (gnus-summary-followup
5254 (list (list article cont))))))
5256 (defun gnus-article-hide (&optional arg force)
5257 "Hide all the gruft in the current article.
5258 This means that PGP stuff, signatures, cited text and (some)
5259 headers will be hidden.
5260 If given a prefix, show the hidden text instead."
5261 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5262 (gnus-article-hide-headers arg)
5263 (gnus-article-hide-list-identifiers arg)
5264 (gnus-article-hide-pgp arg)
5265 (gnus-article-hide-citation-maybe arg force)
5266 (gnus-article-hide-signature arg))
5268 (defun gnus-article-maybe-highlight ()
5269 "Do some article highlighting if article highlighting is requested."
5270 (when (gnus-visual-p 'article-highlight 'highlight)
5271 (gnus-article-highlight-some)))
5273 (defun gnus-check-group-server ()
5274 ;; Make sure the connection to the server is alive.
5275 (unless (gnus-server-opened
5276 (gnus-find-method-for-group gnus-newsgroup-name))
5277 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5278 (gnus-request-group gnus-newsgroup-name t)))
5281 (autoload 'nneething-get-file-name "nneething"))
5283 (defun gnus-request-article-this-buffer (article group)
5284 "Get an article and insert it into this buffer.
5285 T-gnus change: Insert an article into `gnus-original-article-buffer'."
5286 (let (do-update-line sparse-header)
5287 ;; The current buffer is `gnus-article-buffer'.
5291 (gnus-kill-all-overlays)
5292 (setq group (or group gnus-newsgroup-name))
5294 ;; Using `gnus-request-article' directly will insert the article into
5295 ;; `nntp-server-buffer' - so we'll save some time by not having to
5296 ;; copy it from the server buffer into the article buffer.
5298 ;; We only request an article by message-id when we do not have the
5299 ;; headers for it, so we'll have to get those.
5300 (when (stringp article)
5301 (gnus-read-header article))
5303 ;; If the article number is negative, that means that this article
5304 ;; doesn't belong in this newsgroup (possibly), so we find its
5305 ;; message-id and request it by id instead of number.
5306 (when (and (numberp article)
5308 (get-buffer gnus-summary-buffer)
5309 (gnus-buffer-exists-p gnus-summary-buffer))
5311 (set-buffer gnus-summary-buffer)
5312 (let ((header (gnus-summary-article-header article)))
5315 ((memq article gnus-newsgroup-sparse)
5316 ;; This is a sparse gap article.
5317 (setq do-update-line article)
5318 (setq article (mail-header-id header))
5319 (setq sparse-header (gnus-read-header article))
5320 (setq gnus-newsgroup-sparse
5321 (delq article gnus-newsgroup-sparse)))
5323 ;; It's a real article.
5324 (setq article (mail-header-id header)))
5326 ;; It is an extracted pseudo-article.
5327 (setq article 'pseudo)
5328 (gnus-request-pseudo-article header))))
5330 (let ((method (gnus-find-method-for-group
5331 gnus-newsgroup-name)))
5332 (when (and (eq (car method) 'nneething)
5334 (let ((dir (nneething-get-file-name
5335 (mail-header-id header))))
5336 (when (and (stringp dir)
5337 (file-directory-p dir))
5338 (setq article 'nneething)
5339 (gnus-group-enter-directory dir))))))))
5340 (setq gnus-original-article (cons group article))
5342 ;; The current buffer is `gnus-original-article-buffer'.
5343 (if (get-buffer gnus-original-article-buffer)
5344 (set-buffer gnus-original-article-buffer)
5345 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5346 (set-buffer-multibyte nil)
5347 (buffer-disable-undo)
5348 (setq major-mode 'gnus-original-article-mode)
5349 (setq buffer-read-only nil))
5352 ;; Refuse to select canceled articles.
5353 ((and (numberp article)
5355 (get-buffer gnus-summary-buffer)
5356 (gnus-buffer-exists-p gnus-summary-buffer)
5357 (eq (cdr (save-excursion
5358 (set-buffer gnus-summary-buffer)
5359 (assq article gnus-newsgroup-reads)))
5360 gnus-canceled-mark))
5362 ;; Check the backlog.
5363 ((and gnus-keep-backlog
5364 (gnus-backlog-request-article group article (current-buffer)))
5366 ;; Check asynchronous pre-fetch.
5367 ((gnus-async-request-fetched-article group article (current-buffer))
5368 (gnus-async-prefetch-next group article gnus-summary-buffer)
5369 (when (and (numberp article) gnus-keep-backlog)
5370 (gnus-backlog-enter-article group article (current-buffer)))
5373 ((and gnus-use-cache
5375 (gnus-cache-request-article article group))
5377 ;; Check the agent cache.
5378 ((and gnus-agent gnus-agent-cache gnus-plugged
5380 (gnus-agent-request-article article group))
5382 ;; Get the article and put into the article buffer.
5383 ((or (stringp article)
5385 (let ((gnus-override-method gnus-override-method)
5386 (methods (and (stringp article)
5387 gnus-refer-article-method))
5389 (buffer-read-only nil))
5390 (if (or (not (listp methods))
5391 (and (symbolp (car methods))
5392 (assq (car methods) nnoo-definition-alist)))
5393 (setq methods (list methods)))
5394 (when (and (null gnus-override-method)
5396 (setq gnus-override-method (pop methods)))
5398 (when (eq gnus-override-method 'current)
5399 (setq gnus-override-method
5400 (with-current-buffer gnus-summary-buffer
5401 gnus-current-select-method)))
5403 (gnus-kill-all-overlays)
5404 (let ((gnus-newsgroup-name group))
5405 (gnus-check-group-server))
5406 (when (gnus-request-article article group (current-buffer))
5407 (when (numberp article)
5408 (gnus-async-prefetch-next group article
5409 gnus-summary-buffer)
5410 (when gnus-keep-backlog
5411 (gnus-backlog-enter-article
5412 group article (current-buffer))))
5413 (setq result 'article))
5416 (setq gnus-override-method (pop methods))
5417 (setq result 'done))))
5418 (and (eq result 'article) 'article)))
5422 ;; Associate this article with the current summary buffer.
5423 (setq gnus-article-current-summary gnus-summary-buffer)
5425 ;; Copy the requested article from `gnus-original-article-buffer'.
5426 (unless (equal (buffer-name (current-buffer))
5427 (buffer-name (get-buffer gnus-original-article-buffer)))
5428 (insert-buffer gnus-original-article-buffer))
5431 (run-hooks 'gnus-article-decode-hook)
5432 ;; Mark article as decoded or not.
5433 (setq gnus-article-decoded-p gnus-article-decode-hook)
5435 ;; Update sparse articles.
5436 (when (and do-update-line
5437 (or (numberp article)
5439 (let ((buf (current-buffer)))
5440 (set-buffer gnus-summary-buffer)
5441 (gnus-summary-update-article do-update-line sparse-header)
5442 (gnus-summary-goto-subject do-update-line nil t)
5443 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5445 (set-buffer buf))))))
5451 (defcustom gnus-article-edit-mode-hook nil
5452 "Hook run in article edit mode buffers."
5453 :group 'gnus-article-various
5456 (defcustom gnus-article-edit-article-setup-function
5457 'gnus-article-mime-edit-article-setup
5458 "Function called to setup an editing article buffer."
5459 :group 'gnus-article-various
5462 (defvar gnus-article-edit-done-function nil)
5464 (defvar gnus-article-edit-mode-map nil)
5466 ;; Should we be using derived.el for this?
5467 (unless gnus-article-edit-mode-map
5468 (setq gnus-article-edit-mode-map (make-keymap))
5469 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5471 (gnus-define-keys gnus-article-edit-mode-map
5472 "\C-c?" describe-mode
5473 "\C-c\C-c" gnus-article-edit-done
5474 "\C-c\C-k" gnus-article-edit-exit
5475 "\C-c\C-f\C-t" message-goto-to
5476 "\C-c\C-f\C-o" message-goto-from
5477 "\C-c\C-f\C-b" message-goto-bcc
5478 ;;"\C-c\C-f\C-w" message-goto-fcc
5479 "\C-c\C-f\C-c" message-goto-cc
5480 "\C-c\C-f\C-s" message-goto-subject
5481 "\C-c\C-f\C-r" message-goto-reply-to
5482 "\C-c\C-f\C-n" message-goto-newsgroups
5483 "\C-c\C-f\C-d" message-goto-distribution
5484 "\C-c\C-f\C-f" message-goto-followup-to
5485 "\C-c\C-f\C-m" message-goto-mail-followup-to
5486 "\C-c\C-f\C-k" message-goto-keywords
5487 "\C-c\C-f\C-u" message-goto-summary
5488 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5489 "\C-c\C-f\C-a" message-gen-unsubscribed-mft
5490 "\C-c\C-b" message-goto-body
5491 "\C-c\C-i" message-goto-signature
5493 "\C-c\C-t" message-insert-to
5494 "\C-c\C-n" message-insert-newsgroups
5495 "\C-c\C-o" message-sort-headers
5496 "\C-c\C-e" message-elide-region
5497 "\C-c\C-v" message-delete-not-region
5498 "\C-c\C-z" message-kill-to-signature
5499 "\M-\r" message-newline-and-reformat
5500 "\C-c\C-a" mml-attach-file
5501 "\C-a" message-beginning-of-line
5503 "\M-;" comment-region)
5505 (gnus-define-keys (gnus-article-edit-wash-map
5506 "\C-c\C-w" gnus-article-edit-mode-map)
5507 "f" gnus-article-edit-full-stops))
5510 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5512 ["Fetch To" message-insert-to t]
5513 ["Fetch Newsgroups" message-insert-newsgroups t]
5515 ["To" message-goto-to t]
5516 ["From" message-goto-from t]
5517 ["Subject" message-goto-subject t]
5518 ["Cc" message-goto-cc t]
5519 ["Reply-To" message-goto-reply-to t]
5520 ["Summary" message-goto-summary t]
5521 ["Keywords" message-goto-keywords t]
5522 ["Newsgroups" message-goto-newsgroups t]
5523 ["Followup-To" message-goto-followup-to t]
5524 ["Mail-Followup-To" message-goto-mail-followup-to t]
5525 ["Distribution" message-goto-distribution t]
5526 ["Body" message-goto-body t]
5527 ["Signature" message-goto-signature t]))
5529 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5530 "Major mode for editing articles.
5531 This is an extended text-mode.
5533 \\{gnus-article-edit-mode-map}"
5534 (make-local-variable 'gnus-article-edit-done-function)
5535 (make-local-variable 'gnus-prev-winconf)
5536 (set (make-local-variable 'font-lock-defaults)
5537 '(message-font-lock-keywords t))
5538 (set (make-local-variable 'mail-header-separator) "")
5539 (easy-menu-add message-mode-field-menu message-mode-map)
5541 (setq buffer-read-only nil)
5542 (buffer-enable-undo)
5545 (defun gnus-article-edit (&optional force)
5546 "Edit the current article.
5547 This will have permanent effect only in mail groups.
5548 If FORCE is non-nil, allow editing of articles even in read-only
5551 (when (and (not force)
5552 (gnus-group-read-only-p))
5553 (error "The current newsgroup does not support article editing"))
5554 (gnus-article-date-original)
5555 (gnus-article-edit-article
5557 `(lambda (no-highlight)
5559 (gnus-summary-edit-article-done
5560 ,(or (mail-header-references gnus-current-headers) "")
5561 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5563 (defun gnus-article-edit-article (start-func exit-func)
5564 "Start editing the contents of the current article buffer."
5565 (let ((winconf (current-window-configuration)))
5566 (set-buffer gnus-article-buffer)
5567 (gnus-article-edit-mode)
5568 (funcall start-func)
5569 (set-buffer-modified-p nil)
5570 (gnus-configure-windows 'edit-article)
5571 (setq gnus-article-edit-done-function exit-func)
5572 (setq gnus-prev-winconf winconf)
5573 (when gnus-article-edit-article-setup-function
5574 (funcall gnus-article-edit-article-setup-function))
5575 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5577 (defun gnus-article-edit-done (&optional arg)
5578 "Update the article edits and exit."
5580 (let ((func gnus-article-edit-done-function)
5581 (buf (current-buffer))
5582 (start (window-start))
5584 (winconf gnus-prev-winconf))
5585 (remove-hook 'gnus-article-mode-hook
5586 'gnus-article-mime-edit-article-unwind)
5589 ;; The cache and backlog have to be flushed somewhat.
5590 (when gnus-keep-backlog
5591 (gnus-backlog-remove-article
5592 (car gnus-article-current) (cdr gnus-article-current)))
5593 ;; Flush original article as well.
5595 (when (get-buffer gnus-original-article-buffer)
5596 (set-buffer gnus-original-article-buffer)
5597 (setq gnus-original-article nil)))
5598 (when gnus-use-cache
5599 (gnus-cache-update-article
5600 (car gnus-article-current) (cdr gnus-article-current)))
5601 ;; We remove all text props from the article buffer.
5602 (kill-all-local-variables)
5603 (gnus-set-text-properties (point-min) (point-max) nil)
5605 (set-window-configuration winconf)
5607 (set-window-start (get-buffer-window buf) start)
5608 (set-window-point (get-buffer-window buf) (point))))
5610 (defun gnus-article-edit-exit ()
5611 "Exit the article editing without updating."
5613 (when (or (not (buffer-modified-p))
5614 (yes-or-no-p "Article modified; kill anyway? "))
5615 (let ((curbuf (current-buffer))
5617 (window-start (window-start)))
5619 (if (gnus-buffer-live-p gnus-original-article-buffer)
5620 (insert-buffer gnus-original-article-buffer))
5621 (let ((winconf gnus-prev-winconf))
5623 (set-window-configuration winconf)
5624 ;; Tippy-toe some to make sure that point remains where it was.
5625 (save-current-buffer
5627 (set-window-start (get-buffer-window (current-buffer)) window-start)
5630 (defun gnus-article-edit-full-stops ()
5631 "Interactively repair spacing at end of sentences."
5634 (goto-char (point-min))
5635 (search-forward-regexp "^$" nil t)
5636 (let ((case-fold-search nil))
5637 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5640 ;;; Article editing with MIME-Edit
5643 (defcustom gnus-article-mime-edit-article-setup-hook nil
5644 "Hook run after setting up a MIME editing article buffer."
5645 :group 'gnus-article-various
5648 (defun gnus-article-mime-edit-article-unwind ()
5649 "Unwind `gnus-article-buffer' if article editing was given up."
5650 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5651 (when (featurep 'font-lock)
5652 (setq font-lock-defaults nil)
5653 (font-lock-mode -1))
5654 (when mime-edit-mode-flag
5655 (mime-edit-exit 'nomime 'no-error)
5658 (defun gnus-article-mime-edit-article-setup ()
5659 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
5660 after replacing with the original article."
5661 (setq gnus-show-mime t)
5662 (setq gnus-article-edit-done-function
5663 `(lambda (&rest args)
5664 (when mime-edit-mode-flag
5665 (let (mime-edit-insert-user-agent-field)
5668 (goto-char (point-min))
5669 (let (case-fold-search)
5670 (when (re-search-forward
5671 (format "^%s$" (regexp-quote mail-header-separator))
5673 (replace-match "")))
5674 (apply ,gnus-article-edit-done-function args)
5677 (buffer-substring-no-properties (point-min) (point-max))
5678 (set-buffer (get-buffer-create gnus-original-article-buffer))
5680 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5681 (set-buffer gnus-article-buffer)
5682 (gnus-article-prepare-display)))
5683 (substitute-key-definition 'gnus-article-edit-done
5684 'gnus-article-mime-edit-done
5685 gnus-article-edit-mode-map)
5686 (substitute-key-definition 'gnus-article-edit-exit
5687 'gnus-article-mime-edit-exit
5688 gnus-article-edit-mode-map)
5690 (insert-buffer gnus-original-article-buffer)
5691 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
5692 (fset 'mime-edit-decode-single-part-in-buffer
5693 (lambda (&rest args)
5694 (if (let ((content-type (car args)))
5695 (and (eq 'message (mime-content-type-primary-type
5697 (eq 'rfc822 (mime-content-type-subtype content-type))))
5698 (setcar (cdr args) 'not-decode-text))
5702 (fset 'mime-edit-decode-single-part-in-buffer ofn)))
5703 (when (featurep 'font-lock)
5704 (set (make-local-variable 'font-lock-defaults)
5705 '(message-font-lock-keywords t))
5706 (font-lock-set-defaults)
5707 (turn-on-font-lock))
5708 (set-buffer-modified-p nil)
5709 (delete-other-windows)
5710 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5711 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
5713 (defun gnus-article-mime-edit-done (&optional arg)
5714 "Update the article MIME edits and exit."
5716 (when (featurep 'font-lock)
5717 (setq font-lock-defaults nil)
5718 (font-lock-mode -1))
5719 (gnus-article-edit-done arg))
5721 (defun gnus-article-mime-edit-exit ()
5722 "Exit the article MIME editing without updating."
5724 (when (or (not (buffer-modified-p))
5725 (yes-or-no-p "Article modified; kill anyway? "))
5726 (when (featurep 'font-lock)
5727 (setq font-lock-defaults nil)
5728 (font-lock-mode -1))
5729 (when mime-edit-mode-flag
5730 (let (mime-edit-insert-user-agent-field)
5733 (goto-char (point-min))
5734 (let (case-fold-search)
5735 (when (re-search-forward
5736 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
5737 (replace-match "")))
5738 (let ((winconf gnus-prev-winconf))
5740 (buffer-substring-no-properties (point-min) (point-max))
5741 (set-buffer (get-buffer-create gnus-original-article-buffer))
5743 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5744 (set-buffer gnus-article-buffer)
5745 (gnus-article-prepare-display)
5746 (set-window-configuration winconf))))
5749 ;;; Article highlights
5752 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5754 ;;; Internal Variables:
5756 (defcustom gnus-button-url-regexp "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?\\([-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)\\)"
5757 "Regular expression that matches URLs."
5758 :group 'gnus-article-buttons
5761 (defcustom gnus-button-alist
5762 `(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5763 0 t gnus-button-handle-news 3)
5764 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5765 gnus-button-handle-news 2)
5766 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5768 gnus-button-fetch-group 4)
5769 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5770 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5771 t gnus-button-message-id 3)
5772 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5773 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5774 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5776 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
5777 gnus-button-handle-info 2)
5778 ;; This is how URLs _should_ be embedded in text...
5779 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5781 (,gnus-button-url-regexp 0 t browse-url 0))
5782 "*Alist of regexps matching buttons in article bodies.
5784 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5785 REGEXP: is the string matching text around the button,
5786 BUTTON: is the number of the regexp grouping actually matching the button,
5787 FORM: is a lisp expression which must eval to true for the button to
5789 CALLBACK: is the function to call when the user push this button, and each
5790 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5792 CALLBACK can also be a variable, in that case the value of that
5793 variable it the real callback function."
5794 :group 'gnus-article-buttons
5795 :type '(repeat (list regexp
5796 (integer :tag "Button")
5798 (function :tag "Callback")
5801 (integer :tag "Regexp group")))))
5803 (defcustom gnus-header-button-alist
5804 `(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5805 0 t gnus-button-message-id 0)
5806 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5807 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5808 0 t gnus-button-mailto 0)
5809 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
5810 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
5811 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
5812 ("^[^:]+:" "\\bmailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5813 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5814 gnus-button-message-id 3))
5815 "*Alist of headers and regexps to match buttons in article heads.
5817 This alist is very similar to `gnus-button-alist', except that each
5818 alist has an additional HEADER element first in each entry:
5820 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5822 HEADER is a regexp to match a header. For a fuller explanation, see
5823 `gnus-button-alist'."
5824 :group 'gnus-article-buttons
5825 :group 'gnus-article-headers
5826 :type '(repeat (list (regexp :tag "Header")
5828 (integer :tag "Button")
5830 (function :tag "Callback")
5833 (integer :tag "Regexp group")))))
5835 (defvar gnus-button-regexp nil)
5836 (defvar gnus-button-marker-list nil)
5837 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5839 (defvar gnus-button-last nil)
5840 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5844 (defun gnus-article-push-button (event)
5845 "Check text under the mouse pointer for a callback function.
5846 If the text under the mouse pointer has a `gnus-callback' property,
5847 call it with the value of the `gnus-data' text property."
5849 (set-buffer (window-buffer (posn-window (event-start event))))
5850 (let* ((pos (posn-point (event-start event)))
5851 (data (get-text-property pos 'gnus-data))
5852 (fun (get-text-property pos 'gnus-callback)))
5855 (funcall fun data))))
5857 (defun gnus-article-press-button ()
5858 "Check text at point for a callback function.
5859 If the text at point has a `gnus-callback' property,
5860 call it with the value of the `gnus-data' text property."
5862 (let* ((data (get-text-property (point) 'gnus-data))
5863 (fun (get-text-property (point) 'gnus-callback)))
5865 (funcall fun data))))
5867 (defun gnus-article-prev-button (n)
5868 "Move point to N buttons backward.
5869 If N is negative, move forward instead."
5871 (gnus-article-next-button (- n)))
5873 (defun gnus-article-next-button (n)
5874 "Move point to N buttons forward.
5875 If N is negative, move backward instead."
5877 (let ((function (if (< n 0) 'previous-single-property-change
5878 'next-single-property-change))
5879 (inhibit-point-motion-hooks t)
5881 (limit (if (< n 0) (point-min) (point-max))))
5883 (while (and (not (= limit (point)))
5885 ;; Skip past the current button.
5886 (when (get-text-property (point) 'gnus-callback)
5887 (goto-char (funcall function (point) 'gnus-callback nil limit)))
5888 ;; Go to the next (or previous) button.
5889 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
5890 ;; Put point at the start of the button.
5891 (when (and backward (not (get-text-property (point) 'gnus-callback)))
5892 (goto-char (funcall function (point) 'gnus-callback nil limit)))
5893 ;; Skip past intangible buttons.
5894 (when (get-text-property (point) 'intangible)
5898 (gnus-message 5 "No more buttons"))
5901 (defun gnus-article-highlight (&optional force)
5902 "Highlight current article.
5903 This function calls `gnus-article-highlight-headers',
5904 `gnus-article-highlight-citation',
5905 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5906 do the highlighting. See the documentation for those functions."
5907 (interactive (list 'force))
5908 (gnus-article-highlight-headers)
5909 (gnus-article-highlight-citation force)
5910 (gnus-article-highlight-signature)
5911 (gnus-article-add-buttons force)
5912 (gnus-article-add-buttons-to-head))
5914 (defun gnus-article-highlight-some (&optional force)
5915 "Highlight current article.
5916 This function calls `gnus-article-highlight-headers',
5917 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5918 do the highlighting. See the documentation for those functions."
5919 (interactive (list 'force))
5920 (gnus-article-highlight-headers)
5921 (gnus-article-highlight-signature)
5922 (gnus-article-add-buttons))
5924 (defun gnus-article-highlight-headers ()
5925 "Highlight article headers as specified by `gnus-header-face-alist'."
5928 (set-buffer gnus-article-buffer)
5930 (let ((alist gnus-header-face-alist)
5931 (buffer-read-only nil)
5932 (case-fold-search t)
5933 (inhibit-point-motion-hooks t)
5934 entry regexp header-face field-face from hpoints fpoints)
5935 (article-narrow-to-head)
5936 (while (setq entry (pop alist))
5937 (goto-char (point-min))
5938 (setq regexp (concat "^\\("
5939 (if (string-equal "" (nth 0 entry))
5943 header-face (nth 1 entry)
5944 field-face (nth 2 entry))
5945 (while (and (re-search-forward regexp nil t)
5949 (unless (search-forward ":" nil t)
5951 (when (and header-face
5952 (not (memq (point) hpoints)))
5953 (push (point) hpoints)
5954 (gnus-put-text-property from (point) 'face header-face))
5955 (when (and field-face
5956 (not (memq (setq from (point)) fpoints)))
5958 (if (re-search-forward "^[^ \t]" nil t)
5960 (goto-char (point-max)))
5961 (gnus-put-text-property from (point) 'face field-face))))))))
5963 (defun gnus-article-highlight-signature ()
5964 "Highlight the signature in an article.
5965 It does this by highlighting everything after
5966 `gnus-signature-separator' using `gnus-signature-face'."
5968 (when gnus-signature-face
5970 (set-buffer gnus-article-buffer)
5971 (let ((buffer-read-only nil)
5972 (inhibit-point-motion-hooks t))
5974 (when (gnus-article-narrow-to-signature)
5975 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5976 'face gnus-signature-face)))))))
5978 (defun gnus-article-buttonize-signature ()
5979 "Add button to the signature."
5982 (set-buffer gnus-article-buffer)
5983 (let ((buffer-read-only nil)
5984 (inhibit-point-motion-hooks t))
5985 (when (gnus-article-search-signature)
5986 (gnus-article-add-button (match-beginning 0) (match-end 0)
5987 'gnus-signature-toggle
5988 (set-marker (make-marker)
5989 (1+ (match-end 0))))))))
5991 (defun gnus-button-in-region-p (b e prop)
5992 "Say whether PROP exists in the region."
5993 (text-property-not-all b e prop nil))
5995 (defun gnus-article-add-buttons (&optional force)
5996 "Find external references in the article and make buttons of them.
5997 \"External references\" are things like Message-IDs and URLs, as
5998 specified by `gnus-button-alist'."
5999 (interactive (list 'force))
6001 (set-buffer gnus-article-buffer)
6002 (let ((buffer-read-only nil)
6003 (inhibit-point-motion-hooks t)
6004 (case-fold-search t)
6005 (alist gnus-button-alist)
6007 ;; Remove all old markers.
6008 (let (marker entry new-list)
6009 (while (setq marker (pop gnus-button-marker-list))
6010 (if (or (< marker (point-min)) (>= marker (point-max)))
6011 (push marker new-list)
6013 (when (setq entry (gnus-button-entry))
6014 (put-text-property (match-beginning (nth 1 entry))
6015 (match-end (nth 1 entry))
6016 'gnus-callback nil))
6017 (set-marker marker nil)))
6018 (setq gnus-button-marker-list new-list))
6019 ;; We skip the headers.
6022 (while (setq entry (pop alist))
6023 (setq regexp (car entry))
6025 (while (re-search-forward regexp nil t)
6026 (let* ((start (and entry (match-beginning (nth 1 entry))))
6027 (end (and entry (match-end (nth 1 entry))))
6028 (from (match-beginning 0)))
6029 (when (and (or (eq t (nth 2 entry))
6030 (eval (nth 2 entry)))
6031 (not (gnus-button-in-region-p
6032 start end 'gnus-callback)))
6033 ;; That optional form returned non-nil, so we add the
6035 (gnus-article-add-button
6036 start end 'gnus-button-push
6037 (car (push (set-marker (make-marker) from)
6038 gnus-button-marker-list))))))))))
6040 ;; Add buttons to the head of an article.
6041 (defun gnus-article-add-buttons-to-head ()
6042 "Add buttons to the head of the article."
6045 (set-buffer gnus-article-buffer)
6047 (let ((buffer-read-only nil)
6048 (inhibit-point-motion-hooks t)
6049 (case-fold-search t)
6050 (alist gnus-header-button-alist)
6052 (article-narrow-to-head)
6054 ;; Each alist entry.
6055 (setq entry (car alist)
6057 (goto-char (point-min))
6058 (while (re-search-forward (car entry) nil t)
6059 ;; Each header matching the entry.
6060 (setq beg (match-beginning 0))
6061 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6062 (match-beginning 0))
6065 (while (re-search-forward (nth 1 entry) end t)
6066 ;; Each match within a header.
6067 (let* ((entry (cdr entry))
6068 (start (match-beginning (nth 1 entry)))
6069 (end (match-end (nth 1 entry)))
6070 (form (nth 2 entry)))
6071 (goto-char (match-end 0))
6073 (gnus-article-add-button
6074 start end (nth 3 entry)
6075 (buffer-substring (match-beginning (nth 4 entry))
6076 (match-end (nth 4 entry)))))))
6077 (goto-char end)))))))
6079 ;;; External functions:
6081 (defun gnus-article-add-button (from to fun &optional data)
6082 "Create a button between FROM and TO with callback FUN and data DATA."
6083 (when gnus-article-button-face
6084 (gnus-overlay-put (gnus-make-overlay from to)
6085 'face gnus-article-button-face))
6086 (gnus-add-text-properties
6088 (nconc (and gnus-article-mouse-face
6089 (list gnus-mouse-face-prop gnus-article-mouse-face))
6090 (list 'gnus-callback fun)
6091 (and data (list 'gnus-data data))))
6092 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6093 ;; Quote `:button-keymap' for Mule 2.3
6094 ;; but it won't work.
6095 ':button-keymap gnus-widget-button-keymap))
6097 ;;; Internal functions:
6099 (defun gnus-article-set-globals ()
6101 (set-buffer gnus-summary-buffer)
6102 (gnus-set-global-variables)))
6104 (defun gnus-signature-toggle (end)
6106 (set-buffer gnus-article-buffer)
6107 (let ((buffer-read-only nil)
6108 (inhibit-point-motion-hooks t)
6109 (limit (next-single-property-change end 'mime-view-entity
6111 (if (text-property-any end limit 'article-type 'signature)
6113 (gnus-delete-wash-type 'signature)
6114 (gnus-remove-text-properties-when
6115 'article-type 'signature end limit
6116 (cons 'article-type (cons 'signature
6117 gnus-hidden-properties))))
6118 (gnus-add-wash-type 'signature)
6119 (gnus-add-text-properties-when
6120 'article-type nil end limit
6121 (cons 'article-type (cons 'signature
6122 gnus-hidden-properties)))))
6123 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6124 (gnus-set-mode-line 'article))))
6126 (defun gnus-button-entry ()
6127 ;; Return the first entry in `gnus-button-alist' matching this place.
6128 (let ((alist gnus-button-alist)
6131 (setq entry (pop alist))
6132 (if (looking-at (car entry))
6137 (defun gnus-button-push (marker)
6138 ;; Push button starting at MARKER.
6141 (let* ((entry (gnus-button-entry))
6142 (inhibit-point-motion-hooks t)
6144 (args (mapcar (lambda (group)
6145 (let ((string (match-string group)))
6146 (gnus-set-text-properties
6147 0 (length string) nil string)
6154 (fboundp (symbol-value fun)))
6155 (apply (symbol-value fun) args))
6157 (gnus-message 1 "You must define `%S' to use this button"
6158 (cons fun args)))))))
6160 (defun gnus-parse-news-url (url)
6161 (let (scheme server group message-id articles)
6164 (goto-char (point-min))
6165 (when (looking-at "\\([A-Za-z]+\\):")
6166 (setq scheme (match-string 1))
6167 (goto-char (match-end 0)))
6168 (when (looking-at "//\\([^/]+\\)/")
6169 (setq server (match-string 1))
6170 (goto-char (match-end 0)))
6173 ((looking-at "\\(.*@.*\\)")
6174 (setq message-id (match-string 1)))
6175 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6176 (setq group (match-string 1)
6177 articles (split-string (match-string 2) "-")))
6178 ((looking-at "\\([^/]+\\)/?")
6179 (setq group (match-string 1)))
6181 (error "Unknown news URL syntax"))))
6182 (list scheme server group message-id articles)))
6184 (defun gnus-button-handle-news (url)
6186 (destructuring-bind (scheme server group message-id articles)
6187 (gnus-parse-news-url url)
6191 (set-buffer gnus-summary-buffer)
6193 (let ((gnus-refer-article-method (list (list 'nntp server))))
6194 (gnus-summary-refer-article message-id))
6195 (gnus-summary-refer-article message-id))))
6197 (gnus-button-fetch-group url)))))
6199 (defun gnus-button-handle-info (url)
6200 "Fetch an info URL."
6202 "^\\([^:/]+\\)?/\\(.*\\)"
6204 (gnus-info-find-node
6205 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6208 (gnus-url-unhex-string (match-string 2 url))))
6209 (error "Can't parse %s" url)))
6211 (defun gnus-button-message-id (message-id)
6214 (set-buffer gnus-summary-buffer)
6215 (gnus-summary-refer-article message-id)))
6217 (defun gnus-button-fetch-group (address)
6218 "Fetch GROUP specified by ADDRESS."
6219 (if (not (string-match "[:/]" address))
6220 ;; This is just a simple group url.
6221 (gnus-group-read-ephemeral-group address gnus-select-method)
6224 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6226 (error "Can't parse %s" address)
6227 (gnus-group-read-ephemeral-group
6228 (match-string 4 address)
6229 `(nntp ,(match-string 1 address)
6230 (nntp-address ,(match-string 1 address))
6231 (nntp-port-number ,(if (match-end 3)
6232 (match-string 3 address)
6235 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6237 (defun gnus-url-parse-query-string (query &optional downcase)
6238 (let (retval pairs cur key val)
6239 (setq pairs (split-string query "&"))
6241 (setq cur (car pairs)
6243 (if (not (string-match "=" cur))
6245 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6246 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6248 (setq key (downcase key)))
6249 (setq cur (assoc key retval))
6251 (setcdr cur (cons val (cdr cur)))
6252 (setq retval (cons (list key val) retval)))))
6255 (defun gnus-url-mailto (url)
6256 ;; Send mail to someone
6257 (when (string-match "mailto:/*\\(.*\\)" url)
6258 (setq url (substring url (match-beginning 1) nil)))
6259 (let (to args subject func)
6260 (if (string-match (regexp-quote "?") url)
6261 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6262 args (gnus-url-parse-query-string
6263 (substring url (match-end 0) nil) t))
6264 (setq to (gnus-url-unhex-string url)))
6265 (setq args (cons (list "to" to) args)
6266 subject (cdr-safe (assoc "subject" args)))
6269 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6272 (message-position-on-field (caar args)))
6273 (insert (mapconcat 'identity (cdar args) ", "))
6274 (setq args (cdr args)))
6277 (message-goto-subject))))
6279 (defun gnus-button-embedded-url (address)
6280 "Activate ADDRESS with `browse-url'."
6281 (browse-url (gnus-strip-whitespace address)))
6283 ;;; Next/prev buttons in the article buffer.
6285 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6286 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6288 (defvar gnus-prev-page-map
6289 (let ((map (make-sparse-keymap)))
6290 (unless (>= emacs-major-version 21)
6291 ;; XEmacs doesn't care.
6292 (set-keymap-parent map gnus-article-mode-map))
6293 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6294 (define-key map "\r" 'gnus-button-prev-page)
6297 (defun gnus-insert-prev-page-button ()
6299 (buffer-read-only nil)
6300 (situation (get-text-property (point-min) 'mime-view-situation)))
6302 gnus-prev-page-line-format nil
6303 `(,@(gnus-local-map-property gnus-prev-page-map)
6305 gnus-callback gnus-article-button-prev-page
6306 article-type annotation
6307 mime-view-situation ,situation))
6308 (widget-convert-button
6310 :action 'gnus-button-prev-page
6311 :button-keymap gnus-prev-page-map)))
6313 (defvar gnus-next-page-map
6314 (let ((map (make-sparse-keymap)))
6315 (unless (>= emacs-major-version 21)
6316 ;; XEmacs doesn't care.
6317 (set-keymap-parent map gnus-article-mode-map))
6318 (define-key map gnus-mouse-2 'gnus-button-next-page)
6319 (define-key map "\r" 'gnus-button-next-page)
6322 (defun gnus-button-next-page (&optional args more-args)
6323 "Go to the next page."
6325 (let ((win (selected-window)))
6326 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6327 (gnus-article-next-page)
6328 (select-window win)))
6330 (defun gnus-button-prev-page (&optional args more-args)
6331 "Go to the prev page."
6333 (let ((win (selected-window)))
6334 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6335 (gnus-article-prev-page)
6336 (select-window win)))
6338 (defun gnus-insert-next-page-button ()
6340 (buffer-read-only nil)
6341 (situation (get-text-property (point-min) 'mime-view-situation)))
6342 (gnus-eval-format gnus-next-page-line-format nil
6343 `(,@(gnus-local-map-property gnus-next-page-map)
6345 gnus-callback gnus-article-button-next-page
6346 article-type annotation
6347 mime-view-situation ,situation))
6348 (widget-convert-button
6350 :action 'gnus-button-next-page
6351 :button-keymap gnus-next-page-map)))
6353 (defun gnus-article-button-next-page (arg)
6354 "Go to the next page."
6356 (let ((win (selected-window)))
6357 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6358 (gnus-article-next-page)
6359 (select-window win)))
6361 (defun gnus-article-button-prev-page (arg)
6362 "Go to the prev page."
6364 (let ((win (selected-window)))
6365 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6366 (gnus-article-prev-page)
6367 (select-window win)))
6369 (defvar gnus-decode-header-methods
6370 '(mail-decode-encoded-word-region)
6371 "List of methods used to decode headers.
6373 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6374 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6375 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6376 whose names match REGEXP.
6379 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6380 mail-decode-encoded-word-region
6381 (\"chinese\" . rfc1843-decode-region))
6384 (defvar gnus-decode-header-methods-cache nil)
6386 (defun gnus-multi-decode-header (start end)
6387 "Apply the functions from `gnus-encoded-word-methods' that match."
6388 (unless (and gnus-decode-header-methods-cache
6389 (eq gnus-newsgroup-name
6390 (car gnus-decode-header-methods-cache)))
6391 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6394 (nconc gnus-decode-header-methods-cache (list x))
6395 (if (and gnus-newsgroup-name
6396 (string-match (car x) gnus-newsgroup-name))
6397 (nconc gnus-decode-header-methods-cache
6399 gnus-decode-header-methods))
6400 (let ((xlist gnus-decode-header-methods-cache))
6403 (narrow-to-region start end)
6405 (funcall (pop xlist) (point-min) (point-max))))))
6408 ;;; Treatment top-level handling.
6411 (defun gnus-treat-article (condition &optional part-number total-parts type)
6412 (let ((length (- (point-max) (point-min)))
6413 (alist gnus-treatment-function-alist)
6414 (article-goto-body-goes-to-point-min-p t)
6418 (let ((list gnus-article-treat-types))
6420 (when (string-match (pop list) type)
6421 (throw 'found t)))))))
6422 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6423 (entity (static-unless (featurep 'xemacs)
6424 (when (eq 'head condition)
6425 (get-text-property (point-min) 'mime-view-entity))))
6426 val elem buttonized)
6427 (gnus-run-hooks 'gnus-part-display-hook)
6428 (unless gnus-inhibit-treatment
6429 (while (setq elem (pop alist))
6432 (if (gnus-buffer-live-p gnus-summary-buffer)
6433 (set-buffer gnus-summary-buffer))
6434 (symbol-value (car elem))))
6435 (when (and (or (consp val)
6437 (gnus-treat-predicate val)
6438 (or (not (get (car elem) 'highlight))
6440 (when (and (not buttonized)
6442 '(gnus-treat-hide-signature
6443 gnus-treat-highlight-signature)))
6444 (gnus-article-buttonize-signature)
6445 (setq buttonized t))
6447 (funcall (cadr elem)))))
6448 ;; FSF Emacsen does not inherit the existing text properties
6449 ;; in the new text, so we should do it for `mime-view-entity'.
6450 (static-unless (featurep 'xemacs)
6452 (put-text-property (point-min) (point-max)
6453 'mime-view-entity entity))))))
6455 ;; Dynamic variables.
6457 (defvar part-number)
6458 (defvar total-parts)
6463 (defun gnus-treat-predicate (val)
6468 (stringp (car val)))
6469 (apply 'gnus-or (mapcar `(lambda (s)
6470 (string-match s ,(or gnus-newsgroup-name "")))
6473 (let ((pred (pop val)))
6476 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6478 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6480 (not (gnus-treat-predicate (car val))))
6482 (equal (car val) type))
6484 (error "%S is not a valid predicate" pred)))))
6494 (eq part-number total-parts))
6498 (error "%S is not a valid value" val))))
6500 (defun gnus-article-encrypt-body (protocol &optional n)
6501 "Encrypt the article body."
6504 (or gnus-article-encrypt-protocol
6505 (completing-read "Encrypt protocol: "
6506 gnus-article-encrypt-protocol-alist
6508 current-prefix-arg))
6509 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6511 (error (format "Can't find the encrypt protocol %s" protocol)))
6512 (if (equal gnus-newsgroup-name "nndraft:drafts")
6513 (error "Can't encrypt the article in group nndraft:drafts"))
6514 (if (equal gnus-newsgroup-name "nndraft:queue")
6515 (error "Don't encrypt the article in group nndraft:queue"))
6516 (gnus-summary-iterate n
6518 (set-buffer gnus-summary-buffer)
6519 (let ((mail-parse-charset gnus-newsgroup-charset)
6520 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6521 (summary-buffer gnus-summary-buffer)
6523 (gnus-set-global-variables)
6524 (when (gnus-group-read-only-p)
6525 (error "The current newsgroup does not support article encrypt"))
6526 (gnus-summary-show-article t)
6528 (or (mail-header-references gnus-current-headers) ""))
6529 (set-buffer gnus-article-buffer)
6530 (let* ((buffer-read-only nil)
6532 (mapcar (lambda (field)
6533 (and (save-restriction
6534 (message-narrow-to-head)
6535 (goto-char (point-min))
6536 (search-forward field nil t))
6538 (message-narrow-to-field)
6539 (buffer-substring (point-min) (point-max))
6540 (delete-region (point-min) (point-max))
6542 '("Content-Type:" "Content-Transfer-Encoding:"
6543 "Content-Disposition:"))))
6544 (message-narrow-to-head)
6545 (message-remove-header "MIME-Version")
6546 (goto-char (point-max))
6547 (setq point (point))
6548 (insert (apply 'concat headers))
6550 (narrow-to-region point (point-max))
6551 (let ((message-options message-options))
6552 (message-options-set 'message-sender user-mail-address)
6553 (message-options-set 'message-recipients user-mail-address)
6554 (message-options-set 'message-sign-encrypt 'not)
6556 (goto-char (point-min))
6557 (insert "MIME-Version: 1.0\n")
6559 (gnus-summary-edit-article-done
6560 references nil summary-buffer t))
6561 (when gnus-keep-backlog
6562 (gnus-backlog-remove-article
6563 (car gnus-article-current) (cdr gnus-article-current)))
6565 (when (get-buffer gnus-original-article-buffer)
6566 (set-buffer gnus-original-article-buffer)
6567 (setq gnus-original-article nil)))
6568 (when gnus-use-cache
6569 (gnus-cache-update-article
6570 (car gnus-article-current) (cdr gnus-article-current))))))))
6572 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6573 "The following specs can be used:
6574 %t The security MIME type
6577 %D Details if button is pressed")
6579 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6580 "The following specs can be used:
6581 %t The security MIME type
6584 %D Details if button is pressed")
6586 (defvar gnus-mime-security-button-line-format-alist
6587 '((?t gnus-tmp-type ?s)
6588 (?i gnus-tmp-info ?s)
6589 (?d gnus-tmp-details ?s)
6590 (?D gnus-tmp-pressed-details ?s)))
6592 (defvar gnus-mime-security-button-map
6593 (let ((map (make-sparse-keymap)))
6594 (unless (>= (string-to-number emacs-version) 21)
6595 (set-keymap-parent map gnus-article-mode-map))
6596 (define-key map gnus-mouse-2 'gnus-article-push-button)
6597 (define-key map "\r" 'gnus-article-press-button)
6600 (defvar gnus-mime-security-details-buffer nil)
6602 (defvar gnus-mime-security-button-pressed nil)
6604 (defvar gnus-mime-security-show-details-inline t
6605 "If non-nil, show details in the article buffer.")
6607 (defun gnus-mime-security-verify-or-decrypt (handle)
6608 (mm-remove-parts (cdr handle))
6609 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6610 point buffer-read-only)
6612 (goto-char (car region)))
6614 (narrow-to-region (point) (point))
6615 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6616 (let* ((mm-verify-option 'known)
6617 (mm-decrypt-option 'known)
6618 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6619 (unless (eq nparts (cdr handle))
6620 (mm-destroy-parts (cdr handle))
6621 (setcdr handle nparts))))
6622 (setq point (point))
6623 (gnus-mime-display-security handle)
6624 (goto-char (point-max)))
6626 (delete-region (point) (cdr region))
6627 (set-marker (car region) nil)
6628 (set-marker (cdr region) nil))
6631 (defun gnus-mime-security-show-details (handle)
6632 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6634 (if gnus-mime-security-show-details-inline
6635 (let ((gnus-mime-security-button-pressed t)
6636 (gnus-mime-security-button-line-format
6637 (get-text-property (point) 'gnus-line-format))
6640 (while (eq (get-text-property (point) 'gnus-line-format)
6641 gnus-mime-security-button-line-format)
6645 (narrow-to-region (point) (point))
6646 (gnus-insert-mime-security-button handle))
6647 (delete-region (point)
6648 (or (text-property-not-all
6651 gnus-mime-security-button-line-format)
6653 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6654 (with-current-buffer gnus-mime-security-details-buffer
6657 (setq gnus-mime-security-details-buffer
6658 (gnus-get-buffer-create "*MIME Security Details*")))
6659 (with-current-buffer gnus-mime-security-details-buffer
6661 (goto-char (point-min)))
6662 (pop-to-buffer gnus-mime-security-details-buffer))
6663 (gnus-message 5 "No details."))))
6665 (defun gnus-mime-security-press-button (handle)
6666 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6667 (gnus-mime-security-show-details handle)
6668 (gnus-mime-security-verify-or-decrypt handle)))
6670 (defun gnus-insert-mime-security-button (handle &optional displayed)
6671 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6674 (or (nth 2 (assoc protocol mm-verify-function-alist))
6675 (nth 2 (assoc protocol mm-decrypt-function-alist))
6677 (if (equal (car handle) "multipart/signed")
6678 " Signed" " Encrypted")
6681 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6684 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6685 gnus-tmp-pressed-details
6687 (setq gnus-tmp-details
6688 (if gnus-tmp-details
6689 (concat "\n" gnus-tmp-details) ""))
6690 (setq gnus-tmp-pressed-details
6691 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6696 gnus-mime-security-button-line-format
6697 gnus-mime-security-button-line-format-alist
6698 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6699 gnus-callback gnus-mime-security-press-button
6700 gnus-line-format ,gnus-mime-security-button-line-format
6701 article-type annotation
6704 (widget-convert-button
6707 :action 'gnus-widget-press-button
6708 :button-keymap gnus-mime-security-button-map
6710 (lambda (widget/window &optional overlay pos)
6711 ;; Needed to properly clear the message due to a bug in
6712 ;; wid-edit (XEmacs only).
6713 (if (boundp 'help-echo-owns-message)
6714 (setq help-echo-owns-message t))
6717 (aref gnus-mouse-2 0))))))
6719 (defun gnus-mime-display-security (handle)
6721 (narrow-to-region (point) (point))
6722 (unless (gnus-unbuttonized-mime-type-p (car handle))
6723 (gnus-insert-mime-security-button handle))
6724 (gnus-mime-display-mixed (cdr handle))
6727 (unless (gnus-unbuttonized-mime-type-p (car handle))
6728 (let ((gnus-mime-security-button-line-format
6729 gnus-mime-security-button-end-line-format))
6730 (gnus-insert-mime-security-button handle)))
6731 (mm-set-handle-multipart-parameter
6733 (cons (set-marker (make-marker) (point-min))
6734 (set-marker (make-marker) (point-max))))))
6740 (defun gnus-article-header-presentation-method (entity situation)
6741 (mime-insert-header entity)
6742 (article-decode-group-name))
6744 (set-alist 'mime-header-presentation-method-alist
6745 'gnus-original-article-mode
6746 #'gnus-article-header-presentation-method)
6748 (defun gnus-mime-preview-quitting-method ()
6749 (mime-preview-kill-buffer)
6750 (delete-other-windows)
6751 (gnus-article-show-summary)
6752 (gnus-summary-select-article gnus-show-all-headers t))
6754 (set-alist 'mime-preview-quitting-method-alist
6755 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
6757 (set-alist 'mime-preview-following-method-alist
6758 'gnus-original-article-mode #'gnus-following-method)
6760 (set-alist 'mime-preview-over-to-previous-method-alist
6761 'gnus-original-article-mode
6763 (if (> (point-min) 1)
6764 (gnus-article-prev-page)
6765 (gnus-article-read-summary-keys
6766 nil (gnus-character-to-event ?P)))))
6768 (set-alist 'mime-preview-over-to-next-method-alist
6769 'gnus-original-article-mode'
6771 (if (< (point-max) (buffer-size))
6772 (gnus-article-next-page)
6773 (gnus-article-read-summary-keys
6774 nil (gnus-character-to-event ?N)))))
6784 (run-hooks 'gnus-art-load-hook)
6786 ;;; gnus-art.el ends here