1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
43 (autoload 'gnus-msg-mail "gnus-msg" nil t)
44 (autoload 'gnus-button-mailto "gnus-msg")
45 (autoload 'gnus-button-reply "gnus-msg" nil t)
47 (defgroup gnus-article nil
49 :link '(custom-manual "(gnus)The Article Buffer")
52 (defgroup gnus-article-treat nil
53 "Treating article parts."
54 :link '(custom-manual "(gnus)Article Hiding")
57 (defgroup gnus-article-hiding nil
58 "Hiding article parts."
59 :link '(custom-manual "(gnus)Article Hiding")
62 (defgroup gnus-article-highlight nil
63 "Article highlighting."
64 :link '(custom-manual "(gnus)Article Highlighting")
68 (defgroup gnus-article-signature nil
70 :link '(custom-manual "(gnus)Article Signature")
73 (defgroup gnus-article-headers nil
75 :link '(custom-manual "(gnus)Hiding Headers")
78 (defgroup gnus-article-washing nil
79 "Special commands on articles."
80 :link '(custom-manual "(gnus)Article Washing")
83 (defgroup gnus-article-emphasis nil
84 "Fontisizing articles."
85 :link '(custom-manual "(gnus)Article Fontisizing")
88 (defgroup gnus-article-saving nil
90 :link '(custom-manual "(gnus)Saving Articles")
93 (defgroup gnus-article-mime nil
94 "Worshiping the MIME wonder."
95 :link '(custom-manual "(gnus)Using MIME")
98 (defgroup gnus-article-buttons nil
99 "Pushable buttons in the article buffer."
100 :link '(custom-manual "(gnus)Article Buttons")
101 :group 'gnus-article)
103 (defgroup gnus-article-various nil
104 "Other article options."
105 :link '(custom-manual "(gnus)Misc Article")
106 :group 'gnus-article)
108 (defcustom gnus-ignored-headers
111 (concat "^" header ":"))
112 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
113 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
114 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
115 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
116 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
117 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
118 "X-Attribution" "X-Originating-IP" "Delivered-To"
119 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
120 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
121 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
122 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
123 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
124 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
125 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
126 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
127 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
128 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
129 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
130 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
131 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
132 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
133 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
134 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
135 "List-[A-Za-z]+" "X-Listprocessor-Version"
136 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
137 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
138 "X-Received" "Content-length" "X-precedence"
139 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
140 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
141 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
142 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
143 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
144 "X-Content-length" "X-Posting-Agent" "Original-Received"
145 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
146 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
147 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
148 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
149 "X-Abuse-and-DMCA-Info" "X-Postfilter"))
150 "*All headers that start with this regexp will be hidden.
151 This variable can also be a list of regexps of headers to be ignored.
152 If `gnus-visible-headers' is non-nil, this variable will be ignored."
153 :type '(choice :custom-show nil
156 :group 'gnus-article-hiding)
158 (defcustom gnus-visible-headers
159 "^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:"
160 "*All headers that do not match this regexp will be hidden.
161 This variable can also be a list of regexp of headers to remain visible.
162 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
163 :type '(repeat :value-to-internal (lambda (widget value)
164 (custom-split-regexp-maybe value))
165 :match (lambda (widget value)
167 (widget-editable-list-match widget value)))
169 :group 'gnus-article-hiding)
171 (defcustom gnus-sorted-header-list
172 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
173 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
174 "*This variable is a list of regular expressions.
175 If it is non-nil, headers that match the regular expressions will
176 be placed first in the article buffer in the sequence specified by
178 :type '(repeat regexp)
179 :group 'gnus-article-hiding)
181 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
182 "Headers that are only to be displayed if they have interesting data.
183 Possible values in this list are:
185 'empty Headers with no content.
186 'newsgroups Newsgroup identical to Gnus group.
187 'to-address To identical to To-address.
188 'followup-to Followup-to identical to Newsgroups.
189 'reply-to Reply-to identical to From.
190 'date Date less than four days old.
191 'long-to To and/or Cc longer than 1024 characters.
192 'many-to Multiple To and/or Cc."
193 :type '(set (const :tag "Headers with no content." empty)
194 (const :tag "Newsgroups identical to Gnus group." newsgroups)
195 (const :tag "To identical to To-address." to-address)
196 (const :tag "Followup-to identical to Newsgroups." followup-to)
197 (const :tag "Reply-to identical to From." reply-to)
198 (const :tag "Date less than four days old." date)
199 (const :tag "To and/or Cc longer than 1024 characters." long-to)
200 (const :tag "Multiple To and/or Cc headers." many-to))
201 :group 'gnus-article-hiding)
203 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
204 "Regexp matching signature separator.
205 This can also be a list of regexps. In that case, it will be checked
206 from head to tail looking for a separator. Searches will be done from
207 the end of the buffer."
208 :type '(repeat string)
209 :group 'gnus-article-signature)
211 (defcustom gnus-signature-limit nil
212 "Provide a limit to what is considered a signature.
213 If it is a number, no signature may not be longer (in characters) than
214 that number. If it is a floating point number, no signature may be
215 longer (in lines) than that number. If it is a function, the function
216 will be called without any parameters, and if it returns nil, there is
217 no signature in the buffer. If it is a string, it will be used as a
218 regexp. If it matches, the text in question is not a signature."
219 :type '(choice (integer :value 200)
221 (function :value fun)
222 (regexp :value ".*"))
223 :group 'gnus-article-signature)
225 (defcustom gnus-hidden-properties '(invisible t intangible t)
226 "Property list to use for hiding text."
228 :group 'gnus-article-hiding)
230 ;; Fixme: This isn't the right thing for mixed graphical and and
231 ;; non-graphical frames in a session.
232 (defcustom gnus-article-x-face-command
233 (if (featurep 'xemacs)
234 (if (or (gnus-image-type-available-p 'xface)
235 (gnus-image-type-available-p 'pbm))
236 'gnus-display-x-face-in-from
237 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
238 (if (gnus-image-type-available-p 'pbm)
239 'gnus-display-x-face-in-from
240 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
242 "*String or function to be executed to display an X-Face header.
243 If it is a string, the command will be executed in a sub-shell
244 asynchronously. The compressed face will be piped to this command."
245 :type `(choice string
246 (function-item gnus-display-x-face-in-from)
250 :group 'gnus-article-washing)
252 (defcustom gnus-article-x-face-too-ugly nil
253 "Regexp matching posters whose face shouldn't be shown automatically."
254 :type '(choice regexp (const nil))
255 :group 'gnus-article-washing)
257 (defcustom gnus-article-banner-alist nil
258 "Banner alist for stripping.
260 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
262 :type '(repeat (cons symbol regexp))
263 :group 'gnus-article-washing)
265 (gnus-define-group-parameter
268 "Alist of regexps (to match group names) and banner."
269 :variable-group gnus-article-washing
271 '(choice :tag "Banner"
273 (const :tag "Remove signature" signature)
274 (symbol :tag "Item in `gnus-article-banner-alist'" none)
276 (const :tag "None" nil))
278 "If non-nil, specify how to remove `banners' from articles.
280 Symbol `signature' means to remove signatures delimited by
281 `gnus-signature-separator'. Any other symbol is used to look up a
282 regular expression to match the banner in `gnus-article-banner-alist'.
283 A string is used as a regular expression to match the banner
286 (defcustom gnus-article-address-banner-alist nil
287 "Alist of mail addresses and banners.
288 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
289 to match a mail address in the From: header, BANNER is one of a symbol
290 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
291 If ADDRESS matches author's mail address, it will remove things like
292 advertisements. For example:
294 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
298 (regexp :tag "Address")
299 (choice :tag "Banner" :value nil
300 (const :tag "Remove signature" signature)
301 (symbol :tag "Item in `gnus-article-banner-alist'" none)
303 (const :tag "None" nil))))
304 :group 'gnus-article-washing)
306 (defcustom gnus-emphasis-alist
308 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
313 ("_/" "/_" underline-italic)
314 ("_\\*" "\\*_" underline-bold)
315 ("\\*/" "/\\*" bold-italic)
316 ("_\\*/" "/\\*_" underline-bold-italic))))
320 (format format (car spec) (cadr spec))
321 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
323 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
324 2 3 gnus-emphasis-strikethru)
325 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
326 2 3 gnus-emphasis-underline)))
327 "*Alist that says how to fontify certain phrases.
328 Each item looks like this:
330 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
332 The first element is a regular expression to be matched. The second
333 is a number that says what regular expression grouping used to find
334 the entire emphasized word. The third is a number that says what
335 regexp grouping should be displayed and highlighted. The fourth
336 is the face used for highlighting."
337 :type '(repeat (list :value ("" 0 0 default)
339 (integer :tag "Match group")
340 (integer :tag "Emphasize group")
342 :group 'gnus-article-emphasis)
344 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
345 "A regexp to describe whitespace which should not be emphasized.
346 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
347 The former avoids underlining of leading and trailing whitespace,
348 and the latter avoids underlining any whitespace at all."
350 :group 'gnus-article-emphasis
353 (defface gnus-emphasis-bold '((t (:bold t)))
354 "Face used for displaying strong emphasized text (*word*)."
355 :group 'gnus-article-emphasis)
357 (defface gnus-emphasis-italic '((t (:italic t)))
358 "Face used for displaying italic emphasized text (/word/)."
359 :group 'gnus-article-emphasis)
361 (defface gnus-emphasis-underline '((t (:underline t)))
362 "Face used for displaying underlined emphasized text (_word_)."
363 :group 'gnus-article-emphasis)
365 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
366 "Face used for displaying underlined bold emphasized text (_*word*_)."
367 :group 'gnus-article-emphasis)
369 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
370 "Face used for displaying underlined italic emphasized text (_/word/_)."
371 :group 'gnus-article-emphasis)
373 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
374 "Face used for displaying bold italic emphasized text (/*word*/)."
375 :group 'gnus-article-emphasis)
377 (defface gnus-emphasis-underline-bold-italic
378 '((t (:bold t :italic t :underline t)))
379 "Face used for displaying underlined bold italic emphasized text.
380 Example: (_/*word*/_)."
381 :group 'gnus-article-emphasis)
383 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
384 "Face used for displaying strike-through text (-word-)."
385 :group 'gnus-article-emphasis)
387 (defface gnus-emphasis-highlight-words
388 '((t (:background "black" :foreground "yellow")))
389 "Face used for displaying highlighted words."
390 :group 'gnus-article-emphasis)
392 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
393 "Format for display of Date headers in article bodies.
394 See `format-time-string' for the possible values.
396 The variable can also be function, which should return a complete Date
397 header. The function is called with one argument, the time, which can
398 be fed to `format-time-string'."
399 :type '(choice string symbol)
400 :link '(custom-manual "(gnus)Article Date")
401 :group 'gnus-article-washing)
404 (autoload 'mail-extract-address-components "mail-extr"))
406 (defcustom gnus-save-all-headers t
407 "*If non-nil, don't remove any headers before saving."
408 :group 'gnus-article-saving
411 (defcustom gnus-prompt-before-saving 'always
412 "*This variable says how much prompting is to be done when saving articles.
413 If it is nil, no prompting will be done, and the articles will be
414 saved to the default files. If this variable is `always', each and
415 every article that is saved will be preceded by a prompt, even when
416 saving large batches of articles. If this variable is neither nil not
417 `always', there the user will be prompted once for a file name for
418 each invocation of the saving commands."
419 :group 'gnus-article-saving
420 :type '(choice (item always)
421 (item :tag "never" nil)
422 (sexp :tag "once" :format "%t\n" :value t)))
424 (defcustom gnus-saved-headers gnus-visible-headers
425 "Headers to keep if `gnus-save-all-headers' is nil.
426 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
427 If that variable is nil, however, all headers that match this regexp
428 will be kept while the rest will be deleted before saving."
429 :group 'gnus-article-saving
432 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
433 "A function to save articles in your favourite format.
434 The function must be interactively callable (in other words, it must
435 be an Emacs command).
437 Gnus provides the following functions:
439 * gnus-summary-save-in-rmail (Rmail format)
440 * gnus-summary-save-in-mail (Unix mail format)
441 * gnus-summary-save-in-folder (MH folder)
442 * gnus-summary-save-in-file (article format)
443 * gnus-summary-save-body-in-file (article body)
444 * gnus-summary-save-in-vm (use VM's folder format)
445 * gnus-summary-write-to-file (article format -- overwrite)."
446 :group 'gnus-article-saving
447 :type '(radio (function-item gnus-summary-save-in-rmail)
448 (function-item gnus-summary-save-in-mail)
449 (function-item gnus-summary-save-in-folder)
450 (function-item gnus-summary-save-in-file)
451 (function-item gnus-summary-save-body-in-file)
452 (function-item gnus-summary-save-in-vm)
453 (function-item gnus-summary-write-to-file)))
455 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
456 "A function generating a file name to save articles in Rmail format.
457 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
458 :group 'gnus-article-saving
461 (defcustom gnus-mail-save-name 'gnus-plain-save-name
462 "A function generating a file name to save articles in Unix mail format.
463 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
464 :group 'gnus-article-saving
467 (defcustom gnus-folder-save-name 'gnus-folder-save-name
468 "A function generating a file name to save articles in MH folder.
469 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
470 :group 'gnus-article-saving
473 (defcustom gnus-file-save-name 'gnus-numeric-save-name
474 "A function generating a file name to save articles in article format.
475 The function is called with NEWSGROUP, HEADERS, and optional
477 :group 'gnus-article-saving
480 (defcustom gnus-split-methods
481 '((gnus-article-archive-name)
482 (gnus-article-nndoc-name))
483 "*Variable used to suggest where articles are to be saved.
484 For instance, if you would like to save articles related to Gnus in
485 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
486 you could set this variable to something like:
488 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
489 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
491 This variable is an alist where the where the key is the match and the
492 value is a list of possible files to save in if the match is non-nil.
494 If the match is a string, it is used as a regexp match on the
495 article. If the match is a symbol, that symbol will be funcalled
496 from the buffer of the article to be saved with the newsgroup as the
497 parameter. If it is a list, it will be evaled in the same buffer.
499 If this form or function returns a string, this string will be used as
500 a possible file name; and if it returns a non-nil list, that list will
501 be used as possible file names."
502 :group 'gnus-article-saving
503 :type '(repeat (choice (list :value (fun) function)
504 (cons :value ("" "") regexp (repeat string))
507 (defcustom gnus-page-delimiter "^\^L"
508 "*Regexp describing what to use as article page delimiters.
509 The default value is \"^\^L\", which is a form linefeed at the
510 beginning of a line."
512 :group 'gnus-article-various)
514 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
515 "*The format specification for the article mode line.
516 See `gnus-summary-mode-line-format' for a closer description.
518 The following additional specs are available:
520 %w The article washing status.
521 %m The number of MIME parts in the article."
523 :group 'gnus-article-various)
525 (defcustom gnus-article-mode-hook nil
526 "*A hook for Gnus article mode."
528 :group 'gnus-article-various)
530 (when (featurep 'xemacs)
531 ;; Extracted from gnus-xmas-define in order to preserve user settings
532 (when (fboundp 'turn-off-scroll-in-place)
533 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
534 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
535 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
537 (defcustom gnus-article-menu-hook nil
538 "*Hook run after the creation of the article mode menu."
540 :group 'gnus-article-various)
542 (defcustom gnus-article-prepare-hook nil
543 "*A hook called after an article has been prepared in the article buffer."
545 :group 'gnus-article-various)
547 (defvar gnus-article-hide-pgp-hook nil)
548 (make-obsolete-variable 'gnus-article-hide-pgp-hook
549 "This variable is obsolete in Gnus 5.10.")
551 (defcustom gnus-article-button-face 'bold
552 "Face used for highlighting buttons in the article buffer.
554 An article button is a piece of text that you can activate by pressing
555 `RET' or `mouse-2' above it."
557 :group 'gnus-article-buttons)
559 (defcustom gnus-article-mouse-face 'highlight
560 "Face used for mouse highlighting in the article buffer.
562 Article buttons will be displayed in this face when the cursor is
565 :group 'gnus-article-buttons)
567 (defcustom gnus-signature-face 'gnus-signature-face
568 "Face used for highlighting a signature in the article buffer.
569 Obsolete; use the face `gnus-signature-face' for customizations instead."
571 :group 'gnus-article-highlight
572 :group 'gnus-article-signature)
574 (defface gnus-signature-face
577 "Face used for highlighting a signature in the article buffer."
578 :group 'gnus-article-highlight
579 :group 'gnus-article-signature)
581 (defface gnus-header-from-face
584 (:foreground "spring green"))
587 (:foreground "red3"))
590 "Face used for displaying from headers."
591 :group 'gnus-article-headers
592 :group 'gnus-article-highlight)
594 (defface gnus-header-subject-face
597 (:foreground "SeaGreen3"))
600 (:foreground "red4"))
602 (:bold t :italic t)))
603 "Face used for displaying subject headers."
604 :group 'gnus-article-headers
605 :group 'gnus-article-highlight)
607 (defface gnus-header-newsgroups-face
610 (:foreground "yellow" :italic t))
613 (:foreground "MidnightBlue" :italic t))
616 "Face used for displaying newsgroups headers."
617 :group 'gnus-article-headers
618 :group 'gnus-article-highlight)
620 (defface gnus-header-name-face
623 (:foreground "SeaGreen"))
626 (:foreground "maroon"))
629 "Face used for displaying header names."
630 :group 'gnus-article-headers
631 :group 'gnus-article-highlight)
633 (defface gnus-header-content-face
636 (:foreground "forest green" :italic t))
639 (:foreground "indianred4" :italic t))
641 (:italic t))) "Face used for displaying header content."
642 :group 'gnus-article-headers
643 :group 'gnus-article-highlight)
645 (defcustom gnus-header-face-alist
646 '(("From" nil gnus-header-from-face)
647 ("Subject" nil gnus-header-subject-face)
648 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
649 ("" gnus-header-name-face gnus-header-content-face))
650 "*Controls highlighting of article header.
652 An alist of the form (HEADER NAME CONTENT).
654 HEADER is a regular expression which should match the name of an
655 header header and NAME and CONTENT are either face names or nil.
657 The name of each header field will be displayed using the face
658 specified by the first element in the list where HEADER match the
659 header name and NAME is non-nil. Similarly, the content will be
660 displayed by the first non-nil matching CONTENT face."
661 :group 'gnus-article-headers
662 :group 'gnus-article-highlight
663 :type '(repeat (list (regexp :tag "Header")
665 (item :tag "skip" nil)
666 (face :value default))
667 (choice :tag "Content"
668 (item :tag "skip" nil)
669 (face :value default)))))
671 (defcustom gnus-article-decode-hook
672 '(article-decode-charset article-decode-encoded-words
673 article-decode-group-name)
674 "*Hook run to decode charsets in articles."
675 :group 'gnus-article-headers
678 (defcustom gnus-display-mime-function 'gnus-display-mime
679 "Function to display MIME articles."
680 :group 'gnus-article-mime
683 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
684 "Function used to decode headers.")
686 (defvar gnus-article-dumbquotes-map
706 "Table for MS-to-Latin1 translation.")
708 (defcustom gnus-ignored-mime-types nil
709 "List of MIME types that should be ignored by Gnus."
711 :group 'gnus-article-mime
712 :type '(repeat regexp))
714 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
715 "List of MIME types that should not be given buttons when rendered inline.
716 See also `gnus-buttonized-mime-types' which may override this variable.
717 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
719 :group 'gnus-article-mime
720 :type '(repeat regexp))
722 (defcustom gnus-buttonized-mime-types nil
723 "List of MIME types that should be given buttons when rendered inline.
724 If set, this variable overrides `gnus-unbuttonized-mime-types'.
725 To see e.g. security buttons you could set this to
726 `(\"multipart/signed\")'.
727 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
729 :group 'gnus-article-mime
730 :type '(repeat regexp))
732 (defcustom gnus-inhibit-mime-unbuttonizing nil
733 "If non-nil, all MIME parts get buttons.
734 When nil (the default value), then some MIME parts do not get buttons,
735 as described by the variables `gnus-buttonized-mime-types' and
736 `gnus-unbuttonized-mime-types'."
740 (defcustom gnus-body-boundary-delimiter "_"
741 "String used to delimit header and body.
742 This variable is used by `gnus-article-treat-body-boundary' which can
743 be controlled by `gnus-treat-body-boundary'."
744 :group 'gnus-article-various
745 :type '(choice (item :tag "None" :value nil)
748 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
749 "Defines the location of the faces database.
750 For information on obtaining this database of pretty pictures, please
751 see http://www.cs.indiana.edu/picons/ftp/index.html"
752 :type '(repeat directory)
753 :link '(url-link :tag "download"
754 "http://www.cs.indiana.edu/picons/ftp/index.html")
755 :link '(custom-manual "(gnus)Picons")
758 (defun gnus-picons-installed-p ()
759 "Say whether picons are installed on your machine."
760 (let ((installed nil))
761 (dolist (database gnus-picon-databases)
762 (when (file-exists-p database)
766 (defcustom gnus-article-mime-part-function nil
767 "Function called with a MIME handle as the argument.
768 This is meant for people who want to do something automatic based
769 on parts -- for instance, adding Vcard info to a database."
770 :group 'gnus-article-mime
773 (defcustom gnus-mime-multipart-functions nil
774 "An alist of MIME types to functions to display them."
776 :group 'gnus-article-mime
779 (defcustom gnus-article-date-lapsed-new-header nil
780 "Whether the X-Sent and Date headers can coexist.
781 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
782 either replace the old \"Date:\" header (if this variable is nil), or
783 be added below it (otherwise)."
785 :group 'gnus-article-headers
788 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
789 "Function called with a MIME handle as the argument.
790 This is meant for people who want to view first matched part.
791 For `undisplayed-alternative' (default), the first undisplayed
792 part or alternative part is used. For `undisplayed', the first
793 undisplayed part is used. For a function, the first part which
794 the function return t is used. For nil, the first part is
797 :group 'gnus-article-mime
799 (item :tag "first" :value nil)
800 (item :tag "undisplayed" :value undisplayed)
801 (item :tag "undisplayed or alternative"
802 :value undisplayed-alternative)
805 (defcustom gnus-mime-action-alist
806 '(("save to file" . gnus-mime-save-part)
807 ("save and strip" . gnus-mime-save-part-and-strip)
808 ("display as text" . gnus-mime-inline-part)
809 ("view the part" . gnus-mime-view-part)
810 ("pipe to command" . gnus-mime-pipe-part)
811 ("toggle display" . gnus-article-press-button)
812 ("toggle display" . gnus-article-view-part-as-charset)
813 ("view as type" . gnus-mime-view-part-as-type)
814 ("view internally" . gnus-mime-view-part-internally)
815 ("view externally" . gnus-mime-view-part-externally))
816 "An alist of actions that run on the MIME attachment."
817 :group 'gnus-article-mime
818 :type '(repeat (cons (string :tag "name")
822 ;;; The treatment variables
825 (defvar gnus-part-display-hook nil
826 "Hook called on parts that are to receive treatment.")
828 (defvar gnus-article-treat-custom
829 '(choice (const :tag "Off" nil)
831 (const :tag "Header" head)
832 (const :tag "Last" last)
833 (integer :tag "Less")
834 (repeat :tag "Groups" regexp)
835 (sexp :tag "Predicate")))
837 (defvar gnus-article-treat-head-custom
838 '(choice (const :tag "Off" nil)
839 (const :tag "Header" head)))
841 (defvar gnus-article-treat-types '("text/plain")
844 (defvar gnus-inhibit-treatment nil
845 "Whether to inhibit treatment.")
847 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
848 "Highlight the signature.
849 Valid values are nil, t, `head', `last', an integer or a predicate.
850 See Info node `(gnus)Customizing Articles'."
851 :group 'gnus-article-treat
852 :link '(custom-manual "(gnus)Customizing Articles")
853 :type gnus-article-treat-custom)
854 (put 'gnus-treat-highlight-signature 'highlight t)
856 (defcustom gnus-treat-buttonize 100000
858 Valid values are nil, t, `head', `last', an integer or a predicate.
859 See Info node `(gnus)Customizing Articles'."
860 :group 'gnus-article-treat
861 :link '(custom-manual "(gnus)Customizing Articles")
862 :type gnus-article-treat-custom)
863 (put 'gnus-treat-buttonize 'highlight t)
865 (defcustom gnus-treat-buttonize-head 'head
866 "Add buttons to the head.
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-head-custom)
872 (put 'gnus-treat-buttonize-head 'highlight t)
874 (defcustom gnus-treat-emphasize
875 (and (or window-system
877 (>= (string-to-number emacs-version) 21))
880 Valid values are nil, t, `head', `last', an integer or a predicate.
881 See Info node `(gnus)Customizing Articles' for details."
882 :group 'gnus-article-treat
883 :link '(custom-manual "(gnus)Customizing Articles")
884 :type gnus-article-treat-custom)
885 (put 'gnus-treat-emphasize 'highlight t)
887 (defcustom gnus-treat-strip-cr nil
888 "Remove carriage returns.
889 Valid values are nil, t, `head', `last', an integer or a predicate.
890 See Info node `(gnus)Customizing Articles' for details."
891 :group 'gnus-article-treat
892 :link '(custom-manual "(gnus)Customizing Articles")
893 :type gnus-article-treat-custom)
895 (defcustom gnus-treat-unsplit-urls nil
896 "Remove newlines from within URLs.
897 Valid values are nil, t, `head', `last', an integer or a predicate.
898 See Info node `(gnus)Customizing Articles' for details."
899 :group 'gnus-article-treat
900 :link '(custom-manual "(gnus)Customizing Articles")
901 :type gnus-article-treat-custom)
903 (defcustom gnus-treat-leading-whitespace nil
904 "Remove leading whitespace in headers.
905 Valid values are nil, t, `head', `last', an integer or a predicate.
906 See Info node `(gnus)Customizing Articles' for details."
907 :group 'gnus-article-treat
908 :link '(custom-manual "(gnus)Customizing Articles")
909 :type gnus-article-treat-custom)
911 (defcustom gnus-treat-hide-headers 'head
913 Valid values are nil, t, `head', `last', an integer or a predicate.
914 See Info node `(gnus)Customizing Articles' for details."
915 :group 'gnus-article-treat
916 :link '(custom-manual "(gnus)Customizing Articles")
917 :type gnus-article-treat-head-custom)
919 (defcustom gnus-treat-hide-boring-headers nil
920 "Hide boring headers.
921 Valid values are nil, t, `head', `last', an integer or a predicate.
922 See Info node `(gnus)Customizing Articles' for details."
923 :group 'gnus-article-treat
924 :link '(custom-manual "(gnus)Customizing Articles")
925 :type gnus-article-treat-head-custom)
927 (defcustom gnus-treat-hide-signature nil
929 Valid values are nil, t, `head', `last', an integer or a predicate.
930 See Info node `(gnus)Customizing Articles' for details."
931 :group 'gnus-article-treat
932 :link '(custom-manual "(gnus)Customizing Articles")
933 :type gnus-article-treat-custom)
935 (defcustom gnus-treat-fill-article nil
937 Valid values are nil, t, `head', `last', an integer or a predicate.
938 See Info node `(gnus)Customizing Articles' for details."
939 :group 'gnus-article-treat
940 :link '(custom-manual "(gnus)Customizing Articles")
941 :type gnus-article-treat-custom)
943 (defcustom gnus-treat-hide-citation nil
945 Valid values are nil, t, `head', `last', an integer or a predicate.
946 See Info node `(gnus)Customizing Articles' for details."
947 :group 'gnus-article-treat
948 :link '(custom-manual "(gnus)Customizing Articles")
949 :type gnus-article-treat-custom)
951 (defcustom gnus-treat-hide-citation-maybe nil
953 Valid values are nil, t, `head', `last', an integer or a predicate.
954 See Info node `(gnus)Customizing Articles' for details."
955 :group 'gnus-article-treat
956 :link '(custom-manual "(gnus)Customizing Articles")
957 :type gnus-article-treat-custom)
959 (defcustom gnus-treat-strip-list-identifiers 'head
960 "Strip list identifiers from `gnus-list-identifiers`.
961 Valid values are nil, t, `head', `last', an integer or a predicate.
962 See Info node `(gnus)Customizing Articles' for details."
964 :group 'gnus-article-treat
965 :link '(custom-manual "(gnus)Customizing Articles")
966 :type gnus-article-treat-custom)
968 (make-obsolete-variable 'gnus-treat-strip-pgp
969 "This option is obsolete in Gnus 5.10.")
971 (defcustom gnus-treat-strip-pem nil
972 "Strip PEM signatures.
973 Valid values are nil, t, `head', `last', an integer or a predicate.
974 See Info node `(gnus)Customizing Articles' for details."
975 :group 'gnus-article-treat
976 :link '(custom-manual "(gnus)Customizing Articles")
977 :type gnus-article-treat-custom)
979 (defcustom gnus-treat-strip-banner t
980 "Strip banners from articles.
981 The banner to be stripped is specified in the `banner' group parameter.
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-custom)
988 (defcustom gnus-treat-highlight-headers 'head
989 "Highlight the headers.
990 Valid values are nil, t, `head', `last', an integer or a predicate.
991 See Info node `(gnus)Customizing Articles' for details."
992 :group 'gnus-article-treat
993 :link '(custom-manual "(gnus)Customizing Articles")
994 :type gnus-article-treat-head-custom)
995 (put 'gnus-treat-highlight-headers 'highlight t)
997 (defcustom gnus-treat-highlight-citation t
998 "Highlight cited text.
999 Valid values are nil, t, `head', `last', an integer or a predicate.
1000 See Info node `(gnus)Customizing Articles' for details."
1001 :group 'gnus-article-treat
1002 :link '(custom-manual "(gnus)Customizing Articles")
1003 :type gnus-article-treat-custom)
1004 (put 'gnus-treat-highlight-citation 'highlight t)
1006 (defcustom gnus-treat-date-ut nil
1007 "Display the Date in UT (GMT).
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-local nil
1015 "Display the Date in the local timezone.
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-english nil
1023 "Display the Date in a format that can be read aloud in English.
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-lapsed nil
1031 "Display the Date header in a way that says how much time has elapsed.
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-original nil
1039 "Display the date in the original timezone.
1040 Valid values are nil, t, `head', `last', an integer or a predicate.
1041 See Info node `(gnus)Customizing Articles' for details."
1042 :group 'gnus-article-treat
1043 :link '(custom-manual "(gnus)Customizing Articles")
1044 :type gnus-article-treat-head-custom)
1046 (defcustom gnus-treat-date-iso8601 nil
1047 "Display the date in the ISO8601 format.
1048 Valid values are nil, t, `head', `last', an integer or a predicate.
1049 See Info node `(gnus)Customizing Articles' for details."
1051 :group 'gnus-article-treat
1052 :link '(custom-manual "(gnus)Customizing Articles")
1053 :type gnus-article-treat-head-custom)
1055 (defcustom gnus-treat-date-user-defined nil
1056 "Display the date in a user-defined format.
1057 The format is defined by the `gnus-article-time-format' variable.
1058 Valid values are nil, t, `head', `last', an integer or a predicate.
1059 See Info node `(gnus)Customizing Articles' for details."
1060 :group 'gnus-article-treat
1061 :link '(custom-manual "(gnus)Customizing Articles")
1062 :type gnus-article-treat-head-custom)
1064 (defcustom gnus-treat-strip-headers-in-body t
1065 "Strip the X-No-Archive header line from the beginning of the body.
1066 Valid values are nil, t, `head', `last', an integer or a predicate.
1067 See Info node `(gnus)Customizing Articles' for details."
1069 :group 'gnus-article-treat
1070 :link '(custom-manual "(gnus)Customizing Articles")
1071 :type gnus-article-treat-custom)
1073 (defcustom gnus-treat-strip-trailing-blank-lines nil
1074 "Strip trailing 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-leading-blank-lines nil
1082 "Strip leading 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-strip-multiple-blank-lines nil
1090 "Strip multiple blank 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-unfold-headers 'head
1098 "Unfold folded header lines.
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-headers nil
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-fold-newsgroups 'head
1114 "Fold the Newsgroups and Followup-To headers.
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)
1121 (defcustom gnus-treat-overstrike t
1122 "Treat overstrike highlighting.
1123 Valid values are nil, t, `head', `last', an integer or a predicate.
1124 See Info node `(gnus)Customizing Articles' for details."
1125 :group 'gnus-article-treat
1126 :link '(custom-manual "(gnus)Customizing Articles")
1127 :type gnus-article-treat-custom)
1128 (put 'gnus-treat-overstrike 'highlight t)
1130 (defcustom gnus-treat-display-xface
1131 (and (not noninteractive)
1132 (or (and (fboundp 'image-type-available-p)
1133 (image-type-available-p 'xbm)
1134 (string-match "^0x" (shell-command-to-string "uncompface")))
1135 (and (featurep 'xemacs)
1138 "Display X-Face headers.
1139 Valid values are nil, t, `head', `last', an integer or a predicate.
1140 See Info node `(gnus)Customizing Articles' and Info node
1141 `(gnus)X-Face' for details."
1142 :group 'gnus-article-treat
1144 :link '(custom-manual "(gnus)Customizing Articles")
1145 :link '(custom-manual "(gnus)X-Face")
1146 :type gnus-article-treat-head-custom)
1147 (put 'gnus-treat-display-xface 'highlight t)
1149 (defcustom gnus-treat-display-face
1150 (and (not noninteractive)
1151 (or (and (fboundp 'image-type-available-p)
1152 (image-type-available-p 'png))
1153 (and (featurep 'xemacs)
1156 "Display Face headers.
1157 Valid values are nil, t, `head', `last', an integer or a predicate.
1158 See Info node `(gnus)Customizing Articles' and Info node
1159 `(gnus)X-Face' for details."
1160 :group 'gnus-article-treat
1162 :link '(custom-manual "(gnus)Customizing Articles")
1163 :link '(custom-manual "(gnus)X-Face")
1164 :type gnus-article-treat-head-custom)
1165 (put 'gnus-treat-display-xface 'highlight t)
1167 (defcustom gnus-treat-display-smileys
1168 (if (or (and (featurep 'xemacs)
1170 (and (fboundp 'image-type-available-p)
1171 (image-type-available-p 'pbm)))
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)Smileys' for details."
1177 :group 'gnus-article-treat
1179 :link '(custom-manual "(gnus)Customizing Articles")
1180 :link '(custom-manual "(gnus)Smileys")
1181 :type gnus-article-treat-custom)
1182 (put 'gnus-treat-display-smileys 'highlight t)
1184 (defcustom gnus-treat-from-picon
1185 (if (and (gnus-image-type-available-p 'xpm)
1186 (gnus-picons-installed-p))
1188 "Display picons in the From header.
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-from-picon 'highlight t)
1199 (defcustom gnus-treat-mail-picon
1200 (if (and (gnus-image-type-available-p 'xpm)
1201 (gnus-picons-installed-p))
1203 "Display picons in To and Cc 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-mail-picon 'highlight t)
1214 (defcustom gnus-treat-newsgroups-picon
1215 (if (and (gnus-image-type-available-p 'xpm)
1216 (gnus-picons-installed-p))
1218 "Display picons in the Newsgroups and Followup-To headers.
1219 Valid values are nil, t, `head', `last', an integer or a predicate.
1220 See Info node `(gnus)Customizing Articles' and Info node
1221 `(gnus)Picons' for details."
1222 :group 'gnus-article-treat
1224 :link '(custom-manual "(gnus)Customizing Articles")
1225 :link '(custom-manual "(gnus)Picons")
1226 :type gnus-article-treat-head-custom)
1227 (put 'gnus-treat-newsgroups-picon 'highlight t)
1229 (defcustom gnus-treat-body-boundary
1230 (if (or gnus-treat-newsgroups-picon
1231 gnus-treat-mail-picon
1232 gnus-treat-from-picon)
1234 "Draw a boundary at the end of the headers.
1235 Valid values are nil, t, `head', `last', an integer or a predicate.
1236 See Info node `(gnus)Customizing Articles' for details."
1238 :group 'gnus-article-treat
1239 :link '(custom-manual "(gnus)Customizing Articles")
1240 :type gnus-article-treat-custom)
1242 (defcustom gnus-treat-capitalize-sentences nil
1243 "Capitalize sentence-starting words.
1244 Valid values are nil, t, `head', `last', an integer or a predicate.
1245 See Info node `(gnus)Customizing Articles' for details."
1247 :group 'gnus-article-treat
1248 :link '(custom-manual "(gnus)Customizing Articles")
1249 :type gnus-article-treat-custom)
1251 (defcustom gnus-treat-wash-html nil
1253 Valid values are nil, t, `head', `last', an integer or a predicate.
1254 See Info node `(gnus)Customizing Articles' for details."
1255 :group 'gnus-article-treat
1256 :link '(custom-manual "(gnus)Customizing Articles")
1257 :type gnus-article-treat-custom)
1259 (defcustom gnus-treat-fill-long-lines nil
1261 Valid values are nil, t, `head', `last', an integer or a predicate.
1262 See Info node `(gnus)Customizing Articles' for details."
1263 :group 'gnus-article-treat
1264 :link '(custom-manual "(gnus)Customizing Articles")
1265 :type gnus-article-treat-custom)
1267 (defcustom gnus-treat-play-sounds nil
1269 Valid values are nil, t, `head', `last', an integer or a predicate.
1270 See Info node `(gnus)Customizing Articles' for details."
1272 :group 'gnus-article-treat
1273 :link '(custom-manual "(gnus)Customizing Articles")
1274 :type gnus-article-treat-custom)
1276 (defcustom gnus-treat-translate nil
1277 "Translate articles from one language to another.
1278 Valid values are nil, t, `head', `last', an integer or a predicate.
1279 See Info node `(gnus)Customizing Articles' for details."
1281 :group 'gnus-article-treat
1282 :link '(custom-manual "(gnus)Customizing Articles")
1283 :type gnus-article-treat-custom)
1285 (defcustom gnus-treat-x-pgp-sig nil
1287 To automatically treat X-PGP-Sig, set it to head.
1288 Valid values are nil, t, `head', `last', an integer or a predicate.
1289 See Info node `(gnus)Customizing Articles' for details."
1290 :group 'gnus-article-treat
1291 :group 'mime-security
1292 :link '(custom-manual "(gnus)Customizing Articles")
1293 :type gnus-article-treat-custom)
1295 (defvar gnus-article-encrypt-protocol-alist
1296 '(("PGP" . mml2015-self-encrypt)))
1298 ;; Set to nil if more than one protocol added to
1299 ;; gnus-article-encrypt-protocol-alist.
1300 (defcustom gnus-article-encrypt-protocol "PGP"
1301 "The protocol used for encrypt articles.
1302 It is a string, such as \"PGP\". If nil, ask user."
1304 :group 'mime-security)
1306 (defvar gnus-article-wash-function nil
1307 "Function used for converting HTML into text.")
1309 ;;; Internal variables
1311 (defvar gnus-english-month-names
1312 '("January" "February" "March" "April" "May" "June" "July" "August"
1313 "September" "October" "November" "December"))
1315 (defvar article-goto-body-goes-to-point-min-p nil)
1316 (defvar gnus-article-wash-types nil)
1317 (defvar gnus-article-emphasis-alist nil)
1318 (defvar gnus-article-image-alist nil)
1320 (defvar gnus-article-mime-handle-alist-1 nil)
1321 (defvar gnus-treatment-function-alist
1322 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1323 (gnus-treat-strip-banner gnus-article-strip-banner)
1324 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1325 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1326 (gnus-treat-buttonize gnus-article-add-buttons)
1327 (gnus-treat-fill-article gnus-article-fill-cited-article)
1328 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1329 (gnus-treat-strip-cr gnus-article-remove-cr)
1330 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1331 (gnus-treat-date-ut gnus-article-date-ut)
1332 (gnus-treat-date-local gnus-article-date-local)
1333 (gnus-treat-date-english gnus-article-date-english)
1334 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1335 (gnus-treat-date-original gnus-article-date-original)
1336 (gnus-treat-date-user-defined gnus-article-date-user)
1337 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1338 (gnus-treat-display-xface gnus-article-display-x-face)
1339 (gnus-treat-display-face gnus-article-display-face)
1340 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1341 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1342 (gnus-treat-hide-signature gnus-article-hide-signature)
1343 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1344 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1345 (gnus-treat-strip-pem gnus-article-hide-pem)
1346 (gnus-treat-from-picon gnus-treat-from-picon)
1347 (gnus-treat-mail-picon gnus-treat-mail-picon)
1348 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1349 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1350 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1351 (gnus-treat-strip-trailing-blank-lines
1352 gnus-article-remove-trailing-blank-lines)
1353 (gnus-treat-strip-leading-blank-lines
1354 gnus-article-strip-leading-blank-lines)
1355 (gnus-treat-strip-multiple-blank-lines
1356 gnus-article-strip-multiple-blank-lines)
1357 (gnus-treat-overstrike gnus-article-treat-overstrike)
1358 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1359 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1360 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1361 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1362 (gnus-treat-display-smileys gnus-treat-smiley)
1363 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1364 (gnus-treat-wash-html gnus-article-wash-html)
1365 (gnus-treat-emphasize gnus-article-emphasize)
1366 (gnus-treat-hide-citation gnus-article-hide-citation)
1367 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1368 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1369 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1370 (gnus-treat-play-sounds gnus-earcon-display)))
1372 (defvar gnus-article-mime-handle-alist nil)
1373 (defvar article-lapsed-timer nil)
1374 (defvar gnus-article-current-summary nil)
1376 (defvar gnus-article-mode-syntax-table
1377 (let ((table (copy-syntax-table text-mode-syntax-table)))
1378 ;; This causes the citation match run O(2^n).
1379 ;; (modify-syntax-entry ?- "w" table)
1380 (modify-syntax-entry ?> ")<" table)
1381 (modify-syntax-entry ?< "(>" table)
1382 ;; make M-. in article buffers work for `foo' strings
1383 (modify-syntax-entry ?' " " table)
1384 (modify-syntax-entry ?` " " table)
1386 "Syntax table used in article mode buffers.
1387 Initialized from `text-mode-syntax-table.")
1389 (defvar gnus-save-article-buffer nil)
1391 (defvar gnus-article-mode-line-format-alist
1392 (nconc '((?w (gnus-article-wash-status) ?s)
1393 (?m (gnus-article-mime-part-status) ?s))
1394 gnus-summary-mode-line-format-alist))
1396 (defvar gnus-number-of-articles-to-be-saved nil)
1398 (defvar gnus-inhibit-hiding nil)
1400 ;;; Macros for dealing with the article buffer.
1402 (defmacro gnus-with-article-headers (&rest forms)
1404 (set-buffer gnus-article-buffer)
1406 (let ((buffer-read-only nil)
1407 (inhibit-point-motion-hooks t)
1408 (case-fold-search t))
1409 (article-narrow-to-head)
1412 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1413 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1415 (defmacro gnus-with-article-buffer (&rest forms)
1417 (set-buffer gnus-article-buffer)
1418 (let ((buffer-read-only nil))
1421 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1422 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1424 (defun gnus-article-goto-header (header)
1425 "Go to HEADER, which is a regular expression."
1426 (re-search-forward (concat "^\\(" header "\\):") nil t))
1428 (defsubst gnus-article-hide-text (b e props)
1429 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1430 (gnus-add-text-properties-when 'article-type nil b e props)
1431 (when (memq 'intangible props)
1433 (max (1- b) (point-min))
1434 b 'intangible (cddr (memq 'intangible props)))))
1436 (defsubst gnus-article-unhide-text (b e)
1437 "Remove hidden text properties from region between B and E."
1438 (remove-text-properties b e gnus-hidden-properties)
1439 (when (memq 'intangible gnus-hidden-properties)
1440 (put-text-property (max (1- b) (point-min))
1441 b 'intangible nil)))
1443 (defun gnus-article-hide-text-type (b e type)
1444 "Hide text of TYPE between B and E."
1445 (gnus-add-wash-type type)
1446 (gnus-article-hide-text
1447 b e (cons 'article-type (cons type gnus-hidden-properties))))
1449 (defun gnus-article-unhide-text-type (b e type)
1450 "Unhide text of TYPE between B and E."
1451 (gnus-delete-wash-type type)
1452 (remove-text-properties
1453 b e (cons 'article-type (cons type gnus-hidden-properties)))
1454 (when (memq 'intangible gnus-hidden-properties)
1455 (put-text-property (max (1- b) (point-min))
1456 b 'intangible nil)))
1458 (defun gnus-article-hide-text-of-type (type)
1459 "Hide text of TYPE in the current buffer."
1461 (let ((b (point-min))
1463 (while (setq b (text-property-any b e 'article-type type))
1464 (add-text-properties b (incf b) gnus-hidden-properties)))))
1466 (defun gnus-article-delete-text-of-type (type)
1467 "Delete text of TYPE in the current buffer."
1469 (let ((b (point-min)))
1470 (while (setq b (text-property-any b (point-max) 'article-type type))
1472 b (or (text-property-not-all b (point-max) 'article-type type)
1475 (defun gnus-article-delete-invisible-text ()
1476 "Delete all invisible text in the current buffer."
1478 (let ((b (point-min)))
1479 (while (setq b (text-property-any b (point-max) 'invisible t))
1481 b (or (text-property-not-all b (point-max) 'invisible t)
1484 (defun gnus-article-text-type-exists-p (type)
1485 "Say whether any text of type TYPE exists in the buffer."
1486 (text-property-any (point-min) (point-max) 'article-type type))
1488 (defsubst gnus-article-header-rank ()
1489 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1490 (let ((list gnus-sorted-header-list)
1493 (if (looking-at (car list))
1495 (setq list (cdr list))
1499 (defun article-hide-headers (&optional arg delete)
1500 "Hide unwanted headers and possibly sort them as well."
1502 ;; This function might be inhibited.
1503 (unless gnus-inhibit-hiding
1506 (let ((buffer-read-only nil)
1507 (case-fold-search t)
1508 (max (1+ (length gnus-sorted-header-list)))
1509 (ignored (when (not gnus-visible-headers)
1510 (cond ((stringp gnus-ignored-headers)
1511 gnus-ignored-headers)
1512 ((listp gnus-ignored-headers)
1513 (mapconcat 'identity gnus-ignored-headers
1516 (cond ((stringp gnus-visible-headers)
1517 gnus-visible-headers)
1518 ((and gnus-visible-headers
1519 (listp gnus-visible-headers))
1520 (mapconcat 'identity gnus-visible-headers "\\|"))))
1521 (inhibit-point-motion-hooks t)
1523 ;; First we narrow to just the headers.
1524 (article-narrow-to-head)
1525 ;; Hide any "From " lines at the beginning of (mail) articles.
1526 (while (looking-at "From ")
1529 (delete-region (point-min) (point)))
1530 ;; Then treat the rest of the header lines.
1531 ;; Then we use the two regular expressions
1532 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1533 ;; select which header lines is to remain visible in the
1535 (while (re-search-forward "^[^ \t:]*:" nil t)
1537 ;; Mark the rank of the header.
1539 (point) (1+ (point)) 'message-rank
1540 (if (or (and visible (looking-at visible))
1542 (not (looking-at ignored))))
1543 (gnus-article-header-rank)
1546 (message-sort-headers-1)
1547 (when (setq beg (text-property-any
1548 (point-min) (point-max) 'message-rank (+ 2 max)))
1549 ;; We delete the unwanted headers.
1550 (gnus-add-wash-type 'headers)
1551 (add-text-properties (point-min) (+ 5 (point-min))
1552 '(article-type headers dummy-invisible t))
1553 (delete-region beg (point-max))))))))
1555 (defun article-hide-boring-headers (&optional arg)
1556 "Toggle hiding of headers that aren't very interesting.
1557 If given a negative prefix, always show; if given a positive prefix,
1559 (interactive (gnus-article-hidden-arg))
1560 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1561 (not gnus-show-all-headers))
1564 (let ((buffer-read-only nil)
1565 (list gnus-boring-article-headers)
1566 (inhibit-point-motion-hooks t)
1568 (article-narrow-to-head)
1570 (setq elem (pop list))
1571 (goto-char (point-min))
1573 ;; Hide empty headers.
1575 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1577 (gnus-article-hide-text-type
1578 (progn (beginning-of-line) (point))
1581 (if (re-search-forward "^[^ \t]" nil t)
1585 ;; Hide boring Newsgroups header.
1586 ((eq elem 'newsgroups)
1587 (when (gnus-string-equal
1588 (gnus-fetch-field "newsgroups")
1589 (gnus-group-real-name
1590 (if (boundp 'gnus-newsgroup-name)
1593 (gnus-article-hide-header "newsgroups")))
1594 ((eq elem 'to-address)
1595 (let ((to (message-fetch-field "to"))
1597 (gnus-parameter-to-address
1598 (if (boundp 'gnus-newsgroup-name)
1599 gnus-newsgroup-name ""))))
1600 (when (and to to-address
1603 ;; only one address in To
1604 (nth 1 (mail-extract-address-components to))
1606 (gnus-article-hide-header "to"))))
1607 ((eq elem 'followup-to)
1608 (when (gnus-string-equal
1609 (message-fetch-field "followup-to")
1610 (message-fetch-field "newsgroups"))
1611 (gnus-article-hide-header "followup-to")))
1612 ((eq elem 'reply-to)
1613 (let ((from (message-fetch-field "from"))
1614 (reply-to (message-fetch-field "reply-to")))
1619 (nth 1 (mail-extract-address-components from))
1620 (nth 1 (mail-extract-address-components reply-to)))))
1621 (gnus-article-hide-header "reply-to"))))
1623 (let ((date (message-fetch-field "date")))
1625 (< (days-between (current-time-string) date)
1627 (gnus-article-hide-header "date"))))
1629 (let ((to (message-fetch-field "to"))
1630 (cc (message-fetch-field "cc")))
1631 (when (> (length to) 1024)
1632 (gnus-article-hide-header "to"))
1633 (when (> (length cc) 1024)
1634 (gnus-article-hide-header "cc"))))
1638 (goto-char (point-min))
1639 (while (re-search-forward "^to:" nil t)
1640 (setq to-count (1+ to-count)))
1641 (when (> to-count 1)
1642 (while (> to-count 0)
1643 (goto-char (point-min))
1645 (re-search-forward "^to:" nil nil to-count)
1647 (narrow-to-region (point) (point-max))
1648 (gnus-article-hide-header "to"))
1649 (setq to-count (1- to-count))))
1650 (goto-char (point-min))
1651 (while (re-search-forward "^cc:" nil t)
1652 (setq cc-count (1+ cc-count)))
1653 (when (> cc-count 1)
1654 (while (> cc-count 0)
1655 (goto-char (point-min))
1657 (re-search-forward "^cc:" nil nil cc-count)
1659 (narrow-to-region (point) (point-max))
1660 (gnus-article-hide-header "cc"))
1661 (setq cc-count (1- cc-count)))))))))))))
1663 (defun gnus-article-hide-header (header)
1665 (goto-char (point-min))
1666 (when (re-search-forward (concat "^" header ":") nil t)
1667 (gnus-article-hide-text-type
1668 (progn (beginning-of-line) (point))
1671 (if (re-search-forward "^[^ \t]" nil t)
1676 (defvar gnus-article-normalized-header-length 40
1677 "Length of normalized headers.")
1679 (defun article-normalize-headers ()
1680 "Make all header lines 40 characters long."
1682 (let ((buffer-read-only nil)
1686 (article-narrow-to-head)
1689 ((< (setq column (- (gnus-point-at-eol) (point)))
1690 gnus-article-normalized-header-length)
1692 (insert (make-string
1693 (- gnus-article-normalized-header-length column)
1695 ((> column gnus-article-normalized-header-length)
1696 (gnus-put-text-property
1698 (forward-char gnus-article-normalized-header-length)
1705 (forward-line 1))))))
1707 (defun article-treat-dumbquotes ()
1708 "Translate M****s*** sm*rtq**t*s into proper text.
1709 Note that this function guesses whether a character is a sm*rtq**t* or
1710 not, so it should only be used interactively.
1712 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1713 in an attempt to provide more quoting characters. If you see
1714 something like \\222 or \\264 where you're expecting some kind of
1715 apostrophe or quotation mark, then try this wash."
1717 (article-translate-strings gnus-article-dumbquotes-map))
1719 (defun article-translate-characters (from to)
1720 "Translate all characters in the body of the article according to FROM and TO.
1721 FROM is a string of characters to translate from; to is a string of
1722 characters to translate to."
1724 (when (article-goto-body)
1725 (let ((buffer-read-only nil)
1726 (x (make-string 225 ?x))
1728 (while (< (incf i) (length x))
1731 (while (< i (length from))
1732 (aset x (aref from i) (aref to i))
1734 (translate-region (point) (point-max) x)))))
1736 (defun article-translate-strings (map)
1737 "Translate all string in the body of the article according to MAP.
1738 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1740 (when (article-goto-body)
1741 (let ((buffer-read-only nil)
1743 (while (setq elem (pop map))
1745 (while (search-forward (car elem) nil t)
1746 (replace-match (cadr elem)))))))))
1748 (defun article-treat-overstrike ()
1749 "Translate overstrikes into bold text."
1752 (when (article-goto-body)
1753 (let ((buffer-read-only nil))
1754 (while (search-forward "\b" nil t)
1755 (let ((next (char-after))
1756 (previous (char-after (- (point) 2))))
1757 ;; We do the boldification/underlining by hiding the
1758 ;; overstrikes and putting the proper text property
1762 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1763 (put-text-property (point) (1+ (point)) 'face 'bold))
1765 (gnus-article-hide-text-type
1766 (1- (point)) (1+ (point)) 'overstrike)
1768 (- (point) 2) (1- (point)) 'face 'underline))
1770 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1772 (point) (1+ (point)) 'face 'underline)))))))))
1774 (defun gnus-article-treat-unfold-headers ()
1775 "Unfold folded message headers.
1776 Only the headers that fit into the current window width will be
1779 (gnus-with-article-headers
1783 (mail-header-narrow-to-field)
1784 (let ((header (buffer-substring (point-min) (point-max))))
1787 (goto-char (point-min))
1788 (while (re-search-forward "\n[\t ]" nil t)
1789 (replace-match " " t t)))
1790 (setq length (- (point-max) (point-min) 1)))
1791 (when (< length (window-width))
1792 (while (re-search-forward "\n[\t ]" nil t)
1793 (replace-match " " t t)))
1794 (goto-char (point-max)))))))
1796 (defun gnus-article-treat-fold-headers ()
1797 "Fold message headers."
1799 (gnus-with-article-headers
1802 (mail-header-narrow-to-field)
1803 (mail-header-fold-field)
1804 (goto-char (point-max))))))
1806 (defun gnus-treat-smiley ()
1807 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1809 (gnus-with-article-buffer
1810 (if (memq 'smiley gnus-article-wash-types)
1811 (gnus-delete-images 'smiley)
1813 (let ((images (smiley-region (point) (point-max))))
1815 (gnus-add-wash-type 'smiley)
1816 (dolist (image images)
1817 (gnus-add-image 'smiley image)))))))
1819 (defun gnus-article-remove-images ()
1820 "Remove all images from the article buffer."
1822 (gnus-with-article-buffer
1823 (dolist (elem gnus-article-image-alist)
1824 (gnus-delete-images (car elem)))))
1826 (defun gnus-article-treat-fold-newsgroups ()
1827 "Unfold folded message headers.
1828 Only the headers that fit into the current window width will be
1831 (gnus-with-article-headers
1832 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1834 (mail-header-narrow-to-field)
1835 (while (re-search-forward ", *" nil t)
1836 (replace-match ", " t t))
1837 (mail-header-fold-field)
1838 (goto-char (point-max))))))
1840 (defun gnus-article-treat-body-boundary ()
1841 "Place a boundary line at the end of the headers."
1843 (when (and gnus-body-boundary-delimiter
1844 (> (length gnus-body-boundary-delimiter) 0))
1845 (gnus-with-article-headers
1846 (goto-char (point-max))
1847 (let ((start (point)))
1848 (insert "X-Boundary: ")
1849 (gnus-add-text-properties start (point) '(invisible t intangible t))
1851 (while (>= (1- (window-width)) (length str))
1852 (setq str (concat str gnus-body-boundary-delimiter)))
1853 (substring str 0 (1- (window-width))))
1855 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1857 (defun article-fill-long-lines ()
1858 "Fill lines that are wider than the window width."
1861 (let ((buffer-read-only nil)
1862 (width (window-width (get-buffer-window (current-buffer)))))
1865 (let ((adaptive-fill-mode nil)) ;Why? -sm
1868 (when (>= (current-column) (min fill-column width))
1869 (narrow-to-region (min (1+ (point)) (point-max)) (gnus-point-at-bol))
1870 (let ((goback (point-marker)))
1871 (fill-paragraph nil)
1872 (goto-char (marker-position goback)))
1874 (forward-line 1)))))))
1876 (defun article-capitalize-sentences ()
1877 "Capitalize the first word in each sentence."
1880 (let ((buffer-read-only nil)
1881 (paragraph-start "^[\n\^L]"))
1885 (forward-sentence)))))
1887 (defun article-remove-cr ()
1888 "Remove trailing CRs and then translate remaining CRs into LFs."
1891 (let ((buffer-read-only nil))
1892 (goto-char (point-min))
1893 (while (re-search-forward "\r+$" nil t)
1894 (replace-match "" t t))
1895 (goto-char (point-min))
1896 (while (search-forward "\r" nil t)
1897 (replace-match "\n" t t)))))
1899 (defun article-remove-trailing-blank-lines ()
1900 "Remove all trailing blank lines from the article."
1903 (let ((buffer-read-only nil))
1904 (goto-char (point-max))
1908 (while (and (not (bobp))
1909 (looking-at "^[ \t]*$")
1910 (not (gnus-annotation-in-region-p
1911 (point) (gnus-point-at-eol))))
1916 (defun article-display-face ()
1917 "Display any Face headers in the header."
1919 (gnus-with-article-headers
1920 (let ((face (message-fetch-field "face")))
1922 (let ((png (gnus-convert-face-to-png face))
1925 (setq image (gnus-create-image png 'png t))
1926 (gnus-article-goto-header "from")
1928 (insert "From: [no `from' set]\n")
1930 (gnus-add-wash-type 'face)
1931 (gnus-add-image 'face image)
1932 (gnus-put-image image)))))))
1934 (defun article-display-x-face (&optional force)
1935 "Look for an X-Face header and display it if present."
1936 (interactive (list 'force))
1937 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1938 (gnus-with-article-headers
1939 ;; Delete the old process, if any.
1940 (when (process-status "article-x-face")
1941 (delete-process "article-x-face"))
1942 (if (memq 'xface gnus-article-wash-types)
1943 ;; We have already displayed X-Faces, so we remove them
1945 (gnus-delete-images 'xface)
1947 (let (x-faces from face)
1949 (when (and wash-face-p
1951 (goto-char (point-min))
1952 (not (re-search-forward
1953 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
1954 (gnus-buffer-live-p gnus-original-article-buffer))
1955 ;; If type `W f', use gnus-original-article-buffer,
1956 ;; otherwise use the current buffer because displaying
1957 ;; RFC822 parts calls this function too.
1958 (set-buffer gnus-original-article-buffer))
1960 (mail-narrow-to-head)
1961 (while (gnus-article-goto-header "X-Face")
1962 (push (mail-header-field-value) x-faces))
1963 (setq from (message-fetch-field "from"))))
1964 ;; Sending multiple EOFs to xv doesn't work, so we only do a
1965 ;; single external face.
1966 (when (stringp gnus-article-x-face-command)
1967 (setq x-faces (list (car x-faces))))
1968 (while (and (setq face (pop x-faces))
1969 gnus-article-x-face-command
1971 ;; Check whether this face is censored.
1972 (not gnus-article-x-face-too-ugly)
1973 (and gnus-article-x-face-too-ugly from
1974 (not (string-match gnus-article-x-face-too-ugly
1976 ;; We display the face.
1977 (if (symbolp gnus-article-x-face-command)
1978 ;; The command is a lisp function, so we call it.
1979 (if (gnus-functionp gnus-article-x-face-command)
1980 (funcall gnus-article-x-face-command face)
1981 (error "%s is not a function" gnus-article-x-face-command))
1982 ;; The command is a string, so we interpret the command
1983 ;; as a, well, command, and fork it off.
1984 (let ((process-connection-type nil))
1985 (process-kill-without-query
1987 "article-x-face" nil shell-file-name shell-command-switch
1988 gnus-article-x-face-command))
1991 (process-send-region "article-x-face"
1992 (point-min) (point-max)))
1993 (process-send-eof "article-x-face")))))))))
1995 (defun article-decode-mime-words ()
1996 "Decode all MIME-encoded words in the article."
1999 (set-buffer gnus-article-buffer)
2000 (let ((inhibit-point-motion-hooks t)
2002 (mail-parse-charset gnus-newsgroup-charset)
2003 (mail-parse-ignored-charsets
2004 (save-excursion (set-buffer gnus-summary-buffer)
2005 gnus-newsgroup-ignored-charsets)))
2006 (mail-decode-encoded-word-region (point-min) (point-max)))))
2008 (defun article-decode-charset (&optional prompt)
2009 "Decode charset-encoded text in the article.
2010 If PROMPT (the prefix), prompt for a coding system to use."
2012 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2014 (mail-parse-charset gnus-newsgroup-charset)
2015 (mail-parse-ignored-charsets
2016 (save-excursion (condition-case nil
2017 (set-buffer gnus-summary-buffer)
2019 gnus-newsgroup-ignored-charsets))
2020 ct cte ctl charset format)
2023 (article-narrow-to-head)
2024 (setq ct (message-fetch-field "Content-Type" t)
2025 cte (message-fetch-field "Content-Transfer-Encoding" t)
2026 ctl (and ct (ignore-errors
2027 (mail-header-parse-content-type ct)))
2030 (mm-read-coding-system "Charset to decode: "))
2032 (mail-content-type-get ctl 'charset)))
2033 format (and ctl (mail-content-type-get ctl 'format)))
2035 (setq cte (mail-header-strip cte)))
2036 (if (and ctl (not (string-match "/" (car ctl))))
2038 (goto-char (point-max)))
2041 (narrow-to-region (point) (point-max))
2042 (when (and (eq mail-parse-charset 'gnus-decoded)
2043 (eq (mm-body-7-or-8) '8bit))
2044 ;; The text code could have been decoded.
2045 (setq charset mail-parse-charset))
2046 (when (and (or (not ctl)
2047 (equal (car ctl) "text/plain"))
2048 (not format)) ;; article with format will decode later.
2050 charset (and cte (intern (downcase
2051 (gnus-strip-whitespace cte))))
2054 (defun article-decode-encoded-words ()
2055 "Remove encoded-word encoding from headers."
2056 (let ((inhibit-point-motion-hooks t)
2057 (mail-parse-charset gnus-newsgroup-charset)
2058 (mail-parse-ignored-charsets
2059 (save-excursion (condition-case nil
2060 (set-buffer gnus-summary-buffer)
2062 gnus-newsgroup-ignored-charsets))
2065 (article-narrow-to-head)
2066 (funcall gnus-decode-header-function (point-min) (point-max)))))
2068 (defun article-decode-group-name ()
2069 "Decode group names in `Newsgroups:'."
2070 (let ((inhibit-point-motion-hooks t)
2072 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2073 (when (and (or gnus-group-name-charset-method-alist
2074 gnus-group-name-charset-group-alist)
2075 (gnus-buffer-live-p gnus-original-article-buffer))
2076 (when (nnmail-fetch-field "Newsgroups")
2077 (nnheader-replace-header "Newsgroups"
2078 (gnus-decode-newsgroups
2079 (with-current-buffer
2080 gnus-original-article-buffer
2081 (nnmail-fetch-field "Newsgroups"))
2082 gnus-newsgroup-name method)))
2083 (when (nnmail-fetch-field "Followup-To")
2084 (nnheader-replace-header "Followup-To"
2085 (gnus-decode-newsgroups
2086 (with-current-buffer
2087 gnus-original-article-buffer
2088 (nnmail-fetch-field "Followup-To"))
2089 gnus-newsgroup-name method))))))
2091 (defun article-de-quoted-unreadable (&optional force read-charset)
2092 "Translate a quoted-printable-encoded article.
2093 If FORCE, decode the article whether it is marked as quoted-printable
2095 If READ-CHARSET, ask for a coding system."
2096 (interactive (list 'force current-prefix-arg))
2098 (let ((buffer-read-only nil) type charset)
2099 (if (gnus-buffer-live-p gnus-original-article-buffer)
2100 (with-current-buffer gnus-original-article-buffer
2102 (gnus-fetch-field "content-transfer-encoding"))
2103 (let* ((ct (gnus-fetch-field "content-type"))
2106 (mail-header-parse-content-type ct)))))
2107 (setq charset (and ctl
2108 (mail-content-type-get ctl 'charset)))
2109 (if (stringp charset)
2110 (setq charset (intern (downcase charset)))))))
2112 (setq charset (mm-read-coding-system "Charset: " charset)))
2114 (setq charset gnus-newsgroup-charset))
2116 (and type (let ((case-fold-search t))
2117 (string-match "quoted-printable" type))))
2119 (quoted-printable-decode-region
2120 (point) (point-max) (mm-charset-to-coding-system charset))))))
2122 (defun article-de-base64-unreadable (&optional force read-charset)
2123 "Translate a base64 article.
2124 If FORCE, decode the article whether it is marked as base64 not.
2125 If READ-CHARSET, ask for a coding system."
2126 (interactive (list 'force current-prefix-arg))
2128 (let ((buffer-read-only nil) type charset)
2129 (if (gnus-buffer-live-p gnus-original-article-buffer)
2130 (with-current-buffer gnus-original-article-buffer
2132 (gnus-fetch-field "content-transfer-encoding"))
2133 (let* ((ct (gnus-fetch-field "content-type"))
2136 (mail-header-parse-content-type ct)))))
2137 (setq charset (and ctl
2138 (mail-content-type-get ctl 'charset)))
2139 (if (stringp charset)
2140 (setq charset (intern (downcase charset)))))))
2142 (setq charset (mm-read-coding-system "Charset: " charset)))
2144 (setq charset gnus-newsgroup-charset))
2146 (and type (let ((case-fold-search t))
2147 (string-match "base64" type))))
2150 (narrow-to-region (point) (point-max))
2151 (base64-decode-region (point-min) (point-max))
2152 (mm-decode-coding-region
2153 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2158 (defun article-decode-HZ ()
2159 "Translate a HZ-encoded article."
2163 (let ((buffer-read-only nil))
2164 (rfc1843-decode-region (point-min) (point-max)))))
2166 (defun article-unsplit-urls ()
2167 "Remove the newlines that some other mailers insert into URLs."
2170 (let ((buffer-read-only nil))
2171 (goto-char (point-min))
2172 (while (re-search-forward
2173 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2174 (replace-match "\\1\\3" t)))
2175 (when (and gnus-display-mime-function (interactive-p))
2176 (funcall gnus-display-mime-function))))
2179 (defun article-wash-html (&optional read-charset)
2180 "Format an HTML article.
2181 If READ-CHARSET, ask for a coding system."
2184 (let ((buffer-read-only nil)
2186 (when (gnus-buffer-live-p gnus-original-article-buffer)
2187 (with-current-buffer gnus-original-article-buffer
2188 (let* ((ct (gnus-fetch-field "content-type"))
2191 (mail-header-parse-content-type ct)))))
2192 (setq charset (and ctl
2193 (mail-content-type-get ctl 'charset)))
2194 (when (stringp charset)
2195 (setq charset (intern (downcase charset)))))))
2197 (setq charset (mm-read-coding-system "Charset: " charset)))
2199 (setq charset gnus-newsgroup-charset))
2201 (save-window-excursion
2203 (narrow-to-region (point) (point-max))
2204 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2205 (entry (assq func mm-text-html-washer-alist)))
2207 (setq func (cdr entry)))
2209 ((gnus-functionp func)
2212 (apply (car func) (cdr func))))))))))
2214 (defun gnus-article-wash-html-with-w3 ()
2215 "Wash the current buffer with w3."
2217 (let ((w3-strict-width (window-width))
2218 (url-standalone-mode t)
2219 (url-gateway-unplugged t)
2220 (w3-honor-stylesheets nil))
2222 (w3-region (point-min) (point-max))
2225 (defun gnus-article-wash-html-with-w3m ()
2226 "Wash the current buffer with emacs-w3m."
2229 (narrow-to-region (point) (point-max))
2230 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2233 (w3m-display-inline-images mm-inline-text-html-with-images)
2234 w3m-force-redisplay)
2235 (w3m-region (point-min) (point-max)))
2236 (when mm-inline-text-html-with-w3m-keymap
2237 (add-text-properties
2238 (point-min) (point-max)
2239 (nconc (mm-w3m-local-map-property)
2240 '(mm-inline-text-html-with-w3m t))))))
2242 (defun article-hide-list-identifiers ()
2243 "Remove list identifies from the Subject header.
2244 The `gnus-list-identifiers' variable specifies what to do."
2246 (let ((inhibit-point-motion-hooks t)
2247 (regexp (if (consp gnus-list-identifiers)
2248 (mapconcat 'identity gnus-list-identifiers " *\\|")
2249 gnus-list-identifiers))
2254 (article-narrow-to-head)
2255 (goto-char (point-min))
2256 (while (re-search-forward
2257 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2259 (delete-region (match-beginning 2) (match-end 0))
2260 (beginning-of-line))
2261 (when (re-search-forward
2262 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2263 (delete-region (match-beginning 1) (match-end 1))))))))
2265 (defun article-hide-pem (&optional arg)
2266 "Toggle hiding of any PEM headers and signatures in the current article.
2267 If given a negative prefix, always show; if given a positive prefix,
2269 (interactive (gnus-article-hidden-arg))
2270 (unless (gnus-article-check-hidden-text 'pem arg)
2272 (let (buffer-read-only end)
2273 (goto-char (point-min))
2274 ;; Hide the horrendously ugly "header".
2275 (when (and (search-forward
2276 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2278 (setq end (1+ (match-beginning 0))))
2279 (gnus-add-wash-type 'pem)
2280 (gnus-article-hide-text-type
2282 (if (search-forward "\n\n" nil t)
2286 ;; Hide the trailer as well
2287 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2289 (gnus-article-hide-text-type
2290 (match-beginning 0) (match-end 0) 'pem)))))))
2292 (defun article-strip-banner ()
2293 "Strip the banner specified by the `banner' group parameter."
2297 (let ((inhibit-point-motion-hooks t)
2298 (banner (gnus-parameter-banner gnus-newsgroup-name))
2299 (gnus-signature-limit nil)
2300 buffer-read-only beg end)
2301 (when (and gnus-article-address-banner-alist
2304 (let ((from (save-restriction
2306 (article-narrow-to-head)
2307 (mail-fetch-field "from"))))
2310 (caar (mail-header-parse-addresses from))))
2312 (dolist (pair gnus-article-address-banner-alist)
2313 (when (string-match (car pair) from)
2314 (throw 'found (cdr pair)))))))))
2318 ((eq banner 'signature)
2319 (when (gnus-article-narrow-to-signature)
2322 (delete-region (point) (point-max))))
2324 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2325 (while (re-search-forward banner nil t)
2326 (delete-region (match-beginning 0) (match-end 0)))))
2328 (while (re-search-forward banner nil t)
2329 (delete-region (match-beginning 0) (match-end 0))))))))))
2331 (defun article-babel ()
2332 "Translate article using an online translation service."
2336 (set-buffer gnus-article-buffer)
2337 (when (article-goto-body)
2338 (let* ((buffer-read-only nil)
2341 (orig (buffer-substring start end))
2342 (trans (babel-as-string orig)))
2344 (narrow-to-region start end)
2345 (delete-region start end)
2348 (defun article-hide-signature (&optional arg)
2349 "Hide the signature in the current article.
2350 If given a negative prefix, always show; if given a positive prefix,
2352 (interactive (gnus-article-hidden-arg))
2353 (unless (gnus-article-check-hidden-text 'signature arg)
2356 (let ((buffer-read-only nil))
2357 (when (gnus-article-narrow-to-signature)
2358 (gnus-article-hide-text-type
2359 (point-min) (point-max) 'signature))))))
2360 (gnus-set-mode-line 'article))
2362 (defun article-strip-headers-in-body ()
2363 "Strip offensive headers from bodies."
2367 (let ((case-fold-search t))
2368 (when (looking-at "x-no-archive:")
2369 (gnus-delete-line)))))
2371 (defun article-strip-leading-blank-lines ()
2372 "Remove all blank lines from the beginning of the article."
2375 (let ((inhibit-point-motion-hooks t)
2377 (when (article-goto-body)
2378 (while (and (not (eobp))
2379 (looking-at "[ \t]*$"))
2380 (gnus-delete-line))))))
2382 (defun article-narrow-to-head ()
2383 "Narrow the buffer to the head of the message.
2384 Point is left at the beginning of the narrowed-to region."
2386 (goto-char (point-min))
2387 (if (search-forward "\n\n" nil 1)
2390 (goto-char (point-min)))
2392 (defun article-goto-body ()
2393 "Place point at the start of the body."
2394 (goto-char (point-min))
2396 ;; This variable is only bound when dealing with separate
2398 (article-goto-body-goes-to-point-min-p
2400 ((search-forward "\n\n" nil t)
2403 (goto-char (point-max))
2406 (defun article-strip-multiple-blank-lines ()
2407 "Replace consecutive blank lines with one empty line."
2410 (let ((inhibit-point-motion-hooks t)
2412 ;; First make all blank lines empty.
2414 (while (re-search-forward "^[ \t]+$" nil t)
2415 (unless (gnus-annotation-in-region-p
2416 (match-beginning 0) (match-end 0))
2417 (replace-match "" nil t)))
2418 ;; Then replace multiple empty lines with a single empty line.
2420 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2421 (unless (gnus-annotation-in-region-p
2422 (match-beginning 0) (match-end 0))
2423 (delete-region (match-beginning 1) (match-end 1)))))))
2425 (defun article-strip-leading-space ()
2426 "Remove all white space from the beginning of the lines in the article."
2429 (let ((inhibit-point-motion-hooks t)
2432 (while (re-search-forward "^[ \t]+" nil t)
2433 (replace-match "" t t)))))
2435 (defun article-strip-trailing-space ()
2436 "Remove all white space from the end of the lines in the article."
2439 (let ((inhibit-point-motion-hooks t)
2442 (while (re-search-forward "[ \t]+$" nil t)
2443 (replace-match "" t t)))))
2445 (defun article-strip-blank-lines ()
2446 "Strip leading, trailing and multiple blank lines."
2448 (article-strip-leading-blank-lines)
2449 (article-remove-trailing-blank-lines)
2450 (article-strip-multiple-blank-lines))
2452 (defun article-strip-all-blank-lines ()
2453 "Strip all blank lines."
2456 (let ((inhibit-point-motion-hooks t)
2459 (while (re-search-forward "^[ \t]*\n" nil t)
2460 (replace-match "" t t)))))
2462 (defun gnus-article-narrow-to-signature ()
2463 "Narrow to the signature; return t if a signature is found, else nil."
2464 (let ((inhibit-point-motion-hooks t))
2465 (when (gnus-article-search-signature)
2467 ;; Check whether we have some limits to what we consider
2468 ;; to be a signature.
2469 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2470 (list gnus-signature-limit)))
2472 (while (setq limit (pop limits))
2473 (if (or (and (integerp limit)
2474 (< (- (point-max) (point)) limit))
2476 (< (count-lines (point) (point-max)) limit))
2477 (and (gnus-functionp limit)
2479 (and (stringp limit)
2480 (not (re-search-forward limit nil t))))
2481 () ; This limit did not succeed.
2485 (narrow-to-region (point) (point-max))
2488 (defun gnus-article-search-signature ()
2489 "Search the current buffer for the signature separator.
2490 Put point at the beginning of the signature separator."
2491 (let ((cur (point)))
2492 (goto-char (point-max))
2493 (if (if (stringp gnus-signature-separator)
2494 (re-search-backward gnus-signature-separator nil t)
2495 (let ((seps gnus-signature-separator))
2497 (not (re-search-backward (car seps) nil t)))
2504 (defun gnus-article-hidden-arg ()
2505 "Return the current prefix arg as a number, or 0 if no prefix."
2506 (list (if current-prefix-arg
2507 (prefix-numeric-value current-prefix-arg)
2510 (defun gnus-article-check-hidden-text (type arg)
2511 "Return nil if hiding is necessary.
2512 Arg can be nil or a number. nil and positive means hide, negative
2513 means show, 0 means toggle."
2516 (let ((hide (gnus-article-hidden-text-p type)))
2522 (gnus-article-show-hidden-text type)
2525 (if (eq hide 'hidden)
2527 (gnus-article-show-hidden-text type)
2531 (defun gnus-article-hidden-text-p (type)
2532 "Say whether the current buffer contains hidden text of type TYPE."
2533 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2535 (not (get-text-property pos 'invisible))
2536 (not (get-text-property pos 'dummy-invisible)))
2538 (text-property-any (1+ pos) (point-max) 'article-type type)))
2543 (defun gnus-article-show-hidden-text (type &optional dummy)
2544 "Show all hidden text of type TYPE.
2545 Originally it is hide instead of DUMMY."
2546 (let ((buffer-read-only nil)
2547 (inhibit-point-motion-hooks t))
2548 (gnus-remove-text-properties-when
2550 (point-min) (point-max)
2551 (cons 'article-type (cons type
2552 gnus-hidden-properties)))
2553 (gnus-delete-wash-type type)))
2555 (defconst article-time-units
2556 `((year . ,(* 365.25 24 60 60))
2557 (week . ,(* 7 24 60 60))
2558 (day . ,(* 24 60 60))
2562 "Mapping from time units to seconds.")
2564 (defun gnus-article-forward-header ()
2565 "Move point to the start of the next header.
2566 If the current header is a continuation header, this can be several
2571 (if (looking-at "[ \t]+[^ \t]")
2575 (defun article-date-ut (&optional type highlight header)
2576 "Convert DATE date to universal time in the current article.
2577 If TYPE is `local', convert to local time; if it is `lapsed', output
2578 how much time has lapsed since DATE. For `lapsed', the value of
2579 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2580 should replace the \"Date:\" one, or should be added below it."
2581 (interactive (list 'ut t))
2582 (let* ((header (or header
2583 (message-fetch-field "date")
2585 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2588 ((not gnus-article-date-lapsed-new-header)
2594 (date (if (vectorp header) (mail-header-date header)
2596 (inhibit-point-motion-hooks t)
2601 (article-narrow-to-head)
2602 (when (re-search-forward tdate-regexp nil t)
2603 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2604 date (or (get-text-property (gnus-point-at-bol)
2607 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2609 (when (and date (not (string= date "")))
2610 (goto-char (point-min))
2611 (let ((buffer-read-only nil))
2612 ;; Delete any old Date headers.
2613 (while (re-search-forward date-regexp nil t)
2615 (delete-region (progn (beginning-of-line) (point))
2616 (progn (gnus-article-forward-header)
2618 (delete-region (progn (beginning-of-line) (point))
2619 (progn (gnus-article-forward-header)
2622 (setq pos (point))))
2623 (when (and (not pos)
2624 (re-search-forward tdate-regexp nil t))
2628 (insert (article-make-date-line date (or type 'ut)))
2634 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2635 (put-text-property (match-beginning 1) (1+ (match-end 1))
2636 'original-date date)
2637 (put-text-property (match-beginning 1) (1+ (match-end 1))
2639 (put-text-property (match-beginning 2) (match-end 2)
2642 (defun article-make-date-line (date type)
2643 "Return a DATE line of TYPE."
2644 (unless (memq type '(local ut original user iso8601 lapsed english))
2645 (error "Unknown conversion type: %s" type))
2647 (let ((time (date-to-time date)))
2649 ;; Convert to the local timezone.
2651 (let ((tz (car (current-time-zone time))))
2652 (format "Date: %s %s%02d%02d" (current-time-string time)
2653 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2654 (/ (% (abs tz) 3600) 60))))
2655 ;; Convert to Universal Time.
2658 (current-time-string
2659 (let* ((e (parse-time-string date))
2660 (tm (apply 'encode-time e))
2662 (ls (- (cadr tm) (car (current-time-zone time)))))
2663 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2664 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2667 ;; Get the original date from the article.
2668 ((eq type 'original)
2669 (concat "Date: " (if (string-match "\n+$" date)
2670 (substring date 0 (match-beginning 0))
2672 ;; Let the user define the format.
2674 (let ((format (or (condition-case nil
2675 (with-current-buffer gnus-summary-buffer
2676 gnus-article-time-format)
2678 gnus-article-time-format)))
2679 (if (gnus-functionp format)
2680 (funcall format time)
2681 (concat "Date: " (format-time-string format time)))))
2684 (let ((tz (car (current-time-zone time))))
2687 (format-time-string "%Y%m%dT%H%M%S" time)
2688 (format "%s%02d%02d"
2689 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2690 (/ (% (abs tz) 3600) 60)))))
2691 ;; Do an X-Sent lapsed format.
2693 ;; If the date is seriously mangled, the timezone functions are
2694 ;; liable to bug out, so we ignore all errors.
2695 (let* ((now (current-time))
2696 (real-time (subtract-time now time))
2697 (real-sec (and real-time
2698 (+ (* (float (car real-time)) 65536)
2700 (sec (and real-time (abs real-sec)))
2710 ;; This is a bit convoluted, but basically we go
2711 ;; through the time units for years, weeks, etc,
2712 ;; and divide things to see whether that results
2713 ;; in positive answers.
2716 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2717 ;; The (remaining) seconds are too few to
2718 ;; be divided into this time unit.
2720 ;; It's big enough, so we output it.
2721 (setq sec (- sec (* num (cdr unit))))
2723 (concat (if prev ", " "") (int-to-string
2725 " " (symbol-name (car unit))
2726 (if (> num 1) "s" ""))
2728 article-time-units "")
2729 ;; If dates are odd, then it might appear like the
2730 ;; article was sent in the future.
2733 " in the future"))))))
2734 ;; Display the date in proper English
2736 (let ((dtime (decode-time time)))
2739 (number-to-string (nth 3 dtime))
2740 (let ((digit (% (nth 3 dtime) 10)))
2742 ((memq (nth 3 dtime) '(11 12 13)) "th")
2748 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2750 (number-to-string (nth 5 dtime))
2752 (format "%02d" (nth 2 dtime))
2754 (format "%02d" (nth 1 dtime)))))))
2756 (format "Date: %s (from Gnus)" date))))
2758 (defun article-date-local (&optional highlight)
2759 "Convert the current article date to the local timezone."
2760 (interactive (list t))
2761 (article-date-ut 'local highlight))
2763 (defun article-date-english (&optional highlight)
2764 "Convert the current article date to something that is proper English."
2765 (interactive (list t))
2766 (article-date-ut 'english highlight))
2768 (defun article-date-original (&optional highlight)
2769 "Convert the current article date to what it was originally.
2770 This is only useful if you have used some other date conversion
2771 function and want to see what the date was before converting."
2772 (interactive (list t))
2773 (article-date-ut 'original highlight))
2775 (defun article-date-lapsed (&optional highlight)
2776 "Convert the current article date to time lapsed since it was sent."
2777 (interactive (list t))
2778 (article-date-ut 'lapsed highlight))
2780 (defun article-update-date-lapsed ()
2781 "Function to be run from a timer to update the lapsed time line."
2782 (let (deactivate-mark)
2787 (set-buffer (window-buffer w))
2788 (when (eq major-mode 'gnus-article-mode)
2789 (goto-char (point-min))
2790 (when (re-search-forward "^X-Sent:" nil t)
2791 (article-date-lapsed t))))
2794 (defun gnus-start-date-timer (&optional n)
2795 "Start a timer to update the X-Sent header in the article buffers.
2796 The numerical prefix says how frequently (in seconds) the function
2801 (gnus-stop-date-timer)
2802 (setq article-lapsed-timer
2803 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2805 (defun gnus-stop-date-timer ()
2806 "Stop the X-Sent timer."
2808 (when article-lapsed-timer
2809 (nnheader-cancel-timer article-lapsed-timer)
2810 (setq article-lapsed-timer nil)))
2812 (defun article-date-user (&optional highlight)
2813 "Convert the current article date to the user-defined format.
2814 This format is defined by the `gnus-article-time-format' variable."
2815 (interactive (list t))
2816 (article-date-ut 'user highlight))
2818 (defun article-date-iso8601 (&optional highlight)
2819 "Convert the current article date to ISO8601."
2820 (interactive (list t))
2821 (article-date-ut 'iso8601 highlight))
2823 ;; (defun article-show-all ()
2824 ;; "Show all hidden text in the article buffer."
2827 ;; (let ((buffer-read-only nil))
2828 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2830 (defun article-remove-leading-whitespace ()
2831 "Remove excessive whitespace from all headers."
2835 (let ((buffer-read-only nil))
2836 (article-narrow-to-head)
2837 (goto-char (point-min))
2838 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2839 (delete-region (match-beginning 1) (match-end 1)))))))
2841 (defun article-emphasize (&optional arg)
2842 "Emphasize text according to `gnus-emphasis-alist'."
2843 (interactive (gnus-article-hidden-arg))
2844 (unless (gnus-article-check-hidden-text 'emphasis arg)
2848 (with-current-buffer gnus-summary-buffer
2849 gnus-article-emphasis-alist)
2851 gnus-emphasis-alist))
2852 (buffer-read-only nil)
2853 (props (append '(article-type emphasis)
2854 gnus-hidden-properties))
2855 regexp elem beg invisible visible face)
2858 (while (setq elem (pop alist))
2860 (setq regexp (car elem)
2861 invisible (nth 1 elem)
2862 visible (nth 2 elem)
2864 (while (re-search-forward regexp nil t)
2865 (when (and (match-beginning visible) (match-beginning invisible))
2866 (gnus-article-hide-text
2867 (match-beginning invisible) (match-end invisible) props)
2868 (gnus-article-unhide-text-type
2869 (match-beginning visible) (match-end visible) 'emphasis)
2870 (gnus-put-overlay-excluding-newlines
2871 (match-beginning visible) (match-end visible) 'face face)
2872 (gnus-add-wash-type 'emphasis)
2873 (goto-char (match-end invisible)))))))))
2875 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2876 "Setup newsgroup emphasis alist."
2877 (unless gnus-article-emphasis-alist
2878 (let ((name (and gnus-newsgroup-name
2879 (gnus-group-real-name gnus-newsgroup-name))))
2880 (make-local-variable 'gnus-article-emphasis-alist)
2881 (setq gnus-article-emphasis-alist
2883 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2884 (while (setq elem (pop alist))
2885 (when (and name (string-match (car elem) name))
2887 highlight (copy-sequence (cdr elem)))))
2889 (copy-sequence highlight-words)
2890 (if gnus-newsgroup-name
2891 (copy-sequence (gnus-group-find-parameter
2892 gnus-newsgroup-name 'highlight-words t)))
2893 gnus-emphasis-alist)))))
2896 (defvar gnus-summary-article-menu)
2897 (defvar gnus-summary-post-menu))
2899 ;;; Saving functions.
2901 (defun gnus-article-save (save-buffer file &optional num)
2902 "Save the currently selected article."
2903 (unless gnus-save-all-headers
2904 ;; Remove headers according to `gnus-saved-headers'.
2905 (let ((gnus-visible-headers
2906 (or gnus-saved-headers gnus-visible-headers))
2907 (gnus-article-buffer save-buffer))
2909 (set-buffer save-buffer)
2910 (article-hide-headers 1 t))))
2911 (save-window-excursion
2912 (if (not gnus-default-article-saver)
2913 (error "No default saver is defined")
2914 ;; !!! Magic! The saving functions all save
2915 ;; `gnus-save-article-buffer' (or so they think), but we
2916 ;; bind that variable to our save-buffer.
2917 (set-buffer gnus-article-buffer)
2918 (let* ((gnus-save-article-buffer save-buffer)
2921 ((not gnus-prompt-before-saving) 'default)
2922 ((eq gnus-prompt-before-saving 'always) nil)
2924 (gnus-number-of-articles-to-be-saved
2925 (when (eq gnus-prompt-before-saving t)
2927 (set-buffer gnus-article-current-summary)
2928 (funcall gnus-default-article-saver filename)))))
2930 (defun gnus-read-save-file-name (prompt &optional filename
2931 function group headers variable)
2933 (funcall function group headers (symbol-value variable)))
2938 ((eq filename 'default)
2944 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2947 (if (and gnus-number-of-articles-to-be-saved
2948 (> gnus-number-of-articles-to-be-saved 1))
2949 (format "these %d articles"
2950 gnus-number-of-articles-to-be-saved)
2953 ;; Let the split methods have their say.
2955 ;; No split name was found.
2958 (concat prompt " (default "
2959 (file-name-nondirectory default-name) ") ")
2960 (file-name-directory default-name)
2962 ;; A single group name is returned.
2963 ((stringp split-name)
2965 (funcall function split-name headers
2966 (symbol-value variable)))
2968 (concat prompt " (default "
2969 (file-name-nondirectory default-name) ") ")
2970 (file-name-directory default-name)
2972 ;; A single split name was found
2973 ((= 1 (length split-name))
2974 (let* ((name (expand-file-name
2976 gnus-article-save-directory))
2977 (dir (cond ((file-directory-p name)
2978 (file-name-as-directory name))
2979 ((file-exists-p name) name)
2980 (t gnus-article-save-directory))))
2982 (concat prompt " (default " name ") ")
2984 ;; A list of splits was found.
2986 (setq split-name (nreverse split-name))
2988 (let ((file-name-history
2989 (nconc split-name file-name-history)))
2993 (concat prompt " (`M-p' for defaults) ")
2994 gnus-article-save-directory
2996 gnus-article-save-directory)))
2997 (car (push result file-name-history)))))))
2998 ;; Create the directory.
2999 (gnus-make-directory (file-name-directory file))
3000 ;; If we have read a directory, we append the default file name.
3001 (when (file-directory-p file)
3002 (setq file (expand-file-name (file-name-nondirectory
3004 (file-name-as-directory file))))
3005 ;; Possibly translate some characters.
3006 (nnheader-translate-file-chars file))))))
3007 (gnus-make-directory (file-name-directory result))
3008 (set variable result)))
3010 (defun gnus-article-archive-name (group)
3011 "Return the first instance of an \"Archive-name\" in the current buffer."
3012 (let ((case-fold-search t))
3013 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3014 (nnheader-concat gnus-article-save-directory
3015 (match-string 1)))))
3017 (defun gnus-article-nndoc-name (group)
3018 "If GROUP is an nndoc group, return the name of the parent group."
3019 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3020 (gnus-group-get-parameter group 'save-article-group)))
3022 (defun gnus-summary-save-in-rmail (&optional filename)
3023 "Append this article to Rmail file.
3024 Optional argument FILENAME specifies file name.
3025 Directory to save to is default to `gnus-article-save-directory'."
3026 (setq filename (gnus-read-save-file-name
3027 "Save %s in rmail file:" filename
3028 gnus-rmail-save-name gnus-newsgroup-name
3029 gnus-current-headers 'gnus-newsgroup-last-rmail))
3030 (gnus-eval-in-buffer-window gnus-save-article-buffer
3034 (gnus-output-to-rmail filename))))
3037 (defun gnus-summary-save-in-mail (&optional filename)
3038 "Append this article to Unix mail file.
3039 Optional argument FILENAME specifies file name.
3040 Directory to save to is default to `gnus-article-save-directory'."
3041 (setq filename (gnus-read-save-file-name
3042 "Save %s in Unix mail file:" filename
3043 gnus-mail-save-name gnus-newsgroup-name
3044 gnus-current-headers 'gnus-newsgroup-last-mail))
3045 (gnus-eval-in-buffer-window gnus-save-article-buffer
3049 (if (and (file-readable-p filename)
3050 (file-regular-p filename)
3051 (mail-file-babyl-p filename))
3052 (rmail-output-to-rmail-file filename t)
3053 (gnus-output-to-mail filename)))))
3056 (defun gnus-summary-save-in-file (&optional filename overwrite)
3057 "Append this article to file.
3058 Optional argument FILENAME specifies file name.
3059 Directory to save to is default to `gnus-article-save-directory'."
3060 (setq filename (gnus-read-save-file-name
3061 "Save %s in file:" filename
3062 gnus-file-save-name gnus-newsgroup-name
3063 gnus-current-headers 'gnus-newsgroup-last-file))
3064 (gnus-eval-in-buffer-window gnus-save-article-buffer
3068 (when (and overwrite
3069 (file-exists-p filename))
3070 (delete-file filename))
3071 (gnus-output-to-file filename))))
3074 (defun gnus-summary-write-to-file (&optional filename)
3075 "Write this article to a file, overwriting it if the file exists.
3076 Optional argument FILENAME specifies file name.
3077 The directory to save in defaults to `gnus-article-save-directory'."
3078 (gnus-summary-save-in-file nil t))
3080 (defun gnus-summary-save-body-in-file (&optional filename)
3081 "Append this article body to a file.
3082 Optional argument FILENAME specifies file name.
3083 The directory to save in defaults to `gnus-article-save-directory'."
3084 (setq filename (gnus-read-save-file-name
3085 "Save %s body in file:" filename
3086 gnus-file-save-name gnus-newsgroup-name
3087 gnus-current-headers 'gnus-newsgroup-last-file))
3088 (gnus-eval-in-buffer-window gnus-save-article-buffer
3092 (when (article-goto-body)
3093 (narrow-to-region (point) (point-max)))
3094 (gnus-output-to-file filename))))
3097 (defun gnus-summary-save-in-pipe (&optional command)
3098 "Pipe this article to subprocess."
3100 (cond ((and (eq command 'default)
3101 gnus-last-shell-command)
3102 gnus-last-shell-command)
3107 "Shell command on %s: "
3108 (if (and gnus-number-of-articles-to-be-saved
3109 (> gnus-number-of-articles-to-be-saved 1))
3110 (format "these %d articles"
3111 gnus-number-of-articles-to-be-saved)
3113 gnus-last-shell-command))))
3114 (when (string-equal command "")
3115 (if gnus-last-shell-command
3116 (setq command gnus-last-shell-command)
3117 (error "A command is required")))
3118 (gnus-eval-in-buffer-window gnus-article-buffer
3121 (shell-command-on-region (point-min) (point-max) command nil)))
3122 (setq gnus-last-shell-command command))
3124 (defun gnus-summary-pipe-to-muttprint (&optional command)
3125 "Pipe this article to muttprint."
3126 (setq command (read-string
3127 "Print using command: " gnus-summary-muttprint-program
3128 nil gnus-summary-muttprint-program))
3129 (gnus-summary-save-in-pipe command))
3131 ;;; Article file names when saving.
3133 (defun gnus-capitalize-newsgroup (newsgroup)
3134 "Capitalize NEWSGROUP name."
3135 (when (not (zerop (length newsgroup)))
3136 (concat (char-to-string (upcase (aref newsgroup 0)))
3137 (substring newsgroup 1))))
3139 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3140 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3141 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3142 Otherwise, it is like ~/News/news/group/num."
3145 (concat (if (gnus-use-long-file-name 'not-save)
3146 (gnus-capitalize-newsgroup newsgroup)
3147 (gnus-newsgroup-directory-form newsgroup))
3148 "/" (int-to-string (mail-header-number headers)))
3149 gnus-article-save-directory)))
3151 (string-equal (file-name-directory default)
3152 (file-name-directory last-file))
3153 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3155 (or last-file default))))
3157 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3158 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3159 If variable `gnus-use-long-file-name' is non-nil, it is
3160 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3163 (concat (if (gnus-use-long-file-name 'not-save)
3165 (gnus-newsgroup-directory-form newsgroup))
3166 "/" (int-to-string (mail-header-number headers)))
3167 gnus-article-save-directory)))
3169 (string-equal (file-name-directory default)
3170 (file-name-directory last-file))
3171 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3173 (or last-file default))))
3175 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3176 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3177 If variable `gnus-use-long-file-name' is non-nil, it is
3178 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3181 (if (gnus-use-long-file-name 'not-save)
3184 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3186 gnus-article-save-directory)))
3188 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3189 "Generate file name from sender."
3190 (let ((from (mail-header-from headers)))
3192 (if (and from (string-match "\\([^ <]+\\)@" from))
3193 (match-string 1 from)
3195 gnus-article-save-directory)))
3197 (defun article-verify-x-pgp-sig ()
3200 (if (gnus-buffer-live-p gnus-original-article-buffer)
3201 (let ((sig (with-current-buffer gnus-original-article-buffer
3202 (gnus-fetch-field "X-PGP-Sig")))
3206 (mml2015-clear-verify-function))
3208 (insert-buffer gnus-original-article-buffer)
3209 (setq items (split-string sig))
3210 (message-narrow-to-head)
3211 (let ((inhibit-point-motion-hooks t)
3212 (case-fold-search t))
3213 ;; Don't verify multiple headers.
3214 (setq headers (mapconcat (lambda (header)
3216 (mail-fetch-field header) "\n"))
3217 (split-string (nth 1 items) ",") "")))
3218 (delete-region (point-min) (point-max))
3219 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3220 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3225 (if (looking-at "^-")
3228 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3229 (insert "Version: " (car items) "\n\n")
3230 (insert (mapconcat 'identity (cddr items) "\n"))
3231 (insert "\n-----END PGP SIGNATURE-----\n")
3232 (let ((mm-security-handle (list (format "multipart/signed"))))
3233 (mml2015-clean-buffer)
3234 (let ((coding-system-for-write (or gnus-newsgroup-charset
3236 (funcall (mml2015-clear-verify-function)))
3238 (or (mm-handle-multipart-ctl-parameter
3239 mm-security-handle 'gnus-details)
3240 (mm-handle-multipart-ctl-parameter
3241 mm-security-handle 'gnus-info)))))
3243 (let (buffer-read-only bface eface)
3245 (message-narrow-to-head)
3246 (goto-char (point-max))
3248 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3249 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3250 (message-remove-header "X-Gnus-PGP-Verify")
3251 (if (re-search-forward "^X-PGP-Sig:" nil t)
3253 (goto-char (point-max)))
3254 (narrow-to-region (point) (point))
3255 (insert "X-Gnus-PGP-Verify: " info "\n")
3256 (goto-char (point-min))
3259 (if (not (looking-at "^[ \t]"))
3263 (goto-char (point-min))
3264 (when (looking-at "\\([^:]+\\): *")
3265 (put-text-property (match-beginning 1) (1+ (match-end 1))
3267 (put-text-property (match-end 0) (point-max)
3268 'face eface)))))))))
3270 (defun article-verify-cancel-lock ()
3271 "Verify Cancel-Lock header."
3273 (if (gnus-buffer-live-p gnus-original-article-buffer)
3274 (canlock-verify gnus-original-article-buffer)))
3281 (setq afunc (car func)
3284 gfunc (intern (format "gnus-%s" func))))
3286 (when (fboundp afunc)
3287 `(lambda (&optional interactive &rest args)
3288 ,(documentation afunc t)
3289 (interactive (list t))
3291 (set-buffer gnus-article-buffer)
3293 (call-interactively ',afunc)
3294 (apply ',afunc args))))))))
3295 '(article-hide-headers
3296 article-verify-x-pgp-sig
3297 article-verify-cancel-lock
3298 article-hide-boring-headers
3299 article-treat-overstrike
3300 article-fill-long-lines
3301 article-capitalize-sentences
3303 article-remove-leading-whitespace
3304 article-display-x-face
3305 article-display-face
3306 article-de-quoted-unreadable
3307 article-de-base64-unreadable
3310 article-unsplit-urls
3311 article-hide-list-identifiers
3312 article-strip-banner
3315 article-hide-signature
3316 article-strip-headers-in-body
3317 article-remove-trailing-blank-lines
3318 article-strip-leading-blank-lines
3319 article-strip-multiple-blank-lines
3320 article-strip-leading-space
3321 article-strip-trailing-space
3322 article-strip-blank-lines
3323 article-strip-all-blank-lines
3325 article-date-english
3326 article-date-iso8601
3327 article-date-original
3329 article-decode-mime-words
3330 article-decode-charset
3331 article-decode-encoded-words
3335 article-treat-dumbquotes
3336 article-normalize-headers
3337 ;; (article-show-all . gnus-article-show-all-headers)
3341 ;;; Gnus article mode
3344 (put 'gnus-article-mode 'mode-class 'special)
3346 (set-keymap-parent gnus-article-mode-map widget-keymap)
3348 (gnus-define-keys gnus-article-mode-map
3349 " " gnus-article-goto-next-page
3350 "\177" gnus-article-goto-prev-page
3351 [delete] gnus-article-goto-prev-page
3352 [backspace] gnus-article-goto-prev-page
3353 "\C-c^" gnus-article-refer-article
3354 "h" gnus-article-show-summary
3355 "s" gnus-article-show-summary
3356 "\C-c\C-m" gnus-article-mail
3357 "?" gnus-article-describe-briefly
3358 "e" gnus-summary-edit-article
3359 "<" beginning-of-buffer
3361 "\C-c\C-i" gnus-info-find-node
3363 "R" gnus-article-reply-with-original
3364 "F" gnus-article-followup-with-original
3365 "\C-hk" gnus-article-describe-key
3366 "\C-hc" gnus-article-describe-key-briefly
3368 "\C-d" gnus-article-read-summary-keys
3369 "\M-*" gnus-article-read-summary-keys
3370 "\M-#" gnus-article-read-summary-keys
3371 "\M-^" gnus-article-read-summary-keys
3372 "\M-g" gnus-article-read-summary-keys)
3374 (substitute-key-definition
3375 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3377 (defun gnus-article-make-menu-bar ()
3378 (unless (boundp 'gnus-article-commands-menu)
3379 (gnus-summary-make-menu-bar))
3380 (gnus-turn-off-edit-menu 'article)
3381 (unless (boundp 'gnus-article-article-menu)
3383 gnus-article-article-menu gnus-article-mode-map ""
3385 ["Scroll forwards" gnus-article-goto-next-page t]
3386 ["Scroll backwards" gnus-article-goto-prev-page t]
3387 ["Show summary" gnus-article-show-summary t]
3388 ["Fetch Message-ID at point" gnus-article-refer-article t]
3389 ["Mail to address at point" gnus-article-mail t]
3390 ["Send a bug report" gnus-bug t]))
3393 gnus-article-treatment-menu gnus-article-mode-map ""
3394 ;; Fixme: this should use :active (and maybe :visible).
3396 ["Hide headers" gnus-article-hide-headers t]
3397 ["Hide signature" gnus-article-hide-signature t]
3398 ["Hide citation" gnus-article-hide-citation t]
3399 ["Treat overstrike" gnus-article-treat-overstrike t]
3400 ["Remove carriage return" gnus-article-remove-cr t]
3401 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3402 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3403 ["Remove base64" gnus-article-de-base64-unreadable t]
3404 ["Treat html" gnus-article-wash-html t]
3405 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3406 ["Decode HZ" gnus-article-decode-HZ t]))
3408 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3410 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3412 (gnus-run-hooks 'gnus-article-menu-hook)))
3414 (defun gnus-article-mode ()
3415 "Major mode for displaying an article.
3417 All normal editing commands are switched off.
3419 The following commands are available in addition to all summary mode
3421 \\<gnus-article-mode-map>
3422 \\[gnus-article-next-page]\t Scroll the article one page forwards
3423 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3424 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3425 \\[gnus-article-show-summary]\t Display the summary buffer
3426 \\[gnus-article-mail]\t Send a reply to the address near point
3427 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3428 \\[gnus-info-find-node]\t Go to the Gnus info node"
3430 (gnus-simplify-mode-line)
3431 (setq mode-name "Article")
3432 (setq major-mode 'gnus-article-mode)
3433 (make-local-variable 'minor-mode-alist)
3434 (use-local-map gnus-article-mode-map)
3435 (when (gnus-visual-p 'article-menu 'menu)
3436 (gnus-article-make-menu-bar)
3437 (when gnus-summary-tool-bar-map
3438 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3439 (gnus-update-format-specifications nil 'article-mode)
3440 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3441 (make-local-variable 'gnus-page-broken)
3442 (make-local-variable 'gnus-button-marker-list)
3443 (make-local-variable 'gnus-article-current-summary)
3444 (make-local-variable 'gnus-article-mime-handles)
3445 (make-local-variable 'gnus-article-decoded-p)
3446 (make-local-variable 'gnus-article-mime-handle-alist)
3447 (make-local-variable 'gnus-article-wash-types)
3448 (make-local-variable 'gnus-article-image-alist)
3449 (make-local-variable 'gnus-article-charset)
3450 (make-local-variable 'gnus-article-ignored-charsets)
3451 (gnus-set-default-directory)
3452 (buffer-disable-undo)
3453 (setq buffer-read-only t)
3454 (set-syntax-table gnus-article-mode-syntax-table)
3455 (mm-enable-multibyte)
3456 (gnus-run-hooks 'gnus-article-mode-hook))
3458 (defun gnus-article-setup-buffer ()
3459 "Initialize the article buffer."
3460 (let* ((name (if gnus-single-article-buffer "*Article*"
3461 (concat "*Article " gnus-newsgroup-name "*")))
3463 (progn (string-match "\\*Article" name)
3464 (concat " *Original Article"
3465 (substring name (match-end 0))))))
3466 (setq gnus-article-buffer name)
3467 (setq gnus-original-article-buffer original)
3468 (setq gnus-article-mime-handle-alist nil)
3469 ;; This might be a variable local to the summary buffer.
3470 (unless gnus-single-article-buffer
3472 (set-buffer gnus-summary-buffer)
3473 (setq gnus-article-buffer name)
3474 (setq gnus-original-article-buffer original)
3475 (gnus-set-global-variables)))
3476 (gnus-article-setup-highlight-words)
3477 ;; Init original article buffer.
3479 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3480 (mm-enable-multibyte)
3481 (setq major-mode 'gnus-original-article-mode)
3482 (make-local-variable 'gnus-original-article))
3483 (if (get-buffer name)
3486 (when (and gnus-article-edit-mode
3489 (y-or-n-p "Article mode edit in progress; discard? ")))
3490 (error "Action aborted"))
3491 (set (make-local-variable 'gnus-article-edit-mode) nil)
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 ;; This list just keeps growing if we don't reset it.
3500 (setq gnus-button-marker-list nil)
3501 (unless (eq major-mode 'gnus-article-mode)
3502 (gnus-article-mode))
3505 (set-buffer (gnus-get-buffer-create name))
3507 (make-local-variable 'gnus-summary-buffer)
3508 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3509 (current-buffer)))))
3511 ;; Set article window start at LINE, where LINE is the number of lines
3512 ;; from the head of the article.
3513 (defun gnus-article-set-window-start (&optional line)
3515 (gnus-get-buffer-window gnus-article-buffer t)
3517 (set-buffer gnus-article-buffer)
3518 (goto-char (point-min))
3521 (gnus-message 6 "Moved to bookmark")
3522 (search-forward "\n\n" nil t)
3526 (defun gnus-article-prepare (article &optional all-headers header)
3527 "Prepare ARTICLE in article mode buffer.
3528 ARTICLE should either be an article number or a Message-ID.
3529 If ARTICLE is an id, HEADER should be the article headers.
3530 If ALL-HEADERS is non-nil, no headers are hidden."
3532 ;; Make sure we start in a summary buffer.
3533 (unless (eq major-mode 'gnus-summary-mode)
3534 (set-buffer gnus-summary-buffer))
3535 (setq gnus-summary-buffer (current-buffer))
3536 (let* ((gnus-article (if header (mail-header-number header) article))
3537 (summary-buffer (current-buffer))
3538 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3539 (group gnus-newsgroup-name)
3542 (gnus-article-setup-buffer)
3543 (set-buffer gnus-article-buffer)
3544 ;; Deactivate active regions.
3545 (when (and (boundp 'transient-mark-mode)
3546 transient-mark-mode)
3547 (setq mark-active nil))
3548 (if (not (setq result (let ((buffer-read-only nil))
3549 (gnus-request-article-this-buffer
3551 ;; There is no such article.
3553 (when (and (numberp article)
3554 (not (memq article gnus-newsgroup-sparse)))
3555 (setq gnus-article-current
3556 (cons gnus-newsgroup-name article))
3557 (set-buffer gnus-summary-buffer)
3558 (setq gnus-current-article article)
3559 (if (memq article gnus-newsgroup-undownloaded)
3561 (gnus-summary-set-agent-mark article)
3562 (message "Message marked for downloading"))
3563 (gnus-summary-mark-article article gnus-canceled-mark)
3564 (unless (memq article gnus-newsgroup-sparse)
3565 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3566 (if (or (eq result 'pseudo)
3567 (eq result 'nneething))
3570 (set-buffer summary-buffer)
3571 (push article gnus-newsgroup-history)
3572 (setq gnus-last-article gnus-current-article
3573 gnus-current-article 0
3574 gnus-current-headers nil
3575 gnus-article-current nil)
3576 (if (eq result 'nneething)
3577 (gnus-configure-windows 'summary)
3578 (gnus-configure-windows 'article))
3579 (gnus-set-global-variables))
3580 (let ((gnus-article-mime-handle-alist-1
3581 gnus-article-mime-handle-alist))
3582 (gnus-set-mode-line 'article)))
3583 ;; The result from the `request' was an actual article -
3584 ;; or at least some text that is now displayed in the
3586 (when (and (numberp article)
3587 (not (eq article gnus-current-article)))
3588 ;; Seems like a new article has been selected.
3589 ;; `gnus-current-article' must be an article number.
3591 (set-buffer summary-buffer)
3592 (push article gnus-newsgroup-history)
3593 (setq gnus-last-article gnus-current-article
3594 gnus-current-article article
3595 gnus-current-headers
3596 (gnus-summary-article-header gnus-current-article)
3597 gnus-article-current
3598 (cons gnus-newsgroup-name gnus-current-article))
3599 (unless (vectorp gnus-current-headers)
3600 (setq gnus-current-headers nil))
3601 (gnus-summary-goto-subject gnus-current-article)
3602 (when (gnus-summary-show-thread)
3603 ;; If the summary buffer really was folded, the
3604 ;; previous goto may not actually have gone to
3605 ;; the right article, but the thread root instead.
3607 (gnus-summary-goto-subject gnus-current-article))
3608 (gnus-run-hooks 'gnus-mark-article-hook)
3609 (gnus-set-mode-line 'summary)
3610 (when (gnus-visual-p 'article-highlight 'highlight)
3611 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3612 ;; Set the global newsgroup variables here.
3613 (gnus-set-global-variables)
3614 (setq gnus-have-all-headers
3615 (or all-headers gnus-show-all-headers))))
3617 (gnus-configure-windows 'article))
3618 (when (or (numberp article)
3620 (gnus-article-prepare-display)
3622 (goto-char (point-min))
3623 (setq gnus-page-broken
3624 (when gnus-break-pages
3625 (gnus-narrow-to-page)
3627 (let ((gnus-article-mime-handle-alist-1
3628 gnus-article-mime-handle-alist))
3629 (gnus-set-mode-line 'article))
3633 (set-window-point (get-buffer-window (current-buffer)) (point))
3634 (gnus-configure-windows 'article)
3638 (defun gnus-article-prepare-display ()
3639 "Make the current buffer look like a nice article."
3640 ;; Hooks for getting information from the article.
3641 ;; This hook must be called before being narrowed.
3642 (let ((gnus-article-buffer (current-buffer))
3644 (unless (eq major-mode 'gnus-article-mode)
3645 (gnus-article-mode))
3646 (setq buffer-read-only nil
3647 gnus-article-wash-types nil
3648 gnus-article-image-alist nil)
3649 (gnus-run-hooks 'gnus-tmp-internal-hook)
3650 (when gnus-display-mime-function
3651 (funcall gnus-display-mime-function))
3652 (gnus-run-hooks 'gnus-article-prepare-hook)))
3655 ;;; Gnus MIME viewing functions
3658 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3659 "Format of the MIME buttons.
3661 Valid specifiers include:
3663 %T MIME type, along with additional info
3664 %n The `name' parameter
3665 %d The description, if any
3666 %l The length of the encoded part
3667 %p The part identifier number
3668 %e Dots if the part isn't displayed
3670 General format specifiers can also be used. See Info node
3671 `(gnus)Formatting Variables'.")
3673 (defvar gnus-mime-button-line-format-alist
3674 '((?t gnus-tmp-type ?s)
3675 (?T gnus-tmp-type-long ?s)
3676 (?n gnus-tmp-name ?s)
3677 (?d gnus-tmp-description ?s)
3679 (?l gnus-tmp-length ?d)
3680 (?e gnus-tmp-dots ?s)))
3682 (defvar gnus-mime-button-commands
3683 '((gnus-article-press-button "\r" "Toggle Display")
3684 (gnus-mime-view-part "v" "View Interactively...")
3685 (gnus-mime-view-part-as-type "t" "View As Type...")
3686 (gnus-mime-view-part-as-charset "C" "View As charset...")
3687 (gnus-mime-save-part "o" "Save...")
3688 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3689 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3690 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3691 (gnus-mime-view-part-internally "E" "View Internally")
3692 (gnus-mime-view-part-externally "e" "View Externally")
3693 (gnus-mime-print-part "p" "Print")
3694 (gnus-mime-pipe-part "|" "Pipe To Command...")
3695 (gnus-mime-action-on-part "." "Take action on the part")))
3697 (defun gnus-article-mime-part-status ()
3698 (if gnus-article-mime-handle-alist-1
3699 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3701 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3704 (defvar gnus-mime-button-map
3705 (let ((map (make-sparse-keymap)))
3706 (unless (>= (string-to-number emacs-version) 21)
3707 ;; XEmacs doesn't care.
3708 (set-keymap-parent map gnus-article-mode-map))
3709 (define-key map gnus-mouse-2 'gnus-article-push-button)
3710 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3711 (dolist (c gnus-mime-button-commands)
3712 (define-key map (cadr c) (car c)))
3715 (defun gnus-mime-button-menu (event)
3716 "Construct a context-sensitive menu of MIME commands."
3718 (save-window-excursion
3719 (let ((pos (event-start event)))
3720 (select-window (posn-window pos))
3721 (goto-char (posn-point pos))
3722 (gnus-article-check-buffer)
3723 (let ((response (x-popup-menu
3725 ("" ,@(mapcar (lambda (c)
3726 (cons (caddr c) (car c)))
3727 gnus-mime-button-commands))))))
3729 (call-interactively response))))))
3731 (defun gnus-mime-view-all-parts (&optional handles)
3732 "View all the MIME parts."
3734 (save-current-buffer
3735 (set-buffer gnus-article-buffer)
3736 (let ((handles (or handles gnus-article-mime-handles))
3737 (mail-parse-charset gnus-newsgroup-charset)
3738 (mail-parse-ignored-charsets
3739 (with-current-buffer gnus-summary-buffer
3740 gnus-newsgroup-ignored-charsets)))
3742 (mm-remove-parts handles)
3743 (goto-char (point-min))
3744 (or (search-forward "\n\n") (goto-char (point-max)))
3745 (let (buffer-read-only)
3746 (delete-region (point) (point-max))
3747 (mm-display-parts handles))))))
3749 (defun gnus-mime-save-part-and-strip ()
3750 "Save the MIME part under point then replace it with an external body."
3752 (gnus-article-check-buffer)
3753 (let* ((data (get-text-property (point) 'gnus-data))
3755 (handles gnus-article-mime-handles))
3756 (if (mm-multiple-handles gnus-article-mime-handles)
3757 (error "This function is not implemented"))
3758 (setq file (and data (mm-save-part data)))
3760 (with-current-buffer (mm-handle-buffer data)
3762 (insert "Content-Type: " (mm-handle-media-type data))
3763 (mml-insert-parameter-string (cdr (mm-handle-type data))
3766 (insert "Content-ID: " (message-make-message-id) "\n")
3767 (insert "Content-Transfer-Encoding: binary\n")
3770 (cdr (mm-make-handle nil
3771 `("message/external-body"
3772 (access-type . "LOCAL-FILE")
3774 (set-buffer gnus-summary-buffer)
3775 (gnus-article-edit-article
3778 (let ((mail-parse-charset (or gnus-article-charset
3779 ',gnus-newsgroup-charset))
3780 (mail-parse-ignored-charsets
3781 (or gnus-article-ignored-charsets
3782 ',gnus-newsgroup-ignored-charsets))
3783 (mbl mml-buffer-list))
3784 (setq mml-buffer-list nil)
3785 (insert-buffer gnus-original-article-buffer)
3786 (mime-to-mml ',handles)
3787 (setq gnus-article-mime-handles nil)
3788 (let ((mbl1 mml-buffer-list))
3789 (setq mml-buffer-list mbl)
3790 (set (make-local-variable 'mml-buffer-list) mbl1))
3791 ;; LOCAL argument of add-hook differs between GNU Emacs
3792 ;; and XEmacs. make-local-hook makes sure they are local.
3793 (make-local-hook 'kill-buffer-hook)
3794 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3795 `(lambda (no-highlight)
3796 (let ((mail-parse-charset (or gnus-article-charset
3797 ',gnus-newsgroup-charset))
3798 (message-options message-options)
3799 (message-options-set-recipient)
3800 (mail-parse-ignored-charsets
3801 (or gnus-article-ignored-charsets
3802 ',gnus-newsgroup-ignored-charsets)))
3804 (mml-destroy-buffers)
3805 (remove-hook 'kill-buffer-hook
3806 'mml-destroy-buffers t)
3807 (kill-local-variable 'mml-buffer-list))
3808 (gnus-summary-edit-article-done
3809 ,(or (mail-header-references gnus-current-headers) "")
3810 ,(gnus-group-read-only-p)
3811 ,gnus-summary-buffer no-highlight))))))
3813 (defun gnus-mime-save-part ()
3814 "Save the MIME part under point."
3816 (gnus-article-check-buffer)
3817 (let ((data (get-text-property (point) 'gnus-data)))
3819 (mm-save-part data))))
3821 (defun gnus-mime-pipe-part ()
3822 "Pipe the MIME part under point to a process."
3824 (gnus-article-check-buffer)
3825 (let ((data (get-text-property (point) 'gnus-data)))
3827 (mm-pipe-part data))))
3829 (defun gnus-mime-view-part ()
3830 "Interactively choose a viewing method for the MIME part under point."
3832 (gnus-article-check-buffer)
3833 (let ((data (get-text-property (point) 'gnus-data)))
3835 (setq gnus-article-mime-handles
3837 gnus-article-mime-handles (setq data (copy-sequence data))))
3838 (mm-interactively-view-part data))))
3840 (defun gnus-mime-view-part-as-type-internal ()
3841 (gnus-article-check-buffer)
3842 (let* ((name (mail-content-type-get
3843 (mm-handle-type (get-text-property (point) 'gnus-data))
3845 (def-type (and name (mm-default-file-encoding name))))
3846 (and def-type (cons def-type 0))))
3848 (defun gnus-mime-view-part-as-type (&optional mime-type)
3849 "Choose a MIME media type, and view the part as such."
3852 (setq mime-type (completing-read
3853 "View as MIME type: "
3854 (mapcar #'list (mailcap-mime-types))
3856 (gnus-mime-view-part-as-type-internal))))
3857 (gnus-article-check-buffer)
3858 (let ((handle (get-text-property (point) 'gnus-data)))
3861 (mm-make-handle (mm-handle-buffer handle)
3862 (cons mime-type (cdr (mm-handle-type handle)))
3863 (mm-handle-encoding handle)
3864 (mm-handle-undisplayer handle)
3865 (mm-handle-disposition handle)
3866 (mm-handle-description handle)
3868 (mm-handle-id handle)))
3869 (setq gnus-article-mime-handles
3870 (mm-merge-handles gnus-article-mime-handles handle))
3871 (gnus-mm-display-part handle))))
3874 (require 'jka-compr))
3876 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
3877 ;; emacs can do that itself.
3879 (defun gnus-mime-jka-compr-maybe-uncompress ()
3880 "Uncompress the current buffer if `auto-compression-mode' is enabled.
3881 The uncompress method used is derived from `buffer-file-name'."
3882 (when (and (fboundp 'jka-compr-installed-p)
3883 (jka-compr-installed-p))
3884 (let ((info (jka-compr-get-compression-info buffer-file-name)))
3886 (let ((basename (file-name-nondirectory buffer-file-name))
3887 (args (jka-compr-info-uncompress-args info))
3888 (prog (jka-compr-info-uncompress-program info))
3889 (message (jka-compr-info-uncompress-message info))
3890 (err-file (jka-compr-make-temp-name)))
3892 (message "%s %s..." message basename))
3894 (unless (memq (apply 'call-process-region
3895 (point-min) (point-max)
3897 t (list t err-file) nil
3899 jka-compr-acceptable-retval-list)
3900 (jka-compr-error prog args basename message err-file))
3901 (jka-compr-delete-temp-file err-file)))))))
3903 (defun gnus-mime-copy-part (&optional handle)
3904 "Put the MIME part under point into a new buffer.
3905 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
3908 (gnus-article-check-buffer)
3909 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3910 (contents (and handle (mm-get-part handle)))
3912 (file-name-nondirectory
3914 (mail-content-type-get (mm-handle-type handle) 'name)
3915 (mail-content-type-get (mm-handle-disposition handle)
3918 (buffer (and base (generate-new-buffer base))))
3920 (switch-to-buffer buffer)
3922 ;; We do it this way to make `normal-mode' set the appropriate mode.
3925 (setq buffer-file-name (expand-file-name base))
3926 (gnus-mime-jka-compr-maybe-uncompress)
3928 (setq buffer-file-name nil))
3929 (goto-char (point-min)))))
3931 (defun gnus-mime-print-part (&optional handle filename)
3932 "Print the MIME part under point."
3933 (interactive (list nil (ps-print-preprint current-prefix-arg)))
3934 (gnus-article-check-buffer)
3935 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3936 (contents (and handle (mm-get-part handle)))
3937 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
3938 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
3943 (mm-save-part-to-file handle file)
3944 (call-process shell-file-name nil
3945 (generate-new-buffer " *mm*")
3947 shell-command-switch
3949 printer file (mm-handle-type handle))))
3953 (gnus-print-buffer))
3954 (ps-despool filename)))))
3956 (defun gnus-mime-inline-part (&optional handle arg)
3957 "Insert the MIME part under point into the current buffer."
3958 (interactive (list nil current-prefix-arg))
3959 (gnus-article-check-buffer)
3960 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3965 (if (and (not arg) (mm-handle-undisplayer handle))
3966 (mm-remove-part handle)
3967 (setq contents (mm-get-part handle))
3970 (setq charset (or (mail-content-type-get
3971 (mm-handle-type handle) 'charset)
3972 gnus-newsgroup-charset)))
3974 (if (mm-handle-undisplayer handle)
3975 (mm-remove-part handle))
3978 gnus-summary-show-article-charset-alist))
3979 (mm-read-coding-system "Charset: ")))))
3981 (mm-insert-inline handle
3983 (setq charset (mm-charset-to-coding-system
3985 (not (eq charset 'ascii)))
3986 (mm-decode-coding-string contents charset)
3990 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3991 "Insert the MIME part under point into the current buffer using the
3993 (interactive (list nil current-prefix-arg))
3994 (gnus-article-check-buffer)
3995 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4000 (if (mm-handle-undisplayer handle)
4001 (mm-remove-part handle))
4002 (let ((gnus-newsgroup-charset
4004 gnus-summary-show-article-charset-alist))
4005 (mm-read-coding-system "Charset: ")))
4006 (gnus-newsgroup-ignored-charsets 'gnus-all))
4007 (gnus-article-press-button)))))
4009 (defun gnus-mime-view-part-externally (&optional handle)
4010 "View the MIME part under point with an external viewer."
4012 (gnus-article-check-buffer)
4013 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4014 (mm-user-display-methods nil)
4015 (mm-inlined-types nil)
4016 (mail-parse-charset gnus-newsgroup-charset)
4017 (mail-parse-ignored-charsets
4018 (save-excursion (set-buffer gnus-summary-buffer)
4019 gnus-newsgroup-ignored-charsets)))
4021 (if (mm-handle-undisplayer handle)
4022 (mm-remove-part handle)
4023 (mm-display-part handle)))))
4025 (defun gnus-mime-view-part-internally (&optional handle)
4026 "View the MIME part under point with an internal viewer.
4027 If no internal viewer is available, use an external viewer."
4029 (gnus-article-check-buffer)
4030 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4031 (mm-inlined-types '(".*"))
4032 (mm-inline-large-images t)
4033 (mail-parse-charset gnus-newsgroup-charset)
4034 (mail-parse-ignored-charsets
4035 (save-excursion (set-buffer gnus-summary-buffer)
4036 gnus-newsgroup-ignored-charsets))
4039 (if (mm-handle-undisplayer handle)
4040 (mm-remove-part handle)
4041 (mm-display-part handle)))))
4043 (defun gnus-mime-action-on-part (&optional action)
4044 "Do something with the MIME attachment at \(point\)."
4046 (list (completing-read "Action: " gnus-mime-action-alist)))
4047 (gnus-article-check-buffer)
4048 (let ((action-pair (assoc action gnus-mime-action-alist)))
4050 (funcall (cdr action-pair)))))
4052 (defun gnus-article-part-wrapper (n function)
4053 (save-current-buffer
4054 (set-buffer gnus-article-buffer)
4055 (when (> n (length gnus-article-mime-handle-alist))
4056 (error "No such part"))
4057 (gnus-article-goto-part n)
4058 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4059 (funcall function handle))))
4061 (defun gnus-article-pipe-part (n)
4062 "Pipe MIME part N, which is the numerical prefix."
4064 (gnus-article-part-wrapper n 'mm-pipe-part))
4066 (defun gnus-article-save-part (n)
4067 "Save MIME part N, which is the numerical prefix."
4069 (gnus-article-part-wrapper n 'mm-save-part))
4071 (defun gnus-article-interactively-view-part (n)
4072 "View MIME part N interactively, which is the numerical prefix."
4074 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4076 (defun gnus-article-copy-part (n)
4077 "Copy MIME part N, which is the numerical prefix."
4079 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4081 (defun gnus-article-view-part-as-charset (n)
4082 "Copy MIME part N, which is the numerical prefix."
4084 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4086 (defun gnus-article-view-part-externally (n)
4087 "View MIME part N externally, which is the numerical prefix."
4089 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4091 (defun gnus-article-inline-part (n)
4092 "Inline MIME part N, which is the numerical prefix."
4094 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4096 (defun gnus-article-mime-match-handle-first (condition)
4098 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4099 (while (setq ihandle (pop alist))
4101 ((functionp condition)
4102 (funcall condition (cdr ihandle)))
4103 ((eq condition 'undisplayed)
4104 (not (or (mm-handle-undisplayer (cdr ihandle))
4105 (equal (mm-handle-media-type (cdr ihandle))
4106 "multipart/alternative"))))
4107 ((eq condition 'undisplayed-alternative)
4108 (not (mm-handle-undisplayer (cdr ihandle))))
4110 (gnus-article-goto-part (car ihandle))
4111 (or (not n) (< (car ihandle) n)))
4112 (setq n (car ihandle))))
4116 (defun gnus-article-view-part (&optional n)
4117 "View MIME part N, which is the numerical prefix."
4119 (save-current-buffer
4120 (set-buffer gnus-article-buffer)
4121 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4122 gnus-article-mime-match-handle-function)))
4123 (when (> n (length gnus-article-mime-handle-alist))
4124 (error "No such part"))
4125 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4126 (when (gnus-article-goto-part n)
4127 (if (equal (car handle) "multipart/alternative")
4128 (gnus-article-press-button)
4129 (when (eq (gnus-mm-display-part handle) 'internal)
4130 (gnus-set-window-start)))))))
4132 (defsubst gnus-article-mime-total-parts ()
4133 (if (bufferp (car gnus-article-mime-handles))
4135 (1- (length gnus-article-mime-handles))))
4137 (defun gnus-mm-display-part (handle)
4138 "Display HANDLE and fix MIME button."
4139 (let ((id (get-text-property (point) 'gnus-part))
4144 (let ((window (selected-window))
4145 (mail-parse-charset gnus-newsgroup-charset)
4146 (mail-parse-ignored-charsets
4147 (if (gnus-buffer-live-p gnus-summary-buffer)
4149 (set-buffer gnus-summary-buffer)
4150 gnus-newsgroup-ignored-charsets)
4154 (let ((win (gnus-get-buffer-window (current-buffer) t))
4157 (select-window win))
4160 (if (mm-handle-displayed-p handle)
4161 ;; This will remove the part.
4162 (mm-display-part handle)
4164 (narrow-to-region (point)
4165 (if (eobp) (point) (1+ (point))))
4166 (mm-display-part handle)
4167 ;; We narrow to the part itself and
4168 ;; then call the treatment functions.
4169 (goto-char (point-min))
4171 (narrow-to-region (point) (point-max))
4174 (gnus-article-mime-total-parts)
4175 (mm-handle-media-type handle)))))
4176 (if (window-live-p window)
4177 (select-window window)))))
4179 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4180 (gnus-insert-mime-button
4181 handle id (list (mm-handle-displayed-p handle)))
4182 (goto-char point))))
4184 (defun gnus-article-goto-part (n)
4185 "Go to MIME part N."
4186 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4188 (goto-char point))))
4190 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4191 (let ((gnus-tmp-name
4192 (or (mail-content-type-get (mm-handle-type handle) 'name)
4193 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4194 (mail-content-type-get (mm-handle-type handle) 'url)
4196 (gnus-tmp-type (mm-handle-media-type handle))
4197 (gnus-tmp-description
4198 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4201 (if (if displayed (car displayed)
4202 (mm-handle-displayed-p handle))
4204 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4206 gnus-tmp-type-long b e)
4207 (when (string-match ".*/" gnus-tmp-name)
4208 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4209 (setq gnus-tmp-type-long (concat gnus-tmp-type
4210 (and (not (equal gnus-tmp-name ""))
4211 (concat "; " gnus-tmp-name))))
4212 (unless (equal gnus-tmp-description "")
4213 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4218 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4219 `(,@(gnus-local-map-property gnus-mime-button-map)
4220 gnus-callback gnus-mm-display-part
4221 gnus-part ,gnus-tmp-id
4222 article-type annotation
4225 (widget-convert-button
4228 :action 'gnus-widget-press-button
4229 :button-keymap gnus-mime-button-map
4231 (lambda (widget/window &optional overlay pos)
4232 ;; Needed to properly clear the message due to a bug in
4233 ;; wid-edit (XEmacs only).
4234 (if (boundp 'help-echo-owns-message)
4235 (setq help-echo-owns-message t))
4237 "%S: %s the MIME part; %S: more options"
4238 (aref gnus-mouse-2 0)
4239 ;; XEmacs will get a single widget arg; Emacs 21 will get
4240 ;; window, overlay, position.
4241 (if (mm-handle-displayed-p
4243 (with-current-buffer (gnus-overlay-buffer overlay)
4244 (widget-get (widget-at (gnus-overlay-start overlay))
4246 (widget-get widget/window :mime-handle)))
4248 (aref gnus-down-mouse-3 0))))))
4250 (defun gnus-widget-press-button (elems el)
4251 (goto-char (widget-get elems :from))
4252 (gnus-article-press-button))
4254 (defvar gnus-displaying-mime nil)
4256 (defun gnus-display-mime (&optional ihandles)
4257 "Display the MIME parts."
4259 (save-selected-window
4260 (let ((window (get-buffer-window gnus-article-buffer))
4263 (select-window window)
4264 ;; We have to do this since selecting the window
4265 ;; may change the point. So we set the window point.
4266 (set-window-point window point)))
4267 (let* ((handles (or ihandles
4268 (mm-dissect-buffer nil gnus-article-loose-mime)
4269 (and gnus-article-emulate-mime
4271 buffer-read-only handle name type b e display)
4272 (when (and (not ihandles)
4273 (not gnus-displaying-mime))
4274 ;; Top-level call; we clean up.
4275 (when gnus-article-mime-handles
4276 (mm-destroy-parts gnus-article-mime-handles)
4277 (setq gnus-article-mime-handle-alist nil));; A trick.
4278 (setq gnus-article-mime-handles handles)
4279 ;; We allow users to glean info from the handles.
4280 (when gnus-article-mime-part-function
4281 (gnus-mime-part-function handles)))
4283 (or (not (stringp (car handles)))
4286 (when (and (not ihandles)
4287 (not gnus-displaying-mime))
4288 ;; Clean up for mime parts.
4290 (delete-region (point) (point-max)))
4291 (let ((gnus-displaying-mime t))
4292 (gnus-mime-display-part handles)))
4295 (narrow-to-region (point) (point-max))
4296 (gnus-treat-article nil 1 1)
4299 ;; Highlight the headers.
4303 (narrow-to-region (point-min) (point))
4304 (gnus-treat-article 'head))))))))
4306 (defvar gnus-mime-display-multipart-as-mixed nil)
4307 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4308 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4310 (defun gnus-mime-display-part (handle)
4313 ((not (stringp (car handle)))
4314 (gnus-mime-display-single handle))
4315 ;; User-defined multipart
4316 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4317 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4319 ;; multipart/alternative
4320 ((and (equal (car handle) "multipart/alternative")
4321 (not (or gnus-mime-display-multipart-as-mixed
4322 gnus-mime-display-multipart-alternative-as-mixed)))
4323 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4324 (push (cons id handle) gnus-article-mime-handle-alist)
4325 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4326 ;; multipart/related
4327 ((and (equal (car handle) "multipart/related")
4328 (not (or gnus-mime-display-multipart-as-mixed
4329 gnus-mime-display-multipart-related-as-mixed)))
4330 ;;;!!!We should find the start part, but we just default
4331 ;;;!!!to the first part.
4332 ;;(gnus-mime-display-part (cadr handle))
4333 ;;;!!! Most multipart/related is an HTML message plus images.
4334 ;;;!!! Unfortunately we are unable to let W3 display those
4335 ;;;!!! included images, so we just display it as a mixed multipart.
4336 ;;(gnus-mime-display-mixed (cdr handle))
4337 ;;;!!! No, w3 can display everything just fine.
4338 (gnus-mime-display-part (cadr handle)))
4339 ((equal (car handle) "multipart/signed")
4340 (gnus-add-wash-type 'signed)
4341 (gnus-mime-display-security handle))
4342 ((equal (car handle) "multipart/encrypted")
4343 (gnus-add-wash-type 'encrypted)
4344 (gnus-mime-display-security handle))
4345 ;; Other multiparts are handled like multipart/mixed.
4347 (gnus-mime-display-mixed (cdr handle)))))
4349 (defun gnus-mime-part-function (handles)
4350 (if (stringp (car handles))
4351 (mapcar 'gnus-mime-part-function (cdr handles))
4352 (funcall gnus-article-mime-part-function handles)))
4354 (defun gnus-mime-display-mixed (handles)
4355 (mapcar 'gnus-mime-display-part handles))
4357 (defun gnus-mime-display-single (handle)
4358 (let ((type (mm-handle-media-type handle))
4359 (ignored gnus-ignored-mime-types)
4366 (when (string-match (pop ignored) type)
4367 (throw 'ignored nil)))
4368 (if (and (setq not-attachment
4369 (and (not (mm-inline-override-p handle))
4370 (or (not (mm-handle-disposition handle))
4371 (equal (car (mm-handle-disposition handle))
4373 (mm-attachment-override-p handle))))
4374 (mm-automatic-display-p handle)
4376 (mm-inlinable-p handle)
4377 (mm-inlined-p handle))
4378 (mm-automatic-external-display-p type)))
4380 (when (equal (mm-handle-media-supertype handle) "text")
4382 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4384 (push (cons id handle) gnus-article-mime-handle-alist)
4385 (when (or (not display)
4386 (not (gnus-unbuttonized-mime-type-p type)))
4387 ;(gnus-article-insert-newline)
4388 (gnus-insert-mime-button
4389 handle id (list (or display (and not-attachment text))))
4390 (gnus-article-insert-newline)
4391 ;(gnus-article-insert-newline)
4392 ;; Remember modify the number of forward lines.
4400 (let ((mail-parse-charset gnus-newsgroup-charset)
4401 (mail-parse-ignored-charsets
4402 (save-excursion (condition-case ()
4403 (set-buffer gnus-summary-buffer)
4405 gnus-newsgroup-ignored-charsets)))
4406 (mm-display-part handle t))
4407 (goto-char (point-max)))
4408 ((and text not-attachment)
4412 (gnus-article-insert-newline)
4413 (mm-insert-inline handle (mm-get-part handle))
4414 (goto-char (point-max))))
4418 (narrow-to-region beg (point))
4421 (gnus-article-mime-total-parts)
4422 (mm-handle-media-type handle)))))))))
4424 (defun gnus-unbuttonized-mime-type-p (type)
4425 "Say whether TYPE is to be unbuttonized."
4426 (unless gnus-inhibit-mime-unbuttonizing
4428 (let ((types gnus-unbuttonized-mime-types))
4430 (when (string-match (pop types) type)
4431 (throw 'found t)))))
4433 (let ((types gnus-buttonized-mime-types))
4435 (when (string-match (pop types) type)
4436 (throw 'found t)))))))))
4438 (defun gnus-article-insert-newline ()
4439 "Insert a newline, but mark it as undeletable."
4440 (gnus-put-text-property
4441 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4443 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4444 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4447 handle buffer-read-only from props begend not-pref)
4448 (save-window-excursion
4451 (narrow-to-region (car ibegend)
4454 (goto-char (car ibegend))
4457 (delete-region (point-min) (point-max))
4458 (mm-remove-parts handles))
4459 (setq begend (list (point-marker)))
4461 (unless (setq not-pref (cadr (member preferred ihandles)))
4462 (setq not-pref (car ihandles)))
4465 (not (gnus-unbuttonized-mime-type-p
4466 "multipart/alternative")))
4467 (gnus-add-text-properties
4470 (insert (format "%d. " id))
4474 (unless ,(not ibegend)
4475 (setq gnus-article-mime-handle-alist
4476 ',gnus-article-mime-handle-alist))
4477 (gnus-mime-display-alternative
4478 ',ihandles ',not-pref ',begend ,id))
4479 ,@(gnus-local-map-property gnus-mime-button-map)
4480 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4481 face ,gnus-article-button-face
4484 (widget-convert-button 'link from (point)
4485 :action 'gnus-widget-press-button
4486 :button-keymap gnus-widget-button-keymap)
4488 (while (setq handle (pop handles))
4489 (gnus-add-text-properties
4492 (insert (format "(%c) %-18s"
4493 (if (equal handle preferred) ?* ? )
4494 (mm-handle-media-type handle)))
4498 (unless ,(not ibegend)
4499 (setq gnus-article-mime-handle-alist
4500 ',gnus-article-mime-handle-alist))
4501 (gnus-mime-display-alternative
4502 ',ihandles ',handle ',begend ,id))
4503 ,@(gnus-local-map-property gnus-mime-button-map)
4504 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4505 face ,gnus-article-button-face
4508 (widget-convert-button 'link from (point)
4509 :action 'gnus-widget-press-button
4510 :button-keymap gnus-widget-button-keymap)
4514 (if (stringp (car preferred))
4515 (gnus-display-mime preferred)
4516 (let ((mail-parse-charset gnus-newsgroup-charset)
4517 (mail-parse-ignored-charsets
4518 (save-excursion (set-buffer gnus-summary-buffer)
4519 gnus-newsgroup-ignored-charsets)))
4520 (mm-display-part preferred)
4524 (narrow-to-region (car begend) (point-max))
4526 nil (length gnus-article-mime-handle-alist)
4527 (gnus-article-mime-total-parts)
4528 (mm-handle-media-type handle))))))
4529 (goto-char (point-max))
4530 (setcdr begend (point-marker)))))
4532 (goto-char point))))
4534 (defconst gnus-article-wash-status-strings
4535 (let ((alist '((cite "c" "Possible hidden citation text"
4536 " " "All citation text visible")
4537 (headers "h" "Hidden headers"
4538 " " "All headers visible.")
4539 (pgp "p" "Encrypted or signed message status hidden"
4540 " " "No hidden encryption nor digital signature status")
4541 (signature "s" "Signature has been hidden"
4542 " " "Signature is visible")
4543 (overstrike "o" "Overstrike (^H) characters applied"
4544 " " "No overstrike characters applied")
4545 (emphasis "e" "/*_Emphasis_*/ characters applied"
4546 " " "No /*_emphasis_*/ characters applied")))
4548 (dolist (entry alist result)
4549 (let ((key (nth 0 entry))
4550 (on (copy-sequence (nth 1 entry)))
4551 (on-help (nth 2 entry))
4552 (off (copy-sequence (nth 3 entry)))
4553 (off-help (nth 4 entry)))
4554 (put-text-property 0 1 'help-echo on-help on)
4555 (put-text-property 0 1 'help-echo off-help off)
4556 (push (list key on off) result))))
4557 "Alist of strings describing wash status in the mode line.
4558 Each entry has the form (KEY ON OF), where the KEY is a symbol
4559 representing the particular washing function, ON is the string to use
4560 in the article mode line when the washing function is active, and OFF
4561 is the string to use when it is inactive.")
4563 (defun gnus-article-wash-status-entry (key value)
4564 (let ((entry (assoc key gnus-article-wash-status-strings)))
4565 (if value (nth 1 entry) (nth 2 entry))))
4567 (defun gnus-article-wash-status ()
4568 "Return a string which display status of article washing."
4570 (set-buffer gnus-article-buffer)
4571 (let ((cite (memq 'cite gnus-article-wash-types))
4572 (headers (memq 'headers gnus-article-wash-types))
4573 (boring (memq 'boring-headers gnus-article-wash-types))
4574 (pgp (memq 'pgp gnus-article-wash-types))
4575 (pem (memq 'pem gnus-article-wash-types))
4576 (signed (memq 'signed gnus-article-wash-types))
4577 (encrypted (memq 'encrypted gnus-article-wash-types))
4578 (signature (memq 'signature gnus-article-wash-types))
4579 (overstrike (memq 'overstrike gnus-article-wash-types))
4580 (emphasis (memq 'emphasis gnus-article-wash-types)))
4582 (gnus-article-wash-status-entry 'cite cite)
4583 (gnus-article-wash-status-entry 'headers (or headers boring))
4584 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4585 (gnus-article-wash-status-entry 'signature signature)
4586 (gnus-article-wash-status-entry 'overstrike overstrike)
4587 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4589 (defun gnus-add-wash-type (type)
4590 "Add a washing of TYPE to the current status."
4591 (add-to-list 'gnus-article-wash-types type))
4593 (defun gnus-delete-wash-type (type)
4594 "Add a washing of TYPE to the current status."
4595 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4597 (defun gnus-add-image (category image)
4598 "Add IMAGE of CATEGORY to the list of displayed images."
4599 (let ((entry (assq category gnus-article-image-alist)))
4601 (setq entry (list category))
4602 (push entry gnus-article-image-alist))
4603 (nconc entry (list image))))
4605 (defun gnus-delete-images (category)
4606 "Delete all images in CATEGORY."
4607 (let ((entry (assq category gnus-article-image-alist)))
4608 (dolist (image (cdr entry))
4609 (gnus-remove-image image))
4610 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4611 (gnus-delete-wash-type category)))
4613 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4615 (defun gnus-article-maybe-hide-headers ()
4616 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4617 Provided for backwards compatibility."
4618 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4619 (not (save-excursion (set-buffer gnus-summary-buffer)
4620 gnus-have-all-headers)))
4621 (not gnus-inhibit-hiding))
4622 (gnus-article-hide-headers)))
4626 (defun gnus-output-to-file (file-name)
4627 "Append the current article to a file named FILE-NAME."
4628 (let ((artbuf (current-buffer)))
4630 (insert-buffer-substring artbuf)
4631 ;; Append newline at end of the buffer as separator, and then
4633 (goto-char (point-max))
4635 (let ((file-name-coding-system nnmail-pathname-coding-system))
4636 (mm-append-to-file (point-min) (point-max) file-name))
4639 (defun gnus-narrow-to-page (&optional arg)
4640 "Narrow the article buffer to a page.
4641 If given a numerical ARG, move forward ARG pages."
4643 (setq arg (if arg (prefix-numeric-value arg) 0))
4645 (set-buffer gnus-article-buffer)
4646 (goto-char (point-min))
4648 ;; Remove any old next/prev buttons.
4649 (when (gnus-visual-p 'page-marker)
4650 (let ((buffer-read-only nil))
4651 (gnus-remove-text-with-property 'gnus-prev)
4652 (gnus-remove-text-with-property 'gnus-next)))
4655 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4657 (re-search-forward page-delimiter nil 'move arg)))
4658 (goto-char (match-end 0)))
4661 (if (re-search-forward page-delimiter nil 'move)
4664 (when (and (gnus-visual-p 'page-marker)
4665 (not (= (point-min) 1)))
4667 (goto-char (point-min))
4668 (gnus-insert-prev-page-button)))
4669 (when (and (gnus-visual-p 'page-marker)
4670 (< (+ (point-max) 2) (buffer-size)))
4672 (goto-char (point-max))
4673 (gnus-insert-next-page-button)))))
4675 ;; Article mode commands
4677 (defun gnus-article-goto-next-page ()
4678 "Show the next page of the article."
4680 (when (gnus-article-next-page)
4681 (goto-char (point-min))
4682 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4684 (defun gnus-article-goto-prev-page ()
4685 "Show the next page of the article."
4687 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4688 (gnus-article-prev-page nil)))
4690 (defun gnus-article-next-page (&optional lines)
4691 "Show the next page of the current article.
4692 If end of article, return non-nil. Otherwise return nil.
4693 Argument LINES specifies lines to be scrolled up."
4695 (move-to-window-line -1)
4698 (and (pos-visible-in-window-p) ;Not continuation line.
4699 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
4700 ;; Nothing in this page.
4701 (if (or (not gnus-page-broken)
4704 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4706 (gnus-narrow-to-page 1) ;Go to next page.
4708 ;; More in this page.
4709 (let ((scroll-in-place nil))
4713 ;; Long lines may cause an end-of-buffer error.
4714 (goto-char (point-max)))))
4715 (move-to-window-line 0)
4718 (defun gnus-article-prev-page (&optional lines)
4719 "Show previous page of current article.
4720 Argument LINES specifies lines to be scrolled down."
4722 (move-to-window-line 0)
4723 (if (and gnus-page-broken
4725 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4727 (gnus-narrow-to-page -1) ;Go to previous page.
4728 (goto-char (point-max))
4730 (let ((scroll-in-place nil))
4734 (beginning-of-buffer
4735 (goto-char (point-min))))
4736 (move-to-window-line 0)))))
4738 (defun gnus-article-refer-article ()
4739 "Read article specified by message-id around point."
4741 (let ((point (point)))
4742 (search-forward ">" nil t) ;Move point to end of "<....>".
4743 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4744 (let ((message-id (replace-regexp-in-string "<news:" "<" (match-string 1))))
4746 (set-buffer gnus-summary-buffer)
4747 (gnus-summary-refer-article message-id))
4749 (error "No references around point"))))
4751 (defun gnus-article-show-summary ()
4752 "Reconfigure windows to show summary buffer."
4754 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4755 (error "There is no summary buffer for this article buffer")
4756 (gnus-article-set-globals)
4757 (gnus-configure-windows 'article)
4758 (gnus-summary-goto-subject gnus-current-article)
4759 (gnus-summary-position-point)))
4761 (defun gnus-article-describe-briefly ()
4762 "Describe article mode commands briefly."
4764 (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")))
4766 (defun gnus-article-summary-command ()
4767 "Execute the last keystroke in the summary buffer."
4769 (let ((obuf (current-buffer))
4770 (owin (current-window-configuration))
4772 (switch-to-buffer gnus-article-current-summary 'norecord)
4773 (setq func (lookup-key (current-local-map) (this-command-keys)))
4774 (call-interactively func)
4776 (set-window-configuration owin)
4777 (set-window-point (get-buffer-window (current-buffer)) (point))))
4779 (defun gnus-article-summary-command-nosave ()
4780 "Execute the last keystroke in the summary buffer."
4783 (pop-to-buffer gnus-article-current-summary 'norecord)
4784 (setq func (lookup-key (current-local-map) (this-command-keys)))
4785 (call-interactively func)))
4787 (defun gnus-article-check-buffer ()
4788 "Beep if not in an article buffer."
4789 (unless (equal major-mode 'gnus-article-mode)
4790 (error "Command invoked outside of a Gnus article buffer")))
4792 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4793 "Read a summary buffer key sequence and execute it from the article buffer."
4795 (gnus-article-check-buffer)
4797 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4798 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4799 "=" "^" "\M-^" "|"))
4805 '("n" "Gn" "p" "Gp"))
4808 (set-buffer gnus-article-current-summary)
4809 (let (gnus-pick-mode)
4810 (push (or key last-command-event) unread-command-events)
4811 (setq keys (if (featurep 'xemacs)
4812 (events-to-keys (read-key-sequence nil))
4813 (read-key-sequence nil)))))
4817 (if (or (member keys nosaves)
4818 (member keys nosave-but-article)
4819 (member keys nosave-in-article))
4821 (save-window-excursion
4822 (pop-to-buffer gnus-article-current-summary 'norecord)
4823 ;; We disable the pick minor mode commands.
4824 (let (gnus-pick-mode)
4825 (setq func (lookup-key (current-local-map) keys))))
4829 (unless (member keys nosave-in-article)
4830 (set-buffer gnus-article-current-summary))
4831 (call-interactively func)
4832 (setq new-sum-point (point)))
4833 (when (member keys nosave-but-article)
4834 (pop-to-buffer gnus-article-buffer 'norecord)))
4835 ;; These commands should restore window configuration.
4836 (let ((obuf (current-buffer))
4837 (owin (current-window-configuration))
4839 (summary gnus-article-current-summary)
4840 func in-buffer selected)
4841 (if not-restore-window
4842 (pop-to-buffer summary 'norecord)
4843 (switch-to-buffer summary 'norecord))
4844 (setq in-buffer (current-buffer))
4845 ;; We disable the pick minor mode commands.
4846 (if (and (setq func (let (gnus-pick-mode)
4847 (lookup-key (current-local-map) keys)))
4850 (call-interactively func)
4851 (setq new-sum-point (point))
4852 (when (eq in-buffer (current-buffer))
4853 (setq selected (gnus-summary-select-article))
4855 (unless not-restore-window
4856 (set-window-configuration owin))
4857 (when (eq selected 'old)
4859 (set-window-start (get-buffer-window (current-buffer))
4861 (set-window-point (get-buffer-window (current-buffer))
4863 (let ((win (get-buffer-window gnus-article-current-summary)))
4865 (set-window-point win new-sum-point)))) )
4866 (switch-to-buffer gnus-article-buffer)
4869 (defun gnus-article-describe-key (key)
4870 "Display documentation of the function invoked by KEY. KEY is a string."
4871 (interactive "kDescribe key: ")
4872 (gnus-article-check-buffer)
4873 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4875 (set-buffer gnus-article-current-summary)
4876 (let (gnus-pick-mode)
4877 (if (featurep 'xemacs)
4879 (push (elt key 0) unread-command-events)
4880 (setq key (events-to-keys
4881 (read-key-sequence "Describe key: "))))
4882 (setq unread-command-events
4884 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4885 (string-to-list key)))
4886 (setq key (read-key-sequence "Describe key: "))))
4888 (describe-key key)))
4890 (defun gnus-article-describe-key-briefly (key &optional insert)
4891 "Display documentation of the function invoked by KEY. KEY is a string."
4892 (interactive "kDescribe key: \nP")
4893 (gnus-article-check-buffer)
4894 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4896 (set-buffer gnus-article-current-summary)
4897 (let (gnus-pick-mode)
4898 (if (featurep 'xemacs)
4900 (push (elt key 0) unread-command-events)
4901 (setq key (events-to-keys
4902 (read-key-sequence "Describe key: "))))
4903 (setq unread-command-events
4905 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4906 (string-to-list key)))
4907 (setq key (read-key-sequence "Describe key: "))))
4908 (describe-key-briefly key insert))
4909 (describe-key-briefly key insert)))
4911 (defun gnus-article-reply-with-original (&optional wide)
4912 "Start composing a reply mail to the current message.
4913 The text in the region will be yanked. If the region isn't active,
4914 the entire article will be yanked."
4916 (let ((article (cdr gnus-article-current))
4918 (if (not (gnus-mark-active-p))
4919 (with-current-buffer gnus-summary-buffer
4920 (gnus-summary-reply (list (list article)) wide))
4921 (setq contents (buffer-substring (point) (mark t)))
4922 ;; Deactivate active regions.
4923 (when (and (boundp 'transient-mark-mode)
4924 transient-mark-mode)
4925 (setq mark-active nil))
4926 (with-current-buffer gnus-summary-buffer
4928 (list (list article contents)) wide)))))
4930 (defun gnus-article-followup-with-original ()
4931 "Compose a followup to the current article.
4932 The text in the region will be yanked. If the region isn't active,
4933 the entire article will be yanked."
4935 (let ((article (cdr gnus-article-current))
4937 (if (not (gnus-mark-active-p))
4938 (with-current-buffer gnus-summary-buffer
4939 (gnus-summary-followup (list (list article))))
4940 (setq contents (buffer-substring (point) (mark t)))
4941 ;; Deactivate active regions.
4942 (when (and (boundp 'transient-mark-mode)
4943 transient-mark-mode)
4944 (setq mark-active nil))
4945 (with-current-buffer gnus-summary-buffer
4946 (gnus-summary-followup
4947 (list (list article contents)))))))
4949 (defun gnus-article-hide (&optional arg force)
4950 "Hide all the gruft in the current article.
4951 This means that signatures, cited text and (some) headers will be
4953 If given a prefix, show the hidden text instead."
4954 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4955 (gnus-article-hide-headers arg)
4956 (gnus-article-hide-list-identifiers arg)
4957 (gnus-article-hide-citation-maybe arg force)
4958 (gnus-article-hide-signature arg))
4960 (defun gnus-article-maybe-highlight ()
4961 "Do some article highlighting if article highlighting is requested."
4962 (when (gnus-visual-p 'article-highlight 'highlight)
4963 (gnus-article-highlight-some)))
4965 (defun gnus-check-group-server ()
4966 ;; Make sure the connection to the server is alive.
4967 (unless (gnus-server-opened
4968 (gnus-find-method-for-group gnus-newsgroup-name))
4969 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4970 (gnus-request-group gnus-newsgroup-name t)))
4973 (autoload 'nneething-get-file-name "nneething"))
4975 (defun gnus-request-article-this-buffer (article group)
4976 "Get an article and insert it into this buffer."
4977 (let (do-update-line sparse-header)
4981 (gnus-kill-all-overlays)
4982 (setq group (or group gnus-newsgroup-name))
4984 ;; Using `gnus-request-article' directly will insert the article into
4985 ;; `nntp-server-buffer' - so we'll save some time by not having to
4986 ;; copy it from the server buffer into the article buffer.
4988 ;; We only request an article by message-id when we do not have the
4989 ;; headers for it, so we'll have to get those.
4990 (when (stringp article)
4991 (gnus-read-header article))
4993 ;; If the article number is negative, that means that this article
4994 ;; doesn't belong in this newsgroup (possibly), so we find its
4995 ;; message-id and request it by id instead of number.
4996 (when (and (numberp article)
4998 (get-buffer gnus-summary-buffer)
4999 (gnus-buffer-exists-p gnus-summary-buffer))
5001 (set-buffer gnus-summary-buffer)
5002 (let ((header (gnus-summary-article-header article)))
5005 ((memq article gnus-newsgroup-sparse)
5006 ;; This is a sparse gap article.
5007 (setq do-update-line article)
5008 (setq article (mail-header-id header))
5009 (setq sparse-header (gnus-read-header article))
5010 (setq gnus-newsgroup-sparse
5011 (delq article gnus-newsgroup-sparse)))
5013 ;; It's a real article.
5014 (setq article (mail-header-id header)))
5016 ;; It is an extracted pseudo-article.
5017 (setq article 'pseudo)
5018 (gnus-request-pseudo-article header))))
5020 (let ((method (gnus-find-method-for-group
5021 gnus-newsgroup-name)))
5022 (when (and (eq (car method) 'nneething)
5024 (let ((dir (nneething-get-file-name
5025 (mail-header-id header))))
5026 (when (and (stringp dir)
5027 (file-directory-p dir))
5028 (setq article 'nneething)
5029 (gnus-group-enter-directory dir))))))))
5032 ;; Refuse to select canceled articles.
5033 ((and (numberp article)
5035 (get-buffer gnus-summary-buffer)
5036 (gnus-buffer-exists-p gnus-summary-buffer)
5037 (eq (cdr (save-excursion
5038 (set-buffer gnus-summary-buffer)
5039 (assq article gnus-newsgroup-reads)))
5040 gnus-canceled-mark))
5042 ;; We first check `gnus-original-article-buffer'.
5043 ((and (get-buffer gnus-original-article-buffer)
5046 (set-buffer gnus-original-article-buffer)
5047 (and (equal (car gnus-original-article) group)
5048 (eq (cdr gnus-original-article) article))))
5049 (insert-buffer-substring gnus-original-article-buffer)
5051 ;; Check the backlog.
5052 ((and gnus-keep-backlog
5053 (gnus-backlog-request-article group article (current-buffer)))
5055 ;; Check asynchronous pre-fetch.
5056 ((gnus-async-request-fetched-article group article (current-buffer))
5057 (gnus-async-prefetch-next group article gnus-summary-buffer)
5058 (when (and (numberp article) gnus-keep-backlog)
5059 (gnus-backlog-enter-article group article (current-buffer)))
5062 ((and gnus-use-cache
5064 (gnus-cache-request-article article group))
5066 ;; Check the agent cache.
5067 ((and gnus-agent gnus-agent-cache gnus-plugged
5069 (gnus-agent-request-article article group))
5071 ;; Get the article and put into the article buffer.
5072 ((or (stringp article)
5074 (let ((gnus-override-method gnus-override-method)
5075 (methods (and (stringp article)
5076 gnus-refer-article-method))
5077 (backend (car (gnus-find-method-for-group
5078 gnus-newsgroup-name)))
5080 (buffer-read-only nil))
5081 (if (or (not (listp methods))
5082 (and (symbolp (car methods))
5083 (assq (car methods) nnoo-definition-alist)))
5084 (setq methods (list methods)))
5085 (when (and (null gnus-override-method)
5087 (setq gnus-override-method (pop methods)))
5089 (when (eq gnus-override-method 'current)
5090 (setq gnus-override-method
5091 (with-current-buffer gnus-summary-buffer
5092 gnus-current-select-method)))
5094 (gnus-kill-all-overlays)
5095 (let ((gnus-newsgroup-name group))
5096 (gnus-check-group-server))
5098 ((gnus-request-article article group (current-buffer))
5099 (when (numberp article)
5100 (gnus-async-prefetch-next group article
5101 gnus-summary-buffer)
5102 (when gnus-keep-backlog
5103 (gnus-backlog-enter-article
5104 group article (current-buffer))))
5105 (setq result 'article))
5107 (setq gnus-override-method (pop methods)))
5108 ((not (string-match "^400 "
5109 (nnheader-get-report backend)))
5110 ;; If we get 400 server disconnect, reconnect and
5111 ;; retry; otherwise, assume the article has expired.
5112 (setq result 'done))))
5113 (and (eq result 'article) 'article)))
5117 ;; Associate this article with the current summary buffer.
5118 (setq gnus-article-current-summary gnus-summary-buffer)
5120 ;; Take the article from the original article buffer
5121 ;; and place it in the buffer it's supposed to be in.
5122 (when (and (get-buffer gnus-article-buffer)
5123 (equal (buffer-name (current-buffer))
5124 (buffer-name (get-buffer gnus-article-buffer))))
5126 (if (get-buffer gnus-original-article-buffer)
5127 (set-buffer gnus-original-article-buffer)
5128 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5129 (buffer-disable-undo)
5130 (setq major-mode 'gnus-original-article-mode)
5131 (setq buffer-read-only t))
5132 (let (buffer-read-only)
5134 (insert-buffer-substring gnus-article-buffer))
5135 (setq gnus-original-article (cons group article)))
5138 (run-hooks 'gnus-article-decode-hook)
5139 ;; Mark article as decoded or not.
5140 (setq gnus-article-decoded-p gnus-article-decode-hook))
5142 ;; Update sparse articles.
5143 (when (and do-update-line
5144 (or (numberp article)
5146 (let ((buf (current-buffer)))
5147 (set-buffer gnus-summary-buffer)
5148 (gnus-summary-update-article do-update-line sparse-header)
5149 (gnus-summary-goto-subject do-update-line nil t)
5150 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5152 (set-buffer buf))))))
5158 (defcustom gnus-article-edit-mode-hook nil
5159 "Hook run in article edit mode buffers."
5160 :group 'gnus-article-various
5163 (defvar gnus-article-edit-done-function nil)
5165 (defvar gnus-article-edit-mode-map nil)
5166 (defvar gnus-article-edit-mode nil)
5168 ;; Should we be using derived.el for this?
5169 (unless gnus-article-edit-mode-map
5170 (setq gnus-article-edit-mode-map (make-keymap))
5171 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5173 (gnus-define-keys gnus-article-edit-mode-map
5174 "\C-c?" describe-mode
5175 "\C-c\C-c" gnus-article-edit-done
5176 "\C-c\C-k" gnus-article-edit-exit
5177 "\C-c\C-f\C-t" message-goto-to
5178 "\C-c\C-f\C-o" message-goto-from
5179 "\C-c\C-f\C-b" message-goto-bcc
5180 ;;"\C-c\C-f\C-w" message-goto-fcc
5181 "\C-c\C-f\C-c" message-goto-cc
5182 "\C-c\C-f\C-s" message-goto-subject
5183 "\C-c\C-f\C-r" message-goto-reply-to
5184 "\C-c\C-f\C-n" message-goto-newsgroups
5185 "\C-c\C-f\C-d" message-goto-distribution
5186 "\C-c\C-f\C-f" message-goto-followup-to
5187 "\C-c\C-f\C-m" message-goto-mail-followup-to
5188 "\C-c\C-f\C-k" message-goto-keywords
5189 "\C-c\C-f\C-u" message-goto-summary
5190 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5191 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5192 "\C-c\C-b" message-goto-body
5193 "\C-c\C-i" message-goto-signature
5195 "\C-c\C-t" message-insert-to
5196 "\C-c\C-n" message-insert-newsgroups
5197 "\C-c\C-o" message-sort-headers
5198 "\C-c\C-e" message-elide-region
5199 "\C-c\C-v" message-delete-not-region
5200 "\C-c\C-z" message-kill-to-signature
5201 "\M-\r" message-newline-and-reformat
5202 "\C-c\C-a" mml-attach-file
5203 "\C-a" message-beginning-of-line
5205 "\M-;" comment-region)
5207 (gnus-define-keys (gnus-article-edit-wash-map
5208 "\C-c\C-w" gnus-article-edit-mode-map)
5209 "f" gnus-article-edit-full-stops))
5212 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5214 ["Fetch To" message-insert-to t]
5215 ["Fetch Newsgroups" message-insert-newsgroups t]
5217 ["To" message-goto-to t]
5218 ["From" message-goto-from t]
5219 ["Subject" message-goto-subject t]
5220 ["Cc" message-goto-cc t]
5221 ["Reply-To" message-goto-reply-to t]
5222 ["Summary" message-goto-summary t]
5223 ["Keywords" message-goto-keywords t]
5224 ["Newsgroups" message-goto-newsgroups t]
5225 ["Followup-To" message-goto-followup-to t]
5226 ["Mail-Followup-To" message-goto-mail-followup-to t]
5227 ["Distribution" message-goto-distribution t]
5228 ["Body" message-goto-body t]
5229 ["Signature" message-goto-signature t]))
5231 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5232 "Major mode for editing articles.
5233 This is an extended text-mode.
5235 \\{gnus-article-edit-mode-map}"
5236 (make-local-variable 'gnus-article-edit-done-function)
5237 (make-local-variable 'gnus-prev-winconf)
5238 (set (make-local-variable 'font-lock-defaults)
5239 '(message-font-lock-keywords t))
5240 (set (make-local-variable 'mail-header-separator) "")
5241 (set (make-local-variable 'gnus-article-edit-mode) t)
5242 (easy-menu-add message-mode-field-menu message-mode-map)
5244 (setq buffer-read-only nil)
5245 (buffer-enable-undo)
5248 (defun gnus-article-edit (&optional force)
5249 "Edit the current article.
5250 This will have permanent effect only in mail groups.
5251 If FORCE is non-nil, allow editing of articles even in read-only
5254 (when (and (not force)
5255 (gnus-group-read-only-p))
5256 (error "The current newsgroup does not support article editing"))
5257 (gnus-article-date-original)
5258 (gnus-article-edit-article
5260 `(lambda (no-highlight)
5262 (gnus-summary-edit-article-done
5263 ,(or (mail-header-references gnus-current-headers) "")
5264 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5266 (defun gnus-article-edit-article (start-func exit-func)
5267 "Start editing the contents of the current article buffer."
5268 (let ((winconf (current-window-configuration)))
5269 (set-buffer gnus-article-buffer)
5270 (gnus-article-edit-mode)
5271 (funcall start-func)
5272 (set-buffer-modified-p nil)
5273 (gnus-configure-windows 'edit-article)
5274 (setq gnus-article-edit-done-function exit-func)
5275 (setq gnus-prev-winconf winconf)
5276 (gnus-message 6 "C-c C-c to end edits")))
5278 (defun gnus-article-edit-done (&optional arg)
5279 "Update the article edits and exit."
5281 (let ((func gnus-article-edit-done-function)
5282 (buf (current-buffer))
5283 (start (window-start))
5285 (winconf gnus-prev-winconf))
5286 (widen) ;; Widen it in case that users narrowed the buffer.
5289 ;; The cache and backlog have to be flushed somewhat.
5290 (when gnus-keep-backlog
5291 (gnus-backlog-remove-article
5292 (car gnus-article-current) (cdr gnus-article-current)))
5293 ;; Flush original article as well.
5295 (when (get-buffer gnus-original-article-buffer)
5296 (set-buffer gnus-original-article-buffer)
5297 (setq gnus-original-article nil)))
5298 (when gnus-use-cache
5299 (gnus-cache-update-article
5300 (car gnus-article-current) (cdr gnus-article-current)))
5301 ;; We remove all text props from the article buffer.
5302 (kill-all-local-variables)
5303 (gnus-set-text-properties (point-min) (point-max) nil)
5305 (set-window-configuration winconf)
5307 (set-window-start (get-buffer-window buf) start)
5308 (set-window-point (get-buffer-window buf) (point))))
5310 (defun gnus-article-edit-exit ()
5311 "Exit the article editing without updating."
5313 (when (or (not (buffer-modified-p))
5314 (yes-or-no-p "Article modified; kill anyway? "))
5315 (let ((curbuf (current-buffer))
5317 (window-start (window-start)))
5319 (if (gnus-buffer-live-p gnus-original-article-buffer)
5320 (insert-buffer gnus-original-article-buffer))
5321 (let ((winconf gnus-prev-winconf))
5322 (kill-all-local-variables)
5324 (set-window-configuration winconf)
5325 ;; Tippy-toe some to make sure that point remains where it was.
5326 (save-current-buffer
5328 (set-window-start (get-buffer-window (current-buffer)) window-start)
5331 (defun gnus-article-edit-full-stops ()
5332 "Interactively repair spacing at end of sentences."
5335 (goto-char (point-min))
5336 (search-forward-regexp "^$" nil t)
5337 (let ((case-fold-search nil))
5338 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5341 ;;; Article highlights
5344 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5346 ;;; Internal Variables:
5348 (defcustom gnus-button-url-regexp
5349 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5350 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~`%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~`%&*+\\/[:word:]]\\)"
5351 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~`%&*+\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~`%&*+\\/]\\|\\w\\)\\)")
5352 "Regular expression that matches URLs."
5353 :group 'gnus-article-buttons
5356 (defcustom gnus-button-valid-fqdn-regexp
5357 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
5359 "\\([a-z][a-z]" ;; two letter country TDLs
5360 "\\|biz\\|com\\|edu\\|gov\\|int\\|mil\\|net\\|org"
5361 "\\|aero\\|coop\\|info\\|name\\|museum"
5362 "\\|arpa\\|pro\\|uucp\\|bitnet\\|bofh" ;; old style?
5364 "Regular expression that matches a valid FQDN."
5365 :group 'gnus-article-buttons
5368 (defcustom gnus-button-man-handler 'manual-entry
5369 "Function to use for displaying man pages.
5370 The function must take at least one argument with a string naming the
5372 :type '(choice (function-item :tag "Man" manual-entry)
5373 (function-item :tag "Woman" woman)
5374 (function :tag "Other"))
5375 :group 'gnus-article-buttons)
5377 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5378 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5379 If the default site is too slow, try to find a CTAN mirror, see
5380 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5381 the variable `gnus-button-handle-ctan'."
5382 :group 'gnus-article-buttons
5383 :link '(custom-manual "(gnus)Group Parameters")
5384 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5385 (const "http://tug.ctan.org/tex-archive/")
5386 (const "http://www.dante.de/CTAN/")
5387 (string :tag "Other")))
5389 (defcustom gnus-button-ctan-handler 'browse-url
5390 "Function to use for displaying CTAN links.
5391 The function must take one argument, the string naming the URL."
5392 :type '(choice (function-item :tag "Browse Url" browse-url)
5393 (function :tag "Other"))
5394 :group 'gnus-article-buttons)
5396 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5397 "Bogus strings removed from CTAN URLs."
5398 :group 'gnus-article-buttons
5399 :type '(choice (const "^/?tex-archive/\\|/")
5400 (regexp :tag "Other")))
5402 (defcustom gnus-button-mid-or-mail-regexp
5403 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
5404 gnus-button-valid-fqdn-regexp
5406 "Regular expression that matches a message ID or a mail address."
5407 :group 'gnus-article-buttons
5410 (defcustom gnus-button-prefer-mid-or-mail 'guess
5411 "What to do when the button on a string as \"foo123@bar.com\" is pushed.
5412 Strings like this can be either a message ID or a mail address. If the
5413 variable is set to the symbol `ask', query the user what do do. If it is the
5414 symbol `guess', Gnus will do a guess and query the user what do do if it is
5415 ambiguous. See the variable `gnus-button-guessed-mid-regexp' for details
5416 concerning the guessing. If it is one of the sybols `mid' or `mail', Gnus
5417 will always assume that the string is a message ID or a mail address,
5419 ;; FIXME: doc-string could/should be improved.
5420 :group 'gnus-article-buttons
5421 :type '(choice (const ask)
5426 (defcustom gnus-button-guessed-mid-regexp
5428 "^<?\\(slrn\\|Pine\\.\\)"
5429 "\\|\\.fsf@\\|\\.fsf_-_@\\|\\.ln@"
5430 "\\|@4ax\\.com\\|@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de"
5431 "\\|^<?.*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*@")
5432 "Regular expression that matches message IDs and not mail addresses."
5433 ;; TODO: Incorporate more matches from
5434 ;; <URL:http://piology.org/perl/id-or-mail.pl.html>. I.e. translate the
5435 ;; Perl-REs to Elisp-REs.
5436 :group 'gnus-article-buttons
5439 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5440 (let* ((pref gnus-button-prefer-mid-or-mail)
5441 (url-mid (concat "news" ":" mid-or-mail))
5442 (url-mailto (concat "mailto" ":" mid-or-mail)))
5443 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5444 ;; If it looks like a MID (well known readers or servers) use 'mid,
5445 ;; otherwise 'ask the user.
5446 (if (eq pref 'guess)
5447 (if (string-match gnus-button-guessed-mid-regexp mid-or-mail)
5451 (save-window-excursion
5452 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5455 (cond ((eq pref 'mid)
5456 (gnus-message 9 "calling `gnus-button-handle-news' %s" url-mid)
5457 (gnus-button-handle-news url-mid))
5459 (gnus-message 9 "calling `gnus-url-mailto' %s" url-mailto)
5460 (gnus-url-mailto url-mailto)))))
5462 (defun gnus-button-handle-custom (url)
5463 "Follow a Custom URL."
5464 (customize-apropos (gnus-url-unhex-string url)))
5466 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5468 (defun gnus-button-handle-describe-function (url)
5469 "Call `describe-function' when pushing the corresponding URL button."
5472 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5474 (defun gnus-button-handle-describe-variable (url)
5475 "Call `describe-variable' when pushing the corresponding URL button."
5478 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5480 (defun gnus-button-handle-describe-key (url)
5481 "Call `describe-key' when pushing the corresponding URL button."
5483 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5484 (keys (ignore-errors (eval `(kbd ,key-string)))))
5487 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5489 (defun gnus-button-handle-apropos (url)
5490 "Call `apropos' when pushing the corresponding URL button."
5491 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5493 (defun gnus-button-handle-apropos-command (url)
5494 "Call `apropos' when pushing the corresponding URL button."
5496 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5498 (defun gnus-button-handle-apropos-variable (url)
5499 "Call `apropos' when pushing the corresponding URL button."
5501 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5502 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5504 (defun gnus-button-handle-apropos-documentation (url)
5505 "Call `apropos' when pushing the corresponding URL button."
5507 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
5508 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5510 (defun gnus-button-handle-ctan (url)
5511 "Call `browse-url' when pushing a CTAN URL button."
5513 gnus-button-ctan-handler
5516 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
5518 (defcustom gnus-button-tex-level 5
5519 "*Integer that says how many TeX-related buttons Gnus will show.
5520 The higher the number, the more buttons will appear and the more false
5521 positives are possible. Note that you can set this variable local to
5522 specifific groups. Setting it higher in TeX groups is probably a good idea.
5523 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5524 how to set variables in specific groups."
5525 :group 'gnus-article-buttons
5526 :link '(custom-manual "(gnus)Group Parameters")
5529 (defcustom gnus-button-man-level 5
5530 "*Integer that says how many man-related buttons Gnus will show.
5531 The higher the number, the more buttons will appear and the more false
5532 positives are possible. Note that you can set this variable local to
5533 specifific groups. Setting it higher in Unix groups is probably a good idea.
5534 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5535 how to set variables in specific groups."
5536 :group 'gnus-article-buttons
5537 :link '(custom-manual "(gnus)Group Parameters")
5540 (defcustom gnus-button-emacs-level 5
5541 "*Integer that says how many emacs-related buttons Gnus will show.
5542 The higher the number, the more buttons will appear and the more false
5543 positives are possible. Note that you can set this variable local to
5544 specifific groups. Setting it higher in Emacs or Gnus related groups is
5545 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
5546 `gnus-parameters' on how to set variables in specific groups."
5547 :group 'gnus-article-buttons
5548 :link '(custom-manual "(gnus)Group Parameters")
5551 (defcustom gnus-button-mail-level 5
5552 "*Integer that says how many buttons for message IDs or mail addresses will appear.
5553 The higher the number, the more buttons will appear and the more false
5554 positives are possible."
5555 :group 'gnus-article-buttons
5558 (defcustom gnus-button-alist
5559 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5560 0 t gnus-button-handle-news 3)
5561 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5562 gnus-button-handle-news 2)
5563 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5565 gnus-button-fetch-group 4)
5566 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5567 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5568 t gnus-button-message-id 3)
5569 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5570 ("mailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5571 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5573 ("\\bCTAN:[ \t\n]*\\([^>)!;:,\n\t ]*\\)" 0 (>= gnus-button-tex-level 1)
5574 gnus-button-handle-ctan 1)
5576 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5577 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2)
5579 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5580 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
5581 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5582 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
5583 ;; Emacs help commands
5584 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5585 ;; regexp doesn't match arguments containing ` '.
5586 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
5587 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5588 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
5589 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5590 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
5591 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5592 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
5593 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5594 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
5595 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5596 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
5597 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'" 1
5598 ;; Unlike the other regexps we really have to require quoting
5599 ;; here to determine where it ends.
5600 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
5601 ;; This is how URLs _should_ be embedded in text...
5602 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5604 (gnus-button-url-regexp 0 t browse-url 0)
5606 ("\\b\\([a-z][a-z]+\\)([1-9])\\W" 0
5607 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
5608 gnus-button-handle-man 1)
5609 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
5610 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W" 0
5611 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
5612 gnus-button-handle-man 1)
5613 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
5614 ;; SoWWWAnchor(3iv), XSelectInput(3X11)
5615 ("\\b\\([a-z][-_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W" 0
5616 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
5617 ;; MID or mail: To avoid too many false positives we don't try to catch
5618 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
5619 ;; at least one dot. TLD must contain two or three chars or be a know TLD
5620 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
5621 ;; so that non-ambiguous entries (see above) match first.
5622 (gnus-button-mid-or-mail-regexp
5623 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1))
5624 "*Alist of regexps matching buttons in article bodies.
5626 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5627 REGEXP: is the string (case insensitive) matching text around the button (can
5628 also be lisp expression evaluating to a string),
5629 BUTTON: is the number of the regexp grouping actually matching the button,
5630 FORM: is a lisp expression which must eval to true for the button to
5632 CALLBACK: is the function to call when the user push this button, and each
5633 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5635 CALLBACK can also be a variable, in that case the value of that
5636 variable it the real callback function."
5637 :group 'gnus-article-buttons
5638 :type '(repeat (list (choice regexp variable)
5639 (integer :tag "Button")
5641 (function :tag "Callback")
5644 (integer :tag "Regexp group")))))
5646 (defcustom gnus-header-button-alist
5647 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5648 0 t gnus-button-message-id 0)
5649 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5650 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5651 0 t gnus-button-mailto 0)
5652 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
5653 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
5654 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
5655 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5656 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5657 gnus-button-message-id 3))
5658 "*Alist of headers and regexps to match buttons in article heads.
5660 This alist is very similar to `gnus-button-alist', except that each
5661 alist has an additional HEADER element first in each entry:
5663 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5665 HEADER is a regexp to match a header. For a fuller explanation, see
5666 `gnus-button-alist'."
5667 :group 'gnus-article-buttons
5668 :group 'gnus-article-headers
5669 :type '(repeat (list (regexp :tag "Header")
5671 (integer :tag "Button")
5673 (function :tag "Callback")
5676 (integer :tag "Regexp group")))))
5678 (defvar gnus-button-regexp nil)
5679 (defvar gnus-button-marker-list nil)
5680 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5682 (defvar gnus-button-last nil)
5683 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5687 (defun gnus-article-push-button (event)
5688 "Check text under the mouse pointer for a callback function.
5689 If the text under the mouse pointer has a `gnus-callback' property,
5690 call it with the value of the `gnus-data' text property."
5692 (set-buffer (window-buffer (posn-window (event-start event))))
5693 (let* ((pos (posn-point (event-start event)))
5694 (data (get-text-property pos 'gnus-data))
5695 (fun (get-text-property pos 'gnus-callback)))
5698 (funcall fun data))))
5700 (defun gnus-article-press-button ()
5701 "Check text at point for a callback function.
5702 If the text at point has a `gnus-callback' property,
5703 call it with the value of the `gnus-data' text property."
5705 (let ((data (get-text-property (point) 'gnus-data))
5706 (fun (get-text-property (point) 'gnus-callback)))
5708 (funcall fun data))))
5710 (defun gnus-article-highlight (&optional force)
5711 "Highlight current article.
5712 This function calls `gnus-article-highlight-headers',
5713 `gnus-article-highlight-citation',
5714 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5715 do the highlighting. See the documentation for those functions."
5716 (interactive (list 'force))
5717 (gnus-article-highlight-headers)
5718 (gnus-article-highlight-citation force)
5719 (gnus-article-highlight-signature)
5720 (gnus-article-add-buttons force)
5721 (gnus-article-add-buttons-to-head))
5723 (defun gnus-article-highlight-some (&optional force)
5724 "Highlight current article.
5725 This function calls `gnus-article-highlight-headers',
5726 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5727 do the highlighting. See the documentation for those functions."
5728 (interactive (list 'force))
5729 (gnus-article-highlight-headers)
5730 (gnus-article-highlight-signature)
5731 (gnus-article-add-buttons))
5733 (defun gnus-article-highlight-headers ()
5734 "Highlight article headers as specified by `gnus-header-face-alist'."
5737 (set-buffer gnus-article-buffer)
5739 (let ((alist gnus-header-face-alist)
5740 (buffer-read-only nil)
5741 (case-fold-search t)
5742 (inhibit-point-motion-hooks t)
5743 entry regexp header-face field-face from hpoints fpoints)
5744 (article-narrow-to-head)
5745 (while (setq entry (pop alist))
5746 (goto-char (point-min))
5747 (setq regexp (concat "^\\("
5748 (if (string-equal "" (nth 0 entry))
5752 header-face (nth 1 entry)
5753 field-face (nth 2 entry))
5754 (while (and (re-search-forward regexp nil t)
5758 (unless (search-forward ":" nil t)
5760 (when (and header-face
5761 (not (memq (point) hpoints)))
5762 (push (point) hpoints)
5763 (gnus-put-text-property from (point) 'face header-face))
5764 (when (and field-face
5765 (not (memq (setq from (point)) fpoints)))
5767 (if (re-search-forward "^[^ \t]" nil t)
5769 (goto-char (point-max)))
5770 (gnus-put-text-property from (point) 'face field-face))))))))
5772 (defun gnus-article-highlight-signature ()
5773 "Highlight the signature in an article.
5774 It does this by highlighting everything after
5775 `gnus-signature-separator' using `gnus-signature-face'."
5778 (set-buffer gnus-article-buffer)
5779 (let ((buffer-read-only nil)
5780 (inhibit-point-motion-hooks t))
5782 (when (and gnus-signature-face
5783 (gnus-article-narrow-to-signature))
5784 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5785 'face gnus-signature-face)
5787 (gnus-article-search-signature)
5788 (let ((start (match-beginning 0))
5789 (end (set-marker (make-marker) (1+ (match-end 0)))))
5790 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5793 (defun gnus-button-in-region-p (b e prop)
5794 "Say whether PROP exists in the region."
5795 (text-property-not-all b e prop nil))
5797 (defun gnus-article-add-buttons (&optional force)
5798 "Find external references in the article and make buttons of them.
5799 \"External references\" are things like Message-IDs and URLs, as
5800 specified by `gnus-button-alist'."
5801 (interactive (list 'force))
5803 (set-buffer gnus-article-buffer)
5804 (let ((buffer-read-only nil)
5805 (inhibit-point-motion-hooks t)
5806 (case-fold-search t)
5807 (alist gnus-button-alist)
5809 ;; Remove all old markers.
5810 (let (marker entry new-list)
5811 (while (setq marker (pop gnus-button-marker-list))
5812 (if (or (< marker (point-min)) (>= marker (point-max)))
5813 (push marker new-list)
5815 (when (setq entry (gnus-button-entry))
5816 (put-text-property (match-beginning (nth 1 entry))
5817 (match-end (nth 1 entry))
5818 'gnus-callback nil))
5819 (set-marker marker nil)))
5820 (setq gnus-button-marker-list new-list))
5821 ;; We skip the headers.
5824 (while (setq entry (pop alist))
5825 (setq regexp (eval (car entry)))
5827 (while (re-search-forward regexp nil t)
5828 (let* ((start (and entry (match-beginning (nth 1 entry))))
5829 (end (and entry (match-end (nth 1 entry))))
5830 (from (match-beginning 0)))
5831 (when (and (or (eq t (nth 2 entry))
5832 (eval (nth 2 entry)))
5833 (not (gnus-button-in-region-p
5834 start end 'gnus-callback)))
5835 ;; That optional form returned non-nil, so we add the
5837 (gnus-article-add-button
5838 start end 'gnus-button-push
5839 (car (push (set-marker (make-marker) from)
5840 gnus-button-marker-list))))))))))
5842 ;; Add buttons to the head of an article.
5843 (defun gnus-article-add-buttons-to-head ()
5844 "Add buttons to the head of the article."
5847 (set-buffer gnus-article-buffer)
5849 (let ((buffer-read-only nil)
5850 (inhibit-point-motion-hooks t)
5851 (case-fold-search t)
5852 (alist gnus-header-button-alist)
5854 (article-narrow-to-head)
5856 ;; Each alist entry.
5857 (setq entry (car alist)
5859 (goto-char (point-min))
5860 (while (re-search-forward (car entry) nil t)
5861 ;; Each header matching the entry.
5862 (setq beg (match-beginning 0))
5863 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5864 (match-beginning 0))
5867 (while (re-search-forward (eval (nth 1 entry)) end t)
5868 ;; Each match within a header.
5869 (let* ((entry (cdr entry))
5870 (start (match-beginning (nth 1 entry)))
5871 (end (match-end (nth 1 entry)))
5872 (form (nth 2 entry)))
5873 (goto-char (match-end 0))
5875 (gnus-article-add-button
5876 start end (nth 3 entry)
5877 (buffer-substring (match-beginning (nth 4 entry))
5878 (match-end (nth 4 entry)))))))
5879 (goto-char end)))))))
5881 ;;; External functions:
5883 (defun gnus-article-add-button (from to fun &optional data)
5884 "Create a button between FROM and TO with callback FUN and data DATA."
5885 (when gnus-article-button-face
5886 (gnus-overlay-put (gnus-make-overlay from to)
5887 'face gnus-article-button-face))
5888 (gnus-add-text-properties
5890 (nconc (and gnus-article-mouse-face
5891 (list gnus-mouse-face-prop gnus-article-mouse-face))
5892 (list 'gnus-callback fun)
5893 (and data (list 'gnus-data data))))
5894 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5895 :button-keymap gnus-widget-button-keymap))
5897 ;;; Internal functions:
5899 (defun gnus-article-set-globals ()
5901 (set-buffer gnus-summary-buffer)
5902 (gnus-set-global-variables)))
5904 (defun gnus-signature-toggle (end)
5906 (set-buffer gnus-article-buffer)
5907 (let ((buffer-read-only nil)
5908 (inhibit-point-motion-hooks t))
5909 (if (text-property-any end (point-max) 'article-type 'signature)
5911 (gnus-delete-wash-type 'signature)
5912 (gnus-remove-text-properties-when
5913 'article-type 'signature end (point-max)
5914 (cons 'article-type (cons 'signature
5915 gnus-hidden-properties))))
5916 (gnus-add-wash-type 'signature)
5917 (gnus-add-text-properties-when
5918 'article-type nil end (point-max)
5919 (cons 'article-type (cons 'signature
5920 gnus-hidden-properties)))))
5921 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5922 (gnus-set-mode-line 'article))))
5924 (defun gnus-button-entry ()
5925 ;; Return the first entry in `gnus-button-alist' matching this place.
5926 (let ((alist gnus-button-alist)
5929 (setq entry (pop alist))
5930 (if (looking-at (eval (car entry)))
5935 (defun gnus-button-push (marker)
5936 ;; Push button starting at MARKER.
5939 (let* ((entry (gnus-button-entry))
5940 (inhibit-point-motion-hooks t)
5942 (args (mapcar (lambda (group)
5943 (let ((string (match-string group)))
5944 (gnus-set-text-properties
5945 0 (length string) nil string)
5952 (fboundp (symbol-value fun)))
5953 (apply (symbol-value fun) args))
5955 (gnus-message 1 "You must define `%S' to use this button"
5956 (cons fun args)))))))
5958 (defun gnus-parse-news-url (url)
5959 (let (scheme server group message-id articles)
5962 (goto-char (point-min))
5963 (when (looking-at "\\([A-Za-z]+\\):")
5964 (setq scheme (match-string 1))
5965 (goto-char (match-end 0)))
5966 (when (looking-at "//\\([^/]+\\)/")
5967 (setq server (match-string 1))
5968 (goto-char (match-end 0)))
5971 ((looking-at "\\(.*@.*\\)")
5972 (setq message-id (match-string 1)))
5973 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5974 (setq group (match-string 1)
5975 articles (split-string (match-string 2) "-")))
5976 ((looking-at "\\([^/]+\\)/?")
5977 (setq group (match-string 1)))
5979 (error "Unknown news URL syntax"))))
5980 (list scheme server group message-id articles)))
5982 (defun gnus-button-handle-news (url)
5984 (destructuring-bind (scheme server group message-id articles)
5985 (gnus-parse-news-url url)
5989 (set-buffer gnus-summary-buffer)
5991 (let ((gnus-refer-article-method (list (list 'nntp server))))
5992 (gnus-summary-refer-article message-id))
5993 (gnus-summary-refer-article message-id))))
5995 (gnus-button-fetch-group url)))))
5997 (defun gnus-button-handle-man (url)
5999 (funcall gnus-button-man-handler url))
6001 (defun gnus-button-handle-info (url)
6002 "Fetch an info URL."
6004 "^\\([^:/]+\\)?/\\(.*\\)"
6006 (gnus-info-find-node
6007 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6010 (gnus-url-unhex-string (match-string 2 url))))
6011 (error "Can't parse %s" url)))
6013 (defun gnus-button-message-id (message-id)
6016 (set-buffer gnus-summary-buffer)
6017 (gnus-summary-refer-article message-id)))
6019 (defun gnus-button-fetch-group (address)
6020 "Fetch GROUP specified by ADDRESS."
6021 (if (not (string-match "[:/]" address))
6022 ;; This is just a simple group url.
6023 (gnus-group-read-ephemeral-group address gnus-select-method)
6026 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6028 (error "Can't parse %s" address)
6029 (gnus-group-read-ephemeral-group
6030 (match-string 4 address)
6031 `(nntp ,(match-string 1 address)
6032 (nntp-address ,(match-string 1 address))
6033 (nntp-port-number ,(if (match-end 3)
6034 (match-string 3 address)
6037 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6039 (defun gnus-url-parse-query-string (query &optional downcase)
6040 (let (retval pairs cur key val)
6041 (setq pairs (split-string query "&"))
6043 (setq cur (car pairs)
6045 (if (not (string-match "=" cur))
6047 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6048 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6050 (setq key (downcase key)))
6051 (setq cur (assoc key retval))
6053 (setcdr cur (cons val (cdr cur)))
6054 (setq retval (cons (list key val) retval)))))
6057 (defun gnus-url-mailto (url)
6058 ;; Send mail to someone
6059 (when (string-match "mailto:/*\\(.*\\)" url)
6060 (setq url (substring url (match-beginning 1) nil)))
6061 (let (to args subject func)
6062 (if (string-match (regexp-quote "?") url)
6063 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6064 args (gnus-url-parse-query-string
6065 (substring url (match-end 0) nil) t))
6066 (setq to (gnus-url-unhex-string url)))
6067 (setq args (cons (list "to" to) args)
6068 subject (cdr-safe (assoc "subject" args)))
6071 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6074 (message-position-on-field (caar args)))
6075 (insert (mapconcat 'identity (cdar args) ", "))
6076 (setq args (cdr args)))
6079 (message-goto-subject))))
6081 (defun gnus-button-embedded-url (address)
6082 "Activate ADDRESS with `browse-url'."
6083 (browse-url (gnus-strip-whitespace address)))
6085 ;;; Next/prev buttons in the article buffer.
6087 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6088 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6090 (defvar gnus-prev-page-map
6091 (let ((map (make-sparse-keymap)))
6092 (unless (>= emacs-major-version 21)
6093 ;; XEmacs doesn't care.
6094 (set-keymap-parent map gnus-article-mode-map))
6095 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6096 (define-key map "\r" 'gnus-button-prev-page)
6099 (defun gnus-insert-prev-page-button ()
6101 (buffer-read-only nil))
6103 gnus-prev-page-line-format nil
6104 `(,@(gnus-local-map-property gnus-prev-page-map)
6106 gnus-callback gnus-article-button-prev-page
6107 article-type annotation))
6108 (widget-convert-button
6110 :action 'gnus-button-prev-page
6111 :button-keymap gnus-prev-page-map)))
6113 (defvar gnus-prev-page-map
6114 (let ((map (make-sparse-keymap)))
6115 (unless (>= emacs-major-version 21)
6116 ;; XEmacs doesn't care.
6117 (set-keymap-parent map gnus-article-mode-map))
6118 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6119 (define-key map "\r" 'gnus-button-prev-page)
6122 (defvar gnus-next-page-map
6123 (let ((map (make-sparse-keymap)))
6124 (unless (>= emacs-major-version 21)
6125 ;; XEmacs doesn't care.
6126 (set-keymap-parent map gnus-article-mode-map))
6127 (define-key map gnus-mouse-2 'gnus-button-next-page)
6128 (define-key map "\r" 'gnus-button-next-page)
6131 (defun gnus-button-next-page (&optional args more-args)
6132 "Go to the next page."
6134 (let ((win (selected-window)))
6135 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6136 (gnus-article-next-page)
6137 (select-window win)))
6139 (defun gnus-button-prev-page (&optional args more-args)
6140 "Go to the prev page."
6142 (let ((win (selected-window)))
6143 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6144 (gnus-article-prev-page)
6145 (select-window win)))
6147 (defun gnus-insert-next-page-button ()
6149 (buffer-read-only nil))
6150 (gnus-eval-format gnus-next-page-line-format nil
6151 `(,@(gnus-local-map-property gnus-next-page-map)
6153 gnus-callback gnus-article-button-next-page
6154 article-type annotation))
6155 (widget-convert-button
6157 :action 'gnus-button-next-page
6158 :button-keymap gnus-next-page-map)))
6160 (defun gnus-article-button-next-page (arg)
6161 "Go to the next page."
6163 (let ((win (selected-window)))
6164 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6165 (gnus-article-next-page)
6166 (select-window win)))
6168 (defun gnus-article-button-prev-page (arg)
6169 "Go to the prev page."
6171 (let ((win (selected-window)))
6172 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6173 (gnus-article-prev-page)
6174 (select-window win)))
6176 (defvar gnus-decode-header-methods
6177 '(mail-decode-encoded-word-region)
6178 "List of methods used to decode headers.
6180 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6181 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6182 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6183 whose names match REGEXP.
6186 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6187 mail-decode-encoded-word-region
6188 (\"chinese\" . rfc1843-decode-region))
6191 (defvar gnus-decode-header-methods-cache nil)
6193 (defun gnus-multi-decode-header (start end)
6194 "Apply the functions from `gnus-encoded-word-methods' that match."
6195 (unless (and gnus-decode-header-methods-cache
6196 (eq gnus-newsgroup-name
6197 (car gnus-decode-header-methods-cache)))
6198 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6201 (nconc gnus-decode-header-methods-cache (list x))
6202 (if (and gnus-newsgroup-name
6203 (string-match (car x) gnus-newsgroup-name))
6204 (nconc gnus-decode-header-methods-cache
6206 gnus-decode-header-methods))
6207 (let ((xlist gnus-decode-header-methods-cache))
6210 (narrow-to-region start end)
6212 (funcall (pop xlist) (point-min) (point-max))))))
6215 ;;; Treatment top-level handling.
6218 (defun gnus-treat-article (condition &optional part-number total-parts type)
6219 (let ((length (- (point-max) (point-min)))
6220 (alist gnus-treatment-function-alist)
6221 (article-goto-body-goes-to-point-min-p t)
6225 (let ((list gnus-article-treat-types))
6227 (when (string-match (pop list) type)
6228 (throw 'found t)))))))
6229 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6231 (gnus-run-hooks 'gnus-part-display-hook)
6232 (dolist (elem alist)
6235 (when (gnus-buffer-live-p gnus-summary-buffer)
6236 (set-buffer gnus-summary-buffer))
6237 (symbol-value (car elem))))
6238 (when (and (or (consp val)
6240 (gnus-treat-predicate val)
6241 (or (not (get (car elem) 'highlight))
6244 (funcall (cadr elem)))))))
6246 ;; Dynamic variables.
6248 (defvar part-number)
6249 (defvar total-parts)
6254 (defun gnus-treat-predicate (val)
6261 (stringp (car val)))
6262 (apply 'gnus-or (mapcar `(lambda (s)
6263 (string-match s ,(or gnus-newsgroup-name "")))
6266 (let ((pred (pop val)))
6269 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6271 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6273 (not (gnus-treat-predicate (car val))))
6275 (equal (car val) type))
6277 (error "%S is not a valid predicate" pred)))))
6283 (eq part-number total-parts))
6287 (error "%S is not a valid value" val))))
6289 (defun gnus-article-encrypt-body (protocol &optional n)
6290 "Encrypt the article body."
6293 (or gnus-article-encrypt-protocol
6294 (completing-read "Encrypt protocol: "
6295 gnus-article-encrypt-protocol-alist
6297 current-prefix-arg))
6298 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6300 (error (format "Can't find the encrypt protocol %s" protocol)))
6301 (if (member gnus-newsgroup-name '("nndraft:delayed"
6304 (error "Can't encrypt the article in group %s"
6305 gnus-newsgroup-name))
6306 (gnus-summary-iterate n
6308 (set-buffer gnus-summary-buffer)
6309 (let ((mail-parse-charset gnus-newsgroup-charset)
6310 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6311 (summary-buffer gnus-summary-buffer)
6313 (gnus-set-global-variables)
6314 (when (gnus-group-read-only-p)
6315 (error "The current newsgroup does not support article encrypt"))
6316 (gnus-summary-show-article t)
6318 (or (mail-header-references gnus-current-headers) ""))
6319 (set-buffer gnus-article-buffer)
6320 (let* ((buffer-read-only nil)
6322 (mapcar (lambda (field)
6323 (and (save-restriction
6324 (message-narrow-to-head)
6325 (goto-char (point-min))
6326 (search-forward field nil t))
6328 (message-narrow-to-field)
6329 (buffer-substring (point-min) (point-max))
6330 (delete-region (point-min) (point-max))
6332 '("Content-Type:" "Content-Transfer-Encoding:"
6333 "Content-Disposition:"))))
6334 (message-narrow-to-head)
6335 (message-remove-header "MIME-Version")
6336 (goto-char (point-max))
6337 (setq point (point))
6338 (insert (apply 'concat headers))
6340 (narrow-to-region point (point-max))
6341 (let ((message-options message-options))
6342 (message-options-set 'message-sender user-mail-address)
6343 (message-options-set 'message-recipients user-mail-address)
6344 (message-options-set 'message-sign-encrypt 'not)
6346 (goto-char (point-min))
6347 (insert "MIME-Version: 1.0\n")
6349 (gnus-summary-edit-article-done
6350 references nil summary-buffer t))
6351 (when gnus-keep-backlog
6352 (gnus-backlog-remove-article
6353 (car gnus-article-current) (cdr gnus-article-current)))
6355 (when (get-buffer gnus-original-article-buffer)
6356 (set-buffer gnus-original-article-buffer)
6357 (setq gnus-original-article nil)))
6358 (when gnus-use-cache
6359 (gnus-cache-update-article
6360 (car gnus-article-current) (cdr gnus-article-current))))))))
6362 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6363 "The following specs can be used:
6364 %t The security MIME type
6367 %D Details if button is pressed")
6369 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6370 "The following specs can be used:
6371 %t The security MIME type
6374 %D Details if button is pressed")
6376 (defvar gnus-mime-security-button-line-format-alist
6377 '((?t gnus-tmp-type ?s)
6378 (?i gnus-tmp-info ?s)
6379 (?d gnus-tmp-details ?s)
6380 (?D gnus-tmp-pressed-details ?s)))
6382 (defvar gnus-mime-security-button-map
6383 (let ((map (make-sparse-keymap)))
6384 (unless (>= (string-to-number emacs-version) 21)
6385 (set-keymap-parent map gnus-article-mode-map))
6386 (define-key map gnus-mouse-2 'gnus-article-push-button)
6387 (define-key map "\r" 'gnus-article-press-button)
6390 (defvar gnus-mime-security-details-buffer nil)
6392 (defvar gnus-mime-security-button-pressed nil)
6394 (defvar gnus-mime-security-show-details-inline t
6395 "If non-nil, show details in the article buffer.")
6397 (defun gnus-mime-security-verify-or-decrypt (handle)
6398 (mm-remove-parts (cdr handle))
6399 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6400 point buffer-read-only)
6402 (goto-char (car region)))
6404 (narrow-to-region (point) (point))
6405 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6406 (let* ((mm-verify-option 'known)
6407 (mm-decrypt-option 'known)
6408 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6409 (unless (eq nparts (cdr handle))
6410 (mm-destroy-parts (cdr handle))
6411 (setcdr handle nparts))))
6412 (setq point (point))
6413 (gnus-mime-display-security handle)
6414 (goto-char (point-max)))
6416 (delete-region (point) (cdr region))
6417 (set-marker (car region) nil)
6418 (set-marker (cdr region) nil))
6421 (defun gnus-mime-security-show-details (handle)
6422 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6424 (gnus-message 5 "No details.")
6425 (if gnus-mime-security-show-details-inline
6426 (let ((gnus-mime-security-button-pressed
6427 (not (get-text-property (point) 'gnus-mime-details)))
6428 (gnus-mime-security-button-line-format
6429 (get-text-property (point) 'gnus-line-format))
6432 (while (eq (get-text-property (point) 'gnus-line-format)
6433 gnus-mime-security-button-line-format)
6437 (narrow-to-region (point) (point))
6438 (gnus-insert-mime-security-button handle))
6439 (delete-region (point)
6440 (or (text-property-not-all
6443 gnus-mime-security-button-line-format)
6446 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6447 (with-current-buffer gnus-mime-security-details-buffer
6450 (setq gnus-mime-security-details-buffer
6451 (gnus-get-buffer-create "*MIME Security Details*")))
6452 (with-current-buffer gnus-mime-security-details-buffer
6454 (goto-char (point-min)))
6455 (pop-to-buffer gnus-mime-security-details-buffer)))))
6457 (defun gnus-mime-security-press-button (handle)
6459 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6460 (gnus-mime-security-show-details handle)
6461 (gnus-mime-security-verify-or-decrypt handle))))
6463 (defun gnus-insert-mime-security-button (handle &optional displayed)
6464 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6467 (or (nth 2 (assoc protocol mm-verify-function-alist))
6468 (nth 2 (assoc protocol mm-decrypt-function-alist))
6470 (if (equal (car handle) "multipart/signed")
6471 " Signed" " Encrypted")
6474 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6477 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6478 gnus-tmp-pressed-details
6480 (setq gnus-tmp-details
6481 (if gnus-tmp-details
6482 (concat "\n" gnus-tmp-details)
6484 (setq gnus-tmp-pressed-details
6485 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6490 gnus-mime-security-button-line-format
6491 gnus-mime-security-button-line-format-alist
6492 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6493 gnus-callback gnus-mime-security-press-button
6494 gnus-line-format ,gnus-mime-security-button-line-format
6495 gnus-mime-details ,gnus-mime-security-button-pressed
6496 article-type annotation
6499 (widget-convert-button
6502 :action 'gnus-widget-press-button
6503 :button-keymap gnus-mime-security-button-map
6505 (lambda (widget/window &optional overlay pos)
6506 ;; Needed to properly clear the message due to a bug in
6507 ;; wid-edit (XEmacs only).
6508 (when (boundp 'help-echo-owns-message)
6509 (setq help-echo-owns-message t))
6512 (aref gnus-mouse-2 0))))))
6514 (defun gnus-mime-display-security (handle)
6516 (narrow-to-region (point) (point))
6517 (unless (gnus-unbuttonized-mime-type-p (car handle))
6518 (gnus-insert-mime-security-button handle))
6519 (gnus-mime-display-mixed (cdr handle))
6522 (unless (gnus-unbuttonized-mime-type-p (car handle))
6523 (let ((gnus-mime-security-button-line-format
6524 gnus-mime-security-button-end-line-format))
6525 (gnus-insert-mime-security-button handle)))
6526 (mm-set-handle-multipart-parameter
6528 (cons (set-marker (make-marker) (point-min))
6529 (set-marker (make-marker) (point-max))))))
6535 (run-hooks 'gnus-art-load-hook)
6537 ;;; gnus-art.el ends here