1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
43 (autoload 'gnus-msg-mail "gnus-msg" nil t)
44 (autoload 'gnus-button-mailto "gnus-msg")
45 (autoload 'gnus-button-reply "gnus-msg" nil t)
47 (defgroup gnus-article nil
49 :link '(custom-manual "(gnus)The Article Buffer")
52 (defgroup gnus-article-treat nil
53 "Treating article parts."
54 :link '(custom-manual "(gnus)Article Hiding")
57 (defgroup gnus-article-hiding nil
58 "Hiding article parts."
59 :link '(custom-manual "(gnus)Article Hiding")
62 (defgroup gnus-article-highlight nil
63 "Article highlighting."
64 :link '(custom-manual "(gnus)Article Highlighting")
68 (defgroup gnus-article-signature nil
70 :link '(custom-manual "(gnus)Article Signature")
73 (defgroup gnus-article-headers nil
75 :link '(custom-manual "(gnus)Hiding Headers")
78 (defgroup gnus-article-washing nil
79 "Special commands on articles."
80 :link '(custom-manual "(gnus)Article Washing")
83 (defgroup gnus-article-emphasis nil
84 "Fontisizing articles."
85 :link '(custom-manual "(gnus)Article Fontisizing")
88 (defgroup gnus-article-saving nil
90 :link '(custom-manual "(gnus)Saving Articles")
93 (defgroup gnus-article-mime nil
94 "Worshiping the MIME wonder."
95 :link '(custom-manual "(gnus)Using MIME")
98 (defgroup gnus-article-buttons nil
99 "Pushable buttons in the article buffer."
100 :link '(custom-manual "(gnus)Article Buttons")
101 :group 'gnus-article)
103 (defgroup gnus-article-various nil
104 "Other article options."
105 :link '(custom-manual "(gnus)Misc Article")
106 :group 'gnus-article)
108 (defcustom gnus-ignored-headers
109 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
110 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
111 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
112 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
113 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
114 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face"
115 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
116 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
117 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
118 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
119 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
120 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
121 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
122 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
123 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
124 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
125 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
126 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
127 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
128 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
129 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
130 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
131 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
132 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
133 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
134 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
135 "^X-Received:" "^Content-length:" "X-precedence:"
136 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
137 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
138 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
139 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
140 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
141 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:"
142 "^X-Request-PGP:" "^X-Fingerprint:" "^X-WRIEnvto:" "^X-WRIEnvfrom:"
143 "^X-Virus-Scanned:" "^X-Delivery-Agent:" "^Posted-Date:" "^X-Gateway:"
144 "^X-Local-Origin:" "^X-Local-Destination:" "^X-UserInfo1:"
146 "*All headers that start with this regexp will be hidden.
147 This variable can also be a list of regexps of headers to be ignored.
148 If `gnus-visible-headers' is non-nil, this variable will be ignored."
149 :type '(choice :custom-show nil
152 :group 'gnus-article-hiding)
154 (defcustom gnus-visible-headers
155 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
156 "*All headers that do not match this regexp will be hidden.
157 This variable can also be a list of regexp of headers to remain visible.
158 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
159 :type '(repeat :value-to-internal (lambda (widget value)
160 (custom-split-regexp-maybe value))
161 :match (lambda (widget value)
163 (widget-editable-list-match widget value)))
165 :group 'gnus-article-hiding)
167 (defcustom gnus-sorted-header-list
168 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
169 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
170 "*This variable is a list of regular expressions.
171 If it is non-nil, headers that match the regular expressions will
172 be placed first in the article buffer in the sequence specified by
174 :type '(repeat regexp)
175 :group 'gnus-article-hiding)
177 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
178 "Headers that are only to be displayed if they have interesting data.
179 Possible values in this list are:
181 'empty Headers with no content.
182 'newsgroups Newsgroup identical to Gnus group.
183 'to-address To identical to To-address.
184 'followup-to Followup-to identical to Newsgroups.
185 'reply-to Reply-to identical to From.
186 'date Date less than four days old.
187 'long-to To and/or Cc longer than 1024 characters.
188 'many-to Multiple To and/or Cc."
189 :type '(set (const :tag "Headers with no content." empty)
190 (const :tag "Newsgroups identical to Gnus group." newsgroups)
191 (const :tag "To identical to To-address." to-address)
192 (const :tag "Followup-to identical to Newsgroups." followup-to)
193 (const :tag "Reply-to identical to From." reply-to)
194 (const :tag "Date less than four days old." date)
195 (const :tag "To and/or Cc longer than 1024 characters." long-to)
196 (const :tag "Multiple To and/or Cc headers." many-to))
197 :group 'gnus-article-hiding)
199 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
200 "Regexp matching signature separator.
201 This can also be a list of regexps. In that case, it will be checked
202 from head to tail looking for a separator. Searches will be done from
203 the end of the buffer."
204 :type '(repeat string)
205 :group 'gnus-article-signature)
207 (defcustom gnus-signature-limit nil
208 "Provide a limit to what is considered a signature.
209 If it is a number, no signature may not be longer (in characters) than
210 that number. If it is a floating point number, no signature may be
211 longer (in lines) than that number. If it is a function, the function
212 will be called without any parameters, and if it returns nil, there is
213 no signature in the buffer. If it is a string, it will be used as a
214 regexp. If it matches, the text in question is not a signature."
215 :type '(choice (integer :value 200)
217 (function :value fun)
218 (regexp :value ".*"))
219 :group 'gnus-article-signature)
221 (defcustom gnus-hidden-properties '(invisible t intangible t)
222 "Property list to use for hiding text."
224 :group 'gnus-article-hiding)
226 ;; Fixme: This isn't the right thing for mixed graphical and and
227 ;; non-graphical frames in a session.
228 (defcustom gnus-article-x-face-command
229 (if (featurep 'xemacs)
230 (if (or (gnus-image-type-available-p 'xface)
231 (gnus-image-type-available-p 'pbm))
232 'gnus-display-x-face-in-from
233 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
234 (if (gnus-image-type-available-p 'pbm)
235 'gnus-display-x-face-in-from
236 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
238 "*String or function to be executed to display an X-Face header.
239 If it is a string, the command will be executed in a sub-shell
240 asynchronously. The compressed face will be piped to this command."
241 :type `(choice string
242 (function-item gnus-display-x-face-in-from)
246 :group 'gnus-article-washing)
248 (defcustom gnus-article-x-face-too-ugly nil
249 "Regexp matching posters whose face shouldn't be shown automatically."
250 :type '(choice regexp (const nil))
251 :group 'gnus-article-washing)
253 (defcustom gnus-article-banner-alist nil
254 "Banner alist for stripping.
256 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
258 :type '(repeat (cons symbol regexp))
259 :group 'gnus-article-washing)
261 (gnus-define-group-parameter
264 "Alist of regexps (to match group names) and banner."
265 :variable-group gnus-article-washing
267 '(choice :tag "Banner"
269 (const :tag "Remove signature" signature)
270 (symbol :tag "Item in `gnus-article-banner-alist'" none)
272 (const :tag "None" nil))
274 "If non-nil, specify how to remove `banners' from articles.
276 Symbol `signature' means to remove signatures delimited by
277 `gnus-signature-separator'. Any other symbol is used to look up a
278 regular expression to match the banner in `gnus-article-banner-alist'.
279 A string is used as a regular expression to match the banner
282 (defcustom gnus-article-address-banner-alist nil
283 "Alist of mail addresses and banners.
284 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
285 to match a mail address in the From: header, BANNER is one of a symbol
286 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
287 If ADDRESS matches author's mail address, it will remove things like
288 advertisements. For example:
290 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
294 (regexp :tag "Address")
295 (choice :tag "Banner" :value nil
296 (const :tag "Remove signature" signature)
297 (symbol :tag "Item in `gnus-article-banner-alist'" none)
299 (const :tag "None" nil))))
300 :group 'gnus-article-washing)
302 (defcustom gnus-emphasis-alist
304 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
309 ("_/" "/_" underline-italic)
310 ("_\\*" "\\*_" underline-bold)
311 ("\\*/" "/\\*" bold-italic)
312 ("_\\*/" "/\\*_" underline-bold-italic))))
316 (format format (car spec) (cadr spec))
317 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
319 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
320 2 3 gnus-emphasis-strikethru)
321 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
322 2 3 gnus-emphasis-underline)))
323 "*Alist that says how to fontify certain phrases.
324 Each item looks like this:
326 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
328 The first element is a regular expression to be matched. The second
329 is a number that says what regular expression grouping used to find
330 the entire emphasized word. The third is a number that says what
331 regexp grouping should be displayed and highlighted. The fourth
332 is the face used for highlighting."
333 :type '(repeat (list :value ("" 0 0 default)
335 (integer :tag "Match group")
336 (integer :tag "Emphasize group")
338 :group 'gnus-article-emphasis)
340 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
341 "A regexp to describe whitespace which should not be emphasized.
342 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
343 The former avoids underlining of leading and trailing whitespace,
344 and the latter avoids underlining any whitespace at all."
346 :group 'gnus-article-emphasis
349 (defface gnus-emphasis-bold '((t (:bold t)))
350 "Face used for displaying strong emphasized text (*word*)."
351 :group 'gnus-article-emphasis)
353 (defface gnus-emphasis-italic '((t (:italic t)))
354 "Face used for displaying italic emphasized text (/word/)."
355 :group 'gnus-article-emphasis)
357 (defface gnus-emphasis-underline '((t (:underline t)))
358 "Face used for displaying underlined emphasized text (_word_)."
359 :group 'gnus-article-emphasis)
361 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
362 "Face used for displaying underlined bold emphasized text (_*word*_)."
363 :group 'gnus-article-emphasis)
365 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
366 "Face used for displaying underlined italic emphasized text (_/word/_)."
367 :group 'gnus-article-emphasis)
369 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
370 "Face used for displaying bold italic emphasized text (/*word*/)."
371 :group 'gnus-article-emphasis)
373 (defface gnus-emphasis-underline-bold-italic
374 '((t (:bold t :italic t :underline t)))
375 "Face used for displaying underlined bold italic emphasized text.
376 Example: (_/*word*/_)."
377 :group 'gnus-article-emphasis)
379 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
380 "Face used for displaying strike-through text (-word-)."
381 :group 'gnus-article-emphasis)
383 (defface gnus-emphasis-highlight-words
384 '((t (:background "black" :foreground "yellow")))
385 "Face used for displaying highlighted words."
386 :group 'gnus-article-emphasis)
388 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
389 "Format for display of Date headers in article bodies.
390 See `format-time-string' for the possible values.
392 The variable can also be function, which should return a complete Date
393 header. The function is called with one argument, the time, which can
394 be fed to `format-time-string'."
395 :type '(choice string symbol)
396 :link '(custom-manual "(gnus)Article Date")
397 :group 'gnus-article-washing)
400 (autoload 'mail-extract-address-components "mail-extr"))
402 (defcustom gnus-save-all-headers t
403 "*If non-nil, don't remove any headers before saving."
404 :group 'gnus-article-saving
407 (defcustom gnus-prompt-before-saving 'always
408 "*This variable says how much prompting is to be done when saving articles.
409 If it is nil, no prompting will be done, and the articles will be
410 saved to the default files. If this variable is `always', each and
411 every article that is saved will be preceded by a prompt, even when
412 saving large batches of articles. If this variable is neither nil not
413 `always', there the user will be prompted once for a file name for
414 each invocation of the saving commands."
415 :group 'gnus-article-saving
416 :type '(choice (item always)
417 (item :tag "never" nil)
418 (sexp :tag "once" :format "%t\n" :value t)))
420 (defcustom gnus-saved-headers gnus-visible-headers
421 "Headers to keep if `gnus-save-all-headers' is nil.
422 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
423 If that variable is nil, however, all headers that match this regexp
424 will be kept while the rest will be deleted before saving."
425 :group 'gnus-article-saving
428 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
429 "A function to save articles in your favourite format.
430 The function must be interactively callable (in other words, it must
431 be an Emacs command).
433 Gnus provides the following functions:
435 * gnus-summary-save-in-rmail (Rmail format)
436 * gnus-summary-save-in-mail (Unix mail format)
437 * gnus-summary-save-in-folder (MH folder)
438 * gnus-summary-save-in-file (article format)
439 * gnus-summary-save-body-in-file (article body)
440 * gnus-summary-save-in-vm (use VM's folder format)
441 * gnus-summary-write-to-file (article format -- overwrite)."
442 :group 'gnus-article-saving
443 :type '(radio (function-item gnus-summary-save-in-rmail)
444 (function-item gnus-summary-save-in-mail)
445 (function-item gnus-summary-save-in-folder)
446 (function-item gnus-summary-save-in-file)
447 (function-item gnus-summary-save-body-in-file)
448 (function-item gnus-summary-save-in-vm)
449 (function-item gnus-summary-write-to-file)))
451 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
452 "A function generating a file name to save articles in Rmail format.
453 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
454 :group 'gnus-article-saving
457 (defcustom gnus-mail-save-name 'gnus-plain-save-name
458 "A function generating a file name to save articles in Unix mail format.
459 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
460 :group 'gnus-article-saving
463 (defcustom gnus-folder-save-name 'gnus-folder-save-name
464 "A function generating a file name to save articles in MH folder.
465 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
466 :group 'gnus-article-saving
469 (defcustom gnus-file-save-name 'gnus-numeric-save-name
470 "A function generating a file name to save articles in article format.
471 The function is called with NEWSGROUP, HEADERS, and optional
473 :group 'gnus-article-saving
476 (defcustom gnus-split-methods
477 '((gnus-article-archive-name)
478 (gnus-article-nndoc-name))
479 "*Variable used to suggest where articles are to be saved.
480 For instance, if you would like to save articles related to Gnus in
481 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
482 you could set this variable to something like:
484 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
485 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
487 This variable is an alist where the where the key is the match and the
488 value is a list of possible files to save in if the match is non-nil.
490 If the match is a string, it is used as a regexp match on the
491 article. If the match is a symbol, that symbol will be funcalled
492 from the buffer of the article to be saved with the newsgroup as the
493 parameter. If it is a list, it will be evaled in the same buffer.
495 If this form or function returns a string, this string will be used as
496 a possible file name; and if it returns a non-nil list, that list will
497 be used as possible file names."
498 :group 'gnus-article-saving
499 :type '(repeat (choice (list :value (fun) function)
500 (cons :value ("" "") regexp (repeat string))
503 (defcustom gnus-page-delimiter "^\^L"
504 "*Regexp describing what to use as article page delimiters.
505 The default value is \"^\^L\", which is a form linefeed at the
506 beginning of a line."
508 :group 'gnus-article-various)
510 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
511 "*The format specification for the article mode line.
512 See `gnus-summary-mode-line-format' for a closer description.
514 The following additional specs are available:
516 %w The article washing status.
517 %m The number of MIME parts in the article."
519 :group 'gnus-article-various)
521 (defcustom gnus-article-mode-hook nil
522 "*A hook for Gnus article mode."
524 :group 'gnus-article-various)
526 (when (featurep 'xemacs)
527 ;; Extracted from gnus-xmas-define in order to preserve user settings
528 (when (fboundp 'turn-off-scroll-in-place)
529 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
530 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
531 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
533 (defcustom gnus-article-menu-hook nil
534 "*Hook run after the creation of the article mode menu."
536 :group 'gnus-article-various)
538 (defcustom gnus-article-prepare-hook nil
539 "*A hook called after an article has been prepared in the article buffer."
541 :group 'gnus-article-various)
543 (defcustom gnus-article-hide-pgp-hook nil
544 "*A hook called after successfully hiding a PGP signature."
546 :group 'gnus-article-various)
548 (defcustom gnus-article-button-face 'bold
549 "Face used for highlighting buttons in the article buffer.
551 An article button is a piece of text that you can activate by pressing
552 `RET' or `mouse-2' above it."
554 :group 'gnus-article-buttons)
556 (defcustom gnus-article-mouse-face 'highlight
557 "Face used for mouse highlighting in the article buffer.
559 Article buttons will be displayed in this face when the cursor is
562 :group 'gnus-article-buttons)
564 (defcustom gnus-signature-face 'gnus-signature-face
565 "Face used for highlighting a signature in the article buffer.
566 Obsolete; use the face `gnus-signature-face' for customizations instead."
568 :group 'gnus-article-highlight
569 :group 'gnus-article-signature)
571 (defface gnus-signature-face
574 "Face used for highlighting a signature in the article buffer."
575 :group 'gnus-article-highlight
576 :group 'gnus-article-signature)
578 (defface gnus-header-from-face
581 (:foreground "spring green"))
584 (:foreground "red3"))
587 "Face used for displaying from headers."
588 :group 'gnus-article-headers
589 :group 'gnus-article-highlight)
591 (defface gnus-header-subject-face
594 (:foreground "SeaGreen3"))
597 (:foreground "red4"))
599 (:bold t :italic t)))
600 "Face used for displaying subject headers."
601 :group 'gnus-article-headers
602 :group 'gnus-article-highlight)
604 (defface gnus-header-newsgroups-face
607 (:foreground "yellow" :italic t))
610 (:foreground "MidnightBlue" :italic t))
613 "Face used for displaying newsgroups headers."
614 :group 'gnus-article-headers
615 :group 'gnus-article-highlight)
617 (defface gnus-header-name-face
620 (:foreground "SeaGreen"))
623 (:foreground "maroon"))
626 "Face used for displaying header names."
627 :group 'gnus-article-headers
628 :group 'gnus-article-highlight)
630 (defface gnus-header-content-face
633 (:foreground "forest green" :italic t))
636 (:foreground "indianred4" :italic t))
638 (:italic t))) "Face used for displaying header content."
639 :group 'gnus-article-headers
640 :group 'gnus-article-highlight)
642 (defcustom gnus-header-face-alist
643 '(("From" nil gnus-header-from-face)
644 ("Subject" nil gnus-header-subject-face)
645 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
646 ("" gnus-header-name-face gnus-header-content-face))
647 "*Controls highlighting of article header.
649 An alist of the form (HEADER NAME CONTENT).
651 HEADER is a regular expression which should match the name of an
652 header header and NAME and CONTENT are either face names or nil.
654 The name of each header field will be displayed using the face
655 specified by the first element in the list where HEADER match the
656 header name and NAME is non-nil. Similarly, the content will be
657 displayed by the first non-nil matching CONTENT face."
658 :group 'gnus-article-headers
659 :group 'gnus-article-highlight
660 :type '(repeat (list (regexp :tag "Header")
662 (item :tag "skip" nil)
663 (face :value default))
664 (choice :tag "Content"
665 (item :tag "skip" nil)
666 (face :value default)))))
668 (defcustom gnus-article-decode-hook
669 '(article-decode-charset article-decode-encoded-words
670 article-decode-group-name)
671 "*Hook run to decode charsets in articles."
672 :group 'gnus-article-headers
675 (defcustom gnus-display-mime-function 'gnus-display-mime
676 "Function to display MIME articles."
677 :group 'gnus-article-mime
680 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
681 "Function used to decode headers.")
683 (defvar gnus-article-dumbquotes-map
703 "Table for MS-to-Latin1 translation.")
705 (defcustom gnus-ignored-mime-types nil
706 "List of MIME types that should be ignored by Gnus."
708 :group 'gnus-article-mime
709 :type '(repeat regexp))
711 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
712 "List of MIME types that should not be given buttons when rendered inline.
713 See also `gnus-buttonized-mime-types' which may override this variable."
715 :group 'gnus-article-mime
716 :type '(repeat regexp))
718 (defcustom gnus-buttonized-mime-types nil
719 "List of MIME types that should be given buttons when rendered inline.
720 If set, this variable overrides `gnus-unbuttonized-mime-types'.
721 To see e.g. security buttons you could set this to
722 `(\"multipart/signed\")'."
724 :group 'gnus-article-mime
725 :type '(repeat regexp))
727 (defcustom gnus-body-boundary-delimiter "_"
728 "String used to delimit header and body.
729 This variable is used by `gnus-article-treat-body-boundary' which can
730 be controlled by `gnus-treat-body-boundary'."
731 :group 'gnus-article-various
732 :type '(choice (item :tag "None" :value nil)
735 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
736 "Defines the location of the faces database.
737 For information on obtaining this database of pretty pictures, please
738 see http://www.cs.indiana.edu/picons/ftp/index.html"
739 :type '(repeat directory)
740 :link '(url-link :tag "download"
741 "http://www.cs.indiana.edu/picons/ftp/index.html")
742 :link '(custom-manual "(gnus)Picons")
745 (defun gnus-picons-installed-p ()
746 "Say whether picons are installed on your machine."
747 (let ((installed nil))
748 (dolist (database gnus-picon-databases)
749 (when (file-exists-p database)
753 (defcustom gnus-article-mime-part-function nil
754 "Function called with a MIME handle as the argument.
755 This is meant for people who want to do something automatic based
756 on parts -- for instance, adding Vcard info to a database."
757 :group 'gnus-article-mime
760 (defcustom gnus-mime-multipart-functions nil
761 "An alist of MIME types to functions to display them."
763 :group 'gnus-article-mime
766 (defcustom gnus-article-date-lapsed-new-header nil
767 "Whether the X-Sent and Date headers can coexist.
768 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
769 either replace the old \"Date:\" header (if this variable is nil), or
770 be added below it (otherwise)."
772 :group 'gnus-article-headers
775 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
776 "Function called with a MIME handle as the argument.
777 This is meant for people who want to view first matched part.
778 For `undisplayed-alternative' (default), the first undisplayed
779 part or alternative part is used. For `undisplayed', the first
780 undisplayed part is used. For a function, the first part which
781 the function return `t' is used. For `nil', the first part is
784 :group 'gnus-article-mime
786 (item :tag "first" :value nil)
787 (item :tag "undisplayed" :value undisplayed)
788 (item :tag "undisplayed or alternative"
789 :value undisplayed-alternative)
792 (defcustom gnus-mime-action-alist
793 '(("save to file" . gnus-mime-save-part)
794 ("save and strip" . gnus-mime-save-part-and-strip)
795 ("display as text" . gnus-mime-inline-part)
796 ("view the part" . gnus-mime-view-part)
797 ("pipe to command" . gnus-mime-pipe-part)
798 ("toggle display" . gnus-article-press-button)
799 ("toggle display" . gnus-article-view-part-as-charset)
800 ("view as type" . gnus-mime-view-part-as-type)
801 ("view internally" . gnus-mime-view-part-internally)
802 ("view externally" . gnus-mime-view-part-externally))
803 "An alist of actions that run on the MIME attachment."
804 :group 'gnus-article-mime
805 :type '(repeat (cons (string :tag "name")
809 ;;; The treatment variables
812 (defvar gnus-part-display-hook nil
813 "Hook called on parts that are to receive treatment.")
815 (defvar gnus-article-treat-custom
816 '(choice (const :tag "Off" nil)
818 (const :tag "Header" head)
819 (const :tag "Last" last)
820 (integer :tag "Less")
821 (repeat :tag "Groups" regexp)
822 (sexp :tag "Predicate")))
824 (defvar gnus-article-treat-head-custom
825 '(choice (const :tag "Off" nil)
826 (const :tag "Header" head)))
828 (defvar gnus-article-treat-types '("text/plain")
831 (defvar gnus-inhibit-treatment nil
832 "Whether to inhibit treatment.")
834 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
835 "Highlight the signature.
836 Valid values are nil, t, `head', `last', an integer or a predicate.
837 See Info node `(gnus)Customizing Articles'."
838 :group 'gnus-article-treat
839 :link '(custom-manual "(gnus)Customizing Articles")
840 :type gnus-article-treat-custom)
841 (put 'gnus-treat-highlight-signature 'highlight t)
843 (defcustom gnus-treat-buttonize 100000
845 Valid values are nil, t, `head', `last', an integer or a predicate.
846 See Info node `(gnus)Customizing Articles'."
847 :group 'gnus-article-treat
848 :link '(custom-manual "(gnus)Customizing Articles")
849 :type gnus-article-treat-custom)
850 (put 'gnus-treat-buttonize 'highlight t)
852 (defcustom gnus-treat-buttonize-head 'head
853 "Add buttons to the head.
854 Valid values are nil, t, `head', `last', an integer or a predicate.
855 See Info node `(gnus)Customizing Articles' for details."
856 :group 'gnus-article-treat
857 :link '(custom-manual "(gnus)Customizing Articles")
858 :type gnus-article-treat-head-custom)
859 (put 'gnus-treat-buttonize-head 'highlight t)
861 (defcustom gnus-treat-emphasize
862 (and (or window-system
864 (>= (string-to-number emacs-version) 21))
867 Valid values are nil, t, `head', `last', an integer or a predicate.
868 See Info node `(gnus)Customizing Articles' for details."
869 :group 'gnus-article-treat
870 :link '(custom-manual "(gnus)Customizing Articles")
871 :type gnus-article-treat-custom)
872 (put 'gnus-treat-emphasize 'highlight t)
874 (defcustom gnus-treat-strip-cr nil
875 "Remove carriage returns.
876 Valid values are nil, t, `head', `last', an integer or a predicate.
877 See Info node `(gnus)Customizing Articles' for details."
878 :group 'gnus-article-treat
879 :link '(custom-manual "(gnus)Customizing Articles")
880 :type gnus-article-treat-custom)
882 (defcustom gnus-treat-unsplit-urls nil
883 "Remove newlines from within URLs.
884 Valid values are nil, t, `head', `last', an integer or a predicate.
885 See Info node `(gnus)Customizing Articles' for details."
886 :group 'gnus-article-treat
887 :link '(custom-manual "(gnus)Customizing Articles")
888 :type gnus-article-treat-custom)
890 (defcustom gnus-treat-leading-whitespace nil
891 "Remove leading whitespace in headers.
892 Valid values are nil, t, `head', `last', an integer or a predicate.
893 See Info node `(gnus)Customizing Articles' for details."
894 :group 'gnus-article-treat
895 :link '(custom-manual "(gnus)Customizing Articles")
896 :type gnus-article-treat-custom)
898 (defcustom gnus-treat-hide-headers 'head
900 Valid values are nil, t, `head', `last', an integer or a predicate.
901 See Info node `(gnus)Customizing Articles' for details."
902 :group 'gnus-article-treat
903 :link '(custom-manual "(gnus)Customizing Articles")
904 :type gnus-article-treat-head-custom)
906 (defcustom gnus-treat-hide-boring-headers nil
907 "Hide boring headers.
908 Valid values are nil, t, `head', `last', an integer or a predicate.
909 See Info node `(gnus)Customizing Articles' for details."
910 :group 'gnus-article-treat
911 :link '(custom-manual "(gnus)Customizing Articles")
912 :type gnus-article-treat-head-custom)
914 (defcustom gnus-treat-hide-signature nil
916 Valid values are nil, t, `head', `last', an integer or a predicate.
917 See Info node `(gnus)Customizing Articles' for details."
918 :group 'gnus-article-treat
919 :link '(custom-manual "(gnus)Customizing Articles")
920 :type gnus-article-treat-custom)
922 (defcustom gnus-treat-fill-article nil
924 Valid values are nil, t, `head', `last', an integer or a predicate.
925 See Info node `(gnus)Customizing Articles' for details."
926 :group 'gnus-article-treat
927 :link '(custom-manual "(gnus)Customizing Articles")
928 :type gnus-article-treat-custom)
930 (defcustom gnus-treat-hide-citation nil
932 Valid values are nil, t, `head', `last', an integer or a predicate.
933 See Info node `(gnus)Customizing Articles' for details."
934 :group 'gnus-article-treat
935 :link '(custom-manual "(gnus)Customizing Articles")
936 :type gnus-article-treat-custom)
938 (defcustom gnus-treat-hide-citation-maybe nil
940 Valid values are nil, t, `head', `last', an integer or a predicate.
941 See Info node `(gnus)Customizing Articles' for details."
942 :group 'gnus-article-treat
943 :link '(custom-manual "(gnus)Customizing Articles")
944 :type gnus-article-treat-custom)
946 (defcustom gnus-treat-strip-list-identifiers 'head
947 "Strip list identifiers from `gnus-list-identifiers`.
948 Valid values are nil, t, `head', `last', an integer or a predicate.
949 See Info node `(gnus)Customizing Articles' for details."
951 :group 'gnus-article-treat
952 :link '(custom-manual "(gnus)Customizing Articles")
953 :type gnus-article-treat-custom)
955 (defcustom gnus-treat-strip-pgp t
956 "Strip PGP signatures.
957 Valid values are nil, t, `head', `last', an integer or a predicate.
958 See Info node `(gnus)Customizing Articles' for details."
959 :group 'gnus-article-treat
960 :link '(custom-manual "(gnus)Customizing Articles")
961 :type gnus-article-treat-custom)
963 (defcustom gnus-treat-strip-pem nil
964 "Strip PEM signatures.
965 Valid values are nil, t, `head', `last', an integer or a predicate.
966 See Info node `(gnus)Customizing Articles' for details."
967 :group 'gnus-article-treat
968 :link '(custom-manual "(gnus)Customizing Articles")
969 :type gnus-article-treat-custom)
971 (defcustom gnus-treat-strip-banner t
972 "Strip banners from articles.
973 The banner to be stripped is specified in the `banner' group parameter.
974 Valid values are nil, t, `head', `last', an integer or a predicate.
975 See Info node `(gnus)Customizing Articles' for details."
976 :group 'gnus-article-treat
977 :link '(custom-manual "(gnus)Customizing Articles")
978 :type gnus-article-treat-custom)
980 (defcustom gnus-treat-highlight-headers 'head
981 "Highlight the headers.
982 Valid values are nil, t, `head', `last', an integer or a predicate.
983 See Info node `(gnus)Customizing Articles' for details."
984 :group 'gnus-article-treat
985 :link '(custom-manual "(gnus)Customizing Articles")
986 :type gnus-article-treat-head-custom)
987 (put 'gnus-treat-highlight-headers 'highlight t)
989 (defcustom gnus-treat-highlight-citation t
990 "Highlight cited text.
991 Valid values are nil, t, `head', `last', an integer or a predicate.
992 See Info node `(gnus)Customizing Articles' for details."
993 :group 'gnus-article-treat
994 :link '(custom-manual "(gnus)Customizing Articles")
995 :type gnus-article-treat-custom)
996 (put 'gnus-treat-highlight-citation 'highlight t)
998 (defcustom gnus-treat-date-ut nil
999 "Display the Date in UT (GMT).
1000 Valid values are nil, t, `head', `last', an integer or a predicate.
1001 See Info node `(gnus)Customizing Articles' for details."
1002 :group 'gnus-article-treat
1003 :link '(custom-manual "(gnus)Customizing Articles")
1004 :type gnus-article-treat-head-custom)
1006 (defcustom gnus-treat-date-local nil
1007 "Display the Date in the local timezone.
1008 Valid values are nil, t, `head', `last', an integer or a predicate.
1009 See Info node `(gnus)Customizing Articles' for details."
1010 :group 'gnus-article-treat
1011 :link '(custom-manual "(gnus)Customizing Articles")
1012 :type gnus-article-treat-head-custom)
1014 (defcustom gnus-treat-date-english nil
1015 "Display the Date in a format that can be read aloud in English.
1016 Valid values are nil, t, `head', `last', an integer or a predicate.
1017 See Info node `(gnus)Customizing Articles' for details."
1018 :group 'gnus-article-treat
1019 :link '(custom-manual "(gnus)Customizing Articles")
1020 :type gnus-article-treat-head-custom)
1022 (defcustom gnus-treat-date-lapsed nil
1023 "Display the Date header in a way that says how much time has elapsed.
1024 Valid values are nil, t, `head', `last', an integer or a predicate.
1025 See Info node `(gnus)Customizing Articles' for details."
1026 :group 'gnus-article-treat
1027 :link '(custom-manual "(gnus)Customizing Articles")
1028 :type gnus-article-treat-head-custom)
1030 (defcustom gnus-treat-date-original nil
1031 "Display the date in the original timezone.
1032 Valid values are nil, t, `head', `last', an integer or a predicate.
1033 See Info node `(gnus)Customizing Articles' for details."
1034 :group 'gnus-article-treat
1035 :link '(custom-manual "(gnus)Customizing Articles")
1036 :type gnus-article-treat-head-custom)
1038 (defcustom gnus-treat-date-iso8601 nil
1039 "Display the date in the ISO8601 format.
1040 Valid values are nil, t, `head', `last', an integer or a predicate.
1041 See Info node `(gnus)Customizing Articles' for details."
1043 :group 'gnus-article-treat
1044 :link '(custom-manual "(gnus)Customizing Articles")
1045 :type gnus-article-treat-head-custom)
1047 (defcustom gnus-treat-date-user-defined nil
1048 "Display the date in a user-defined format.
1049 The format is defined by the `gnus-article-time-format' variable.
1050 Valid values are nil, t, `head', `last', an integer or a predicate.
1051 See Info node `(gnus)Customizing Articles' for details."
1052 :group 'gnus-article-treat
1053 :link '(custom-manual "(gnus)Customizing Articles")
1054 :type gnus-article-treat-head-custom)
1056 (defcustom gnus-treat-strip-headers-in-body t
1057 "Strip the X-No-Archive header line from the beginning of the body.
1058 Valid values are nil, t, `head', `last', an integer or a predicate.
1059 See Info node `(gnus)Customizing Articles' for details."
1061 :group 'gnus-article-treat
1062 :link '(custom-manual "(gnus)Customizing Articles")
1063 :type gnus-article-treat-custom)
1065 (defcustom gnus-treat-strip-trailing-blank-lines nil
1066 "Strip trailing blank lines.
1067 Valid values are nil, t, `head', `last', an integer or a predicate.
1068 See Info node `(gnus)Customizing Articles' for details."
1069 :group 'gnus-article-treat
1070 :link '(custom-manual "(gnus)Customizing Articles")
1071 :type gnus-article-treat-custom)
1073 (defcustom gnus-treat-strip-leading-blank-lines nil
1074 "Strip leading blank lines.
1075 Valid values are nil, t, `head', `last', an integer or a predicate.
1076 See Info node `(gnus)Customizing Articles' for details."
1077 :group 'gnus-article-treat
1078 :link '(custom-manual "(gnus)Customizing Articles")
1079 :type gnus-article-treat-custom)
1081 (defcustom gnus-treat-strip-multiple-blank-lines nil
1082 "Strip multiple blank lines.
1083 Valid values are nil, t, `head', `last', an integer or a predicate.
1084 See Info node `(gnus)Customizing Articles' for details."
1085 :group 'gnus-article-treat
1086 :link '(custom-manual "(gnus)Customizing Articles")
1087 :type gnus-article-treat-custom)
1089 (defcustom gnus-treat-unfold-headers 'head
1090 "Unfold folded header lines.
1091 Valid values are nil, t, `head', `last', an integer or a predicate.
1092 See Info node `(gnus)Customizing Articles' for details."
1093 :group 'gnus-article-treat
1094 :link '(custom-manual "(gnus)Customizing Articles")
1095 :type gnus-article-treat-custom)
1097 (defcustom gnus-treat-fold-headers nil
1099 Valid values are nil, t, `head', `last', an integer or a predicate.
1100 See Info node `(gnus)Customizing Articles' for details."
1101 :group 'gnus-article-treat
1102 :link '(custom-manual "(gnus)Customizing Articles")
1103 :type gnus-article-treat-custom)
1105 (defcustom gnus-treat-fold-newsgroups 'head
1106 "Fold the Newsgroups and Followup-To headers.
1107 Valid values are nil, t, `head', `last', an integer or a predicate.
1108 See Info node `(gnus)Customizing Articles' for details."
1109 :group 'gnus-article-treat
1110 :link '(custom-manual "(gnus)Customizing Articles")
1111 :type gnus-article-treat-custom)
1113 (defcustom gnus-treat-overstrike t
1114 "Treat overstrike highlighting.
1115 Valid values are nil, t, `head', `last', an integer or a predicate.
1116 See Info node `(gnus)Customizing Articles' for details."
1117 :group 'gnus-article-treat
1118 :link '(custom-manual "(gnus)Customizing Articles")
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)
1130 "Display X-Face headers.
1131 Valid values are nil, t, `head', `last', an integer or a predicate.
1132 See Info node `(gnus)Customizing Articles' and Info node
1133 `(gnus)X-Face' for details."
1134 :group 'gnus-article-treat
1136 :link '(custom-manual "(gnus)Customizing Articles")
1137 :link '(custom-manual "(gnus)X-Face")
1138 :type gnus-article-treat-head-custom)
1139 (put 'gnus-treat-display-xface 'highlight t)
1141 (defcustom gnus-treat-display-grey-xface
1142 (and (not noninteractive)
1143 (string-match "^0x" (shell-command-to-string "uncompface"))
1145 "Display grey X-Face headers.
1146 Valid values are nil, t."
1147 :group 'gnus-article-treat
1150 (put 'gnus-treat-display-grey-xface 'highlight t)
1152 (defcustom gnus-treat-display-smileys
1153 (if (or (and (featurep 'xemacs)
1155 (and (fboundp 'image-type-available-p)
1156 (image-type-available-p 'pbm)))
1159 Valid values are nil, t, `head', `last', an integer or a predicate.
1160 See Info node `(gnus)Customizing Articles' and Info node
1161 `(gnus)Smileys' for details."
1162 :group 'gnus-article-treat
1164 :link '(custom-manual "(gnus)Customizing Articles")
1165 :link '(custom-manual "(gnus)Smileys")
1166 :type gnus-article-treat-custom)
1167 (put 'gnus-treat-display-smileys 'highlight t)
1169 (defcustom gnus-treat-from-picon
1170 (if (and (gnus-image-type-available-p 'xpm)
1171 (gnus-picons-installed-p))
1173 "Display picons in the From header.
1174 Valid values are nil, t, `head', `last', an integer or a predicate.
1175 See Info node `(gnus)Customizing Articles' and Info node
1176 `(gnus)Picons' for details."
1177 :group 'gnus-article-treat
1179 :link '(custom-manual "(gnus)Customizing Articles")
1180 :link '(custom-manual "(gnus)Picons")
1181 :type gnus-article-treat-head-custom)
1182 (put 'gnus-treat-from-picon 'highlight t)
1184 (defcustom gnus-treat-mail-picon
1185 (if (and (gnus-image-type-available-p 'xpm)
1186 (gnus-picons-installed-p))
1188 "Display picons in To and Cc headers.
1189 Valid values are nil, t, `head', `last', an integer or a predicate.
1190 See Info node `(gnus)Customizing Articles' and Info node
1191 `(gnus)Picons' for details."
1192 :group 'gnus-article-treat
1194 :link '(custom-manual "(gnus)Customizing Articles")
1195 :link '(custom-manual "(gnus)Picons")
1196 :type gnus-article-treat-head-custom)
1197 (put 'gnus-treat-mail-picon 'highlight t)
1199 (defcustom gnus-treat-newsgroups-picon
1200 (if (and (gnus-image-type-available-p 'xpm)
1201 (gnus-picons-installed-p))
1203 "Display picons in the Newsgroups and Followup-To headers.
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
1209 :link '(custom-manual "(gnus)Customizing Articles")
1210 :link '(custom-manual "(gnus)Picons")
1211 :type gnus-article-treat-head-custom)
1212 (put 'gnus-treat-newsgroups-picon 'highlight t)
1214 (defcustom gnus-treat-body-boundary
1215 (if (or gnus-treat-newsgroups-picon
1216 gnus-treat-mail-picon
1217 gnus-treat-from-picon)
1219 "Draw a boundary at the end of the headers.
1220 Valid values are nil, t, `head', `last', an integer or a predicate.
1221 See Info node `(gnus)Customizing Articles' for details."
1223 :group 'gnus-article-treat
1224 :link '(custom-manual "(gnus)Customizing Articles")
1225 :type gnus-article-treat-custom)
1227 (defcustom gnus-treat-capitalize-sentences nil
1228 "Capitalize sentence-starting words.
1229 Valid values are nil, t, `head', `last', an integer or a predicate.
1230 See Info node `(gnus)Customizing Articles' for details."
1232 :group 'gnus-article-treat
1233 :link '(custom-manual "(gnus)Customizing Articles")
1234 :type gnus-article-treat-custom)
1236 (defcustom gnus-treat-fill-long-lines nil
1238 Valid values are nil, t, `head', `last', an integer or a predicate.
1239 See Info node `(gnus)Customizing Articles' for details."
1240 :group 'gnus-article-treat
1241 :link '(custom-manual "(gnus)Customizing Articles")
1242 :type gnus-article-treat-custom)
1244 (defcustom gnus-treat-play-sounds nil
1246 Valid values are nil, t, `head', `last', an integer or a predicate.
1247 See Info node `(gnus)Customizing Articles' for details."
1249 :group 'gnus-article-treat
1250 :link '(custom-manual "(gnus)Customizing Articles")
1251 :type gnus-article-treat-custom)
1253 (defcustom gnus-treat-translate nil
1254 "Translate articles from one language to another.
1255 Valid values are nil, t, `head', `last', an integer or a predicate.
1256 See Info node `(gnus)Customizing Articles' for details."
1258 :group 'gnus-article-treat
1259 :link '(custom-manual "(gnus)Customizing Articles")
1260 :type gnus-article-treat-custom)
1262 (defcustom gnus-treat-x-pgp-sig nil
1264 To automatically treat X-PGP-Sig, set it to head.
1265 Valid values are nil, t, `head', `last', an integer or a predicate.
1266 See Info node `(gnus)Customizing Articles' for details."
1267 :group 'gnus-article-treat
1268 :group 'mime-security
1269 :link '(custom-manual "(gnus)Customizing Articles")
1270 :type gnus-article-treat-custom)
1272 (defvar gnus-article-encrypt-protocol-alist
1273 '(("PGP" . mml2015-self-encrypt)))
1275 ;; Set to nil if more than one protocol added to
1276 ;; gnus-article-encrypt-protocol-alist.
1277 (defcustom gnus-article-encrypt-protocol "PGP"
1278 "The protocol used for encrypt articles.
1279 It is a string, such as \"PGP\". If nil, ask user."
1281 :group 'mime-security)
1283 (defvar gnus-article-wash-function nil
1284 "Function used for converting HTML into text.")
1286 ;;; Internal variables
1288 (defvar gnus-english-month-names
1289 '("January" "February" "March" "April" "May" "June" "July" "August"
1290 "September" "October" "November" "December"))
1292 (defvar article-goto-body-goes-to-point-min-p nil)
1293 (defvar gnus-article-wash-types nil)
1294 (defvar gnus-article-emphasis-alist nil)
1295 (defvar gnus-article-image-alist nil)
1297 (defvar gnus-article-mime-handle-alist-1 nil)
1298 (defvar gnus-treatment-function-alist
1299 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1300 (gnus-treat-strip-banner gnus-article-strip-banner)
1301 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1302 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1303 (gnus-treat-buttonize gnus-article-add-buttons)
1304 (gnus-treat-fill-article gnus-article-fill-cited-article)
1305 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1306 (gnus-treat-strip-cr gnus-article-remove-cr)
1307 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1308 (gnus-treat-date-ut gnus-article-date-ut)
1309 (gnus-treat-date-local gnus-article-date-local)
1310 (gnus-treat-date-english gnus-article-date-english)
1311 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1312 (gnus-treat-date-original gnus-article-date-original)
1313 (gnus-treat-date-user-defined gnus-article-date-user)
1314 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1315 (gnus-treat-display-xface gnus-article-display-x-face)
1316 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1317 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1318 (gnus-treat-hide-signature gnus-article-hide-signature)
1319 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1320 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1321 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1322 (gnus-treat-strip-pem gnus-article-hide-pem)
1323 (gnus-treat-from-picon gnus-treat-from-picon)
1324 (gnus-treat-mail-picon gnus-treat-mail-picon)
1325 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1326 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1327 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1328 (gnus-treat-strip-trailing-blank-lines
1329 gnus-article-remove-trailing-blank-lines)
1330 (gnus-treat-strip-leading-blank-lines
1331 gnus-article-strip-leading-blank-lines)
1332 (gnus-treat-strip-multiple-blank-lines
1333 gnus-article-strip-multiple-blank-lines)
1334 (gnus-treat-overstrike gnus-article-treat-overstrike)
1335 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1336 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1337 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1338 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1339 (gnus-treat-display-smileys gnus-treat-smiley)
1340 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1341 (gnus-treat-emphasize gnus-article-emphasize)
1342 (gnus-treat-hide-citation gnus-article-hide-citation)
1343 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1344 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1345 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1346 (gnus-treat-play-sounds gnus-earcon-display)))
1348 (defvar gnus-article-mime-handle-alist nil)
1349 (defvar article-lapsed-timer nil)
1350 (defvar gnus-article-current-summary nil)
1352 (defvar gnus-article-mode-syntax-table
1353 (let ((table (copy-syntax-table text-mode-syntax-table)))
1354 ;; This causes the citation match run O(2^n).
1355 ;; (modify-syntax-entry ?- "w" table)
1356 (modify-syntax-entry ?> ")<" table)
1357 (modify-syntax-entry ?< "(>" table)
1358 ;; make M-. in article buffers work for `foo' strings
1359 (modify-syntax-entry ?' " " table)
1360 (modify-syntax-entry ?` " " table)
1362 "Syntax table used in article mode buffers.
1363 Initialized from `text-mode-syntax-table.")
1365 (defvar gnus-save-article-buffer nil)
1367 (defvar gnus-article-mode-line-format-alist
1368 (nconc '((?w (gnus-article-wash-status) ?s)
1369 (?m (gnus-article-mime-part-status) ?s))
1370 gnus-summary-mode-line-format-alist))
1372 (defvar gnus-number-of-articles-to-be-saved nil)
1374 (defvar gnus-inhibit-hiding nil)
1376 ;;; Macros for dealing with the article buffer.
1378 (defmacro gnus-with-article-headers (&rest forms)
1380 (set-buffer gnus-article-buffer)
1382 (let ((buffer-read-only nil)
1383 (inhibit-point-motion-hooks t)
1384 (case-fold-search t))
1385 (article-narrow-to-head)
1388 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1389 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1391 (defmacro gnus-with-article-buffer (&rest forms)
1393 (set-buffer gnus-article-buffer)
1394 (let ((buffer-read-only nil))
1397 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1398 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1400 (defun gnus-article-goto-header (header)
1401 "Go to HEADER, which is a regular expression."
1402 (re-search-forward (concat "^\\(" header "\\):") nil t))
1404 (defsubst gnus-article-hide-text (b e props)
1405 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1406 (gnus-add-text-properties-when 'article-type nil b e props)
1407 (when (memq 'intangible props)
1409 (max (1- b) (point-min))
1410 b 'intangible (cddr (memq 'intangible props)))))
1412 (defsubst gnus-article-unhide-text (b e)
1413 "Remove hidden text properties from region between B and E."
1414 (remove-text-properties b e gnus-hidden-properties)
1415 (when (memq 'intangible gnus-hidden-properties)
1416 (put-text-property (max (1- b) (point-min))
1417 b 'intangible nil)))
1419 (defun gnus-article-hide-text-type (b e type)
1420 "Hide text of TYPE between B and E."
1421 (gnus-add-wash-type type)
1422 (gnus-article-hide-text
1423 b e (cons 'article-type (cons type gnus-hidden-properties))))
1425 (defun gnus-article-unhide-text-type (b e type)
1426 "Unhide text of TYPE between B and E."
1427 (gnus-delete-wash-type type)
1428 (remove-text-properties
1429 b e (cons 'article-type (cons type gnus-hidden-properties)))
1430 (when (memq 'intangible gnus-hidden-properties)
1431 (put-text-property (max (1- b) (point-min))
1432 b 'intangible nil)))
1434 (defun gnus-article-hide-text-of-type (type)
1435 "Hide text of TYPE in the current buffer."
1437 (let ((b (point-min))
1439 (while (setq b (text-property-any b e 'article-type type))
1440 (add-text-properties b (incf b) gnus-hidden-properties)))))
1442 (defun gnus-article-delete-text-of-type (type)
1443 "Delete text of TYPE in the current buffer."
1445 (let ((b (point-min)))
1446 (while (setq b (text-property-any b (point-max) 'article-type type))
1448 b (or (text-property-not-all b (point-max) 'article-type type)
1451 (defun gnus-article-delete-invisible-text ()
1452 "Delete all invisible text in the current buffer."
1454 (let ((b (point-min)))
1455 (while (setq b (text-property-any b (point-max) 'invisible t))
1457 b (or (text-property-not-all b (point-max) 'invisible t)
1460 (defun gnus-article-text-type-exists-p (type)
1461 "Say whether any text of type TYPE exists in the buffer."
1462 (text-property-any (point-min) (point-max) 'article-type type))
1464 (defsubst gnus-article-header-rank ()
1465 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1466 (let ((list gnus-sorted-header-list)
1469 (when (looking-at (car list))
1471 (setq list (cdr list))
1475 (defun article-hide-headers (&optional arg delete)
1476 "Hide unwanted headers and possibly sort them as well."
1478 ;; This function might be inhibited.
1479 (unless gnus-inhibit-hiding
1482 (let ((buffer-read-only nil)
1483 (case-fold-search t)
1484 (max (1+ (length gnus-sorted-header-list)))
1485 (ignored (when (not gnus-visible-headers)
1486 (cond ((stringp gnus-ignored-headers)
1487 gnus-ignored-headers)
1488 ((listp gnus-ignored-headers)
1489 (mapconcat 'identity gnus-ignored-headers
1492 (cond ((stringp gnus-visible-headers)
1493 gnus-visible-headers)
1494 ((and gnus-visible-headers
1495 (listp gnus-visible-headers))
1496 (mapconcat 'identity gnus-visible-headers "\\|"))))
1497 (inhibit-point-motion-hooks t)
1499 ;; First we narrow to just the headers.
1500 (article-narrow-to-head)
1501 ;; Hide any "From " lines at the beginning of (mail) articles.
1502 (while (looking-at "From ")
1505 (delete-region (point-min) (point)))
1506 ;; Then treat the rest of the header lines.
1507 ;; Then we use the two regular expressions
1508 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1509 ;; select which header lines is to remain visible in the
1511 (while (re-search-forward "^[^ \t:]*:" nil t)
1513 ;; Mark the rank of the header.
1515 (point) (1+ (point)) 'message-rank
1516 (if (or (and visible (looking-at visible))
1518 (not (looking-at ignored))))
1519 (gnus-article-header-rank)
1522 (message-sort-headers-1)
1523 (when (setq beg (text-property-any
1524 (point-min) (point-max) 'message-rank (+ 2 max)))
1525 ;; We delete the unwanted headers.
1526 (gnus-add-wash-type 'headers)
1527 (add-text-properties (point-min) (+ 5 (point-min))
1528 '(article-type headers dummy-invisible t))
1529 (delete-region beg (point-max))))))))
1531 (defun article-hide-boring-headers (&optional arg)
1532 "Toggle hiding of headers that aren't very interesting.
1533 If given a negative prefix, always show; if given a positive prefix,
1535 (interactive (gnus-article-hidden-arg))
1536 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1537 (not gnus-show-all-headers))
1540 (let ((buffer-read-only nil)
1541 (list gnus-boring-article-headers)
1542 (inhibit-point-motion-hooks t)
1544 (article-narrow-to-head)
1546 (setq elem (pop list))
1547 (goto-char (point-min))
1549 ;; Hide empty headers.
1551 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1553 (gnus-article-hide-text-type
1554 (progn (beginning-of-line) (point))
1557 (if (re-search-forward "^[^ \t]" nil t)
1561 ;; Hide boring Newsgroups header.
1562 ((eq elem 'newsgroups)
1563 (when (gnus-string-equal
1564 (gnus-fetch-field "newsgroups")
1565 (gnus-group-real-name
1566 (if (boundp 'gnus-newsgroup-name)
1569 (gnus-article-hide-header "newsgroups")))
1570 ((eq elem 'to-address)
1571 (let ((to (message-fetch-field "to"))
1573 (gnus-parameter-to-address
1574 (if (boundp 'gnus-newsgroup-name)
1575 gnus-newsgroup-name ""))))
1576 (when (and to to-address
1579 ;; only one address in To
1580 (nth 1 (mail-extract-address-components to))
1582 (gnus-article-hide-header "to"))))
1583 ((eq elem 'followup-to)
1584 (when (gnus-string-equal
1585 (message-fetch-field "followup-to")
1586 (message-fetch-field "newsgroups"))
1587 (gnus-article-hide-header "followup-to")))
1588 ((eq elem 'reply-to)
1589 (let ((from (message-fetch-field "from"))
1590 (reply-to (message-fetch-field "reply-to")))
1595 (nth 1 (mail-extract-address-components from))
1596 (nth 1 (mail-extract-address-components reply-to)))))
1597 (gnus-article-hide-header "reply-to"))))
1599 (let ((date (message-fetch-field "date")))
1601 (< (days-between (current-time-string) date)
1603 (gnus-article-hide-header "date"))))
1605 (let ((to (message-fetch-field "to"))
1606 (cc (message-fetch-field "cc")))
1607 (when (> (length to) 1024)
1608 (gnus-article-hide-header "to"))
1609 (when (> (length cc) 1024)
1610 (gnus-article-hide-header "cc"))))
1614 (goto-char (point-min))
1615 (while (re-search-forward "^to:" nil t)
1616 (setq to-count (1+ to-count)))
1617 (when (> to-count 1)
1618 (while (> to-count 0)
1619 (goto-char (point-min))
1621 (re-search-forward "^to:" nil nil to-count)
1623 (narrow-to-region (point) (point-max))
1624 (gnus-article-hide-header "to"))
1625 (setq to-count (1- to-count))))
1626 (goto-char (point-min))
1627 (while (re-search-forward "^cc:" nil t)
1628 (setq cc-count (1+ cc-count)))
1629 (when (> cc-count 1)
1630 (while (> cc-count 0)
1631 (goto-char (point-min))
1633 (re-search-forward "^cc:" nil nil cc-count)
1635 (narrow-to-region (point) (point-max))
1636 (gnus-article-hide-header "cc"))
1637 (setq cc-count (1- cc-count)))))))))))))
1639 (defun gnus-article-hide-header (header)
1641 (goto-char (point-min))
1642 (when (re-search-forward (concat "^" header ":") nil t)
1643 (gnus-article-hide-text-type
1644 (progn (beginning-of-line) (point))
1647 (if (re-search-forward "^[^ \t]" nil t)
1652 (defvar gnus-article-normalized-header-length 40
1653 "Length of normalized headers.")
1655 (defun article-normalize-headers ()
1656 "Make all header lines 40 characters long."
1658 (let ((buffer-read-only nil)
1662 (article-narrow-to-head)
1665 ((< (setq column (- (gnus-point-at-eol) (point)))
1666 gnus-article-normalized-header-length)
1668 (insert (make-string
1669 (- gnus-article-normalized-header-length column)
1671 ((> column gnus-article-normalized-header-length)
1672 (gnus-put-text-property
1674 (forward-char gnus-article-normalized-header-length)
1681 (forward-line 1))))))
1683 (defun article-treat-dumbquotes ()
1684 "Translate M****s*** sm*rtq**t*s into proper text.
1685 Note that this function guesses whether a character is a sm*rtq**t* or
1686 not, so it should only be used interactively.
1688 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1689 in an attempt to provide more quoting characters. If you see
1690 something like \\222 or \\264 where you're expecting some kind of
1691 apostrophe or quotation mark, then try this wash."
1693 (article-translate-strings gnus-article-dumbquotes-map))
1695 (defun article-translate-characters (from to)
1696 "Translate all characters in the body of the article according to FROM and TO.
1697 FROM is a string of characters to translate from; to is a string of
1698 characters to translate to."
1700 (when (article-goto-body)
1701 (let ((buffer-read-only nil)
1702 (x (make-string 225 ?x))
1704 (while (< (incf i) (length x))
1707 (while (< i (length from))
1708 (aset x (aref from i) (aref to i))
1710 (translate-region (point) (point-max) x)))))
1712 (defun article-translate-strings (map)
1713 "Translate all string in the body of the article according to MAP.
1714 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1716 (when (article-goto-body)
1717 (let ((buffer-read-only nil)
1719 (while (setq elem (pop map))
1721 (while (search-forward (car elem) nil t)
1722 (replace-match (cadr elem)))))))))
1724 (defun article-treat-overstrike ()
1725 "Translate overstrikes into bold text."
1728 (when (article-goto-body)
1729 (let ((buffer-read-only nil))
1730 (while (search-forward "\b" nil t)
1731 (let ((next (char-after))
1732 (previous (char-after (- (point) 2))))
1733 ;; We do the boldification/underlining by hiding the
1734 ;; overstrikes and putting the proper text property
1738 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1739 (put-text-property (point) (1+ (point)) 'face 'bold))
1741 (gnus-article-hide-text-type
1742 (1- (point)) (1+ (point)) 'overstrike)
1744 (- (point) 2) (1- (point)) 'face 'underline))
1746 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1748 (point) (1+ (point)) 'face 'underline)))))))))
1750 (defun gnus-article-treat-unfold-headers ()
1751 "Unfold folded message headers.
1752 Only the headers that fit into the current window width will be
1755 (gnus-with-article-headers
1759 (mail-header-narrow-to-field)
1760 (let ((header (buffer-substring (point-min) (point-max))))
1763 (goto-char (point-min))
1764 (while (re-search-forward "\n[\t ]" nil t)
1765 (replace-match " " t t)))
1766 (setq length (- (point-max) (point-min) 1)))
1767 (when (< length (window-width))
1768 (while (re-search-forward "\n[\t ]" nil t)
1769 (replace-match " " t t)))
1770 (goto-char (point-max)))))))
1772 (defun gnus-article-treat-fold-headers ()
1773 "Fold message headers."
1775 (gnus-with-article-headers
1778 (mail-header-narrow-to-field)
1779 (mail-header-fold-field)
1780 (goto-char (point-max))))))
1782 (defun gnus-treat-smiley ()
1783 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1785 (gnus-with-article-buffer
1786 (if (memq 'smiley gnus-article-wash-types)
1787 (gnus-delete-images 'smiley)
1789 (let ((images (smiley-region (point) (point-max))))
1791 (gnus-add-wash-type 'smiley)
1792 (dolist (image images)
1793 (gnus-add-image 'smiley image)))))))
1795 (defun gnus-article-remove-images ()
1796 "Remove all images from the article buffer."
1798 (gnus-with-article-buffer
1799 (dolist (elem gnus-article-image-alist)
1800 (gnus-delete-images (car elem)))))
1802 (defun gnus-article-treat-fold-newsgroups ()
1803 "Unfold folded message headers.
1804 Only the headers that fit into the current window width will be
1807 (gnus-with-article-headers
1808 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1810 (mail-header-narrow-to-field)
1811 (while (re-search-forward ", *" nil t)
1812 (replace-match ", " t t))
1813 (mail-header-fold-field)
1814 (goto-char (point-max))))))
1816 (defun gnus-article-treat-body-boundary ()
1817 "Place a boundary line at the end of the headers."
1819 (when (and gnus-body-boundary-delimiter
1820 (> (length gnus-body-boundary-delimiter) 0))
1821 (gnus-with-article-headers
1822 (goto-char (point-max))
1823 (let ((start (point)))
1824 (insert "X-Boundary: ")
1825 (gnus-add-text-properties start (point) '(invisible t intangible t))
1827 (while (>= (1- (window-width)) (length str))
1828 (setq str (concat str gnus-body-boundary-delimiter)))
1829 (substring str 0 (1- (window-width))))
1831 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1833 (defun article-fill-long-lines ()
1834 "Fill lines that are wider than the window width."
1837 (let ((buffer-read-only nil)
1838 (width (window-width (get-buffer-window (current-buffer)))))
1841 (let ((adaptive-fill-mode nil)) ;Why? -sm
1844 (when (>= (current-column) (min fill-column width))
1845 (narrow-to-region (min (1+ (point)) (point-max)) (gnus-point-at-bol))
1846 (let ((goback (point-marker)))
1847 (fill-paragraph nil)
1848 (goto-char (marker-position goback)))
1850 (forward-line 1)))))))
1852 (defun article-capitalize-sentences ()
1853 "Capitalize the first word in each sentence."
1856 (let ((buffer-read-only nil)
1857 (paragraph-start "^[\n\^L]"))
1861 (forward-sentence)))))
1863 (defun article-remove-cr ()
1864 "Remove trailing CRs and then translate remaining CRs into LFs."
1867 (let ((buffer-read-only nil))
1868 (goto-char (point-min))
1869 (while (re-search-forward "\r+$" nil t)
1870 (replace-match "" t t))
1871 (goto-char (point-min))
1872 (while (search-forward "\r" nil t)
1873 (replace-match "\n" t t)))))
1875 (defun article-remove-trailing-blank-lines ()
1876 "Remove all trailing blank lines from the article."
1879 (let ((buffer-read-only nil))
1880 (goto-char (point-max))
1884 (while (and (not (bobp))
1885 (looking-at "^[ \t]*$")
1886 (not (gnus-annotation-in-region-p
1887 (point) (gnus-point-at-eol))))
1892 (defun article-display-x-face (&optional force)
1893 "Look for an X-Face header and display it if present."
1894 (interactive (list 'force))
1895 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1896 (gnus-with-article-headers
1897 ;; Delete the old process, if any.
1898 (when (process-status "article-x-face")
1899 (delete-process "article-x-face"))
1900 (if (memq 'xface gnus-article-wash-types)
1901 ;; We have already displayed X-Faces, so we remove them
1903 (gnus-delete-images 'xface)
1905 (let (x-faces from face grey)
1907 (when (and wash-face-p
1909 (goto-char (point-min))
1910 (not (re-search-forward
1911 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
1912 (gnus-buffer-live-p gnus-original-article-buffer))
1913 ;; If type `W f', use gnus-original-article-buffer,
1914 ;; otherwise use the current buffer because displaying
1915 ;; RFC822 parts calls this function too.
1916 (set-buffer gnus-original-article-buffer))
1918 (mail-narrow-to-head)
1919 (if gnus-treat-display-grey-xface
1921 (while (gnus-article-goto-header "X-Face\\(-[0-9]+\\)?")
1922 (if (match-beginning 2)
1925 (push (cons (- (string-to-number (match-string 2)))
1926 (mail-header-field-value))
1928 (push (cons 0 (mail-header-field-value)) x-faces)))
1929 (dolist (x-face (prog1
1931 (sort x-faces 'car-less-than-car)
1933 (setq x-faces nil)))
1934 (push (cdr x-face) x-faces)))
1935 (while (gnus-article-goto-header "X-Face")
1936 (push (mail-header-field-value) x-faces)))
1937 (setq from (message-fetch-field "from"))))
1939 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
1942 (setq image (gnus-create-image xpm 'xpm t))
1943 (gnus-article-goto-header "from")
1945 (insert "From: [no `from' set]\n")
1947 (gnus-add-wash-type 'xface)
1948 (gnus-add-image 'xface image)
1949 (gnus-put-image image)))
1950 ;; Sending multiple EOFs to xv doesn't work, so we only do a
1951 ;; single external face.
1952 (when (stringp gnus-article-x-face-command)
1953 (setq x-faces (list (car x-faces))))
1954 (while (and (setq face (pop x-faces))
1955 gnus-article-x-face-command
1957 ;; Check whether this face is censored.
1958 (not gnus-article-x-face-too-ugly)
1959 (and gnus-article-x-face-too-ugly from
1960 (not (string-match gnus-article-x-face-too-ugly
1962 ;; We display the face.
1963 (if (symbolp gnus-article-x-face-command)
1964 ;; The command is a lisp function, so we call it.
1965 (if (gnus-functionp gnus-article-x-face-command)
1966 (funcall gnus-article-x-face-command face)
1967 (error "%s is not a function" gnus-article-x-face-command))
1968 ;; The command is a string, so we interpret the command
1969 ;; as a, well, command, and fork it off.
1970 (let ((process-connection-type nil))
1971 (process-kill-without-query
1973 "article-x-face" nil shell-file-name shell-command-switch
1974 gnus-article-x-face-command))
1977 (process-send-region "article-x-face"
1978 (point-min) (point-max)))
1979 (process-send-eof "article-x-face"))))))))))
1981 (defun article-decode-mime-words ()
1982 "Decode all MIME-encoded words in the article."
1985 (set-buffer gnus-article-buffer)
1986 (let ((inhibit-point-motion-hooks t)
1988 (mail-parse-charset gnus-newsgroup-charset)
1989 (mail-parse-ignored-charsets
1990 (save-excursion (set-buffer gnus-summary-buffer)
1991 gnus-newsgroup-ignored-charsets)))
1992 (mail-decode-encoded-word-region (point-min) (point-max)))))
1994 (defun article-decode-charset (&optional prompt)
1995 "Decode charset-encoded text in the article.
1996 If PROMPT (the prefix), prompt for a coding system to use."
1998 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2000 (mail-parse-charset gnus-newsgroup-charset)
2001 (mail-parse-ignored-charsets
2002 (save-excursion (condition-case nil
2003 (set-buffer gnus-summary-buffer)
2005 gnus-newsgroup-ignored-charsets))
2006 ct cte ctl charset format)
2009 (article-narrow-to-head)
2010 (setq ct (message-fetch-field "Content-Type" t)
2011 cte (message-fetch-field "Content-Transfer-Encoding" t)
2012 ctl (and ct (ignore-errors
2013 (mail-header-parse-content-type ct)))
2016 (mm-read-coding-system "Charset to decode: "))
2018 (mail-content-type-get ctl 'charset)))
2019 format (and ctl (mail-content-type-get ctl 'format)))
2021 (setq cte (mail-header-strip cte)))
2022 (if (and ctl (not (string-match "/" (car ctl))))
2024 (goto-char (point-max)))
2027 (narrow-to-region (point) (point-max))
2028 (when (and (eq mail-parse-charset 'gnus-decoded)
2029 (eq (mm-body-7-or-8) '8bit))
2030 ;; The text code could have been decoded.
2031 (setq charset mail-parse-charset))
2032 (when (and (or (not ctl)
2033 (equal (car ctl) "text/plain"))
2034 (not format)) ;; article with format will decode later.
2036 charset (and cte (intern (downcase
2037 (gnus-strip-whitespace cte))))
2040 (defun article-decode-encoded-words ()
2041 "Remove encoded-word encoding from headers."
2042 (let ((inhibit-point-motion-hooks t)
2043 (mail-parse-charset gnus-newsgroup-charset)
2044 (mail-parse-ignored-charsets
2045 (save-excursion (condition-case nil
2046 (set-buffer gnus-summary-buffer)
2048 gnus-newsgroup-ignored-charsets))
2051 (article-narrow-to-head)
2052 (funcall gnus-decode-header-function (point-min) (point-max)))))
2054 (defun article-decode-group-name ()
2055 "Decode group names in `Newsgroups:'."
2056 (let ((inhibit-point-motion-hooks t)
2058 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2059 (when (and (or gnus-group-name-charset-method-alist
2060 gnus-group-name-charset-group-alist)
2061 (gnus-buffer-live-p gnus-original-article-buffer))
2062 (when (nnmail-fetch-field "Newsgroups")
2063 (nnheader-replace-header "Newsgroups"
2064 (gnus-decode-newsgroups
2065 (with-current-buffer
2066 gnus-original-article-buffer
2067 (nnmail-fetch-field "Newsgroups"))
2068 gnus-newsgroup-name method)))
2069 (when (nnmail-fetch-field "Followup-To")
2070 (nnheader-replace-header "Followup-To"
2071 (gnus-decode-newsgroups
2072 (with-current-buffer
2073 gnus-original-article-buffer
2074 (nnmail-fetch-field "Followup-To"))
2075 gnus-newsgroup-name method))))))
2077 (defun article-de-quoted-unreadable (&optional force read-charset)
2078 "Translate a quoted-printable-encoded article.
2079 If FORCE, decode the article whether it is marked as quoted-printable
2081 If READ-CHARSET, ask for a coding system."
2082 (interactive (list 'force current-prefix-arg))
2084 (let ((buffer-read-only nil) type charset)
2085 (if (gnus-buffer-live-p gnus-original-article-buffer)
2086 (with-current-buffer gnus-original-article-buffer
2088 (gnus-fetch-field "content-transfer-encoding"))
2089 (let* ((ct (gnus-fetch-field "content-type"))
2092 (mail-header-parse-content-type ct)))))
2093 (setq charset (and ctl
2094 (mail-content-type-get ctl 'charset)))
2095 (if (stringp charset)
2096 (setq charset (intern (downcase charset)))))))
2098 (setq charset (mm-read-coding-system "Charset: " charset)))
2100 (setq charset gnus-newsgroup-charset))
2102 (and type (let ((case-fold-search t))
2103 (string-match "quoted-printable" type))))
2105 (quoted-printable-decode-region
2106 (point) (point-max) (mm-charset-to-coding-system charset))))))
2108 (defun article-de-base64-unreadable (&optional force read-charset)
2109 "Translate a base64 article.
2110 If FORCE, decode the article whether it is marked as base64 not.
2111 If READ-CHARSET, ask for a coding system."
2112 (interactive (list 'force current-prefix-arg))
2114 (let ((buffer-read-only nil) type charset)
2115 (if (gnus-buffer-live-p gnus-original-article-buffer)
2116 (with-current-buffer gnus-original-article-buffer
2118 (gnus-fetch-field "content-transfer-encoding"))
2119 (let* ((ct (gnus-fetch-field "content-type"))
2122 (mail-header-parse-content-type ct)))))
2123 (setq charset (and ctl
2124 (mail-content-type-get ctl 'charset)))
2125 (if (stringp charset)
2126 (setq charset (intern (downcase charset)))))))
2128 (setq charset (mm-read-coding-system "Charset: " charset)))
2130 (setq charset gnus-newsgroup-charset))
2132 (and type (let ((case-fold-search t))
2133 (string-match "base64" type))))
2136 (narrow-to-region (point) (point-max))
2137 (base64-decode-region (point-min) (point-max))
2138 (mm-decode-coding-region
2139 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2144 (defun article-decode-HZ ()
2145 "Translate a HZ-encoded article."
2149 (let ((buffer-read-only nil))
2150 (rfc1843-decode-region (point-min) (point-max)))))
2152 (defun article-unsplit-urls ()
2153 "Remove the newlines that some other mailers insert into URLs."
2156 (let ((buffer-read-only nil))
2157 (goto-char (point-min))
2158 (while (re-search-forward
2159 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2160 (replace-match "\\1\\3" t)))
2161 (when (and gnus-display-mime-function (interactive-p))
2162 (funcall gnus-display-mime-function))))
2165 (defun article-wash-html (&optional read-charset)
2166 "Format an html article.
2167 If READ-CHARSET, ask for a coding system."
2170 (let ((buffer-read-only nil)
2172 (if (gnus-buffer-live-p gnus-original-article-buffer)
2173 (with-current-buffer gnus-original-article-buffer
2174 (let* ((ct (gnus-fetch-field "content-type"))
2177 (mail-header-parse-content-type ct)))))
2178 (setq charset (and ctl
2179 (mail-content-type-get ctl 'charset)))
2180 (if (stringp charset)
2181 (setq charset (intern (downcase charset)))))))
2183 (setq charset (mm-read-coding-system "Charset: " charset)))
2185 (setq charset gnus-newsgroup-charset))
2187 (save-window-excursion
2189 (narrow-to-region (point) (point-max))
2190 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2191 (entry (assq func mm-text-html-washer-alist)))
2193 (setq func (cdr entry)))
2195 ((gnus-functionp func)
2198 (apply (car func) (cdr func))))))))))
2200 (defun gnus-article-wash-html-with-w3 ()
2201 "Wash the current buffer with w3."
2203 (let ((w3-strict-width (window-width))
2204 (url-standalone-mode t)
2205 (url-gateway-unplugged t)
2206 (w3-honor-stylesheets nil))
2208 (w3-region (point-min) (point-max))
2211 (defun gnus-article-wash-html-with-w3m ()
2212 "Wash the current buffer with emacs-w3m."
2215 (narrow-to-region (point) (point-max))
2216 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2219 (w3m-display-inline-images mm-inline-text-html-with-images)
2220 w3m-force-redisplay)
2221 (w3m-region (point-min) (point-max)))
2222 (when mm-inline-text-html-with-w3m-keymap
2223 (add-text-properties
2224 (point-min) (point-max)
2225 (nconc (mm-w3m-local-map-property)
2226 '(mm-inline-text-html-with-w3m t))))))
2228 (defun article-hide-list-identifiers ()
2229 "Remove list identifies from the Subject header.
2230 The `gnus-list-identifiers' variable specifies what to do."
2232 (let ((inhibit-point-motion-hooks t)
2233 (regexp (if (consp gnus-list-identifiers)
2234 (mapconcat 'identity gnus-list-identifiers " *\\|")
2235 gnus-list-identifiers))
2240 (article-narrow-to-head)
2241 (goto-char (point-min))
2242 (while (re-search-forward
2243 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2245 (delete-region (match-beginning 2) (match-end 0))
2246 (beginning-of-line))
2247 (when (re-search-forward
2248 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2249 (delete-region (match-beginning 1) (match-end 1))))))))
2251 (defun article-hide-pgp ()
2252 "Remove any PGP headers and signatures in the current article."
2256 (let ((inhibit-point-motion-hooks t)
2257 buffer-read-only beg end)
2259 ;; Hide the "header".
2260 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2261 (gnus-add-wash-type 'pgp)
2262 (delete-region (match-beginning 0) (match-end 0))
2263 ;; Remove armor headers (rfc2440 6.2)
2264 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2267 ;; Hide the actual signature.
2268 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2269 (setq end (1+ (match-beginning 0)))
2272 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2274 ;; Perhaps we shouldn't hide to the end of the buffer
2275 ;; if there is no end to the signature?
2277 ;; Hide "- " PGP quotation markers.
2279 (narrow-to-region beg end)
2280 (goto-char (point-min))
2281 (while (re-search-forward "^- " nil t)
2283 (match-beginning 0) (match-end 0)))
2285 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2287 (defun article-hide-pem (&optional arg)
2288 "Toggle hiding of any PEM headers and signatures in the current article.
2289 If given a negative prefix, always show; if given a positive prefix,
2291 (interactive (gnus-article-hidden-arg))
2292 (unless (gnus-article-check-hidden-text 'pem arg)
2294 (let (buffer-read-only end)
2295 (goto-char (point-min))
2296 ;; Hide the horrendously ugly "header".
2297 (when (and (search-forward
2298 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2300 (setq end (1+ (match-beginning 0))))
2301 (gnus-add-wash-type 'pem)
2302 (gnus-article-hide-text-type
2304 (if (search-forward "\n\n" nil t)
2308 ;; Hide the trailer as well
2309 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2311 (gnus-article-hide-text-type
2312 (match-beginning 0) (match-end 0) 'pem)))))))
2314 (defun article-strip-banner ()
2315 "Strip the banner specified by the `banner' group parameter."
2319 (let ((inhibit-point-motion-hooks t)
2320 (banner (gnus-parameter-banner gnus-newsgroup-name))
2321 (gnus-signature-limit nil)
2322 buffer-read-only beg end)
2323 (when (and gnus-article-address-banner-alist
2326 (let ((from (save-restriction
2328 (article-narrow-to-head)
2329 (mail-fetch-field "from"))))
2332 (caar (mail-header-parse-addresses from))))
2334 (dolist (pair gnus-article-address-banner-alist)
2335 (when (string-match (car pair) from)
2336 (throw 'found (cdr pair)))))))))
2340 ((eq banner 'signature)
2341 (when (gnus-article-narrow-to-signature)
2344 (delete-region (point) (point-max))))
2346 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2347 (while (re-search-forward banner nil t)
2348 (delete-region (match-beginning 0) (match-end 0)))))
2350 (while (re-search-forward banner nil t)
2351 (delete-region (match-beginning 0) (match-end 0))))))))))
2353 (defun article-babel ()
2354 "Translate article using an online translation service."
2358 (set-buffer gnus-article-buffer)
2359 (when (article-goto-body)
2360 (let* ((buffer-read-only nil)
2363 (orig (buffer-substring start end))
2364 (trans (babel-as-string orig)))
2366 (narrow-to-region start end)
2367 (delete-region start end)
2370 (defun article-hide-signature (&optional arg)
2371 "Hide the signature in the current article.
2372 If given a negative prefix, always show; if given a positive prefix,
2374 (interactive (gnus-article-hidden-arg))
2375 (unless (gnus-article-check-hidden-text 'signature arg)
2378 (let ((buffer-read-only nil))
2379 (when (gnus-article-narrow-to-signature)
2380 (gnus-article-hide-text-type
2381 (point-min) (point-max) 'signature))))))
2382 (gnus-set-mode-line 'article))
2384 (defun article-strip-headers-in-body ()
2385 "Strip offensive headers from bodies."
2389 (let ((case-fold-search t))
2390 (when (looking-at "x-no-archive:")
2391 (gnus-delete-line)))))
2393 (defun article-strip-leading-blank-lines ()
2394 "Remove all blank lines from the beginning of the article."
2397 (let ((inhibit-point-motion-hooks t)
2399 (when (article-goto-body)
2400 (while (and (not (eobp))
2401 (looking-at "[ \t]*$"))
2402 (gnus-delete-line))))))
2404 (defun article-narrow-to-head ()
2405 "Narrow the buffer to the head of the message.
2406 Point is left at the beginning of the narrowed-to region."
2408 (goto-char (point-min))
2409 (if (search-forward "\n\n" nil 1)
2412 (goto-char (point-min)))
2414 (defun article-goto-body ()
2415 "Place point at the start of the body."
2416 (goto-char (point-min))
2418 ;; This variable is only bound when dealing with separate
2420 (article-goto-body-goes-to-point-min-p
2422 ((search-forward "\n\n" nil t)
2425 (goto-char (point-max))
2428 (defun article-strip-multiple-blank-lines ()
2429 "Replace consecutive blank lines with one empty line."
2432 (let ((inhibit-point-motion-hooks t)
2434 ;; First make all blank lines empty.
2436 (while (re-search-forward "^[ \t]+$" nil t)
2437 (unless (gnus-annotation-in-region-p
2438 (match-beginning 0) (match-end 0))
2439 (replace-match "" nil t)))
2440 ;; Then replace multiple empty lines with a single empty line.
2442 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2443 (unless (gnus-annotation-in-region-p
2444 (match-beginning 0) (match-end 0))
2445 (delete-region (match-beginning 1) (match-end 1)))))))
2447 (defun article-strip-leading-space ()
2448 "Remove all white space from the beginning of the lines in the article."
2451 (let ((inhibit-point-motion-hooks t)
2454 (while (re-search-forward "^[ \t]+" nil t)
2455 (replace-match "" t t)))))
2457 (defun article-strip-trailing-space ()
2458 "Remove all white space from the end of the lines in the article."
2461 (let ((inhibit-point-motion-hooks t)
2464 (while (re-search-forward "[ \t]+$" nil t)
2465 (replace-match "" t t)))))
2467 (defun article-strip-blank-lines ()
2468 "Strip leading, trailing and multiple blank lines."
2470 (article-strip-leading-blank-lines)
2471 (article-remove-trailing-blank-lines)
2472 (article-strip-multiple-blank-lines))
2474 (defun article-strip-all-blank-lines ()
2475 "Strip all blank lines."
2478 (let ((inhibit-point-motion-hooks t)
2481 (while (re-search-forward "^[ \t]*\n" nil t)
2482 (replace-match "" t t)))))
2484 (defun gnus-article-narrow-to-signature ()
2485 "Narrow to the signature; return t if a signature is found, else nil."
2486 (let ((inhibit-point-motion-hooks t))
2487 (when (gnus-article-search-signature)
2489 ;; Check whether we have some limits to what we consider
2490 ;; to be a signature.
2491 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2492 (list gnus-signature-limit)))
2494 (while (setq limit (pop limits))
2495 (if (or (and (integerp limit)
2496 (< (- (point-max) (point)) limit))
2498 (< (count-lines (point) (point-max)) limit))
2499 (and (gnus-functionp limit)
2501 (and (stringp limit)
2502 (not (re-search-forward limit nil t))))
2503 () ; This limit did not succeed.
2507 (narrow-to-region (point) (point-max))
2510 (defun gnus-article-search-signature ()
2511 "Search the current buffer for the signature separator.
2512 Put point at the beginning of the signature separator."
2513 (let ((cur (point)))
2514 (goto-char (point-max))
2515 (if (if (stringp gnus-signature-separator)
2516 (re-search-backward gnus-signature-separator nil t)
2517 (let ((seps gnus-signature-separator))
2519 (not (re-search-backward (car seps) nil t)))
2526 (defun gnus-article-hidden-arg ()
2527 "Return the current prefix arg as a number, or 0 if no prefix."
2528 (list (if current-prefix-arg
2529 (prefix-numeric-value current-prefix-arg)
2532 (defun gnus-article-check-hidden-text (type arg)
2533 "Return nil if hiding is necessary.
2534 Arg can be nil or a number. nil and positive means hide, negative
2535 means show, 0 means toggle."
2538 (let ((hide (gnus-article-hidden-text-p type)))
2544 (gnus-article-show-hidden-text type)
2547 (if (eq hide 'hidden)
2549 (gnus-article-show-hidden-text type)
2553 (defun gnus-article-hidden-text-p (type)
2554 "Say whether the current buffer contains hidden text of type TYPE."
2555 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2557 (not (get-text-property pos 'invisible))
2558 (not (get-text-property pos 'dummy-invisible)))
2560 (text-property-any (1+ pos) (point-max) 'article-type type)))
2565 (defun gnus-article-show-hidden-text (type &optional dummy)
2566 "Show all hidden text of type TYPE.
2567 Originally it is hide instead of DUMMY."
2568 (let ((buffer-read-only nil)
2569 (inhibit-point-motion-hooks t))
2570 (gnus-remove-text-properties-when
2572 (point-min) (point-max)
2573 (cons 'article-type (cons type
2574 gnus-hidden-properties)))
2575 (gnus-delete-wash-type type)))
2577 (defconst article-time-units
2578 `((year . ,(* 365.25 24 60 60))
2579 (week . ,(* 7 24 60 60))
2580 (day . ,(* 24 60 60))
2584 "Mapping from time units to seconds.")
2586 (defun article-date-ut (&optional type highlight header)
2587 "Convert DATE date to universal time in the current article.
2588 If TYPE is `local', convert to local time; if it is `lapsed', output
2589 how much time has lapsed since DATE. For `lapsed', the value of
2590 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2591 should replace the \"Date:\" one, or should be added below it."
2592 (interactive (list 'ut t))
2593 (let* ((header (or header
2594 (message-fetch-field "date")
2596 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2599 ((not gnus-article-date-lapsed-new-header)
2605 (date (if (vectorp header) (mail-header-date header)
2607 (inhibit-point-motion-hooks t)
2612 (article-narrow-to-head)
2613 (when (re-search-forward tdate-regexp nil t)
2614 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2615 date (or (get-text-property (gnus-point-at-bol)
2618 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2620 (when (and date (not (string= date "")))
2621 (goto-char (point-min))
2622 (let ((buffer-read-only nil))
2623 ;; Delete any old Date headers.
2624 (while (re-search-forward date-regexp nil t)
2626 (delete-region (progn (beginning-of-line) (point))
2627 (progn (forward-line 1) (point)))
2628 (delete-region (progn (beginning-of-line) (point))
2629 (progn (end-of-line) (point)))
2630 (setq pos (point))))
2631 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2633 (if pos (goto-char pos))
2634 (insert (article-make-date-line date (or type 'ut)))
2640 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2641 (put-text-property (match-beginning 1) (1+ (match-end 1))
2642 'original-date date)
2643 (put-text-property (match-beginning 1) (1+ (match-end 1))
2645 (put-text-property (match-beginning 2) (match-end 2)
2648 (defun article-make-date-line (date type)
2649 "Return a DATE line of TYPE."
2650 (unless (memq type '(local ut original user iso8601 lapsed english))
2651 (error "Unknown conversion type: %s" type))
2653 (let ((time (date-to-time date)))
2655 ;; Convert to the local timezone.
2657 (let ((tz (car (current-time-zone time))))
2658 (format "Date: %s %s%02d%02d" (current-time-string time)
2659 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2660 (/ (% (abs tz) 3600) 60))))
2661 ;; Convert to Universal Time.
2664 (current-time-string
2665 (let* ((e (parse-time-string date))
2666 (tm (apply 'encode-time e))
2668 (ls (- (cadr tm) (car (current-time-zone time)))))
2669 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2670 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2673 ;; Get the original date from the article.
2674 ((eq type 'original)
2675 (concat "Date: " (if (string-match "\n+$" date)
2676 (substring date 0 (match-beginning 0))
2678 ;; Let the user define the format.
2680 (let ((format (or (condition-case nil
2681 (with-current-buffer gnus-summary-buffer
2682 gnus-article-time-format)
2684 gnus-article-time-format)))
2685 (if (gnus-functionp format)
2686 (funcall format time)
2687 (concat "Date: " (format-time-string format time)))))
2690 (let ((tz (car (current-time-zone time))))
2693 (format-time-string "%Y%m%dT%H%M%S" time)
2694 (format "%s%02d%02d"
2695 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2696 (/ (% (abs tz) 3600) 60)))))
2697 ;; Do an X-Sent lapsed format.
2699 ;; If the date is seriously mangled, the timezone functions are
2700 ;; liable to bug out, so we ignore all errors.
2701 (let* ((now (current-time))
2702 (real-time (subtract-time now time))
2703 (real-sec (and real-time
2704 (+ (* (float (car real-time)) 65536)
2706 (sec (and real-time (abs real-sec)))
2716 ;; This is a bit convoluted, but basically we go
2717 ;; through the time units for years, weeks, etc,
2718 ;; and divide things to see whether that results
2719 ;; in positive answers.
2722 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2723 ;; The (remaining) seconds are too few to
2724 ;; be divided into this time unit.
2726 ;; It's big enough, so we output it.
2727 (setq sec (- sec (* num (cdr unit))))
2729 (concat (if prev ", " "") (int-to-string
2731 " " (symbol-name (car unit))
2732 (if (> num 1) "s" ""))
2734 article-time-units "")
2735 ;; If dates are odd, then it might appear like the
2736 ;; article was sent in the future.
2739 " in the future"))))))
2740 ;; Display the date in proper English
2742 (let ((dtime (decode-time time)))
2745 (number-to-string (nth 3 dtime))
2746 (let ((digit (% (nth 3 dtime) 10)))
2748 ((memq (nth 3 dtime) '(11 12 13)) "th")
2754 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2756 (number-to-string (nth 5 dtime))
2758 (format "%02d" (nth 2 dtime))
2760 (format "%02d" (nth 1 dtime)))))))
2762 (format "Date: %s (from Gnus)" date))))
2764 (defun article-date-local (&optional highlight)
2765 "Convert the current article date to the local timezone."
2766 (interactive (list t))
2767 (article-date-ut 'local highlight))
2769 (defun article-date-english (&optional highlight)
2770 "Convert the current article date to something that is proper English."
2771 (interactive (list t))
2772 (article-date-ut 'english highlight))
2774 (defun article-date-original (&optional highlight)
2775 "Convert the current article date to what it was originally.
2776 This is only useful if you have used some other date conversion
2777 function and want to see what the date was before converting."
2778 (interactive (list t))
2779 (article-date-ut 'original highlight))
2781 (defun article-date-lapsed (&optional highlight)
2782 "Convert the current article date to time lapsed since it was sent."
2783 (interactive (list t))
2784 (article-date-ut 'lapsed highlight))
2786 (defun article-update-date-lapsed ()
2787 "Function to be run from a timer to update the lapsed time line."
2788 (let (deactivate-mark)
2793 (set-buffer (window-buffer w))
2794 (when (eq major-mode 'gnus-article-mode)
2795 (goto-char (point-min))
2796 (when (re-search-forward "^X-Sent:" nil t)
2797 (article-date-lapsed t))))
2800 (defun gnus-start-date-timer (&optional n)
2801 "Start a timer to update the X-Sent header in the article buffers.
2802 The numerical prefix says how frequently (in seconds) the function
2807 (gnus-stop-date-timer)
2808 (setq article-lapsed-timer
2809 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2811 (defun gnus-stop-date-timer ()
2812 "Stop the X-Sent timer."
2814 (when article-lapsed-timer
2815 (nnheader-cancel-timer article-lapsed-timer)
2816 (setq article-lapsed-timer nil)))
2818 (defun article-date-user (&optional highlight)
2819 "Convert the current article date to the user-defined format.
2820 This format is defined by the `gnus-article-time-format' variable."
2821 (interactive (list t))
2822 (article-date-ut 'user highlight))
2824 (defun article-date-iso8601 (&optional highlight)
2825 "Convert the current article date to ISO8601."
2826 (interactive (list t))
2827 (article-date-ut 'iso8601 highlight))
2829 ;; (defun article-show-all ()
2830 ;; "Show all hidden text in the article buffer."
2833 ;; (let ((buffer-read-only nil))
2834 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2836 (defun article-remove-leading-whitespace ()
2837 "Remove excessive whitespace from all headers."
2841 (let ((buffer-read-only nil))
2842 (article-narrow-to-head)
2843 (goto-char (point-min))
2844 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2845 (delete-region (match-beginning 1) (match-end 1)))))))
2847 (defun article-emphasize (&optional arg)
2848 "Emphasize text according to `gnus-emphasis-alist'."
2849 (interactive (gnus-article-hidden-arg))
2850 (unless (gnus-article-check-hidden-text 'emphasis arg)
2854 (with-current-buffer gnus-summary-buffer
2855 gnus-article-emphasis-alist)
2857 gnus-emphasis-alist))
2858 (buffer-read-only nil)
2859 (props (append '(article-type emphasis)
2860 gnus-hidden-properties))
2861 regexp elem beg invisible visible face)
2864 (while (setq elem (pop alist))
2866 (setq regexp (car elem)
2867 invisible (nth 1 elem)
2868 visible (nth 2 elem)
2870 (while (re-search-forward regexp nil t)
2871 (when (and (match-beginning visible) (match-beginning invisible))
2872 (gnus-article-hide-text
2873 (match-beginning invisible) (match-end invisible) props)
2874 (gnus-article-unhide-text-type
2875 (match-beginning visible) (match-end visible) 'emphasis)
2876 (gnus-put-overlay-excluding-newlines
2877 (match-beginning visible) (match-end visible) 'face face)
2878 (gnus-add-wash-type 'emphasis)
2879 (goto-char (match-end invisible)))))))))
2881 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2882 "Setup newsgroup emphasis alist."
2883 (unless gnus-article-emphasis-alist
2884 (let ((name (and gnus-newsgroup-name
2885 (gnus-group-real-name gnus-newsgroup-name))))
2886 (make-local-variable 'gnus-article-emphasis-alist)
2887 (setq gnus-article-emphasis-alist
2889 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2890 (while (setq elem (pop alist))
2891 (when (and name (string-match (car elem) name))
2893 highlight (copy-sequence (cdr elem)))))
2895 (copy-sequence highlight-words)
2896 (if gnus-newsgroup-name
2897 (copy-sequence (gnus-group-find-parameter
2898 gnus-newsgroup-name 'highlight-words t)))
2899 gnus-emphasis-alist)))))
2902 (defvar gnus-summary-article-menu)
2903 (defvar gnus-summary-post-menu))
2905 ;;; Saving functions.
2907 (defun gnus-article-save (save-buffer file &optional num)
2908 "Save the currently selected article."
2909 (unless gnus-save-all-headers
2910 ;; Remove headers according to `gnus-saved-headers'.
2911 (let ((gnus-visible-headers
2912 (or gnus-saved-headers gnus-visible-headers))
2913 (gnus-article-buffer save-buffer))
2915 (set-buffer save-buffer)
2916 (article-hide-headers 1 t))))
2917 (save-window-excursion
2918 (if (not gnus-default-article-saver)
2919 (error "No default saver is defined")
2920 ;; !!! Magic! The saving functions all save
2921 ;; `gnus-save-article-buffer' (or so they think), but we
2922 ;; bind that variable to our save-buffer.
2923 (set-buffer gnus-article-buffer)
2924 (let* ((gnus-save-article-buffer save-buffer)
2927 ((not gnus-prompt-before-saving) 'default)
2928 ((eq gnus-prompt-before-saving 'always) nil)
2930 (gnus-number-of-articles-to-be-saved
2931 (when (eq gnus-prompt-before-saving t)
2933 (set-buffer gnus-article-current-summary)
2934 (funcall gnus-default-article-saver filename)))))
2936 (defun gnus-read-save-file-name (prompt &optional filename
2937 function group headers variable)
2939 (funcall function group headers (symbol-value variable)))
2944 ((eq filename 'default)
2950 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2953 (if (and gnus-number-of-articles-to-be-saved
2954 (> gnus-number-of-articles-to-be-saved 1))
2955 (format "these %d articles"
2956 gnus-number-of-articles-to-be-saved)
2959 ;; Let the split methods have their say.
2961 ;; No split name was found.
2964 (concat prompt " (default "
2965 (file-name-nondirectory default-name) ") ")
2966 (file-name-directory default-name)
2968 ;; A single group name is returned.
2969 ((stringp split-name)
2971 (funcall function split-name headers
2972 (symbol-value variable)))
2974 (concat prompt " (default "
2975 (file-name-nondirectory default-name) ") ")
2976 (file-name-directory default-name)
2978 ;; A single split name was found
2979 ((= 1 (length split-name))
2980 (let* ((name (expand-file-name
2982 gnus-article-save-directory))
2983 (dir (cond ((file-directory-p name)
2984 (file-name-as-directory name))
2985 ((file-exists-p name) name)
2986 (t gnus-article-save-directory))))
2988 (concat prompt " (default " name ") ")
2990 ;; A list of splits was found.
2992 (setq split-name (nreverse split-name))
2994 (let ((file-name-history
2995 (nconc split-name file-name-history)))
2999 (concat prompt " (`M-p' for defaults) ")
3000 gnus-article-save-directory
3002 gnus-article-save-directory)))
3003 (car (push result file-name-history)))))))
3004 ;; Create the directory.
3005 (gnus-make-directory (file-name-directory file))
3006 ;; If we have read a directory, we append the default file name.
3007 (when (file-directory-p file)
3008 (setq file (expand-file-name (file-name-nondirectory
3010 (file-name-as-directory file))))
3011 ;; Possibly translate some characters.
3012 (nnheader-translate-file-chars file))))))
3013 (gnus-make-directory (file-name-directory result))
3014 (set variable result)))
3016 (defun gnus-article-archive-name (group)
3017 "Return the first instance of an \"Archive-name\" in the current buffer."
3018 (let ((case-fold-search t))
3019 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3020 (nnheader-concat gnus-article-save-directory
3021 (match-string 1)))))
3023 (defun gnus-article-nndoc-name (group)
3024 "If GROUP is an nndoc group, return the name of the parent group."
3025 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3026 (gnus-group-get-parameter group 'save-article-group)))
3028 (defun gnus-summary-save-in-rmail (&optional filename)
3029 "Append this article to Rmail file.
3030 Optional argument FILENAME specifies file name.
3031 Directory to save to is default to `gnus-article-save-directory'."
3032 (setq filename (gnus-read-save-file-name
3033 "Save %s in rmail file:" filename
3034 gnus-rmail-save-name gnus-newsgroup-name
3035 gnus-current-headers 'gnus-newsgroup-last-rmail))
3036 (gnus-eval-in-buffer-window gnus-save-article-buffer
3040 (gnus-output-to-rmail filename))))
3043 (defun gnus-summary-save-in-mail (&optional filename)
3044 "Append this article to Unix mail file.
3045 Optional argument FILENAME specifies file name.
3046 Directory to save to is default to `gnus-article-save-directory'."
3047 (setq filename (gnus-read-save-file-name
3048 "Save %s in Unix mail file:" filename
3049 gnus-mail-save-name gnus-newsgroup-name
3050 gnus-current-headers 'gnus-newsgroup-last-mail))
3051 (gnus-eval-in-buffer-window gnus-save-article-buffer
3055 (if (and (file-readable-p filename)
3056 (mail-file-babyl-p filename))
3057 (rmail-output-to-rmail-file filename t)
3058 (gnus-output-to-mail filename)))))
3061 (defun gnus-summary-save-in-file (&optional filename overwrite)
3062 "Append this article to file.
3063 Optional argument FILENAME specifies file name.
3064 Directory to save to is default to `gnus-article-save-directory'."
3065 (setq filename (gnus-read-save-file-name
3066 "Save %s in file:" filename
3067 gnus-file-save-name gnus-newsgroup-name
3068 gnus-current-headers 'gnus-newsgroup-last-file))
3069 (gnus-eval-in-buffer-window gnus-save-article-buffer
3073 (when (and overwrite
3074 (file-exists-p filename))
3075 (delete-file filename))
3076 (gnus-output-to-file filename))))
3079 (defun gnus-summary-write-to-file (&optional filename)
3080 "Write this article to a file, overwriting it if the file exists.
3081 Optional argument FILENAME specifies file name.
3082 The directory to save in defaults to `gnus-article-save-directory'."
3083 (gnus-summary-save-in-file nil t))
3085 (defun gnus-summary-save-body-in-file (&optional filename)
3086 "Append this article body to a file.
3087 Optional argument FILENAME specifies file name.
3088 The directory to save in defaults to `gnus-article-save-directory'."
3089 (setq filename (gnus-read-save-file-name
3090 "Save %s body in file:" filename
3091 gnus-file-save-name gnus-newsgroup-name
3092 gnus-current-headers 'gnus-newsgroup-last-file))
3093 (gnus-eval-in-buffer-window gnus-save-article-buffer
3097 (when (article-goto-body)
3098 (narrow-to-region (point) (point-max)))
3099 (gnus-output-to-file filename))))
3102 (defun gnus-summary-save-in-pipe (&optional command)
3103 "Pipe this article to subprocess."
3105 (cond ((and (eq command 'default)
3106 gnus-last-shell-command)
3107 gnus-last-shell-command)
3112 "Shell command on %s: "
3113 (if (and gnus-number-of-articles-to-be-saved
3114 (> gnus-number-of-articles-to-be-saved 1))
3115 (format "these %d articles"
3116 gnus-number-of-articles-to-be-saved)
3118 gnus-last-shell-command))))
3119 (when (string-equal command "")
3120 (if gnus-last-shell-command
3121 (setq command gnus-last-shell-command)
3122 (error "A command is required")))
3123 (gnus-eval-in-buffer-window gnus-article-buffer
3126 (shell-command-on-region (point-min) (point-max) command nil)))
3127 (setq gnus-last-shell-command command))
3129 (defun gnus-summary-pipe-to-muttprint (&optional command)
3130 "Pipe this article to muttprint."
3131 (setq command (read-string
3132 "Print using command: " gnus-summary-muttprint-program
3133 nil gnus-summary-muttprint-program))
3134 (gnus-summary-save-in-pipe command))
3136 ;;; Article file names when saving.
3138 (defun gnus-capitalize-newsgroup (newsgroup)
3139 "Capitalize NEWSGROUP name."
3140 (when (not (zerop (length newsgroup)))
3141 (concat (char-to-string (upcase (aref newsgroup 0)))
3142 (substring newsgroup 1))))
3144 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3145 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3146 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3147 Otherwise, it is like ~/News/news/group/num."
3150 (concat (if (gnus-use-long-file-name 'not-save)
3151 (gnus-capitalize-newsgroup newsgroup)
3152 (gnus-newsgroup-directory-form newsgroup))
3153 "/" (int-to-string (mail-header-number headers)))
3154 gnus-article-save-directory)))
3156 (string-equal (file-name-directory default)
3157 (file-name-directory last-file))
3158 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3160 (or last-file default))))
3162 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3163 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3164 If variable `gnus-use-long-file-name' is non-nil, it is
3165 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3168 (concat (if (gnus-use-long-file-name 'not-save)
3170 (gnus-newsgroup-directory-form newsgroup))
3171 "/" (int-to-string (mail-header-number headers)))
3172 gnus-article-save-directory)))
3174 (string-equal (file-name-directory default)
3175 (file-name-directory last-file))
3176 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3178 (or last-file default))))
3180 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3181 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3182 If variable `gnus-use-long-file-name' is non-nil, it is
3183 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3186 (if (gnus-use-long-file-name 'not-save)
3189 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3191 gnus-article-save-directory)))
3193 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3194 "Generate file name from sender."
3195 (let ((from (mail-header-from headers)))
3197 (if (and from (string-match "\\([^ <]+\\)@" from))
3198 (match-string 1 from)
3200 gnus-article-save-directory)))
3202 (defun article-verify-x-pgp-sig ()
3205 (if (gnus-buffer-live-p gnus-original-article-buffer)
3206 (let ((sig (with-current-buffer gnus-original-article-buffer
3207 (gnus-fetch-field "X-PGP-Sig")))
3211 (mml2015-clear-verify-function))
3213 (insert-buffer gnus-original-article-buffer)
3214 (setq items (split-string sig))
3215 (message-narrow-to-head)
3216 (let ((inhibit-point-motion-hooks t)
3217 (case-fold-search t))
3218 ;; Don't verify multiple headers.
3219 (setq headers (mapconcat (lambda (header)
3221 (mail-fetch-field header) "\n"))
3222 (split-string (nth 1 items) ",") "")))
3223 (delete-region (point-min) (point-max))
3224 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3225 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3230 (if (looking-at "^-")
3233 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3234 (insert "Version: " (car items) "\n\n")
3235 (insert (mapconcat 'identity (cddr items) "\n"))
3236 (insert "\n-----END PGP SIGNATURE-----\n")
3237 (let ((mm-security-handle (list (format "multipart/signed"))))
3238 (mml2015-clean-buffer)
3239 (let ((coding-system-for-write (or gnus-newsgroup-charset
3241 (funcall (mml2015-clear-verify-function)))
3243 (or (mm-handle-multipart-ctl-parameter
3244 mm-security-handle 'gnus-details)
3245 (mm-handle-multipart-ctl-parameter
3246 mm-security-handle 'gnus-info)))))
3248 (let (buffer-read-only bface eface)
3250 (message-narrow-to-head)
3251 (goto-char (point-max))
3253 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3254 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3255 (message-remove-header "X-Gnus-PGP-Verify")
3256 (if (re-search-forward "^X-PGP-Sig:" nil t)
3258 (goto-char (point-max)))
3259 (narrow-to-region (point) (point))
3260 (insert "X-Gnus-PGP-Verify: " info "\n")
3261 (goto-char (point-min))
3264 (if (not (looking-at "^[ \t]"))
3268 (goto-char (point-min))
3269 (when (looking-at "\\([^:]+\\): *")
3270 (put-text-property (match-beginning 1) (1+ (match-end 1))
3272 (put-text-property (match-end 0) (point-max)
3273 'face eface)))))))))
3275 (defun article-verify-cancel-lock ()
3276 "Verify Cancel-Lock header."
3278 (if (gnus-buffer-live-p gnus-original-article-buffer)
3279 (canlock-verify gnus-original-article-buffer)))
3286 (setq afunc (car func)
3289 gfunc (intern (format "gnus-%s" func))))
3291 (when (fboundp afunc)
3292 `(lambda (&optional interactive &rest args)
3293 ,(documentation afunc t)
3294 (interactive (list t))
3296 (set-buffer gnus-article-buffer)
3298 (call-interactively ',afunc)
3299 (apply ',afunc args))))))))
3300 '(article-hide-headers
3301 article-verify-x-pgp-sig
3302 article-verify-cancel-lock
3303 article-hide-boring-headers
3304 article-treat-overstrike
3305 article-fill-long-lines
3306 article-capitalize-sentences
3308 article-remove-leading-whitespace
3309 article-display-x-face
3310 article-de-quoted-unreadable
3311 article-de-base64-unreadable
3314 article-unsplit-urls
3315 article-hide-list-identifiers
3317 article-strip-banner
3320 article-hide-signature
3321 article-strip-headers-in-body
3322 article-remove-trailing-blank-lines
3323 article-strip-leading-blank-lines
3324 article-strip-multiple-blank-lines
3325 article-strip-leading-space
3326 article-strip-trailing-space
3327 article-strip-blank-lines
3328 article-strip-all-blank-lines
3330 article-date-english
3331 article-date-iso8601
3332 article-date-original
3334 article-decode-mime-words
3335 article-decode-charset
3336 article-decode-encoded-words
3340 article-treat-dumbquotes
3341 article-normalize-headers
3342 ;; (article-show-all . gnus-article-show-all-headers)
3346 ;;; Gnus article mode
3349 (put 'gnus-article-mode 'mode-class 'special)
3351 (set-keymap-parent gnus-article-mode-map widget-keymap)
3353 (gnus-define-keys gnus-article-mode-map
3354 " " gnus-article-goto-next-page
3355 "\177" gnus-article-goto-prev-page
3356 [delete] gnus-article-goto-prev-page
3357 [backspace] gnus-article-goto-prev-page
3358 "\C-c^" gnus-article-refer-article
3359 "h" gnus-article-show-summary
3360 "s" gnus-article-show-summary
3361 "\C-c\C-m" gnus-article-mail
3362 "?" gnus-article-describe-briefly
3363 "e" gnus-summary-edit-article
3364 "<" beginning-of-buffer
3366 "\C-c\C-i" gnus-info-find-node
3368 "R" gnus-article-reply-with-original
3369 "F" gnus-article-followup-with-original
3370 "\C-hk" gnus-article-describe-key
3371 "\C-hc" gnus-article-describe-key-briefly
3373 "\C-d" gnus-article-read-summary-keys
3374 "\M-*" gnus-article-read-summary-keys
3375 "\M-#" gnus-article-read-summary-keys
3376 "\M-^" gnus-article-read-summary-keys
3377 "\M-g" gnus-article-read-summary-keys)
3379 (substitute-key-definition
3380 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3382 (defun gnus-article-make-menu-bar ()
3383 (unless (boundp 'gnus-article-commands-menu)
3384 (gnus-summary-make-menu-bar))
3385 (gnus-turn-off-edit-menu 'article)
3386 (unless (boundp 'gnus-article-article-menu)
3388 gnus-article-article-menu gnus-article-mode-map ""
3390 ["Scroll forwards" gnus-article-goto-next-page t]
3391 ["Scroll backwards" gnus-article-goto-prev-page t]
3392 ["Show summary" gnus-article-show-summary t]
3393 ["Fetch Message-ID at point" gnus-article-refer-article t]
3394 ["Mail to address at point" gnus-article-mail t]
3395 ["Send a bug report" gnus-bug t]))
3398 gnus-article-treatment-menu gnus-article-mode-map ""
3399 ;; Fixme: this should use :active (and maybe :visible).
3401 ["Hide headers" gnus-article-hide-headers t]
3402 ["Hide signature" gnus-article-hide-signature t]
3403 ["Hide citation" gnus-article-hide-citation t]
3404 ["Treat overstrike" gnus-article-treat-overstrike t]
3405 ["Remove carriage return" gnus-article-remove-cr t]
3406 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3407 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3408 ["Remove base64" gnus-article-de-base64-unreadable t]
3409 ["Treat html" gnus-article-wash-html t]
3410 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3411 ["Decode HZ" gnus-article-decode-HZ t]))
3413 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3415 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3417 (gnus-run-hooks 'gnus-article-menu-hook)))
3419 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3422 (defun gnus-article-mode ()
3423 "Major mode for displaying an article.
3425 All normal editing commands are switched off.
3427 The following commands are available in addition to all summary mode
3429 \\<gnus-article-mode-map>
3430 \\[gnus-article-next-page]\t Scroll the article one page forwards
3431 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3432 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3433 \\[gnus-article-show-summary]\t Display the summary buffer
3434 \\[gnus-article-mail]\t Send a reply to the address near point
3435 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3436 \\[gnus-info-find-node]\t Go to the Gnus info node"
3438 (gnus-simplify-mode-line)
3439 (setq mode-name "Article")
3440 (setq major-mode 'gnus-article-mode)
3441 (make-local-variable 'minor-mode-alist)
3442 (use-local-map gnus-article-mode-map)
3443 (when (gnus-visual-p 'article-menu 'menu)
3444 (gnus-article-make-menu-bar))
3445 (gnus-update-format-specifications nil 'article-mode)
3446 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3447 (make-local-variable 'gnus-page-broken)
3448 (make-local-variable 'gnus-button-marker-list)
3449 (make-local-variable 'gnus-article-current-summary)
3450 (make-local-variable 'gnus-article-mime-handles)
3451 (make-local-variable 'gnus-article-decoded-p)
3452 (make-local-variable 'gnus-article-mime-handle-alist)
3453 (make-local-variable 'gnus-article-wash-types)
3454 (make-local-variable 'gnus-article-image-alist)
3455 (make-local-variable 'gnus-article-charset)
3456 (make-local-variable 'gnus-article-ignored-charsets)
3457 (gnus-set-default-directory)
3458 (buffer-disable-undo)
3459 (setq buffer-read-only t)
3460 (set-syntax-table gnus-article-mode-syntax-table)
3461 (mm-enable-multibyte)
3462 (gnus-run-hooks 'gnus-article-mode-hook))
3464 (defun gnus-article-setup-buffer ()
3465 "Initialize the article buffer."
3466 (let* ((name (if gnus-single-article-buffer "*Article*"
3467 (concat "*Article " gnus-newsgroup-name "*")))
3469 (progn (string-match "\\*Article" name)
3470 (concat " *Original Article"
3471 (substring name (match-end 0))))))
3472 (setq gnus-article-buffer name)
3473 (setq gnus-original-article-buffer original)
3474 (setq gnus-article-mime-handle-alist nil)
3475 ;; This might be a variable local to the summary buffer.
3476 (unless gnus-single-article-buffer
3478 (set-buffer gnus-summary-buffer)
3479 (setq gnus-article-buffer name)
3480 (setq gnus-original-article-buffer original)
3481 (gnus-set-global-variables)))
3482 (gnus-article-setup-highlight-words)
3483 ;; Init original article buffer.
3485 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3486 (mm-enable-multibyte)
3487 (setq major-mode 'gnus-original-article-mode)
3488 (make-local-variable 'gnus-original-article))
3489 (if (get-buffer name)
3492 (when gnus-article-mime-handles
3493 (mm-destroy-parts gnus-article-mime-handles)
3494 (setq gnus-article-mime-handles nil))
3495 ;; Set it to nil in article-buffer!
3496 (setq gnus-article-mime-handle-alist nil)
3497 (buffer-disable-undo)
3498 (setq buffer-read-only t)
3499 (unless (eq major-mode 'gnus-article-mode)
3500 (gnus-article-mode))
3503 (set-buffer (gnus-get-buffer-create name))
3505 (make-local-variable 'gnus-summary-buffer)
3506 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3507 (current-buffer)))))
3509 ;; Set article window start at LINE, where LINE is the number of lines
3510 ;; from the head of the article.
3511 (defun gnus-article-set-window-start (&optional line)
3513 (gnus-get-buffer-window gnus-article-buffer t)
3515 (set-buffer gnus-article-buffer)
3516 (goto-char (point-min))
3519 (gnus-message 6 "Moved to bookmark")
3520 (search-forward "\n\n" nil t)
3524 (defun gnus-article-prepare (article &optional all-headers header)
3525 "Prepare ARTICLE in article mode buffer.
3526 ARTICLE should either be an article number or a Message-ID.
3527 If ARTICLE is an id, HEADER should be the article headers.
3528 If ALL-HEADERS is non-nil, no headers are hidden."
3530 ;; Make sure we start in a summary buffer.
3531 (unless (eq major-mode 'gnus-summary-mode)
3532 (set-buffer gnus-summary-buffer))
3533 (setq gnus-summary-buffer (current-buffer))
3534 (let* ((gnus-article (if header (mail-header-number header) article))
3535 (summary-buffer (current-buffer))
3536 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3537 (group gnus-newsgroup-name)
3540 (gnus-article-setup-buffer)
3541 (set-buffer gnus-article-buffer)
3542 ;; Deactivate active regions.
3543 (when (and (boundp 'transient-mark-mode)
3544 transient-mark-mode)
3545 (setq mark-active nil))
3546 (if (not (setq result (let ((buffer-read-only nil))
3547 (gnus-request-article-this-buffer
3549 ;; There is no such article.
3551 (when (and (numberp article)
3552 (not (memq article gnus-newsgroup-sparse)))
3553 (setq gnus-article-current
3554 (cons gnus-newsgroup-name article))
3555 (set-buffer gnus-summary-buffer)
3556 (setq gnus-current-article article)
3557 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3559 (gnus-summary-set-agent-mark article)
3560 (message "Message marked for downloading"))
3561 (gnus-summary-mark-article article gnus-canceled-mark)
3562 (unless (memq article gnus-newsgroup-sparse)
3563 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3564 (if (or (eq result 'pseudo)
3565 (eq result 'nneething))
3568 (set-buffer summary-buffer)
3569 (push article gnus-newsgroup-history)
3570 (setq gnus-last-article gnus-current-article
3571 gnus-current-article 0
3572 gnus-current-headers nil
3573 gnus-article-current nil)
3574 (if (eq result 'nneething)
3575 (gnus-configure-windows 'summary)
3576 (gnus-configure-windows 'article))
3577 (gnus-set-global-variables))
3578 (let ((gnus-article-mime-handle-alist-1
3579 gnus-article-mime-handle-alist))
3580 (gnus-set-mode-line 'article)))
3581 ;; The result from the `request' was an actual article -
3582 ;; or at least some text that is now displayed in the
3584 (when (and (numberp article)
3585 (not (eq article gnus-current-article)))
3586 ;; Seems like a new article has been selected.
3587 ;; `gnus-current-article' must be an article number.
3589 (set-buffer summary-buffer)
3590 (push article gnus-newsgroup-history)
3591 (setq gnus-last-article gnus-current-article
3592 gnus-current-article article
3593 gnus-current-headers
3594 (gnus-summary-article-header gnus-current-article)
3595 gnus-article-current
3596 (cons gnus-newsgroup-name gnus-current-article))
3597 (unless (vectorp gnus-current-headers)
3598 (setq gnus-current-headers nil))
3599 (gnus-summary-goto-subject gnus-current-article)
3600 (when (gnus-summary-show-thread)
3601 ;; If the summary buffer really was folded, the
3602 ;; previous goto may not actually have gone to
3603 ;; the right article, but the thread root instead.
3605 (gnus-summary-goto-subject gnus-current-article))
3606 (gnus-run-hooks 'gnus-mark-article-hook)
3607 (gnus-set-mode-line 'summary)
3608 (when (gnus-visual-p 'article-highlight 'highlight)
3609 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3610 ;; Set the global newsgroup variables here.
3611 (gnus-set-global-variables)
3612 (setq gnus-have-all-headers
3613 (or all-headers gnus-show-all-headers))))
3615 (gnus-configure-windows 'article))
3616 (when (or (numberp article)
3618 (gnus-article-prepare-display)
3620 (goto-char (point-min))
3621 (setq gnus-page-broken
3622 (when gnus-break-pages
3623 (gnus-narrow-to-page)
3625 (let ((gnus-article-mime-handle-alist-1
3626 gnus-article-mime-handle-alist))
3627 (gnus-set-mode-line 'article))
3631 (set-window-point (get-buffer-window (current-buffer)) (point))
3632 (gnus-configure-windows 'article)
3636 (defun gnus-article-prepare-display ()
3637 "Make the current buffer look like a nice article."
3638 ;; Hooks for getting information from the article.
3639 ;; This hook must be called before being narrowed.
3640 (let ((gnus-article-buffer (current-buffer))
3642 (unless (eq major-mode 'gnus-article-mode)
3643 (gnus-article-mode))
3644 (setq buffer-read-only nil
3645 gnus-article-wash-types nil
3646 gnus-article-image-alist nil)
3647 (gnus-run-hooks 'gnus-tmp-internal-hook)
3648 (when gnus-display-mime-function
3649 (funcall gnus-display-mime-function))
3650 (gnus-run-hooks 'gnus-article-prepare-hook)))
3653 ;;; Gnus MIME viewing functions
3656 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3657 "Format of the MIME buttons.
3659 Valid specifiers include:
3661 %T MIME type, along with additional info
3662 %n The `name' parameter
3663 %d The description, if any
3664 %l The length of the encoded part
3665 %p The part identifier number
3666 %e Dots if the part isn't displayed
3668 General format specifiers can also be used. See Info node
3669 `(gnus)Formatting Variables'.")
3671 (defvar gnus-mime-button-line-format-alist
3672 '((?t gnus-tmp-type ?s)
3673 (?T gnus-tmp-type-long ?s)
3674 (?n gnus-tmp-name ?s)
3675 (?d gnus-tmp-description ?s)
3677 (?l gnus-tmp-length ?d)
3678 (?e gnus-tmp-dots ?s)))
3680 (defvar gnus-mime-button-commands
3681 '((gnus-article-press-button "\r" "Toggle Display")
3682 (gnus-mime-view-part "v" "View Interactively...")
3683 (gnus-mime-view-part-as-type "t" "View As Type...")
3684 (gnus-mime-view-part-as-charset "C" "View As charset...")
3685 (gnus-mime-save-part "o" "Save...")
3686 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3687 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3688 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3689 (gnus-mime-view-part-internally "E" "View Internally")
3690 (gnus-mime-view-part-externally "e" "View Externally")
3691 (gnus-mime-print-part "p" "Print")
3692 (gnus-mime-pipe-part "|" "Pipe To Command...")
3693 (gnus-mime-action-on-part "." "Take action on the part")))
3695 (defun gnus-article-mime-part-status ()
3696 (if gnus-article-mime-handle-alist-1
3697 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3699 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3702 (defvar gnus-mime-button-map
3703 (let ((map (make-sparse-keymap)))
3704 (unless (>= (string-to-number emacs-version) 21)
3705 ;; XEmacs doesn't care.
3706 (set-keymap-parent map gnus-article-mode-map))
3707 (define-key map gnus-mouse-2 'gnus-article-push-button)
3708 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3709 (dolist (c gnus-mime-button-commands)
3710 (define-key map (cadr c) (car c)))
3713 (defun gnus-mime-button-menu (event)
3714 "Construct a context-sensitive menu of MIME commands."
3716 (save-window-excursion
3717 (let ((pos (event-start event)))
3718 (select-window (posn-window pos))
3719 (goto-char (posn-point pos))
3720 (gnus-article-check-buffer)
3721 (let ((response (x-popup-menu
3723 ("" ,@(mapcar (lambda (c)
3724 (cons (caddr c) (car c)))
3725 gnus-mime-button-commands))))))
3727 (call-interactively response))))))
3729 (defun gnus-mime-view-all-parts (&optional handles)
3730 "View all the MIME parts."
3732 (save-current-buffer
3733 (set-buffer gnus-article-buffer)
3734 (let ((handles (or handles gnus-article-mime-handles))
3735 (mail-parse-charset gnus-newsgroup-charset)
3736 (mail-parse-ignored-charsets
3737 (with-current-buffer gnus-summary-buffer
3738 gnus-newsgroup-ignored-charsets)))
3740 (mm-remove-parts handles)
3741 (goto-char (point-min))
3742 (or (search-forward "\n\n") (goto-char (point-max)))
3743 (let (buffer-read-only)
3744 (delete-region (point) (point-max))
3745 (mm-display-parts handles))))))
3747 (defun gnus-mime-save-part-and-strip ()
3748 "Save the MIME part under point then replace it with an external body."
3750 (gnus-article-check-buffer)
3751 (let* ((data (get-text-property (point) 'gnus-data))
3753 (handles gnus-article-mime-handles))
3754 (if (mm-multiple-handles gnus-article-mime-handles)
3755 (error "This function is not implemented"))
3756 (setq file (and data (mm-save-part data)))
3758 (with-current-buffer (mm-handle-buffer data)
3760 (insert "Content-Type: " (mm-handle-media-type data))
3761 (mml-insert-parameter-string (cdr (mm-handle-type data))
3764 (insert "Content-ID: " (message-make-message-id) "\n")
3765 (insert "Content-Transfer-Encoding: binary\n")
3768 (cdr (mm-make-handle nil
3769 `("message/external-body"
3770 (access-type . "LOCAL-FILE")
3772 (set-buffer gnus-summary-buffer)
3773 (gnus-article-edit-article
3776 (let ((mail-parse-charset (or gnus-article-charset
3777 ',gnus-newsgroup-charset))
3778 (mail-parse-ignored-charsets
3779 (or gnus-article-ignored-charsets
3780 ',gnus-newsgroup-ignored-charsets))
3781 (mbl mml-buffer-list))
3782 (setq mml-buffer-list nil)
3783 (insert-buffer gnus-original-article-buffer)
3784 (mime-to-mml ',handles)
3785 (setq gnus-article-mime-handles nil)
3786 (let ((mbl1 mml-buffer-list))
3787 (setq mml-buffer-list mbl)
3788 (set (make-local-variable 'mml-buffer-list) mbl1))
3789 ;; LOCAL argument of add-hook differs between GNU Emacs
3790 ;; and XEmacs. make-local-hook makes sure they are local.
3791 (make-local-hook 'kill-buffer-hook)
3792 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3793 `(lambda (no-highlight)
3794 (let ((mail-parse-charset (or gnus-article-charset
3795 ',gnus-newsgroup-charset))
3796 (message-options message-options)
3797 (message-options-set-recipient)
3798 (mail-parse-ignored-charsets
3799 (or gnus-article-ignored-charsets
3800 ',gnus-newsgroup-ignored-charsets)))
3802 (mml-destroy-buffers)
3803 (remove-hook 'kill-buffer-hook
3804 'mml-destroy-buffers t)
3805 (kill-local-variable 'mml-buffer-list))
3806 (gnus-summary-edit-article-done
3807 ,(or (mail-header-references gnus-current-headers) "")
3808 ,(gnus-group-read-only-p)
3809 ,gnus-summary-buffer no-highlight))))))
3811 (defun gnus-mime-save-part ()
3812 "Save the MIME part under point."
3814 (gnus-article-check-buffer)
3815 (let ((data (get-text-property (point) 'gnus-data)))
3817 (mm-save-part data))))
3819 (defun gnus-mime-pipe-part ()
3820 "Pipe the MIME part under point to a process."
3822 (gnus-article-check-buffer)
3823 (let ((data (get-text-property (point) 'gnus-data)))
3825 (mm-pipe-part data))))
3827 (defun gnus-mime-view-part ()
3828 "Interactively choose a viewing method for the MIME part under point."
3830 (gnus-article-check-buffer)
3831 (let ((data (get-text-property (point) 'gnus-data)))
3833 (setq gnus-article-mime-handles
3835 gnus-article-mime-handles (setq data (copy-sequence data))))
3836 (mm-interactively-view-part data))))
3838 (defun gnus-mime-view-part-as-type-internal ()
3839 (gnus-article-check-buffer)
3840 (let* ((name (mail-content-type-get
3841 (mm-handle-type (get-text-property (point) 'gnus-data))
3843 (def-type (and name (mm-default-file-encoding name))))
3844 (and def-type (cons def-type 0))))
3846 (defun gnus-mime-view-part-as-type (&optional mime-type)
3847 "Choose a MIME media type, and view the part as such."
3850 (setq mime-type (completing-read
3851 "View as MIME type: "
3852 (mapcar #'list (mailcap-mime-types))
3854 (gnus-mime-view-part-as-type-internal))))
3855 (gnus-article-check-buffer)
3856 (let ((handle (get-text-property (point) 'gnus-data)))
3859 (mm-make-handle (mm-handle-buffer handle)
3860 (cons mime-type (cdr (mm-handle-type handle)))
3861 (mm-handle-encoding handle)
3862 (mm-handle-undisplayer handle)
3863 (mm-handle-disposition handle)
3864 (mm-handle-description handle)
3866 (mm-handle-id handle)))
3867 (setq gnus-article-mime-handles
3868 (mm-merge-handles gnus-article-mime-handles handle))
3869 (gnus-mm-display-part handle))))
3871 (defun gnus-mime-copy-part (&optional handle)
3872 "Put the MIME part under point into a new buffer."
3874 (gnus-article-check-buffer)
3875 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3876 (contents (and handle (mm-get-part handle)))
3878 (file-name-nondirectory
3880 (mail-content-type-get (mm-handle-type handle) 'name)
3881 (mail-content-type-get (mm-handle-type handle)
3884 (buffer (and base (generate-new-buffer base))))
3886 (switch-to-buffer buffer)
3888 ;; We do it this way to make `normal-mode' set the appropriate mode.
3891 (setq buffer-file-name (expand-file-name base))
3893 (setq buffer-file-name nil))
3894 (goto-char (point-min)))))
3896 (defun gnus-mime-print-part (&optional handle filename)
3897 "Print the MIME part under point."
3898 (interactive (list nil (ps-print-preprint current-prefix-arg)))
3899 (gnus-article-check-buffer)
3900 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3901 (contents (and handle (mm-get-part handle)))
3902 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
3903 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
3908 (with-temp-file file
3910 (call-process shell-file-name nil
3911 (generate-new-buffer " *mm*")
3913 shell-command-switch
3915 printer file (mm-handle-type handle))))
3919 (gnus-print-buffer))
3920 (ps-despool filename)))))
3922 (defun gnus-mime-inline-part (&optional handle arg)
3923 "Insert the MIME part under point into the current buffer."
3924 (interactive (list nil current-prefix-arg))
3925 (gnus-article-check-buffer)
3926 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3931 (if (and (not arg) (mm-handle-undisplayer handle))
3932 (mm-remove-part handle)
3933 (setq contents (mm-get-part handle))
3936 (setq charset (or (mail-content-type-get
3937 (mm-handle-type handle) 'charset)
3938 gnus-newsgroup-charset)))
3940 (if (mm-handle-undisplayer handle)
3941 (mm-remove-part handle))
3944 gnus-summary-show-article-charset-alist))
3945 (mm-read-coding-system "Charset: ")))))
3947 (mm-insert-inline handle
3949 (setq charset (mm-charset-to-coding-system
3951 (not (eq charset 'ascii)))
3952 (mm-decode-coding-string contents charset)
3956 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3957 "Insert the MIME part under point into the current buffer using the
3959 (interactive (list nil current-prefix-arg))
3960 (gnus-article-check-buffer)
3961 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3966 (if (mm-handle-undisplayer handle)
3967 (mm-remove-part handle))
3968 (let ((gnus-newsgroup-charset
3970 gnus-summary-show-article-charset-alist))
3971 (mm-read-coding-system "Charset: ")))
3972 (gnus-newsgroup-ignored-charsets 'gnus-all))
3973 (gnus-article-press-button)))))
3975 (defun gnus-mime-view-part-externally (&optional handle)
3976 "View the MIME part under point with an external viewer."
3978 (gnus-article-check-buffer)
3979 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3980 (mm-user-display-methods nil)
3981 (mm-inlined-types nil)
3982 (mail-parse-charset gnus-newsgroup-charset)
3983 (mail-parse-ignored-charsets
3984 (save-excursion (set-buffer gnus-summary-buffer)
3985 gnus-newsgroup-ignored-charsets)))
3987 (if (mm-handle-undisplayer handle)
3988 (mm-remove-part handle)
3989 (mm-display-part handle)))))
3991 (defun gnus-mime-view-part-internally (&optional handle)
3992 "View the MIME part under point with an internal viewer.
3993 If no internal viewer is available, use an external viewer."
3995 (gnus-article-check-buffer)
3996 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3997 (mm-inlined-types '(".*"))
3998 (mm-inline-large-images t)
3999 (mail-parse-charset gnus-newsgroup-charset)
4000 (mail-parse-ignored-charsets
4001 (save-excursion (set-buffer gnus-summary-buffer)
4002 gnus-newsgroup-ignored-charsets)))
4004 (if (mm-handle-undisplayer handle)
4005 (mm-remove-part handle)
4006 (mm-display-part handle)))))
4008 (defun gnus-mime-action-on-part (&optional action)
4009 "Do something with the MIME attachment at \(point\)."
4011 (list (completing-read "Action: " gnus-mime-action-alist)))
4012 (gnus-article-check-buffer)
4013 (let ((action-pair (assoc action gnus-mime-action-alist)))
4015 (funcall (cdr action-pair)))))
4017 (defun gnus-article-part-wrapper (n function)
4018 (save-current-buffer
4019 (set-buffer gnus-article-buffer)
4020 (when (> n (length gnus-article-mime-handle-alist))
4021 (error "No such part"))
4022 (gnus-article-goto-part n)
4023 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4024 (funcall function handle))))
4026 (defun gnus-article-pipe-part (n)
4027 "Pipe MIME part N, which is the numerical prefix."
4029 (gnus-article-part-wrapper n 'mm-pipe-part))
4031 (defun gnus-article-save-part (n)
4032 "Save MIME part N, which is the numerical prefix."
4034 (gnus-article-part-wrapper n 'mm-save-part))
4036 (defun gnus-article-interactively-view-part (n)
4037 "View MIME part N interactively, which is the numerical prefix."
4039 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4041 (defun gnus-article-copy-part (n)
4042 "Copy MIME part N, which is the numerical prefix."
4044 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4046 (defun gnus-article-view-part-as-charset (n)
4047 "Copy MIME part N, which is the numerical prefix."
4049 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4051 (defun gnus-article-view-part-externally (n)
4052 "View MIME part N externally, which is the numerical prefix."
4054 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4056 (defun gnus-article-inline-part (n)
4057 "Inline MIME part N, which is the numerical prefix."
4059 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4061 (defun gnus-article-mime-match-handle-first (condition)
4063 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4064 (while (setq ihandle (pop alist))
4066 ((functionp condition)
4067 (funcall condition (cdr ihandle)))
4068 ((eq condition 'undisplayed)
4069 (not (or (mm-handle-undisplayer (cdr ihandle))
4070 (equal (mm-handle-media-type (cdr ihandle))
4071 "multipart/alternative"))))
4072 ((eq condition 'undisplayed-alternative)
4073 (not (mm-handle-undisplayer (cdr ihandle))))
4075 (gnus-article-goto-part (car ihandle))
4076 (or (not n) (< (car ihandle) n)))
4077 (setq n (car ihandle))))
4081 (defun gnus-article-view-part (&optional n)
4082 "View MIME part N, which is the numerical prefix."
4084 (save-current-buffer
4085 (set-buffer gnus-article-buffer)
4086 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4087 gnus-article-mime-match-handle-function)))
4088 (when (> n (length gnus-article-mime-handle-alist))
4089 (error "No such part"))
4090 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4091 (when (gnus-article-goto-part n)
4092 (if (equal (car handle) "multipart/alternative")
4093 (gnus-article-press-button)
4094 (when (eq (gnus-mm-display-part handle) 'internal)
4095 (gnus-set-window-start)))))))
4097 (defsubst gnus-article-mime-total-parts ()
4098 (if (bufferp (car gnus-article-mime-handles))
4100 (1- (length gnus-article-mime-handles))))
4102 (defun gnus-mm-display-part (handle)
4103 "Display HANDLE and fix MIME button."
4104 (let ((id (get-text-property (point) 'gnus-part))
4109 (let ((window (selected-window))
4110 (mail-parse-charset gnus-newsgroup-charset)
4111 (mail-parse-ignored-charsets
4112 (if (gnus-buffer-live-p gnus-summary-buffer)
4114 (set-buffer gnus-summary-buffer)
4115 gnus-newsgroup-ignored-charsets)
4119 (let ((win (gnus-get-buffer-window (current-buffer) t))
4122 (select-window win))
4125 (if (mm-handle-displayed-p handle)
4126 ;; This will remove the part.
4127 (mm-display-part handle)
4129 (narrow-to-region (point)
4130 (if (eobp) (point) (1+ (point))))
4131 (mm-display-part handle)
4132 ;; We narrow to the part itself and
4133 ;; then call the treatment functions.
4134 (goto-char (point-min))
4136 (narrow-to-region (point) (point-max))
4139 (gnus-article-mime-total-parts)
4140 (mm-handle-media-type handle)))))
4141 (if (window-live-p window)
4142 (select-window window)))))
4144 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4145 (gnus-insert-mime-button
4146 handle id (list (mm-handle-displayed-p handle)))
4147 (goto-char point))))
4149 (defun gnus-article-goto-part (n)
4150 "Go to MIME part N."
4151 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4153 (goto-char point))))
4155 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4156 (let ((gnus-tmp-name
4157 (or (mail-content-type-get (mm-handle-type handle) 'name)
4158 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4159 (mail-content-type-get (mm-handle-type handle) 'url)
4161 (gnus-tmp-type (mm-handle-media-type handle))
4162 (gnus-tmp-description
4163 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4166 (if (if displayed (car displayed)
4167 (mm-handle-displayed-p handle))
4169 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4171 gnus-tmp-type-long b e)
4172 (when (string-match ".*/" gnus-tmp-name)
4173 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4174 (setq gnus-tmp-type-long (concat gnus-tmp-type
4175 (and (not (equal gnus-tmp-name ""))
4176 (concat "; " gnus-tmp-name))))
4177 (unless (equal gnus-tmp-description "")
4178 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4183 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4184 `(,@(gnus-local-map-property gnus-mime-button-map)
4185 gnus-callback gnus-mm-display-part
4186 gnus-part ,gnus-tmp-id
4187 article-type annotation
4190 (widget-convert-button
4193 :action 'gnus-widget-press-button
4194 :button-keymap gnus-mime-button-map
4196 (lambda (widget/window &optional overlay pos)
4197 ;; Needed to properly clear the message due to a bug in
4198 ;; wid-edit (XEmacs only).
4199 (if (boundp 'help-echo-owns-message)
4200 (setq help-echo-owns-message t))
4202 "%S: %s the MIME part; %S: more options"
4203 (aref gnus-mouse-2 0)
4204 ;; XEmacs will get a single widget arg; Emacs 21 will get
4205 ;; window, overlay, position.
4206 (if (mm-handle-displayed-p
4208 (with-current-buffer (gnus-overlay-buffer overlay)
4209 (widget-get (widget-at (gnus-overlay-start overlay))
4211 (widget-get widget/window :mime-handle)))
4213 (aref gnus-down-mouse-3 0))))))
4215 (defun gnus-widget-press-button (elems el)
4216 (goto-char (widget-get elems :from))
4217 (gnus-article-press-button))
4219 (defvar gnus-displaying-mime nil)
4221 (defun gnus-display-mime (&optional ihandles)
4222 "Display the MIME parts."
4224 (save-selected-window
4225 (let ((window (get-buffer-window gnus-article-buffer))
4228 (select-window window)
4229 ;; We have to do this since selecting the window
4230 ;; may change the point. So we set the window point.
4231 (set-window-point window point)))
4232 (let* ((handles (or ihandles (mm-dissect-buffer
4233 nil gnus-article-loose-mime)
4235 buffer-read-only handle name type b e display)
4236 (when (and (not ihandles)
4237 (not gnus-displaying-mime))
4238 ;; Top-level call; we clean up.
4239 (when gnus-article-mime-handles
4240 (mm-destroy-parts gnus-article-mime-handles)
4241 (setq gnus-article-mime-handle-alist nil));; A trick.
4242 (setq gnus-article-mime-handles handles)
4243 ;; We allow users to glean info from the handles.
4244 (when gnus-article-mime-part-function
4245 (gnus-mime-part-function handles)))
4247 (or (not (stringp (car handles)))
4250 (when (and (not ihandles)
4251 (not gnus-displaying-mime))
4252 ;; Clean up for mime parts.
4254 (delete-region (point) (point-max)))
4255 (let ((gnus-displaying-mime t))
4256 (gnus-mime-display-part handles)))
4259 (narrow-to-region (point) (point-max))
4260 (gnus-treat-article nil 1 1)
4263 ;; Highlight the headers.
4267 (narrow-to-region (point-min) (point))
4268 (gnus-treat-article 'head))))))))
4270 (defvar gnus-mime-display-multipart-as-mixed nil)
4271 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4272 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4274 (defun gnus-mime-display-part (handle)
4277 ((not (stringp (car handle)))
4278 (gnus-mime-display-single handle))
4279 ;; User-defined multipart
4280 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4281 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4283 ;; multipart/alternative
4284 ((and (equal (car handle) "multipart/alternative")
4285 (not (or gnus-mime-display-multipart-as-mixed
4286 gnus-mime-display-multipart-alternative-as-mixed)))
4287 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4288 (push (cons id handle) gnus-article-mime-handle-alist)
4289 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4290 ;; multipart/related
4291 ((and (equal (car handle) "multipart/related")
4292 (not (or gnus-mime-display-multipart-as-mixed
4293 gnus-mime-display-multipart-related-as-mixed)))
4294 ;;;!!!We should find the start part, but we just default
4295 ;;;!!!to the first part.
4296 ;;(gnus-mime-display-part (cadr handle))
4297 ;;;!!! Most multipart/related is an HTML message plus images.
4298 ;;;!!! Unfortunately we are unable to let W3 display those
4299 ;;;!!! included images, so we just display it as a mixed multipart.
4300 ;;(gnus-mime-display-mixed (cdr handle))
4301 ;;;!!! No, w3 can display everything just fine.
4302 (gnus-mime-display-part (cadr handle)))
4303 ((equal (car handle) "multipart/signed")
4304 (gnus-add-wash-type 'signed)
4305 (gnus-mime-display-security handle))
4306 ((equal (car handle) "multipart/encrypted")
4307 (gnus-add-wash-type 'encrypted)
4308 (gnus-mime-display-security handle))
4309 ;; Other multiparts are handled like multipart/mixed.
4311 (gnus-mime-display-mixed (cdr handle)))))
4313 (defun gnus-mime-part-function (handles)
4314 (if (stringp (car handles))
4315 (mapcar 'gnus-mime-part-function (cdr handles))
4316 (funcall gnus-article-mime-part-function handles)))
4318 (defun gnus-mime-display-mixed (handles)
4319 (mapcar 'gnus-mime-display-part handles))
4321 (defun gnus-mime-display-single (handle)
4322 (let ((type (mm-handle-media-type handle))
4323 (ignored gnus-ignored-mime-types)
4330 (when (string-match (pop ignored) type)
4331 (throw 'ignored nil)))
4332 (if (and (setq not-attachment
4333 (and (not (mm-inline-override-p handle))
4334 (or (not (mm-handle-disposition handle))
4335 (equal (car (mm-handle-disposition handle))
4337 (mm-attachment-override-p handle))))
4338 (mm-automatic-display-p handle)
4340 (mm-inlinable-p handle)
4341 (mm-inlined-p handle))
4342 (mm-automatic-external-display-p type)))
4344 (when (equal (mm-handle-media-supertype handle) "text")
4346 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4348 (push (cons id handle) gnus-article-mime-handle-alist)
4349 (when (or (not display)
4350 (not (gnus-unbuttonized-mime-type-p type)))
4351 ;(gnus-article-insert-newline)
4352 (gnus-insert-mime-button
4353 handle id (list (or display (and not-attachment text))))
4354 (gnus-article-insert-newline)
4355 ;(gnus-article-insert-newline)
4356 ;; Remember modify the number of forward lines.
4364 (let ((mail-parse-charset gnus-newsgroup-charset)
4365 (mail-parse-ignored-charsets
4366 (save-excursion (condition-case ()
4367 (set-buffer gnus-summary-buffer)
4369 gnus-newsgroup-ignored-charsets)))
4370 (mm-display-part handle t))
4371 (goto-char (point-max)))
4372 ((and text not-attachment)
4376 (gnus-article-insert-newline)
4377 (mm-insert-inline handle (mm-get-part handle))
4378 (goto-char (point-max))))
4382 (narrow-to-region beg (point))
4385 (gnus-article-mime-total-parts)
4386 (mm-handle-media-type handle)))))))))
4388 (defun gnus-unbuttonized-mime-type-p (type)
4389 "Say whether TYPE is to be unbuttonized."
4390 (unless gnus-inhibit-mime-unbuttonizing
4392 (let ((types gnus-unbuttonized-mime-types))
4394 (when (string-match (pop types) type)
4395 (throw 'found t)))))
4397 (let ((types gnus-buttonized-mime-types))
4399 (when (string-match (pop types) type)
4400 (throw 'found t)))))))))
4402 (defun gnus-article-insert-newline ()
4403 "Insert a newline, but mark it as undeletable."
4404 (gnus-put-text-property
4405 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4407 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4408 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4411 handle buffer-read-only from props begend not-pref)
4412 (save-window-excursion
4415 (narrow-to-region (car ibegend)
4418 (goto-char (car ibegend))
4421 (delete-region (point-min) (point-max))
4422 (mm-remove-parts handles))
4423 (setq begend (list (point-marker)))
4425 (unless (setq not-pref (cadr (member preferred ihandles)))
4426 (setq not-pref (car ihandles)))
4429 (not (gnus-unbuttonized-mime-type-p
4430 "multipart/alternative")))
4431 (gnus-add-text-properties
4434 (insert (format "%d. " id))
4438 (unless ,(not ibegend)
4439 (setq gnus-article-mime-handle-alist
4440 ',gnus-article-mime-handle-alist))
4441 (gnus-mime-display-alternative
4442 ',ihandles ',not-pref ',begend ,id))
4443 ,@(gnus-local-map-property gnus-mime-button-map)
4444 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4445 face ,gnus-article-button-face
4448 (widget-convert-button 'link from (point)
4449 :action 'gnus-widget-press-button
4450 :button-keymap gnus-widget-button-keymap)
4452 (while (setq handle (pop handles))
4453 (gnus-add-text-properties
4456 (insert (format "(%c) %-18s"
4457 (if (equal handle preferred) ?* ? )
4458 (mm-handle-media-type handle)))
4462 (unless ,(not ibegend)
4463 (setq gnus-article-mime-handle-alist
4464 ',gnus-article-mime-handle-alist))
4465 (gnus-mime-display-alternative
4466 ',ihandles ',handle ',begend ,id))
4467 ,@(gnus-local-map-property gnus-mime-button-map)
4468 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4469 face ,gnus-article-button-face
4472 (widget-convert-button 'link from (point)
4473 :action 'gnus-widget-press-button
4474 :button-keymap gnus-widget-button-keymap)
4478 (if (stringp (car preferred))
4479 (gnus-display-mime preferred)
4480 (let ((mail-parse-charset gnus-newsgroup-charset)
4481 (mail-parse-ignored-charsets
4482 (save-excursion (set-buffer gnus-summary-buffer)
4483 gnus-newsgroup-ignored-charsets)))
4484 (mm-display-part preferred)
4488 (narrow-to-region (car begend) (point-max))
4490 nil (length gnus-article-mime-handle-alist)
4491 (gnus-article-mime-total-parts)
4492 (mm-handle-media-type handle))))))
4493 (goto-char (point-max))
4494 (setcdr begend (point-marker)))))
4496 (goto-char point))))
4498 (defconst gnus-article-wash-status-strings
4499 (let ((alist '((cite "c" "Possible hidden citation text"
4500 " " "All citation text visible")
4501 (headers "h" "Hidden headers"
4502 " " "All headers visible.")
4503 (pgp "p" "Encrypted or signed message status hidden"
4504 " " "No hidden encryption nor digital signature status")
4505 (signature "s" "Signature has been hidden"
4506 " " "Signature is visible")
4507 (overstrike "o" "Overstrike (^H) characters applied"
4508 " " "No overstrike characters applied")
4509 (emphasis "e" "/*_Emphasis_*/ characters applied"
4510 " " "No /*_emphasis_*/ characters applied")))
4512 (dolist (entry alist result)
4513 (let ((key (nth 0 entry))
4514 (on (copy-sequence (nth 1 entry)))
4515 (on-help (nth 2 entry))
4516 (off (copy-sequence (nth 3 entry)))
4517 (off-help (nth 4 entry)))
4518 (put-text-property 0 1 'help-echo on-help on)
4519 (put-text-property 0 1 'help-echo off-help off)
4520 (push (list key on off) result))))
4521 "Alist of strings describing wash status in the mode line.
4522 Each entry has the form (KEY ON OF), where the KEY is a symbol
4523 representing the particular washing function, ON is the string to use
4524 in the article mode line when the washing function is active, and OFF
4525 is the string to use when it is inactive.")
4527 (defun gnus-article-wash-status-entry (key value)
4528 (let ((entry (assoc key gnus-article-wash-status-strings)))
4529 (if value (nth 1 entry) (nth 2 entry))))
4531 (defun gnus-article-wash-status ()
4532 "Return a string which display status of article washing."
4534 (set-buffer gnus-article-buffer)
4535 (let ((cite (memq 'cite gnus-article-wash-types))
4536 (headers (memq 'headers gnus-article-wash-types))
4537 (boring (memq 'boring-headers gnus-article-wash-types))
4538 (pgp (memq 'pgp gnus-article-wash-types))
4539 (pem (memq 'pem gnus-article-wash-types))
4540 (signed (memq 'signed gnus-article-wash-types))
4541 (encrypted (memq 'encrypted gnus-article-wash-types))
4542 (signature (memq 'signature gnus-article-wash-types))
4543 (overstrike (memq 'overstrike gnus-article-wash-types))
4544 (emphasis (memq 'emphasis gnus-article-wash-types)))
4546 (gnus-article-wash-status-entry 'cite cite)
4547 (gnus-article-wash-status-entry 'headers (or headers boring))
4548 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4549 (gnus-article-wash-status-entry 'signature signature)
4550 (gnus-article-wash-status-entry 'overstrike overstrike)
4551 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4553 (defun gnus-add-wash-type (type)
4554 "Add a washing of TYPE to the current status."
4555 (add-to-list 'gnus-article-wash-types type))
4557 (defun gnus-delete-wash-type (type)
4558 "Add a washing of TYPE to the current status."
4559 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4561 (defun gnus-add-image (category image)
4562 "Add IMAGE of CATEGORY to the list of displayed images."
4563 (let ((entry (assq category gnus-article-image-alist)))
4565 (setq entry (list category))
4566 (push entry gnus-article-image-alist))
4567 (nconc entry (list image))))
4569 (defun gnus-delete-images (category)
4570 "Delete all images in CATEGORY."
4571 (let ((entry (assq category gnus-article-image-alist)))
4572 (dolist (image (cdr entry))
4573 (gnus-remove-image image))
4574 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4575 (gnus-delete-wash-type category)))
4577 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4579 (defun gnus-article-maybe-hide-headers ()
4580 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4581 Provided for backwards compatibility."
4582 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4583 (not (save-excursion (set-buffer gnus-summary-buffer)
4584 gnus-have-all-headers)))
4585 (not gnus-inhibit-hiding))
4586 (gnus-article-hide-headers)))
4590 (defun gnus-output-to-file (file-name)
4591 "Append the current article to a file named FILE-NAME."
4592 (let ((artbuf (current-buffer)))
4594 (insert-buffer-substring artbuf)
4595 ;; Append newline at end of the buffer as separator, and then
4597 (goto-char (point-max))
4599 (let ((file-name-coding-system nnmail-pathname-coding-system))
4600 (mm-append-to-file (point-min) (point-max) file-name))
4603 (defun gnus-narrow-to-page (&optional arg)
4604 "Narrow the article buffer to a page.
4605 If given a numerical ARG, move forward ARG pages."
4607 (setq arg (if arg (prefix-numeric-value arg) 0))
4609 (set-buffer gnus-article-buffer)
4610 (goto-char (point-min))
4612 ;; Remove any old next/prev buttons.
4613 (when (gnus-visual-p 'page-marker)
4614 (let ((buffer-read-only nil))
4615 (gnus-remove-text-with-property 'gnus-prev)
4616 (gnus-remove-text-with-property 'gnus-next)))
4619 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4621 (re-search-forward page-delimiter nil 'move arg)))
4622 (goto-char (match-end 0)))
4625 (if (re-search-forward page-delimiter nil 'move)
4628 (when (and (gnus-visual-p 'page-marker)
4629 (not (= (point-min) 1)))
4631 (goto-char (point-min))
4632 (gnus-insert-prev-page-button)))
4633 (when (and (gnus-visual-p 'page-marker)
4634 (< (+ (point-max) 2) (buffer-size)))
4636 (goto-char (point-max))
4637 (gnus-insert-next-page-button)))))
4639 ;; Article mode commands
4641 (defun gnus-article-goto-next-page ()
4642 "Show the next page of the article."
4644 (when (gnus-article-next-page)
4645 (goto-char (point-min))
4646 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4648 (defun gnus-article-goto-prev-page ()
4649 "Show the next page of the article."
4651 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4652 (gnus-article-prev-page nil)))
4654 (defun gnus-article-next-page (&optional lines)
4655 "Show the next page of the current article.
4656 If end of article, return non-nil. Otherwise return nil.
4657 Argument LINES specifies lines to be scrolled up."
4659 (move-to-window-line -1)
4662 (and (pos-visible-in-window-p) ;Not continuation line.
4664 ;; Nothing in this page.
4665 (if (or (not gnus-page-broken)
4668 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4670 (gnus-narrow-to-page 1) ;Go to next page.
4672 ;; More in this page.
4673 (let ((scroll-in-place nil))
4677 ;; Long lines may cause an end-of-buffer error.
4678 (goto-char (point-max)))))
4679 (move-to-window-line 0)
4682 (defun gnus-article-prev-page (&optional lines)
4683 "Show previous page of current article.
4684 Argument LINES specifies lines to be scrolled down."
4686 (move-to-window-line 0)
4687 (if (and gnus-page-broken
4689 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4691 (gnus-narrow-to-page -1) ;Go to previous page.
4692 (goto-char (point-max))
4694 (let ((scroll-in-place nil))
4698 (beginning-of-buffer
4699 (goto-char (point-min))))
4700 (move-to-window-line 0)))))
4702 (defun gnus-article-refer-article ()
4703 "Read article specified by message-id around point."
4705 (let ((point (point)))
4706 (search-forward ">" nil t) ;Move point to end of "<....>".
4707 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4708 (let ((message-id (match-string 1)))
4710 (set-buffer gnus-summary-buffer)
4711 (gnus-summary-refer-article message-id))
4713 (error "No references around point"))))
4715 (defun gnus-article-show-summary ()
4716 "Reconfigure windows to show summary buffer."
4718 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4719 (error "There is no summary buffer for this article buffer")
4720 (gnus-article-set-globals)
4721 (gnus-configure-windows 'article)
4722 (gnus-summary-goto-subject gnus-current-article)
4723 (gnus-summary-position-point)))
4725 (defun gnus-article-describe-briefly ()
4726 "Describe article mode commands briefly."
4728 (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")))
4730 (defun gnus-article-summary-command ()
4731 "Execute the last keystroke in the summary buffer."
4733 (let ((obuf (current-buffer))
4734 (owin (current-window-configuration))
4736 (switch-to-buffer gnus-article-current-summary 'norecord)
4737 (setq func (lookup-key (current-local-map) (this-command-keys)))
4738 (call-interactively func)
4740 (set-window-configuration owin)
4741 (set-window-point (get-buffer-window (current-buffer)) (point))))
4743 (defun gnus-article-summary-command-nosave ()
4744 "Execute the last keystroke in the summary buffer."
4747 (pop-to-buffer gnus-article-current-summary 'norecord)
4748 (setq func (lookup-key (current-local-map) (this-command-keys)))
4749 (call-interactively func)))
4751 (defun gnus-article-check-buffer ()
4752 "Beep if not in an article buffer."
4753 (unless (equal major-mode 'gnus-article-mode)
4754 (error "Command invoked outside of a Gnus article buffer")))
4756 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4757 "Read a summary buffer key sequence and execute it from the article buffer."
4759 (gnus-article-check-buffer)
4761 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4762 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4763 "=" "^" "\M-^" "|"))
4769 '("n" "Gn" "p" "Gp"))
4772 (set-buffer gnus-article-current-summary)
4773 (let (gnus-pick-mode)
4774 (push (or key last-command-event) unread-command-events)
4775 (setq keys (if (featurep 'xemacs)
4776 (events-to-keys (read-key-sequence nil))
4777 (read-key-sequence nil)))))
4781 (if (or (member keys nosaves)
4782 (member keys nosave-but-article)
4783 (member keys nosave-in-article))
4785 (save-window-excursion
4786 (pop-to-buffer gnus-article-current-summary 'norecord)
4787 ;; We disable the pick minor mode commands.
4788 (let (gnus-pick-mode)
4789 (setq func (lookup-key (current-local-map) keys))))
4793 (unless (member keys nosave-in-article)
4794 (set-buffer gnus-article-current-summary))
4795 (call-interactively func)
4796 (setq new-sum-point (point)))
4797 (when (member keys nosave-but-article)
4798 (pop-to-buffer gnus-article-buffer 'norecord)))
4799 ;; These commands should restore window configuration.
4800 (let ((obuf (current-buffer))
4801 (owin (current-window-configuration))
4803 (summary gnus-article-current-summary)
4804 func in-buffer selected)
4805 (if not-restore-window
4806 (pop-to-buffer summary 'norecord)
4807 (switch-to-buffer summary 'norecord))
4808 (setq in-buffer (current-buffer))
4809 ;; We disable the pick minor mode commands.
4810 (if (and (setq func (let (gnus-pick-mode)
4811 (lookup-key (current-local-map) keys)))
4814 (call-interactively func)
4815 (setq new-sum-point (point))
4816 (when (eq in-buffer (current-buffer))
4817 (setq selected (gnus-summary-select-article))
4819 (unless not-restore-window
4820 (set-window-configuration owin))
4821 (when (eq selected 'old)
4823 (set-window-start (get-buffer-window (current-buffer))
4825 (set-window-point (get-buffer-window (current-buffer))
4827 (let ((win (get-buffer-window gnus-article-current-summary)))
4829 (set-window-point win new-sum-point)))) )
4830 (switch-to-buffer gnus-article-buffer)
4833 (defun gnus-article-describe-key (key)
4834 "Display documentation of the function invoked by KEY. KEY is a string."
4835 (interactive "kDescribe key: ")
4836 (gnus-article-check-buffer)
4837 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4839 (set-buffer gnus-article-current-summary)
4840 (let (gnus-pick-mode)
4841 (if (featurep 'xemacs)
4843 (push (elt key 0) unread-command-events)
4844 (setq key (events-to-keys
4845 (read-key-sequence "Describe key: "))))
4846 (setq unread-command-events
4848 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4849 (string-to-list key)))
4850 (setq key (read-key-sequence "Describe key: "))))
4852 (describe-key key)))
4854 (defun gnus-article-describe-key-briefly (key &optional insert)
4855 "Display documentation of the function invoked by KEY. KEY is a string."
4856 (interactive "kDescribe key: \nP")
4857 (gnus-article-check-buffer)
4858 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4860 (set-buffer gnus-article-current-summary)
4861 (let (gnus-pick-mode)
4862 (if (featurep 'xemacs)
4864 (push (elt key 0) unread-command-events)
4865 (setq key (events-to-keys
4866 (read-key-sequence "Describe key: "))))
4867 (setq unread-command-events
4869 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4870 (string-to-list key)))
4871 (setq key (read-key-sequence "Describe key: "))))
4872 (describe-key-briefly key insert))
4873 (describe-key-briefly key insert)))
4875 (defun gnus-article-reply-with-original (&optional wide)
4876 "Start composing a reply mail to the current message.
4877 The text in the region will be yanked. If the region isn't active,
4878 the entire article will be yanked."
4880 (let ((article (cdr gnus-article-current)) cont)
4882 (with-current-buffer gnus-summary-buffer
4883 (gnus-summary-reply (list (list article)) wide))
4884 (setq cont (buffer-substring (point) (mark t)))
4885 ;; Deactivate active regions.
4886 (when (and (boundp 'transient-mark-mode)
4887 transient-mark-mode)
4888 (setq mark-active nil))
4889 (with-current-buffer gnus-summary-buffer
4891 (list (list article cont)) wide)))))
4893 (defun gnus-article-followup-with-original ()
4894 "Compose a followup to the current article.
4895 The text in the region will be yanked. If the region isn't active,
4896 the entire article will be yanked."
4898 (let ((article (cdr gnus-article-current)) cont)
4900 (with-current-buffer gnus-summary-buffer
4901 (gnus-summary-followup (list (list article))))
4902 (setq cont (buffer-substring (point) (mark t)))
4903 ;; Deactivate active regions.
4904 (when (and (boundp 'transient-mark-mode)
4905 transient-mark-mode)
4906 (setq mark-active nil))
4907 (with-current-buffer gnus-summary-buffer
4908 (gnus-summary-followup
4909 (list (list article cont)))))))
4911 (defun gnus-article-hide (&optional arg force)
4912 "Hide all the gruft in the current article.
4913 This means that PGP stuff, signatures, cited text and (some)
4914 headers will be hidden.
4915 If given a prefix, show the hidden text instead."
4916 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4917 (gnus-article-hide-headers arg)
4918 (gnus-article-hide-list-identifiers arg)
4919 (gnus-article-hide-pgp arg)
4920 (gnus-article-hide-citation-maybe arg force)
4921 (gnus-article-hide-signature arg))
4923 (defun gnus-article-maybe-highlight ()
4924 "Do some article highlighting if article highlighting is requested."
4925 (when (gnus-visual-p 'article-highlight 'highlight)
4926 (gnus-article-highlight-some)))
4928 (defun gnus-check-group-server ()
4929 ;; Make sure the connection to the server is alive.
4930 (unless (gnus-server-opened
4931 (gnus-find-method-for-group gnus-newsgroup-name))
4932 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4933 (gnus-request-group gnus-newsgroup-name t)))
4936 (autoload 'nneething-get-file-name "nneething"))
4938 (defun gnus-request-article-this-buffer (article group)
4939 "Get an article and insert it into this buffer."
4940 (let (do-update-line sparse-header)
4944 (gnus-kill-all-overlays)
4945 (setq group (or group gnus-newsgroup-name))
4947 ;; Using `gnus-request-article' directly will insert the article into
4948 ;; `nntp-server-buffer' - so we'll save some time by not having to
4949 ;; copy it from the server buffer into the article buffer.
4951 ;; We only request an article by message-id when we do not have the
4952 ;; headers for it, so we'll have to get those.
4953 (when (stringp article)
4954 (gnus-read-header article))
4956 ;; If the article number is negative, that means that this article
4957 ;; doesn't belong in this newsgroup (possibly), so we find its
4958 ;; message-id and request it by id instead of number.
4959 (when (and (numberp article)
4961 (get-buffer gnus-summary-buffer)
4962 (gnus-buffer-exists-p gnus-summary-buffer))
4964 (set-buffer gnus-summary-buffer)
4965 (let ((header (gnus-summary-article-header article)))
4968 ((memq article gnus-newsgroup-sparse)
4969 ;; This is a sparse gap article.
4970 (setq do-update-line article)
4971 (setq article (mail-header-id header))
4972 (setq sparse-header (gnus-read-header article))
4973 (setq gnus-newsgroup-sparse
4974 (delq article gnus-newsgroup-sparse)))
4976 ;; It's a real article.
4977 (setq article (mail-header-id header)))
4979 ;; It is an extracted pseudo-article.
4980 (setq article 'pseudo)
4981 (gnus-request-pseudo-article header))))
4983 (let ((method (gnus-find-method-for-group
4984 gnus-newsgroup-name)))
4985 (when (and (eq (car method) 'nneething)
4987 (let ((dir (nneething-get-file-name
4988 (mail-header-id header))))
4989 (when (and (stringp dir)
4990 (file-directory-p dir))
4991 (setq article 'nneething)
4992 (gnus-group-enter-directory dir))))))))
4995 ;; Refuse to select canceled articles.
4996 ((and (numberp article)
4998 (get-buffer gnus-summary-buffer)
4999 (gnus-buffer-exists-p gnus-summary-buffer)
5000 (eq (cdr (save-excursion
5001 (set-buffer gnus-summary-buffer)
5002 (assq article gnus-newsgroup-reads)))
5003 gnus-canceled-mark))
5005 ;; We first check `gnus-original-article-buffer'.
5006 ((and (get-buffer gnus-original-article-buffer)
5009 (set-buffer gnus-original-article-buffer)
5010 (and (equal (car gnus-original-article) group)
5011 (eq (cdr gnus-original-article) article))))
5012 (insert-buffer-substring gnus-original-article-buffer)
5014 ;; Check the backlog.
5015 ((and gnus-keep-backlog
5016 (gnus-backlog-request-article group article (current-buffer)))
5018 ;; Check asynchronous pre-fetch.
5019 ((gnus-async-request-fetched-article group article (current-buffer))
5020 (gnus-async-prefetch-next group article gnus-summary-buffer)
5021 (when (and (numberp article) gnus-keep-backlog)
5022 (gnus-backlog-enter-article group article (current-buffer)))
5025 ((and gnus-use-cache
5027 (gnus-cache-request-article article group))
5029 ;; Check the agent cache.
5030 ((and gnus-agent gnus-agent-cache gnus-plugged
5032 (gnus-agent-request-article article group))
5034 ;; Get the article and put into the article buffer.
5035 ((or (stringp article)
5037 (let ((gnus-override-method gnus-override-method)
5038 (methods (and (stringp article)
5039 gnus-refer-article-method))
5040 (backend (car (gnus-find-method-for-group
5041 gnus-newsgroup-name)))
5043 (buffer-read-only nil))
5044 (if (or (not (listp methods))
5045 (and (symbolp (car methods))
5046 (assq (car methods) nnoo-definition-alist)))
5047 (setq methods (list methods)))
5048 (when (and (null gnus-override-method)
5050 (setq gnus-override-method (pop methods)))
5052 (when (eq gnus-override-method 'current)
5053 (setq gnus-override-method
5054 (with-current-buffer gnus-summary-buffer
5055 gnus-current-select-method)))
5057 (gnus-kill-all-overlays)
5058 (let ((gnus-newsgroup-name group))
5059 (gnus-check-group-server))
5061 ((gnus-request-article article group (current-buffer))
5062 (when (numberp article)
5063 (gnus-async-prefetch-next group article
5064 gnus-summary-buffer)
5065 (when gnus-keep-backlog
5066 (gnus-backlog-enter-article
5067 group article (current-buffer))))
5068 (setq result 'article))
5070 (setq gnus-override-method (pop methods)))
5071 ((not (string-match "^400 "
5072 (nnheader-get-report backend)))
5073 ;; If we get 400 server disconnect, reconnect and
5074 ;; retry; otherwise, assume the article has expired.
5075 (setq result 'done))))
5076 (and (eq result 'article) 'article)))
5080 ;; Associate this article with the current summary buffer.
5081 (setq gnus-article-current-summary gnus-summary-buffer)
5083 ;; Take the article from the original article buffer
5084 ;; and place it in the buffer it's supposed to be in.
5085 (when (and (get-buffer gnus-article-buffer)
5086 (equal (buffer-name (current-buffer))
5087 (buffer-name (get-buffer gnus-article-buffer))))
5089 (if (get-buffer gnus-original-article-buffer)
5090 (set-buffer gnus-original-article-buffer)
5091 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5092 (buffer-disable-undo)
5093 (setq major-mode 'gnus-original-article-mode)
5094 (setq buffer-read-only t))
5095 (let (buffer-read-only)
5097 (insert-buffer-substring gnus-article-buffer))
5098 (setq gnus-original-article (cons group article)))
5101 (run-hooks 'gnus-article-decode-hook)
5102 ;; Mark article as decoded or not.
5103 (setq gnus-article-decoded-p gnus-article-decode-hook))
5105 ;; Update sparse articles.
5106 (when (and do-update-line
5107 (or (numberp article)
5109 (let ((buf (current-buffer)))
5110 (set-buffer gnus-summary-buffer)
5111 (gnus-summary-update-article do-update-line sparse-header)
5112 (gnus-summary-goto-subject do-update-line nil t)
5113 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5115 (set-buffer buf))))))
5121 (defcustom gnus-article-edit-mode-hook nil
5122 "Hook run in article edit mode buffers."
5123 :group 'gnus-article-various
5126 (defvar gnus-article-edit-done-function nil)
5128 (defvar gnus-article-edit-mode-map nil)
5130 ;; Should we be using derived.el for this?
5131 (unless gnus-article-edit-mode-map
5132 (setq gnus-article-edit-mode-map (make-keymap))
5133 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5136 (gnus-define-keys gnus-article-edit-mode-map
5137 "\C-c?" describe-mode
5138 "\C-c\C-c" gnus-article-edit-done
5139 "\C-c\C-k" gnus-article-edit-exit
5140 "\C-c\C-f\C-t" message-goto-to
5141 "\C-c\C-f\C-o" message-goto-from
5142 "\C-c\C-f\C-b" message-goto-bcc
5143 ;;"\C-c\C-f\C-w" message-goto-fcc
5144 "\C-c\C-f\C-c" message-goto-cc
5145 "\C-c\C-f\C-s" message-goto-subject
5146 "\C-c\C-f\C-r" message-goto-reply-to
5147 "\C-c\C-f\C-n" message-goto-newsgroups
5148 "\C-c\C-f\C-d" message-goto-distribution
5149 "\C-c\C-f\C-f" message-goto-followup-to
5150 "\C-c\C-f\C-m" message-goto-mail-followup-to
5151 "\C-c\C-f\C-k" message-goto-keywords
5152 "\C-c\C-f\C-u" message-goto-summary
5153 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5154 "\C-c\C-f\C-a" message-gen-unsubscribed-mft
5155 "\C-c\C-b" message-goto-body
5156 "\C-c\C-i" message-goto-signature
5158 "\C-c\C-t" message-insert-to
5159 "\C-c\C-n" message-insert-newsgroups
5160 "\C-c\C-o" message-sort-headers
5161 "\C-c\C-e" message-elide-region
5162 "\C-c\C-v" message-delete-not-region
5163 "\C-c\C-z" message-kill-to-signature
5164 "\M-\r" message-newline-and-reformat
5165 "\C-c\C-a" mml-attach-file
5166 "\C-a" message-beginning-of-line
5168 "\M-;" comment-region)
5170 (gnus-define-keys (gnus-article-edit-wash-map
5171 "\C-c\C-w" gnus-article-edit-mode-map)
5172 "f" gnus-article-edit-full-stops))
5175 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5177 ["Fetch To" message-insert-to t]
5178 ["Fetch Newsgroups" message-insert-newsgroups t]
5180 ["To" message-goto-to t]
5181 ["From" message-goto-from t]
5182 ["Subject" message-goto-subject t]
5183 ["Cc" message-goto-cc t]
5184 ["Reply-To" message-goto-reply-to t]
5185 ["Summary" message-goto-summary t]
5186 ["Keywords" message-goto-keywords t]
5187 ["Newsgroups" message-goto-newsgroups t]
5188 ["Followup-To" message-goto-followup-to t]
5189 ["Mail-Followup-To" message-goto-mail-followup-to t]
5190 ["Distribution" message-goto-distribution t]
5191 ["Body" message-goto-body t]
5192 ["Signature" message-goto-signature t]))
5194 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5195 "Major mode for editing articles.
5196 This is an extended text-mode.
5198 \\{gnus-article-edit-mode-map}"
5199 (make-local-variable 'gnus-article-edit-done-function)
5200 (make-local-variable 'gnus-prev-winconf)
5201 (set (make-local-variable 'font-lock-defaults)
5202 '(message-font-lock-keywords t))
5203 (set (make-local-variable 'mail-header-separator) "")
5204 (easy-menu-add message-mode-field-menu message-mode-map)
5206 (setq buffer-read-only nil)
5207 (buffer-enable-undo)
5210 (defun gnus-article-edit (&optional force)
5211 "Edit the current article.
5212 This will have permanent effect only in mail groups.
5213 If FORCE is non-nil, allow editing of articles even in read-only
5216 (when (and (not force)
5217 (gnus-group-read-only-p))
5218 (error "The current newsgroup does not support article editing"))
5219 (gnus-article-date-original)
5220 (gnus-article-edit-article
5222 `(lambda (no-highlight)
5224 (gnus-summary-edit-article-done
5225 ,(or (mail-header-references gnus-current-headers) "")
5226 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5228 (defun gnus-article-edit-article (start-func exit-func)
5229 "Start editing the contents of the current article buffer."
5230 (let ((winconf (current-window-configuration)))
5231 (set-buffer gnus-article-buffer)
5232 (gnus-article-edit-mode)
5233 (funcall start-func)
5234 (set-buffer-modified-p nil)
5235 (gnus-configure-windows 'edit-article)
5236 (setq gnus-article-edit-done-function exit-func)
5237 (setq gnus-prev-winconf winconf)
5238 (gnus-message 6 "C-c C-c to end edits")))
5240 (defun gnus-article-edit-done (&optional arg)
5241 "Update the article edits and exit."
5243 (let ((func gnus-article-edit-done-function)
5244 (buf (current-buffer))
5245 (start (window-start))
5247 (winconf gnus-prev-winconf))
5248 (widen) ;; Widen it in case that users narrowed the buffer.
5251 ;; The cache and backlog have to be flushed somewhat.
5252 (when gnus-keep-backlog
5253 (gnus-backlog-remove-article
5254 (car gnus-article-current) (cdr gnus-article-current)))
5255 ;; Flush original article as well.
5257 (when (get-buffer gnus-original-article-buffer)
5258 (set-buffer gnus-original-article-buffer)
5259 (setq gnus-original-article nil)))
5260 (when gnus-use-cache
5261 (gnus-cache-update-article
5262 (car gnus-article-current) (cdr gnus-article-current)))
5263 ;; We remove all text props from the article buffer.
5264 (kill-all-local-variables)
5265 (gnus-set-text-properties (point-min) (point-max) nil)
5267 (set-window-configuration winconf)
5269 (set-window-start (get-buffer-window buf) start)
5270 (set-window-point (get-buffer-window buf) (point))))
5272 (defun gnus-article-edit-exit ()
5273 "Exit the article editing without updating."
5275 (when (or (not (buffer-modified-p))
5276 (yes-or-no-p "Article modified; kill anyway? "))
5277 (let ((curbuf (current-buffer))
5279 (window-start (window-start)))
5281 (if (gnus-buffer-live-p gnus-original-article-buffer)
5282 (insert-buffer gnus-original-article-buffer))
5283 (let ((winconf gnus-prev-winconf))
5284 (kill-all-local-variables)
5286 (set-window-configuration winconf)
5287 ;; Tippy-toe some to make sure that point remains where it was.
5288 (save-current-buffer
5290 (set-window-start (get-buffer-window (current-buffer)) window-start)
5293 (defun gnus-article-edit-full-stops ()
5294 "Interactively repair spacing at end of sentences."
5297 (goto-char (point-min))
5298 (search-forward-regexp "^$" nil t)
5299 (let ((case-fold-search nil))
5300 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5303 ;;; Article highlights
5306 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5308 ;;; Internal Variables:
5310 (defcustom gnus-button-url-regexp
5311 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5312 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?[-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,[:word:]]+[-a-zA-Z0-9_=#$@~`%&*+|\\/[:word:]]\\)"
5313 "\\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\\)\\)")
5314 "Regular expression that matches URLs."
5315 :group 'gnus-article-buttons
5318 (defcustom gnus-button-man-handler 'manual-entry
5319 "Function to use for displaying man pages.
5320 The function must take at least one argument with a string naming the
5322 :type '(choice (function-item :tag "Man" manual-entry)
5323 (function-item :tag "Woman" woman)
5324 (function :tag "Other"))
5325 :group 'gnus-article-buttons)
5327 (defcustom gnus-button-prefer-mid-or-mail 'guess
5328 "What to do when the button on a string as \"foo123@bar.com\" is pushed.
5329 Strings like this can be either a message ID or a mail address. If the
5330 variable is set to the symbol `ask', query the user what do do. If it is the
5331 symbol `guess', Gnus will do a guess and query the user what do do if it is
5332 ambiguous. If it is one of the sybols `mid' or `mail', Gnus will always assume
5333 that the string is a message ID or a mail address, respectivly. See the
5334 variable `gnus-button-guessed-mid-regexp' for details concerning the
5336 ;; FIXME: doc-string could/should be improved.
5337 :group 'gnus-article-buttons
5338 :type '(choice (const ask)
5343 (defcustom gnus-button-guessed-mid-regexp
5345 "^<?\\(slrn\\|Pine\\.\\)"
5346 "\\|\\.fsf@\\|\\.fsf_-_@\\|\\.ln@"
5347 "\\|@4ax\\.com\\|@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de"
5348 "\\|^<?.*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*@")
5349 "Regular expression that matches message IDs and not mail addresses."
5350 ;; TODO: Incorporate more matches from
5351 ;; <URL:http://piology.org/perl/id-or-mail.pl.html>. I.e. translate the
5352 ;; Perl-REs to Elisp-REs.
5353 :group 'gnus-article-buttons
5356 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5357 (let* ((pref gnus-button-prefer-mid-or-mail)
5358 (url-mid (concat "news" ":" mid-or-mail))
5359 (url-mailto (concat "mailto" ":" mid-or-mail)))
5360 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5361 ;; If it looks like a MID (well known readers or servers) use 'mid,
5362 ;; otherwise 'ask the user.
5363 (if (eq pref 'guess)
5364 (if (string-match gnus-button-guessed-mid-regexp mid-or-mail)
5368 (save-window-excursion
5369 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5372 (cond ((eq pref 'mid)
5373 (gnus-message 9 "calling `gnus-button-handle-news' %s" url-mid)
5374 (gnus-button-handle-news url-mid))
5376 (gnus-message 9 "calling `gnus-url-mailto' %s" url-mailto)
5377 (gnus-url-mailto url-mailto)))))
5379 (defun gnus-button-handle-custom (url)
5380 "Follow a Custom URL."
5381 (customize-apropos (gnus-url-unhex-string url)))
5383 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5385 (defun gnus-button-handle-describe-function (url)
5386 "Call describe-function when pushing the corresponding URL button."
5389 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5391 (defun gnus-button-handle-describe-variable (url)
5392 "Call describe-variable when pushing the corresponding URL button."
5395 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5397 ;; FIXME: Is is possible to implement this? Else it should be removed here
5398 ;; and in `gnus-button-alist'.
5399 (defun gnus-button-handle-describe-key (url)
5400 "Call describe-key when pushing the corresponding URL button."
5401 (error "not implemented"))
5403 (defun gnus-button-handle-apropos (url)
5404 "Call apropos when pushing the corresponding URL button."
5405 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5407 (defun gnus-button-handle-apropos-command (url)
5408 "Call apropos when pushing the corresponding URL button."
5410 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5412 (defun gnus-button-handle-apropos-variable (url)
5413 "Call apropos when pushing the corresponding URL button."
5415 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5416 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5418 (defcustom gnus-button-man-level 5
5419 "*Integer that says how many man-related buttons Gnus will show.
5420 The higher the number, the more buttons will appear and the more false
5421 positves are possible. Note that you can set this variable local to
5422 specifific groups. Setting it higher in Unix groups is probably a good idea.
5423 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5424 how to set variables in specific groups."
5425 :group 'gnus-article-buttons
5426 :link '(custom-manual "(gnus)Group Parameters")
5429 (defcustom gnus-button-emacs-level 5
5430 "*Integer that says how many emacs-related buttons Gnus will show.
5431 The higher the number, the more buttons will appear and the more false
5432 positves are possible. Note that you can set this variable local to
5433 specifific groups. Setting it higher in Emacs or Gnus related groups is
5434 probably a good idea.See Info node `(gnus)Group Parameters' and the variable
5435 `gnus-parameters' on how to set variables in specific groups."
5436 :group 'gnus-article-buttons
5437 :link '(custom-manual "(gnus)Group Parameters")
5440 (defcustom gnus-button-mail-level 5
5441 "*Integer that says how many buttons for message IDs or mail addresses will appear.
5442 The higher the number, the more buttons will appear and the more false
5443 positves are possible."
5444 :group 'gnus-article-buttons
5447 (defcustom gnus-button-alist
5448 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5449 0 t gnus-button-handle-news 3)
5450 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5451 gnus-button-handle-news 2)
5452 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5454 gnus-button-fetch-group 4)
5455 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5456 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5457 t gnus-button-message-id 3)
5458 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5459 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5460 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5462 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5463 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2)
5465 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5466 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
5467 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5468 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
5469 ;; Emacs help commands
5470 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5471 ;; regexp doesn't match arguments containing ` '.
5472 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
5473 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5474 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
5475 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5476 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
5477 ("\\W\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5478 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
5479 ("\\W\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5480 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
5481 ("\\W\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+" 0
5482 ;; this regexp needs to be fixed!
5483 (>= gnus-button-emacs-level 9) gnus-button-handle-describe-key 2)
5484 ;; This is how URLs _should_ be embedded in text...
5485 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5487 (gnus-button-url-regexp 0 t browse-url 0)
5489 ("\\b\\([a-z][a-z]+\\)([0-9])\\W" 0
5490 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
5491 gnus-button-handle-man 1)
5492 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
5493 ("\\b\\([a-zA-Z][-_.a-zA-Z0-9]+\\)([0-9])\\W" 0
5494 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
5495 gnus-button-handle-man 1)
5496 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm), SoWWWAnchor(3iv)
5497 ("\\b\\([a-zA-Z][-_.:a-zA-Z0-9]+\\)([0-9][a-z]*)\\W" 0
5498 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
5499 ;; MID or mail: To avoid too many false positives we don't try to catch
5500 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
5501 ;; at least one dot. TLD must contain two or three chars or be a know TLD
5502 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
5503 ;; so that non-ambiguous entries (see above) match first.
5504 ("\\b\\(<?[a-zA-Z0-9][^<>\")!;:,{}\n\t ]*@[a-zA-Z0-9][-.a-zA-Z0-9]+\\.\\([a-zA-Z][a-zA-Z]\\([a-zA-Z]\\)?\\|[Ii][Nn][Ff][Oo]\\|[Nn][Aa][Mm][Ee]\\)>?\\)\\b"
5505 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1))
5506 "*Alist of regexps matching buttons in article bodies.
5508 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5509 REGEXP: is the string matching text around the button (can also be lisp
5510 expression evaluating to a string),
5511 BUTTON: is the number of the regexp grouping actually matching the button,
5512 FORM: is a lisp expression which must eval to true for the button to
5514 CALLBACK: is the function to call when the user push this button, and each
5515 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5517 CALLBACK can also be a variable, in that case the value of that
5518 variable it the real callback function."
5519 :group 'gnus-article-buttons
5520 :type '(repeat (list (choice regexp variable)
5521 (integer :tag "Button")
5523 (function :tag "Callback")
5526 (integer :tag "Regexp group")))))
5528 (defcustom gnus-header-button-alist
5529 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5530 0 t gnus-button-message-id 0)
5531 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5532 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5533 0 t gnus-button-mailto 0)
5534 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
5535 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
5536 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
5537 ("^[^:]+:" "\\bmailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5538 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5539 gnus-button-message-id 3))
5540 "*Alist of headers and regexps to match buttons in article heads.
5542 This alist is very similar to `gnus-button-alist', except that each
5543 alist has an additional HEADER element first in each entry:
5545 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5547 HEADER is a regexp to match a header. For a fuller explanation, see
5548 `gnus-button-alist'."
5549 :group 'gnus-article-buttons
5550 :group 'gnus-article-headers
5551 :type '(repeat (list (regexp :tag "Header")
5553 (integer :tag "Button")
5555 (function :tag "Callback")
5558 (integer :tag "Regexp group")))))
5560 (defvar gnus-button-regexp nil)
5561 (defvar gnus-button-marker-list nil)
5562 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5564 (defvar gnus-button-last nil)
5565 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5569 (defun gnus-article-push-button (event)
5570 "Check text under the mouse pointer for a callback function.
5571 If the text under the mouse pointer has a `gnus-callback' property,
5572 call it with the value of the `gnus-data' text property."
5574 (set-buffer (window-buffer (posn-window (event-start event))))
5575 (let* ((pos (posn-point (event-start event)))
5576 (data (get-text-property pos 'gnus-data))
5577 (fun (get-text-property pos 'gnus-callback)))
5580 (funcall fun data))))
5582 (defun gnus-article-press-button ()
5583 "Check text at point for a callback function.
5584 If the text at point has a `gnus-callback' property,
5585 call it with the value of the `gnus-data' text property."
5587 (let* ((data (get-text-property (point) 'gnus-data))
5588 (fun (get-text-property (point) 'gnus-callback)))
5590 (funcall fun data))))
5592 (defun gnus-article-highlight (&optional force)
5593 "Highlight current article.
5594 This function calls `gnus-article-highlight-headers',
5595 `gnus-article-highlight-citation',
5596 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5597 do the highlighting. See the documentation for those functions."
5598 (interactive (list 'force))
5599 (gnus-article-highlight-headers)
5600 (gnus-article-highlight-citation force)
5601 (gnus-article-highlight-signature)
5602 (gnus-article-add-buttons force)
5603 (gnus-article-add-buttons-to-head))
5605 (defun gnus-article-highlight-some (&optional force)
5606 "Highlight current article.
5607 This function calls `gnus-article-highlight-headers',
5608 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5609 do the highlighting. See the documentation for those functions."
5610 (interactive (list 'force))
5611 (gnus-article-highlight-headers)
5612 (gnus-article-highlight-signature)
5613 (gnus-article-add-buttons))
5615 (defun gnus-article-highlight-headers ()
5616 "Highlight article headers as specified by `gnus-header-face-alist'."
5619 (set-buffer gnus-article-buffer)
5621 (let ((alist gnus-header-face-alist)
5622 (buffer-read-only nil)
5623 (case-fold-search t)
5624 (inhibit-point-motion-hooks t)
5625 entry regexp header-face field-face from hpoints fpoints)
5626 (article-narrow-to-head)
5627 (while (setq entry (pop alist))
5628 (goto-char (point-min))
5629 (setq regexp (concat "^\\("
5630 (if (string-equal "" (nth 0 entry))
5634 header-face (nth 1 entry)
5635 field-face (nth 2 entry))
5636 (while (and (re-search-forward regexp nil t)
5640 (unless (search-forward ":" nil t)
5642 (when (and header-face
5643 (not (memq (point) hpoints)))
5644 (push (point) hpoints)
5645 (gnus-put-text-property from (point) 'face header-face))
5646 (when (and field-face
5647 (not (memq (setq from (point)) fpoints)))
5649 (if (re-search-forward "^[^ \t]" nil t)
5651 (goto-char (point-max)))
5652 (gnus-put-text-property from (point) 'face field-face))))))))
5654 (defun gnus-article-highlight-signature ()
5655 "Highlight the signature in an article.
5656 It does this by highlighting everything after
5657 `gnus-signature-separator' using `gnus-signature-face'."
5660 (set-buffer gnus-article-buffer)
5661 (let ((buffer-read-only nil)
5662 (inhibit-point-motion-hooks t))
5664 (when (and gnus-signature-face
5665 (gnus-article-narrow-to-signature))
5666 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5667 'face gnus-signature-face)
5669 (gnus-article-search-signature)
5670 (let ((start (match-beginning 0))
5671 (end (set-marker (make-marker) (1+ (match-end 0)))))
5672 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5675 (defun gnus-button-in-region-p (b e prop)
5676 "Say whether PROP exists in the region."
5677 (text-property-not-all b e prop nil))
5679 (defun gnus-article-add-buttons (&optional force)
5680 "Find external references in the article and make buttons of them.
5681 \"External references\" are things like Message-IDs and URLs, as
5682 specified by `gnus-button-alist'."
5683 (interactive (list 'force))
5685 (set-buffer gnus-article-buffer)
5686 (let ((buffer-read-only nil)
5687 (inhibit-point-motion-hooks t)
5688 (case-fold-search t)
5689 (alist gnus-button-alist)
5691 ;; Remove all old markers.
5692 (let (marker entry new-list)
5693 (while (setq marker (pop gnus-button-marker-list))
5694 (if (or (< marker (point-min)) (>= marker (point-max)))
5695 (push marker new-list)
5697 (when (setq entry (gnus-button-entry))
5698 (put-text-property (match-beginning (nth 1 entry))
5699 (match-end (nth 1 entry))
5700 'gnus-callback nil))
5701 (set-marker marker nil)))
5702 (setq gnus-button-marker-list new-list))
5703 ;; We skip the headers.
5706 (while (setq entry (pop alist))
5707 (setq regexp (eval (car entry)))
5709 (while (re-search-forward regexp nil t)
5710 (let* ((start (and entry (match-beginning (nth 1 entry))))
5711 (end (and entry (match-end (nth 1 entry))))
5712 (from (match-beginning 0)))
5713 (when (and (or (eq t (nth 2 entry))
5714 (eval (nth 2 entry)))
5715 (not (gnus-button-in-region-p
5716 start end 'gnus-callback)))
5717 ;; That optional form returned non-nil, so we add the
5719 (gnus-article-add-button
5720 start end 'gnus-button-push
5721 (car (push (set-marker (make-marker) from)
5722 gnus-button-marker-list))))))))))
5724 ;; Add buttons to the head of an article.
5725 (defun gnus-article-add-buttons-to-head ()
5726 "Add buttons to the head of the article."
5729 (set-buffer gnus-article-buffer)
5731 (let ((buffer-read-only nil)
5732 (inhibit-point-motion-hooks t)
5733 (case-fold-search t)
5734 (alist gnus-header-button-alist)
5736 (article-narrow-to-head)
5738 ;; Each alist entry.
5739 (setq entry (car alist)
5741 (goto-char (point-min))
5742 (while (re-search-forward (car entry) nil t)
5743 ;; Each header matching the entry.
5744 (setq beg (match-beginning 0))
5745 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5746 (match-beginning 0))
5749 (while (re-search-forward (eval (nth 1 entry)) end t)
5750 ;; Each match within a header.
5751 (let* ((entry (cdr entry))
5752 (start (match-beginning (nth 1 entry)))
5753 (end (match-end (nth 1 entry)))
5754 (form (nth 2 entry)))
5755 (goto-char (match-end 0))
5757 (gnus-article-add-button
5758 start end (nth 3 entry)
5759 (buffer-substring (match-beginning (nth 4 entry))
5760 (match-end (nth 4 entry)))))))
5761 (goto-char end)))))))
5763 ;;; External functions:
5765 (defun gnus-article-add-button (from to fun &optional data)
5766 "Create a button between FROM and TO with callback FUN and data DATA."
5767 (when gnus-article-button-face
5768 (gnus-overlay-put (gnus-make-overlay from to)
5769 'face gnus-article-button-face))
5770 (gnus-add-text-properties
5772 (nconc (and gnus-article-mouse-face
5773 (list gnus-mouse-face-prop gnus-article-mouse-face))
5774 (list 'gnus-callback fun)
5775 (and data (list 'gnus-data data))))
5776 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5777 :button-keymap gnus-widget-button-keymap))
5779 ;;; Internal functions:
5781 (defun gnus-article-set-globals ()
5783 (set-buffer gnus-summary-buffer)
5784 (gnus-set-global-variables)))
5786 (defun gnus-signature-toggle (end)
5788 (set-buffer gnus-article-buffer)
5789 (let ((buffer-read-only nil)
5790 (inhibit-point-motion-hooks t))
5791 (if (text-property-any end (point-max) 'article-type 'signature)
5793 (gnus-delete-wash-type 'signature)
5794 (gnus-remove-text-properties-when
5795 'article-type 'signature end (point-max)
5796 (cons 'article-type (cons 'signature
5797 gnus-hidden-properties))))
5798 (gnus-add-wash-type 'signature)
5799 (gnus-add-text-properties-when
5800 'article-type nil end (point-max)
5801 (cons 'article-type (cons 'signature
5802 gnus-hidden-properties)))))
5803 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5804 (gnus-set-mode-line 'article))))
5806 (defun gnus-button-entry ()
5807 ;; Return the first entry in `gnus-button-alist' matching this place.
5808 (let ((alist gnus-button-alist)
5811 (setq entry (pop alist))
5812 (if (looking-at (eval (car entry)))
5817 (defun gnus-button-push (marker)
5818 ;; Push button starting at MARKER.
5821 (let* ((entry (gnus-button-entry))
5822 (inhibit-point-motion-hooks t)
5824 (args (mapcar (lambda (group)
5825 (let ((string (match-string group)))
5826 (gnus-set-text-properties
5827 0 (length string) nil string)
5834 (fboundp (symbol-value fun)))
5835 (apply (symbol-value fun) args))
5837 (gnus-message 1 "You must define `%S' to use this button"
5838 (cons fun args)))))))
5840 (defun gnus-parse-news-url (url)
5841 (let (scheme server group message-id articles)
5844 (goto-char (point-min))
5845 (when (looking-at "\\([A-Za-z]+\\):")
5846 (setq scheme (match-string 1))
5847 (goto-char (match-end 0)))
5848 (when (looking-at "//\\([^/]+\\)/")
5849 (setq server (match-string 1))
5850 (goto-char (match-end 0)))
5853 ((looking-at "\\(.*@.*\\)")
5854 (setq message-id (match-string 1)))
5855 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5856 (setq group (match-string 1)
5857 articles (split-string (match-string 2) "-")))
5858 ((looking-at "\\([^/]+\\)/?")
5859 (setq group (match-string 1)))
5861 (error "Unknown news URL syntax"))))
5862 (list scheme server group message-id articles)))
5864 (defun gnus-button-handle-news (url)
5866 (destructuring-bind (scheme server group message-id articles)
5867 (gnus-parse-news-url url)
5871 (set-buffer gnus-summary-buffer)
5873 (let ((gnus-refer-article-method (list (list 'nntp server))))
5874 (gnus-summary-refer-article message-id))
5875 (gnus-summary-refer-article message-id))))
5877 (gnus-button-fetch-group url)))))
5879 (defun gnus-button-handle-man (url)
5881 (funcall gnus-button-man-handler url))
5883 (defun gnus-button-handle-info (url)
5884 "Fetch an info URL."
5886 "^\\([^:/]+\\)?/\\(.*\\)"
5888 (gnus-info-find-node
5889 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5892 (gnus-url-unhex-string (match-string 2 url))))
5893 (error "Can't parse %s" url)))
5895 (defun gnus-button-message-id (message-id)
5898 (set-buffer gnus-summary-buffer)
5899 (gnus-summary-refer-article message-id)))
5901 (defun gnus-button-fetch-group (address)
5902 "Fetch GROUP specified by ADDRESS."
5903 (if (not (string-match "[:/]" address))
5904 ;; This is just a simple group url.
5905 (gnus-group-read-ephemeral-group address gnus-select-method)
5908 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5910 (error "Can't parse %s" address)
5911 (gnus-group-read-ephemeral-group
5912 (match-string 4 address)
5913 `(nntp ,(match-string 1 address)
5914 (nntp-address ,(match-string 1 address))
5915 (nntp-port-number ,(if (match-end 3)
5916 (match-string 3 address)
5919 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5921 (defun gnus-url-parse-query-string (query &optional downcase)
5922 (let (retval pairs cur key val)
5923 (setq pairs (split-string query "&"))
5925 (setq cur (car pairs)
5927 (if (not (string-match "=" cur))
5929 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5930 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
5932 (setq key (downcase key)))
5933 (setq cur (assoc key retval))
5935 (setcdr cur (cons val (cdr cur)))
5936 (setq retval (cons (list key val) retval)))))
5939 (defun gnus-url-mailto (url)
5940 ;; Send mail to someone
5941 (when (string-match "mailto:/*\\(.*\\)" url)
5942 (setq url (substring url (match-beginning 1) nil)))
5943 (let (to args subject func)
5944 (if (string-match (regexp-quote "?") url)
5945 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5946 args (gnus-url-parse-query-string
5947 (substring url (match-end 0) nil) t))
5948 (setq to (gnus-url-unhex-string url)))
5949 (setq args (cons (list "to" to) args)
5950 subject (cdr-safe (assoc "subject" args)))
5953 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5956 (message-position-on-field (caar args)))
5957 (insert (mapconcat 'identity (cdar args) ", "))
5958 (setq args (cdr args)))
5961 (message-goto-subject))))
5963 (defun gnus-button-embedded-url (address)
5964 "Activate ADDRESS with `browse-url'."
5965 (browse-url (gnus-strip-whitespace address)))
5967 ;;; Next/prev buttons in the article buffer.
5969 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5970 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5972 (defvar gnus-prev-page-map
5973 (let ((map (make-sparse-keymap)))
5974 (unless (>= emacs-major-version 21)
5975 ;; XEmacs doesn't care.
5976 (set-keymap-parent map gnus-article-mode-map))
5977 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5978 (define-key map "\r" 'gnus-button-prev-page)
5981 (defun gnus-insert-prev-page-button ()
5983 (buffer-read-only nil))
5985 gnus-prev-page-line-format nil
5986 `(,@(gnus-local-map-property gnus-prev-page-map)
5988 gnus-callback gnus-article-button-prev-page
5989 article-type annotation))
5990 (widget-convert-button
5992 :action 'gnus-button-prev-page
5993 :button-keymap gnus-prev-page-map)))
5995 (defvar gnus-prev-page-map
5996 (let ((map (make-sparse-keymap)))
5997 (unless (>= emacs-major-version 21)
5998 ;; XEmacs doesn't care.
5999 (set-keymap-parent map gnus-article-mode-map))
6000 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6001 (define-key map "\r" 'gnus-button-prev-page)
6004 (defvar gnus-next-page-map
6005 (let ((map (make-sparse-keymap)))
6006 (unless (>= emacs-major-version 21)
6007 ;; XEmacs doesn't care.
6008 (set-keymap-parent map gnus-article-mode-map))
6009 (define-key map gnus-mouse-2 'gnus-button-next-page)
6010 (define-key map "\r" 'gnus-button-next-page)
6013 (defun gnus-button-next-page (&optional args more-args)
6014 "Go to the next page."
6016 (let ((win (selected-window)))
6017 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6018 (gnus-article-next-page)
6019 (select-window win)))
6021 (defun gnus-button-prev-page (&optional args more-args)
6022 "Go to the prev page."
6024 (let ((win (selected-window)))
6025 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6026 (gnus-article-prev-page)
6027 (select-window win)))
6029 (defun gnus-insert-next-page-button ()
6031 (buffer-read-only nil))
6032 (gnus-eval-format gnus-next-page-line-format nil
6033 `(,@(gnus-local-map-property gnus-next-page-map)
6035 gnus-callback gnus-article-button-next-page
6036 article-type annotation))
6037 (widget-convert-button
6039 :action 'gnus-button-next-page
6040 :button-keymap gnus-next-page-map)))
6042 (defun gnus-article-button-next-page (arg)
6043 "Go to the next page."
6045 (let ((win (selected-window)))
6046 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6047 (gnus-article-next-page)
6048 (select-window win)))
6050 (defun gnus-article-button-prev-page (arg)
6051 "Go to the prev page."
6053 (let ((win (selected-window)))
6054 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6055 (gnus-article-prev-page)
6056 (select-window win)))
6058 (defvar gnus-decode-header-methods
6059 '(mail-decode-encoded-word-region)
6060 "List of methods used to decode headers.
6062 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6063 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6064 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6065 whose names match REGEXP.
6068 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6069 mail-decode-encoded-word-region
6070 (\"chinese\" . rfc1843-decode-region))
6073 (defvar gnus-decode-header-methods-cache nil)
6075 (defun gnus-multi-decode-header (start end)
6076 "Apply the functions from `gnus-encoded-word-methods' that match."
6077 (unless (and gnus-decode-header-methods-cache
6078 (eq gnus-newsgroup-name
6079 (car gnus-decode-header-methods-cache)))
6080 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6083 (nconc gnus-decode-header-methods-cache (list x))
6084 (if (and gnus-newsgroup-name
6085 (string-match (car x) gnus-newsgroup-name))
6086 (nconc gnus-decode-header-methods-cache
6088 gnus-decode-header-methods))
6089 (let ((xlist gnus-decode-header-methods-cache))
6092 (narrow-to-region start end)
6094 (funcall (pop xlist) (point-min) (point-max))))))
6097 ;;; Treatment top-level handling.
6100 (defun gnus-treat-article (condition &optional part-number total-parts type)
6101 (let ((length (- (point-max) (point-min)))
6102 (alist gnus-treatment-function-alist)
6103 (article-goto-body-goes-to-point-min-p t)
6107 (let ((list gnus-article-treat-types))
6109 (when (string-match (pop list) type)
6110 (throw 'found t)))))))
6111 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6113 (gnus-run-hooks 'gnus-part-display-hook)
6114 (while (setq elem (pop alist))
6117 (if (gnus-buffer-live-p gnus-summary-buffer)
6118 (set-buffer gnus-summary-buffer))
6119 (symbol-value (car elem))))
6120 (when (and (or (consp val)
6122 (gnus-treat-predicate val)
6123 (or (not (get (car elem) 'highlight))
6126 (funcall (cadr elem)))))))
6128 ;; Dynamic variables.
6130 (defvar part-number)
6131 (defvar total-parts)
6136 (defun gnus-treat-predicate (val)
6141 (stringp (car val)))
6142 (apply 'gnus-or (mapcar `(lambda (s)
6143 (string-match s ,(or gnus-newsgroup-name "")))
6146 (let ((pred (pop val)))
6149 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6151 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6153 (not (gnus-treat-predicate (car val))))
6155 (equal (car val) type))
6157 (error "%S is not a valid predicate" pred)))))
6165 (eq part-number total-parts))
6169 (error "%S is not a valid value" val))))
6171 (defun gnus-article-encrypt-body (protocol &optional n)
6172 "Encrypt the article body."
6175 (or gnus-article-encrypt-protocol
6176 (completing-read "Encrypt protocol: "
6177 gnus-article-encrypt-protocol-alist
6179 current-prefix-arg))
6180 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6182 (error (format "Can't find the encrypt protocol %s" protocol)))
6183 (if (member gnus-newsgroup-name '("nndraft:delayed"
6186 (error "Can't encrypt the article in group %s"
6187 gnus-newsgroup-name))
6188 (gnus-summary-iterate n
6190 (set-buffer gnus-summary-buffer)
6191 (let ((mail-parse-charset gnus-newsgroup-charset)
6192 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6193 (summary-buffer gnus-summary-buffer)
6195 (gnus-set-global-variables)
6196 (when (gnus-group-read-only-p)
6197 (error "The current newsgroup does not support article encrypt"))
6198 (gnus-summary-show-article t)
6200 (or (mail-header-references gnus-current-headers) ""))
6201 (set-buffer gnus-article-buffer)
6202 (let* ((buffer-read-only nil)
6204 (mapcar (lambda (field)
6205 (and (save-restriction
6206 (message-narrow-to-head)
6207 (goto-char (point-min))
6208 (search-forward field nil t))
6210 (message-narrow-to-field)
6211 (buffer-substring (point-min) (point-max))
6212 (delete-region (point-min) (point-max))
6214 '("Content-Type:" "Content-Transfer-Encoding:"
6215 "Content-Disposition:"))))
6216 (message-narrow-to-head)
6217 (message-remove-header "MIME-Version")
6218 (goto-char (point-max))
6219 (setq point (point))
6220 (insert (apply 'concat headers))
6222 (narrow-to-region point (point-max))
6223 (let ((message-options message-options))
6224 (message-options-set 'message-sender user-mail-address)
6225 (message-options-set 'message-recipients user-mail-address)
6226 (message-options-set 'message-sign-encrypt 'not)
6228 (goto-char (point-min))
6229 (insert "MIME-Version: 1.0\n")
6231 (gnus-summary-edit-article-done
6232 references nil summary-buffer t))
6233 (when gnus-keep-backlog
6234 (gnus-backlog-remove-article
6235 (car gnus-article-current) (cdr gnus-article-current)))
6237 (when (get-buffer gnus-original-article-buffer)
6238 (set-buffer gnus-original-article-buffer)
6239 (setq gnus-original-article nil)))
6240 (when gnus-use-cache
6241 (gnus-cache-update-article
6242 (car gnus-article-current) (cdr gnus-article-current))))))))
6244 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6245 "The following specs can be used:
6246 %t The security MIME type
6249 %D Details if button is pressed")
6251 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6252 "The following specs can be used:
6253 %t The security MIME type
6256 %D Details if button is pressed")
6258 (defvar gnus-mime-security-button-line-format-alist
6259 '((?t gnus-tmp-type ?s)
6260 (?i gnus-tmp-info ?s)
6261 (?d gnus-tmp-details ?s)
6262 (?D gnus-tmp-pressed-details ?s)))
6264 (defvar gnus-mime-security-button-map
6265 (let ((map (make-sparse-keymap)))
6266 (unless (>= (string-to-number emacs-version) 21)
6267 (set-keymap-parent map gnus-article-mode-map))
6268 (define-key map gnus-mouse-2 'gnus-article-push-button)
6269 (define-key map "\r" 'gnus-article-press-button)
6272 (defvar gnus-mime-security-details-buffer nil)
6274 (defvar gnus-mime-security-button-pressed nil)
6276 (defvar gnus-mime-security-show-details-inline t
6277 "If non-nil, show details in the article buffer.")
6279 (defun gnus-mime-security-verify-or-decrypt (handle)
6280 (mm-remove-parts (cdr handle))
6281 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6282 point buffer-read-only)
6284 (goto-char (car region)))
6286 (narrow-to-region (point) (point))
6287 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6288 (let* ((mm-verify-option 'known)
6289 (mm-decrypt-option 'known)
6290 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6291 (unless (eq nparts (cdr handle))
6292 (mm-destroy-parts (cdr handle))
6293 (setcdr handle nparts))))
6294 (setq point (point))
6295 (gnus-mime-display-security handle)
6296 (goto-char (point-max)))
6298 (delete-region (point) (cdr region))
6299 (set-marker (car region) nil)
6300 (set-marker (cdr region) nil))
6303 (defun gnus-mime-security-show-details (handle)
6304 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6306 (if gnus-mime-security-show-details-inline
6307 (let ((gnus-mime-security-button-pressed t)
6308 (gnus-mime-security-button-line-format
6309 (get-text-property (point) 'gnus-line-format))
6312 (while (eq (get-text-property (point) 'gnus-line-format)
6313 gnus-mime-security-button-line-format)
6317 (narrow-to-region (point) (point))
6318 (gnus-insert-mime-security-button handle))
6319 (delete-region (point)
6320 (or (text-property-not-all
6323 gnus-mime-security-button-line-format)
6325 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6326 (with-current-buffer gnus-mime-security-details-buffer
6329 (setq gnus-mime-security-details-buffer
6330 (gnus-get-buffer-create "*MIME Security Details*")))
6331 (with-current-buffer gnus-mime-security-details-buffer
6333 (goto-char (point-min)))
6334 (pop-to-buffer gnus-mime-security-details-buffer))
6335 (gnus-message 5 "No details."))))
6337 (defun gnus-mime-security-press-button (handle)
6338 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6339 (gnus-mime-security-show-details handle)
6340 (gnus-mime-security-verify-or-decrypt handle)))
6342 (defun gnus-insert-mime-security-button (handle &optional displayed)
6343 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6346 (or (nth 2 (assoc protocol mm-verify-function-alist))
6347 (nth 2 (assoc protocol mm-decrypt-function-alist))
6349 (if (equal (car handle) "multipart/signed")
6350 " Signed" " Encrypted")
6353 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6356 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6357 gnus-tmp-pressed-details
6359 (setq gnus-tmp-details
6360 (if gnus-tmp-details
6361 (concat "\n" gnus-tmp-details) ""))
6362 (setq gnus-tmp-pressed-details
6363 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6368 gnus-mime-security-button-line-format
6369 gnus-mime-security-button-line-format-alist
6370 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6371 gnus-callback gnus-mime-security-press-button
6372 gnus-line-format ,gnus-mime-security-button-line-format
6373 article-type annotation
6376 (widget-convert-button
6379 :action 'gnus-widget-press-button
6380 :button-keymap gnus-mime-security-button-map
6382 (lambda (widget/window &optional overlay pos)
6383 ;; Needed to properly clear the message due to a bug in
6384 ;; wid-edit (XEmacs only).
6385 (if (boundp 'help-echo-owns-message)
6386 (setq help-echo-owns-message t))
6389 (aref gnus-mouse-2 0))))))
6391 (defun gnus-mime-display-security (handle)
6393 (narrow-to-region (point) (point))
6394 (unless (gnus-unbuttonized-mime-type-p (car handle))
6395 (gnus-insert-mime-security-button handle))
6396 (gnus-mime-display-mixed (cdr handle))
6399 (unless (gnus-unbuttonized-mime-type-p (car handle))
6400 (let ((gnus-mime-security-button-line-format
6401 gnus-mime-security-button-end-line-format))
6402 (gnus-insert-mime-security-button handle)))
6403 (mm-set-handle-multipart-parameter
6405 (cons (set-marker (make-marker) (point-min))
6406 (set-marker (make-marker) (point-max))))))
6412 (run-hooks 'gnus-art-load-hook)
6414 ;;; gnus-art.el ends here