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-article-skip-boring nil
204 "Skip over text that is not worth reading.
205 By default, if you set this t, then Gnus will display citations and
206 signatures, but will never scroll down to show you a page consisting
207 only of boring text. Boring text is controlled by
208 `gnus-article-boring-faces'."
210 :group 'gnus-article-hiding)
212 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
213 "Regexp matching signature separator.
214 This can also be a list of regexps. In that case, it will be checked
215 from head to tail looking for a separator. Searches will be done from
216 the end of the buffer."
217 :type '(repeat string)
218 :group 'gnus-article-signature)
220 (defcustom gnus-signature-limit nil
221 "Provide a limit to what is considered a signature.
222 If it is a number, no signature may not be longer (in characters) than
223 that number. If it is a floating point number, no signature may be
224 longer (in lines) than that number. If it is a function, the function
225 will be called without any parameters, and if it returns nil, there is
226 no signature in the buffer. If it is a string, it will be used as a
227 regexp. If it matches, the text in question is not a signature."
228 :type '(choice (integer :value 200)
230 (function :value fun)
231 (regexp :value ".*"))
232 :group 'gnus-article-signature)
234 (defcustom gnus-hidden-properties '(invisible t intangible t)
235 "Property list to use for hiding text."
237 :group 'gnus-article-hiding)
239 ;; Fixme: This isn't the right thing for mixed graphical and and
240 ;; non-graphical frames in a session.
241 (defcustom gnus-article-x-face-command
242 (if (featurep 'xemacs)
243 (if (or (gnus-image-type-available-p 'xface)
244 (gnus-image-type-available-p 'pbm))
245 'gnus-display-x-face-in-from
246 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
247 (if (gnus-image-type-available-p 'pbm)
248 'gnus-display-x-face-in-from
249 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
251 "*String or function to be executed to display an X-Face header.
252 If it is a string, the command will be executed in a sub-shell
253 asynchronously. The compressed face will be piped to this command."
254 :type `(choice string
255 (function-item gnus-display-x-face-in-from)
259 :group 'gnus-article-washing)
261 (defcustom gnus-article-x-face-too-ugly nil
262 "Regexp matching posters whose face shouldn't be shown automatically."
263 :type '(choice regexp (const nil))
264 :group 'gnus-article-washing)
266 (defcustom gnus-article-banner-alist nil
267 "Banner alist for stripping.
269 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
271 :type '(repeat (cons symbol regexp))
272 :group 'gnus-article-washing)
274 (gnus-define-group-parameter
277 "Alist of regexps (to match group names) and banner."
278 :variable-group gnus-article-washing
280 '(choice :tag "Banner"
282 (const :tag "Remove signature" signature)
283 (symbol :tag "Item in `gnus-article-banner-alist'" none)
285 (const :tag "None" nil))
287 "If non-nil, specify how to remove `banners' from articles.
289 Symbol `signature' means to remove signatures delimited by
290 `gnus-signature-separator'. Any other symbol is used to look up a
291 regular expression to match the banner in `gnus-article-banner-alist'.
292 A string is used as a regular expression to match the banner
295 (defcustom gnus-article-address-banner-alist nil
296 "Alist of mail addresses and banners.
297 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
298 to match a mail address in the From: header, BANNER is one of a symbol
299 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
300 If ADDRESS matches author's mail address, it will remove things like
301 advertisements. For example:
303 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
307 (regexp :tag "Address")
308 (choice :tag "Banner" :value nil
309 (const :tag "Remove signature" signature)
310 (symbol :tag "Item in `gnus-article-banner-alist'" none)
312 (const :tag "None" nil))))
313 :group 'gnus-article-washing)
315 (defcustom gnus-emphasis-alist
317 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
322 ("_/" "/_" underline-italic)
323 ("_\\*" "\\*_" underline-bold)
324 ("\\*/" "/\\*" bold-italic)
325 ("_\\*/" "/\\*_" underline-bold-italic))))
329 (format format (car spec) (cadr spec))
330 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
332 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
333 2 3 gnus-emphasis-strikethru)
334 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
335 2 3 gnus-emphasis-underline)))
336 "*Alist that says how to fontify certain phrases.
337 Each item looks like this:
339 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
341 The first element is a regular expression to be matched. The second
342 is a number that says what regular expression grouping used to find
343 the entire emphasized word. The third is a number that says what
344 regexp grouping should be displayed and highlighted. The fourth
345 is the face used for highlighting."
346 :type '(repeat (list :value ("" 0 0 default)
348 (integer :tag "Match group")
349 (integer :tag "Emphasize group")
351 :group 'gnus-article-emphasis)
353 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
354 "A regexp to describe whitespace which should not be emphasized.
355 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
356 The former avoids underlining of leading and trailing whitespace,
357 and the latter avoids underlining any whitespace at all."
359 :group 'gnus-article-emphasis
362 (defface gnus-emphasis-bold '((t (:bold t)))
363 "Face used for displaying strong emphasized text (*word*)."
364 :group 'gnus-article-emphasis)
366 (defface gnus-emphasis-italic '((t (:italic t)))
367 "Face used for displaying italic emphasized text (/word/)."
368 :group 'gnus-article-emphasis)
370 (defface gnus-emphasis-underline '((t (:underline t)))
371 "Face used for displaying underlined emphasized text (_word_)."
372 :group 'gnus-article-emphasis)
374 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
375 "Face used for displaying underlined bold emphasized text (_*word*_)."
376 :group 'gnus-article-emphasis)
378 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
379 "Face used for displaying underlined italic emphasized text (_/word/_)."
380 :group 'gnus-article-emphasis)
382 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
383 "Face used for displaying bold italic emphasized text (/*word*/)."
384 :group 'gnus-article-emphasis)
386 (defface gnus-emphasis-underline-bold-italic
387 '((t (:bold t :italic t :underline t)))
388 "Face used for displaying underlined bold italic emphasized text.
389 Example: (_/*word*/_)."
390 :group 'gnus-article-emphasis)
392 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
393 "Face used for displaying strike-through text (-word-)."
394 :group 'gnus-article-emphasis)
396 (defface gnus-emphasis-highlight-words
397 '((t (:background "black" :foreground "yellow")))
398 "Face used for displaying highlighted words."
399 :group 'gnus-article-emphasis)
401 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
402 "Format for display of Date headers in article bodies.
403 See `format-time-string' for the possible values.
405 The variable can also be function, which should return a complete Date
406 header. The function is called with one argument, the time, which can
407 be fed to `format-time-string'."
408 :type '(choice string symbol)
409 :link '(custom-manual "(gnus)Article Date")
410 :group 'gnus-article-washing)
413 (autoload 'mail-extract-address-components "mail-extr"))
415 (defcustom gnus-save-all-headers t
416 "*If non-nil, don't remove any headers before saving."
417 :group 'gnus-article-saving
420 (defcustom gnus-prompt-before-saving 'always
421 "*This variable says how much prompting is to be done when saving articles.
422 If it is nil, no prompting will be done, and the articles will be
423 saved to the default files. If this variable is `always', each and
424 every article that is saved will be preceded by a prompt, even when
425 saving large batches of articles. If this variable is neither nil not
426 `always', there the user will be prompted once for a file name for
427 each invocation of the saving commands."
428 :group 'gnus-article-saving
429 :type '(choice (item always)
430 (item :tag "never" nil)
431 (sexp :tag "once" :format "%t\n" :value t)))
433 (defcustom gnus-saved-headers gnus-visible-headers
434 "Headers to keep if `gnus-save-all-headers' is nil.
435 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
436 If that variable is nil, however, all headers that match this regexp
437 will be kept while the rest will be deleted before saving."
438 :group 'gnus-article-saving
441 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
442 "A function to save articles in your favourite format.
443 The function must be interactively callable (in other words, it must
444 be an Emacs command).
446 Gnus provides the following functions:
448 * gnus-summary-save-in-rmail (Rmail format)
449 * gnus-summary-save-in-mail (Unix mail format)
450 * gnus-summary-save-in-folder (MH folder)
451 * gnus-summary-save-in-file (article format)
452 * gnus-summary-save-body-in-file (article body)
453 * gnus-summary-save-in-vm (use VM's folder format)
454 * gnus-summary-write-to-file (article format -- overwrite)."
455 :group 'gnus-article-saving
456 :type '(radio (function-item gnus-summary-save-in-rmail)
457 (function-item gnus-summary-save-in-mail)
458 (function-item gnus-summary-save-in-folder)
459 (function-item gnus-summary-save-in-file)
460 (function-item gnus-summary-save-body-in-file)
461 (function-item gnus-summary-save-in-vm)
462 (function-item gnus-summary-write-to-file)))
464 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
465 "A function generating a file name to save articles in Rmail format.
466 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
467 :group 'gnus-article-saving
470 (defcustom gnus-mail-save-name 'gnus-plain-save-name
471 "A function generating a file name to save articles in Unix mail format.
472 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
473 :group 'gnus-article-saving
476 (defcustom gnus-folder-save-name 'gnus-folder-save-name
477 "A function generating a file name to save articles in MH folder.
478 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
479 :group 'gnus-article-saving
482 (defcustom gnus-file-save-name 'gnus-numeric-save-name
483 "A function generating a file name to save articles in article format.
484 The function is called with NEWSGROUP, HEADERS, and optional
486 :group 'gnus-article-saving
489 (defcustom gnus-split-methods
490 '((gnus-article-archive-name)
491 (gnus-article-nndoc-name))
492 "*Variable used to suggest where articles are to be saved.
493 For instance, if you would like to save articles related to Gnus in
494 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
495 you could set this variable to something like:
497 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
498 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
500 This variable is an alist where the where the key is the match and the
501 value is a list of possible files to save in if the match is non-nil.
503 If the match is a string, it is used as a regexp match on the
504 article. If the match is a symbol, that symbol will be funcalled
505 from the buffer of the article to be saved with the newsgroup as the
506 parameter. If it is a list, it will be evaled in the same buffer.
508 If this form or function returns a string, this string will be used as
509 a possible file name; and if it returns a non-nil list, that list will
510 be used as possible file names."
511 :group 'gnus-article-saving
512 :type '(repeat (choice (list :value (fun) function)
513 (cons :value ("" "") regexp (repeat string))
516 (defcustom gnus-page-delimiter "^\^L"
517 "*Regexp describing what to use as article page delimiters.
518 The default value is \"^\^L\", which is a form linefeed at the
519 beginning of a line."
521 :group 'gnus-article-various)
523 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
524 "*The format specification for the article mode line.
525 See `gnus-summary-mode-line-format' for a closer description.
527 The following additional specs are available:
529 %w The article washing status.
530 %m The number of MIME parts in the article."
532 :group 'gnus-article-various)
534 (defcustom gnus-article-mode-hook nil
535 "*A hook for Gnus article mode."
537 :group 'gnus-article-various)
539 (when (featurep 'xemacs)
540 ;; Extracted from gnus-xmas-define in order to preserve user settings
541 (when (fboundp 'turn-off-scroll-in-place)
542 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
543 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
544 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
546 (defcustom gnus-article-menu-hook nil
547 "*Hook run after the creation of the article mode menu."
549 :group 'gnus-article-various)
551 (defcustom gnus-article-prepare-hook nil
552 "*A hook called after an article has been prepared in the article buffer."
554 :group 'gnus-article-various)
556 (defvar gnus-article-hide-pgp-hook nil)
557 (make-obsolete-variable 'gnus-article-hide-pgp-hook
558 "This variable is obsolete in Gnus 5.10.")
560 (defcustom gnus-article-button-face 'bold
561 "Face used for highlighting buttons in the article buffer.
563 An article button is a piece of text that you can activate by pressing
564 `RET' or `mouse-2' above it."
566 :group 'gnus-article-buttons)
568 (defcustom gnus-article-mouse-face 'highlight
569 "Face used for mouse highlighting in the article buffer.
571 Article buttons will be displayed in this face when the cursor is
574 :group 'gnus-article-buttons)
576 (defcustom gnus-signature-face 'gnus-signature-face
577 "Face used for highlighting a signature in the article buffer.
578 Obsolete; use the face `gnus-signature-face' for customizations instead."
580 :group 'gnus-article-highlight
581 :group 'gnus-article-signature)
583 (defface gnus-signature-face
586 "Face used for highlighting a signature in the article buffer."
587 :group 'gnus-article-highlight
588 :group 'gnus-article-signature)
590 (defface gnus-header-from-face
593 (:foreground "spring green"))
596 (:foreground "red3"))
599 "Face used for displaying from headers."
600 :group 'gnus-article-headers
601 :group 'gnus-article-highlight)
603 (defface gnus-header-subject-face
606 (:foreground "SeaGreen3"))
609 (:foreground "red4"))
611 (:bold t :italic t)))
612 "Face used for displaying subject headers."
613 :group 'gnus-article-headers
614 :group 'gnus-article-highlight)
616 (defface gnus-header-newsgroups-face
619 (:foreground "yellow" :italic t))
622 (:foreground "MidnightBlue" :italic t))
625 "Face used for displaying newsgroups headers."
626 :group 'gnus-article-headers
627 :group 'gnus-article-highlight)
629 (defface gnus-header-name-face
632 (:foreground "SeaGreen"))
635 (:foreground "maroon"))
638 "Face used for displaying header names."
639 :group 'gnus-article-headers
640 :group 'gnus-article-highlight)
642 (defface gnus-header-content-face
645 (:foreground "forest green" :italic t))
648 (:foreground "indianred4" :italic t))
650 (:italic t))) "Face used for displaying header content."
651 :group 'gnus-article-headers
652 :group 'gnus-article-highlight)
654 (defcustom gnus-header-face-alist
655 '(("From" nil gnus-header-from-face)
656 ("Subject" nil gnus-header-subject-face)
657 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
658 ("" gnus-header-name-face gnus-header-content-face))
659 "*Controls highlighting of article header.
661 An alist of the form (HEADER NAME CONTENT).
663 HEADER is a regular expression which should match the name of an
664 header header and NAME and CONTENT are either face names or nil.
666 The name of each header field will be displayed using the face
667 specified by the first element in the list where HEADER match the
668 header name and NAME is non-nil. Similarly, the content will be
669 displayed by the first non-nil matching CONTENT face."
670 :group 'gnus-article-headers
671 :group 'gnus-article-highlight
672 :type '(repeat (list (regexp :tag "Header")
674 (item :tag "skip" nil)
675 (face :value default))
676 (choice :tag "Content"
677 (item :tag "skip" nil)
678 (face :value default)))))
680 (defcustom gnus-article-decode-hook
681 '(article-decode-charset article-decode-encoded-words
682 article-decode-group-name)
683 "*Hook run to decode charsets in articles."
684 :group 'gnus-article-headers
687 (defcustom gnus-display-mime-function 'gnus-display-mime
688 "Function to display MIME articles."
689 :group 'gnus-article-mime
692 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
693 "Function used to decode headers.")
695 (defvar gnus-article-dumbquotes-map
715 "Table for MS-to-Latin1 translation.")
717 (defcustom gnus-ignored-mime-types nil
718 "List of MIME types that should be ignored by Gnus."
720 :group 'gnus-article-mime
721 :type '(repeat regexp))
723 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
724 "List of MIME types that should not be given buttons when rendered inline.
725 See also `gnus-buttonized-mime-types' which may override this variable.
726 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
728 :group 'gnus-article-mime
729 :type '(repeat regexp))
731 (defcustom gnus-buttonized-mime-types nil
732 "List of MIME types that should be given buttons when rendered inline.
733 If set, this variable overrides `gnus-unbuttonized-mime-types'.
734 To see e.g. security buttons you could set this to
735 `(\"multipart/signed\")'.
736 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
738 :group 'gnus-article-mime
739 :type '(repeat regexp))
741 (defcustom gnus-inhibit-mime-unbuttonizing nil
742 "If non-nil, all MIME parts get buttons.
743 When nil (the default value), then some MIME parts do not get buttons,
744 as described by the variables `gnus-buttonized-mime-types' and
745 `gnus-unbuttonized-mime-types'."
749 (defcustom gnus-body-boundary-delimiter "_"
750 "String used to delimit header and body.
751 This variable is used by `gnus-article-treat-body-boundary' which can
752 be controlled by `gnus-treat-body-boundary'."
753 :group 'gnus-article-various
754 :type '(choice (item :tag "None" :value nil)
757 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
758 "Defines the location of the faces database.
759 For information on obtaining this database of pretty pictures, please
760 see http://www.cs.indiana.edu/picons/ftp/index.html"
761 :type '(repeat directory)
762 :link '(url-link :tag "download"
763 "http://www.cs.indiana.edu/picons/ftp/index.html")
764 :link '(custom-manual "(gnus)Picons")
767 (defun gnus-picons-installed-p ()
768 "Say whether picons are installed on your machine."
769 (let ((installed nil))
770 (dolist (database gnus-picon-databases)
771 (when (file-exists-p database)
775 (defcustom gnus-article-mime-part-function nil
776 "Function called with a MIME handle as the argument.
777 This is meant for people who want to do something automatic based
778 on parts -- for instance, adding Vcard info to a database."
779 :group 'gnus-article-mime
782 (defcustom gnus-mime-multipart-functions nil
783 "An alist of MIME types to functions to display them."
785 :group 'gnus-article-mime
788 (defcustom gnus-article-date-lapsed-new-header nil
789 "Whether the X-Sent and Date headers can coexist.
790 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
791 either replace the old \"Date:\" header (if this variable is nil), or
792 be added below it (otherwise)."
794 :group 'gnus-article-headers
797 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
798 "Function called with a MIME handle as the argument.
799 This is meant for people who want to view first matched part.
800 For `undisplayed-alternative' (default), the first undisplayed
801 part or alternative part is used. For `undisplayed', the first
802 undisplayed part is used. For a function, the first part which
803 the function return t is used. For nil, the first part is
806 :group 'gnus-article-mime
808 (item :tag "first" :value nil)
809 (item :tag "undisplayed" :value undisplayed)
810 (item :tag "undisplayed or alternative"
811 :value undisplayed-alternative)
814 (defcustom gnus-mime-action-alist
815 '(("save to file" . gnus-mime-save-part)
816 ("save and strip" . gnus-mime-save-part-and-strip)
817 ("display as text" . gnus-mime-inline-part)
818 ("view the part" . gnus-mime-view-part)
819 ("pipe to command" . gnus-mime-pipe-part)
820 ("toggle display" . gnus-article-press-button)
821 ("toggle display" . gnus-article-view-part-as-charset)
822 ("view as type" . gnus-mime-view-part-as-type)
823 ("view internally" . gnus-mime-view-part-internally)
824 ("view externally" . gnus-mime-view-part-externally))
825 "An alist of actions that run on the MIME attachment."
826 :group 'gnus-article-mime
827 :type '(repeat (cons (string :tag "name")
831 ;;; The treatment variables
834 (defvar gnus-part-display-hook nil
835 "Hook called on parts that are to receive treatment.")
837 (defvar gnus-article-treat-custom
838 '(choice (const :tag "Off" nil)
840 (const :tag "Header" head)
841 (const :tag "Last" last)
842 (integer :tag "Less")
843 (repeat :tag "Groups" regexp)
844 (sexp :tag "Predicate")))
846 (defvar gnus-article-treat-head-custom
847 '(choice (const :tag "Off" nil)
848 (const :tag "Header" head)))
850 (defvar gnus-article-treat-types '("text/plain")
853 (defvar gnus-inhibit-treatment nil
854 "Whether to inhibit treatment.")
856 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
857 "Highlight the signature.
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-highlight-signature 'highlight t)
865 (defcustom gnus-treat-buttonize 100000
867 Valid values are nil, t, `head', `last', an integer or a predicate.
868 See Info node `(gnus)Customizing Articles'."
869 :group 'gnus-article-treat
870 :link '(custom-manual "(gnus)Customizing Articles")
871 :type gnus-article-treat-custom)
872 (put 'gnus-treat-buttonize 'highlight t)
874 (defcustom gnus-treat-buttonize-head 'head
875 "Add buttons to the head.
876 Valid values are nil, t, `head', `last', an integer or a predicate.
877 See Info node `(gnus)Customizing Articles' for details."
878 :group 'gnus-article-treat
879 :link '(custom-manual "(gnus)Customizing Articles")
880 :type gnus-article-treat-head-custom)
881 (put 'gnus-treat-buttonize-head 'highlight t)
883 (defcustom gnus-treat-emphasize
884 (and (or window-system
886 (>= (string-to-number emacs-version) 21))
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)
894 (put 'gnus-treat-emphasize 'highlight t)
896 (defcustom gnus-treat-strip-cr nil
897 "Remove carriage returns.
898 Valid values are nil, t, `head', `last', an integer or a predicate.
899 See Info node `(gnus)Customizing Articles' for details."
900 :group 'gnus-article-treat
901 :link '(custom-manual "(gnus)Customizing Articles")
902 :type gnus-article-treat-custom)
904 (defcustom gnus-treat-unsplit-urls nil
905 "Remove newlines from within URLs.
906 Valid values are nil, t, `head', `last', an integer or a predicate.
907 See Info node `(gnus)Customizing Articles' for details."
908 :group 'gnus-article-treat
909 :link '(custom-manual "(gnus)Customizing Articles")
910 :type gnus-article-treat-custom)
912 (defcustom gnus-treat-leading-whitespace nil
913 "Remove leading whitespace in headers.
914 Valid values are nil, t, `head', `last', an integer or a predicate.
915 See Info node `(gnus)Customizing Articles' for details."
916 :group 'gnus-article-treat
917 :link '(custom-manual "(gnus)Customizing Articles")
918 :type gnus-article-treat-custom)
920 (defcustom gnus-treat-hide-headers 'head
922 Valid values are nil, t, `head', `last', an integer or a predicate.
923 See Info node `(gnus)Customizing Articles' for details."
924 :group 'gnus-article-treat
925 :link '(custom-manual "(gnus)Customizing Articles")
926 :type gnus-article-treat-head-custom)
928 (defcustom gnus-treat-hide-boring-headers nil
929 "Hide boring headers.
930 Valid values are nil, t, `head', `last', an integer or a predicate.
931 See Info node `(gnus)Customizing Articles' for details."
932 :group 'gnus-article-treat
933 :link '(custom-manual "(gnus)Customizing Articles")
934 :type gnus-article-treat-head-custom)
936 (defcustom gnus-treat-hide-signature nil
938 Valid values are nil, t, `head', `last', an integer or a predicate.
939 See Info node `(gnus)Customizing Articles' for details."
940 :group 'gnus-article-treat
941 :link '(custom-manual "(gnus)Customizing Articles")
942 :type gnus-article-treat-custom)
944 (defcustom gnus-treat-fill-article nil
946 Valid values are nil, t, `head', `last', an integer or a predicate.
947 See Info node `(gnus)Customizing Articles' for details."
948 :group 'gnus-article-treat
949 :link '(custom-manual "(gnus)Customizing Articles")
950 :type gnus-article-treat-custom)
952 (defcustom gnus-treat-hide-citation nil
954 Valid values are nil, t, `head', `last', an integer or a predicate.
955 See Info node `(gnus)Customizing Articles' for details."
956 :group 'gnus-article-treat
957 :link '(custom-manual "(gnus)Customizing Articles")
958 :type gnus-article-treat-custom)
960 (defcustom gnus-treat-hide-citation-maybe nil
962 Valid values are nil, t, `head', `last', an integer or a predicate.
963 See Info node `(gnus)Customizing Articles' for details."
964 :group 'gnus-article-treat
965 :link '(custom-manual "(gnus)Customizing Articles")
966 :type gnus-article-treat-custom)
968 (defcustom gnus-treat-strip-list-identifiers 'head
969 "Strip list identifiers from `gnus-list-identifiers`.
970 Valid values are nil, t, `head', `last', an integer or a predicate.
971 See Info node `(gnus)Customizing Articles' for details."
973 :group 'gnus-article-treat
974 :link '(custom-manual "(gnus)Customizing Articles")
975 :type gnus-article-treat-custom)
977 (make-obsolete-variable 'gnus-treat-strip-pgp
978 "This option is obsolete in Gnus 5.10.")
980 (defcustom gnus-treat-strip-pem nil
981 "Strip PEM signatures.
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-strip-banner t
989 "Strip banners from articles.
990 The banner to be stripped is specified in the `banner' group parameter.
991 Valid values are nil, t, `head', `last', an integer or a predicate.
992 See Info node `(gnus)Customizing Articles' for details."
993 :group 'gnus-article-treat
994 :link '(custom-manual "(gnus)Customizing Articles")
995 :type gnus-article-treat-custom)
997 (defcustom gnus-treat-highlight-headers 'head
998 "Highlight the headers.
999 Valid values are nil, t, `head', `last', an integer or a predicate.
1000 See Info node `(gnus)Customizing Articles' for details."
1001 :group 'gnus-article-treat
1002 :link '(custom-manual "(gnus)Customizing Articles")
1003 :type gnus-article-treat-head-custom)
1004 (put 'gnus-treat-highlight-headers 'highlight t)
1006 (defcustom gnus-treat-highlight-citation t
1007 "Highlight cited text.
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-custom)
1013 (put 'gnus-treat-highlight-citation 'highlight t)
1015 (defcustom gnus-treat-date-ut nil
1016 "Display the Date in UT (GMT).
1017 Valid values are nil, t, `head', `last', an integer or a predicate.
1018 See Info node `(gnus)Customizing Articles' for details."
1019 :group 'gnus-article-treat
1020 :link '(custom-manual "(gnus)Customizing Articles")
1021 :type gnus-article-treat-head-custom)
1023 (defcustom gnus-treat-date-local nil
1024 "Display the Date in the local timezone.
1025 Valid values are nil, t, `head', `last', an integer or a predicate.
1026 See Info node `(gnus)Customizing Articles' for details."
1027 :group 'gnus-article-treat
1028 :link '(custom-manual "(gnus)Customizing Articles")
1029 :type gnus-article-treat-head-custom)
1031 (defcustom gnus-treat-date-english nil
1032 "Display the Date in a format that can be read aloud in English.
1033 Valid values are nil, t, `head', `last', an integer or a predicate.
1034 See Info node `(gnus)Customizing Articles' for details."
1035 :group 'gnus-article-treat
1036 :link '(custom-manual "(gnus)Customizing Articles")
1037 :type gnus-article-treat-head-custom)
1039 (defcustom gnus-treat-date-lapsed nil
1040 "Display the Date header in a way that says how much time has elapsed.
1041 Valid values are nil, t, `head', `last', an integer or a predicate.
1042 See Info node `(gnus)Customizing Articles' for details."
1043 :group 'gnus-article-treat
1044 :link '(custom-manual "(gnus)Customizing Articles")
1045 :type gnus-article-treat-head-custom)
1047 (defcustom gnus-treat-date-original nil
1048 "Display the date in the original timezone.
1049 Valid values are nil, t, `head', `last', an integer or a predicate.
1050 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-iso8601 nil
1056 "Display the date in the ISO8601 format.
1057 Valid values are nil, t, `head', `last', an integer or a predicate.
1058 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-date-user-defined nil
1065 "Display the date in a user-defined format.
1066 The format is defined by the `gnus-article-time-format' variable.
1067 Valid values are nil, t, `head', `last', an integer or a predicate.
1068 See Info node `(gnus)Customizing Articles' for details."
1069 :group 'gnus-article-treat
1070 :link '(custom-manual "(gnus)Customizing Articles")
1071 :type gnus-article-treat-head-custom)
1073 (defcustom gnus-treat-strip-headers-in-body t
1074 "Strip the X-No-Archive header line from the beginning of the body.
1075 Valid values are nil, t, `head', `last', an integer or a predicate.
1076 See Info node `(gnus)Customizing Articles' for details."
1078 :group 'gnus-article-treat
1079 :link '(custom-manual "(gnus)Customizing Articles")
1080 :type gnus-article-treat-custom)
1082 (defcustom gnus-treat-strip-trailing-blank-lines nil
1083 "Strip trailing blank lines.
1084 Valid values are nil, t, `head', `last', an integer or a predicate.
1085 See Info node `(gnus)Customizing Articles' for details."
1086 :group 'gnus-article-treat
1087 :link '(custom-manual "(gnus)Customizing Articles")
1088 :type gnus-article-treat-custom)
1090 (defcustom gnus-treat-strip-leading-blank-lines nil
1091 "Strip leading blank lines.
1092 Valid values are nil, t, `head', `last', an integer or a predicate.
1093 See Info node `(gnus)Customizing Articles' for details."
1094 :group 'gnus-article-treat
1095 :link '(custom-manual "(gnus)Customizing Articles")
1096 :type gnus-article-treat-custom)
1098 (defcustom gnus-treat-strip-multiple-blank-lines nil
1099 "Strip multiple blank lines.
1100 Valid values are nil, t, `head', `last', an integer or a predicate.
1101 See Info node `(gnus)Customizing Articles' for details."
1102 :group 'gnus-article-treat
1103 :link '(custom-manual "(gnus)Customizing Articles")
1104 :type gnus-article-treat-custom)
1106 (defcustom gnus-treat-unfold-headers 'head
1107 "Unfold folded header lines.
1108 Valid values are nil, t, `head', `last', an integer or a predicate.
1109 See Info node `(gnus)Customizing Articles' for details."
1110 :group 'gnus-article-treat
1111 :link '(custom-manual "(gnus)Customizing Articles")
1112 :type gnus-article-treat-custom)
1114 (defcustom gnus-treat-fold-headers nil
1116 Valid values are nil, t, `head', `last', an integer or a predicate.
1117 See Info node `(gnus)Customizing Articles' for details."
1118 :group 'gnus-article-treat
1119 :link '(custom-manual "(gnus)Customizing Articles")
1120 :type gnus-article-treat-custom)
1122 (defcustom gnus-treat-fold-newsgroups 'head
1123 "Fold the Newsgroups and Followup-To headers.
1124 Valid values are nil, t, `head', `last', an integer or a predicate.
1125 See Info node `(gnus)Customizing Articles' for details."
1126 :group 'gnus-article-treat
1127 :link '(custom-manual "(gnus)Customizing Articles")
1128 :type gnus-article-treat-custom)
1130 (defcustom gnus-treat-overstrike t
1131 "Treat overstrike highlighting.
1132 Valid values are nil, t, `head', `last', an integer or a predicate.
1133 See Info node `(gnus)Customizing Articles' for details."
1134 :group 'gnus-article-treat
1135 :link '(custom-manual "(gnus)Customizing Articles")
1136 :type gnus-article-treat-custom)
1137 (put 'gnus-treat-overstrike 'highlight t)
1139 (defcustom gnus-treat-display-xface
1140 (and (not noninteractive)
1141 (or (and (fboundp 'image-type-available-p)
1142 (image-type-available-p 'xbm)
1143 (string-match "^0x" (shell-command-to-string "uncompface")))
1144 (and (featurep 'xemacs)
1147 "Display X-Face headers.
1148 Valid values are nil, t, `head', `last', an integer or a predicate.
1149 See Info node `(gnus)Customizing Articles' and Info node
1150 `(gnus)X-Face' for details."
1151 :group 'gnus-article-treat
1153 :link '(custom-manual "(gnus)Customizing Articles")
1154 :link '(custom-manual "(gnus)X-Face")
1155 :type gnus-article-treat-head-custom)
1156 (put 'gnus-treat-display-xface 'highlight t)
1158 (defcustom gnus-treat-display-face
1159 (and (not noninteractive)
1160 (or (and (fboundp 'image-type-available-p)
1161 (image-type-available-p 'png))
1162 (and (featurep 'xemacs)
1165 "Display Face headers.
1166 Valid values are nil, t, `head', `last', an integer or a predicate.
1167 See Info node `(gnus)Customizing Articles' and Info node
1168 `(gnus)X-Face' for details."
1169 :group 'gnus-article-treat
1171 :link '(custom-manual "(gnus)Customizing Articles")
1172 :link '(custom-manual "(gnus)X-Face")
1173 :type gnus-article-treat-head-custom)
1174 (put 'gnus-treat-display-xface 'highlight t)
1176 (defcustom gnus-treat-display-smileys
1177 (if (or (and (featurep 'xemacs)
1179 (and (fboundp 'image-type-available-p)
1180 (image-type-available-p 'pbm)))
1183 Valid values are nil, t, `head', `last', an integer or a predicate.
1184 See Info node `(gnus)Customizing Articles' and Info node
1185 `(gnus)Smileys' for details."
1186 :group 'gnus-article-treat
1188 :link '(custom-manual "(gnus)Customizing Articles")
1189 :link '(custom-manual "(gnus)Smileys")
1190 :type gnus-article-treat-custom)
1191 (put 'gnus-treat-display-smileys 'highlight t)
1193 (defcustom gnus-treat-from-picon
1194 (if (and (gnus-image-type-available-p 'xpm)
1195 (gnus-picons-installed-p))
1197 "Display picons in the From header.
1198 Valid values are nil, t, `head', `last', an integer or a predicate.
1199 See Info node `(gnus)Customizing Articles' and Info node
1200 `(gnus)Picons' for details."
1201 :group 'gnus-article-treat
1203 :link '(custom-manual "(gnus)Customizing Articles")
1204 :link '(custom-manual "(gnus)Picons")
1205 :type gnus-article-treat-head-custom)
1206 (put 'gnus-treat-from-picon 'highlight t)
1208 (defcustom gnus-treat-mail-picon
1209 (if (and (gnus-image-type-available-p 'xpm)
1210 (gnus-picons-installed-p))
1212 "Display picons in To and Cc headers.
1213 Valid values are nil, t, `head', `last', an integer or a predicate.
1214 See Info node `(gnus)Customizing Articles' and Info node
1215 `(gnus)Picons' for details."
1216 :group 'gnus-article-treat
1218 :link '(custom-manual "(gnus)Customizing Articles")
1219 :link '(custom-manual "(gnus)Picons")
1220 :type gnus-article-treat-head-custom)
1221 (put 'gnus-treat-mail-picon 'highlight t)
1223 (defcustom gnus-treat-newsgroups-picon
1224 (if (and (gnus-image-type-available-p 'xpm)
1225 (gnus-picons-installed-p))
1227 "Display picons in the Newsgroups and Followup-To headers.
1228 Valid values are nil, t, `head', `last', an integer or a predicate.
1229 See Info node `(gnus)Customizing Articles' and Info node
1230 `(gnus)Picons' for details."
1231 :group 'gnus-article-treat
1233 :link '(custom-manual "(gnus)Customizing Articles")
1234 :link '(custom-manual "(gnus)Picons")
1235 :type gnus-article-treat-head-custom)
1236 (put 'gnus-treat-newsgroups-picon 'highlight t)
1238 (defcustom gnus-treat-body-boundary
1239 (if (or gnus-treat-newsgroups-picon
1240 gnus-treat-mail-picon
1241 gnus-treat-from-picon)
1243 "Draw a boundary at the end of the headers.
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-capitalize-sentences nil
1252 "Capitalize sentence-starting words.
1253 Valid values are nil, t, `head', `last', an integer or a predicate.
1254 See Info node `(gnus)Customizing Articles' for details."
1256 :group 'gnus-article-treat
1257 :link '(custom-manual "(gnus)Customizing Articles")
1258 :type gnus-article-treat-custom)
1260 (defcustom gnus-treat-wash-html nil
1262 Valid values are nil, t, `head', `last', an integer or a predicate.
1263 See Info node `(gnus)Customizing Articles' for details."
1264 :group 'gnus-article-treat
1265 :link '(custom-manual "(gnus)Customizing Articles")
1266 :type gnus-article-treat-custom)
1268 (defcustom gnus-treat-fill-long-lines nil
1270 Valid values are nil, t, `head', `last', an integer or a predicate.
1271 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-play-sounds nil
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-translate nil
1286 "Translate articles from one language to another.
1287 Valid values are nil, t, `head', `last', an integer or a predicate.
1288 See Info node `(gnus)Customizing Articles' for details."
1290 :group 'gnus-article-treat
1291 :link '(custom-manual "(gnus)Customizing Articles")
1292 :type gnus-article-treat-custom)
1294 (defcustom gnus-treat-x-pgp-sig nil
1296 To automatically treat X-PGP-Sig, set it to head.
1297 Valid values are nil, t, `head', `last', an integer or a predicate.
1298 See Info node `(gnus)Customizing Articles' for details."
1299 :group 'gnus-article-treat
1300 :group 'mime-security
1301 :link '(custom-manual "(gnus)Customizing Articles")
1302 :type gnus-article-treat-custom)
1304 (defvar gnus-article-encrypt-protocol-alist
1305 '(("PGP" . mml2015-self-encrypt)))
1307 ;; Set to nil if more than one protocol added to
1308 ;; gnus-article-encrypt-protocol-alist.
1309 (defcustom gnus-article-encrypt-protocol "PGP"
1310 "The protocol used for encrypt articles.
1311 It is a string, such as \"PGP\". If nil, ask user."
1313 :group 'mime-security)
1315 (defvar gnus-article-wash-function nil
1316 "Function used for converting HTML into text.")
1318 ;;; Internal variables
1320 (defvar gnus-english-month-names
1321 '("January" "February" "March" "April" "May" "June" "July" "August"
1322 "September" "October" "November" "December"))
1324 (defvar article-goto-body-goes-to-point-min-p nil)
1325 (defvar gnus-article-wash-types nil)
1326 (defvar gnus-article-emphasis-alist nil)
1327 (defvar gnus-article-image-alist nil)
1329 (defvar gnus-article-mime-handle-alist-1 nil)
1330 (defvar gnus-treatment-function-alist
1331 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1332 (gnus-treat-strip-banner gnus-article-strip-banner)
1333 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1334 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1335 (gnus-treat-buttonize gnus-article-add-buttons)
1336 (gnus-treat-fill-article gnus-article-fill-cited-article)
1337 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1338 (gnus-treat-strip-cr gnus-article-remove-cr)
1339 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1340 (gnus-treat-date-ut gnus-article-date-ut)
1341 (gnus-treat-date-local gnus-article-date-local)
1342 (gnus-treat-date-english gnus-article-date-english)
1343 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1344 (gnus-treat-date-original gnus-article-date-original)
1345 (gnus-treat-date-user-defined gnus-article-date-user)
1346 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1347 (gnus-treat-display-xface gnus-article-display-x-face)
1348 (gnus-treat-display-face gnus-article-display-face)
1349 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1350 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1351 (gnus-treat-hide-signature gnus-article-hide-signature)
1352 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1353 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1354 (gnus-treat-strip-pem gnus-article-hide-pem)
1355 (gnus-treat-from-picon gnus-treat-from-picon)
1356 (gnus-treat-mail-picon gnus-treat-mail-picon)
1357 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1358 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1359 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1360 (gnus-treat-strip-trailing-blank-lines
1361 gnus-article-remove-trailing-blank-lines)
1362 (gnus-treat-strip-leading-blank-lines
1363 gnus-article-strip-leading-blank-lines)
1364 (gnus-treat-strip-multiple-blank-lines
1365 gnus-article-strip-multiple-blank-lines)
1366 (gnus-treat-overstrike gnus-article-treat-overstrike)
1367 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1368 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1369 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1370 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1371 (gnus-treat-display-smileys gnus-treat-smiley)
1372 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1373 (gnus-treat-wash-html gnus-article-wash-html)
1374 (gnus-treat-emphasize gnus-article-emphasize)
1375 (gnus-treat-hide-citation gnus-article-hide-citation)
1376 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1377 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1378 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1379 (gnus-treat-play-sounds gnus-earcon-display)))
1381 (defvar gnus-article-mime-handle-alist nil)
1382 (defvar article-lapsed-timer nil)
1383 (defvar gnus-article-current-summary nil)
1385 (defvar gnus-article-mode-syntax-table
1386 (let ((table (copy-syntax-table text-mode-syntax-table)))
1387 ;; This causes the citation match run O(2^n).
1388 ;; (modify-syntax-entry ?- "w" table)
1389 (modify-syntax-entry ?> ")<" table)
1390 (modify-syntax-entry ?< "(>" table)
1391 ;; make M-. in article buffers work for `foo' strings
1392 (modify-syntax-entry ?' " " table)
1393 (modify-syntax-entry ?` " " table)
1395 "Syntax table used in article mode buffers.
1396 Initialized from `text-mode-syntax-table.")
1398 (defvar gnus-save-article-buffer nil)
1400 (defvar gnus-article-mode-line-format-alist
1401 (nconc '((?w (gnus-article-wash-status) ?s)
1402 (?m (gnus-article-mime-part-status) ?s))
1403 gnus-summary-mode-line-format-alist))
1405 (defvar gnus-number-of-articles-to-be-saved nil)
1407 (defvar gnus-inhibit-hiding nil)
1409 ;;; Macros for dealing with the article buffer.
1411 (defmacro gnus-with-article-headers (&rest forms)
1413 (set-buffer gnus-article-buffer)
1415 (let ((buffer-read-only nil)
1416 (inhibit-point-motion-hooks t)
1417 (case-fold-search t))
1418 (article-narrow-to-head)
1421 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1422 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1424 (defmacro gnus-with-article-buffer (&rest forms)
1426 (set-buffer gnus-article-buffer)
1427 (let ((buffer-read-only nil))
1430 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1431 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1433 (defun gnus-article-goto-header (header)
1434 "Go to HEADER, which is a regular expression."
1435 (re-search-forward (concat "^\\(" header "\\):") nil t))
1437 (defsubst gnus-article-hide-text (b e props)
1438 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1439 (gnus-add-text-properties-when 'article-type nil b e props)
1440 (when (memq 'intangible props)
1442 (max (1- b) (point-min))
1443 b 'intangible (cddr (memq 'intangible props)))))
1445 (defsubst gnus-article-unhide-text (b e)
1446 "Remove hidden text properties from region between B and E."
1447 (remove-text-properties b e gnus-hidden-properties)
1448 (when (memq 'intangible gnus-hidden-properties)
1449 (put-text-property (max (1- b) (point-min))
1450 b 'intangible nil)))
1452 (defun gnus-article-hide-text-type (b e type)
1453 "Hide text of TYPE between B and E."
1454 (gnus-add-wash-type type)
1455 (gnus-article-hide-text
1456 b e (cons 'article-type (cons type gnus-hidden-properties))))
1458 (defun gnus-article-unhide-text-type (b e type)
1459 "Unhide text of TYPE between B and E."
1460 (gnus-delete-wash-type type)
1461 (remove-text-properties
1462 b e (cons 'article-type (cons type gnus-hidden-properties)))
1463 (when (memq 'intangible gnus-hidden-properties)
1464 (put-text-property (max (1- b) (point-min))
1465 b 'intangible nil)))
1467 (defun gnus-article-hide-text-of-type (type)
1468 "Hide text of TYPE in the current buffer."
1470 (let ((b (point-min))
1472 (while (setq b (text-property-any b e 'article-type type))
1473 (add-text-properties b (incf b) gnus-hidden-properties)))))
1475 (defun gnus-article-delete-text-of-type (type)
1476 "Delete text of TYPE in the current buffer."
1478 (let ((b (point-min)))
1479 (while (setq b (text-property-any b (point-max) 'article-type type))
1481 b (or (text-property-not-all b (point-max) 'article-type type)
1484 (defun gnus-article-delete-invisible-text ()
1485 "Delete all invisible text in the current buffer."
1487 (let ((b (point-min)))
1488 (while (setq b (text-property-any b (point-max) 'invisible t))
1490 b (or (text-property-not-all b (point-max) 'invisible t)
1493 (defun gnus-article-text-type-exists-p (type)
1494 "Say whether any text of type TYPE exists in the buffer."
1495 (text-property-any (point-min) (point-max) 'article-type type))
1497 (defsubst gnus-article-header-rank ()
1498 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1499 (let ((list gnus-sorted-header-list)
1502 (if (looking-at (car list))
1504 (setq list (cdr list))
1508 (defun article-hide-headers (&optional arg delete)
1509 "Hide unwanted headers and possibly sort them as well."
1511 ;; This function might be inhibited.
1512 (unless gnus-inhibit-hiding
1515 (let ((buffer-read-only nil)
1516 (case-fold-search t)
1517 (max (1+ (length gnus-sorted-header-list)))
1518 (ignored (when (not gnus-visible-headers)
1519 (cond ((stringp gnus-ignored-headers)
1520 gnus-ignored-headers)
1521 ((listp gnus-ignored-headers)
1522 (mapconcat 'identity gnus-ignored-headers
1525 (cond ((stringp gnus-visible-headers)
1526 gnus-visible-headers)
1527 ((and gnus-visible-headers
1528 (listp gnus-visible-headers))
1529 (mapconcat 'identity gnus-visible-headers "\\|"))))
1530 (inhibit-point-motion-hooks t)
1532 ;; First we narrow to just the headers.
1533 (article-narrow-to-head)
1534 ;; Hide any "From " lines at the beginning of (mail) articles.
1535 (while (looking-at "From ")
1538 (delete-region (point-min) (point)))
1539 ;; Then treat the rest of the header lines.
1540 ;; Then we use the two regular expressions
1541 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1542 ;; select which header lines is to remain visible in the
1544 (while (re-search-forward "^[^ \t:]*:" nil t)
1546 ;; Mark the rank of the header.
1548 (point) (1+ (point)) 'message-rank
1549 (if (or (and visible (looking-at visible))
1551 (not (looking-at ignored))))
1552 (gnus-article-header-rank)
1555 (message-sort-headers-1)
1556 (when (setq beg (text-property-any
1557 (point-min) (point-max) 'message-rank (+ 2 max)))
1558 ;; We delete the unwanted headers.
1559 (gnus-add-wash-type 'headers)
1560 (add-text-properties (point-min) (+ 5 (point-min))
1561 '(article-type headers dummy-invisible t))
1562 (delete-region beg (point-max))))))))
1564 (defun article-hide-boring-headers (&optional arg)
1565 "Toggle hiding of headers that aren't very interesting.
1566 If given a negative prefix, always show; if given a positive prefix,
1568 (interactive (gnus-article-hidden-arg))
1569 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1570 (not gnus-show-all-headers))
1573 (let ((buffer-read-only nil)
1574 (list gnus-boring-article-headers)
1575 (inhibit-point-motion-hooks t)
1577 (article-narrow-to-head)
1579 (setq elem (pop list))
1580 (goto-char (point-min))
1582 ;; Hide empty headers.
1584 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1586 (gnus-article-hide-text-type
1587 (progn (beginning-of-line) (point))
1590 (if (re-search-forward "^[^ \t]" nil t)
1594 ;; Hide boring Newsgroups header.
1595 ((eq elem 'newsgroups)
1596 (when (gnus-string-equal
1597 (gnus-fetch-field "newsgroups")
1598 (gnus-group-real-name
1599 (if (boundp 'gnus-newsgroup-name)
1602 (gnus-article-hide-header "newsgroups")))
1603 ((eq elem 'to-address)
1604 (let ((to (message-fetch-field "to"))
1606 (gnus-parameter-to-address
1607 (if (boundp 'gnus-newsgroup-name)
1608 gnus-newsgroup-name ""))))
1609 (when (and to to-address
1612 ;; only one address in To
1613 (nth 1 (mail-extract-address-components to))
1615 (gnus-article-hide-header "to"))))
1616 ((eq elem 'followup-to)
1617 (when (gnus-string-equal
1618 (message-fetch-field "followup-to")
1619 (message-fetch-field "newsgroups"))
1620 (gnus-article-hide-header "followup-to")))
1621 ((eq elem 'reply-to)
1622 (let ((from (message-fetch-field "from"))
1623 (reply-to (message-fetch-field "reply-to")))
1628 (nth 1 (mail-extract-address-components from))
1629 (nth 1 (mail-extract-address-components reply-to)))))
1630 (gnus-article-hide-header "reply-to"))))
1632 (let ((date (message-fetch-field "date")))
1634 (< (days-between (current-time-string) date)
1636 (gnus-article-hide-header "date"))))
1638 (let ((to (message-fetch-field "to"))
1639 (cc (message-fetch-field "cc")))
1640 (when (> (length to) 1024)
1641 (gnus-article-hide-header "to"))
1642 (when (> (length cc) 1024)
1643 (gnus-article-hide-header "cc"))))
1647 (goto-char (point-min))
1648 (while (re-search-forward "^to:" nil t)
1649 (setq to-count (1+ to-count)))
1650 (when (> to-count 1)
1651 (while (> to-count 0)
1652 (goto-char (point-min))
1654 (re-search-forward "^to:" nil nil to-count)
1656 (narrow-to-region (point) (point-max))
1657 (gnus-article-hide-header "to"))
1658 (setq to-count (1- to-count))))
1659 (goto-char (point-min))
1660 (while (re-search-forward "^cc:" nil t)
1661 (setq cc-count (1+ cc-count)))
1662 (when (> cc-count 1)
1663 (while (> cc-count 0)
1664 (goto-char (point-min))
1666 (re-search-forward "^cc:" nil nil cc-count)
1668 (narrow-to-region (point) (point-max))
1669 (gnus-article-hide-header "cc"))
1670 (setq cc-count (1- cc-count)))))))))))))
1672 (defun gnus-article-hide-header (header)
1674 (goto-char (point-min))
1675 (when (re-search-forward (concat "^" header ":") nil t)
1676 (gnus-article-hide-text-type
1677 (progn (beginning-of-line) (point))
1680 (if (re-search-forward "^[^ \t]" nil t)
1685 (defvar gnus-article-normalized-header-length 40
1686 "Length of normalized headers.")
1688 (defun article-normalize-headers ()
1689 "Make all header lines 40 characters long."
1691 (let ((buffer-read-only nil)
1695 (article-narrow-to-head)
1698 ((< (setq column (- (gnus-point-at-eol) (point)))
1699 gnus-article-normalized-header-length)
1701 (insert (make-string
1702 (- gnus-article-normalized-header-length column)
1704 ((> column gnus-article-normalized-header-length)
1705 (gnus-put-text-property
1707 (forward-char gnus-article-normalized-header-length)
1714 (forward-line 1))))))
1716 (defun article-treat-dumbquotes ()
1717 "Translate M****s*** sm*rtq**t*s into proper text.
1718 Note that this function guesses whether a character is a sm*rtq**t* or
1719 not, so it should only be used interactively.
1721 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1722 in an attempt to provide more quoting characters. If you see
1723 something like \\222 or \\264 where you're expecting some kind of
1724 apostrophe or quotation mark, then try this wash."
1726 (article-translate-strings gnus-article-dumbquotes-map))
1728 (defun article-translate-characters (from to)
1729 "Translate all characters in the body of the article according to FROM and TO.
1730 FROM is a string of characters to translate from; to is a string of
1731 characters to translate to."
1733 (when (article-goto-body)
1734 (let ((buffer-read-only nil)
1735 (x (make-string 225 ?x))
1737 (while (< (incf i) (length x))
1740 (while (< i (length from))
1741 (aset x (aref from i) (aref to i))
1743 (translate-region (point) (point-max) x)))))
1745 (defun article-translate-strings (map)
1746 "Translate all string in the body of the article according to MAP.
1747 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1749 (when (article-goto-body)
1750 (let ((buffer-read-only nil)
1752 (while (setq elem (pop map))
1754 (while (search-forward (car elem) nil t)
1755 (replace-match (cadr elem)))))))))
1757 (defun article-treat-overstrike ()
1758 "Translate overstrikes into bold text."
1761 (when (article-goto-body)
1762 (let ((buffer-read-only nil))
1763 (while (search-forward "\b" nil t)
1764 (let ((next (char-after))
1765 (previous (char-after (- (point) 2))))
1766 ;; We do the boldification/underlining by hiding the
1767 ;; overstrikes and putting the proper text property
1771 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1772 (put-text-property (point) (1+ (point)) 'face 'bold))
1774 (gnus-article-hide-text-type
1775 (1- (point)) (1+ (point)) 'overstrike)
1777 (- (point) 2) (1- (point)) 'face 'underline))
1779 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1781 (point) (1+ (point)) 'face 'underline)))))))))
1783 (defun gnus-article-treat-unfold-headers ()
1784 "Unfold folded message headers.
1785 Only the headers that fit into the current window width will be
1788 (gnus-with-article-headers
1792 (mail-header-narrow-to-field)
1793 (let ((header (buffer-substring (point-min) (point-max))))
1796 (goto-char (point-min))
1797 (while (re-search-forward "\n[\t ]" nil t)
1798 (replace-match " " t t)))
1799 (setq length (- (point-max) (point-min) 1)))
1800 (when (< length (window-width))
1801 (while (re-search-forward "\n[\t ]" nil t)
1802 (replace-match " " t t)))
1803 (goto-char (point-max)))))))
1805 (defun gnus-article-treat-fold-headers ()
1806 "Fold message headers."
1808 (gnus-with-article-headers
1811 (mail-header-narrow-to-field)
1812 (mail-header-fold-field)
1813 (goto-char (point-max))))))
1815 (defun gnus-treat-smiley ()
1816 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1818 (gnus-with-article-buffer
1819 (if (memq 'smiley gnus-article-wash-types)
1820 (gnus-delete-images 'smiley)
1822 (let ((images (smiley-region (point) (point-max))))
1824 (gnus-add-wash-type 'smiley)
1825 (dolist (image images)
1826 (gnus-add-image 'smiley image)))))))
1828 (defun gnus-article-remove-images ()
1829 "Remove all images from the article buffer."
1831 (gnus-with-article-buffer
1832 (dolist (elem gnus-article-image-alist)
1833 (gnus-delete-images (car elem)))))
1835 (defun gnus-article-treat-fold-newsgroups ()
1836 "Unfold folded message headers.
1837 Only the headers that fit into the current window width will be
1840 (gnus-with-article-headers
1841 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1843 (mail-header-narrow-to-field)
1844 (while (re-search-forward ", *" nil t)
1845 (replace-match ", " t t))
1846 (mail-header-fold-field)
1847 (goto-char (point-max))))))
1849 (defun gnus-article-treat-body-boundary ()
1850 "Place a boundary line at the end of the headers."
1852 (when (and gnus-body-boundary-delimiter
1853 (> (length gnus-body-boundary-delimiter) 0))
1854 (gnus-with-article-headers
1855 (goto-char (point-max))
1856 (let ((start (point)))
1857 (insert "X-Boundary: ")
1858 (gnus-add-text-properties start (point) '(invisible t intangible t))
1860 (while (>= (1- (window-width)) (length str))
1861 (setq str (concat str gnus-body-boundary-delimiter)))
1862 (substring str 0 (1- (window-width))))
1864 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1866 (defun article-fill-long-lines ()
1867 "Fill lines that are wider than the window width."
1870 (let ((buffer-read-only nil)
1871 (width (window-width (get-buffer-window (current-buffer)))))
1874 (let ((adaptive-fill-mode nil)) ;Why? -sm
1877 (when (>= (current-column) (min fill-column width))
1878 (narrow-to-region (min (1+ (point)) (point-max)) (gnus-point-at-bol))
1879 (let ((goback (point-marker)))
1880 (fill-paragraph nil)
1881 (goto-char (marker-position goback)))
1883 (forward-line 1)))))))
1885 (defun article-capitalize-sentences ()
1886 "Capitalize the first word in each sentence."
1889 (let ((buffer-read-only nil)
1890 (paragraph-start "^[\n\^L]"))
1894 (forward-sentence)))))
1896 (defun article-remove-cr ()
1897 "Remove trailing CRs and then translate remaining CRs into LFs."
1900 (let ((buffer-read-only nil))
1901 (goto-char (point-min))
1902 (while (re-search-forward "\r+$" nil t)
1903 (replace-match "" t t))
1904 (goto-char (point-min))
1905 (while (search-forward "\r" nil t)
1906 (replace-match "\n" t t)))))
1908 (defun article-remove-trailing-blank-lines ()
1909 "Remove all trailing blank lines from the article."
1912 (let ((buffer-read-only nil))
1913 (goto-char (point-max))
1917 (while (and (not (bobp))
1918 (looking-at "^[ \t]*$")
1919 (not (gnus-annotation-in-region-p
1920 (point) (gnus-point-at-eol))))
1925 (defun article-display-face ()
1926 "Display any Face headers in the header."
1928 (gnus-with-article-headers
1929 (let ((face (message-fetch-field "face")))
1931 (let ((png (gnus-convert-face-to-png face))
1934 (setq image (gnus-create-image png 'png t))
1935 (gnus-article-goto-header "from")
1937 (insert "From: [no `from' set]\n")
1939 (gnus-add-wash-type 'face)
1940 (gnus-add-image 'face image)
1941 (gnus-put-image image)))))))
1943 (defun article-display-x-face (&optional force)
1944 "Look for an X-Face header and display it if present."
1945 (interactive (list 'force))
1946 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1947 (gnus-with-article-headers
1948 ;; Delete the old process, if any.
1949 (when (process-status "article-x-face")
1950 (delete-process "article-x-face"))
1951 (if (memq 'xface gnus-article-wash-types)
1952 ;; We have already displayed X-Faces, so we remove them
1954 (gnus-delete-images 'xface)
1956 (let (x-faces from face)
1958 (when (and wash-face-p
1960 (goto-char (point-min))
1961 (not (re-search-forward
1962 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
1963 (gnus-buffer-live-p gnus-original-article-buffer))
1964 ;; If type `W f', use gnus-original-article-buffer,
1965 ;; otherwise use the current buffer because displaying
1966 ;; RFC822 parts calls this function too.
1967 (set-buffer gnus-original-article-buffer))
1969 (mail-narrow-to-head)
1970 (while (gnus-article-goto-header "X-Face")
1971 (push (mail-header-field-value) x-faces))
1972 (setq from (message-fetch-field "from"))))
1973 ;; Sending multiple EOFs to xv doesn't work, so we only do a
1974 ;; single external face.
1975 (when (stringp gnus-article-x-face-command)
1976 (setq x-faces (list (car x-faces))))
1977 (while (and (setq face (pop x-faces))
1978 gnus-article-x-face-command
1980 ;; Check whether this face is censored.
1981 (not gnus-article-x-face-too-ugly)
1982 (and gnus-article-x-face-too-ugly from
1983 (not (string-match gnus-article-x-face-too-ugly
1985 ;; We display the face.
1986 (if (symbolp gnus-article-x-face-command)
1987 ;; The command is a lisp function, so we call it.
1988 (if (gnus-functionp gnus-article-x-face-command)
1989 (funcall gnus-article-x-face-command face)
1990 (error "%s is not a function" gnus-article-x-face-command))
1991 ;; The command is a string, so we interpret the command
1992 ;; as a, well, command, and fork it off.
1993 (let ((process-connection-type nil))
1994 (process-kill-without-query
1996 "article-x-face" nil shell-file-name shell-command-switch
1997 gnus-article-x-face-command))
2000 (process-send-region "article-x-face"
2001 (point-min) (point-max)))
2002 (process-send-eof "article-x-face")))))))))
2004 (defun article-decode-mime-words ()
2005 "Decode all MIME-encoded words in the article."
2008 (set-buffer gnus-article-buffer)
2009 (let ((inhibit-point-motion-hooks t)
2011 (mail-parse-charset gnus-newsgroup-charset)
2012 (mail-parse-ignored-charsets
2013 (save-excursion (set-buffer gnus-summary-buffer)
2014 gnus-newsgroup-ignored-charsets)))
2015 (mail-decode-encoded-word-region (point-min) (point-max)))))
2017 (defun article-decode-charset (&optional prompt)
2018 "Decode charset-encoded text in the article.
2019 If PROMPT (the prefix), prompt for a coding system to use."
2021 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2023 (mail-parse-charset gnus-newsgroup-charset)
2024 (mail-parse-ignored-charsets
2025 (save-excursion (condition-case nil
2026 (set-buffer gnus-summary-buffer)
2028 gnus-newsgroup-ignored-charsets))
2029 ct cte ctl charset format)
2032 (article-narrow-to-head)
2033 (setq ct (message-fetch-field "Content-Type" t)
2034 cte (message-fetch-field "Content-Transfer-Encoding" t)
2035 ctl (and ct (ignore-errors
2036 (mail-header-parse-content-type ct)))
2039 (mm-read-coding-system "Charset to decode: "))
2041 (mail-content-type-get ctl 'charset)))
2042 format (and ctl (mail-content-type-get ctl 'format)))
2044 (setq cte (mail-header-strip cte)))
2045 (if (and ctl (not (string-match "/" (car ctl))))
2047 (goto-char (point-max)))
2050 (narrow-to-region (point) (point-max))
2051 (when (and (eq mail-parse-charset 'gnus-decoded)
2052 (eq (mm-body-7-or-8) '8bit))
2053 ;; The text code could have been decoded.
2054 (setq charset mail-parse-charset))
2055 (when (and (or (not ctl)
2056 (equal (car ctl) "text/plain"))
2057 (not format)) ;; article with format will decode later.
2059 charset (and cte (intern (downcase
2060 (gnus-strip-whitespace cte))))
2063 (defun article-decode-encoded-words ()
2064 "Remove encoded-word encoding from headers."
2065 (let ((inhibit-point-motion-hooks t)
2066 (mail-parse-charset gnus-newsgroup-charset)
2067 (mail-parse-ignored-charsets
2068 (save-excursion (condition-case nil
2069 (set-buffer gnus-summary-buffer)
2071 gnus-newsgroup-ignored-charsets))
2074 (article-narrow-to-head)
2075 (funcall gnus-decode-header-function (point-min) (point-max)))))
2077 (defun article-decode-group-name ()
2078 "Decode group names in `Newsgroups:'."
2079 (let ((inhibit-point-motion-hooks t)
2081 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2082 (when (and (or gnus-group-name-charset-method-alist
2083 gnus-group-name-charset-group-alist)
2084 (gnus-buffer-live-p gnus-original-article-buffer))
2085 (when (nnmail-fetch-field "Newsgroups")
2086 (nnheader-replace-header "Newsgroups"
2087 (gnus-decode-newsgroups
2088 (with-current-buffer
2089 gnus-original-article-buffer
2090 (nnmail-fetch-field "Newsgroups"))
2091 gnus-newsgroup-name method)))
2092 (when (nnmail-fetch-field "Followup-To")
2093 (nnheader-replace-header "Followup-To"
2094 (gnus-decode-newsgroups
2095 (with-current-buffer
2096 gnus-original-article-buffer
2097 (nnmail-fetch-field "Followup-To"))
2098 gnus-newsgroup-name method))))))
2100 (defun article-de-quoted-unreadable (&optional force read-charset)
2101 "Translate a quoted-printable-encoded article.
2102 If FORCE, decode the article whether it is marked as quoted-printable
2104 If READ-CHARSET, ask for a coding system."
2105 (interactive (list 'force current-prefix-arg))
2107 (let ((buffer-read-only nil) type charset)
2108 (if (gnus-buffer-live-p gnus-original-article-buffer)
2109 (with-current-buffer gnus-original-article-buffer
2111 (gnus-fetch-field "content-transfer-encoding"))
2112 (let* ((ct (gnus-fetch-field "content-type"))
2115 (mail-header-parse-content-type ct)))))
2116 (setq charset (and ctl
2117 (mail-content-type-get ctl 'charset)))
2118 (if (stringp charset)
2119 (setq charset (intern (downcase charset)))))))
2121 (setq charset (mm-read-coding-system "Charset: " charset)))
2123 (setq charset gnus-newsgroup-charset))
2125 (and type (let ((case-fold-search t))
2126 (string-match "quoted-printable" type))))
2128 (quoted-printable-decode-region
2129 (point) (point-max) (mm-charset-to-coding-system charset))))))
2131 (defun article-de-base64-unreadable (&optional force read-charset)
2132 "Translate a base64 article.
2133 If FORCE, decode the article whether it is marked as base64 not.
2134 If READ-CHARSET, ask for a coding system."
2135 (interactive (list 'force current-prefix-arg))
2137 (let ((buffer-read-only nil) type charset)
2138 (if (gnus-buffer-live-p gnus-original-article-buffer)
2139 (with-current-buffer gnus-original-article-buffer
2141 (gnus-fetch-field "content-transfer-encoding"))
2142 (let* ((ct (gnus-fetch-field "content-type"))
2145 (mail-header-parse-content-type ct)))))
2146 (setq charset (and ctl
2147 (mail-content-type-get ctl 'charset)))
2148 (if (stringp charset)
2149 (setq charset (intern (downcase charset)))))))
2151 (setq charset (mm-read-coding-system "Charset: " charset)))
2153 (setq charset gnus-newsgroup-charset))
2155 (and type (let ((case-fold-search t))
2156 (string-match "base64" type))))
2159 (narrow-to-region (point) (point-max))
2160 (base64-decode-region (point-min) (point-max))
2161 (mm-decode-coding-region
2162 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2167 (defun article-decode-HZ ()
2168 "Translate a HZ-encoded article."
2172 (let ((buffer-read-only nil))
2173 (rfc1843-decode-region (point-min) (point-max)))))
2175 (defun article-unsplit-urls ()
2176 "Remove the newlines that some other mailers insert into URLs."
2179 (let ((buffer-read-only nil))
2180 (goto-char (point-min))
2181 (while (re-search-forward
2182 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2183 (replace-match "\\1\\3" t)))
2184 (when (and gnus-display-mime-function (interactive-p))
2185 (funcall gnus-display-mime-function))))
2188 (defun article-wash-html (&optional read-charset)
2189 "Format an HTML article.
2190 If READ-CHARSET, ask for a coding system."
2193 (let ((buffer-read-only nil)
2195 (when (gnus-buffer-live-p gnus-original-article-buffer)
2196 (with-current-buffer gnus-original-article-buffer
2197 (let* ((ct (gnus-fetch-field "content-type"))
2200 (mail-header-parse-content-type ct)))))
2201 (setq charset (and ctl
2202 (mail-content-type-get ctl 'charset)))
2203 (when (stringp charset)
2204 (setq charset (intern (downcase charset)))))))
2206 (setq charset (mm-read-coding-system "Charset: " charset)))
2208 (setq charset gnus-newsgroup-charset))
2210 (save-window-excursion
2212 (narrow-to-region (point) (point-max))
2213 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2214 (entry (assq func mm-text-html-washer-alist)))
2216 (setq func (cdr entry)))
2218 ((gnus-functionp func)
2221 (apply (car func) (cdr func))))))))))
2223 (defun gnus-article-wash-html-with-w3 ()
2224 "Wash the current buffer with w3."
2226 (let ((w3-strict-width (window-width))
2227 (url-standalone-mode t)
2228 (url-gateway-unplugged t)
2229 (w3-honor-stylesheets nil))
2231 (w3-region (point-min) (point-max))
2234 (defun gnus-article-wash-html-with-w3m ()
2235 "Wash the current buffer with emacs-w3m."
2238 (narrow-to-region (point) (point-max))
2239 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2242 (w3m-display-inline-images mm-inline-text-html-with-images)
2243 w3m-force-redisplay)
2244 (w3m-region (point-min) (point-max)))
2245 (when mm-inline-text-html-with-w3m-keymap
2246 (add-text-properties
2247 (point-min) (point-max)
2248 (nconc (mm-w3m-local-map-property)
2249 '(mm-inline-text-html-with-w3m t))))))
2251 (defun article-hide-list-identifiers ()
2252 "Remove list identifies from the Subject header.
2253 The `gnus-list-identifiers' variable specifies what to do."
2255 (let ((inhibit-point-motion-hooks t)
2256 (regexp (if (consp gnus-list-identifiers)
2257 (mapconcat 'identity gnus-list-identifiers " *\\|")
2258 gnus-list-identifiers))
2263 (article-narrow-to-head)
2264 (goto-char (point-min))
2265 (while (re-search-forward
2266 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2268 (delete-region (match-beginning 2) (match-end 0))
2269 (beginning-of-line))
2270 (when (re-search-forward
2271 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2272 (delete-region (match-beginning 1) (match-end 1))))))))
2274 (defun article-hide-pem (&optional arg)
2275 "Toggle hiding of any PEM headers and signatures in the current article.
2276 If given a negative prefix, always show; if given a positive prefix,
2278 (interactive (gnus-article-hidden-arg))
2279 (unless (gnus-article-check-hidden-text 'pem arg)
2281 (let (buffer-read-only end)
2282 (goto-char (point-min))
2283 ;; Hide the horrendously ugly "header".
2284 (when (and (search-forward
2285 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2287 (setq end (1+ (match-beginning 0))))
2288 (gnus-add-wash-type 'pem)
2289 (gnus-article-hide-text-type
2291 (if (search-forward "\n\n" nil t)
2295 ;; Hide the trailer as well
2296 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2298 (gnus-article-hide-text-type
2299 (match-beginning 0) (match-end 0) 'pem)))))))
2301 (defun article-strip-banner ()
2302 "Strip the banner specified by the `banner' group parameter."
2306 (let ((inhibit-point-motion-hooks t)
2307 (banner (gnus-parameter-banner gnus-newsgroup-name))
2308 (gnus-signature-limit nil)
2309 buffer-read-only beg end)
2310 (when (and gnus-article-address-banner-alist
2313 (let ((from (save-restriction
2315 (article-narrow-to-head)
2316 (mail-fetch-field "from"))))
2319 (caar (mail-header-parse-addresses from))))
2321 (dolist (pair gnus-article-address-banner-alist)
2322 (when (string-match (car pair) from)
2323 (throw 'found (cdr pair)))))))))
2327 ((eq banner 'signature)
2328 (when (gnus-article-narrow-to-signature)
2331 (delete-region (point) (point-max))))
2333 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2334 (while (re-search-forward banner nil t)
2335 (delete-region (match-beginning 0) (match-end 0)))))
2337 (while (re-search-forward banner nil t)
2338 (delete-region (match-beginning 0) (match-end 0))))))))))
2340 (defun article-babel ()
2341 "Translate article using an online translation service."
2345 (set-buffer gnus-article-buffer)
2346 (when (article-goto-body)
2347 (let* ((buffer-read-only nil)
2350 (orig (buffer-substring start end))
2351 (trans (babel-as-string orig)))
2353 (narrow-to-region start end)
2354 (delete-region start end)
2357 (defun article-hide-signature (&optional arg)
2358 "Hide the signature in the current article.
2359 If given a negative prefix, always show; if given a positive prefix,
2361 (interactive (gnus-article-hidden-arg))
2362 (unless (gnus-article-check-hidden-text 'signature arg)
2365 (let ((buffer-read-only nil))
2366 (when (gnus-article-narrow-to-signature)
2367 (gnus-article-hide-text-type
2368 (point-min) (point-max) 'signature))))))
2369 (gnus-set-mode-line 'article))
2371 (defun article-strip-headers-in-body ()
2372 "Strip offensive headers from bodies."
2376 (let ((case-fold-search t))
2377 (when (looking-at "x-no-archive:")
2378 (gnus-delete-line)))))
2380 (defun article-strip-leading-blank-lines ()
2381 "Remove all blank lines from the beginning of the article."
2384 (let ((inhibit-point-motion-hooks t)
2386 (when (article-goto-body)
2387 (while (and (not (eobp))
2388 (looking-at "[ \t]*$"))
2389 (gnus-delete-line))))))
2391 (defun article-narrow-to-head ()
2392 "Narrow the buffer to the head of the message.
2393 Point is left at the beginning of the narrowed-to region."
2395 (goto-char (point-min))
2396 (if (search-forward "\n\n" nil 1)
2399 (goto-char (point-min)))
2401 (defun article-goto-body ()
2402 "Place point at the start of the body."
2403 (goto-char (point-min))
2405 ;; This variable is only bound when dealing with separate
2407 (article-goto-body-goes-to-point-min-p
2409 ((search-forward "\n\n" nil t)
2412 (goto-char (point-max))
2415 (defun article-strip-multiple-blank-lines ()
2416 "Replace consecutive blank lines with one empty line."
2419 (let ((inhibit-point-motion-hooks t)
2421 ;; First make all blank lines empty.
2423 (while (re-search-forward "^[ \t]+$" nil t)
2424 (unless (gnus-annotation-in-region-p
2425 (match-beginning 0) (match-end 0))
2426 (replace-match "" nil t)))
2427 ;; Then replace multiple empty lines with a single empty line.
2429 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2430 (unless (gnus-annotation-in-region-p
2431 (match-beginning 0) (match-end 0))
2432 (delete-region (match-beginning 1) (match-end 1)))))))
2434 (defun article-strip-leading-space ()
2435 "Remove all white space from the beginning of the lines in the article."
2438 (let ((inhibit-point-motion-hooks t)
2441 (while (re-search-forward "^[ \t]+" nil t)
2442 (replace-match "" t t)))))
2444 (defun article-strip-trailing-space ()
2445 "Remove all white space from the end of the lines in the article."
2448 (let ((inhibit-point-motion-hooks t)
2451 (while (re-search-forward "[ \t]+$" nil t)
2452 (replace-match "" t t)))))
2454 (defun article-strip-blank-lines ()
2455 "Strip leading, trailing and multiple blank lines."
2457 (article-strip-leading-blank-lines)
2458 (article-remove-trailing-blank-lines)
2459 (article-strip-multiple-blank-lines))
2461 (defun article-strip-all-blank-lines ()
2462 "Strip all blank lines."
2465 (let ((inhibit-point-motion-hooks t)
2468 (while (re-search-forward "^[ \t]*\n" nil t)
2469 (replace-match "" t t)))))
2471 (defun gnus-article-narrow-to-signature ()
2472 "Narrow to the signature; return t if a signature is found, else nil."
2473 (let ((inhibit-point-motion-hooks t))
2474 (when (gnus-article-search-signature)
2476 ;; Check whether we have some limits to what we consider
2477 ;; to be a signature.
2478 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2479 (list gnus-signature-limit)))
2481 (while (setq limit (pop limits))
2482 (if (or (and (integerp limit)
2483 (< (- (point-max) (point)) limit))
2485 (< (count-lines (point) (point-max)) limit))
2486 (and (gnus-functionp limit)
2488 (and (stringp limit)
2489 (not (re-search-forward limit nil t))))
2490 () ; This limit did not succeed.
2494 (narrow-to-region (point) (point-max))
2497 (defun gnus-article-search-signature ()
2498 "Search the current buffer for the signature separator.
2499 Put point at the beginning of the signature separator."
2500 (let ((cur (point)))
2501 (goto-char (point-max))
2502 (if (if (stringp gnus-signature-separator)
2503 (re-search-backward gnus-signature-separator nil t)
2504 (let ((seps gnus-signature-separator))
2506 (not (re-search-backward (car seps) nil t)))
2513 (defun gnus-article-hidden-arg ()
2514 "Return the current prefix arg as a number, or 0 if no prefix."
2515 (list (if current-prefix-arg
2516 (prefix-numeric-value current-prefix-arg)
2519 (defun gnus-article-check-hidden-text (type arg)
2520 "Return nil if hiding is necessary.
2521 Arg can be nil or a number. nil and positive means hide, negative
2522 means show, 0 means toggle."
2525 (let ((hide (gnus-article-hidden-text-p type)))
2531 (gnus-article-show-hidden-text type)
2534 (if (eq hide 'hidden)
2536 (gnus-article-show-hidden-text type)
2540 (defun gnus-article-hidden-text-p (type)
2541 "Say whether the current buffer contains hidden text of type TYPE."
2542 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2544 (not (get-text-property pos 'invisible))
2545 (not (get-text-property pos 'dummy-invisible)))
2547 (text-property-any (1+ pos) (point-max) 'article-type type)))
2552 (defun gnus-article-show-hidden-text (type &optional dummy)
2553 "Show all hidden text of type TYPE.
2554 Originally it is hide instead of DUMMY."
2555 (let ((buffer-read-only nil)
2556 (inhibit-point-motion-hooks t))
2557 (gnus-remove-text-properties-when
2559 (point-min) (point-max)
2560 (cons 'article-type (cons type
2561 gnus-hidden-properties)))
2562 (gnus-delete-wash-type type)))
2564 (defconst article-time-units
2565 `((year . ,(* 365.25 24 60 60))
2566 (week . ,(* 7 24 60 60))
2567 (day . ,(* 24 60 60))
2571 "Mapping from time units to seconds.")
2573 (defun gnus-article-forward-header ()
2574 "Move point to the start of the next header.
2575 If the current header is a continuation header, this can be several
2580 (if (looking-at "[ \t]+[^ \t]")
2584 (defun article-date-ut (&optional type highlight header)
2585 "Convert DATE date to universal time in the current article.
2586 If TYPE is `local', convert to local time; if it is `lapsed', output
2587 how much time has lapsed since DATE. For `lapsed', the value of
2588 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2589 should replace the \"Date:\" one, or should be added below it."
2590 (interactive (list 'ut t))
2591 (let* ((header (or header
2592 (message-fetch-field "date")
2594 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2597 ((not gnus-article-date-lapsed-new-header)
2603 (date (if (vectorp header) (mail-header-date header)
2605 (inhibit-point-motion-hooks t)
2610 (article-narrow-to-head)
2611 (when (re-search-forward tdate-regexp nil t)
2612 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2613 date (or (get-text-property (gnus-point-at-bol)
2616 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2618 (when (and date (not (string= date "")))
2619 (goto-char (point-min))
2620 (let ((buffer-read-only nil))
2621 ;; Delete any old Date headers.
2622 (while (re-search-forward date-regexp nil t)
2624 (delete-region (progn (beginning-of-line) (point))
2625 (progn (gnus-article-forward-header)
2627 (delete-region (progn (beginning-of-line) (point))
2628 (progn (gnus-article-forward-header)
2631 (setq pos (point))))
2632 (when (and (not pos)
2633 (re-search-forward tdate-regexp nil t))
2637 (insert (article-make-date-line date (or type 'ut)))
2643 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2644 (put-text-property (match-beginning 1) (1+ (match-end 1))
2645 'original-date date)
2646 (put-text-property (match-beginning 1) (1+ (match-end 1))
2648 (put-text-property (match-beginning 2) (match-end 2)
2651 (defun article-make-date-line (date type)
2652 "Return a DATE line of TYPE."
2653 (unless (memq type '(local ut original user iso8601 lapsed english))
2654 (error "Unknown conversion type: %s" type))
2656 (let ((time (date-to-time date)))
2658 ;; Convert to the local timezone.
2660 (let ((tz (car (current-time-zone time))))
2661 (format "Date: %s %s%02d%02d" (current-time-string time)
2662 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2663 (/ (% (abs tz) 3600) 60))))
2664 ;; Convert to Universal Time.
2667 (current-time-string
2668 (let* ((e (parse-time-string date))
2669 (tm (apply 'encode-time e))
2671 (ls (- (cadr tm) (car (current-time-zone time)))))
2672 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2673 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2676 ;; Get the original date from the article.
2677 ((eq type 'original)
2678 (concat "Date: " (if (string-match "\n+$" date)
2679 (substring date 0 (match-beginning 0))
2681 ;; Let the user define the format.
2683 (let ((format (or (condition-case nil
2684 (with-current-buffer gnus-summary-buffer
2685 gnus-article-time-format)
2687 gnus-article-time-format)))
2688 (if (gnus-functionp format)
2689 (funcall format time)
2690 (concat "Date: " (format-time-string format time)))))
2693 (let ((tz (car (current-time-zone time))))
2696 (format-time-string "%Y%m%dT%H%M%S" time)
2697 (format "%s%02d%02d"
2698 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2699 (/ (% (abs tz) 3600) 60)))))
2700 ;; Do an X-Sent lapsed format.
2702 ;; If the date is seriously mangled, the timezone functions are
2703 ;; liable to bug out, so we ignore all errors.
2704 (let* ((now (current-time))
2705 (real-time (subtract-time now time))
2706 (real-sec (and real-time
2707 (+ (* (float (car real-time)) 65536)
2709 (sec (and real-time (abs real-sec)))
2719 ;; This is a bit convoluted, but basically we go
2720 ;; through the time units for years, weeks, etc,
2721 ;; and divide things to see whether that results
2722 ;; in positive answers.
2725 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2726 ;; The (remaining) seconds are too few to
2727 ;; be divided into this time unit.
2729 ;; It's big enough, so we output it.
2730 (setq sec (- sec (* num (cdr unit))))
2732 (concat (if prev ", " "") (int-to-string
2734 " " (symbol-name (car unit))
2735 (if (> num 1) "s" ""))
2737 article-time-units "")
2738 ;; If dates are odd, then it might appear like the
2739 ;; article was sent in the future.
2742 " in the future"))))))
2743 ;; Display the date in proper English
2745 (let ((dtime (decode-time time)))
2748 (number-to-string (nth 3 dtime))
2749 (let ((digit (% (nth 3 dtime) 10)))
2751 ((memq (nth 3 dtime) '(11 12 13)) "th")
2757 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2759 (number-to-string (nth 5 dtime))
2761 (format "%02d" (nth 2 dtime))
2763 (format "%02d" (nth 1 dtime)))))))
2765 (format "Date: %s (from Gnus)" date))))
2767 (defun article-date-local (&optional highlight)
2768 "Convert the current article date to the local timezone."
2769 (interactive (list t))
2770 (article-date-ut 'local highlight))
2772 (defun article-date-english (&optional highlight)
2773 "Convert the current article date to something that is proper English."
2774 (interactive (list t))
2775 (article-date-ut 'english highlight))
2777 (defun article-date-original (&optional highlight)
2778 "Convert the current article date to what it was originally.
2779 This is only useful if you have used some other date conversion
2780 function and want to see what the date was before converting."
2781 (interactive (list t))
2782 (article-date-ut 'original highlight))
2784 (defun article-date-lapsed (&optional highlight)
2785 "Convert the current article date to time lapsed since it was sent."
2786 (interactive (list t))
2787 (article-date-ut 'lapsed highlight))
2789 (defun article-update-date-lapsed ()
2790 "Function to be run from a timer to update the lapsed time line."
2791 (let (deactivate-mark)
2796 (set-buffer (window-buffer w))
2797 (when (eq major-mode 'gnus-article-mode)
2798 (goto-char (point-min))
2799 (when (re-search-forward "^X-Sent:" nil t)
2800 (article-date-lapsed t))))
2803 (defun gnus-start-date-timer (&optional n)
2804 "Start a timer to update the X-Sent header in the article buffers.
2805 The numerical prefix says how frequently (in seconds) the function
2810 (gnus-stop-date-timer)
2811 (setq article-lapsed-timer
2812 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2814 (defun gnus-stop-date-timer ()
2815 "Stop the X-Sent timer."
2817 (when article-lapsed-timer
2818 (nnheader-cancel-timer article-lapsed-timer)
2819 (setq article-lapsed-timer nil)))
2821 (defun article-date-user (&optional highlight)
2822 "Convert the current article date to the user-defined format.
2823 This format is defined by the `gnus-article-time-format' variable."
2824 (interactive (list t))
2825 (article-date-ut 'user highlight))
2827 (defun article-date-iso8601 (&optional highlight)
2828 "Convert the current article date to ISO8601."
2829 (interactive (list t))
2830 (article-date-ut 'iso8601 highlight))
2832 ;; (defun article-show-all ()
2833 ;; "Show all hidden text in the article buffer."
2836 ;; (let ((buffer-read-only nil))
2837 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2839 (defun article-remove-leading-whitespace ()
2840 "Remove excessive whitespace from all headers."
2844 (let ((buffer-read-only nil))
2845 (article-narrow-to-head)
2846 (goto-char (point-min))
2847 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2848 (delete-region (match-beginning 1) (match-end 1)))))))
2850 (defun article-emphasize (&optional arg)
2851 "Emphasize text according to `gnus-emphasis-alist'."
2852 (interactive (gnus-article-hidden-arg))
2853 (unless (gnus-article-check-hidden-text 'emphasis arg)
2857 (with-current-buffer gnus-summary-buffer
2858 gnus-article-emphasis-alist)
2860 gnus-emphasis-alist))
2861 (buffer-read-only nil)
2862 (props (append '(article-type emphasis)
2863 gnus-hidden-properties))
2864 regexp elem beg invisible visible face)
2867 (while (setq elem (pop alist))
2869 (setq regexp (car elem)
2870 invisible (nth 1 elem)
2871 visible (nth 2 elem)
2873 (while (re-search-forward regexp nil t)
2874 (when (and (match-beginning visible) (match-beginning invisible))
2875 (gnus-article-hide-text
2876 (match-beginning invisible) (match-end invisible) props)
2877 (gnus-article-unhide-text-type
2878 (match-beginning visible) (match-end visible) 'emphasis)
2879 (gnus-put-overlay-excluding-newlines
2880 (match-beginning visible) (match-end visible) 'face face)
2881 (gnus-add-wash-type 'emphasis)
2882 (goto-char (match-end invisible)))))))))
2884 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2885 "Setup newsgroup emphasis alist."
2886 (unless gnus-article-emphasis-alist
2887 (let ((name (and gnus-newsgroup-name
2888 (gnus-group-real-name gnus-newsgroup-name))))
2889 (make-local-variable 'gnus-article-emphasis-alist)
2890 (setq gnus-article-emphasis-alist
2892 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2893 (while (setq elem (pop alist))
2894 (when (and name (string-match (car elem) name))
2896 highlight (copy-sequence (cdr elem)))))
2898 (copy-sequence highlight-words)
2899 (if gnus-newsgroup-name
2900 (copy-sequence (gnus-group-find-parameter
2901 gnus-newsgroup-name 'highlight-words t)))
2902 gnus-emphasis-alist)))))
2905 (defvar gnus-summary-article-menu)
2906 (defvar gnus-summary-post-menu))
2908 ;;; Saving functions.
2910 (defun gnus-article-save (save-buffer file &optional num)
2911 "Save the currently selected article."
2912 (unless gnus-save-all-headers
2913 ;; Remove headers according to `gnus-saved-headers'.
2914 (let ((gnus-visible-headers
2915 (or gnus-saved-headers gnus-visible-headers))
2916 (gnus-article-buffer save-buffer))
2918 (set-buffer save-buffer)
2919 (article-hide-headers 1 t))))
2920 (save-window-excursion
2921 (if (not gnus-default-article-saver)
2922 (error "No default saver is defined")
2923 ;; !!! Magic! The saving functions all save
2924 ;; `gnus-save-article-buffer' (or so they think), but we
2925 ;; bind that variable to our save-buffer.
2926 (set-buffer gnus-article-buffer)
2927 (let* ((gnus-save-article-buffer save-buffer)
2930 ((not gnus-prompt-before-saving) 'default)
2931 ((eq gnus-prompt-before-saving 'always) nil)
2933 (gnus-number-of-articles-to-be-saved
2934 (when (eq gnus-prompt-before-saving t)
2936 (set-buffer gnus-article-current-summary)
2937 (funcall gnus-default-article-saver filename)))))
2939 (defun gnus-read-save-file-name (prompt &optional filename
2940 function group headers variable)
2942 (funcall function group headers (symbol-value variable)))
2947 ((eq filename 'default)
2953 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2956 (if (and gnus-number-of-articles-to-be-saved
2957 (> gnus-number-of-articles-to-be-saved 1))
2958 (format "these %d articles"
2959 gnus-number-of-articles-to-be-saved)
2962 ;; Let the split methods have their say.
2964 ;; No split name was found.
2967 (concat prompt " (default "
2968 (file-name-nondirectory default-name) ") ")
2969 (file-name-directory default-name)
2971 ;; A single group name is returned.
2972 ((stringp split-name)
2974 (funcall function split-name headers
2975 (symbol-value variable)))
2977 (concat prompt " (default "
2978 (file-name-nondirectory default-name) ") ")
2979 (file-name-directory default-name)
2981 ;; A single split name was found
2982 ((= 1 (length split-name))
2983 (let* ((name (expand-file-name
2985 gnus-article-save-directory))
2986 (dir (cond ((file-directory-p name)
2987 (file-name-as-directory name))
2988 ((file-exists-p name) name)
2989 (t gnus-article-save-directory))))
2991 (concat prompt " (default " name ") ")
2993 ;; A list of splits was found.
2995 (setq split-name (nreverse split-name))
2997 (let ((file-name-history
2998 (nconc split-name file-name-history)))
3002 (concat prompt " (`M-p' for defaults) ")
3003 gnus-article-save-directory
3005 gnus-article-save-directory)))
3006 (car (push result file-name-history)))))))
3007 ;; Create the directory.
3008 (gnus-make-directory (file-name-directory file))
3009 ;; If we have read a directory, we append the default file name.
3010 (when (file-directory-p file)
3011 (setq file (expand-file-name (file-name-nondirectory
3013 (file-name-as-directory file))))
3014 ;; Possibly translate some characters.
3015 (nnheader-translate-file-chars file))))))
3016 (gnus-make-directory (file-name-directory result))
3017 (set variable result)))
3019 (defun gnus-article-archive-name (group)
3020 "Return the first instance of an \"Archive-name\" in the current buffer."
3021 (let ((case-fold-search t))
3022 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3023 (nnheader-concat gnus-article-save-directory
3024 (match-string 1)))))
3026 (defun gnus-article-nndoc-name (group)
3027 "If GROUP is an nndoc group, return the name of the parent group."
3028 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3029 (gnus-group-get-parameter group 'save-article-group)))
3031 (defun gnus-summary-save-in-rmail (&optional filename)
3032 "Append this article to Rmail file.
3033 Optional argument FILENAME specifies file name.
3034 Directory to save to is default to `gnus-article-save-directory'."
3035 (setq filename (gnus-read-save-file-name
3036 "Save %s in rmail file:" filename
3037 gnus-rmail-save-name gnus-newsgroup-name
3038 gnus-current-headers 'gnus-newsgroup-last-rmail))
3039 (gnus-eval-in-buffer-window gnus-save-article-buffer
3043 (gnus-output-to-rmail filename))))
3046 (defun gnus-summary-save-in-mail (&optional filename)
3047 "Append this article to Unix mail file.
3048 Optional argument FILENAME specifies file name.
3049 Directory to save to is default to `gnus-article-save-directory'."
3050 (setq filename (gnus-read-save-file-name
3051 "Save %s in Unix mail file:" filename
3052 gnus-mail-save-name gnus-newsgroup-name
3053 gnus-current-headers 'gnus-newsgroup-last-mail))
3054 (gnus-eval-in-buffer-window gnus-save-article-buffer
3058 (if (and (file-readable-p filename)
3059 (file-regular-p filename)
3060 (mail-file-babyl-p filename))
3061 (rmail-output-to-rmail-file filename t)
3062 (gnus-output-to-mail filename)))))
3065 (defun gnus-summary-save-in-file (&optional filename overwrite)
3066 "Append this article to file.
3067 Optional argument FILENAME specifies file name.
3068 Directory to save to is default to `gnus-article-save-directory'."
3069 (setq filename (gnus-read-save-file-name
3070 "Save %s in file:" filename
3071 gnus-file-save-name gnus-newsgroup-name
3072 gnus-current-headers 'gnus-newsgroup-last-file))
3073 (gnus-eval-in-buffer-window gnus-save-article-buffer
3077 (when (and overwrite
3078 (file-exists-p filename))
3079 (delete-file filename))
3080 (gnus-output-to-file filename))))
3083 (defun gnus-summary-write-to-file (&optional filename)
3084 "Write this article to a file, overwriting it if the file exists.
3085 Optional argument FILENAME specifies file name.
3086 The directory to save in defaults to `gnus-article-save-directory'."
3087 (gnus-summary-save-in-file nil t))
3089 (defun gnus-summary-save-body-in-file (&optional filename)
3090 "Append this article body to a file.
3091 Optional argument FILENAME specifies file name.
3092 The directory to save in defaults to `gnus-article-save-directory'."
3093 (setq filename (gnus-read-save-file-name
3094 "Save %s body in file:" filename
3095 gnus-file-save-name gnus-newsgroup-name
3096 gnus-current-headers 'gnus-newsgroup-last-file))
3097 (gnus-eval-in-buffer-window gnus-save-article-buffer
3101 (when (article-goto-body)
3102 (narrow-to-region (point) (point-max)))
3103 (gnus-output-to-file filename))))
3106 (defun gnus-summary-save-in-pipe (&optional command)
3107 "Pipe this article to subprocess."
3109 (cond ((and (eq command 'default)
3110 gnus-last-shell-command)
3111 gnus-last-shell-command)
3116 "Shell command on %s: "
3117 (if (and gnus-number-of-articles-to-be-saved
3118 (> gnus-number-of-articles-to-be-saved 1))
3119 (format "these %d articles"
3120 gnus-number-of-articles-to-be-saved)
3122 gnus-last-shell-command))))
3123 (when (string-equal command "")
3124 (if gnus-last-shell-command
3125 (setq command gnus-last-shell-command)
3126 (error "A command is required")))
3127 (gnus-eval-in-buffer-window gnus-article-buffer
3130 (shell-command-on-region (point-min) (point-max) command nil)))
3131 (setq gnus-last-shell-command command))
3133 (defun gnus-summary-pipe-to-muttprint (&optional command)
3134 "Pipe this article to muttprint."
3135 (setq command (read-string
3136 "Print using command: " gnus-summary-muttprint-program
3137 nil gnus-summary-muttprint-program))
3138 (gnus-summary-save-in-pipe command))
3140 ;;; Article file names when saving.
3142 (defun gnus-capitalize-newsgroup (newsgroup)
3143 "Capitalize NEWSGROUP name."
3144 (when (not (zerop (length newsgroup)))
3145 (concat (char-to-string (upcase (aref newsgroup 0)))
3146 (substring newsgroup 1))))
3148 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3149 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3150 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3151 Otherwise, it is like ~/News/news/group/num."
3154 (concat (if (gnus-use-long-file-name 'not-save)
3155 (gnus-capitalize-newsgroup newsgroup)
3156 (gnus-newsgroup-directory-form newsgroup))
3157 "/" (int-to-string (mail-header-number headers)))
3158 gnus-article-save-directory)))
3160 (string-equal (file-name-directory default)
3161 (file-name-directory last-file))
3162 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3164 (or last-file default))))
3166 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3167 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3168 If variable `gnus-use-long-file-name' is non-nil, it is
3169 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3172 (concat (if (gnus-use-long-file-name 'not-save)
3174 (gnus-newsgroup-directory-form newsgroup))
3175 "/" (int-to-string (mail-header-number headers)))
3176 gnus-article-save-directory)))
3178 (string-equal (file-name-directory default)
3179 (file-name-directory last-file))
3180 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3182 (or last-file default))))
3184 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3185 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3186 If variable `gnus-use-long-file-name' is non-nil, it is
3187 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3190 (if (gnus-use-long-file-name 'not-save)
3193 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3195 gnus-article-save-directory)))
3197 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3198 "Generate file name from sender."
3199 (let ((from (mail-header-from headers)))
3201 (if (and from (string-match "\\([^ <]+\\)@" from))
3202 (match-string 1 from)
3204 gnus-article-save-directory)))
3206 (defun article-verify-x-pgp-sig ()
3209 (if (gnus-buffer-live-p gnus-original-article-buffer)
3210 (let ((sig (with-current-buffer gnus-original-article-buffer
3211 (gnus-fetch-field "X-PGP-Sig")))
3215 (mml2015-clear-verify-function))
3217 (insert-buffer gnus-original-article-buffer)
3218 (setq items (split-string sig))
3219 (message-narrow-to-head)
3220 (let ((inhibit-point-motion-hooks t)
3221 (case-fold-search t))
3222 ;; Don't verify multiple headers.
3223 (setq headers (mapconcat (lambda (header)
3225 (mail-fetch-field header) "\n"))
3226 (split-string (nth 1 items) ",") "")))
3227 (delete-region (point-min) (point-max))
3228 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3229 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3234 (if (looking-at "^-")
3237 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3238 (insert "Version: " (car items) "\n\n")
3239 (insert (mapconcat 'identity (cddr items) "\n"))
3240 (insert "\n-----END PGP SIGNATURE-----\n")
3241 (let ((mm-security-handle (list (format "multipart/signed"))))
3242 (mml2015-clean-buffer)
3243 (let ((coding-system-for-write (or gnus-newsgroup-charset
3245 (funcall (mml2015-clear-verify-function)))
3247 (or (mm-handle-multipart-ctl-parameter
3248 mm-security-handle 'gnus-details)
3249 (mm-handle-multipart-ctl-parameter
3250 mm-security-handle 'gnus-info)))))
3252 (let (buffer-read-only bface eface)
3254 (message-narrow-to-head)
3255 (goto-char (point-max))
3257 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3258 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3259 (message-remove-header "X-Gnus-PGP-Verify")
3260 (if (re-search-forward "^X-PGP-Sig:" nil t)
3262 (goto-char (point-max)))
3263 (narrow-to-region (point) (point))
3264 (insert "X-Gnus-PGP-Verify: " info "\n")
3265 (goto-char (point-min))
3268 (if (not (looking-at "^[ \t]"))
3272 (goto-char (point-min))
3273 (when (looking-at "\\([^:]+\\): *")
3274 (put-text-property (match-beginning 1) (1+ (match-end 1))
3276 (put-text-property (match-end 0) (point-max)
3277 'face eface)))))))))
3279 (defun article-verify-cancel-lock ()
3280 "Verify Cancel-Lock header."
3282 (if (gnus-buffer-live-p gnus-original-article-buffer)
3283 (canlock-verify gnus-original-article-buffer)))
3290 (setq afunc (car func)
3293 gfunc (intern (format "gnus-%s" func))))
3295 (when (fboundp afunc)
3296 `(lambda (&optional interactive &rest args)
3297 ,(documentation afunc t)
3298 (interactive (list t))
3300 (set-buffer gnus-article-buffer)
3302 (call-interactively ',afunc)
3303 (apply ',afunc args))))))))
3304 '(article-hide-headers
3305 article-verify-x-pgp-sig
3306 article-verify-cancel-lock
3307 article-hide-boring-headers
3308 article-treat-overstrike
3309 article-fill-long-lines
3310 article-capitalize-sentences
3312 article-remove-leading-whitespace
3313 article-display-x-face
3314 article-display-face
3315 article-de-quoted-unreadable
3316 article-de-base64-unreadable
3319 article-unsplit-urls
3320 article-hide-list-identifiers
3321 article-strip-banner
3324 article-hide-signature
3325 article-strip-headers-in-body
3326 article-remove-trailing-blank-lines
3327 article-strip-leading-blank-lines
3328 article-strip-multiple-blank-lines
3329 article-strip-leading-space
3330 article-strip-trailing-space
3331 article-strip-blank-lines
3332 article-strip-all-blank-lines
3334 article-date-english
3335 article-date-iso8601
3336 article-date-original
3338 article-decode-mime-words
3339 article-decode-charset
3340 article-decode-encoded-words
3344 article-treat-dumbquotes
3345 article-normalize-headers
3346 ;; (article-show-all . gnus-article-show-all-headers)
3350 ;;; Gnus article mode
3353 (put 'gnus-article-mode 'mode-class 'special)
3355 (set-keymap-parent gnus-article-mode-map widget-keymap)
3357 (gnus-define-keys gnus-article-mode-map
3358 " " gnus-article-goto-next-page
3359 "\177" gnus-article-goto-prev-page
3360 [delete] gnus-article-goto-prev-page
3361 [backspace] gnus-article-goto-prev-page
3362 "\C-c^" gnus-article-refer-article
3363 "h" gnus-article-show-summary
3364 "s" gnus-article-show-summary
3365 "\C-c\C-m" gnus-article-mail
3366 "?" gnus-article-describe-briefly
3367 "e" gnus-summary-edit-article
3368 "<" beginning-of-buffer
3370 "\C-c\C-i" gnus-info-find-node
3372 "R" gnus-article-reply-with-original
3373 "F" gnus-article-followup-with-original
3374 "\C-hk" gnus-article-describe-key
3375 "\C-hc" gnus-article-describe-key-briefly
3377 "\C-d" gnus-article-read-summary-keys
3378 "\M-*" gnus-article-read-summary-keys
3379 "\M-#" gnus-article-read-summary-keys
3380 "\M-^" gnus-article-read-summary-keys
3381 "\M-g" gnus-article-read-summary-keys)
3383 (substitute-key-definition
3384 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3386 (defun gnus-article-make-menu-bar ()
3387 (unless (boundp 'gnus-article-commands-menu)
3388 (gnus-summary-make-menu-bar))
3389 (gnus-turn-off-edit-menu 'article)
3390 (unless (boundp 'gnus-article-article-menu)
3392 gnus-article-article-menu gnus-article-mode-map ""
3394 ["Scroll forwards" gnus-article-goto-next-page t]
3395 ["Scroll backwards" gnus-article-goto-prev-page t]
3396 ["Show summary" gnus-article-show-summary t]
3397 ["Fetch Message-ID at point" gnus-article-refer-article t]
3398 ["Mail to address at point" gnus-article-mail t]
3399 ["Send a bug report" gnus-bug t]))
3402 gnus-article-treatment-menu gnus-article-mode-map ""
3403 ;; Fixme: this should use :active (and maybe :visible).
3405 ["Hide headers" gnus-article-hide-headers t]
3406 ["Hide signature" gnus-article-hide-signature t]
3407 ["Hide citation" gnus-article-hide-citation t]
3408 ["Treat overstrike" gnus-article-treat-overstrike t]
3409 ["Remove carriage return" gnus-article-remove-cr t]
3410 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3411 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3412 ["Remove base64" gnus-article-de-base64-unreadable t]
3413 ["Treat html" gnus-article-wash-html t]
3414 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3415 ["Decode HZ" gnus-article-decode-HZ t]))
3417 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3419 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3421 (gnus-run-hooks 'gnus-article-menu-hook)))
3423 (defun gnus-article-mode ()
3424 "Major mode for displaying an article.
3426 All normal editing commands are switched off.
3428 The following commands are available in addition to all summary mode
3430 \\<gnus-article-mode-map>
3431 \\[gnus-article-next-page]\t Scroll the article one page forwards
3432 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3433 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3434 \\[gnus-article-show-summary]\t Display the summary buffer
3435 \\[gnus-article-mail]\t Send a reply to the address near point
3436 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3437 \\[gnus-info-find-node]\t Go to the Gnus info node"
3439 (gnus-simplify-mode-line)
3440 (setq mode-name "Article")
3441 (setq major-mode 'gnus-article-mode)
3442 (make-local-variable 'minor-mode-alist)
3443 (use-local-map gnus-article-mode-map)
3444 (when (gnus-visual-p 'article-menu 'menu)
3445 (gnus-article-make-menu-bar)
3446 (when gnus-summary-tool-bar-map
3447 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3448 (gnus-update-format-specifications nil 'article-mode)
3449 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3450 (make-local-variable 'gnus-page-broken)
3451 (make-local-variable 'gnus-button-marker-list)
3452 (make-local-variable 'gnus-article-current-summary)
3453 (make-local-variable 'gnus-article-mime-handles)
3454 (make-local-variable 'gnus-article-decoded-p)
3455 (make-local-variable 'gnus-article-mime-handle-alist)
3456 (make-local-variable 'gnus-article-wash-types)
3457 (make-local-variable 'gnus-article-image-alist)
3458 (make-local-variable 'gnus-article-charset)
3459 (make-local-variable 'gnus-article-ignored-charsets)
3460 (gnus-set-default-directory)
3461 (buffer-disable-undo)
3462 (setq buffer-read-only t)
3463 (set-syntax-table gnus-article-mode-syntax-table)
3464 (mm-enable-multibyte)
3465 (gnus-run-hooks 'gnus-article-mode-hook))
3467 (defun gnus-article-setup-buffer ()
3468 "Initialize the article buffer."
3469 (let* ((name (if gnus-single-article-buffer "*Article*"
3470 (concat "*Article " gnus-newsgroup-name "*")))
3472 (progn (string-match "\\*Article" name)
3473 (concat " *Original Article"
3474 (substring name (match-end 0))))))
3475 (setq gnus-article-buffer name)
3476 (setq gnus-original-article-buffer original)
3477 (setq gnus-article-mime-handle-alist nil)
3478 ;; This might be a variable local to the summary buffer.
3479 (unless gnus-single-article-buffer
3481 (set-buffer gnus-summary-buffer)
3482 (setq gnus-article-buffer name)
3483 (setq gnus-original-article-buffer original)
3484 (gnus-set-global-variables)))
3485 (gnus-article-setup-highlight-words)
3486 ;; Init original article buffer.
3488 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3489 (mm-enable-multibyte)
3490 (setq major-mode 'gnus-original-article-mode)
3491 (make-local-variable 'gnus-original-article))
3492 (if (get-buffer name)
3495 (when (and gnus-article-edit-mode
3498 (y-or-n-p "Article mode edit in progress; discard? ")))
3499 (error "Action aborted"))
3500 (set (make-local-variable 'gnus-article-edit-mode) nil)
3501 (when gnus-article-mime-handles
3502 (mm-destroy-parts gnus-article-mime-handles)
3503 (setq gnus-article-mime-handles nil))
3504 ;; Set it to nil in article-buffer!
3505 (setq gnus-article-mime-handle-alist nil)
3506 (buffer-disable-undo)
3507 (setq buffer-read-only t)
3508 ;; This list just keeps growing if we don't reset it.
3509 (setq gnus-button-marker-list nil)
3510 (unless (eq major-mode 'gnus-article-mode)
3511 (gnus-article-mode))
3514 (set-buffer (gnus-get-buffer-create name))
3516 (make-local-variable 'gnus-summary-buffer)
3517 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3518 (current-buffer)))))
3520 ;; Set article window start at LINE, where LINE is the number of lines
3521 ;; from the head of the article.
3522 (defun gnus-article-set-window-start (&optional line)
3524 (gnus-get-buffer-window gnus-article-buffer t)
3526 (set-buffer gnus-article-buffer)
3527 (goto-char (point-min))
3530 (gnus-message 6 "Moved to bookmark")
3531 (search-forward "\n\n" nil t)
3535 (defun gnus-article-prepare (article &optional all-headers header)
3536 "Prepare ARTICLE in article mode buffer.
3537 ARTICLE should either be an article number or a Message-ID.
3538 If ARTICLE is an id, HEADER should be the article headers.
3539 If ALL-HEADERS is non-nil, no headers are hidden."
3541 ;; Make sure we start in a summary buffer.
3542 (unless (eq major-mode 'gnus-summary-mode)
3543 (set-buffer gnus-summary-buffer))
3544 (setq gnus-summary-buffer (current-buffer))
3545 (let* ((gnus-article (if header (mail-header-number header) article))
3546 (summary-buffer (current-buffer))
3547 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3548 (group gnus-newsgroup-name)
3551 (gnus-article-setup-buffer)
3552 (set-buffer gnus-article-buffer)
3553 ;; Deactivate active regions.
3554 (when (and (boundp 'transient-mark-mode)
3555 transient-mark-mode)
3556 (setq mark-active nil))
3557 (if (not (setq result (let ((buffer-read-only nil))
3558 (gnus-request-article-this-buffer
3560 ;; There is no such article.
3562 (when (and (numberp article)
3563 (not (memq article gnus-newsgroup-sparse)))
3564 (setq gnus-article-current
3565 (cons gnus-newsgroup-name article))
3566 (set-buffer gnus-summary-buffer)
3567 (setq gnus-current-article article)
3568 (if (memq article gnus-newsgroup-undownloaded)
3570 (gnus-summary-set-agent-mark article)
3571 (message "Message marked for downloading"))
3572 (gnus-summary-mark-article article gnus-canceled-mark)
3573 (unless (memq article gnus-newsgroup-sparse)
3574 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3575 (if (or (eq result 'pseudo)
3576 (eq result 'nneething))
3579 (set-buffer summary-buffer)
3580 (push article gnus-newsgroup-history)
3581 (setq gnus-last-article gnus-current-article
3582 gnus-current-article 0
3583 gnus-current-headers nil
3584 gnus-article-current nil)
3585 (if (eq result 'nneething)
3586 (gnus-configure-windows 'summary)
3587 (gnus-configure-windows 'article))
3588 (gnus-set-global-variables))
3589 (let ((gnus-article-mime-handle-alist-1
3590 gnus-article-mime-handle-alist))
3591 (gnus-set-mode-line 'article)))
3592 ;; The result from the `request' was an actual article -
3593 ;; or at least some text that is now displayed in the
3595 (when (and (numberp article)
3596 (not (eq article gnus-current-article)))
3597 ;; Seems like a new article has been selected.
3598 ;; `gnus-current-article' must be an article number.
3600 (set-buffer summary-buffer)
3601 (push article gnus-newsgroup-history)
3602 (setq gnus-last-article gnus-current-article
3603 gnus-current-article article
3604 gnus-current-headers
3605 (gnus-summary-article-header gnus-current-article)
3606 gnus-article-current
3607 (cons gnus-newsgroup-name gnus-current-article))
3608 (unless (vectorp gnus-current-headers)
3609 (setq gnus-current-headers nil))
3610 (gnus-summary-goto-subject gnus-current-article)
3611 (when (gnus-summary-show-thread)
3612 ;; If the summary buffer really was folded, the
3613 ;; previous goto may not actually have gone to
3614 ;; the right article, but the thread root instead.
3616 (gnus-summary-goto-subject gnus-current-article))
3617 (gnus-run-hooks 'gnus-mark-article-hook)
3618 (gnus-set-mode-line 'summary)
3619 (when (gnus-visual-p 'article-highlight 'highlight)
3620 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3621 ;; Set the global newsgroup variables here.
3622 (gnus-set-global-variables)
3623 (setq gnus-have-all-headers
3624 (or all-headers gnus-show-all-headers))))
3626 (gnus-configure-windows 'article))
3627 (when (or (numberp article)
3629 (gnus-article-prepare-display)
3631 (goto-char (point-min))
3632 (setq gnus-page-broken
3633 (when gnus-break-pages
3634 (gnus-narrow-to-page)
3636 (let ((gnus-article-mime-handle-alist-1
3637 gnus-article-mime-handle-alist))
3638 (gnus-set-mode-line 'article))
3642 (set-window-point (get-buffer-window (current-buffer)) (point))
3643 (gnus-configure-windows 'article)
3647 (defun gnus-article-prepare-display ()
3648 "Make the current buffer look like a nice article."
3649 ;; Hooks for getting information from the article.
3650 ;; This hook must be called before being narrowed.
3651 (let ((gnus-article-buffer (current-buffer))
3653 (unless (eq major-mode 'gnus-article-mode)
3654 (gnus-article-mode))
3655 (setq buffer-read-only nil
3656 gnus-article-wash-types nil
3657 gnus-article-image-alist nil)
3658 (gnus-run-hooks 'gnus-tmp-internal-hook)
3659 (when gnus-display-mime-function
3660 (funcall gnus-display-mime-function))
3661 (gnus-run-hooks 'gnus-article-prepare-hook)))
3664 ;;; Gnus MIME viewing functions
3667 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3668 "Format of the MIME buttons.
3670 Valid specifiers include:
3672 %T MIME type, along with additional info
3673 %n The `name' parameter
3674 %d The description, if any
3675 %l The length of the encoded part
3676 %p The part identifier number
3677 %e Dots if the part isn't displayed
3679 General format specifiers can also be used. See Info node
3680 `(gnus)Formatting Variables'.")
3682 (defvar gnus-mime-button-line-format-alist
3683 '((?t gnus-tmp-type ?s)
3684 (?T gnus-tmp-type-long ?s)
3685 (?n gnus-tmp-name ?s)
3686 (?d gnus-tmp-description ?s)
3688 (?l gnus-tmp-length ?d)
3689 (?e gnus-tmp-dots ?s)))
3691 (defvar gnus-mime-button-commands
3692 '((gnus-article-press-button "\r" "Toggle Display")
3693 (gnus-mime-view-part "v" "View Interactively...")
3694 (gnus-mime-view-part-as-type "t" "View As Type...")
3695 (gnus-mime-view-part-as-charset "C" "View As charset...")
3696 (gnus-mime-save-part "o" "Save...")
3697 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3698 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3699 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3700 (gnus-mime-view-part-internally "E" "View Internally")
3701 (gnus-mime-view-part-externally "e" "View Externally")
3702 (gnus-mime-print-part "p" "Print")
3703 (gnus-mime-pipe-part "|" "Pipe To Command...")
3704 (gnus-mime-action-on-part "." "Take action on the part")))
3706 (defun gnus-article-mime-part-status ()
3707 (if gnus-article-mime-handle-alist-1
3708 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3710 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3713 (defvar gnus-mime-button-map
3714 (let ((map (make-sparse-keymap)))
3715 (unless (>= (string-to-number emacs-version) 21)
3716 ;; XEmacs doesn't care.
3717 (set-keymap-parent map gnus-article-mode-map))
3718 (define-key map gnus-mouse-2 'gnus-article-push-button)
3719 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3720 (dolist (c gnus-mime-button-commands)
3721 (define-key map (cadr c) (car c)))
3724 (defun gnus-mime-button-menu (event)
3725 "Construct a context-sensitive menu of MIME commands."
3727 (save-window-excursion
3728 (let ((pos (event-start event)))
3729 (select-window (posn-window pos))
3730 (goto-char (posn-point pos))
3731 (gnus-article-check-buffer)
3732 (let ((response (x-popup-menu
3734 ("" ,@(mapcar (lambda (c)
3735 (cons (caddr c) (car c)))
3736 gnus-mime-button-commands))))))
3738 (call-interactively response))))))
3740 (defun gnus-mime-view-all-parts (&optional handles)
3741 "View all the MIME parts."
3743 (save-current-buffer
3744 (set-buffer gnus-article-buffer)
3745 (let ((handles (or handles gnus-article-mime-handles))
3746 (mail-parse-charset gnus-newsgroup-charset)
3747 (mail-parse-ignored-charsets
3748 (with-current-buffer gnus-summary-buffer
3749 gnus-newsgroup-ignored-charsets)))
3751 (mm-remove-parts handles)
3752 (goto-char (point-min))
3753 (or (search-forward "\n\n") (goto-char (point-max)))
3754 (let (buffer-read-only)
3755 (delete-region (point) (point-max))
3756 (mm-display-parts handles))))))
3758 (defun gnus-mime-save-part-and-strip ()
3759 "Save the MIME part under point then replace it with an external body."
3761 (gnus-article-check-buffer)
3762 (let* ((data (get-text-property (point) 'gnus-data))
3764 (handles gnus-article-mime-handles))
3765 (if (mm-multiple-handles gnus-article-mime-handles)
3766 (error "This function is not implemented"))
3767 (setq file (and data (mm-save-part data)))
3769 (with-current-buffer (mm-handle-buffer data)
3771 (insert "Content-Type: " (mm-handle-media-type data))
3772 (mml-insert-parameter-string (cdr (mm-handle-type data))
3775 (insert "Content-ID: " (message-make-message-id) "\n")
3776 (insert "Content-Transfer-Encoding: binary\n")
3779 (cdr (mm-make-handle nil
3780 `("message/external-body"
3781 (access-type . "LOCAL-FILE")
3783 (set-buffer gnus-summary-buffer)
3784 (gnus-article-edit-article
3787 (let ((mail-parse-charset (or gnus-article-charset
3788 ',gnus-newsgroup-charset))
3789 (mail-parse-ignored-charsets
3790 (or gnus-article-ignored-charsets
3791 ',gnus-newsgroup-ignored-charsets))
3792 (mbl mml-buffer-list))
3793 (setq mml-buffer-list nil)
3794 (insert-buffer gnus-original-article-buffer)
3795 (mime-to-mml ',handles)
3796 (setq gnus-article-mime-handles nil)
3797 (let ((mbl1 mml-buffer-list))
3798 (setq mml-buffer-list mbl)
3799 (set (make-local-variable 'mml-buffer-list) mbl1))
3800 ;; LOCAL argument of add-hook differs between GNU Emacs
3801 ;; and XEmacs. make-local-hook makes sure they are local.
3802 (make-local-hook 'kill-buffer-hook)
3803 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3804 `(lambda (no-highlight)
3805 (let ((mail-parse-charset (or gnus-article-charset
3806 ',gnus-newsgroup-charset))
3807 (message-options message-options)
3808 (message-options-set-recipient)
3809 (mail-parse-ignored-charsets
3810 (or gnus-article-ignored-charsets
3811 ',gnus-newsgroup-ignored-charsets)))
3813 (mml-destroy-buffers)
3814 (remove-hook 'kill-buffer-hook
3815 'mml-destroy-buffers t)
3816 (kill-local-variable 'mml-buffer-list))
3817 (gnus-summary-edit-article-done
3818 ,(or (mail-header-references gnus-current-headers) "")
3819 ,(gnus-group-read-only-p)
3820 ,gnus-summary-buffer no-highlight))))))
3822 (defun gnus-mime-save-part ()
3823 "Save the MIME part under point."
3825 (gnus-article-check-buffer)
3826 (let ((data (get-text-property (point) 'gnus-data)))
3828 (mm-save-part data))))
3830 (defun gnus-mime-pipe-part ()
3831 "Pipe the MIME part under point to a process."
3833 (gnus-article-check-buffer)
3834 (let ((data (get-text-property (point) 'gnus-data)))
3836 (mm-pipe-part data))))
3838 (defun gnus-mime-view-part ()
3839 "Interactively choose a viewing method for the MIME part under point."
3841 (gnus-article-check-buffer)
3842 (let ((data (get-text-property (point) 'gnus-data)))
3844 (setq gnus-article-mime-handles
3846 gnus-article-mime-handles (setq data (copy-sequence data))))
3847 (mm-interactively-view-part data))))
3849 (defun gnus-mime-view-part-as-type-internal ()
3850 (gnus-article-check-buffer)
3851 (let* ((name (mail-content-type-get
3852 (mm-handle-type (get-text-property (point) 'gnus-data))
3854 (def-type (and name (mm-default-file-encoding name))))
3855 (and def-type (cons def-type 0))))
3857 (defun gnus-mime-view-part-as-type (&optional mime-type)
3858 "Choose a MIME media type, and view the part as such."
3861 (setq mime-type (completing-read
3862 "View as MIME type: "
3863 (mapcar #'list (mailcap-mime-types))
3865 (gnus-mime-view-part-as-type-internal))))
3866 (gnus-article-check-buffer)
3867 (let ((handle (get-text-property (point) 'gnus-data)))
3870 (mm-make-handle (mm-handle-buffer handle)
3871 (cons mime-type (cdr (mm-handle-type handle)))
3872 (mm-handle-encoding handle)
3873 (mm-handle-undisplayer handle)
3874 (mm-handle-disposition handle)
3875 (mm-handle-description handle)
3877 (mm-handle-id handle)))
3878 (setq gnus-article-mime-handles
3879 (mm-merge-handles gnus-article-mime-handles handle))
3880 (gnus-mm-display-part handle))))
3883 (require 'jka-compr))
3885 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
3886 ;; emacs can do that itself.
3888 (defun gnus-mime-jka-compr-maybe-uncompress ()
3889 "Uncompress the current buffer if `auto-compression-mode' is enabled.
3890 The uncompress method used is derived from `buffer-file-name'."
3891 (when (and (fboundp 'jka-compr-installed-p)
3892 (jka-compr-installed-p))
3893 (let ((info (jka-compr-get-compression-info buffer-file-name)))
3895 (let ((basename (file-name-nondirectory buffer-file-name))
3896 (args (jka-compr-info-uncompress-args info))
3897 (prog (jka-compr-info-uncompress-program info))
3898 (message (jka-compr-info-uncompress-message info))
3899 (err-file (jka-compr-make-temp-name)))
3901 (message "%s %s..." message basename))
3903 (unless (memq (apply 'call-process-region
3904 (point-min) (point-max)
3906 t (list t err-file) nil
3908 jka-compr-acceptable-retval-list)
3909 (jka-compr-error prog args basename message err-file))
3910 (jka-compr-delete-temp-file err-file)))))))
3912 (defun gnus-mime-copy-part (&optional handle)
3913 "Put the MIME part under point into a new buffer.
3914 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
3917 (gnus-article-check-buffer)
3918 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3919 (contents (and handle (mm-get-part handle)))
3921 (file-name-nondirectory
3923 (mail-content-type-get (mm-handle-type handle) 'name)
3924 (mail-content-type-get (mm-handle-disposition handle)
3927 (buffer (and base (generate-new-buffer base))))
3929 (switch-to-buffer buffer)
3931 ;; We do it this way to make `normal-mode' set the appropriate mode.
3934 (setq buffer-file-name (expand-file-name base))
3935 (gnus-mime-jka-compr-maybe-uncompress)
3937 (setq buffer-file-name nil))
3938 (goto-char (point-min)))))
3940 (defun gnus-mime-print-part (&optional handle filename)
3941 "Print the MIME part under point."
3942 (interactive (list nil (ps-print-preprint current-prefix-arg)))
3943 (gnus-article-check-buffer)
3944 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3945 (contents (and handle (mm-get-part handle)))
3946 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
3947 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
3952 (mm-save-part-to-file handle file)
3953 (call-process shell-file-name nil
3954 (generate-new-buffer " *mm*")
3956 shell-command-switch
3958 printer file (mm-handle-type handle))))
3962 (gnus-print-buffer))
3963 (ps-despool filename)))))
3965 (defun gnus-mime-inline-part (&optional handle arg)
3966 "Insert the MIME part under point into the current buffer."
3967 (interactive (list nil current-prefix-arg))
3968 (gnus-article-check-buffer)
3969 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3974 (if (and (not arg) (mm-handle-undisplayer handle))
3975 (mm-remove-part handle)
3976 (setq contents (mm-get-part handle))
3979 (setq charset (or (mail-content-type-get
3980 (mm-handle-type handle) 'charset)
3981 gnus-newsgroup-charset)))
3983 (if (mm-handle-undisplayer handle)
3984 (mm-remove-part handle))
3987 gnus-summary-show-article-charset-alist))
3988 (mm-read-coding-system "Charset: ")))))
3990 (mm-insert-inline handle
3992 (setq charset (mm-charset-to-coding-system
3994 (not (eq charset 'ascii)))
3995 (mm-decode-coding-string contents charset)
3999 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4000 "Insert the MIME part under point into the current buffer using the
4002 (interactive (list nil current-prefix-arg))
4003 (gnus-article-check-buffer)
4004 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4009 (if (mm-handle-undisplayer handle)
4010 (mm-remove-part handle))
4011 (let ((gnus-newsgroup-charset
4013 gnus-summary-show-article-charset-alist))
4014 (mm-read-coding-system "Charset: ")))
4015 (gnus-newsgroup-ignored-charsets 'gnus-all))
4016 (gnus-article-press-button)))))
4018 (defun gnus-mime-view-part-externally (&optional handle)
4019 "View the MIME part under point with an external viewer."
4021 (gnus-article-check-buffer)
4022 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4023 (mm-user-display-methods nil)
4024 (mm-inlined-types nil)
4025 (mail-parse-charset gnus-newsgroup-charset)
4026 (mail-parse-ignored-charsets
4027 (save-excursion (set-buffer gnus-summary-buffer)
4028 gnus-newsgroup-ignored-charsets)))
4030 (if (mm-handle-undisplayer handle)
4031 (mm-remove-part handle)
4032 (mm-display-part handle)))))
4034 (defun gnus-mime-view-part-internally (&optional handle)
4035 "View the MIME part under point with an internal viewer.
4036 If no internal viewer is available, use an external viewer."
4038 (gnus-article-check-buffer)
4039 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4040 (mm-inlined-types '(".*"))
4041 (mm-inline-large-images t)
4042 (mail-parse-charset gnus-newsgroup-charset)
4043 (mail-parse-ignored-charsets
4044 (save-excursion (set-buffer gnus-summary-buffer)
4045 gnus-newsgroup-ignored-charsets))
4048 (if (mm-handle-undisplayer handle)
4049 (mm-remove-part handle)
4050 (mm-display-part handle)))))
4052 (defun gnus-mime-action-on-part (&optional action)
4053 "Do something with the MIME attachment at \(point\)."
4055 (list (completing-read "Action: " gnus-mime-action-alist)))
4056 (gnus-article-check-buffer)
4057 (let ((action-pair (assoc action gnus-mime-action-alist)))
4059 (funcall (cdr action-pair)))))
4061 (defun gnus-article-part-wrapper (n function)
4062 (save-current-buffer
4063 (set-buffer gnus-article-buffer)
4064 (when (> n (length gnus-article-mime-handle-alist))
4065 (error "No such part"))
4066 (gnus-article-goto-part n)
4067 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4068 (funcall function handle))))
4070 (defun gnus-article-pipe-part (n)
4071 "Pipe MIME part N, which is the numerical prefix."
4073 (gnus-article-part-wrapper n 'mm-pipe-part))
4075 (defun gnus-article-save-part (n)
4076 "Save MIME part N, which is the numerical prefix."
4078 (gnus-article-part-wrapper n 'mm-save-part))
4080 (defun gnus-article-interactively-view-part (n)
4081 "View MIME part N interactively, which is the numerical prefix."
4083 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4085 (defun gnus-article-copy-part (n)
4086 "Copy MIME part N, which is the numerical prefix."
4088 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4090 (defun gnus-article-view-part-as-charset (n)
4091 "Copy MIME part N, which is the numerical prefix."
4093 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4095 (defun gnus-article-view-part-externally (n)
4096 "View MIME part N externally, which is the numerical prefix."
4098 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4100 (defun gnus-article-inline-part (n)
4101 "Inline MIME part N, which is the numerical prefix."
4103 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4105 (defun gnus-article-mime-match-handle-first (condition)
4107 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4108 (while (setq ihandle (pop alist))
4110 ((functionp condition)
4111 (funcall condition (cdr ihandle)))
4112 ((eq condition 'undisplayed)
4113 (not (or (mm-handle-undisplayer (cdr ihandle))
4114 (equal (mm-handle-media-type (cdr ihandle))
4115 "multipart/alternative"))))
4116 ((eq condition 'undisplayed-alternative)
4117 (not (mm-handle-undisplayer (cdr ihandle))))
4119 (gnus-article-goto-part (car ihandle))
4120 (or (not n) (< (car ihandle) n)))
4121 (setq n (car ihandle))))
4125 (defun gnus-article-view-part (&optional n)
4126 "View MIME part N, which is the numerical prefix."
4128 (save-current-buffer
4129 (set-buffer gnus-article-buffer)
4130 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4131 gnus-article-mime-match-handle-function)))
4132 (when (> n (length gnus-article-mime-handle-alist))
4133 (error "No such part"))
4134 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4135 (when (gnus-article-goto-part n)
4136 (if (equal (car handle) "multipart/alternative")
4137 (gnus-article-press-button)
4138 (when (eq (gnus-mm-display-part handle) 'internal)
4139 (gnus-set-window-start)))))))
4141 (defsubst gnus-article-mime-total-parts ()
4142 (if (bufferp (car gnus-article-mime-handles))
4144 (1- (length gnus-article-mime-handles))))
4146 (defun gnus-mm-display-part (handle)
4147 "Display HANDLE and fix MIME button."
4148 (let ((id (get-text-property (point) 'gnus-part))
4153 (let ((window (selected-window))
4154 (mail-parse-charset gnus-newsgroup-charset)
4155 (mail-parse-ignored-charsets
4156 (if (gnus-buffer-live-p gnus-summary-buffer)
4158 (set-buffer gnus-summary-buffer)
4159 gnus-newsgroup-ignored-charsets)
4163 (let ((win (gnus-get-buffer-window (current-buffer) t))
4166 (select-window win))
4169 (if (mm-handle-displayed-p handle)
4170 ;; This will remove the part.
4171 (mm-display-part handle)
4173 (narrow-to-region (point)
4174 (if (eobp) (point) (1+ (point))))
4175 (mm-display-part handle)
4176 ;; We narrow to the part itself and
4177 ;; then call the treatment functions.
4178 (goto-char (point-min))
4180 (narrow-to-region (point) (point-max))
4183 (gnus-article-mime-total-parts)
4184 (mm-handle-media-type handle)))))
4185 (if (window-live-p window)
4186 (select-window window)))))
4188 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4189 (gnus-insert-mime-button
4190 handle id (list (mm-handle-displayed-p handle)))
4191 (goto-char point))))
4193 (defun gnus-article-goto-part (n)
4194 "Go to MIME part N."
4195 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4197 (goto-char point))))
4199 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4200 (let ((gnus-tmp-name
4201 (or (mail-content-type-get (mm-handle-type handle) 'name)
4202 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4203 (mail-content-type-get (mm-handle-type handle) 'url)
4205 (gnus-tmp-type (mm-handle-media-type handle))
4206 (gnus-tmp-description
4207 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4210 (if (if displayed (car displayed)
4211 (mm-handle-displayed-p handle))
4213 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4215 gnus-tmp-type-long b e)
4216 (when (string-match ".*/" gnus-tmp-name)
4217 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4218 (setq gnus-tmp-type-long (concat gnus-tmp-type
4219 (and (not (equal gnus-tmp-name ""))
4220 (concat "; " gnus-tmp-name))))
4221 (unless (equal gnus-tmp-description "")
4222 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4227 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4228 `(,@(gnus-local-map-property gnus-mime-button-map)
4229 gnus-callback gnus-mm-display-part
4230 gnus-part ,gnus-tmp-id
4231 article-type annotation
4234 (widget-convert-button
4237 :action 'gnus-widget-press-button
4238 :button-keymap gnus-mime-button-map
4240 (lambda (widget/window &optional overlay pos)
4241 ;; Needed to properly clear the message due to a bug in
4242 ;; wid-edit (XEmacs only).
4243 (if (boundp 'help-echo-owns-message)
4244 (setq help-echo-owns-message t))
4246 "%S: %s the MIME part; %S: more options"
4247 (aref gnus-mouse-2 0)
4248 ;; XEmacs will get a single widget arg; Emacs 21 will get
4249 ;; window, overlay, position.
4250 (if (mm-handle-displayed-p
4252 (with-current-buffer (gnus-overlay-buffer overlay)
4253 (widget-get (widget-at (gnus-overlay-start overlay))
4255 (widget-get widget/window :mime-handle)))
4257 (aref gnus-down-mouse-3 0))))))
4259 (defun gnus-widget-press-button (elems el)
4260 (goto-char (widget-get elems :from))
4261 (gnus-article-press-button))
4263 (defvar gnus-displaying-mime nil)
4265 (defun gnus-display-mime (&optional ihandles)
4266 "Display the MIME parts."
4268 (save-selected-window
4269 (let ((window (get-buffer-window gnus-article-buffer))
4272 (select-window window)
4273 ;; We have to do this since selecting the window
4274 ;; may change the point. So we set the window point.
4275 (set-window-point window point)))
4276 (let* ((handles (or ihandles
4277 (mm-dissect-buffer nil gnus-article-loose-mime)
4278 (and gnus-article-emulate-mime
4280 buffer-read-only handle name type b e display)
4281 (when (and (not ihandles)
4282 (not gnus-displaying-mime))
4283 ;; Top-level call; we clean up.
4284 (when gnus-article-mime-handles
4285 (mm-destroy-parts gnus-article-mime-handles)
4286 (setq gnus-article-mime-handle-alist nil));; A trick.
4287 (setq gnus-article-mime-handles handles)
4288 ;; We allow users to glean info from the handles.
4289 (when gnus-article-mime-part-function
4290 (gnus-mime-part-function handles)))
4292 (or (not (stringp (car handles)))
4295 (when (and (not ihandles)
4296 (not gnus-displaying-mime))
4297 ;; Clean up for mime parts.
4299 (delete-region (point) (point-max)))
4300 (let ((gnus-displaying-mime t))
4301 (gnus-mime-display-part handles)))
4304 (narrow-to-region (point) (point-max))
4305 (gnus-treat-article nil 1 1)
4308 ;; Highlight the headers.
4312 (narrow-to-region (point-min) (point))
4313 (gnus-treat-article 'head))))))))
4315 (defvar gnus-mime-display-multipart-as-mixed nil)
4316 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4317 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4319 (defun gnus-mime-display-part (handle)
4322 ((not (stringp (car handle)))
4323 (gnus-mime-display-single handle))
4324 ;; User-defined multipart
4325 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4326 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4328 ;; multipart/alternative
4329 ((and (equal (car handle) "multipart/alternative")
4330 (not (or gnus-mime-display-multipart-as-mixed
4331 gnus-mime-display-multipart-alternative-as-mixed)))
4332 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4333 (push (cons id handle) gnus-article-mime-handle-alist)
4334 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4335 ;; multipart/related
4336 ((and (equal (car handle) "multipart/related")
4337 (not (or gnus-mime-display-multipart-as-mixed
4338 gnus-mime-display-multipart-related-as-mixed)))
4339 ;;;!!!We should find the start part, but we just default
4340 ;;;!!!to the first part.
4341 ;;(gnus-mime-display-part (cadr handle))
4342 ;;;!!! Most multipart/related is an HTML message plus images.
4343 ;;;!!! Unfortunately we are unable to let W3 display those
4344 ;;;!!! included images, so we just display it as a mixed multipart.
4345 ;;(gnus-mime-display-mixed (cdr handle))
4346 ;;;!!! No, w3 can display everything just fine.
4347 (gnus-mime-display-part (cadr handle)))
4348 ((equal (car handle) "multipart/signed")
4349 (gnus-add-wash-type 'signed)
4350 (gnus-mime-display-security handle))
4351 ((equal (car handle) "multipart/encrypted")
4352 (gnus-add-wash-type 'encrypted)
4353 (gnus-mime-display-security handle))
4354 ;; Other multiparts are handled like multipart/mixed.
4356 (gnus-mime-display-mixed (cdr handle)))))
4358 (defun gnus-mime-part-function (handles)
4359 (if (stringp (car handles))
4360 (mapcar 'gnus-mime-part-function (cdr handles))
4361 (funcall gnus-article-mime-part-function handles)))
4363 (defun gnus-mime-display-mixed (handles)
4364 (mapcar 'gnus-mime-display-part handles))
4366 (defun gnus-mime-display-single (handle)
4367 (let ((type (mm-handle-media-type handle))
4368 (ignored gnus-ignored-mime-types)
4375 (when (string-match (pop ignored) type)
4376 (throw 'ignored nil)))
4377 (if (and (setq not-attachment
4378 (and (not (mm-inline-override-p handle))
4379 (or (not (mm-handle-disposition handle))
4380 (equal (car (mm-handle-disposition handle))
4382 (mm-attachment-override-p handle))))
4383 (mm-automatic-display-p handle)
4385 (mm-inlinable-p handle)
4386 (mm-inlined-p handle))
4387 (mm-automatic-external-display-p type)))
4389 (when (equal (mm-handle-media-supertype handle) "text")
4391 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4393 (push (cons id handle) gnus-article-mime-handle-alist)
4394 (when (or (not display)
4395 (not (gnus-unbuttonized-mime-type-p type)))
4396 ;(gnus-article-insert-newline)
4397 (gnus-insert-mime-button
4398 handle id (list (or display (and not-attachment text))))
4399 (gnus-article-insert-newline)
4400 ;(gnus-article-insert-newline)
4401 ;; Remember modify the number of forward lines.
4409 (let ((mail-parse-charset gnus-newsgroup-charset)
4410 (mail-parse-ignored-charsets
4411 (save-excursion (condition-case ()
4412 (set-buffer gnus-summary-buffer)
4414 gnus-newsgroup-ignored-charsets)))
4415 (mm-display-part handle t))
4416 (goto-char (point-max)))
4417 ((and text not-attachment)
4421 (gnus-article-insert-newline)
4422 (mm-insert-inline handle (mm-get-part handle))
4423 (goto-char (point-max))))
4427 (narrow-to-region beg (point))
4430 (gnus-article-mime-total-parts)
4431 (mm-handle-media-type handle)))))))))
4433 (defun gnus-unbuttonized-mime-type-p (type)
4434 "Say whether TYPE is to be unbuttonized."
4435 (unless gnus-inhibit-mime-unbuttonizing
4437 (let ((types gnus-unbuttonized-mime-types))
4439 (when (string-match (pop types) type)
4440 (throw 'found t)))))
4442 (let ((types gnus-buttonized-mime-types))
4444 (when (string-match (pop types) type)
4445 (throw 'found t)))))))))
4447 (defun gnus-article-insert-newline ()
4448 "Insert a newline, but mark it as undeletable."
4449 (gnus-put-text-property
4450 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4452 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4453 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4456 handle buffer-read-only from props begend not-pref)
4457 (save-window-excursion
4460 (narrow-to-region (car ibegend)
4463 (goto-char (car ibegend))
4466 (delete-region (point-min) (point-max))
4467 (mm-remove-parts handles))
4468 (setq begend (list (point-marker)))
4470 (unless (setq not-pref (cadr (member preferred ihandles)))
4471 (setq not-pref (car ihandles)))
4474 (not (gnus-unbuttonized-mime-type-p
4475 "multipart/alternative")))
4476 (gnus-add-text-properties
4479 (insert (format "%d. " id))
4483 (unless ,(not ibegend)
4484 (setq gnus-article-mime-handle-alist
4485 ',gnus-article-mime-handle-alist))
4486 (gnus-mime-display-alternative
4487 ',ihandles ',not-pref ',begend ,id))
4488 ,@(gnus-local-map-property gnus-mime-button-map)
4489 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4490 face ,gnus-article-button-face
4493 (widget-convert-button 'link from (point)
4494 :action 'gnus-widget-press-button
4495 :button-keymap gnus-widget-button-keymap)
4497 (while (setq handle (pop handles))
4498 (gnus-add-text-properties
4501 (insert (format "(%c) %-18s"
4502 (if (equal handle preferred) ?* ? )
4503 (mm-handle-media-type handle)))
4507 (unless ,(not ibegend)
4508 (setq gnus-article-mime-handle-alist
4509 ',gnus-article-mime-handle-alist))
4510 (gnus-mime-display-alternative
4511 ',ihandles ',handle ',begend ,id))
4512 ,@(gnus-local-map-property gnus-mime-button-map)
4513 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4514 face ,gnus-article-button-face
4517 (widget-convert-button 'link from (point)
4518 :action 'gnus-widget-press-button
4519 :button-keymap gnus-widget-button-keymap)
4523 (if (stringp (car preferred))
4524 (gnus-display-mime preferred)
4525 (let ((mail-parse-charset gnus-newsgroup-charset)
4526 (mail-parse-ignored-charsets
4527 (save-excursion (set-buffer gnus-summary-buffer)
4528 gnus-newsgroup-ignored-charsets)))
4529 (mm-display-part preferred)
4533 (narrow-to-region (car begend) (point-max))
4535 nil (length gnus-article-mime-handle-alist)
4536 (gnus-article-mime-total-parts)
4537 (mm-handle-media-type handle))))))
4538 (goto-char (point-max))
4539 (setcdr begend (point-marker)))))
4541 (goto-char point))))
4543 (defconst gnus-article-wash-status-strings
4544 (let ((alist '((cite "c" "Possible hidden citation text"
4545 " " "All citation text visible")
4546 (headers "h" "Hidden headers"
4547 " " "All headers visible.")
4548 (pgp "p" "Encrypted or signed message status hidden"
4549 " " "No hidden encryption nor digital signature status")
4550 (signature "s" "Signature has been hidden"
4551 " " "Signature is visible")
4552 (overstrike "o" "Overstrike (^H) characters applied"
4553 " " "No overstrike characters applied")
4554 (emphasis "e" "/*_Emphasis_*/ characters applied"
4555 " " "No /*_emphasis_*/ characters applied")))
4557 (dolist (entry alist result)
4558 (let ((key (nth 0 entry))
4559 (on (copy-sequence (nth 1 entry)))
4560 (on-help (nth 2 entry))
4561 (off (copy-sequence (nth 3 entry)))
4562 (off-help (nth 4 entry)))
4563 (put-text-property 0 1 'help-echo on-help on)
4564 (put-text-property 0 1 'help-echo off-help off)
4565 (push (list key on off) result))))
4566 "Alist of strings describing wash status in the mode line.
4567 Each entry has the form (KEY ON OF), where the KEY is a symbol
4568 representing the particular washing function, ON is the string to use
4569 in the article mode line when the washing function is active, and OFF
4570 is the string to use when it is inactive.")
4572 (defun gnus-article-wash-status-entry (key value)
4573 (let ((entry (assoc key gnus-article-wash-status-strings)))
4574 (if value (nth 1 entry) (nth 2 entry))))
4576 (defun gnus-article-wash-status ()
4577 "Return a string which display status of article washing."
4579 (set-buffer gnus-article-buffer)
4580 (let ((cite (memq 'cite gnus-article-wash-types))
4581 (headers (memq 'headers gnus-article-wash-types))
4582 (boring (memq 'boring-headers gnus-article-wash-types))
4583 (pgp (memq 'pgp gnus-article-wash-types))
4584 (pem (memq 'pem gnus-article-wash-types))
4585 (signed (memq 'signed gnus-article-wash-types))
4586 (encrypted (memq 'encrypted gnus-article-wash-types))
4587 (signature (memq 'signature gnus-article-wash-types))
4588 (overstrike (memq 'overstrike gnus-article-wash-types))
4589 (emphasis (memq 'emphasis gnus-article-wash-types)))
4591 (gnus-article-wash-status-entry 'cite cite)
4592 (gnus-article-wash-status-entry 'headers (or headers boring))
4593 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4594 (gnus-article-wash-status-entry 'signature signature)
4595 (gnus-article-wash-status-entry 'overstrike overstrike)
4596 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4598 (defun gnus-add-wash-type (type)
4599 "Add a washing of TYPE to the current status."
4600 (add-to-list 'gnus-article-wash-types type))
4602 (defun gnus-delete-wash-type (type)
4603 "Add a washing of TYPE to the current status."
4604 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4606 (defun gnus-add-image (category image)
4607 "Add IMAGE of CATEGORY to the list of displayed images."
4608 (let ((entry (assq category gnus-article-image-alist)))
4610 (setq entry (list category))
4611 (push entry gnus-article-image-alist))
4612 (nconc entry (list image))))
4614 (defun gnus-delete-images (category)
4615 "Delete all images in CATEGORY."
4616 (let ((entry (assq category gnus-article-image-alist)))
4617 (dolist (image (cdr entry))
4618 (gnus-remove-image image))
4619 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4620 (gnus-delete-wash-type category)))
4622 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4624 (defun gnus-article-maybe-hide-headers ()
4625 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4626 Provided for backwards compatibility."
4627 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4628 (not (save-excursion (set-buffer gnus-summary-buffer)
4629 gnus-have-all-headers)))
4630 (not gnus-inhibit-hiding))
4631 (gnus-article-hide-headers)))
4635 (defun gnus-output-to-file (file-name)
4636 "Append the current article to a file named FILE-NAME."
4637 (let ((artbuf (current-buffer)))
4639 (insert-buffer-substring artbuf)
4640 ;; Append newline at end of the buffer as separator, and then
4642 (goto-char (point-max))
4644 (let ((file-name-coding-system nnmail-pathname-coding-system))
4645 (mm-append-to-file (point-min) (point-max) file-name))
4648 (defun gnus-narrow-to-page (&optional arg)
4649 "Narrow the article buffer to a page.
4650 If given a numerical ARG, move forward ARG pages."
4652 (setq arg (if arg (prefix-numeric-value arg) 0))
4654 (set-buffer gnus-article-buffer)
4655 (goto-char (point-min))
4657 ;; Remove any old next/prev buttons.
4658 (when (gnus-visual-p 'page-marker)
4659 (let ((buffer-read-only nil))
4660 (gnus-remove-text-with-property 'gnus-prev)
4661 (gnus-remove-text-with-property 'gnus-next)))
4664 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4666 (re-search-forward page-delimiter nil 'move arg)))
4667 (goto-char (match-end 0)))
4670 (if (re-search-forward page-delimiter nil 'move)
4673 (when (and (gnus-visual-p 'page-marker)
4674 (not (= (point-min) 1)))
4676 (goto-char (point-min))
4677 (gnus-insert-prev-page-button)))
4678 (when (and (gnus-visual-p 'page-marker)
4679 (< (+ (point-max) 2) (buffer-size)))
4681 (goto-char (point-max))
4682 (gnus-insert-next-page-button)))))
4684 ;; Article mode commands
4686 (defun gnus-article-goto-next-page ()
4687 "Show the next page of the article."
4689 (when (gnus-article-next-page)
4690 (goto-char (point-min))
4691 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4693 (defun gnus-article-goto-prev-page ()
4694 "Show the next page of the article."
4696 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4697 (gnus-article-prev-page nil)))
4699 (defun gnus-article-next-page (&optional lines)
4700 "Show the next page of the current article.
4701 If end of article, return non-nil. Otherwise return nil.
4702 Argument LINES specifies lines to be scrolled up."
4704 (move-to-window-line -1)
4707 (and (pos-visible-in-window-p) ;Not continuation line.
4708 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
4709 ;; Nothing in this page.
4710 (if (or (not gnus-page-broken)
4713 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4715 (gnus-narrow-to-page 1) ;Go to next page.
4717 ;; More in this page.
4718 (let ((scroll-in-place nil))
4722 ;; Long lines may cause an end-of-buffer error.
4723 (goto-char (point-max)))))
4724 (move-to-window-line 0)
4727 (defun gnus-article-prev-page (&optional lines)
4728 "Show previous page of current article.
4729 Argument LINES specifies lines to be scrolled down."
4731 (move-to-window-line 0)
4732 (if (and gnus-page-broken
4734 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4736 (gnus-narrow-to-page -1) ;Go to previous page.
4737 (goto-char (point-max))
4739 (let ((scroll-in-place nil))
4743 (beginning-of-buffer
4744 (goto-char (point-min))))
4745 (move-to-window-line 0)))))
4747 (defun gnus-article-only-boring-p ()
4748 "Decide whether there is only boring text remaining in the article.
4749 Something \"interesting\" is a word of at least two letters that does
4750 not have a face in `gnus-article-boring-faces'."
4751 (when (and gnus-article-skip-boring
4752 gnus-article-boring-faces)
4755 (while (re-search-forward "\\b\\w\\w" nil t)
4757 (when (not (gnus-intersection
4758 (cons (plist-get (text-properties-at (point))
4762 (extent-property extent 'face))
4763 nil (current-buffer) (point) (point)))
4764 gnus-article-boring-faces))
4765 (throw 'only-boring nil)))
4766 (throw 'only-boring t)))))
4768 (defun gnus-article-refer-article ()
4769 "Read article specified by message-id around point."
4771 (let ((point (point)))
4772 (search-forward ">" nil t) ;Move point to end of "<....>".
4773 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4774 (let ((message-id (gnus-replace-in-string (match-string 1) "<news:" "<" )))
4776 (set-buffer gnus-summary-buffer)
4777 (gnus-summary-refer-article message-id))
4779 (error "No references around point"))))
4781 (defun gnus-article-show-summary ()
4782 "Reconfigure windows to show summary buffer."
4784 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4785 (error "There is no summary buffer for this article buffer")
4786 (gnus-article-set-globals)
4787 (gnus-configure-windows 'article)
4788 (gnus-summary-goto-subject gnus-current-article)
4789 (gnus-summary-position-point)))
4791 (defun gnus-article-describe-briefly ()
4792 "Describe article mode commands briefly."
4794 (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")))
4796 (defun gnus-article-summary-command ()
4797 "Execute the last keystroke in the summary buffer."
4799 (let ((obuf (current-buffer))
4800 (owin (current-window-configuration))
4802 (switch-to-buffer gnus-article-current-summary 'norecord)
4803 (setq func (lookup-key (current-local-map) (this-command-keys)))
4804 (call-interactively func)
4806 (set-window-configuration owin)
4807 (set-window-point (get-buffer-window (current-buffer)) (point))))
4809 (defun gnus-article-summary-command-nosave ()
4810 "Execute the last keystroke in the summary buffer."
4813 (pop-to-buffer gnus-article-current-summary 'norecord)
4814 (setq func (lookup-key (current-local-map) (this-command-keys)))
4815 (call-interactively func)))
4817 (defun gnus-article-check-buffer ()
4818 "Beep if not in an article buffer."
4819 (unless (equal major-mode 'gnus-article-mode)
4820 (error "Command invoked outside of a Gnus article buffer")))
4822 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4823 "Read a summary buffer key sequence and execute it from the article buffer."
4825 (gnus-article-check-buffer)
4827 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4828 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4829 "=" "^" "\M-^" "|"))
4835 '("n" "Gn" "p" "Gp"))
4838 (set-buffer gnus-article-current-summary)
4839 (let (gnus-pick-mode)
4840 (push (or key last-command-event) unread-command-events)
4841 (setq keys (if (featurep 'xemacs)
4842 (events-to-keys (read-key-sequence nil))
4843 (read-key-sequence nil)))))
4847 (if (or (member keys nosaves)
4848 (member keys nosave-but-article)
4849 (member keys nosave-in-article))
4851 (save-window-excursion
4852 (pop-to-buffer gnus-article-current-summary 'norecord)
4853 ;; We disable the pick minor mode commands.
4854 (let (gnus-pick-mode)
4855 (setq func (lookup-key (current-local-map) keys))))
4859 (unless (member keys nosave-in-article)
4860 (set-buffer gnus-article-current-summary))
4861 (call-interactively func)
4862 (setq new-sum-point (point)))
4863 (when (member keys nosave-but-article)
4864 (pop-to-buffer gnus-article-buffer 'norecord)))
4865 ;; These commands should restore window configuration.
4866 (let ((obuf (current-buffer))
4867 (owin (current-window-configuration))
4869 (summary gnus-article-current-summary)
4870 func in-buffer selected)
4871 (if not-restore-window
4872 (pop-to-buffer summary 'norecord)
4873 (switch-to-buffer summary 'norecord))
4874 (setq in-buffer (current-buffer))
4875 ;; We disable the pick minor mode commands.
4876 (if (and (setq func (let (gnus-pick-mode)
4877 (lookup-key (current-local-map) keys)))
4880 (call-interactively func)
4881 (setq new-sum-point (point))
4882 (when (eq in-buffer (current-buffer))
4883 (setq selected (gnus-summary-select-article))
4885 (unless not-restore-window
4886 (set-window-configuration owin))
4887 (when (eq selected 'old)
4889 (set-window-start (get-buffer-window (current-buffer))
4891 (set-window-point (get-buffer-window (current-buffer))
4893 (let ((win (get-buffer-window gnus-article-current-summary)))
4895 (set-window-point win new-sum-point)))) )
4896 (switch-to-buffer gnus-article-buffer)
4899 (defun gnus-article-describe-key (key)
4900 "Display documentation of the function invoked by KEY. KEY is a string."
4901 (interactive "kDescribe key: ")
4902 (gnus-article-check-buffer)
4903 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4905 (set-buffer gnus-article-current-summary)
4906 (let (gnus-pick-mode)
4907 (if (featurep 'xemacs)
4909 (push (elt key 0) unread-command-events)
4910 (setq key (events-to-keys
4911 (read-key-sequence "Describe key: "))))
4912 (setq unread-command-events
4914 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4915 (string-to-list key)))
4916 (setq key (read-key-sequence "Describe key: "))))
4918 (describe-key key)))
4920 (defun gnus-article-describe-key-briefly (key &optional insert)
4921 "Display documentation of the function invoked by KEY. KEY is a string."
4922 (interactive "kDescribe key: \nP")
4923 (gnus-article-check-buffer)
4924 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4926 (set-buffer gnus-article-current-summary)
4927 (let (gnus-pick-mode)
4928 (if (featurep 'xemacs)
4930 (push (elt key 0) unread-command-events)
4931 (setq key (events-to-keys
4932 (read-key-sequence "Describe key: "))))
4933 (setq unread-command-events
4935 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4936 (string-to-list key)))
4937 (setq key (read-key-sequence "Describe key: "))))
4938 (describe-key-briefly key insert))
4939 (describe-key-briefly key insert)))
4941 (defun gnus-article-reply-with-original (&optional wide)
4942 "Start composing a reply mail to the current message.
4943 The text in the region will be yanked. If the region isn't active,
4944 the entire article will be yanked."
4946 (let ((article (cdr gnus-article-current))
4948 (if (not (gnus-mark-active-p))
4949 (with-current-buffer gnus-summary-buffer
4950 (gnus-summary-reply (list (list article)) wide))
4951 (setq contents (buffer-substring (point) (mark t)))
4952 ;; Deactivate active regions.
4953 (when (and (boundp 'transient-mark-mode)
4954 transient-mark-mode)
4955 (setq mark-active nil))
4956 (with-current-buffer gnus-summary-buffer
4958 (list (list article contents)) wide)))))
4960 (defun gnus-article-followup-with-original ()
4961 "Compose a followup to the current article.
4962 The text in the region will be yanked. If the region isn't active,
4963 the entire article will be yanked."
4965 (let ((article (cdr gnus-article-current))
4967 (if (not (gnus-mark-active-p))
4968 (with-current-buffer gnus-summary-buffer
4969 (gnus-summary-followup (list (list article))))
4970 (setq contents (buffer-substring (point) (mark t)))
4971 ;; Deactivate active regions.
4972 (when (and (boundp 'transient-mark-mode)
4973 transient-mark-mode)
4974 (setq mark-active nil))
4975 (with-current-buffer gnus-summary-buffer
4976 (gnus-summary-followup
4977 (list (list article contents)))))))
4979 (defun gnus-article-hide (&optional arg force)
4980 "Hide all the gruft in the current article.
4981 This means that signatures, cited text and (some) headers will be
4983 If given a prefix, show the hidden text instead."
4984 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4985 (gnus-article-hide-headers arg)
4986 (gnus-article-hide-list-identifiers arg)
4987 (gnus-article-hide-citation-maybe arg force)
4988 (gnus-article-hide-signature arg))
4990 (defun gnus-article-maybe-highlight ()
4991 "Do some article highlighting if article highlighting is requested."
4992 (when (gnus-visual-p 'article-highlight 'highlight)
4993 (gnus-article-highlight-some)))
4995 (defun gnus-check-group-server ()
4996 ;; Make sure the connection to the server is alive.
4997 (unless (gnus-server-opened
4998 (gnus-find-method-for-group gnus-newsgroup-name))
4999 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5000 (gnus-request-group gnus-newsgroup-name t)))
5003 (autoload 'nneething-get-file-name "nneething"))
5005 (defun gnus-request-article-this-buffer (article group)
5006 "Get an article and insert it into this buffer."
5007 (let (do-update-line sparse-header)
5011 (gnus-kill-all-overlays)
5012 (setq group (or group gnus-newsgroup-name))
5014 ;; Using `gnus-request-article' directly will insert the article into
5015 ;; `nntp-server-buffer' - so we'll save some time by not having to
5016 ;; copy it from the server buffer into the article buffer.
5018 ;; We only request an article by message-id when we do not have the
5019 ;; headers for it, so we'll have to get those.
5020 (when (stringp article)
5021 (gnus-read-header article))
5023 ;; If the article number is negative, that means that this article
5024 ;; doesn't belong in this newsgroup (possibly), so we find its
5025 ;; message-id and request it by id instead of number.
5026 (when (and (numberp article)
5028 (get-buffer gnus-summary-buffer)
5029 (gnus-buffer-exists-p gnus-summary-buffer))
5031 (set-buffer gnus-summary-buffer)
5032 (let ((header (gnus-summary-article-header article)))
5035 ((memq article gnus-newsgroup-sparse)
5036 ;; This is a sparse gap article.
5037 (setq do-update-line article)
5038 (setq article (mail-header-id header))
5039 (setq sparse-header (gnus-read-header article))
5040 (setq gnus-newsgroup-sparse
5041 (delq article gnus-newsgroup-sparse)))
5043 ;; It's a real article.
5044 (setq article (mail-header-id header)))
5046 ;; It is an extracted pseudo-article.
5047 (setq article 'pseudo)
5048 (gnus-request-pseudo-article header))))
5050 (let ((method (gnus-find-method-for-group
5051 gnus-newsgroup-name)))
5052 (when (and (eq (car method) 'nneething)
5054 (let ((dir (nneething-get-file-name
5055 (mail-header-id header))))
5056 (when (and (stringp dir)
5057 (file-directory-p dir))
5058 (setq article 'nneething)
5059 (gnus-group-enter-directory dir))))))))
5062 ;; Refuse to select canceled articles.
5063 ((and (numberp article)
5065 (get-buffer gnus-summary-buffer)
5066 (gnus-buffer-exists-p gnus-summary-buffer)
5067 (eq (cdr (save-excursion
5068 (set-buffer gnus-summary-buffer)
5069 (assq article gnus-newsgroup-reads)))
5070 gnus-canceled-mark))
5072 ;; We first check `gnus-original-article-buffer'.
5073 ((and (get-buffer gnus-original-article-buffer)
5076 (set-buffer gnus-original-article-buffer)
5077 (and (equal (car gnus-original-article) group)
5078 (eq (cdr gnus-original-article) article))))
5079 (insert-buffer-substring gnus-original-article-buffer)
5081 ;; Check the backlog.
5082 ((and gnus-keep-backlog
5083 (gnus-backlog-request-article group article (current-buffer)))
5085 ;; Check asynchronous pre-fetch.
5086 ((gnus-async-request-fetched-article group article (current-buffer))
5087 (gnus-async-prefetch-next group article gnus-summary-buffer)
5088 (when (and (numberp article) gnus-keep-backlog)
5089 (gnus-backlog-enter-article group article (current-buffer)))
5092 ((and gnus-use-cache
5094 (gnus-cache-request-article article group))
5096 ;; Check the agent cache.
5097 ((and gnus-agent gnus-agent-cache gnus-plugged
5099 (gnus-agent-request-article article group))
5101 ;; Get the article and put into the article buffer.
5102 ((or (stringp article)
5104 (let ((gnus-override-method gnus-override-method)
5105 (methods (and (stringp article)
5106 gnus-refer-article-method))
5107 (backend (car (gnus-find-method-for-group
5108 gnus-newsgroup-name)))
5110 (buffer-read-only nil))
5111 (if (or (not (listp methods))
5112 (and (symbolp (car methods))
5113 (assq (car methods) nnoo-definition-alist)))
5114 (setq methods (list methods)))
5115 (when (and (null gnus-override-method)
5117 (setq gnus-override-method (pop methods)))
5119 (when (eq gnus-override-method 'current)
5120 (setq gnus-override-method
5121 (with-current-buffer gnus-summary-buffer
5122 gnus-current-select-method)))
5124 (gnus-kill-all-overlays)
5125 (let ((gnus-newsgroup-name group))
5126 (gnus-check-group-server))
5128 ((gnus-request-article article group (current-buffer))
5129 (when (numberp article)
5130 (gnus-async-prefetch-next group article
5131 gnus-summary-buffer)
5132 (when gnus-keep-backlog
5133 (gnus-backlog-enter-article
5134 group article (current-buffer))))
5135 (setq result 'article))
5137 (setq gnus-override-method (pop methods)))
5138 ((not (string-match "^400 "
5139 (nnheader-get-report backend)))
5140 ;; If we get 400 server disconnect, reconnect and
5141 ;; retry; otherwise, assume the article has expired.
5142 (setq result 'done))))
5143 (and (eq result 'article) 'article)))
5147 ;; Associate this article with the current summary buffer.
5148 (setq gnus-article-current-summary gnus-summary-buffer)
5150 ;; Take the article from the original article buffer
5151 ;; and place it in the buffer it's supposed to be in.
5152 (when (and (get-buffer gnus-article-buffer)
5153 (equal (buffer-name (current-buffer))
5154 (buffer-name (get-buffer gnus-article-buffer))))
5156 (if (get-buffer gnus-original-article-buffer)
5157 (set-buffer gnus-original-article-buffer)
5158 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5159 (buffer-disable-undo)
5160 (setq major-mode 'gnus-original-article-mode)
5161 (setq buffer-read-only t))
5162 (let (buffer-read-only)
5164 (insert-buffer-substring gnus-article-buffer))
5165 (setq gnus-original-article (cons group article)))
5168 (run-hooks 'gnus-article-decode-hook)
5169 ;; Mark article as decoded or not.
5170 (setq gnus-article-decoded-p gnus-article-decode-hook))
5172 ;; Update sparse articles.
5173 (when (and do-update-line
5174 (or (numberp article)
5176 (let ((buf (current-buffer)))
5177 (set-buffer gnus-summary-buffer)
5178 (gnus-summary-update-article do-update-line sparse-header)
5179 (gnus-summary-goto-subject do-update-line nil t)
5180 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5182 (set-buffer buf))))))
5188 (defcustom gnus-article-edit-mode-hook nil
5189 "Hook run in article edit mode buffers."
5190 :group 'gnus-article-various
5193 (defvar gnus-article-edit-done-function nil)
5195 (defvar gnus-article-edit-mode-map nil)
5196 (defvar gnus-article-edit-mode nil)
5198 ;; Should we be using derived.el for this?
5199 (unless gnus-article-edit-mode-map
5200 (setq gnus-article-edit-mode-map (make-keymap))
5201 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5203 (gnus-define-keys gnus-article-edit-mode-map
5204 "\C-c?" describe-mode
5205 "\C-c\C-c" gnus-article-edit-done
5206 "\C-c\C-k" gnus-article-edit-exit
5207 "\C-c\C-f\C-t" message-goto-to
5208 "\C-c\C-f\C-o" message-goto-from
5209 "\C-c\C-f\C-b" message-goto-bcc
5210 ;;"\C-c\C-f\C-w" message-goto-fcc
5211 "\C-c\C-f\C-c" message-goto-cc
5212 "\C-c\C-f\C-s" message-goto-subject
5213 "\C-c\C-f\C-r" message-goto-reply-to
5214 "\C-c\C-f\C-n" message-goto-newsgroups
5215 "\C-c\C-f\C-d" message-goto-distribution
5216 "\C-c\C-f\C-f" message-goto-followup-to
5217 "\C-c\C-f\C-m" message-goto-mail-followup-to
5218 "\C-c\C-f\C-k" message-goto-keywords
5219 "\C-c\C-f\C-u" message-goto-summary
5220 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5221 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5222 "\C-c\C-b" message-goto-body
5223 "\C-c\C-i" message-goto-signature
5225 "\C-c\C-t" message-insert-to
5226 "\C-c\C-n" message-insert-newsgroups
5227 "\C-c\C-o" message-sort-headers
5228 "\C-c\C-e" message-elide-region
5229 "\C-c\C-v" message-delete-not-region
5230 "\C-c\C-z" message-kill-to-signature
5231 "\M-\r" message-newline-and-reformat
5232 "\C-c\C-a" mml-attach-file
5233 "\C-a" message-beginning-of-line
5235 "\M-;" comment-region)
5237 (gnus-define-keys (gnus-article-edit-wash-map
5238 "\C-c\C-w" gnus-article-edit-mode-map)
5239 "f" gnus-article-edit-full-stops))
5242 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5244 ["Fetch To" message-insert-to t]
5245 ["Fetch Newsgroups" message-insert-newsgroups t]
5247 ["To" message-goto-to t]
5248 ["From" message-goto-from t]
5249 ["Subject" message-goto-subject t]
5250 ["Cc" message-goto-cc t]
5251 ["Reply-To" message-goto-reply-to t]
5252 ["Summary" message-goto-summary t]
5253 ["Keywords" message-goto-keywords t]
5254 ["Newsgroups" message-goto-newsgroups t]
5255 ["Followup-To" message-goto-followup-to t]
5256 ["Mail-Followup-To" message-goto-mail-followup-to t]
5257 ["Distribution" message-goto-distribution t]
5258 ["Body" message-goto-body t]
5259 ["Signature" message-goto-signature t]))
5261 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5262 "Major mode for editing articles.
5263 This is an extended text-mode.
5265 \\{gnus-article-edit-mode-map}"
5266 (make-local-variable 'gnus-article-edit-done-function)
5267 (make-local-variable 'gnus-prev-winconf)
5268 (set (make-local-variable 'font-lock-defaults)
5269 '(message-font-lock-keywords t))
5270 (set (make-local-variable 'mail-header-separator) "")
5271 (set (make-local-variable 'gnus-article-edit-mode) t)
5272 (easy-menu-add message-mode-field-menu message-mode-map)
5274 (setq buffer-read-only nil)
5275 (buffer-enable-undo)
5278 (defun gnus-article-edit (&optional force)
5279 "Edit the current article.
5280 This will have permanent effect only in mail groups.
5281 If FORCE is non-nil, allow editing of articles even in read-only
5284 (when (and (not force)
5285 (gnus-group-read-only-p))
5286 (error "The current newsgroup does not support article editing"))
5287 (gnus-article-date-original)
5288 (gnus-article-edit-article
5290 `(lambda (no-highlight)
5292 (gnus-summary-edit-article-done
5293 ,(or (mail-header-references gnus-current-headers) "")
5294 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5296 (defun gnus-article-edit-article (start-func exit-func)
5297 "Start editing the contents of the current article buffer."
5298 (let ((winconf (current-window-configuration)))
5299 (set-buffer gnus-article-buffer)
5300 (gnus-article-edit-mode)
5301 (funcall start-func)
5302 (set-buffer-modified-p nil)
5303 (gnus-configure-windows 'edit-article)
5304 (setq gnus-article-edit-done-function exit-func)
5305 (setq gnus-prev-winconf winconf)
5306 (gnus-message 6 "C-c C-c to end edits")))
5308 (defun gnus-article-edit-done (&optional arg)
5309 "Update the article edits and exit."
5311 (let ((func gnus-article-edit-done-function)
5312 (buf (current-buffer))
5313 (start (window-start))
5315 (winconf gnus-prev-winconf))
5316 (widen) ;; Widen it in case that users narrowed the buffer.
5319 ;; The cache and backlog have to be flushed somewhat.
5320 (when gnus-keep-backlog
5321 (gnus-backlog-remove-article
5322 (car gnus-article-current) (cdr gnus-article-current)))
5323 ;; Flush original article as well.
5325 (when (get-buffer gnus-original-article-buffer)
5326 (set-buffer gnus-original-article-buffer)
5327 (setq gnus-original-article nil)))
5328 (when gnus-use-cache
5329 (gnus-cache-update-article
5330 (car gnus-article-current) (cdr gnus-article-current)))
5331 ;; We remove all text props from the article buffer.
5332 (kill-all-local-variables)
5333 (gnus-set-text-properties (point-min) (point-max) nil)
5335 (set-window-configuration winconf)
5337 (set-window-start (get-buffer-window buf) start)
5338 (set-window-point (get-buffer-window buf) (point))))
5340 (defun gnus-article-edit-exit ()
5341 "Exit the article editing without updating."
5343 (when (or (not (buffer-modified-p))
5344 (yes-or-no-p "Article modified; kill anyway? "))
5345 (let ((curbuf (current-buffer))
5347 (window-start (window-start)))
5349 (if (gnus-buffer-live-p gnus-original-article-buffer)
5350 (insert-buffer gnus-original-article-buffer))
5351 (let ((winconf gnus-prev-winconf))
5352 (kill-all-local-variables)
5354 (set-window-configuration winconf)
5355 ;; Tippy-toe some to make sure that point remains where it was.
5356 (save-current-buffer
5358 (set-window-start (get-buffer-window (current-buffer)) window-start)
5361 (defun gnus-article-edit-full-stops ()
5362 "Interactively repair spacing at end of sentences."
5365 (goto-char (point-min))
5366 (search-forward-regexp "^$" nil t)
5367 (let ((case-fold-search nil))
5368 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5371 ;;; Article highlights
5374 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5376 ;;; Internal Variables:
5378 (defcustom gnus-button-url-regexp
5379 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5380 "\\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:]]\\)"
5381 "\\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\\)\\)")
5382 "Regular expression that matches URLs."
5383 :group 'gnus-article-buttons
5386 (defcustom gnus-button-valid-fqdn-regexp
5387 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
5389 "\\([a-z][a-z]" ;; two letter country TDLs
5390 "\\|biz\\|com\\|edu\\|gov\\|int\\|mil\\|net\\|org"
5391 "\\|aero\\|coop\\|info\\|name\\|museum"
5392 "\\|arpa\\|pro\\|uucp\\|bitnet\\|bofh" ;; old style?
5394 "Regular expression that matches a valid FQDN."
5395 :group 'gnus-article-buttons
5398 (defcustom gnus-button-man-handler 'manual-entry
5399 "Function to use for displaying man pages.
5400 The function must take at least one argument with a string naming the
5402 :type '(choice (function-item :tag "Man" manual-entry)
5403 (function-item :tag "Woman" woman)
5404 (function :tag "Other"))
5405 :group 'gnus-article-buttons)
5407 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5408 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5409 If the default site is too slow, try to find a CTAN mirror, see
5410 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5411 the variable `gnus-button-handle-ctan'."
5412 :group 'gnus-article-buttons
5413 :link '(custom-manual "(gnus)Group Parameters")
5414 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5415 (const "http://tug.ctan.org/tex-archive/")
5416 (const "http://www.dante.de/CTAN/")
5417 (string :tag "Other")))
5419 (defcustom gnus-button-ctan-handler 'browse-url
5420 "Function to use for displaying CTAN links.
5421 The function must take one argument, the string naming the URL."
5422 :type '(choice (function-item :tag "Browse Url" browse-url)
5423 (function :tag "Other"))
5424 :group 'gnus-article-buttons)
5426 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5427 "Bogus strings removed from CTAN URLs."
5428 :group 'gnus-article-buttons
5429 :type '(choice (const "^/?tex-archive/\\|/")
5430 (regexp :tag "Other")))
5432 (defcustom gnus-button-mid-or-mail-regexp
5433 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
5434 gnus-button-valid-fqdn-regexp
5436 "Regular expression that matches a message ID or a mail address."
5437 :group 'gnus-article-buttons
5440 (defcustom gnus-button-prefer-mid-or-mail 'guess
5441 "What to do when the button on a string as \"foo123@bar.com\" is pushed.
5442 Strings like this can be either a message ID or a mail address. If the
5443 variable is set to the symbol `ask', query the user what do do. If it is the
5444 symbol `guess', Gnus will do a guess and query the user what do do if it is
5445 ambiguous. See the variable `gnus-button-guessed-mid-regexp' for details
5446 concerning the guessing. If it is one of the sybols `mid' or `mail', Gnus
5447 will always assume that the string is a message ID or a mail address,
5449 ;; FIXME: doc-string could/should be improved.
5450 :group 'gnus-article-buttons
5451 :type '(choice (const ask)
5456 (defcustom gnus-button-guessed-mid-regexp
5458 "^<?\\(slrn\\|Pine\\.\\)"
5459 "\\|\\.fsf@\\|\\.fsf_-_@\\|\\.ln@"
5460 "\\|@4ax\\.com\\|@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de"
5461 "\\|^<?.*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*@")
5462 "Regular expression that matches message IDs and not mail addresses."
5463 ;; TODO: Incorporate more matches from
5464 ;; <URL:http://piology.org/perl/id-or-mail.pl.html>. I.e. translate the
5465 ;; Perl-REs to Elisp-REs.
5466 :group 'gnus-article-buttons
5469 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5470 (let* ((pref gnus-button-prefer-mid-or-mail)
5471 (url-mid (concat "news" ":" mid-or-mail))
5472 (url-mailto (concat "mailto" ":" mid-or-mail)))
5473 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5474 ;; If it looks like a MID (well known readers or servers) use 'mid,
5475 ;; otherwise 'ask the user.
5476 (if (eq pref 'guess)
5477 (if (string-match gnus-button-guessed-mid-regexp mid-or-mail)
5481 (save-window-excursion
5482 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5485 (cond ((eq pref 'mid)
5486 (gnus-message 9 "calling `gnus-button-handle-news' %s" url-mid)
5487 (gnus-button-handle-news url-mid))
5489 (gnus-message 9 "calling `gnus-url-mailto' %s" url-mailto)
5490 (gnus-url-mailto url-mailto)))))
5492 (defun gnus-button-handle-custom (url)
5493 "Follow a Custom URL."
5494 (customize-apropos (gnus-url-unhex-string url)))
5496 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5498 (defun gnus-button-handle-describe-function (url)
5499 "Call `describe-function' when pushing the corresponding URL button."
5502 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5504 (defun gnus-button-handle-describe-variable (url)
5505 "Call `describe-variable' when pushing the corresponding URL button."
5508 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5510 (defun gnus-button-handle-describe-key (url)
5511 "Call `describe-key' when pushing the corresponding URL button."
5513 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5514 (keys (ignore-errors (eval `(kbd ,key-string)))))
5517 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5519 (defun gnus-button-handle-apropos (url)
5520 "Call `apropos' when pushing the corresponding URL button."
5521 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5523 (defun gnus-button-handle-apropos-command (url)
5524 "Call `apropos' when pushing the corresponding URL button."
5526 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5528 (defun gnus-button-handle-apropos-variable (url)
5529 "Call `apropos' when pushing the corresponding URL button."
5531 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5532 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5534 (defun gnus-button-handle-apropos-documentation (url)
5535 "Call `apropos' when pushing the corresponding URL button."
5537 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
5538 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5540 (defun gnus-button-handle-ctan (url)
5541 "Call `browse-url' when pushing a CTAN URL button."
5543 gnus-button-ctan-handler
5546 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
5548 (defcustom gnus-button-tex-level 5
5549 "*Integer that says how many TeX-related buttons Gnus will show.
5550 The higher the number, the more buttons will appear and the more false
5551 positives are possible. Note that you can set this variable local to
5552 specifific groups. Setting it higher in TeX groups is probably a good idea.
5553 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5554 how to set variables in specific groups."
5555 :group 'gnus-article-buttons
5556 :link '(custom-manual "(gnus)Group Parameters")
5559 (defcustom gnus-button-man-level 5
5560 "*Integer that says how many man-related buttons Gnus will show.
5561 The higher the number, the more buttons will appear and the more false
5562 positives are possible. Note that you can set this variable local to
5563 specifific groups. Setting it higher in Unix groups is probably a good idea.
5564 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5565 how to set variables in specific groups."
5566 :group 'gnus-article-buttons
5567 :link '(custom-manual "(gnus)Group Parameters")
5570 (defcustom gnus-button-emacs-level 5
5571 "*Integer that says how many emacs-related buttons Gnus will show.
5572 The higher the number, the more buttons will appear and the more false
5573 positives are possible. Note that you can set this variable local to
5574 specifific groups. Setting it higher in Emacs or Gnus related groups is
5575 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
5576 `gnus-parameters' on how to set variables in specific groups."
5577 :group 'gnus-article-buttons
5578 :link '(custom-manual "(gnus)Group Parameters")
5581 (defcustom gnus-button-mail-level 5
5582 "*Integer that says how many buttons for message IDs or mail addresses will appear.
5583 The higher the number, the more buttons will appear and the more false
5584 positives are possible."
5585 :group 'gnus-article-buttons
5588 (defcustom gnus-button-alist
5589 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5590 0 t gnus-button-handle-news 3)
5591 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5592 gnus-button-handle-news 2)
5593 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5595 gnus-button-fetch-group 4)
5596 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5597 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5598 t gnus-button-message-id 3)
5599 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5600 ("mailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5601 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5603 ("\\bCTAN:[ \t\n]*\\([^>)!;:,\n\t ]*\\)" 0 (>= gnus-button-tex-level 1)
5604 gnus-button-handle-ctan 1)
5606 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5607 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2)
5609 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5610 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
5611 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5612 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
5613 ;; Emacs help commands
5614 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5615 ;; regexp doesn't match arguments containing ` '.
5616 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
5617 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5618 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
5619 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5620 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
5621 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5622 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
5623 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5624 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
5625 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5626 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
5627 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'" 1
5628 ;; Unlike the other regexps we really have to require quoting
5629 ;; here to determine where it ends.
5630 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
5631 ;; This is how URLs _should_ be embedded in text...
5632 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5634 (gnus-button-url-regexp 0 t browse-url 0)
5636 ("\\b\\([a-z][a-z]+\\)([1-9])\\W" 0
5637 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
5638 gnus-button-handle-man 1)
5639 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
5640 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W" 0
5641 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
5642 gnus-button-handle-man 1)
5643 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
5644 ;; SoWWWAnchor(3iv), XSelectInput(3X11)
5645 ("\\b\\([a-z][-_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W" 0
5646 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
5647 ;; MID or mail: To avoid too many false positives we don't try to catch
5648 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
5649 ;; at least one dot. TLD must contain two or three chars or be a know TLD
5650 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
5651 ;; so that non-ambiguous entries (see above) match first.
5652 (gnus-button-mid-or-mail-regexp
5653 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1))
5654 "*Alist of regexps matching buttons in article bodies.
5656 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5657 REGEXP: is the string (case insensitive) matching text around the button (can
5658 also be lisp expression evaluating to a string),
5659 BUTTON: is the number of the regexp grouping actually matching the button,
5660 FORM: is a lisp expression which must eval to true for the button to
5662 CALLBACK: is the function to call when the user push this button, and each
5663 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5665 CALLBACK can also be a variable, in that case the value of that
5666 variable it the real callback function."
5667 :group 'gnus-article-buttons
5668 :type '(repeat (list (choice regexp variable)
5669 (integer :tag "Button")
5671 (function :tag "Callback")
5674 (integer :tag "Regexp group")))))
5676 (defcustom gnus-header-button-alist
5677 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5678 0 t gnus-button-message-id 0)
5679 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5680 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5681 0 t gnus-button-mailto 0)
5682 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
5683 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
5684 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
5685 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5686 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5687 gnus-button-message-id 3))
5688 "*Alist of headers and regexps to match buttons in article heads.
5690 This alist is very similar to `gnus-button-alist', except that each
5691 alist has an additional HEADER element first in each entry:
5693 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5695 HEADER is a regexp to match a header. For a fuller explanation, see
5696 `gnus-button-alist'."
5697 :group 'gnus-article-buttons
5698 :group 'gnus-article-headers
5699 :type '(repeat (list (regexp :tag "Header")
5701 (integer :tag "Button")
5703 (function :tag "Callback")
5706 (integer :tag "Regexp group")))))
5708 (defvar gnus-button-regexp nil)
5709 (defvar gnus-button-marker-list nil)
5710 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5712 (defvar gnus-button-last nil)
5713 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5717 (defun gnus-article-push-button (event)
5718 "Check text under the mouse pointer for a callback function.
5719 If the text under the mouse pointer has a `gnus-callback' property,
5720 call it with the value of the `gnus-data' text property."
5722 (set-buffer (window-buffer (posn-window (event-start event))))
5723 (let* ((pos (posn-point (event-start event)))
5724 (data (get-text-property pos 'gnus-data))
5725 (fun (get-text-property pos 'gnus-callback)))
5728 (funcall fun data))))
5730 (defun gnus-article-press-button ()
5731 "Check text at point for a callback function.
5732 If the text at point has a `gnus-callback' property,
5733 call it with the value of the `gnus-data' text property."
5735 (let ((data (get-text-property (point) 'gnus-data))
5736 (fun (get-text-property (point) 'gnus-callback)))
5738 (funcall fun data))))
5740 (defun gnus-article-highlight (&optional force)
5741 "Highlight current article.
5742 This function calls `gnus-article-highlight-headers',
5743 `gnus-article-highlight-citation',
5744 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5745 do the highlighting. See the documentation for those functions."
5746 (interactive (list 'force))
5747 (gnus-article-highlight-headers)
5748 (gnus-article-highlight-citation force)
5749 (gnus-article-highlight-signature)
5750 (gnus-article-add-buttons force)
5751 (gnus-article-add-buttons-to-head))
5753 (defun gnus-article-highlight-some (&optional force)
5754 "Highlight current article.
5755 This function calls `gnus-article-highlight-headers',
5756 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5757 do the highlighting. See the documentation for those functions."
5758 (interactive (list 'force))
5759 (gnus-article-highlight-headers)
5760 (gnus-article-highlight-signature)
5761 (gnus-article-add-buttons))
5763 (defun gnus-article-highlight-headers ()
5764 "Highlight article headers as specified by `gnus-header-face-alist'."
5767 (set-buffer gnus-article-buffer)
5769 (let ((alist gnus-header-face-alist)
5770 (buffer-read-only nil)
5771 (case-fold-search t)
5772 (inhibit-point-motion-hooks t)
5773 entry regexp header-face field-face from hpoints fpoints)
5774 (article-narrow-to-head)
5775 (while (setq entry (pop alist))
5776 (goto-char (point-min))
5777 (setq regexp (concat "^\\("
5778 (if (string-equal "" (nth 0 entry))
5782 header-face (nth 1 entry)
5783 field-face (nth 2 entry))
5784 (while (and (re-search-forward regexp nil t)
5788 (unless (search-forward ":" nil t)
5790 (when (and header-face
5791 (not (memq (point) hpoints)))
5792 (push (point) hpoints)
5793 (gnus-put-text-property from (point) 'face header-face))
5794 (when (and field-face
5795 (not (memq (setq from (point)) fpoints)))
5797 (if (re-search-forward "^[^ \t]" nil t)
5799 (goto-char (point-max)))
5800 (gnus-put-text-property from (point) 'face field-face))))))))
5802 (defun gnus-article-highlight-signature ()
5803 "Highlight the signature in an article.
5804 It does this by highlighting everything after
5805 `gnus-signature-separator' using `gnus-signature-face'."
5808 (set-buffer gnus-article-buffer)
5809 (let ((buffer-read-only nil)
5810 (inhibit-point-motion-hooks t))
5812 (when (and gnus-signature-face
5813 (gnus-article-narrow-to-signature))
5814 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5815 'face gnus-signature-face)
5817 (gnus-article-search-signature)
5818 (let ((start (match-beginning 0))
5819 (end (set-marker (make-marker) (1+ (match-end 0)))))
5820 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5823 (defun gnus-button-in-region-p (b e prop)
5824 "Say whether PROP exists in the region."
5825 (text-property-not-all b e prop nil))
5827 (defun gnus-article-add-buttons (&optional force)
5828 "Find external references in the article and make buttons of them.
5829 \"External references\" are things like Message-IDs and URLs, as
5830 specified by `gnus-button-alist'."
5831 (interactive (list 'force))
5833 (set-buffer gnus-article-buffer)
5834 (let ((buffer-read-only nil)
5835 (inhibit-point-motion-hooks t)
5836 (case-fold-search t)
5837 (alist gnus-button-alist)
5839 ;; Remove all old markers.
5840 (let (marker entry new-list)
5841 (while (setq marker (pop gnus-button-marker-list))
5842 (if (or (< marker (point-min)) (>= marker (point-max)))
5843 (push marker new-list)
5845 (when (setq entry (gnus-button-entry))
5846 (put-text-property (match-beginning (nth 1 entry))
5847 (match-end (nth 1 entry))
5848 'gnus-callback nil))
5849 (set-marker marker nil)))
5850 (setq gnus-button-marker-list new-list))
5851 ;; We skip the headers.
5854 (while (setq entry (pop alist))
5855 (setq regexp (eval (car entry)))
5857 (while (re-search-forward regexp nil t)
5858 (let* ((start (and entry (match-beginning (nth 1 entry))))
5859 (end (and entry (match-end (nth 1 entry))))
5860 (from (match-beginning 0)))
5861 (when (and (or (eq t (nth 2 entry))
5862 (eval (nth 2 entry)))
5863 (not (gnus-button-in-region-p
5864 start end 'gnus-callback)))
5865 ;; That optional form returned non-nil, so we add the
5867 (gnus-article-add-button
5868 start end 'gnus-button-push
5869 (car (push (set-marker (make-marker) from)
5870 gnus-button-marker-list))))))))))
5872 ;; Add buttons to the head of an article.
5873 (defun gnus-article-add-buttons-to-head ()
5874 "Add buttons to the head of the article."
5877 (set-buffer gnus-article-buffer)
5879 (let ((buffer-read-only nil)
5880 (inhibit-point-motion-hooks t)
5881 (case-fold-search t)
5882 (alist gnus-header-button-alist)
5884 (article-narrow-to-head)
5886 ;; Each alist entry.
5887 (setq entry (car alist)
5889 (goto-char (point-min))
5890 (while (re-search-forward (car entry) nil t)
5891 ;; Each header matching the entry.
5892 (setq beg (match-beginning 0))
5893 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5894 (match-beginning 0))
5897 (while (re-search-forward (eval (nth 1 entry)) end t)
5898 ;; Each match within a header.
5899 (let* ((entry (cdr entry))
5900 (start (match-beginning (nth 1 entry)))
5901 (end (match-end (nth 1 entry)))
5902 (form (nth 2 entry)))
5903 (goto-char (match-end 0))
5905 (gnus-article-add-button
5906 start end (nth 3 entry)
5907 (buffer-substring (match-beginning (nth 4 entry))
5908 (match-end (nth 4 entry)))))))
5909 (goto-char end)))))))
5911 ;;; External functions:
5913 (defun gnus-article-add-button (from to fun &optional data)
5914 "Create a button between FROM and TO with callback FUN and data DATA."
5915 (when gnus-article-button-face
5916 (gnus-overlay-put (gnus-make-overlay from to)
5917 'face gnus-article-button-face))
5918 (gnus-add-text-properties
5920 (nconc (and gnus-article-mouse-face
5921 (list gnus-mouse-face-prop gnus-article-mouse-face))
5922 (list 'gnus-callback fun)
5923 (and data (list 'gnus-data data))))
5924 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5925 :button-keymap gnus-widget-button-keymap))
5927 ;;; Internal functions:
5929 (defun gnus-article-set-globals ()
5931 (set-buffer gnus-summary-buffer)
5932 (gnus-set-global-variables)))
5934 (defun gnus-signature-toggle (end)
5936 (set-buffer gnus-article-buffer)
5937 (let ((buffer-read-only nil)
5938 (inhibit-point-motion-hooks t))
5939 (if (text-property-any end (point-max) 'article-type 'signature)
5941 (gnus-delete-wash-type 'signature)
5942 (gnus-remove-text-properties-when
5943 'article-type 'signature end (point-max)
5944 (cons 'article-type (cons 'signature
5945 gnus-hidden-properties))))
5946 (gnus-add-wash-type 'signature)
5947 (gnus-add-text-properties-when
5948 'article-type nil end (point-max)
5949 (cons 'article-type (cons 'signature
5950 gnus-hidden-properties)))))
5951 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5952 (gnus-set-mode-line 'article))))
5954 (defun gnus-button-entry ()
5955 ;; Return the first entry in `gnus-button-alist' matching this place.
5956 (let ((alist gnus-button-alist)
5959 (setq entry (pop alist))
5960 (if (looking-at (eval (car entry)))
5965 (defun gnus-button-push (marker)
5966 ;; Push button starting at MARKER.
5969 (let* ((entry (gnus-button-entry))
5970 (inhibit-point-motion-hooks t)
5972 (args (mapcar (lambda (group)
5973 (let ((string (match-string group)))
5974 (gnus-set-text-properties
5975 0 (length string) nil string)
5982 (fboundp (symbol-value fun)))
5983 (apply (symbol-value fun) args))
5985 (gnus-message 1 "You must define `%S' to use this button"
5986 (cons fun args)))))))
5988 (defun gnus-parse-news-url (url)
5989 (let (scheme server group message-id articles)
5992 (goto-char (point-min))
5993 (when (looking-at "\\([A-Za-z]+\\):")
5994 (setq scheme (match-string 1))
5995 (goto-char (match-end 0)))
5996 (when (looking-at "//\\([^/]+\\)/")
5997 (setq server (match-string 1))
5998 (goto-char (match-end 0)))
6001 ((looking-at "\\(.*@.*\\)")
6002 (setq message-id (match-string 1)))
6003 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6004 (setq group (match-string 1)
6005 articles (split-string (match-string 2) "-")))
6006 ((looking-at "\\([^/]+\\)/?")
6007 (setq group (match-string 1)))
6009 (error "Unknown news URL syntax"))))
6010 (list scheme server group message-id articles)))
6012 (defun gnus-button-handle-news (url)
6014 (destructuring-bind (scheme server group message-id articles)
6015 (gnus-parse-news-url url)
6019 (set-buffer gnus-summary-buffer)
6021 (let ((gnus-refer-article-method (list (list 'nntp server))))
6022 (gnus-summary-refer-article message-id))
6023 (gnus-summary-refer-article message-id))))
6025 (gnus-button-fetch-group url)))))
6027 (defun gnus-button-handle-man (url)
6029 (funcall gnus-button-man-handler url))
6031 (defun gnus-button-handle-info (url)
6032 "Fetch an info URL."
6034 "^\\([^:/]+\\)?/\\(.*\\)"
6036 (gnus-info-find-node
6037 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6040 (gnus-url-unhex-string (match-string 2 url))))
6041 (error "Can't parse %s" url)))
6043 (defun gnus-button-message-id (message-id)
6046 (set-buffer gnus-summary-buffer)
6047 (gnus-summary-refer-article message-id)))
6049 (defun gnus-button-fetch-group (address)
6050 "Fetch GROUP specified by ADDRESS."
6051 (if (not (string-match "[:/]" address))
6052 ;; This is just a simple group url.
6053 (gnus-group-read-ephemeral-group address gnus-select-method)
6056 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6058 (error "Can't parse %s" address)
6059 (gnus-group-read-ephemeral-group
6060 (match-string 4 address)
6061 `(nntp ,(match-string 1 address)
6062 (nntp-address ,(match-string 1 address))
6063 (nntp-port-number ,(if (match-end 3)
6064 (match-string 3 address)
6067 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6069 (defun gnus-url-parse-query-string (query &optional downcase)
6070 (let (retval pairs cur key val)
6071 (setq pairs (split-string query "&"))
6073 (setq cur (car pairs)
6075 (if (not (string-match "=" cur))
6077 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6078 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6080 (setq key (downcase key)))
6081 (setq cur (assoc key retval))
6083 (setcdr cur (cons val (cdr cur)))
6084 (setq retval (cons (list key val) retval)))))
6087 (defun gnus-url-mailto (url)
6088 ;; Send mail to someone
6089 (when (string-match "mailto:/*\\(.*\\)" url)
6090 (setq url (substring url (match-beginning 1) nil)))
6091 (let (to args subject func)
6092 (if (string-match (regexp-quote "?") url)
6093 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6094 args (gnus-url-parse-query-string
6095 (substring url (match-end 0) nil) t))
6096 (setq to (gnus-url-unhex-string url)))
6097 (setq args (cons (list "to" to) args)
6098 subject (cdr-safe (assoc "subject" args)))
6101 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6104 (message-position-on-field (caar args)))
6105 (insert (mapconcat 'identity (cdar args) ", "))
6106 (setq args (cdr args)))
6109 (message-goto-subject))))
6111 (defun gnus-button-embedded-url (address)
6112 "Activate ADDRESS with `browse-url'."
6113 (browse-url (gnus-strip-whitespace address)))
6115 ;;; Next/prev buttons in the article buffer.
6117 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6118 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6120 (defvar gnus-prev-page-map
6121 (let ((map (make-sparse-keymap)))
6122 (unless (>= emacs-major-version 21)
6123 ;; XEmacs doesn't care.
6124 (set-keymap-parent map gnus-article-mode-map))
6125 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6126 (define-key map "\r" 'gnus-button-prev-page)
6129 (defun gnus-insert-prev-page-button ()
6131 (buffer-read-only nil))
6133 gnus-prev-page-line-format nil
6134 `(,@(gnus-local-map-property gnus-prev-page-map)
6136 gnus-callback gnus-article-button-prev-page
6137 article-type annotation))
6138 (widget-convert-button
6140 :action 'gnus-button-prev-page
6141 :button-keymap gnus-prev-page-map)))
6143 (defvar gnus-prev-page-map
6144 (let ((map (make-sparse-keymap)))
6145 (unless (>= emacs-major-version 21)
6146 ;; XEmacs doesn't care.
6147 (set-keymap-parent map gnus-article-mode-map))
6148 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6149 (define-key map "\r" 'gnus-button-prev-page)
6152 (defvar gnus-next-page-map
6153 (let ((map (make-sparse-keymap)))
6154 (unless (>= emacs-major-version 21)
6155 ;; XEmacs doesn't care.
6156 (set-keymap-parent map gnus-article-mode-map))
6157 (define-key map gnus-mouse-2 'gnus-button-next-page)
6158 (define-key map "\r" 'gnus-button-next-page)
6161 (defun gnus-button-next-page (&optional args more-args)
6162 "Go to the next page."
6164 (let ((win (selected-window)))
6165 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6166 (gnus-article-next-page)
6167 (select-window win)))
6169 (defun gnus-button-prev-page (&optional args more-args)
6170 "Go to the prev page."
6172 (let ((win (selected-window)))
6173 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6174 (gnus-article-prev-page)
6175 (select-window win)))
6177 (defun gnus-insert-next-page-button ()
6179 (buffer-read-only nil))
6180 (gnus-eval-format gnus-next-page-line-format nil
6181 `(,@(gnus-local-map-property gnus-next-page-map)
6183 gnus-callback gnus-article-button-next-page
6184 article-type annotation))
6185 (widget-convert-button
6187 :action 'gnus-button-next-page
6188 :button-keymap gnus-next-page-map)))
6190 (defun gnus-article-button-next-page (arg)
6191 "Go to the next page."
6193 (let ((win (selected-window)))
6194 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6195 (gnus-article-next-page)
6196 (select-window win)))
6198 (defun gnus-article-button-prev-page (arg)
6199 "Go to the prev page."
6201 (let ((win (selected-window)))
6202 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6203 (gnus-article-prev-page)
6204 (select-window win)))
6206 (defvar gnus-decode-header-methods
6207 '(mail-decode-encoded-word-region)
6208 "List of methods used to decode headers.
6210 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6211 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6212 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6213 whose names match REGEXP.
6216 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6217 mail-decode-encoded-word-region
6218 (\"chinese\" . rfc1843-decode-region))
6221 (defvar gnus-decode-header-methods-cache nil)
6223 (defun gnus-multi-decode-header (start end)
6224 "Apply the functions from `gnus-encoded-word-methods' that match."
6225 (unless (and gnus-decode-header-methods-cache
6226 (eq gnus-newsgroup-name
6227 (car gnus-decode-header-methods-cache)))
6228 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6231 (nconc gnus-decode-header-methods-cache (list x))
6232 (if (and gnus-newsgroup-name
6233 (string-match (car x) gnus-newsgroup-name))
6234 (nconc gnus-decode-header-methods-cache
6236 gnus-decode-header-methods))
6237 (let ((xlist gnus-decode-header-methods-cache))
6240 (narrow-to-region start end)
6242 (funcall (pop xlist) (point-min) (point-max))))))
6245 ;;; Treatment top-level handling.
6248 (defun gnus-treat-article (condition &optional part-number total-parts type)
6249 (let ((length (- (point-max) (point-min)))
6250 (alist gnus-treatment-function-alist)
6251 (article-goto-body-goes-to-point-min-p t)
6255 (let ((list gnus-article-treat-types))
6257 (when (string-match (pop list) type)
6258 (throw 'found t)))))))
6259 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6261 (gnus-run-hooks 'gnus-part-display-hook)
6262 (dolist (elem alist)
6265 (when (gnus-buffer-live-p gnus-summary-buffer)
6266 (set-buffer gnus-summary-buffer))
6267 (symbol-value (car elem))))
6268 (when (and (or (consp val)
6270 (gnus-treat-predicate val)
6271 (or (not (get (car elem) 'highlight))
6274 (funcall (cadr elem)))))))
6276 ;; Dynamic variables.
6278 (defvar part-number)
6279 (defvar total-parts)
6284 (defun gnus-treat-predicate (val)
6291 (stringp (car val)))
6292 (apply 'gnus-or (mapcar `(lambda (s)
6293 (string-match s ,(or gnus-newsgroup-name "")))
6296 (let ((pred (pop val)))
6299 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6301 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6303 (not (gnus-treat-predicate (car val))))
6305 (equal (car val) type))
6307 (error "%S is not a valid predicate" pred)))))
6313 (eq part-number total-parts))
6317 (error "%S is not a valid value" val))))
6319 (defun gnus-article-encrypt-body (protocol &optional n)
6320 "Encrypt the article body."
6323 (or gnus-article-encrypt-protocol
6324 (completing-read "Encrypt protocol: "
6325 gnus-article-encrypt-protocol-alist
6327 current-prefix-arg))
6328 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6330 (error (format "Can't find the encrypt protocol %s" protocol)))
6331 (if (member gnus-newsgroup-name '("nndraft:delayed"
6334 (error "Can't encrypt the article in group %s"
6335 gnus-newsgroup-name))
6336 (gnus-summary-iterate n
6338 (set-buffer gnus-summary-buffer)
6339 (let ((mail-parse-charset gnus-newsgroup-charset)
6340 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6341 (summary-buffer gnus-summary-buffer)
6343 (gnus-set-global-variables)
6344 (when (gnus-group-read-only-p)
6345 (error "The current newsgroup does not support article encrypt"))
6346 (gnus-summary-show-article t)
6348 (or (mail-header-references gnus-current-headers) ""))
6349 (set-buffer gnus-article-buffer)
6350 (let* ((buffer-read-only nil)
6352 (mapcar (lambda (field)
6353 (and (save-restriction
6354 (message-narrow-to-head)
6355 (goto-char (point-min))
6356 (search-forward field nil t))
6358 (message-narrow-to-field)
6359 (buffer-substring (point-min) (point-max))
6360 (delete-region (point-min) (point-max))
6362 '("Content-Type:" "Content-Transfer-Encoding:"
6363 "Content-Disposition:"))))
6364 (message-narrow-to-head)
6365 (message-remove-header "MIME-Version")
6366 (goto-char (point-max))
6367 (setq point (point))
6368 (insert (apply 'concat headers))
6370 (narrow-to-region point (point-max))
6371 (let ((message-options message-options))
6372 (message-options-set 'message-sender user-mail-address)
6373 (message-options-set 'message-recipients user-mail-address)
6374 (message-options-set 'message-sign-encrypt 'not)
6376 (goto-char (point-min))
6377 (insert "MIME-Version: 1.0\n")
6379 (gnus-summary-edit-article-done
6380 references nil summary-buffer t))
6381 (when gnus-keep-backlog
6382 (gnus-backlog-remove-article
6383 (car gnus-article-current) (cdr gnus-article-current)))
6385 (when (get-buffer gnus-original-article-buffer)
6386 (set-buffer gnus-original-article-buffer)
6387 (setq gnus-original-article nil)))
6388 (when gnus-use-cache
6389 (gnus-cache-update-article
6390 (car gnus-article-current) (cdr gnus-article-current))))))))
6392 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6393 "The following specs can be used:
6394 %t The security MIME type
6397 %D Details if button is pressed")
6399 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6400 "The following specs can be used:
6401 %t The security MIME type
6404 %D Details if button is pressed")
6406 (defvar gnus-mime-security-button-line-format-alist
6407 '((?t gnus-tmp-type ?s)
6408 (?i gnus-tmp-info ?s)
6409 (?d gnus-tmp-details ?s)
6410 (?D gnus-tmp-pressed-details ?s)))
6412 (defvar gnus-mime-security-button-map
6413 (let ((map (make-sparse-keymap)))
6414 (unless (>= (string-to-number emacs-version) 21)
6415 (set-keymap-parent map gnus-article-mode-map))
6416 (define-key map gnus-mouse-2 'gnus-article-push-button)
6417 (define-key map "\r" 'gnus-article-press-button)
6420 (defvar gnus-mime-security-details-buffer nil)
6422 (defvar gnus-mime-security-button-pressed nil)
6424 (defvar gnus-mime-security-show-details-inline t
6425 "If non-nil, show details in the article buffer.")
6427 (defun gnus-mime-security-verify-or-decrypt (handle)
6428 (mm-remove-parts (cdr handle))
6429 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6430 point buffer-read-only)
6432 (goto-char (car region)))
6434 (narrow-to-region (point) (point))
6435 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6436 (let* ((mm-verify-option 'known)
6437 (mm-decrypt-option 'known)
6438 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6439 (unless (eq nparts (cdr handle))
6440 (mm-destroy-parts (cdr handle))
6441 (setcdr handle nparts))))
6442 (setq point (point))
6443 (gnus-mime-display-security handle)
6444 (goto-char (point-max)))
6446 (delete-region (point) (cdr region))
6447 (set-marker (car region) nil)
6448 (set-marker (cdr region) nil))
6451 (defun gnus-mime-security-show-details (handle)
6452 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6454 (gnus-message 5 "No details.")
6455 (if gnus-mime-security-show-details-inline
6456 (let ((gnus-mime-security-button-pressed
6457 (not (get-text-property (point) 'gnus-mime-details)))
6458 (gnus-mime-security-button-line-format
6459 (get-text-property (point) 'gnus-line-format))
6462 (while (eq (get-text-property (point) 'gnus-line-format)
6463 gnus-mime-security-button-line-format)
6467 (narrow-to-region (point) (point))
6468 (gnus-insert-mime-security-button handle))
6469 (delete-region (point)
6470 (or (text-property-not-all
6473 gnus-mime-security-button-line-format)
6476 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6477 (with-current-buffer gnus-mime-security-details-buffer
6480 (setq gnus-mime-security-details-buffer
6481 (gnus-get-buffer-create "*MIME Security Details*")))
6482 (with-current-buffer gnus-mime-security-details-buffer
6484 (goto-char (point-min)))
6485 (pop-to-buffer gnus-mime-security-details-buffer)))))
6487 (defun gnus-mime-security-press-button (handle)
6489 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6490 (gnus-mime-security-show-details handle)
6491 (gnus-mime-security-verify-or-decrypt handle))))
6493 (defun gnus-insert-mime-security-button (handle &optional displayed)
6494 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6497 (or (nth 2 (assoc protocol mm-verify-function-alist))
6498 (nth 2 (assoc protocol mm-decrypt-function-alist))
6500 (if (equal (car handle) "multipart/signed")
6501 " Signed" " Encrypted")
6504 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6507 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6508 gnus-tmp-pressed-details
6510 (setq gnus-tmp-details
6511 (if gnus-tmp-details
6512 (concat "\n" gnus-tmp-details)
6514 (setq gnus-tmp-pressed-details
6515 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6520 gnus-mime-security-button-line-format
6521 gnus-mime-security-button-line-format-alist
6522 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6523 gnus-callback gnus-mime-security-press-button
6524 gnus-line-format ,gnus-mime-security-button-line-format
6525 gnus-mime-details ,gnus-mime-security-button-pressed
6526 article-type annotation
6529 (widget-convert-button
6532 :action 'gnus-widget-press-button
6533 :button-keymap gnus-mime-security-button-map
6535 (lambda (widget/window &optional overlay pos)
6536 ;; Needed to properly clear the message due to a bug in
6537 ;; wid-edit (XEmacs only).
6538 (when (boundp 'help-echo-owns-message)
6539 (setq help-echo-owns-message t))
6542 (aref gnus-mouse-2 0))))))
6544 (defun gnus-mime-display-security (handle)
6546 (narrow-to-region (point) (point))
6547 (unless (gnus-unbuttonized-mime-type-p (car handle))
6548 (gnus-insert-mime-security-button handle))
6549 (gnus-mime-display-mixed (cdr handle))
6552 (unless (gnus-unbuttonized-mime-type-p (car handle))
6553 (let ((gnus-mime-security-button-line-format
6554 gnus-mime-security-button-end-line-format))
6555 (gnus-insert-mime-security-button handle)))
6556 (mm-set-handle-multipart-parameter
6558 (cons (set-marker (make-marker) (point-min))
6559 (set-marker (make-marker) (point-max))))))
6565 (run-hooks 'gnus-art-load-hook)
6567 ;;; gnus-art.el ends here