1 ;;; gnus-art.el --- article mode commands for Semi-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>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval-when-compile (require 'cl))
32 (eval-when-compile (require 'static))
44 ;; Avoid byte-compile warnings.
52 (autoload 'gnus-msg-mail "gnus-msg" nil t)
53 (autoload 'gnus-button-mailto "gnus-msg")
54 (autoload 'gnus-button-reply "gnus-msg" nil t)
56 (defgroup gnus-article nil
58 :link '(custom-manual "(gnus)The Article Buffer")
61 (defgroup gnus-article-treat nil
62 "Treating article parts."
63 :link '(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-hiding nil
67 "Hiding article parts."
68 :link '(custom-manual "(gnus)Article Hiding")
71 (defgroup gnus-article-highlight nil
72 "Article highlighting."
73 :link '(custom-manual "(gnus)Article Highlighting")
77 (defgroup gnus-article-signature nil
79 :link '(custom-manual "(gnus)Article Signature")
82 (defgroup gnus-article-headers nil
84 :link '(custom-manual "(gnus)Hiding Headers")
87 (defgroup gnus-article-washing nil
88 "Special commands on articles."
89 :link '(custom-manual "(gnus)Article Washing")
92 (defgroup gnus-article-emphasis nil
93 "Fontisizing articles."
94 :link '(custom-manual "(gnus)Article Fontisizing")
97 (defgroup gnus-article-saving nil
99 :link '(custom-manual "(gnus)Saving Articles")
100 :group 'gnus-article)
102 (defgroup gnus-article-mime nil
103 "Worshiping the MIME wonder."
104 :link '(custom-manual "(gnus)Using MIME")
105 :group 'gnus-article)
107 (defgroup gnus-article-buttons nil
108 "Pushable buttons in the article buffer."
109 :link '(custom-manual "(gnus)Article Buttons")
110 :group 'gnus-article)
112 (defgroup gnus-article-various nil
113 "Other article options."
114 :link '(custom-manual "(gnus)Misc Article")
115 :group 'gnus-article)
117 (defcustom gnus-ignored-headers
120 (concat "^" header ":"))
121 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
122 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
123 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
124 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
125 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
126 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
127 "X-Attribution" "X-Originating-IP" "Delivered-To"
128 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
129 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
130 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
131 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
132 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
133 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
134 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
135 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
136 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
137 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
138 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
139 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
140 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
141 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
142 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
143 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
144 "List-[A-Za-z]+" "X-Listprocessor-Version"
145 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
146 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
147 "X-Received" "Content-length" "X-precedence"
148 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
149 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
150 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
151 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
152 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
153 "X-Content-length" "X-Posting-Agent" "Original-Received"
154 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
155 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
156 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
157 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
158 "X-Abuse-and-DMCA-Info" "X-Postfilter"))
159 "*All headers that start with this regexp will be hidden.
160 This variable can also be a list of regexps of headers to be ignored.
161 If `gnus-visible-headers' is non-nil, this variable will be ignored."
162 :type '(choice :custom-show nil
165 :group 'gnus-article-hiding)
167 (defcustom gnus-visible-headers
168 "^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:"
169 "*All headers that do not match this regexp will be hidden.
170 This variable can also be a list of regexp of headers to remain visible.
171 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
172 :type '(repeat :value-to-internal (lambda (widget value)
173 (custom-split-regexp-maybe value))
174 :match (lambda (widget value)
176 (widget-editable-list-match widget value)))
178 :group 'gnus-article-hiding)
180 (defcustom gnus-sorted-header-list
181 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
182 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
183 "*This variable is a list of regular expressions.
184 If it is non-nil, headers that match the regular expressions will
185 be placed first in the article buffer in the sequence specified by
187 :type '(repeat regexp)
188 :group 'gnus-article-hiding)
190 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
191 "Headers that are only to be displayed if they have interesting data.
192 Possible values in this list are:
194 'empty Headers with no content.
195 'newsgroups Newsgroup identical to Gnus group.
196 'to-address To identical to To-address.
197 'followup-to Followup-to identical to Newsgroups.
198 'reply-to Reply-to identical to From.
199 'date Date less than four days old.
200 'long-to To and/or Cc longer than 1024 characters.
201 'many-to Multiple To and/or Cc."
202 :type '(set (const :tag "Headers with no content." empty)
203 (const :tag "Newsgroups identical to Gnus group." newsgroups)
204 (const :tag "To identical to To-address." to-address)
205 (const :tag "Followup-to identical to Newsgroups." followup-to)
206 (const :tag "Reply-to identical to From." reply-to)
207 (const :tag "Date less than four days old." date)
208 (const :tag "To and/or Cc longer than 1024 characters." long-to)
209 (const :tag "Multiple To and/or Cc headers." many-to))
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
244 (if (or (gnus-image-type-available-p 'xface)
245 (gnus-image-type-available-p 'pbm))
246 'gnus-display-x-face-in-from
247 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
248 ((and (fboundp 'image-type-available-p)
249 (module-installed-p 'x-face-e21))
250 'x-face-decode-message-header)
251 ((gnus-image-type-available-p 'pbm)
252 'gnus-display-x-face-in-from)
254 (module-installed-p 'x-face-mule))
255 'x-face-mule-gnus-article-display-x-face)
257 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
259 "*String or function to be executed to display an X-Face header.
260 If it is a string, the command will be executed in a sub-shell
261 asynchronously. The compressed face will be piped to this command."
263 ,@(let (x-face-e21 x-face-mule)
264 (if (featurep 'xemacs)
266 (setq x-face-e21 (module-installed-p 'x-face-e21)
267 x-face-mule (module-installed-p 'x-face-mule)))
271 (if (or (gnus-image-type-available-p 'xface)
272 (gnus-image-type-available-p 'pbm))
273 '(function-item gnus-display-x-face-in-from))
275 (fboundp 'image-type-available-p))
277 :tag "x-face-decode-message-header (x-face-e21)"
278 x-face-decode-message-header))
281 x-face-mule-gnus-article-display-x-face))
285 :group 'gnus-article-washing)
287 (defcustom gnus-article-x-face-too-ugly nil
288 "Regexp matching posters whose face shouldn't be shown automatically."
289 :type '(choice regexp (const nil))
290 :group 'gnus-article-washing)
292 (defcustom gnus-article-banner-alist nil
293 "Banner alist for stripping.
295 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
297 :type '(repeat (cons symbol regexp))
298 :group 'gnus-article-washing)
300 (gnus-define-group-parameter
303 "Alist of regexps (to match group names) and banner."
304 :variable-group gnus-article-washing
306 '(choice :tag "Banner"
308 (const :tag "Remove signature" signature)
309 (symbol :tag "Item in `gnus-article-banner-alist'" none)
311 (const :tag "None" nil))
313 "If non-nil, specify how to remove `banners' from articles.
315 Symbol `signature' means to remove signatures delimited by
316 `gnus-signature-separator'. Any other symbol is used to look up a
317 regular expression to match the banner in `gnus-article-banner-alist'.
318 A string is used as a regular expression to match the banner
321 (defcustom gnus-article-address-banner-alist nil
322 "Alist of mail addresses and banners.
323 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
324 to match a mail address in the From: header, BANNER is one of a symbol
325 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
326 If ADDRESS matches author's mail address, it will remove things like
327 advertisements. For example:
329 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
333 (regexp :tag "Address")
334 (choice :tag "Banner" :value nil
335 (const :tag "Remove signature" signature)
336 (symbol :tag "Item in `gnus-article-banner-alist'" none)
338 (const :tag "None" nil))))
339 :group 'gnus-article-washing)
341 (defcustom gnus-emphasis-alist
343 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
348 ("_/" "/_" underline-italic)
349 ("_\\*" "\\*_" underline-bold)
350 ("\\*/" "/\\*" bold-italic)
351 ("_\\*/" "/\\*_" underline-bold-italic))))
355 (format format (car spec) (car (cdr spec)))
356 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
358 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
359 2 3 gnus-emphasis-strikethru)
360 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
361 2 3 gnus-emphasis-underline)))
362 "*Alist that says how to fontify certain phrases.
363 Each item looks like this:
365 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
367 The first element is a regular expression to be matched. The second
368 is a number that says what regular expression grouping used to find
369 the entire emphasized word. The third is a number that says what
370 regexp grouping should be displayed and highlighted. The fourth
371 is the face used for highlighting."
372 :type '(repeat (list :value ("" 0 0 default)
374 (integer :tag "Match group")
375 (integer :tag "Emphasize group")
377 :group 'gnus-article-emphasis)
379 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
380 "A regexp to describe whitespace which should not be emphasized.
381 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
382 The former avoids underlining of leading and trailing whitespace,
383 and the latter avoids underlining any whitespace at all."
385 :group 'gnus-article-emphasis
388 (defface gnus-emphasis-bold '((t (:bold t)))
389 "Face used for displaying strong emphasized text (*word*)."
390 :group 'gnus-article-emphasis)
392 (defface gnus-emphasis-italic '((t (:italic t)))
393 "Face used for displaying italic emphasized text (/word/)."
394 :group 'gnus-article-emphasis)
396 (defface gnus-emphasis-underline '((t (:underline t)))
397 "Face used for displaying underlined emphasized text (_word_)."
398 :group 'gnus-article-emphasis)
400 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
401 "Face used for displaying underlined bold emphasized text (_*word*_)."
402 :group 'gnus-article-emphasis)
404 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
405 "Face used for displaying underlined italic emphasized text (_/word/_)."
406 :group 'gnus-article-emphasis)
408 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
409 "Face used for displaying bold italic emphasized text (/*word*/)."
410 :group 'gnus-article-emphasis)
412 (defface gnus-emphasis-underline-bold-italic
413 '((t (:bold t :italic t :underline t)))
414 "Face used for displaying underlined bold italic emphasized text.
415 Example: (_/*word*/_)."
416 :group 'gnus-article-emphasis)
418 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
419 "Face used for displaying strike-through text (-word-)."
420 :group 'gnus-article-emphasis)
422 (defface gnus-emphasis-highlight-words
423 '((t (:background "black" :foreground "yellow")))
424 "Face used for displaying highlighted words."
425 :group 'gnus-article-emphasis)
427 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
428 "Format for display of Date headers in article bodies.
429 See `format-time-string' for the possible values.
431 The variable can also be function, which should return a complete Date
432 header. The function is called with one argument, the time, which can
433 be fed to `format-time-string'."
434 :type '(choice string symbol)
435 :link '(custom-manual "(gnus)Article Date")
436 :group 'gnus-article-washing)
439 (autoload 'mail-extract-address-components "mail-extr"))
441 (defcustom gnus-save-all-headers t
442 "*If non-nil, don't remove any headers before saving."
443 :group 'gnus-article-saving
446 (defcustom gnus-prompt-before-saving 'always
447 "*This variable says how much prompting is to be done when saving articles.
448 If it is nil, no prompting will be done, and the articles will be
449 saved to the default files. If this variable is `always', each and
450 every article that is saved will be preceded by a prompt, even when
451 saving large batches of articles. If this variable is neither nil not
452 `always', there the user will be prompted once for a file name for
453 each invocation of the saving commands."
454 :group 'gnus-article-saving
455 :type '(choice (item always)
456 (item :tag "never" nil)
457 (sexp :tag "once" :format "%t\n" :value t)))
459 (defcustom gnus-saved-headers gnus-visible-headers
460 "Headers to keep if `gnus-save-all-headers' is nil.
461 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
462 If that variable is nil, however, all headers that match this regexp
463 will be kept while the rest will be deleted before saving."
464 :group 'gnus-article-saving
467 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
468 "A function to save articles in your favourite format.
469 The function must be interactively callable (in other words, it must
470 be an Emacs command).
472 Gnus provides the following functions:
474 * gnus-summary-save-in-rmail (Rmail format)
475 * gnus-summary-save-in-mail (Unix mail format)
476 * gnus-summary-save-in-folder (MH folder)
477 * gnus-summary-save-in-file (article format)
478 * gnus-summary-save-body-in-file (article body)
479 * gnus-summary-save-in-vm (use VM's folder format)
480 * gnus-summary-write-to-file (article format -- overwrite)."
481 :group 'gnus-article-saving
482 :type '(radio (function-item gnus-summary-save-in-rmail)
483 (function-item gnus-summary-save-in-mail)
484 (function-item gnus-summary-save-in-folder)
485 (function-item gnus-summary-save-in-file)
486 (function-item gnus-summary-save-body-in-file)
487 (function-item gnus-summary-save-in-vm)
488 (function-item gnus-summary-write-to-file)))
490 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
491 "A function generating a file name to save articles in Rmail format.
492 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
493 :group 'gnus-article-saving
496 (defcustom gnus-mail-save-name 'gnus-plain-save-name
497 "A function generating a file name to save articles in Unix mail format.
498 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
499 :group 'gnus-article-saving
502 (defcustom gnus-folder-save-name 'gnus-folder-save-name
503 "A function generating a file name to save articles in MH folder.
504 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
505 :group 'gnus-article-saving
508 (defcustom gnus-file-save-name 'gnus-numeric-save-name
509 "A function generating a file name to save articles in article format.
510 The function is called with NEWSGROUP, HEADERS, and optional
512 :group 'gnus-article-saving
515 (defcustom gnus-split-methods
516 '((gnus-article-archive-name)
517 (gnus-article-nndoc-name))
518 "*Variable used to suggest where articles are to be saved.
519 For instance, if you would like to save articles related to Gnus in
520 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
521 you could set this variable to something like:
523 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
524 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
526 This variable is an alist where the where the key is the match and the
527 value is a list of possible files to save in if the match is non-nil.
529 If the match is a string, it is used as a regexp match on the
530 article. If the match is a symbol, that symbol will be funcalled
531 from the buffer of the article to be saved with the newsgroup as the
532 parameter. If it is a list, it will be evaled in the same buffer.
534 If this form or function returns a string, this string will be used as
535 a possible file name; and if it returns a non-nil list, that list will
536 be used as possible file names."
537 :group 'gnus-article-saving
538 :type '(repeat (choice (list :value (fun) function)
539 (cons :value ("" "") regexp (repeat string))
542 (defcustom gnus-article-display-method-for-mime
543 'gnus-article-display-mime-message
544 "Function to display a MIME message.
545 The function is called from the article buffer."
546 :group 'gnus-article-mime
549 (defcustom gnus-article-display-method-for-traditional
550 'gnus-article-display-traditional-message
551 "*Function to display a traditional message.
552 The function is called from the article buffer."
553 :group 'gnus-article-mime
556 (defcustom gnus-page-delimiter "^\^L"
557 "*Regexp describing what to use as article page delimiters.
558 The default value is \"^\^L\", which is a form linefeed at the
559 beginning of a line."
561 :group 'gnus-article-various)
563 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
564 "*The format specification for the article mode line.
565 See `gnus-summary-mode-line-format' for a closer description.
567 The following additional specs are available:
569 %w The article washing status.
570 %m The number of MIME parts in the article."
572 :group 'gnus-article-various)
574 (defcustom gnus-article-mode-hook nil
575 "*A hook for Gnus article mode."
577 :group 'gnus-article-various)
579 (when (featurep 'xemacs)
580 ;; Extracted from gnus-xmas-define in order to preserve user settings
581 (when (fboundp 'turn-off-scroll-in-place)
582 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
583 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
584 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
586 (defcustom gnus-article-menu-hook nil
587 "*Hook run after the creation of the article mode menu."
589 :group 'gnus-article-various)
591 (defcustom gnus-article-prepare-hook nil
592 "*A hook called after an article has been prepared in the article buffer."
594 :group 'gnus-article-various)
596 (defcustom gnus-article-hide-pgp-hook nil
597 "*A hook called after successfully hiding a PGP signature."
599 :group 'gnus-article-various)
601 (defcustom gnus-article-button-face 'bold
602 "Face used for highlighting buttons in the article buffer.
604 An article button is a piece of text that you can activate by pressing
605 `RET' or `mouse-2' above it."
607 :group 'gnus-article-buttons)
609 (defcustom gnus-article-mouse-face 'highlight
610 "Face used for mouse highlighting in the article buffer.
612 Article buttons will be displayed in this face when the cursor is
615 :group 'gnus-article-buttons)
617 (defcustom gnus-signature-face 'gnus-signature-face
618 "Face used for highlighting a signature in the article buffer.
619 Obsolete; use the face `gnus-signature-face' for customizations instead."
621 :group 'gnus-article-highlight
622 :group 'gnus-article-signature)
624 (defface gnus-signature-face
627 "Face used for highlighting a signature in the article buffer."
628 :group 'gnus-article-highlight
629 :group 'gnus-article-signature)
631 (defface gnus-header-from-face
634 (:foreground "spring green"))
637 (:foreground "red3"))
640 "Face used for displaying from headers."
641 :group 'gnus-article-headers
642 :group 'gnus-article-highlight)
644 (defface gnus-header-subject-face
647 (:foreground "SeaGreen3"))
650 (:foreground "red4"))
652 (:bold t :italic t)))
653 "Face used for displaying subject headers."
654 :group 'gnus-article-headers
655 :group 'gnus-article-highlight)
657 (defface gnus-header-newsgroups-face
660 (:foreground "yellow" :italic t))
663 (:foreground "MidnightBlue" :italic t))
666 "Face used for displaying newsgroups headers."
667 :group 'gnus-article-headers
668 :group 'gnus-article-highlight)
670 (defface gnus-header-name-face
673 (:foreground "SeaGreen"))
676 (:foreground "maroon"))
679 "Face used for displaying header names."
680 :group 'gnus-article-headers
681 :group 'gnus-article-highlight)
683 (defface gnus-header-content-face
686 (:foreground "forest green" :italic t))
689 (:foreground "indianred4" :italic t))
692 "Face used for displaying header content."
693 :group 'gnus-article-headers
694 :group 'gnus-article-highlight)
696 (defcustom gnus-header-face-alist
697 '(("From" nil gnus-header-from-face)
698 ("Subject" nil gnus-header-subject-face)
699 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
700 ("" gnus-header-name-face gnus-header-content-face))
701 "*Controls highlighting of article header.
703 An alist of the form (HEADER NAME CONTENT).
705 HEADER is a regular expression which should match the name of an
706 header header and NAME and CONTENT are either face names or nil.
708 The name of each header field will be displayed using the face
709 specified by the first element in the list where HEADER match the
710 header name and NAME is non-nil. Similarly, the content will be
711 displayed by the first non-nil matching CONTENT face."
712 :group 'gnus-article-headers
713 :group 'gnus-article-highlight
714 :type '(repeat (list (regexp :tag "Header")
716 (item :tag "skip" nil)
717 (face :value default))
718 (choice :tag "Content"
719 (item :tag "skip" nil)
720 (face :value default)))))
722 (defcustom gnus-article-decode-hook nil
723 "*Hook run to decode charsets in articles."
724 :group 'gnus-article-headers
727 (defcustom gnus-display-mime-function 'gnus-display-mime
728 "Function to display MIME articles."
729 :group 'gnus-article-mime
732 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
733 "Function used to decode headers.")
735 (defvar gnus-article-dumbquotes-map
755 "Table for MS-to-Latin1 translation.")
757 (defcustom gnus-ignored-mime-types nil
758 "List of MIME types that should be ignored by Gnus."
760 :group 'gnus-article-mime
761 :type '(repeat regexp))
763 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
764 "List of MIME types that should not be given buttons when rendered inline.
765 See also `gnus-buttonized-mime-types' which may override this variable.
766 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
768 :group 'gnus-article-mime
769 :type '(repeat regexp))
771 (defcustom gnus-buttonized-mime-types nil
772 "List of MIME types that should be given buttons when rendered inline.
773 If set, this variable overrides `gnus-unbuttonized-mime-types'.
774 To see e.g. security buttons you could set this to
775 `(\"multipart/signed\")'.
776 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
778 :group 'gnus-article-mime
779 :type '(repeat regexp))
781 (defcustom gnus-inhibit-mime-unbuttonizing nil
782 "If non-nil, all MIME parts get buttons.
783 When nil (the default value), then some MIME parts do not get buttons,
784 as described by the variables `gnus-buttonized-mime-types' and
785 `gnus-unbuttonized-mime-types'."
789 (defcustom gnus-body-boundary-delimiter "_"
790 "String used to delimit header and body.
791 This variable is used by `gnus-article-treat-body-boundary' which can
792 be controlled by `gnus-treat-body-boundary'."
793 :group 'gnus-article-various
794 :type '(choice (item :tag "None" :value nil)
797 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
798 "Defines the location of the faces database.
799 For information on obtaining this database of pretty pictures, please
800 see http://www.cs.indiana.edu/picons/ftp/index.html"
801 :type '(repeat directory)
802 :link '(url-link :tag "download"
803 "http://www.cs.indiana.edu/picons/ftp/index.html")
804 :link '(custom-manual "(gnus)Picons")
807 (defun gnus-picons-installed-p ()
808 "Say whether picons are installed on your machine."
809 (let ((installed nil))
810 (dolist (database gnus-picon-databases)
811 (when (file-exists-p database)
815 (defcustom gnus-article-mime-part-function nil
816 "Function called with a MIME handle as the argument.
817 This is meant for people who want to do something automatic based
818 on parts -- for instance, adding Vcard info to a database."
819 :group 'gnus-article-mime
822 (defcustom gnus-mime-multipart-functions nil
823 "An alist of MIME types to functions to display them."
825 :group 'gnus-article-mime
828 (defcustom gnus-article-date-lapsed-new-header nil
829 "Whether the X-Sent and Date headers can coexist.
830 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
831 either replace the old \"Date:\" header (if this variable is nil), or
832 be added below it (otherwise)."
834 :group 'gnus-article-headers
837 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
838 "Function called with a MIME handle as the argument.
839 This is meant for people who want to view first matched part.
840 For `undisplayed-alternative' (default), the first undisplayed
841 part or alternative part is used. For `undisplayed', the first
842 undisplayed part is used. For a function, the first part which
843 the function return `t' is used. For `nil', the first part is
846 :group 'gnus-article-mime
848 (item :tag "first" :value nil)
849 (item :tag "undisplayed" :value undisplayed)
850 (item :tag "undisplayed or alternative"
851 :value undisplayed-alternative)
854 (defcustom gnus-mime-action-alist
855 '(("save to file" . gnus-mime-save-part)
856 ("save and strip" . gnus-mime-save-part-and-strip)
857 ("display as text" . gnus-mime-inline-part)
858 ("view the part" . gnus-mime-view-part)
859 ("pipe to command" . gnus-mime-pipe-part)
860 ("toggle display" . gnus-article-press-button)
861 ("toggle display" . gnus-article-view-part-as-charset)
862 ("view as type" . gnus-mime-view-part-as-type)
863 ("view internally" . gnus-mime-view-part-internally)
864 ("view externally" . gnus-mime-view-part-externally))
865 "An alist of actions that run on the MIME attachment."
866 :group 'gnus-article-mime
867 :type '(repeat (cons (string :tag "name")
871 ;;; The treatment variables
874 (defvar gnus-part-display-hook nil
875 "Hook called on parts that are to receive treatment.")
877 (defvar gnus-article-treat-custom
878 '(choice (const :tag "Off" nil)
880 (const :tag "Header" head)
881 (const :tag "Last" last)
882 (const :tag "Mime" mime)
883 (integer :tag "Less")
884 (repeat :tag "Groups" regexp)
885 (sexp :tag "Predicate")))
887 (defvar gnus-article-treat-head-custom
888 '(choice (const :tag "Off" nil)
889 (const :tag "Header" head)))
891 (defvar gnus-article-treat-types '("text/plain")
894 (defvar gnus-inhibit-treatment nil
895 "Whether to inhibit treatment.")
897 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
898 "Highlight the signature.
899 Valid values are nil, t, `head', `last', an integer or a predicate.
900 See Info node `(gnus)Customizing Articles'."
901 :group 'gnus-article-treat
902 :link '(custom-manual "(gnus)Customizing Articles")
903 :type gnus-article-treat-custom)
904 (put 'gnus-treat-highlight-signature 'highlight t)
906 (defcustom gnus-treat-buttonize 100000
908 Valid values are nil, t, `head', `last', an integer or a predicate.
909 See Info node `(gnus)Customizing Articles'."
910 :group 'gnus-article-treat
911 :link '(custom-manual "(gnus)Customizing Articles")
912 :type gnus-article-treat-custom)
913 (put 'gnus-treat-buttonize 'highlight t)
915 (defcustom gnus-treat-buttonize-head 'head
916 "Add buttons to the head.
917 Valid values are nil, t, `head', `last', an integer or a predicate.
918 See Info node `(gnus)Customizing Articles' for details."
919 :group 'gnus-article-treat
920 :link '(custom-manual "(gnus)Customizing Articles")
921 :type gnus-article-treat-head-custom)
922 (put 'gnus-treat-buttonize-head 'highlight t)
924 (defcustom gnus-treat-emphasize
925 (and (or window-system
927 (>= (string-to-number emacs-version) 21))
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-custom)
935 (put 'gnus-treat-emphasize 'highlight t)
937 (defcustom gnus-treat-strip-cr nil
938 "Remove carriage returns.
939 Valid values are nil, t, `head', `last', an integer or a predicate.
940 See Info node `(gnus)Customizing Articles' for details."
941 :group 'gnus-article-treat
942 :link '(custom-manual "(gnus)Customizing Articles")
943 :type gnus-article-treat-custom)
945 (defcustom gnus-treat-unsplit-urls nil
946 "Remove newlines from within URLs.
947 Valid values are nil, t, `head', `last', an integer or a predicate.
948 See Info node `(gnus)Customizing Articles' for details."
949 :group 'gnus-article-treat
950 :link '(custom-manual "(gnus)Customizing Articles")
951 :type gnus-article-treat-custom)
953 (defcustom gnus-treat-leading-whitespace nil
954 "Remove leading whitespace in headers.
955 Valid values are nil, t, `head', `last', an integer or a predicate.
956 See Info node `(gnus)Customizing Articles' for details."
957 :group 'gnus-article-treat
958 :link '(custom-manual "(gnus)Customizing Articles")
959 :type gnus-article-treat-custom)
961 (defcustom gnus-treat-hide-headers 'head
963 Valid values are nil, t, `head', `last', an integer or a predicate.
964 See Info node `(gnus)Customizing Articles' for details."
965 :group 'gnus-article-treat
966 :link '(custom-manual "(gnus)Customizing Articles")
967 :type gnus-article-treat-head-custom)
969 (defcustom gnus-treat-hide-boring-headers nil
970 "Hide boring headers.
971 Valid values are nil, t, `head', `last', an integer or a predicate.
972 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-head-custom)
977 (defcustom gnus-treat-hide-signature nil
979 Valid values are nil, t, `head', `last', an integer or a predicate.
980 See Info node `(gnus)Customizing Articles' for details."
981 :group 'gnus-article-treat
982 :link '(custom-manual "(gnus)Customizing Articles")
983 :type gnus-article-treat-custom)
985 (defcustom gnus-treat-fill-article nil
987 Valid values are nil, t, `head', `last', an integer or a predicate.
988 See Info node `(gnus)Customizing Articles' for details."
989 :group 'gnus-article-treat
990 :link '(custom-manual "(gnus)Customizing Articles")
991 :type gnus-article-treat-custom)
993 (defcustom gnus-treat-hide-citation nil
995 Valid values are nil, t, `head', `last', an integer or a predicate.
996 See Info node `(gnus)Customizing Articles' for details."
997 :group 'gnus-article-treat
998 :link '(custom-manual "(gnus)Customizing Articles")
999 :type gnus-article-treat-custom)
1001 (defcustom gnus-treat-hide-citation-maybe nil
1003 Valid values are nil, t, `head', `last', an integer or a predicate.
1004 See Info node `(gnus)Customizing Articles' for details."
1005 :group 'gnus-article-treat
1006 :link '(custom-manual "(gnus)Customizing Articles")
1007 :type gnus-article-treat-custom)
1009 (defcustom gnus-treat-strip-list-identifiers 'head
1010 "Strip list identifiers from `gnus-list-identifiers`.
1011 Valid values are nil, t, `head', `last', an integer or a predicate.
1012 See Info node `(gnus)Customizing Articles' for details."
1014 :group 'gnus-article-treat
1015 :link '(custom-manual "(gnus)Customizing Articles")
1016 :type gnus-article-treat-custom)
1018 (defcustom gnus-treat-strip-pgp t
1019 "Strip PGP signatures.
1020 Valid values are nil, t, `head', `last', an integer or a predicate.
1021 See Info node `(gnus)Customizing Articles' for details."
1022 :group 'gnus-article-treat
1023 :link '(custom-manual "(gnus)Customizing Articles")
1024 :type gnus-article-treat-custom)
1026 (defcustom gnus-treat-strip-pem nil
1027 "Strip PEM signatures.
1028 Valid values are nil, t, `head', `last', an integer or a predicate.
1029 See Info node `(gnus)Customizing Articles' for details."
1030 :group 'gnus-article-treat
1031 :link '(custom-manual "(gnus)Customizing Articles")
1032 :type gnus-article-treat-custom)
1034 (defcustom gnus-treat-strip-banner t
1035 "Strip banners from articles.
1036 The banner to be stripped is specified in the `banner' group parameter.
1037 Valid values are nil, t, `head', `last', an integer or a predicate.
1038 See Info node `(gnus)Customizing Articles' for details."
1039 :group 'gnus-article-treat
1040 :link '(custom-manual "(gnus)Customizing Articles")
1041 :type gnus-article-treat-custom)
1043 (defcustom gnus-treat-highlight-headers 'head
1044 "Highlight the headers.
1045 Valid values are nil, t, `head', `last', an integer or a predicate.
1046 See Info node `(gnus)Customizing Articles' for details."
1047 :group 'gnus-article-treat
1048 :link '(custom-manual "(gnus)Customizing Articles")
1049 :type gnus-article-treat-head-custom)
1050 (put 'gnus-treat-highlight-headers 'highlight t)
1052 (defcustom gnus-treat-highlight-citation t
1053 "Highlight cited text.
1054 Valid values are nil, t, `head', `last', an integer or a predicate.
1055 See Info node `(gnus)Customizing Articles' for details."
1056 :group 'gnus-article-treat
1057 :link '(custom-manual "(gnus)Customizing Articles")
1058 :type gnus-article-treat-custom)
1059 (put 'gnus-treat-highlight-citation 'highlight t)
1061 (defcustom gnus-treat-date-ut nil
1062 "Display the Date in UT (GMT).
1063 Valid values are nil, t, `head', `last', an integer or a predicate.
1064 See Info node `(gnus)Customizing Articles' for details."
1065 :group 'gnus-article-treat
1066 :link '(custom-manual "(gnus)Customizing Articles")
1067 :type gnus-article-treat-head-custom)
1069 (defcustom gnus-treat-date-local nil
1070 "Display the Date in the local timezone.
1071 Valid values are nil, t, `head', `last', an integer or a predicate.
1072 See Info node `(gnus)Customizing Articles' for details."
1073 :group 'gnus-article-treat
1074 :link '(custom-manual "(gnus)Customizing Articles")
1075 :type gnus-article-treat-head-custom)
1077 (defcustom gnus-treat-date-english nil
1078 "Display the Date in a format that can be read aloud in English.
1079 Valid values are nil, t, `head', `last', an integer or a predicate.
1080 See Info node `(gnus)Customizing Articles' for details."
1081 :group 'gnus-article-treat
1082 :link '(custom-manual "(gnus)Customizing Articles")
1083 :type gnus-article-treat-head-custom)
1085 (defcustom gnus-treat-date-lapsed nil
1086 "Display the Date header in a way that says how much time has elapsed.
1087 Valid values are nil, t, `head', `last', an integer or a predicate.
1088 See Info node `(gnus)Customizing Articles' for details."
1089 :group 'gnus-article-treat
1090 :link '(custom-manual "(gnus)Customizing Articles")
1091 :type gnus-article-treat-head-custom)
1093 (defcustom gnus-treat-date-original nil
1094 "Display the date in the original timezone.
1095 Valid values are nil, t, `head', `last', an integer or a predicate.
1096 See Info node `(gnus)Customizing Articles' for details."
1097 :group 'gnus-article-treat
1098 :link '(custom-manual "(gnus)Customizing Articles")
1099 :type gnus-article-treat-head-custom)
1101 (defcustom gnus-treat-date-iso8601 nil
1102 "Display the date in the ISO8601 format.
1103 Valid values are nil, t, `head', `last', an integer or a predicate.
1104 See Info node `(gnus)Customizing Articles' for details."
1106 :group 'gnus-article-treat
1107 :link '(custom-manual "(gnus)Customizing Articles")
1108 :type gnus-article-treat-head-custom)
1110 (defcustom gnus-treat-date-user-defined nil
1111 "Display the date in a user-defined format.
1112 The format is defined by the `gnus-article-time-format' variable.
1113 Valid values are nil, t, `head', `last', an integer or a predicate.
1114 See Info node `(gnus)Customizing Articles' for details."
1115 :group 'gnus-article-treat
1116 :link '(custom-manual "(gnus)Customizing Articles")
1117 :type gnus-article-treat-head-custom)
1119 (defcustom gnus-treat-strip-headers-in-body t
1120 "Strip the X-No-Archive header line from the beginning of the body.
1121 Valid values are nil, t, `head', `last', an integer or a predicate.
1122 See Info node `(gnus)Customizing Articles' for details."
1124 :group 'gnus-article-treat
1125 :link '(custom-manual "(gnus)Customizing Articles")
1126 :type gnus-article-treat-custom)
1128 (defcustom gnus-treat-strip-trailing-blank-lines nil
1129 "Strip trailing blank lines.
1130 Valid values are nil, t, `head', `last', an integer or a predicate.
1131 See Info node `(gnus)Customizing Articles' for details."
1132 :group 'gnus-article-treat
1133 :link '(custom-manual "(gnus)Customizing Articles")
1134 :type gnus-article-treat-custom)
1136 (defcustom gnus-treat-strip-leading-blank-lines nil
1137 "Strip leading blank lines.
1138 Valid values are nil, t, `head', `last', an integer or a predicate.
1139 See Info node `(gnus)Customizing Articles' for details."
1140 :group 'gnus-article-treat
1141 :link '(custom-manual "(gnus)Customizing Articles")
1142 :type gnus-article-treat-custom)
1144 (defcustom gnus-treat-strip-multiple-blank-lines nil
1145 "Strip multiple blank lines.
1146 Valid values are nil, t, `head', `last', an integer or a predicate.
1147 See Info node `(gnus)Customizing Articles' for details."
1148 :group 'gnus-article-treat
1149 :link '(custom-manual "(gnus)Customizing Articles")
1150 :type gnus-article-treat-custom)
1152 (defcustom gnus-treat-unfold-headers 'head
1153 "Unfold folded header lines.
1154 Valid values are nil, t, `head', `last', an integer or a predicate.
1155 See Info node `(gnus)Customizing Articles' for details."
1156 :group 'gnus-article-treat
1157 :link '(custom-manual "(gnus)Customizing Articles")
1158 :type gnus-article-treat-custom)
1160 (defcustom gnus-treat-fold-headers nil
1162 Valid values are nil, t, `head', `last', an integer or a predicate.
1163 See Info node `(gnus)Customizing Articles' for details."
1164 :group 'gnus-article-treat
1165 :link '(custom-manual "(gnus)Customizing Articles")
1166 :type gnus-article-treat-custom)
1168 (defcustom gnus-treat-fold-newsgroups 'head
1169 "Fold the Newsgroups and Followup-To headers.
1170 Valid values are nil, t, `head', `last', an integer or a predicate.
1171 See Info node `(gnus)Customizing Articles' for details."
1172 :group 'gnus-article-treat
1173 :link '(custom-manual "(gnus)Customizing Articles")
1174 :type gnus-article-treat-custom)
1176 (defcustom gnus-treat-overstrike t
1177 "Treat overstrike highlighting.
1178 Valid values are nil, t, `head', `last', an integer or a predicate.
1179 See Info node `(gnus)Customizing Articles' for details."
1180 :group 'gnus-article-treat
1181 :link '(custom-manual "(gnus)Customizing Articles")
1182 :type gnus-article-treat-custom)
1183 (put 'gnus-treat-overstrike 'highlight t)
1185 (defcustom gnus-treat-display-xface
1186 (and (not noninteractive)
1187 (or (and (fboundp 'image-type-available-p)
1188 (image-type-available-p 'xbm)
1189 (string-match "^0x" (shell-command-to-string "uncompface")))
1190 (and (featurep 'xemacs)
1192 (eq 'x-face-mule-gnus-article-display-x-face
1193 gnus-article-x-face-command))
1195 "Display X-Face headers.
1196 Valid values are nil, t, `head', `last', an integer or a predicate.
1197 See Info node `(gnus)Customizing Articles' and Info node
1198 `(gnus)X-Face' for details."
1199 :group 'gnus-article-treat
1201 :link '(custom-manual "(gnus)Customizing Articles")
1202 :link '(custom-manual "(gnus)X-Face")
1203 :type gnus-article-treat-head-custom)
1204 (put 'gnus-treat-display-xface 'highlight t)
1206 (defcustom gnus-article-should-use-smiley-mule
1207 (not (or (featurep 'xemacs)
1208 (gnus-image-type-available-p 'xpm)
1209 (gnus-image-type-available-p 'pbm)))
1210 "If non-nil, gnus uses `smiley-mule' for displaying smileys rather than
1211 `smiley'. It defaults to t when Emacs 20 or earlier is running.
1212 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1213 even if you are using Emacs 21+. It has no effect on XEmacs."
1214 :group 'gnus-article-various
1216 :get (lambda (symbol)
1217 (and (default-value symbol)
1218 (not (featurep 'xemacs))
1219 (module-installed-p 'smiley-mule)
1221 :set (lambda (symbol value)
1222 (set-default symbol (and value
1223 (not (featurep 'xemacs))
1224 (module-installed-p 'smiley-mule)
1227 (defvar gnus-article-smiley-mule-loaded-p nil
1228 "Internal variable used to say whether `smiley-mule' is loaded (whether
1229 smiley functions are not overridden by `smiley').")
1231 (defcustom gnus-treat-display-face
1232 (and (not noninteractive)
1233 (or (and (fboundp 'image-type-available-p)
1234 (image-type-available-p 'png))
1235 (and (featurep 'xemacs)
1238 "Display Face headers.
1239 Valid values are nil, t, `head', `last', an integer or a predicate.
1240 See Info node `(gnus)Customizing Articles' and Info node
1241 `(gnus)X-Face' for details."
1242 :group 'gnus-article-treat
1244 :link '(custom-manual "(gnus)Customizing Articles")
1245 :link '(custom-manual "(gnus)X-Face")
1246 :type gnus-article-treat-head-custom)
1247 (put 'gnus-treat-display-xface 'highlight t)
1249 (defcustom gnus-treat-display-grey-xface
1250 (and (not noninteractive)
1251 (or (featurep 'xemacs)
1252 (and (fboundp 'display-images-p)
1253 (display-images-p)))
1254 (string-match "^0x" (shell-command-to-string "uncompface"))
1256 "Display grey X-Face headers.
1257 Valid values are nil, t."
1258 :group 'gnus-article-treat
1261 (put 'gnus-treat-display-grey-xface 'highlight t)
1263 (defcustom gnus-treat-display-smileys
1264 (if (or (and (featurep 'xemacs)
1266 (gnus-image-type-available-p 'xpm)
1267 (gnus-image-type-available-p 'pbm)
1268 (and (not (featurep 'xemacs))
1270 (module-installed-p 'smiley-mule)))
1274 Valid values are nil, t, `head', `last', an integer or a predicate.
1275 See Info node `(gnus)Customizing Articles' and Info node
1276 `(gnus)Smileys' for details."
1277 :group 'gnus-article-treat
1279 :link '(custom-manual "(gnus)Customizing Articles")
1280 :link '(custom-manual "(gnus)Smileys")
1281 :type gnus-article-treat-custom)
1282 (put 'gnus-treat-display-smileys 'highlight t)
1284 (defcustom gnus-treat-from-picon
1285 (if (and (gnus-image-type-available-p 'xpm)
1286 (gnus-picons-installed-p))
1288 "Display picons in the From header.
1289 Valid values are nil, t, `head', `last', an integer or a predicate.
1290 See Info node `(gnus)Customizing Articles' and Info node
1291 `(gnus)Picons' for details."
1292 :group 'gnus-article-treat
1294 :link '(custom-manual "(gnus)Customizing Articles")
1295 :link '(custom-manual "(gnus)Picons")
1296 :type gnus-article-treat-head-custom)
1297 (put 'gnus-treat-from-picon 'highlight t)
1299 (defcustom gnus-treat-mail-picon
1300 (if (and (gnus-image-type-available-p 'xpm)
1301 (gnus-picons-installed-p))
1303 "Display picons in To and Cc headers.
1304 Valid values are nil, t, `head', `last', an integer or a predicate.
1305 See Info node `(gnus)Customizing Articles' and Info node
1306 `(gnus)Picons' for details."
1307 :group 'gnus-article-treat
1309 :link '(custom-manual "(gnus)Customizing Articles")
1310 :link '(custom-manual "(gnus)Picons")
1311 :type gnus-article-treat-head-custom)
1312 (put 'gnus-treat-mail-picon 'highlight t)
1314 (defcustom gnus-treat-newsgroups-picon
1315 (if (and (gnus-image-type-available-p 'xpm)
1316 (gnus-picons-installed-p))
1318 "Display picons in the Newsgroups and Followup-To headers.
1319 Valid values are nil, t, `head', `last', an integer or a predicate.
1320 See Info node `(gnus)Customizing Articles' and Info node
1321 `(gnus)Picons' for details."
1322 :group 'gnus-article-treat
1324 :link '(custom-manual "(gnus)Customizing Articles")
1325 :link '(custom-manual "(gnus)Picons")
1326 :type gnus-article-treat-head-custom)
1327 (put 'gnus-treat-newsgroups-picon 'highlight t)
1329 (defcustom gnus-treat-body-boundary
1330 (if (or gnus-treat-newsgroups-picon
1331 gnus-treat-mail-picon
1332 gnus-treat-from-picon)
1334 "Draw a boundary at the end of the headers.
1335 Valid values are nil, t, `head', `last', an integer or a predicate.
1336 See Info node `(gnus)Customizing Articles' for details."
1338 :group 'gnus-article-treat
1339 :link '(custom-manual "(gnus)Customizing Articles")
1340 :type gnus-article-treat-custom)
1342 (defcustom gnus-treat-capitalize-sentences nil
1343 "Capitalize sentence-starting words.
1344 Valid values are nil, t, `head', `last', an integer or a predicate.
1345 See Info node `(gnus)Customizing Articles' for details."
1347 :group 'gnus-article-treat
1348 :link '(custom-manual "(gnus)Customizing Articles")
1349 :type gnus-article-treat-custom)
1351 (defcustom gnus-treat-wash-html nil
1353 Valid values are nil, t, `head', `last', an integer or a predicate.
1354 See Info node `(gnus)Customizing Articles' for details."
1355 :group 'gnus-article-treat
1356 :link '(custom-manual "(gnus)Customizing Articles")
1357 :type gnus-article-treat-custom)
1359 (defcustom gnus-treat-fill-long-lines nil
1361 Valid values are nil, t, `head', `last', an integer or a predicate.
1362 See Info node `(gnus)Customizing Articles' for details."
1363 :group 'gnus-article-treat
1364 :link '(custom-manual "(gnus)Customizing Articles")
1365 :type gnus-article-treat-custom)
1367 (defcustom gnus-treat-play-sounds nil
1369 Valid values are nil, t, `head', `last', an integer or a predicate.
1370 See Info node `(gnus)Customizing Articles' for details."
1372 :group 'gnus-article-treat
1373 :link '(custom-manual "(gnus)Customizing Articles")
1374 :type gnus-article-treat-custom)
1376 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1377 "Decode an article as `default-mime-charset'. For instance, if you want to
1378 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1379 you could set this variable to something like: nil for don't decode, t for
1380 decode the body, '(or header t) for the whole article, etc."
1381 :group 'gnus-article-treat
1382 :type '(radio (const :tag "Off" nil)
1383 (const :tag "Decode body" t)
1384 (const :tag "Decode all" (or head t))))
1386 (defcustom gnus-treat-translate nil
1387 "Translate articles from one language to another.
1388 Valid values are nil, t, `head', `last', an integer or a predicate.
1389 See Info node `(gnus)Customizing Articles' for details."
1391 :group 'gnus-article-treat
1392 :link '(custom-manual "(gnus)Customizing Articles")
1393 :type gnus-article-treat-custom)
1395 (defcustom gnus-treat-x-pgp-sig nil
1397 To automatically treat X-PGP-Sig, set it to head.
1398 Valid values are nil, t, `head', `last', an integer or a predicate.
1399 See Info node `(gnus)Customizing Articles' for details."
1400 :group 'gnus-article-treat
1401 :group 'mime-security
1402 :type gnus-article-treat-custom)
1404 (defcustom gnus-treat-monafy nil
1405 "Display body part with mona font.
1406 Valid values are nil, t, `head', `last', an integer or a predicate.
1407 See Info node `(gnus)Customizing Articles' for details."
1408 :group 'gnus-article-treat
1409 :group 'mime-security
1410 :link '(custom-manual "(gnus)Customizing Articles")
1411 :type gnus-article-treat-custom)
1413 (defvar gnus-article-encrypt-protocol-alist
1414 '(("PGP" . mml2015-self-encrypt)))
1416 ;; Set to nil if more than one protocol added to
1417 ;; gnus-article-encrypt-protocol-alist.
1418 (defcustom gnus-article-encrypt-protocol "PGP"
1419 "The protocol used for encrypt articles.
1420 It is a string, such as \"PGP\". If nil, ask user."
1422 :group 'mime-security)
1424 (defvar gnus-article-wash-function nil
1425 "Function used for converting HTML into text.")
1427 ;;; Internal variables
1429 (defvar gnus-english-month-names
1430 '("January" "February" "March" "April" "May" "June" "July" "August"
1431 "September" "October" "November" "December"))
1433 (defvar article-goto-body-goes-to-point-min-p nil)
1434 (defvar gnus-article-wash-types nil)
1435 (defvar gnus-article-emphasis-alist nil)
1436 (defvar gnus-article-image-alist nil)
1438 (defvar gnus-article-mime-handle-alist-1 nil)
1439 (defvar gnus-treatment-function-alist
1440 '((gnus-treat-decode-article-as-default-mime-charset
1441 gnus-article-decode-article-as-default-mime-charset)
1442 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1443 (gnus-treat-monafy gnus-article-monafy)
1444 (gnus-treat-strip-banner gnus-article-strip-banner)
1445 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1446 (gnus-treat-buttonize gnus-article-add-buttons)
1447 (gnus-treat-fill-article gnus-article-fill-cited-article)
1448 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1449 (gnus-treat-strip-cr gnus-article-remove-cr)
1450 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1451 (gnus-treat-date-ut gnus-article-date-ut)
1452 (gnus-treat-date-local gnus-article-date-local)
1453 (gnus-treat-date-english gnus-article-date-english)
1454 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1455 (gnus-treat-date-original gnus-article-date-original)
1456 (gnus-treat-date-user-defined gnus-article-date-user)
1457 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1458 (gnus-treat-display-face gnus-article-display-face)
1459 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1460 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1461 (gnus-treat-hide-signature gnus-article-hide-signature)
1462 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1463 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1464 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1465 (gnus-treat-strip-pem gnus-article-hide-pem)
1466 (gnus-treat-from-picon gnus-treat-from-picon)
1467 (gnus-treat-mail-picon gnus-treat-mail-picon)
1468 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1469 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1470 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1471 (gnus-treat-strip-trailing-blank-lines
1472 gnus-article-remove-trailing-blank-lines)
1473 (gnus-treat-strip-leading-blank-lines
1474 gnus-article-strip-leading-blank-lines)
1475 (gnus-treat-strip-multiple-blank-lines
1476 gnus-article-strip-multiple-blank-lines)
1477 (gnus-treat-overstrike gnus-article-treat-overstrike)
1478 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1479 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1480 ;; Displaying X-Face should be done after unfolding headers
1481 ;; to protect bitmap lines.
1482 (gnus-treat-display-xface gnus-article-display-x-face)
1483 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1484 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1485 (gnus-treat-display-smileys gnus-treat-smiley)
1486 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1487 (gnus-treat-wash-html gnus-article-wash-html)
1488 (gnus-treat-emphasize gnus-article-emphasize)
1489 (gnus-treat-hide-citation gnus-article-hide-citation)
1490 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1491 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1492 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1493 (gnus-treat-play-sounds gnus-earcon-display)))
1495 (defvar gnus-article-mime-handle-alist nil)
1496 (defvar article-lapsed-timer nil)
1497 (defvar gnus-article-current-summary nil)
1499 (defvar gnus-article-mode-syntax-table
1500 (let ((table (copy-syntax-table text-mode-syntax-table)))
1501 ;; This causes the citation match run O(2^n).
1502 ;; (modify-syntax-entry ?- "w" table)
1503 (modify-syntax-entry ?> ")<" table)
1504 (modify-syntax-entry ?< "(>" table)
1505 ;; make M-. in article buffers work for `foo' strings
1506 (modify-syntax-entry ?' " " table)
1507 (modify-syntax-entry ?` " " table)
1509 "Syntax table used in article mode buffers.
1510 Initialized from `text-mode-syntax-table.")
1512 (defvar gnus-save-article-buffer nil)
1514 (defvar gnus-article-mode-line-format-alist
1515 (nconc '((?w (gnus-article-wash-status) ?s)
1516 (?m (gnus-article-mime-part-status) ?s))
1517 gnus-summary-mode-line-format-alist))
1519 (defvar gnus-number-of-articles-to-be-saved nil)
1521 (defvar gnus-inhibit-hiding nil)
1523 ;;; Macros for dealing with the article buffer.
1525 (defmacro gnus-with-article-headers (&rest forms)
1527 (set-buffer gnus-article-buffer)
1529 (let ((buffer-read-only nil)
1530 (inhibit-point-motion-hooks t)
1531 (case-fold-search t))
1532 (article-narrow-to-head)
1535 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1536 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1538 (defmacro gnus-with-article-buffer (&rest forms)
1540 (set-buffer gnus-article-buffer)
1541 (let ((buffer-read-only nil))
1544 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1545 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1547 (defun gnus-article-goto-header (header)
1548 "Go to HEADER, which is a regular expression."
1549 (re-search-forward (concat "^\\(" header "\\):") nil t))
1551 (defsubst gnus-article-hide-text (b e props)
1552 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1553 (gnus-add-text-properties-when 'article-type nil b e props)
1554 (when (memq 'intangible props)
1556 (max (1- b) (point-min))
1557 b 'intangible (cddr (memq 'intangible props)))))
1559 (defsubst gnus-article-unhide-text (b e)
1560 "Remove hidden text properties from region between B and E."
1561 (remove-text-properties b e gnus-hidden-properties)
1562 (when (memq 'intangible gnus-hidden-properties)
1563 (put-text-property (max (1- b) (point-min))
1564 b 'intangible nil)))
1566 (defun gnus-article-hide-text-type (b e type)
1567 "Hide text of TYPE between B and E."
1568 (gnus-add-wash-type type)
1569 (gnus-article-hide-text
1570 b e (cons 'article-type (cons type gnus-hidden-properties))))
1572 (defun gnus-article-unhide-text-type (b e type)
1573 "Unhide text of TYPE between B and E."
1574 (gnus-delete-wash-type type)
1575 (remove-text-properties
1576 b e (cons 'article-type (cons type gnus-hidden-properties)))
1577 (when (memq 'intangible gnus-hidden-properties)
1578 (put-text-property (max (1- b) (point-min))
1579 b 'intangible nil)))
1581 (defun gnus-article-hide-text-of-type (type)
1582 "Hide text of TYPE in the current buffer."
1584 (let ((b (point-min))
1586 (while (setq b (text-property-any b e 'article-type type))
1587 (add-text-properties b (incf b) gnus-hidden-properties)))))
1589 (defun gnus-article-delete-text-of-type (type)
1590 "Delete text of TYPE in the current buffer."
1592 (let ((b (point-min)))
1593 (while (setq b (text-property-any b (point-max) 'article-type type))
1595 b (or (text-property-not-all b (point-max) 'article-type type)
1598 (defun gnus-article-delete-invisible-text ()
1599 "Delete all invisible text in the current buffer."
1601 (let ((b (point-min)))
1602 (while (setq b (text-property-any b (point-max) 'invisible t))
1604 b (or (text-property-not-all b (point-max) 'invisible t)
1607 (defun gnus-article-text-type-exists-p (type)
1608 "Say whether any text of type TYPE exists in the buffer."
1609 (text-property-any (point-min) (point-max) 'article-type type))
1611 (defsubst gnus-article-header-rank ()
1612 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1613 (let ((list gnus-sorted-header-list)
1616 (if (looking-at (car list))
1618 (setq list (cdr list))
1622 (defun article-hide-headers (&optional arg delete)
1623 "Hide unwanted headers and possibly sort them as well."
1624 (interactive (gnus-article-hidden-arg))
1625 ;; Lars said that this function might be inhibited.
1626 (if (gnus-article-check-hidden-text 'headers arg)
1628 ;; Show boring headers as well.
1629 (gnus-article-show-hidden-text 'boring-headers)
1630 (when (eq 1 (point-min))
1631 (set-window-start (get-buffer-window (current-buffer)) 1)))
1632 (unless gnus-inhibit-hiding
1635 (let ((inhibit-read-only t)
1636 (case-fold-search t)
1637 (max (1+ (length gnus-sorted-header-list)))
1638 (ignored (when (not gnus-visible-headers)
1639 (cond ((stringp gnus-ignored-headers)
1640 gnus-ignored-headers)
1641 ((listp gnus-ignored-headers)
1642 (mapconcat 'identity gnus-ignored-headers
1645 (cond ((stringp gnus-visible-headers)
1646 gnus-visible-headers)
1647 ((and gnus-visible-headers
1648 (listp gnus-visible-headers))
1649 (mapconcat 'identity gnus-visible-headers "\\|"))))
1650 (inhibit-point-motion-hooks t)
1652 ;; First we narrow to just the headers.
1653 (article-narrow-to-head)
1654 ;; Hide any "From " lines at the beginning of (mail) articles.
1655 (while (looking-at "From ")
1659 (delete-region (point-min) (point))
1660 (gnus-article-hide-text (point-min) (point)
1661 (nconc (list 'article-type 'headers)
1662 gnus-hidden-properties))))
1663 ;; Then treat the rest of the header lines.
1664 ;; Then we use the two regular expressions
1665 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1666 ;; select which header lines is to remain visible in the
1668 (while (re-search-forward "^[^ \t:]*:" nil t)
1670 ;; Mark the rank of the header.
1672 (point) (1+ (point)) 'message-rank
1673 (if (or (and visible (looking-at visible))
1675 (not (looking-at ignored))))
1676 (gnus-article-header-rank)
1679 (message-sort-headers-1)
1680 (when (setq beg (text-property-any
1681 (point-min) (point-max) 'message-rank (+ 2 max)))
1682 ;; We delete or make invisible the unwanted headers.
1683 (gnus-add-wash-type 'headers)
1686 (add-text-properties
1687 (point-min) (+ 5 (point-min))
1688 '(article-type headers dummy-invisible t))
1689 (delete-region beg (point-max)))
1690 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1692 (defun article-hide-boring-headers (&optional arg)
1693 "Toggle hiding of headers that aren't very interesting.
1694 If given a negative prefix, always show; if given a positive prefix,
1696 (interactive (gnus-article-hidden-arg))
1697 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1698 (not gnus-show-all-headers))
1701 (let ((buffer-read-only nil)
1702 (list gnus-boring-article-headers)
1703 (inhibit-point-motion-hooks t)
1705 (article-narrow-to-head)
1707 (setq elem (pop list))
1708 (goto-char (point-min))
1710 ;; Hide empty headers.
1712 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1714 (gnus-article-hide-text-type
1715 (progn (beginning-of-line) (point))
1718 (if (re-search-forward "^[^ \t]" nil t)
1722 ;; Hide boring Newsgroups header.
1723 ((eq elem 'newsgroups)
1724 (when (gnus-string-equal
1725 (gnus-fetch-field "newsgroups")
1726 (gnus-group-real-name
1727 (if (boundp 'gnus-newsgroup-name)
1730 (gnus-article-hide-header "newsgroups")))
1731 ((eq elem 'to-address)
1732 (let ((to (message-fetch-field "to"))
1734 (gnus-parameter-to-address
1735 (if (boundp 'gnus-newsgroup-name)
1736 gnus-newsgroup-name ""))))
1737 (when (and to to-address
1740 ;; only one address in To
1741 (nth 1 (mail-extract-address-components to))
1743 (gnus-article-hide-header "to"))))
1744 ((eq elem 'followup-to)
1745 (when (gnus-string-equal
1746 (message-fetch-field "followup-to")
1747 (message-fetch-field "newsgroups"))
1748 (gnus-article-hide-header "followup-to")))
1749 ((eq elem 'reply-to)
1750 (let ((from (message-fetch-field "from"))
1751 (reply-to (message-fetch-field "reply-to")))
1756 (nth 1 (mail-extract-address-components from))
1757 (nth 1 (mail-extract-address-components reply-to)))))
1758 (gnus-article-hide-header "reply-to"))))
1760 (let ((date (message-fetch-field "date")))
1762 (< (days-between (current-time-string) date)
1764 (gnus-article-hide-header "date"))))
1766 (let ((to (message-fetch-field "to"))
1767 (cc (message-fetch-field "cc")))
1768 (when (> (length to) 1024)
1769 (gnus-article-hide-header "to"))
1770 (when (> (length cc) 1024)
1771 (gnus-article-hide-header "cc"))))
1775 (goto-char (point-min))
1776 (while (re-search-forward "^to:" nil t)
1777 (setq to-count (1+ to-count)))
1778 (when (> to-count 1)
1779 (while (> to-count 0)
1780 (goto-char (point-min))
1782 (re-search-forward "^to:" nil nil to-count)
1784 (narrow-to-region (point) (point-max))
1785 (gnus-article-hide-header "to"))
1786 (setq to-count (1- to-count))))
1787 (goto-char (point-min))
1788 (while (re-search-forward "^cc:" nil t)
1789 (setq cc-count (1+ cc-count)))
1790 (when (> cc-count 1)
1791 (while (> cc-count 0)
1792 (goto-char (point-min))
1794 (re-search-forward "^cc:" nil nil cc-count)
1796 (narrow-to-region (point) (point-max))
1797 (gnus-article-hide-header "cc"))
1798 (setq cc-count (1- cc-count)))))))))))))
1800 (defun gnus-article-hide-header (header)
1802 (goto-char (point-min))
1803 (when (re-search-forward (concat "^" header ":") nil t)
1804 (gnus-article-hide-text-type
1805 (progn (beginning-of-line) (point))
1808 (if (re-search-forward "^[^ \t]" nil t)
1813 (defvar gnus-article-normalized-header-length 40
1814 "Length of normalized headers.")
1816 (defun article-normalize-headers ()
1817 "Make all header lines 40 characters long."
1819 (let ((buffer-read-only nil)
1823 (article-narrow-to-head)
1826 ((< (setq column (- (gnus-point-at-eol) (point)))
1827 gnus-article-normalized-header-length)
1829 (insert (make-string
1830 (- gnus-article-normalized-header-length column)
1832 ((> column gnus-article-normalized-header-length)
1833 (gnus-put-text-property
1835 (forward-char gnus-article-normalized-header-length)
1842 (forward-line 1))))))
1844 (defun article-treat-dumbquotes ()
1845 "Translate M****s*** sm*rtq**t*s into proper text.
1846 Note that this function guesses whether a character is a sm*rtq**t* or
1847 not, so it should only be used interactively.
1849 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1850 in an attempt to provide more quoting characters. If you see
1851 something like \\222 or \\264 where you're expecting some kind of
1852 apostrophe or quotation mark, then try this wash."
1854 (article-translate-strings gnus-article-dumbquotes-map))
1856 (defun article-translate-characters (from to)
1857 "Translate all characters in the body of the article according to FROM and TO.
1858 FROM is a string of characters to translate from; to is a string of
1859 characters to translate to."
1861 (when (article-goto-body)
1862 (let ((buffer-read-only nil)
1863 (x (make-string 225 ?x))
1865 (while (< (incf i) (length x))
1868 (while (< i (length from))
1869 (aset x (aref from i) (aref to i))
1871 (translate-region (point) (point-max) x)))))
1873 (defun article-translate-strings (map)
1874 "Translate all string in the body of the article according to MAP.
1875 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1877 (when (article-goto-body)
1878 (let ((buffer-read-only nil)
1880 (while (setq elem (pop map))
1882 (while (search-forward (car elem) nil t)
1883 (replace-match (cadr elem)))))))))
1885 (defun article-treat-overstrike ()
1886 "Translate overstrikes into bold text."
1889 (when (article-goto-body)
1890 (let ((buffer-read-only nil))
1891 (while (search-forward "\b" nil t)
1892 (let ((next (char-after))
1896 previous (char-after))
1900 ;; We do the boldification/underlining by hiding the
1901 ;; overstrikes and putting the proper text property
1905 (gnus-article-hide-text-type start (point) 'overstrike)
1906 (put-text-property (point) end 'face 'bold))
1908 (gnus-article-hide-text-type
1909 (1- (point)) (1+ (point)) 'overstrike)
1911 start (1- (point)) 'face 'underline))
1913 (gnus-article-hide-text-type start (point) 'overstrike)
1915 (point) end 'face 'underline)))))))))
1917 (defun gnus-article-treat-unfold-headers ()
1918 "Unfold folded message headers.
1919 Only the headers that fit into the current window width will be
1922 (gnus-with-article-headers
1926 (mail-header-narrow-to-field)
1927 (let ((header (buffer-substring (point-min) (point-max))))
1930 (goto-char (point-min))
1931 (while (re-search-forward "\n[\t ]" nil t)
1932 (replace-match " " t t)))
1933 (setq length (- (point-max) (point-min) 1)))
1934 (when (< length (window-width))
1935 (while (re-search-forward "\n[\t ]" nil t)
1936 (replace-match " " t t)))
1937 (goto-char (point-max)))))))
1939 (defun gnus-article-treat-fold-headers ()
1940 "Fold message headers."
1942 (gnus-with-article-headers
1945 (mail-header-narrow-to-field)
1946 (mail-header-fold-field)
1947 (goto-char (point-max))))))
1949 (defun gnus-treat-smiley ()
1950 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1952 (unless (featurep 'xemacs)
1953 (when (and (>= emacs-major-version 21)
1954 (not gnus-article-should-use-smiley-mule)
1955 gnus-article-smiley-mule-loaded-p)
1956 (load "smiley" nil t)
1957 (setq gnus-article-smiley-mule-loaded-p nil))
1958 (when (and gnus-article-should-use-smiley-mule
1959 (not gnus-article-smiley-mule-loaded-p))
1960 (load "smiley-mule" nil t)
1961 (setq gnus-article-smiley-mule-loaded-p t)))
1962 (gnus-with-article-buffer
1963 (if (memq 'smiley gnus-article-wash-types)
1964 (gnus-delete-images 'smiley)
1966 (let ((images (smiley-region (point) (point-max))))
1968 (gnus-add-wash-type 'smiley)
1969 (dolist (image images)
1970 (gnus-add-image 'smiley image)))))))
1972 (defun gnus-article-remove-images ()
1973 "Remove all images from the article buffer."
1975 (gnus-with-article-buffer
1976 (dolist (elem gnus-article-image-alist)
1977 (gnus-delete-images (car elem)))))
1979 (defun gnus-article-treat-fold-newsgroups ()
1980 "Unfold folded message headers.
1981 Only the headers that fit into the current window width will be
1984 (gnus-with-article-headers
1985 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1987 (mail-header-narrow-to-field)
1988 (while (re-search-forward ", *" nil t)
1989 (replace-match ", " t t))
1990 (mail-header-fold-field)
1991 (goto-char (point-max))))))
1993 (defun gnus-article-treat-body-boundary ()
1994 "Place a boundary line at the end of the headers."
1996 (when (and gnus-body-boundary-delimiter
1997 (> (length gnus-body-boundary-delimiter) 0))
1998 (gnus-with-article-headers
1999 (goto-char (point-max))
2000 (let ((start (point)))
2001 (insert "X-Boundary: ")
2002 (gnus-add-text-properties start (point) '(invisible t intangible t))
2004 (while (>= (1- (window-width)) (length str))
2005 (setq str (concat str gnus-body-boundary-delimiter)))
2006 (substring str 0 (1- (window-width))))
2008 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2010 (defun article-fill-long-lines ()
2011 "Fill lines that are wider than the window width."
2014 (let ((buffer-read-only nil)
2015 (width (window-width (get-buffer-window (current-buffer)))))
2018 (let ((adaptive-fill-mode nil)) ;Why? -sm
2021 (when (>= (current-column) (min fill-column width))
2022 (narrow-to-region (min (1+ (point)) (point-max))
2023 (gnus-point-at-bol))
2024 (let ((goback (point-marker)))
2025 (fill-paragraph nil)
2026 (goto-char (marker-position goback)))
2028 (forward-line 1)))))))
2030 (defun article-capitalize-sentences ()
2031 "Capitalize the first word in each sentence."
2034 (let ((buffer-read-only nil)
2035 (paragraph-start "^[\n\^L]"))
2039 (forward-sentence)))))
2041 (defun article-remove-cr ()
2042 "Remove trailing CRs and then translate remaining CRs into LFs."
2045 (let ((buffer-read-only nil))
2046 (goto-char (point-min))
2047 (while (re-search-forward "\r+$" nil t)
2048 (replace-match "" t t))
2049 (goto-char (point-min))
2050 (while (search-forward "\r" nil t)
2051 (replace-match "\n" t t)))))
2053 (defun article-remove-trailing-blank-lines ()
2054 "Remove all trailing blank lines from the article."
2057 (let ((buffer-read-only nil))
2058 (goto-char (point-max))
2062 (while (and (not (bobp))
2063 (looking-at "^[ \t]*$")
2064 (not (gnus-annotation-in-region-p
2065 (point) (gnus-point-at-eol))))
2070 (defun article-display-face ()
2071 "Display any Face headers in the header."
2073 (gnus-with-article-headers
2076 (when (gnus-buffer-live-p gnus-original-article-buffer)
2077 (set-buffer gnus-original-article-buffer)
2078 (setq face (message-fetch-field "face"))))
2080 (let ((png (gnus-convert-face-to-png face))
2083 (setq image (gnus-create-image png 'png t))
2084 (gnus-article-goto-header "from")
2086 (insert "From: [no `from' set]\n")
2088 (gnus-add-wash-type 'face)
2089 (gnus-add-image 'face image)
2090 (gnus-put-image image)))))))
2092 (defun article-display-x-face (&optional force)
2093 "Look for an X-Face header and display it if present."
2094 (interactive (list 'force))
2095 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2096 (gnus-with-article-headers
2097 ;; Delete the old process, if any.
2098 (when (process-status "article-x-face")
2099 (delete-process "article-x-face"))
2100 (if (memq 'xface gnus-article-wash-types)
2101 ;; We have already displayed X-Faces, so we remove them
2103 (gnus-delete-images 'xface)
2105 (let (x-faces from face grey)
2107 (when (and wash-face-p
2109 (goto-char (point-min))
2110 (not (re-search-forward
2111 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2112 (gnus-buffer-live-p gnus-original-article-buffer))
2113 ;; If type `W f', use gnus-original-article-buffer,
2114 ;; otherwise use the current buffer because displaying
2115 ;; RFC822 parts calls this function too.
2116 (set-buffer gnus-original-article-buffer))
2118 (mail-narrow-to-head)
2119 (if gnus-treat-display-grey-xface
2121 (while (gnus-article-goto-header "X-Face\\(-[0-9]+\\)?")
2122 (if (match-beginning 2)
2125 (push (cons (- (string-to-number (match-string 2)))
2126 (mail-header-field-value))
2128 (push (cons 0 (mail-header-field-value)) x-faces)))
2129 (dolist (x-face (prog1
2131 (sort x-faces 'car-less-than-car)
2133 (setq x-faces nil)))
2134 (push (cdr x-face) x-faces)))
2135 (while (gnus-article-goto-header "X-Face")
2136 (push (mail-header-field-value) x-faces)))
2137 (setq from (message-fetch-field "from"))))
2139 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
2142 (setq image (gnus-create-image xpm 'xpm t))
2143 (gnus-article-goto-header "from")
2145 (insert "From: [no `from' set]\n")
2147 (gnus-add-wash-type 'xface)
2148 (gnus-add-image 'xface image)
2149 (gnus-put-image image)))
2150 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2151 ;; single external face.
2152 (when (stringp gnus-article-x-face-command)
2153 (setq x-faces (list (car x-faces))))
2154 (while (and (setq face (pop x-faces))
2155 gnus-article-x-face-command
2157 ;; Check whether this face is censored.
2158 (not gnus-article-x-face-too-ugly)
2159 (and gnus-article-x-face-too-ugly from
2160 (not (string-match gnus-article-x-face-too-ugly
2162 ;; We display the face.
2163 (if (symbolp gnus-article-x-face-command)
2164 ;; The command is a lisp function, so we call it.
2165 (if (gnus-functionp gnus-article-x-face-command)
2166 (funcall gnus-article-x-face-command face)
2167 (error "%s is not a function" gnus-article-x-face-command))
2168 ;; The command is a string, so we interpret the command
2169 ;; as a, well, command, and fork it off.
2170 (let ((process-connection-type nil))
2171 (process-kill-without-query
2173 "article-x-face" nil shell-file-name shell-command-switch
2174 gnus-article-x-face-command))
2177 (process-send-region "article-x-face"
2178 (point-min) (point-max)))
2179 (process-send-eof "article-x-face"))))))))))
2181 (defun article-decode-mime-words ()
2182 "Decode all MIME-encoded words in the article."
2185 (set-buffer gnus-article-buffer)
2186 (let ((inhibit-point-motion-hooks t)
2188 (mail-parse-charset gnus-newsgroup-charset)
2189 (mail-parse-ignored-charsets
2190 (save-excursion (set-buffer gnus-summary-buffer)
2191 gnus-newsgroup-ignored-charsets)))
2192 (mail-decode-encoded-word-region (point-min) (point-max)))))
2194 (defun article-decode-charset (&optional prompt)
2195 "Decode charset-encoded text in the article.
2196 If PROMPT (the prefix), prompt for a coding system to use."
2198 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2200 (mail-parse-charset gnus-newsgroup-charset)
2201 (mail-parse-ignored-charsets
2202 (save-excursion (condition-case nil
2203 (set-buffer gnus-summary-buffer)
2205 gnus-newsgroup-ignored-charsets))
2206 ct cte ctl charset format)
2209 (article-narrow-to-head)
2210 (setq ct (message-fetch-field "Content-Type" t)
2211 cte (message-fetch-field "Content-Transfer-Encoding" t)
2212 ctl (and ct (ignore-errors
2213 (mail-header-parse-content-type ct)))
2216 (mm-read-coding-system "Charset to decode: "))
2218 (mail-content-type-get ctl 'charset)))
2219 format (and ctl (mail-content-type-get ctl 'format)))
2221 (setq cte (mail-header-strip cte)))
2222 (if (and ctl (not (string-match "/" (car ctl))))
2224 (goto-char (point-max)))
2227 (narrow-to-region (point) (point-max))
2228 (when (and (eq mail-parse-charset 'gnus-decoded)
2229 (eq (mm-body-7-or-8) '8bit))
2230 ;; The text code could have been decoded.
2231 (setq charset mail-parse-charset))
2232 (when (and (or (not ctl)
2233 (equal (car ctl) "text/plain"))
2234 (not format)) ;; article with format will decode later.
2236 charset (and cte (intern (downcase
2237 (gnus-strip-whitespace cte))))
2240 (defun article-decode-encoded-words ()
2241 "Remove encoded-word encoding from headers."
2242 (let (buffer-read-only)
2243 (let ((charset (save-excursion
2244 (set-buffer gnus-summary-buffer)
2245 default-mime-charset)))
2246 (mime-decode-header-in-buffer charset))))
2248 (defun article-decode-group-name ()
2249 "Decode group names in `Newsgroups:'."
2250 (let ((inhibit-point-motion-hooks t)
2252 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2253 (when (and (or gnus-group-name-charset-method-alist
2254 gnus-group-name-charset-group-alist)
2255 (gnus-buffer-live-p gnus-original-article-buffer))
2256 (when (nnmail-fetch-field "Newsgroups")
2257 (nnheader-replace-header "Newsgroups"
2258 (gnus-decode-newsgroups
2259 (with-current-buffer
2260 gnus-original-article-buffer
2261 (nnmail-fetch-field "Newsgroups"))
2262 gnus-newsgroup-name method)))
2263 (when (nnmail-fetch-field "Followup-To")
2264 (nnheader-replace-header "Followup-To"
2265 (gnus-decode-newsgroups
2266 (with-current-buffer
2267 gnus-original-article-buffer
2268 (nnmail-fetch-field "Followup-To"))
2269 gnus-newsgroup-name method))))))
2271 (defun article-de-quoted-unreadable (&optional force read-charset)
2272 "Translate a quoted-printable-encoded article.
2273 If FORCE, decode the article whether it is marked as quoted-printable
2275 If READ-CHARSET, ask for a coding system."
2276 (interactive (list 'force current-prefix-arg))
2278 (let ((buffer-read-only nil) type charset)
2279 (if (gnus-buffer-live-p gnus-original-article-buffer)
2280 (with-current-buffer gnus-original-article-buffer
2282 (gnus-fetch-field "content-transfer-encoding"))
2283 (let* ((ct (gnus-fetch-field "content-type"))
2286 (mail-header-parse-content-type ct)))))
2287 (setq charset (and ctl
2288 (mail-content-type-get ctl 'charset)))
2289 (if (stringp charset)
2290 (setq charset (intern (downcase charset)))))))
2292 (setq charset (mm-read-coding-system "Charset: " charset)))
2294 (setq charset gnus-newsgroup-charset))
2296 (and type (let ((case-fold-search t))
2297 (string-match "quoted-printable" type))))
2299 (quoted-printable-decode-region
2300 (point) (point-max) (mm-charset-to-coding-system charset))))))
2302 (defun article-de-base64-unreadable (&optional force read-charset)
2303 "Translate a base64 article.
2304 If FORCE, decode the article whether it is marked as base64 not.
2305 If READ-CHARSET, ask for a coding system."
2306 (interactive (list 'force current-prefix-arg))
2308 (let ((buffer-read-only nil) type charset)
2309 (if (gnus-buffer-live-p gnus-original-article-buffer)
2310 (with-current-buffer gnus-original-article-buffer
2312 (gnus-fetch-field "content-transfer-encoding"))
2313 (let* ((ct (gnus-fetch-field "content-type"))
2316 (mail-header-parse-content-type ct)))))
2317 (setq charset (and ctl
2318 (mail-content-type-get ctl 'charset)))
2319 (if (stringp charset)
2320 (setq charset (intern (downcase charset)))))))
2322 (setq charset (mm-read-coding-system "Charset: " charset)))
2324 (setq charset gnus-newsgroup-charset))
2326 (and type (let ((case-fold-search t))
2327 (string-match "base64" type))))
2330 (narrow-to-region (point) (point-max))
2331 (base64-decode-region (point-min) (point-max))
2332 (mm-decode-coding-region
2333 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2338 (defun article-decode-HZ ()
2339 "Translate a HZ-encoded article."
2343 (let ((buffer-read-only nil))
2344 (rfc1843-decode-region (point-min) (point-max)))))
2346 (defun article-unsplit-urls ()
2347 "Remove the newlines that some other mailers insert into URLs."
2350 (let ((buffer-read-only nil))
2351 (goto-char (point-min))
2352 (while (re-search-forward
2353 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2354 (replace-match "\\1\\3" t)))
2355 (when (and gnus-display-mime-function (interactive-p))
2356 (funcall gnus-display-mime-function))))
2359 (defun article-wash-html (&optional read-charset)
2360 "Format an HTML article.
2361 If READ-CHARSET, ask for a coding system."
2364 (let ((buffer-read-only nil)
2366 (when (gnus-buffer-live-p gnus-original-article-buffer)
2367 (with-current-buffer gnus-original-article-buffer
2368 (let* ((ct (gnus-fetch-field "content-type"))
2371 (mail-header-parse-content-type ct)))))
2372 (setq charset (and ctl
2373 (mail-content-type-get ctl 'charset)))
2374 (when (stringp charset)
2375 (setq charset (intern (downcase charset)))))))
2377 (setq charset (mm-read-coding-system "Charset: " charset)))
2379 (setq charset gnus-newsgroup-charset))
2381 (save-window-excursion
2383 (narrow-to-region (point) (point-max))
2384 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2385 (entry (assq func mm-text-html-washer-alist)))
2387 (setq func (cdr entry)))
2389 ((gnus-functionp func)
2392 (apply (car func) (cdr func))))))))))
2394 (defun gnus-article-wash-html-with-w3 ()
2395 "Wash the current buffer with w3."
2397 (let ((w3-strict-width (window-width))
2398 (url-standalone-mode t)
2399 (url-gateway-unplugged t)
2400 (w3-honor-stylesheets nil))
2402 (w3-region (point-min) (point-max))
2405 (defun gnus-article-wash-html-with-w3m ()
2406 "Wash the current buffer with emacs-w3m."
2409 (narrow-to-region (point) (point-max))
2410 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2413 (w3m-display-inline-images mm-inline-text-html-with-images)
2414 w3m-force-redisplay)
2415 (w3m-region (point-min) (point-max)))
2416 (when mm-inline-text-html-with-w3m-keymap
2417 (add-text-properties
2418 (point-min) (point-max)
2419 (nconc (mm-w3m-local-map-property)
2420 '(mm-inline-text-html-with-w3m t))))))
2422 (defun article-hide-list-identifiers ()
2423 "Remove list identifies from the Subject header.
2424 The `gnus-list-identifiers' variable specifies what to do."
2426 (let ((inhibit-point-motion-hooks t)
2427 (regexp (if (consp gnus-list-identifiers)
2428 (mapconcat 'identity gnus-list-identifiers " *\\|")
2429 gnus-list-identifiers))
2434 (article-narrow-to-head)
2435 (goto-char (point-min))
2436 (while (re-search-forward
2437 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2439 (delete-region (match-beginning 2) (match-end 0))
2440 (beginning-of-line))
2441 (when (re-search-forward
2442 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2443 (delete-region (match-beginning 1) (match-end 1))))))))
2445 (defun article-hide-pgp ()
2446 "Remove any PGP headers and signatures in the current article."
2450 (let ((inhibit-point-motion-hooks t)
2451 buffer-read-only beg end)
2453 ;; Hide the "header".
2454 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2455 (gnus-add-wash-type 'pgp)
2456 (delete-region (match-beginning 0) (match-end 0))
2457 ;; Remove armor headers (rfc2440 6.2)
2458 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2461 ;; Hide the actual signature.
2462 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2463 (setq end (1+ (match-beginning 0)))
2466 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2468 ;; Perhaps we shouldn't hide to the end of the buffer
2469 ;; if there is no end to the signature?
2471 ;; Hide "- " PGP quotation markers.
2473 (narrow-to-region beg end)
2474 (goto-char (point-min))
2475 (while (re-search-forward "^- " nil t)
2477 (match-beginning 0) (match-end 0)))
2479 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2481 (defun article-hide-pem (&optional arg)
2482 "Toggle hiding of any PEM headers and signatures in the current article.
2483 If given a negative prefix, always show; if given a positive prefix,
2485 (interactive (gnus-article-hidden-arg))
2486 (unless (gnus-article-check-hidden-text 'pem arg)
2488 (let (buffer-read-only end)
2489 (goto-char (point-min))
2490 ;; Hide the horrendously ugly "header".
2491 (when (and (search-forward
2492 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2494 (setq end (1+ (match-beginning 0))))
2495 (gnus-add-wash-type 'pem)
2496 (gnus-article-hide-text-type
2498 (if (search-forward "\n\n" nil t)
2502 ;; Hide the trailer as well
2503 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2505 (gnus-article-hide-text-type
2506 (match-beginning 0) (match-end 0) 'pem)))))))
2508 (defun article-strip-banner ()
2509 "Strip the banner specified by the `banner' group parameter."
2513 (let ((inhibit-point-motion-hooks t)
2514 (banner (gnus-parameter-banner gnus-newsgroup-name))
2515 (gnus-signature-limit nil)
2516 buffer-read-only beg end)
2517 (when (and gnus-article-address-banner-alist
2520 (let ((from (save-restriction
2522 (article-narrow-to-head)
2523 (mail-fetch-field "from"))))
2526 (caar (mail-header-parse-addresses from))))
2528 (dolist (pair gnus-article-address-banner-alist)
2529 (when (string-match (car pair) from)
2530 (throw 'found (cdr pair)))))))))
2534 ((eq banner 'signature)
2535 (when (gnus-article-narrow-to-signature)
2538 (delete-region (point) (point-max))))
2540 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2541 (while (re-search-forward banner nil t)
2542 (delete-region (match-beginning 0) (match-end 0)))))
2544 (while (re-search-forward banner nil t)
2545 (delete-region (match-beginning 0) (match-end 0))))))))))
2547 (defun article-babel ()
2548 "Translate article using an online translation service."
2552 (set-buffer gnus-article-buffer)
2553 (when (article-goto-body)
2554 (let* ((buffer-read-only nil)
2557 (orig (buffer-substring start end))
2558 (trans (babel-as-string orig)))
2560 (narrow-to-region start end)
2561 (delete-region start end)
2564 (defun article-hide-signature (&optional arg)
2565 "Hide the signature in the current article.
2566 If given a negative prefix, always show; if given a positive prefix,
2568 (interactive (gnus-article-hidden-arg))
2574 (article-goto-body))
2575 (goto-char (point-min)))
2576 (unless (gnus-article-check-hidden-text 'signature arg)
2577 (let ((buffer-read-only nil)
2579 (while (setq button (text-property-any button (point-max)
2581 'gnus-signature-toggle))
2582 (setq button (text-property-not-all button (point-max)
2584 'gnus-signature-toggle))
2585 (when (and button (not (eobp)))
2586 (gnus-article-hide-text-type
2588 (next-single-property-change (1+ button) 'mime-view-entity
2591 (gnus-set-mode-line 'article))
2593 (defun article-strip-headers-in-body ()
2594 "Strip offensive headers from bodies."
2598 (let ((case-fold-search t))
2599 (when (looking-at "x-no-archive:")
2600 (gnus-delete-line)))))
2602 (defun article-strip-leading-blank-lines ()
2603 "Remove all blank lines from the beginning of the article."
2606 (let ((inhibit-point-motion-hooks t)
2608 (when (article-goto-body)
2609 (while (and (not (eobp))
2610 (looking-at "[ \t]*$"))
2611 (gnus-delete-line))))))
2613 (defun article-narrow-to-head ()
2614 "Narrow the buffer to the head of the message.
2615 Point is left at the beginning of the narrowed-to region."
2617 (goto-char (point-min))
2618 (if (search-forward "\n\n" nil 1)
2621 (goto-char (point-min)))
2623 (defun article-goto-body ()
2624 "Place point at the start of the body."
2625 (goto-char (point-min))
2627 ;; This variable is only bound when dealing with separate
2629 (article-goto-body-goes-to-point-min-p
2631 ((search-forward "\n\n" nil t)
2634 (goto-char (point-max))
2637 (defun article-strip-multiple-blank-lines ()
2638 "Replace consecutive blank lines with one empty line."
2641 (let ((inhibit-point-motion-hooks t)
2643 ;; First make all blank lines empty.
2645 (while (re-search-forward "^[ \t]+$" nil t)
2646 (unless (gnus-annotation-in-region-p
2647 (match-beginning 0) (match-end 0))
2648 (replace-match "" nil t)))
2649 ;; Then replace multiple empty lines with a single empty line.
2651 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2652 (unless (gnus-annotation-in-region-p
2653 (match-beginning 0) (match-end 0))
2654 (delete-region (match-beginning 1) (match-end 1)))))))
2656 (defun article-strip-leading-space ()
2657 "Remove all white space from the beginning of the lines in the article."
2660 (let ((inhibit-point-motion-hooks t)
2663 (while (re-search-forward "^[ \t]+" nil t)
2664 (replace-match "" t t)))))
2666 (defun article-strip-trailing-space ()
2667 "Remove all white space from the end of the lines in the article."
2670 (let ((inhibit-point-motion-hooks t)
2673 (while (re-search-forward "[ \t]+$" nil t)
2674 (replace-match "" t t)))))
2676 (defun article-strip-blank-lines ()
2677 "Strip leading, trailing and multiple blank lines."
2679 (article-strip-leading-blank-lines)
2680 (article-remove-trailing-blank-lines)
2681 (article-strip-multiple-blank-lines))
2683 (defun article-strip-all-blank-lines ()
2684 "Strip all blank lines."
2687 (let ((inhibit-point-motion-hooks t)
2690 (while (re-search-forward "^[ \t]*\n" nil t)
2691 (replace-match "" t t)))))
2693 (defun gnus-article-narrow-to-signature ()
2694 "Narrow to the signature; return t if a signature is found, else nil."
2695 (let ((inhibit-point-motion-hooks t))
2696 (when (gnus-article-search-signature)
2698 ;; Check whether we have some limits to what we consider
2699 ;; to be a signature.
2700 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2701 (list gnus-signature-limit)))
2703 (while (setq limit (pop limits))
2704 (if (or (and (integerp limit)
2705 (< (- (point-max) (point)) limit))
2707 (< (count-lines (point) (point-max)) limit))
2708 (and (gnus-functionp limit)
2710 (and (stringp limit)
2711 (not (re-search-forward limit nil t))))
2712 () ; This limit did not succeed.
2716 (narrow-to-region (point) (point-max))
2719 (defun gnus-article-search-signature ()
2720 "Search the current buffer for the signature separator.
2721 Put point at the beginning of the signature separator."
2722 (let ((cur (point)))
2723 (goto-char (point-max))
2724 (if (if (stringp gnus-signature-separator)
2725 (re-search-backward gnus-signature-separator nil t)
2726 (let ((seps gnus-signature-separator))
2728 (not (re-search-backward (car seps) nil t)))
2735 (defun gnus-article-hidden-arg ()
2736 "Return the current prefix arg as a number, or 0 if no prefix."
2737 (list (if current-prefix-arg
2738 (prefix-numeric-value current-prefix-arg)
2741 (defun gnus-article-check-hidden-text (type arg)
2742 "Return nil if hiding is necessary.
2743 Arg can be nil or a number. nil and positive means hide, negative
2744 means show, 0 means toggle."
2747 (let ((hide (gnus-article-hidden-text-p type)))
2753 (gnus-article-show-hidden-text type)
2756 (if (eq hide 'hidden)
2758 (gnus-article-show-hidden-text type)
2762 (defun gnus-article-hidden-text-p (type)
2763 "Say whether the current buffer contains hidden text of type TYPE."
2764 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2766 (not (get-text-property pos 'invisible))
2767 (not (get-text-property pos 'dummy-invisible)))
2769 (text-property-any (1+ pos) (point-max) 'article-type type)))
2774 (defun gnus-article-show-hidden-text (type &optional dummy)
2775 "Show all hidden text of type TYPE.
2776 Originally it is hide instead of DUMMY."
2777 (let ((buffer-read-only nil)
2778 (inhibit-point-motion-hooks t))
2779 (gnus-remove-text-properties-when
2781 (point-min) (point-max)
2782 (cons 'article-type (cons type
2783 gnus-hidden-properties)))
2784 (gnus-delete-wash-type type)))
2786 (defconst article-time-units
2787 `((year . ,(* 365.25 24 60 60))
2788 (week . ,(* 7 24 60 60))
2789 (day . ,(* 24 60 60))
2793 "Mapping from time units to seconds.")
2795 (defun gnus-article-forward-header ()
2796 "Move point to the start of the next header.
2797 If the current header is a continuation header, this can be several
2802 (if (looking-at "[ \t]+[^ \t]")
2806 (defun article-date-ut (&optional type highlight header)
2807 "Convert DATE date to universal time in the current article.
2808 If TYPE is `local', convert to local time; if it is `lapsed', output
2809 how much time has lapsed since DATE. For `lapsed', the value of
2810 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2811 should replace the \"Date:\" one, or should be added below it."
2812 (interactive (list 'ut t))
2813 (let* ((header (or header
2814 (and (eq 1 (point-min))
2815 (mail-header-date (save-excursion
2816 (set-buffer gnus-summary-buffer)
2817 gnus-current-headers)))
2818 (message-fetch-field "date")
2820 (date (if (vectorp header) (mail-header-date header)
2822 (inhibit-point-motion-hooks t)
2823 bface eface date-pos)
2824 (when (and date (not (string= date "")))
2827 (article-narrow-to-head)
2828 (when (or (and (eq type 'lapsed)
2829 gnus-article-date-lapsed-new-header
2830 ;; Attempt to get the face of X-Sent first.
2831 (re-search-forward "^X-Sent:[ \t]" nil t))
2832 (re-search-forward "^Date:[ \t]" nil t)
2833 ;; If Date is missing, try again for X-Sent.
2834 (re-search-forward "^X-Sent:[ \t]" nil t))
2835 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2836 date (or (get-text-property (gnus-point-at-bol)
2839 eface (get-text-property (1- (gnus-point-at-eol))
2841 (let ((buffer-read-only nil))
2842 ;; Delete any old X-Sent headers.
2843 (when (setq date-pos
2844 (text-property-any (point-min) (point-max)
2845 'article-date-lapsed t))
2846 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2847 (delete-region (match-beginning 0)
2848 (progn (forward-line 1) (point))))
2849 (goto-char (point-min))
2850 ;; Delete any old Date headers.
2851 (while (re-search-forward "^Date:[ \t]" nil t)
2853 (setq date-pos (match-beginning 0)))
2854 (unless (and (eq type 'lapsed)
2855 gnus-article-date-lapsed-new-header)
2856 (delete-region (match-beginning 0)
2857 (progn (message-next-header) (point)))))
2860 (goto-char date-pos)
2862 ;; Possibly, Date has been deleted.
2864 (when (and (eq type 'lapsed)
2865 gnus-article-date-lapsed-new-header
2866 (looking-at "Date:"))
2868 (goto-char (point-min)))
2869 (insert (article-make-date-line date type))
2870 (when (eq type 'lapsed)
2871 (put-text-property (gnus-point-at-bol) (point)
2872 'article-date-lapsed t))
2876 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2877 (put-text-property (match-beginning 1) (1+ (match-end 1))
2878 'original-date date)
2879 (put-text-property (match-beginning 1) (1+ (match-end 1))
2881 (put-text-property (match-beginning 2) (match-end 2)
2884 (defun article-make-date-line (date type)
2885 "Return a DATE line of TYPE."
2886 (unless (memq type '(local ut original user iso8601 lapsed english))
2887 (error "Unknown conversion type: %s" type))
2889 (let ((time (date-to-time date)))
2891 ;; Convert to the local timezone.
2893 (let ((tz (car (current-time-zone time))))
2894 (format "Date: %s %s%02d%02d" (current-time-string time)
2895 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2896 (/ (% (abs tz) 3600) 60))))
2897 ;; Convert to Universal Time.
2900 (current-time-string
2901 (let* ((e (parse-time-string date))
2902 (tm (apply 'encode-time e))
2904 (ls (- (cadr tm) (car (current-time-zone time)))))
2905 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2906 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2909 ;; Get the original date from the article.
2910 ((eq type 'original)
2911 (concat "Date: " (if (string-match "\n+$" date)
2912 (substring date 0 (match-beginning 0))
2914 ;; Let the user define the format.
2916 (let ((format (or (condition-case nil
2917 (with-current-buffer gnus-summary-buffer
2918 gnus-article-time-format)
2920 gnus-article-time-format)))
2921 (if (gnus-functionp format)
2922 (funcall format time)
2923 (concat "Date: " (format-time-string format time)))))
2926 (let ((tz (car (current-time-zone time))))
2929 (format-time-string "%Y%m%dT%H%M%S" time)
2930 (format "%s%02d%02d"
2931 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2932 (/ (% (abs tz) 3600) 60)))))
2933 ;; Do an X-Sent lapsed format.
2935 ;; If the date is seriously mangled, the timezone functions are
2936 ;; liable to bug out, so we ignore all errors.
2937 (let* ((now (current-time))
2938 (real-time (subtract-time now time))
2939 (real-sec (and real-time
2940 (+ (* (float (car real-time)) 65536)
2942 (sec (and real-time (abs real-sec)))
2952 ;; This is a bit convoluted, but basically we go
2953 ;; through the time units for years, weeks, etc,
2954 ;; and divide things to see whether that results
2955 ;; in positive answers.
2958 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2959 ;; The (remaining) seconds are too few to
2960 ;; be divided into this time unit.
2962 ;; It's big enough, so we output it.
2963 (setq sec (- sec (* num (cdr unit))))
2965 (concat (if prev ", " "") (int-to-string
2967 " " (symbol-name (car unit))
2968 (if (> num 1) "s" ""))
2970 article-time-units "")
2971 ;; If dates are odd, then it might appear like the
2972 ;; article was sent in the future.
2975 " in the future"))))))
2976 ;; Display the date in proper English
2978 (let ((dtime (decode-time time)))
2981 (number-to-string (nth 3 dtime))
2982 (let ((digit (% (nth 3 dtime) 10)))
2984 ((memq (nth 3 dtime) '(11 12 13)) "th")
2990 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2992 (number-to-string (nth 5 dtime))
2994 (format "%02d" (nth 2 dtime))
2996 (format "%02d" (nth 1 dtime)))))))
2998 (format "Date: %s (from T-gnus)" date))))
3000 (defun article-date-local (&optional highlight)
3001 "Convert the current article date to the local timezone."
3002 (interactive (list t))
3003 (article-date-ut 'local highlight))
3005 (defun article-date-english (&optional highlight)
3006 "Convert the current article date to something that is proper English."
3007 (interactive (list t))
3008 (article-date-ut 'english highlight))
3010 (defun article-date-original (&optional highlight)
3011 "Convert the current article date to what it was originally.
3012 This is only useful if you have used some other date conversion
3013 function and want to see what the date was before converting."
3014 (interactive (list t))
3015 (article-date-ut 'original highlight))
3017 (defun article-date-lapsed (&optional highlight)
3018 "Convert the current article date to time lapsed since it was sent."
3019 (interactive (list t))
3020 (article-date-ut 'lapsed highlight))
3022 (defun article-update-date-lapsed ()
3023 "Function to be run from a timer to update the lapsed time line."
3024 (let (deactivate-mark)
3029 (set-buffer (window-buffer w))
3030 (when (eq major-mode 'gnus-article-mode)
3031 (goto-char (point-min))
3032 (when (re-search-forward "^X-Sent:" nil t)
3033 (article-date-lapsed t))))
3036 (defun gnus-start-date-timer (&optional n)
3037 "Start a timer to update the X-Sent header in the article buffers.
3038 The numerical prefix says how frequently (in seconds) the function
3043 (gnus-stop-date-timer)
3044 (setq article-lapsed-timer
3045 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
3047 (defun gnus-stop-date-timer ()
3048 "Stop the X-Sent timer."
3050 (when article-lapsed-timer
3051 (nnheader-cancel-timer article-lapsed-timer)
3052 (setq article-lapsed-timer nil)))
3054 (defun article-date-user (&optional highlight)
3055 "Convert the current article date to the user-defined format.
3056 This format is defined by the `gnus-article-time-format' variable."
3057 (interactive (list t))
3058 (article-date-ut 'user highlight))
3060 (defun article-date-iso8601 (&optional highlight)
3061 "Convert the current article date to ISO8601."
3062 (interactive (list t))
3063 (article-date-ut 'iso8601 highlight))
3065 ;; (defun article-show-all ()
3066 ;; "Show all hidden text in the article buffer."
3070 ;; (let ((buffer-read-only nil))
3071 ;; (gnus-article-unhide-text (point-min) (point-max))
3072 ;; (gnus-remove-text-with-property 'gnus-prev)
3073 ;; (gnus-remove-text-with-property 'gnus-next))))
3075 (defun article-show-all-headers ()
3076 "Show all hidden headers in the article buffer."
3081 (article-narrow-to-head)
3082 (let ((buffer-read-only nil))
3083 (gnus-article-unhide-text (point-min) (point-max))))))
3085 (defun article-remove-leading-whitespace ()
3086 "Remove excessive whitespace from all headers."
3090 (let ((buffer-read-only nil))
3091 (article-narrow-to-head)
3092 (goto-char (point-min))
3093 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3094 (delete-region (match-beginning 1) (match-end 1)))))))
3096 (defun article-emphasize (&optional arg)
3097 "Emphasize text according to `gnus-emphasis-alist'."
3098 (interactive (gnus-article-hidden-arg))
3099 (unless (gnus-article-check-hidden-text 'emphasis arg)
3103 (with-current-buffer gnus-summary-buffer
3104 gnus-article-emphasis-alist)
3106 gnus-emphasis-alist))
3107 (buffer-read-only nil)
3108 (props (append '(article-type emphasis)
3109 gnus-hidden-properties))
3110 regexp elem beg invisible visible face)
3113 (while (setq elem (pop alist))
3115 (setq regexp (car elem)
3116 invisible (nth 1 elem)
3117 visible (nth 2 elem)
3119 (while (re-search-forward regexp nil t)
3120 (when (and (match-beginning visible) (match-beginning invisible))
3121 (gnus-article-hide-text
3122 (match-beginning invisible) (match-end invisible) props)
3123 (gnus-article-unhide-text-type
3124 (match-beginning visible) (match-end visible) 'emphasis)
3125 (gnus-put-overlay-excluding-newlines
3126 (match-beginning visible) (match-end visible) 'face face)
3127 (gnus-add-wash-type 'emphasis)
3128 (goto-char (match-end invisible)))))))))
3130 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3131 "Setup newsgroup emphasis alist."
3132 (unless gnus-article-emphasis-alist
3133 (let ((name (and gnus-newsgroup-name
3134 (gnus-group-real-name gnus-newsgroup-name))))
3135 (make-local-variable 'gnus-article-emphasis-alist)
3136 (setq gnus-article-emphasis-alist
3138 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3139 (while (setq elem (pop alist))
3140 (when (and name (string-match (car elem) name))
3142 highlight (copy-sequence (cdr elem)))))
3144 (copy-sequence highlight-words)
3145 (if gnus-newsgroup-name
3146 (copy-sequence (gnus-group-find-parameter
3147 gnus-newsgroup-name 'highlight-words t)))
3148 gnus-emphasis-alist)))))
3151 (defvar gnus-summary-article-menu)
3152 (defvar gnus-summary-post-menu))
3154 ;;; Saving functions.
3156 (defun gnus-article-save (save-buffer file &optional num)
3157 "Save the currently selected article."
3158 (unless gnus-save-all-headers
3159 ;; Remove headers according to `gnus-saved-headers'.
3160 (let ((gnus-visible-headers
3161 (or gnus-saved-headers gnus-visible-headers))
3162 (gnus-article-buffer save-buffer))
3164 (set-buffer save-buffer)
3165 (article-hide-headers 1 t))))
3166 (save-window-excursion
3167 (if (not gnus-default-article-saver)
3168 (error "No default saver is defined")
3169 ;; !!! Magic! The saving functions all save
3170 ;; `gnus-save-article-buffer' (or so they think), but we
3171 ;; bind that variable to our save-buffer.
3172 (set-buffer gnus-article-buffer)
3173 (let* ((gnus-save-article-buffer save-buffer)
3176 ((not gnus-prompt-before-saving) 'default)
3177 ((eq gnus-prompt-before-saving 'always) nil)
3179 (gnus-number-of-articles-to-be-saved
3180 (when (eq gnus-prompt-before-saving t)
3182 (set-buffer gnus-article-current-summary)
3183 (funcall gnus-default-article-saver filename)))))
3185 (defun gnus-read-save-file-name (prompt &optional filename
3186 function group headers variable)
3188 (funcall function group headers (symbol-value variable)))
3193 ((eq filename 'default)
3199 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3202 (if (and gnus-number-of-articles-to-be-saved
3203 (> gnus-number-of-articles-to-be-saved 1))
3204 (format "these %d articles"
3205 gnus-number-of-articles-to-be-saved)
3208 ;; Let the split methods have their say.
3210 ;; No split name was found.
3213 (concat prompt " (default "
3214 (file-name-nondirectory default-name) ") ")
3215 (file-name-directory default-name)
3217 ;; A single group name is returned.
3218 ((stringp split-name)
3220 (funcall function split-name headers
3221 (symbol-value variable)))
3223 (concat prompt " (default "
3224 (file-name-nondirectory default-name) ") ")
3225 (file-name-directory default-name)
3227 ;; A single split name was found
3228 ((= 1 (length split-name))
3229 (let* ((name (expand-file-name
3231 gnus-article-save-directory))
3232 (dir (cond ((file-directory-p name)
3233 (file-name-as-directory name))
3234 ((file-exists-p name) name)
3235 (t gnus-article-save-directory))))
3237 (concat prompt " (default " name ") ")
3239 ;; A list of splits was found.
3241 (setq split-name (nreverse split-name))
3243 (let ((file-name-history
3244 (nconc split-name file-name-history)))
3248 (concat prompt " (`M-p' for defaults) ")
3249 gnus-article-save-directory
3251 gnus-article-save-directory)))
3252 (car (push result file-name-history)))))))
3253 ;; Create the directory.
3254 (gnus-make-directory (file-name-directory file))
3255 ;; If we have read a directory, we append the default file name.
3256 (when (file-directory-p file)
3257 (setq file (expand-file-name (file-name-nondirectory
3259 (file-name-as-directory file))))
3260 ;; Possibly translate some characters.
3261 (nnheader-translate-file-chars file))))))
3262 (gnus-make-directory (file-name-directory result))
3263 (set variable result)))
3265 (defun gnus-article-archive-name (group)
3266 "Return the first instance of an \"Archive-name\" in the current buffer."
3267 (let ((case-fold-search t))
3268 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3269 (nnheader-concat gnus-article-save-directory
3270 (match-string 1)))))
3272 (defun gnus-article-nndoc-name (group)
3273 "If GROUP is an nndoc group, return the name of the parent group."
3274 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3275 (gnus-group-get-parameter group 'save-article-group)))
3277 (defun gnus-summary-save-in-rmail (&optional filename)
3278 "Append this article to Rmail file.
3279 Optional argument FILENAME specifies file name.
3280 Directory to save to is default to `gnus-article-save-directory'."
3281 (setq filename (gnus-read-save-file-name
3282 "Save %s in rmail file:" filename
3283 gnus-rmail-save-name gnus-newsgroup-name
3284 gnus-current-headers 'gnus-newsgroup-last-rmail))
3285 (gnus-eval-in-buffer-window gnus-save-article-buffer
3289 (gnus-output-to-rmail filename))))
3292 (defun gnus-summary-save-in-mail (&optional filename)
3293 "Append this article to Unix mail file.
3294 Optional argument FILENAME specifies file name.
3295 Directory to save to is default to `gnus-article-save-directory'."
3296 (setq filename (gnus-read-save-file-name
3297 "Save %s in Unix mail file:" filename
3298 gnus-mail-save-name gnus-newsgroup-name
3299 gnus-current-headers 'gnus-newsgroup-last-mail))
3300 (gnus-eval-in-buffer-window gnus-save-article-buffer
3304 (if (and (file-readable-p filename)
3305 (mail-file-babyl-p filename))
3306 (rmail-output-to-rmail-file filename t)
3307 (gnus-output-to-mail filename)))))
3310 (defun gnus-summary-save-in-file (&optional filename overwrite)
3311 "Append this article to file.
3312 Optional argument FILENAME specifies file name.
3313 Directory to save to is default to `gnus-article-save-directory'."
3314 (setq filename (gnus-read-save-file-name
3315 "Save %s in file:" filename
3316 gnus-file-save-name gnus-newsgroup-name
3317 gnus-current-headers 'gnus-newsgroup-last-file))
3318 (gnus-eval-in-buffer-window gnus-save-article-buffer
3322 (when (and overwrite
3323 (file-exists-p filename))
3324 (delete-file filename))
3325 (gnus-output-to-file filename))))
3328 (defun gnus-summary-write-to-file (&optional filename)
3329 "Write this article to a file, overwriting it if the file exists.
3330 Optional argument FILENAME specifies file name.
3331 The directory to save in defaults to `gnus-article-save-directory'."
3332 (gnus-summary-save-in-file nil t))
3334 (defun gnus-summary-save-body-in-file (&optional filename)
3335 "Append this article body to a file.
3336 Optional argument FILENAME specifies file name.
3337 The directory to save in defaults to `gnus-article-save-directory'."
3338 (setq filename (gnus-read-save-file-name
3339 "Save %s body in file:" filename
3340 gnus-file-save-name gnus-newsgroup-name
3341 gnus-current-headers 'gnus-newsgroup-last-file))
3342 (gnus-eval-in-buffer-window gnus-save-article-buffer
3346 (when (article-goto-body)
3347 (narrow-to-region (point) (point-max)))
3348 (gnus-output-to-file filename))))
3351 (defun gnus-summary-save-in-pipe (&optional command)
3352 "Pipe this article to subprocess."
3354 (cond ((and (eq command 'default)
3355 gnus-last-shell-command)
3356 gnus-last-shell-command)
3361 "Shell command on %s: "
3362 (if (and gnus-number-of-articles-to-be-saved
3363 (> gnus-number-of-articles-to-be-saved 1))
3364 (format "these %d articles"
3365 gnus-number-of-articles-to-be-saved)
3367 gnus-last-shell-command))))
3368 (when (string-equal command "")
3369 (if gnus-last-shell-command
3370 (setq command gnus-last-shell-command)
3371 (error "A command is required")))
3372 (gnus-eval-in-buffer-window gnus-article-buffer
3375 (shell-command-on-region (point-min) (point-max) command nil)))
3376 (setq gnus-last-shell-command command))
3378 (defun gnus-summary-pipe-to-muttprint (&optional command)
3379 "Pipe this article to muttprint."
3380 (setq command (read-string
3381 "Print using command: " gnus-summary-muttprint-program
3382 nil gnus-summary-muttprint-program))
3383 (gnus-summary-save-in-pipe command))
3385 ;;; Article file names when saving.
3387 (defun gnus-capitalize-newsgroup (newsgroup)
3388 "Capitalize NEWSGROUP name."
3389 (when (not (zerop (length newsgroup)))
3390 (concat (char-to-string (upcase (aref newsgroup 0)))
3391 (substring newsgroup 1))))
3393 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3394 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3395 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3396 Otherwise, it is like ~/News/news/group/num."
3399 (concat (if (gnus-use-long-file-name 'not-save)
3400 (gnus-capitalize-newsgroup newsgroup)
3401 (gnus-newsgroup-directory-form newsgroup))
3402 "/" (int-to-string (mail-header-number headers)))
3403 gnus-article-save-directory)))
3405 (string-equal (file-name-directory default)
3406 (file-name-directory last-file))
3407 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3409 (or last-file default))))
3411 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3412 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3413 If variable `gnus-use-long-file-name' is non-nil, it is
3414 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3417 (concat (if (gnus-use-long-file-name 'not-save)
3419 (gnus-newsgroup-directory-form newsgroup))
3420 "/" (int-to-string (mail-header-number headers)))
3421 gnus-article-save-directory)))
3423 (string-equal (file-name-directory default)
3424 (file-name-directory last-file))
3425 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3427 (or last-file default))))
3429 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3430 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3431 If variable `gnus-use-long-file-name' is non-nil, it is
3432 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3435 (if (gnus-use-long-file-name 'not-save)
3438 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3440 gnus-article-save-directory)))
3442 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3443 "Generate file name from sender."
3444 (let ((from (mail-header-from headers)))
3446 (if (and from (string-match "\\([^ <]+\\)@" from))
3447 (match-string 1 from)
3449 gnus-article-save-directory)))
3451 (defun article-verify-x-pgp-sig ()
3454 (if (gnus-buffer-live-p gnus-original-article-buffer)
3455 (let ((sig (with-current-buffer gnus-original-article-buffer
3456 (gnus-fetch-field "X-PGP-Sig")))
3460 (mml2015-clear-verify-function))
3462 (insert-buffer-substring gnus-original-article-buffer)
3463 (setq items (split-string sig))
3464 (message-narrow-to-head)
3465 (let ((inhibit-point-motion-hooks t)
3466 (case-fold-search t))
3467 ;; Don't verify multiple headers.
3468 (setq headers (mapconcat (lambda (header)
3470 (mail-fetch-field header) "\n"))
3471 (split-string (nth 1 items) ",") "")))
3472 (delete-region (point-min) (point-max))
3473 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3474 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3479 (if (looking-at "^-")
3482 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3483 (insert "Version: " (car items) "\n\n")
3484 (insert (mapconcat 'identity (cddr items) "\n"))
3485 (insert "\n-----END PGP SIGNATURE-----\n")
3486 (let ((mm-security-handle (list (format "multipart/signed"))))
3487 (mml2015-clean-buffer)
3488 (let ((coding-system-for-write (or gnus-newsgroup-charset
3490 (funcall (mml2015-clear-verify-function)))
3492 (or (mm-handle-multipart-ctl-parameter
3493 mm-security-handle 'gnus-details)
3494 (mm-handle-multipart-ctl-parameter
3495 mm-security-handle 'gnus-info)))))
3497 (let (buffer-read-only bface eface)
3499 (message-narrow-to-head)
3500 (goto-char (point-max))
3502 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3503 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3504 (message-remove-header "X-Gnus-PGP-Verify")
3505 (if (re-search-forward "^X-PGP-Sig:" nil t)
3507 (goto-char (point-max)))
3508 (narrow-to-region (point) (point))
3509 (insert "X-Gnus-PGP-Verify: " info "\n")
3510 (goto-char (point-min))
3513 (if (not (looking-at "^[ \t]"))
3517 (goto-char (point-min))
3518 (when (looking-at "\\([^:]+\\): *")
3519 (put-text-property (match-beginning 1) (1+ (match-end 1))
3521 (put-text-property (match-end 0) (point-max)
3522 'face eface)))))))))
3524 (defun article-verify-cancel-lock ()
3525 "Verify Cancel-Lock header."
3527 (if (gnus-buffer-live-p gnus-original-article-buffer)
3528 (canlock-verify gnus-original-article-buffer)))
3530 (defun article-monafy ()
3531 "Display body part with mona font."
3533 (unless (if (featurep 'xemacs)
3534 (find-face 'gnus-mona-face)
3535 (facep 'gnus-mona-face))
3536 (require 'navi2ch-mona)
3537 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3539 (let ((buffer-read-only nil))
3542 (gnus-make-overlay (point) (point-max))
3543 'face 'gnus-mona-face))))
3550 (setq afunc (car func)
3553 gfunc (intern (format "gnus-%s" func))))
3555 (when (fboundp afunc)
3556 `(lambda (&optional interactive &rest args)
3557 ,(documentation afunc t)
3558 (interactive (list t))
3560 (set-buffer gnus-article-buffer)
3562 (call-interactively ',afunc)
3563 (apply ',afunc args))))))))
3564 '(article-hide-headers
3565 article-verify-x-pgp-sig
3566 article-verify-cancel-lock
3568 article-hide-boring-headers
3569 article-treat-overstrike
3570 article-fill-long-lines
3571 article-capitalize-sentences
3573 article-remove-leading-whitespace
3574 article-display-x-face
3575 article-display-face
3576 article-de-quoted-unreadable
3577 article-de-base64-unreadable
3580 article-unsplit-urls
3581 article-hide-list-identifiers
3583 article-strip-banner
3586 article-hide-signature
3587 article-strip-headers-in-body
3588 article-remove-trailing-blank-lines
3589 article-strip-leading-blank-lines
3590 article-strip-multiple-blank-lines
3591 article-strip-leading-space
3592 article-strip-trailing-space
3593 article-strip-blank-lines
3594 article-strip-all-blank-lines
3596 article-date-english
3597 article-date-iso8601
3598 article-date-original
3600 article-decode-mime-words
3601 article-decode-charset
3602 article-decode-encoded-words
3606 article-treat-dumbquotes
3607 article-normalize-headers
3608 (article-show-all-headers . gnus-article-show-all-headers)
3609 ;; (article-show-all . gnus-article-show-all)
3613 ;;; Gnus article mode
3616 (put 'gnus-article-mode 'mode-class 'special)
3618 (gnus-define-keys gnus-article-mode-map
3619 " " gnus-article-goto-next-page
3620 "\177" gnus-article-goto-prev-page
3621 [delete] gnus-article-goto-prev-page
3622 [backspace] gnus-article-goto-prev-page
3623 "\C-c^" gnus-article-refer-article
3624 "h" gnus-article-show-summary
3625 "s" gnus-article-show-summary
3626 "\C-c\C-m" gnus-article-mail
3627 "?" gnus-article-describe-briefly
3628 "e" gnus-summary-edit-article
3629 "<" beginning-of-buffer
3631 "\C-c\C-i" gnus-info-find-node
3633 "R" gnus-article-reply-with-original
3634 "F" gnus-article-followup-with-original
3635 "\C-hk" gnus-article-describe-key
3636 "\C-hc" gnus-article-describe-key-briefly
3638 "\C-d" gnus-article-read-summary-keys
3639 "\M-*" gnus-article-read-summary-keys
3640 "\M-#" gnus-article-read-summary-keys
3641 "\M-^" gnus-article-read-summary-keys
3642 "\M-g" gnus-article-read-summary-keys)
3644 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3648 (push (char-to-string key) keys)
3650 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3651 (setq key (car elem))
3652 (when (and (> (length key) 0)
3653 (not (eq 'menu-bar (aref key 0)))
3654 (symbolp (lookup-key gnus-summary-mode-map key)))
3657 (unless (lookup-key gnus-article-mode-map key)
3658 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3660 (defun gnus-article-make-menu-bar ()
3661 (unless (boundp 'gnus-article-commands-menu)
3662 (gnus-summary-make-menu-bar))
3663 (gnus-turn-off-edit-menu 'article)
3664 (unless (boundp 'gnus-article-article-menu)
3666 gnus-article-article-menu gnus-article-mode-map ""
3668 ["Scroll forwards" gnus-article-goto-next-page t]
3669 ["Scroll backwards" gnus-article-goto-prev-page t]
3670 ["Show summary" gnus-article-show-summary t]
3671 ["Fetch Message-ID at point" gnus-article-refer-article t]
3672 ["Mail to address at point" gnus-article-mail t]
3673 ["Send a bug report" gnus-bug t]))
3676 gnus-article-treatment-menu gnus-article-mode-map ""
3677 ;; Fixme: this should use :active (and maybe :visible).
3679 ["Hide headers" gnus-article-hide-headers t]
3680 ["Hide signature" gnus-article-hide-signature t]
3681 ["Hide citation" gnus-article-hide-citation t]
3682 ["Treat overstrike" gnus-article-treat-overstrike t]
3683 ["Remove carriage return" gnus-article-remove-cr t]
3684 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3685 ["Treat html" gnus-article-wash-html t]
3686 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3687 ["Decode HZ" gnus-article-decode-HZ t]))
3689 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3691 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3693 (gnus-run-hooks 'gnus-article-menu-hook)))
3695 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3698 (defun gnus-article-mode ()
3699 "Major mode for displaying an article.
3701 All normal editing commands are switched off.
3703 The following commands are available in addition to all summary mode
3705 \\<gnus-article-mode-map>
3706 \\[gnus-article-next-page]\t Scroll the article one page forwards
3707 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3708 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3709 \\[gnus-article-show-summary]\t Display the summary buffer
3710 \\[gnus-article-mail]\t Send a reply to the address near point
3711 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3712 \\[gnus-info-find-node]\t Go to the Gnus info node"
3714 (gnus-simplify-mode-line)
3715 (setq mode-name "Article")
3716 (setq major-mode 'gnus-article-mode)
3717 (make-local-variable 'minor-mode-alist)
3718 (unless (assq 'gnus-show-mime minor-mode-alist)
3719 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3720 (use-local-map gnus-article-mode-map)
3721 (when (gnus-visual-p 'article-menu 'menu)
3722 (gnus-article-make-menu-bar))
3723 (gnus-update-format-specifications nil 'article-mode)
3724 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3725 (make-local-variable 'gnus-page-broken)
3726 (make-local-variable 'gnus-button-marker-list)
3727 (make-local-variable 'gnus-article-current-summary)
3728 (make-local-variable 'gnus-article-mime-handles)
3729 (make-local-variable 'gnus-article-decoded-p)
3730 (make-local-variable 'gnus-article-mime-handle-alist)
3731 (make-local-variable 'gnus-article-wash-types)
3732 (make-local-variable 'gnus-article-image-alist)
3733 (make-local-variable 'gnus-article-charset)
3734 (make-local-variable 'gnus-article-ignored-charsets)
3735 (gnus-set-default-directory)
3736 (buffer-disable-undo)
3737 (setq buffer-read-only t)
3738 (set-syntax-table gnus-article-mode-syntax-table)
3739 (gnus-run-hooks 'gnus-article-mode-hook))
3741 (defun gnus-article-setup-buffer ()
3742 "Initialize the article buffer."
3743 (let* ((name (if gnus-single-article-buffer "*Article*"
3744 (concat "*Article " gnus-newsgroup-name "*")))
3746 (progn (string-match "\\*Article" name)
3747 (concat " *Original Article"
3748 (substring name (match-end 0))))))
3749 (setq gnus-article-buffer name)
3750 (setq gnus-original-article-buffer original)
3751 (setq gnus-article-mime-handle-alist nil)
3752 ;; This might be a variable local to the summary buffer.
3753 (unless gnus-single-article-buffer
3755 (set-buffer gnus-summary-buffer)
3756 (setq gnus-article-buffer name)
3757 (setq gnus-original-article-buffer original)
3758 (gnus-set-global-variables)))
3759 (gnus-article-setup-highlight-words)
3760 ;; Init original article buffer.
3762 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3763 (set-buffer-multibyte t)
3764 (setq major-mode 'gnus-original-article-mode)
3765 (make-local-variable 'gnus-original-article))
3766 (if (get-buffer name)
3769 (when (and gnus-article-edit-mode
3772 (y-or-n-p "Article mode edit in progress; discard? ")))
3773 (error "Action aborted"))
3774 (set (make-local-variable 'gnus-article-edit-mode) nil)
3775 (buffer-disable-undo)
3776 (setq buffer-read-only t)
3777 (unless (eq major-mode 'gnus-article-mode)
3778 (gnus-article-mode))
3781 (set-buffer (gnus-get-buffer-create name))
3783 (make-local-variable 'gnus-summary-buffer)
3784 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3785 (current-buffer)))))
3787 ;; Set article window start at LINE, where LINE is the number of lines
3788 ;; from the head of the article.
3789 (defun gnus-article-set-window-start (&optional line)
3791 (gnus-get-buffer-window gnus-article-buffer t)
3793 (set-buffer gnus-article-buffer)
3794 (goto-char (point-min))
3797 (gnus-message 6 "Moved to bookmark")
3798 (search-forward "\n\n" nil t)
3802 ;;; @@ article filters
3805 (defun gnus-article-display-mime-message ()
3806 "Article display method for MIME message."
3807 ;; called from `gnus-original-article-buffer'.
3808 (let (charset all-headers)
3809 (with-current-buffer gnus-summary-buffer
3810 (setq charset default-mime-charset
3811 all-headers gnus-have-all-headers))
3812 (make-local-variable 'default-mime-charset)
3813 (setq default-mime-charset charset)
3814 (with-current-buffer (get-buffer-create gnus-article-buffer)
3815 (make-local-variable 'default-mime-charset)
3816 (setq default-mime-charset charset))
3817 (mime-display-message mime-message-structure
3818 gnus-article-buffer nil gnus-article-mode-map)
3820 (gnus-article-hide-headers nil -1)))
3821 (run-hooks 'gnus-mime-article-prepare-hook))
3823 (defun gnus-article-display-traditional-message ()
3824 "Article display method for traditional message."
3825 (set-buffer gnus-article-buffer)
3826 (let (buffer-read-only)
3828 (insert-buffer-substring gnus-original-article-buffer)))
3830 (defun gnus-article-make-full-mail-header (&optional number charset)
3831 "Create a new mail header structure in a raw article buffer."
3832 (unless (and number charset)
3833 (save-current-buffer
3834 (set-buffer gnus-summary-buffer)
3836 (setq number (or (cdr gnus-article-current) 0)))
3838 (setq charset (or default-mime-charset 'x-ctext)))))
3839 (goto-char (point-min))
3840 (let ((header-end (if (search-forward "\n\n" nil t)
3842 (goto-char (point-max))))
3843 (chars (- (point-max) (point)))
3844 (lines (count-lines (point) (point-max)))
3845 (default-mime-charset charset)
3847 (narrow-to-region (point-min) header-end)
3848 (setq xref (std11-fetch-field "xref"))
3850 (make-full-mail-header
3852 (std11-fetch-field "subject")
3853 (std11-fetch-field "from")
3854 (std11-fetch-field "date")
3855 (std11-fetch-field "message-id")
3856 (std11-fetch-field "references")
3859 (when xref (concat "Xref: " xref)))
3862 (defun gnus-article-prepare (article &optional all-headers header)
3863 "Prepare ARTICLE in article mode buffer.
3864 ARTICLE should either be an article number or a Message-ID.
3865 If ARTICLE is an id, HEADER should be the article headers.
3866 If ALL-HEADERS is non-nil, no headers are hidden."
3868 ;; Make sure we start in a summary buffer.
3869 (unless (eq major-mode 'gnus-summary-mode)
3870 (set-buffer gnus-summary-buffer))
3871 (setq gnus-summary-buffer (current-buffer))
3872 (let* ((gnus-article (if header (mail-header-number header) article))
3873 (summary-buffer (current-buffer))
3874 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3875 (group gnus-newsgroup-name)
3878 (gnus-article-setup-buffer)
3879 (set-buffer gnus-article-buffer)
3880 ;; Deactivate active regions.
3881 (when (and (boundp 'transient-mark-mode)
3882 transient-mark-mode)
3883 (setq mark-active nil))
3884 (if (not (setq result (let ((buffer-read-only nil))
3885 (gnus-request-article-this-buffer
3887 ;; There is no such article.
3889 (when (and (numberp article)
3890 (not (memq article gnus-newsgroup-sparse)))
3891 (setq gnus-article-current
3892 (cons gnus-newsgroup-name article))
3893 (set-buffer gnus-summary-buffer)
3894 (setq gnus-current-article article)
3895 (if (memq article gnus-newsgroup-undownloaded)
3897 (gnus-summary-set-agent-mark article)
3898 (message "Message marked for downloading"))
3899 (gnus-summary-mark-article article gnus-canceled-mark)
3900 (unless (memq article gnus-newsgroup-sparse)
3901 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3902 (if (or (eq result 'pseudo)
3903 (eq result 'nneething))
3906 (set-buffer summary-buffer)
3907 (push article gnus-newsgroup-history)
3908 (setq gnus-last-article gnus-current-article
3909 gnus-current-article 0
3910 gnus-current-headers nil
3911 gnus-article-current nil)
3912 (if (eq result 'nneething)
3913 (gnus-configure-windows 'summary)
3914 (gnus-configure-windows 'article))
3915 (gnus-set-global-variables))
3916 (let ((gnus-article-mime-handle-alist-1
3917 gnus-article-mime-handle-alist))
3918 (gnus-set-mode-line 'article)))
3919 ;; The result from the `request' was an actual article -
3920 ;; or at least some text that is now displayed in the
3922 (when (and (numberp article)
3923 (not (eq article gnus-current-article)))
3924 ;; Seems like a new article has been selected.
3925 ;; `gnus-current-article' must be an article number.
3927 (set-buffer summary-buffer)
3928 (push article gnus-newsgroup-history)
3929 (setq gnus-last-article gnus-current-article
3930 gnus-current-article article
3931 gnus-current-headers
3932 (gnus-summary-article-header gnus-current-article)
3933 gnus-article-current
3934 (cons gnus-newsgroup-name gnus-current-article))
3935 (unless (vectorp gnus-current-headers)
3936 (setq gnus-current-headers nil))
3937 (gnus-summary-goto-subject gnus-current-article)
3938 (when (gnus-summary-show-thread)
3939 ;; If the summary buffer really was folded, the
3940 ;; previous goto may not actually have gone to
3941 ;; the right article, but the thread root instead.
3943 (gnus-summary-goto-subject gnus-current-article))
3944 (gnus-run-hooks 'gnus-mark-article-hook)
3945 (gnus-set-mode-line 'summary)
3946 (when (gnus-visual-p 'article-highlight 'highlight)
3947 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3948 ;; Set the global newsgroup variables here.
3949 (gnus-set-global-variables)
3950 (setq gnus-have-all-headers
3951 (or all-headers gnus-show-all-headers))))
3953 (gnus-configure-windows 'article))
3954 (when (or (numberp article)
3956 (gnus-article-prepare-display)
3958 (goto-char (point-min))
3959 (setq gnus-page-broken
3960 (when gnus-break-pages
3961 (gnus-narrow-to-page)
3963 (let ((gnus-article-mime-handle-alist-1
3964 gnus-article-mime-handle-alist))
3965 (gnus-set-mode-line 'article))
3969 (set-window-point (get-buffer-window (current-buffer)) (point))
3970 (gnus-configure-windows 'article)
3973 (defun gnus-article-prepare-mime-display (&optional number)
3974 (goto-char (point-min))
3975 (when (re-search-forward "^[^\t ]+:" nil t)
3976 (goto-char (match-beginning 0)))
3977 (let ((entity (if (eq 1 (point-min))
3978 (get-text-property 1 'mime-view-entity)
3979 (get-text-property (point) 'mime-view-entity)))
3980 last-entity child-entity next type)
3981 (setq child-entity (mime-entity-children entity))
3983 (setq last-entity (nth (1- (length child-entity))
3985 (setq last-entity entity))
3987 (narrow-to-region (point)
3988 (if (search-forward "\n\n" nil t)
3991 (gnus-treat-article 'head)
3992 (put-text-property (point-min) (point-max) 'article-treated-header t)
3993 (goto-char (point-max)))
3994 (while (and (not (eobp)) entity)
3995 (setq next (set-marker
3997 (next-single-property-change (point) 'mime-view-entity
3999 (let ((types (mime-entity-content-type entity)))
4000 (while (eq 'multipart (mime-content-type-primary-type types))
4001 (setq entity (car (mime-entity-children entity))
4002 types (mime-entity-content-type entity)))
4004 (setq type (format "%s/%s"
4005 (mime-content-type-primary-type types)
4006 (mime-content-type-subtype types)))))
4007 (if (string-equal type "message/rfc822")
4010 (let ((children (mime-entity-children entity))
4013 (setq last-children (nth (1- (length children)) children))
4016 (not (eq last-children
4017 (get-text-property next 'mime-view-entity)))
4019 (next-single-property-change next
4021 nil (point-max)))))))
4022 (setq next (next-single-property-change next 'mime-view-entity
4025 (narrow-to-region (point) next)
4026 (gnus-article-prepare-mime-display)
4027 (goto-char (point-max)))
4028 (setq entity (get-text-property (point) 'mime-view-entity)))
4030 (narrow-to-region (point) next)
4031 ;; Kludge. We have to count true number, but for now,
4032 ;; part number is here only to achieve `last'.
4033 (gnus-treat-article nil 1
4034 (if (eq entity last-entity)
4037 (goto-char (point-max)))
4038 (setq entity (get-text-property next 'mime-view-entity))))))
4041 (defun gnus-article-prepare-display ()
4042 "Make the current buffer look like a nice article."
4043 (let ((gnus-article-buffer (current-buffer))
4045 (unless (eq major-mode 'gnus-article-mode)
4046 (gnus-article-mode))
4047 (setq buffer-read-only nil
4048 gnus-button-marker-list nil
4049 gnus-article-wash-types nil
4050 gnus-article-image-alist nil)
4053 (static-if (featurep 'xemacs)
4054 (map-extents (lambda (extent maparg) (delete-extent extent)))
4055 (let ((lists (overlay-lists)))
4056 (dolist (overlay (nconc (car lists) (cdr lists)))
4057 (delete-overlay overlay)))))
4058 (gnus-run-hooks 'gnus-tmp-internal-hook))
4059 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4062 (inhibit-read-only t))
4063 (set-buffer gnus-original-article-buffer)
4065 (setq mime-message-structure gnus-current-headers)
4066 (mime-buffer-entity-set-buffer-internal mime-message-structure
4067 gnus-original-article-buffer)
4068 (mime-entity-set-representation-type-internal mime-message-structure
4069 'mime-buffer-entity)
4070 (luna-send mime-message-structure 'initialize-instance
4071 mime-message-structure)
4073 (let (mime-display-header-hook mime-display-text/plain-hook)
4074 (funcall gnus-article-display-method-for-mime))
4075 (funcall gnus-article-display-method-for-traditional))
4076 ;; Call the treatment functions.
4080 (gnus-article-prepare-mime-display)
4081 (narrow-to-region (goto-char (point-min))
4082 (if (search-forward "\n\n" nil t)
4085 (gnus-treat-article 'head)
4086 (put-text-property (point-min) (point-max) 'article-treated-header t)
4087 (goto-char (point-max))
4089 (narrow-to-region (point) (point-max))
4090 (gnus-treat-article nil))
4091 (put-text-property (point-min) (point-max) 'read-only nil)))
4092 (gnus-run-hooks 'gnus-article-prepare-hook))
4094 (defun gnus-article-decode-article-as-default-mime-charset ()
4095 "Decode an article as `default-mime-charset'. It won't work if the
4096 value of the variable `gnus-show-mime' is non-nil."
4097 (unless (or gnus-show-mime
4098 (member gnus-newsgroup-name '("nndraft:delayed"
4100 (set (make-local-variable 'default-mime-charset)
4101 (with-current-buffer gnus-summary-buffer
4102 default-mime-charset))
4103 (decode-mime-charset-region (point-min) (point-max)
4104 default-mime-charset)))
4107 ;;; Gnus MIME viewing functions
4110 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4111 "Format of the MIME buttons.
4113 Valid specifiers include:
4115 %T MIME type, along with additional info
4116 %n The `name' parameter
4117 %d The description, if any
4118 %l The length of the encoded part
4119 %p The part identifier number
4120 %e Dots if the part isn't displayed
4122 General format specifiers can also be used. See Info node
4123 `(gnus)Formatting Variables'.")
4125 (defvar gnus-mime-button-line-format-alist
4126 '((?t gnus-tmp-type ?s)
4127 (?T gnus-tmp-type-long ?s)
4128 (?n gnus-tmp-name ?s)
4129 (?d gnus-tmp-description ?s)
4131 (?l gnus-tmp-length ?d)
4132 (?e gnus-tmp-dots ?s)))
4134 (defvar gnus-mime-button-commands
4135 '((gnus-article-press-button "\r" "Toggle Display")
4136 (gnus-mime-view-part "v" "View Interactively...")
4137 (gnus-mime-view-part-as-type "t" "View As Type...")
4138 (gnus-mime-view-part-as-charset "C" "View As charset...")
4139 (gnus-mime-save-part "o" "Save...")
4140 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4141 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4142 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4143 (gnus-mime-view-part-internally "E" "View Internally")
4144 (gnus-mime-view-part-externally "e" "View Externally")
4145 (gnus-mime-print-part "p" "Print")
4146 (gnus-mime-pipe-part "|" "Pipe To Command...")
4147 (gnus-mime-action-on-part "." "Take action on the part")))
4149 (defun gnus-article-mime-part-status ()
4150 (with-current-buffer gnus-article-buffer
4151 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4154 (setq children (mime-entity-children entity))
4155 (setq children (length children)))
4158 (format " (%d parts)" children))
4161 (defvar gnus-mime-button-map
4162 (let ((map (make-sparse-keymap)))
4163 (unless (>= (string-to-number emacs-version) 21)
4164 ;; XEmacs doesn't care.
4165 (set-keymap-parent map gnus-article-mode-map))
4166 (define-key map gnus-mouse-2 'gnus-article-push-button)
4167 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4168 (dolist (c gnus-mime-button-commands)
4169 (define-key map (cadr c) (car c)))
4172 (defun gnus-mime-button-menu (event)
4173 "Construct a context-sensitive menu of MIME commands."
4175 (save-window-excursion
4176 (let ((pos (event-start event)))
4177 (select-window (posn-window pos))
4178 (goto-char (posn-point pos))
4179 (gnus-article-check-buffer)
4180 (let ((response (x-popup-menu
4182 ("" ,@(mapcar (lambda (c)
4183 (cons (caddr c) (car c)))
4184 gnus-mime-button-commands))))))
4186 (call-interactively response))))))
4188 (defun gnus-mime-view-all-parts (&optional handles)
4189 "View all the MIME parts."
4191 (save-current-buffer
4192 (set-buffer gnus-article-buffer)
4193 (let ((handles (or handles gnus-article-mime-handles))
4194 (mail-parse-charset gnus-newsgroup-charset)
4195 (mail-parse-ignored-charsets
4196 (with-current-buffer gnus-summary-buffer
4197 gnus-newsgroup-ignored-charsets)))
4199 (mm-remove-parts handles)
4200 (goto-char (point-min))
4201 (or (search-forward "\n\n") (goto-char (point-max)))
4202 (let (buffer-read-only)
4203 (delete-region (point) (point-max))
4204 (mm-display-parts handles))))))
4206 (defun gnus-mime-save-part-and-strip ()
4207 "Save the MIME part under point then replace it with an external body."
4209 (gnus-article-check-buffer)
4210 (let* ((data (get-text-property (point) 'gnus-data))
4212 (handles gnus-article-mime-handles))
4213 (if (mm-multiple-handles gnus-article-mime-handles)
4214 (error "This function is not implemented"))
4215 (setq file (and data (mm-save-part data)))
4217 (with-current-buffer (mm-handle-buffer data)
4219 (insert "Content-Type: " (mm-handle-media-type data))
4220 (mml-insert-parameter-string (cdr (mm-handle-type data))
4223 (insert "Content-ID: " (message-make-message-id) "\n")
4224 (insert "Content-Transfer-Encoding: binary\n")
4227 (cdr (mm-make-handle nil
4228 `("message/external-body"
4229 (access-type . "LOCAL-FILE")
4231 (set-buffer gnus-summary-buffer)
4232 (gnus-article-edit-article
4235 (let ((mail-parse-charset (or gnus-article-charset
4236 ',gnus-newsgroup-charset))
4237 (mail-parse-ignored-charsets
4238 (or gnus-article-ignored-charsets
4239 ',gnus-newsgroup-ignored-charsets))
4240 (mbl mml-buffer-list))
4241 (setq mml-buffer-list nil)
4242 (insert-buffer gnus-original-article-buffer)
4243 (mime-to-mml ',handles)
4244 (setq gnus-article-mime-handles nil)
4245 (let ((mbl1 mml-buffer-list))
4246 (setq mml-buffer-list mbl)
4247 (set (make-local-variable 'mml-buffer-list) mbl1))
4248 ;; LOCAL argument of add-hook differs between GNU Emacs
4249 ;; and XEmacs. make-local-hook makes sure they are local.
4250 (make-local-hook 'kill-buffer-hook)
4251 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4252 `(lambda (no-highlight)
4253 (let ((mail-parse-charset (or gnus-article-charset
4254 ',gnus-newsgroup-charset))
4255 (message-options message-options)
4256 (message-options-set-recipient)
4257 (mail-parse-ignored-charsets
4258 (or gnus-article-ignored-charsets
4259 ',gnus-newsgroup-ignored-charsets)))
4261 (mml-destroy-buffers)
4262 (remove-hook 'kill-buffer-hook
4263 'mml-destroy-buffers t)
4264 (kill-local-variable 'mml-buffer-list))
4265 (gnus-summary-edit-article-done
4266 ,(or (mail-header-references gnus-current-headers) "")
4267 ,(gnus-group-read-only-p)
4268 ,gnus-summary-buffer no-highlight))))))
4270 (defun gnus-mime-save-part ()
4271 "Save the MIME part under point."
4273 (gnus-article-check-buffer)
4274 (let ((data (get-text-property (point) 'gnus-data)))
4276 (mm-save-part data))))
4278 (defun gnus-mime-pipe-part ()
4279 "Pipe the MIME part under point to a process."
4281 (gnus-article-check-buffer)
4282 (let ((data (get-text-property (point) 'gnus-data)))
4284 (mm-pipe-part data))))
4286 (defun gnus-mime-view-part ()
4287 "Interactively choose a viewing method for the MIME part under point."
4289 (gnus-article-check-buffer)
4290 (let ((data (get-text-property (point) 'gnus-data)))
4292 (setq gnus-article-mime-handles
4294 gnus-article-mime-handles (setq data (copy-sequence data))))
4295 (mm-interactively-view-part data))))
4297 (defun gnus-mime-view-part-as-type-internal ()
4298 (gnus-article-check-buffer)
4299 (let* ((name (mail-content-type-get
4300 (mm-handle-type (get-text-property (point) 'gnus-data))
4302 (def-type (and name (mm-default-file-encoding name))))
4303 (and def-type (cons def-type 0))))
4305 (defun gnus-mime-view-part-as-type (&optional mime-type)
4306 "Choose a MIME media type, and view the part as such."
4309 (setq mime-type (completing-read
4310 "View as MIME type: "
4311 (mapcar #'list (mailcap-mime-types))
4313 (gnus-mime-view-part-as-type-internal))))
4314 (gnus-article-check-buffer)
4315 (let ((handle (get-text-property (point) 'gnus-data)))
4318 (mm-make-handle (mm-handle-buffer handle)
4319 (cons mime-type (cdr (mm-handle-type handle)))
4320 (mm-handle-encoding handle)
4321 (mm-handle-undisplayer handle)
4322 (mm-handle-disposition handle)
4323 (mm-handle-description handle)
4325 (mm-handle-id handle)))
4326 (setq gnus-article-mime-handles
4327 (mm-merge-handles gnus-article-mime-handles handle))
4328 (gnus-mm-display-part handle))))
4331 (require 'jka-compr))
4333 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4334 ;; emacs can do that itself.
4336 (defun gnus-mime-jka-compr-maybe-uncompress ()
4337 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4338 The uncompress method used is derived from `buffer-file-name'."
4339 (when (and (fboundp 'jka-compr-installed-p)
4340 (jka-compr-installed-p))
4341 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4343 (let ((basename (file-name-nondirectory buffer-file-name))
4344 (args (jka-compr-info-uncompress-args info))
4345 (prog (jka-compr-info-uncompress-program info))
4346 (message (jka-compr-info-uncompress-message info))
4347 (err-file (jka-compr-make-temp-name)))
4349 (message "%s %s..." message basename))
4351 (unless (memq (apply 'call-process-region
4352 (point-min) (point-max)
4354 t (list t err-file) nil
4356 jka-compr-acceptable-retval-list)
4357 (jka-compr-error prog args basename message err-file))
4358 (jka-compr-delete-temp-file err-file)))))))
4360 (defun gnus-mime-copy-part (&optional handle)
4361 "Put the MIME part under point into a new buffer.
4362 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4365 (gnus-article-check-buffer)
4366 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4367 (contents (and handle (mm-get-part handle)))
4369 (file-name-nondirectory
4371 (mail-content-type-get (mm-handle-type handle) 'name)
4372 (mail-content-type-get (mm-handle-disposition handle)
4375 (buffer (and base (generate-new-buffer base))))
4377 (switch-to-buffer buffer)
4379 ;; We do it this way to make `normal-mode' set the appropriate mode.
4382 (setq buffer-file-name (expand-file-name base))
4383 (gnus-mime-jka-compr-maybe-uncompress)
4385 (setq buffer-file-name nil))
4386 (goto-char (point-min)))))
4388 (defun gnus-mime-print-part (&optional handle filename)
4389 "Print the MIME part under point."
4390 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4391 (gnus-article-check-buffer)
4392 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4393 (contents (and handle (mm-get-part handle)))
4394 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4395 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4400 (mm-save-part-to-file handle file)
4401 (call-process shell-file-name nil
4402 (generate-new-buffer " *mm*")
4404 shell-command-switch
4406 printer file (mm-handle-type handle))))
4410 (gnus-print-buffer))
4411 (ps-despool filename)))))
4413 (defun gnus-mime-inline-part (&optional handle arg)
4414 "Insert the MIME part under point into the current buffer."
4415 (interactive (list nil current-prefix-arg))
4416 (gnus-article-check-buffer)
4417 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4422 (if (and (not arg) (mm-handle-undisplayer handle))
4423 (mm-remove-part handle)
4424 (setq contents (mm-get-part handle))
4427 (setq charset (or (mail-content-type-get
4428 (mm-handle-type handle) 'charset)
4429 gnus-newsgroup-charset)))
4431 (if (mm-handle-undisplayer handle)
4432 (mm-remove-part handle))
4435 gnus-summary-show-article-charset-alist))
4436 (mm-read-coding-system "Charset: ")))))
4438 (mm-insert-inline handle
4440 (setq charset (mm-charset-to-coding-system
4442 (not (eq charset 'ascii)))
4443 (mm-decode-coding-string contents charset)
4447 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4448 "Insert the MIME part under point into the current buffer using the
4450 (interactive (list nil current-prefix-arg))
4451 (gnus-article-check-buffer)
4452 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4457 (if (mm-handle-undisplayer handle)
4458 (mm-remove-part handle))
4459 (let ((gnus-newsgroup-charset
4461 gnus-summary-show-article-charset-alist))
4462 (mm-read-coding-system "Charset: ")))
4463 (gnus-newsgroup-ignored-charsets 'gnus-all))
4464 (gnus-article-press-button)))))
4466 (defun gnus-mime-view-part-externally (&optional handle)
4467 "View the MIME part under point with an external viewer."
4469 (gnus-article-check-buffer)
4470 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4471 (mm-user-display-methods nil)
4472 (mm-inlined-types nil)
4473 (mail-parse-charset gnus-newsgroup-charset)
4474 (mail-parse-ignored-charsets
4475 (save-excursion (set-buffer gnus-summary-buffer)
4476 gnus-newsgroup-ignored-charsets)))
4478 (if (mm-handle-undisplayer handle)
4479 (mm-remove-part handle)
4480 (mm-display-part handle)))))
4482 (defun gnus-mime-view-part-internally (&optional handle)
4483 "View the MIME part under point with an internal viewer.
4484 If no internal viewer is available, use an external viewer."
4486 (gnus-article-check-buffer)
4487 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4488 (mm-inlined-types '(".*"))
4489 (mm-inline-large-images t)
4490 (mail-parse-charset gnus-newsgroup-charset)
4491 (mail-parse-ignored-charsets
4492 (save-excursion (set-buffer gnus-summary-buffer)
4493 gnus-newsgroup-ignored-charsets)))
4495 (if (mm-handle-undisplayer handle)
4496 (mm-remove-part handle)
4497 (mm-display-part handle)))))
4499 (defun gnus-mime-action-on-part (&optional action)
4500 "Do something with the MIME attachment at \(point\)."
4502 (list (completing-read "Action: " gnus-mime-action-alist)))
4503 (gnus-article-check-buffer)
4504 (let ((action-pair (assoc action gnus-mime-action-alist)))
4506 (funcall (cdr action-pair)))))
4508 (defun gnus-article-part-wrapper (n function)
4509 (save-current-buffer
4510 (set-buffer gnus-article-buffer)
4511 (when (> n (length gnus-article-mime-handle-alist))
4512 (error "No such part"))
4513 (gnus-article-goto-part n)
4514 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4515 (funcall function handle))))
4517 (defun gnus-article-pipe-part (n)
4518 "Pipe MIME part N, which is the numerical prefix."
4520 (gnus-article-part-wrapper n 'mm-pipe-part))
4522 (defun gnus-article-save-part (n)
4523 "Save MIME part N, which is the numerical prefix."
4525 (gnus-article-part-wrapper n 'mm-save-part))
4527 (defun gnus-article-interactively-view-part (n)
4528 "View MIME part N interactively, which is the numerical prefix."
4530 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4532 (defun gnus-article-copy-part (n)
4533 "Copy MIME part N, which is the numerical prefix."
4535 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4537 (defun gnus-article-view-part-as-charset (n)
4538 "Copy MIME part N, which is the numerical prefix."
4540 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4542 (defun gnus-article-view-part-externally (n)
4543 "View MIME part N externally, which is the numerical prefix."
4545 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4547 (defun gnus-article-inline-part (n)
4548 "Inline MIME part N, which is the numerical prefix."
4550 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4552 (defun gnus-article-mime-match-handle-first (condition)
4554 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4555 (while (setq ihandle (pop alist))
4557 ((functionp condition)
4558 (funcall condition (cdr ihandle)))
4559 ((eq condition 'undisplayed)
4560 (not (or (mm-handle-undisplayer (cdr ihandle))
4561 (equal (mm-handle-media-type (cdr ihandle))
4562 "multipart/alternative"))))
4563 ((eq condition 'undisplayed-alternative)
4564 (not (mm-handle-undisplayer (cdr ihandle))))
4566 (gnus-article-goto-part (car ihandle))
4567 (or (not n) (< (car ihandle) n)))
4568 (setq n (car ihandle))))
4572 (defun gnus-article-view-part (&optional n)
4573 "View MIME part N, which is the numerical prefix."
4575 (save-current-buffer
4576 (set-buffer gnus-article-buffer)
4577 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4578 gnus-article-mime-match-handle-function)))
4579 (when (> n (length gnus-article-mime-handle-alist))
4580 (error "No such part"))
4581 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4582 (when (gnus-article-goto-part n)
4583 (if (equal (car handle) "multipart/alternative")
4584 (gnus-article-press-button)
4585 (when (eq (gnus-mm-display-part handle) 'internal)
4586 (gnus-set-window-start)))))))
4588 (defsubst gnus-article-mime-total-parts ()
4589 (if (bufferp (car gnus-article-mime-handles))
4591 (1- (length gnus-article-mime-handles))))
4593 (defun gnus-mm-display-part (handle)
4594 "Display HANDLE and fix MIME button."
4595 (let ((id (get-text-property (point) 'gnus-part))
4600 (let ((window (selected-window))
4601 (mail-parse-charset gnus-newsgroup-charset)
4602 (mail-parse-ignored-charsets
4603 (if (gnus-buffer-live-p gnus-summary-buffer)
4605 (set-buffer gnus-summary-buffer)
4606 gnus-newsgroup-ignored-charsets)
4610 (let ((win (gnus-get-buffer-window (current-buffer) t))
4613 (select-window win))
4616 (if (mm-handle-displayed-p handle)
4617 ;; This will remove the part.
4618 (mm-display-part handle)
4620 (narrow-to-region (point)
4621 (if (eobp) (point) (1+ (point))))
4622 (mm-display-part handle)
4623 ;; We narrow to the part itself and
4624 ;; then call the treatment functions.
4625 (goto-char (point-min))
4627 (narrow-to-region (point) (point-max))
4630 (gnus-article-mime-total-parts)
4631 (mm-handle-media-type handle)))))
4632 (if (window-live-p window)
4633 (select-window window)))))
4635 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4636 (gnus-insert-mime-button
4637 handle id (list (mm-handle-displayed-p handle)))
4638 (goto-char point))))
4640 (defun gnus-article-goto-part (n)
4641 "Go to MIME part N."
4642 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4644 (goto-char point))))
4646 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4647 (let ((gnus-tmp-name
4648 (or (mail-content-type-get (mm-handle-type handle) 'name)
4649 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4650 (mail-content-type-get (mm-handle-type handle) 'url)
4652 (gnus-tmp-type (mm-handle-media-type handle))
4653 (gnus-tmp-description
4654 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4657 (if (if displayed (car displayed)
4658 (mm-handle-displayed-p handle))
4660 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4662 gnus-tmp-type-long b e)
4663 (when (string-match ".*/" gnus-tmp-name)
4664 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4665 (setq gnus-tmp-type-long (concat gnus-tmp-type
4666 (and (not (equal gnus-tmp-name ""))
4667 (concat "; " gnus-tmp-name))))
4668 (unless (equal gnus-tmp-description "")
4669 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4674 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4675 `(,@(gnus-local-map-property gnus-mime-button-map)
4676 gnus-callback gnus-mm-display-part
4677 gnus-part ,gnus-tmp-id
4678 article-type annotation
4681 (widget-convert-button
4684 :action 'gnus-widget-press-button
4685 :button-keymap gnus-mime-button-map
4687 (lambda (widget/window &optional overlay pos)
4688 ;; Needed to properly clear the message due to a bug in
4689 ;; wid-edit (XEmacs only).
4690 (if (boundp 'help-echo-owns-message)
4691 (setq help-echo-owns-message t))
4693 "%S: %s the MIME part; %S: more options"
4694 (aref gnus-mouse-2 0)
4695 ;; XEmacs will get a single widget arg; Emacs 21 will get
4696 ;; window, overlay, position.
4697 (if (mm-handle-displayed-p
4699 (with-current-buffer (gnus-overlay-buffer overlay)
4700 (widget-get (widget-at (gnus-overlay-start overlay))
4702 (widget-get widget/window :mime-handle)))
4704 (aref gnus-down-mouse-3 0))))))
4706 (defun gnus-widget-press-button (elems el)
4707 (goto-char (widget-get elems :from))
4708 (gnus-article-press-button))
4710 (defvar gnus-displaying-mime nil)
4712 (defun gnus-display-mime (&optional ihandles)
4713 "Display the MIME parts."
4715 (save-selected-window
4716 (let ((window (get-buffer-window gnus-article-buffer))
4719 (select-window window)
4720 ;; We have to do this since selecting the window
4721 ;; may change the point. So we set the window point.
4722 (set-window-point window point)))
4723 (let* ((handles (or ihandles
4724 (mm-dissect-buffer nil gnus-article-loose-mime)
4725 (and gnus-article-emulate-mime
4727 buffer-read-only handle name type b e display)
4728 (when (and (not ihandles)
4729 (not gnus-displaying-mime))
4730 ;; Top-level call; we clean up.
4731 (when gnus-article-mime-handles
4732 (mm-destroy-parts gnus-article-mime-handles)
4733 (setq gnus-article-mime-handle-alist nil));; A trick.
4734 (setq gnus-article-mime-handles handles)
4735 ;; We allow users to glean info from the handles.
4736 (when gnus-article-mime-part-function
4737 (gnus-mime-part-function handles)))
4739 (or (not (stringp (car handles)))
4742 (when (and (not ihandles)
4743 (not gnus-displaying-mime))
4744 ;; Clean up for mime parts.
4746 (delete-region (point) (point-max)))
4747 (let ((gnus-displaying-mime t))
4748 (gnus-mime-display-part handles)))
4751 (narrow-to-region (point) (point-max))
4752 (gnus-treat-article nil 1 1)
4755 ;; Highlight the headers.
4759 (narrow-to-region (point-min) (point))
4760 (gnus-treat-article 'head))))))))
4762 (defvar gnus-mime-display-multipart-as-mixed nil)
4763 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4764 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4766 (defun gnus-mime-display-part (handle)
4769 ((not (stringp (car handle)))
4770 (gnus-mime-display-single handle))
4771 ;; User-defined multipart
4772 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4773 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4775 ;; multipart/alternative
4776 ((and (equal (car handle) "multipart/alternative")
4777 (not (or gnus-mime-display-multipart-as-mixed
4778 gnus-mime-display-multipart-alternative-as-mixed)))
4779 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4780 (push (cons id handle) gnus-article-mime-handle-alist)
4781 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4782 ;; multipart/related
4783 ((and (equal (car handle) "multipart/related")
4784 (not (or gnus-mime-display-multipart-as-mixed
4785 gnus-mime-display-multipart-related-as-mixed)))
4786 ;;;!!!We should find the start part, but we just default
4787 ;;;!!!to the first part.
4788 ;;(gnus-mime-display-part (cadr handle))
4789 ;;;!!! Most multipart/related is an HTML message plus images.
4790 ;;;!!! Unfortunately we are unable to let W3 display those
4791 ;;;!!! included images, so we just display it as a mixed multipart.
4792 ;;(gnus-mime-display-mixed (cdr handle))
4793 ;;;!!! No, w3 can display everything just fine.
4794 (gnus-mime-display-part (cadr handle)))
4795 ((equal (car handle) "multipart/signed")
4796 (gnus-add-wash-type 'signed)
4797 (gnus-mime-display-security handle))
4798 ((equal (car handle) "multipart/encrypted")
4799 (gnus-add-wash-type 'encrypted)
4800 (gnus-mime-display-security handle))
4801 ;; Other multiparts are handled like multipart/mixed.
4803 (gnus-mime-display-mixed (cdr handle)))))
4805 (defun gnus-mime-part-function (handles)
4806 (if (stringp (car handles))
4807 (mapcar 'gnus-mime-part-function (cdr handles))
4808 (funcall gnus-article-mime-part-function handles)))
4810 (defun gnus-mime-display-mixed (handles)
4811 (mapcar 'gnus-mime-display-part handles))
4813 (defun gnus-mime-display-single (handle)
4814 (let ((type (mm-handle-media-type handle))
4815 (ignored gnus-ignored-mime-types)
4822 (when (string-match (pop ignored) type)
4823 (throw 'ignored nil)))
4824 (if (and (setq not-attachment
4825 (and (not (mm-inline-override-p handle))
4826 (or (not (mm-handle-disposition handle))
4827 (equal (car (mm-handle-disposition handle))
4829 (mm-attachment-override-p handle))))
4830 (mm-automatic-display-p handle)
4832 (mm-inlinable-p handle)
4833 (mm-inlined-p handle))
4834 (mm-automatic-external-display-p type)))
4836 (when (equal (mm-handle-media-supertype handle) "text")
4838 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4840 (push (cons id handle) gnus-article-mime-handle-alist)
4841 (when (or (not display)
4842 (not (gnus-unbuttonized-mime-type-p type)))
4843 ;(gnus-article-insert-newline)
4844 (gnus-insert-mime-button
4845 handle id (list (or display (and not-attachment text))))
4846 (gnus-article-insert-newline)
4847 ;(gnus-article-insert-newline)
4848 ;; Remember modify the number of forward lines.
4856 (let ((mail-parse-charset gnus-newsgroup-charset)
4857 (mail-parse-ignored-charsets
4858 (save-excursion (condition-case ()
4859 (set-buffer gnus-summary-buffer)
4861 gnus-newsgroup-ignored-charsets)))
4862 (mm-display-part handle t))
4863 (goto-char (point-max)))
4864 ((and text not-attachment)
4868 (gnus-article-insert-newline)
4869 (mm-insert-inline handle (mm-get-part handle))
4870 (goto-char (point-max))))
4874 (narrow-to-region beg (point))
4877 (gnus-article-mime-total-parts)
4878 (mm-handle-media-type handle)))))))))
4880 (defun gnus-unbuttonized-mime-type-p (type)
4881 "Say whether TYPE is to be unbuttonized."
4882 (unless gnus-inhibit-mime-unbuttonizing
4884 (let ((types gnus-unbuttonized-mime-types))
4886 (when (string-match (pop types) type)
4887 (throw 'found t)))))
4889 (let ((types gnus-buttonized-mime-types))
4891 (when (string-match (pop types) type)
4892 (throw 'found t)))))))))
4894 (defun gnus-article-insert-newline ()
4895 "Insert a newline, but mark it as undeletable."
4896 (gnus-put-text-property
4897 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4899 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4900 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4903 handle buffer-read-only from props begend not-pref)
4904 (save-window-excursion
4907 (narrow-to-region (car ibegend)
4910 (goto-char (car ibegend))
4913 (delete-region (point-min) (point-max))
4914 (mm-remove-parts handles))
4915 (setq begend (list (point-marker)))
4917 (unless (setq not-pref (cadr (member preferred ihandles)))
4918 (setq not-pref (car ihandles)))
4921 (not (gnus-unbuttonized-mime-type-p
4922 "multipart/alternative")))
4923 (gnus-add-text-properties
4926 (insert (format "%d. " id))
4930 (unless ,(not ibegend)
4931 (setq gnus-article-mime-handle-alist
4932 ',gnus-article-mime-handle-alist))
4933 (gnus-mime-display-alternative
4934 ',ihandles ',not-pref ',begend ,id))
4935 ,@(gnus-local-map-property gnus-mime-button-map)
4936 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4937 face ,gnus-article-button-face
4940 (widget-convert-button 'link from (point)
4941 :action 'gnus-widget-press-button
4942 :button-keymap gnus-widget-button-keymap)
4944 (while (setq handle (pop handles))
4945 (gnus-add-text-properties
4948 (insert (format "(%c) %-18s"
4949 (if (equal handle preferred) ?* ? )
4950 (mm-handle-media-type handle)))
4954 (unless ,(not ibegend)
4955 (setq gnus-article-mime-handle-alist
4956 ',gnus-article-mime-handle-alist))
4957 (gnus-mime-display-alternative
4958 ',ihandles ',handle ',begend ,id))
4959 ,@(gnus-local-map-property gnus-mime-button-map)
4960 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4961 face ,gnus-article-button-face
4964 (widget-convert-button 'link from (point)
4965 :action 'gnus-widget-press-button
4966 :button-keymap gnus-widget-button-keymap)
4970 (if (stringp (car preferred))
4971 (gnus-display-mime preferred)
4972 (let ((mail-parse-charset gnus-newsgroup-charset)
4973 (mail-parse-ignored-charsets
4974 (save-excursion (set-buffer gnus-summary-buffer)
4975 gnus-newsgroup-ignored-charsets)))
4976 (mm-display-part preferred)
4980 (narrow-to-region (car begend) (point-max))
4982 nil (length gnus-article-mime-handle-alist)
4983 (gnus-article-mime-total-parts)
4984 (mm-handle-media-type handle))))))
4985 (goto-char (point-max))
4986 (setcdr begend (point-marker)))))
4988 (goto-char point))))
4990 (defconst gnus-article-wash-status-strings
4991 (let ((alist '((cite "c" "Possible hidden citation text"
4992 " " "All citation text visible")
4993 (headers "h" "Hidden headers"
4994 " " "All headers visible.")
4995 (pgp "p" "Encrypted or signed message status hidden"
4996 " " "No hidden encryption nor digital signature status")
4997 (signature "s" "Signature has been hidden"
4998 " " "Signature is visible")
4999 (overstrike "o" "Overstrike (^H) characters applied"
5000 " " "No overstrike characters applied")
5001 (gnus-show-mime "m" "Mime processing is activated"
5002 " " "Mime processing is not activated")
5003 (emphasis "e" "/*_Emphasis_*/ characters applied"
5004 " " "No /*_emphasis_*/ characters applied")))
5006 (dolist (entry alist result)
5007 (let ((key (nth 0 entry))
5008 (on (copy-sequence (nth 1 entry)))
5009 (on-help (nth 2 entry))
5010 (off (copy-sequence (nth 3 entry)))
5011 (off-help (nth 4 entry)))
5012 (put-text-property 0 1 'help-echo on-help on)
5013 (put-text-property 0 1 'help-echo off-help off)
5014 (push (list key on off) result))))
5015 "Alist of strings describing wash status in the mode line.
5016 Each entry has the form (KEY ON OF), where the KEY is a symbol
5017 representing the particular washing function, ON is the string to use
5018 in the article mode line when the washing function is active, and OFF
5019 is the string to use when it is inactive.")
5021 (defun gnus-article-wash-status-entry (key value)
5022 (let ((entry (assoc key gnus-article-wash-status-strings)))
5023 (if value (nth 1 entry) (nth 2 entry))))
5025 (defun gnus-article-wash-status ()
5026 "Return a string which display status of article washing."
5028 (set-buffer gnus-article-buffer)
5029 (let ((cite (memq 'cite gnus-article-wash-types))
5030 (headers (memq 'headers gnus-article-wash-types))
5031 (boring (memq 'boring-headers gnus-article-wash-types))
5032 (pgp (memq 'pgp gnus-article-wash-types))
5033 (pem (memq 'pem gnus-article-wash-types))
5034 (signed (memq 'signed gnus-article-wash-types))
5035 (encrypted (memq 'encrypted gnus-article-wash-types))
5036 (signature (memq 'signature gnus-article-wash-types))
5037 (overstrike (memq 'overstrike gnus-article-wash-types))
5038 (emphasis (memq 'emphasis gnus-article-wash-types)))
5040 (gnus-article-wash-status-entry 'cite cite)
5041 (gnus-article-wash-status-entry 'headers (or headers boring))
5042 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5043 (gnus-article-wash-status-entry 'signature signature)
5044 (gnus-article-wash-status-entry 'overstrike overstrike)
5045 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5046 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5048 (defun gnus-add-wash-type (type)
5049 "Add a washing of TYPE to the current status."
5050 (add-to-list 'gnus-article-wash-types type))
5052 (defun gnus-delete-wash-type (type)
5053 "Add a washing of TYPE to the current status."
5054 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5056 (defun gnus-add-image (category image)
5057 "Add IMAGE of CATEGORY to the list of displayed images."
5058 (let ((entry (assq category gnus-article-image-alist)))
5060 (setq entry (list category))
5061 (push entry gnus-article-image-alist))
5062 (nconc entry (list image))))
5064 (defun gnus-delete-images (category)
5065 "Delete all images in CATEGORY."
5066 (let ((entry (assq category gnus-article-image-alist)))
5067 (dolist (image (cdr entry))
5068 (gnus-remove-image image))
5069 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5070 (gnus-delete-wash-type category)))
5072 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5074 (defun gnus-article-maybe-hide-headers ()
5075 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5076 Provided for backwards compatibility."
5077 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5078 (not (save-excursion (set-buffer gnus-summary-buffer)
5079 gnus-have-all-headers)))
5080 (not gnus-inhibit-hiding))
5081 (gnus-article-hide-headers)))
5085 (defun gnus-output-to-file (file-name)
5086 "Append the current article to a file named FILE-NAME."
5087 (let ((artbuf (current-buffer)))
5089 (insert-buffer-substring artbuf)
5090 ;; Append newline at end of the buffer as separator, and then
5092 (goto-char (point-max))
5094 (let ((file-name-coding-system nnmail-pathname-coding-system)
5095 (pathname-coding-system nnmail-pathname-coding-system))
5096 (write-region-as-binary (point-min) (point-max) file-name 'append))
5099 (defun gnus-narrow-to-page (&optional arg)
5100 "Narrow the article buffer to a page.
5101 If given a numerical ARG, move forward ARG pages."
5103 (setq arg (if arg (prefix-numeric-value arg) 0))
5105 (set-buffer gnus-article-buffer)
5106 (goto-char (point-min))
5108 ;; Remove any old next/prev buttons.
5109 (when (gnus-visual-p 'page-marker)
5110 (let ((buffer-read-only nil))
5111 (gnus-remove-text-with-property 'gnus-prev)
5112 (gnus-remove-text-with-property 'gnus-next)))
5115 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5117 (re-search-forward page-delimiter nil 'move arg)))
5118 (goto-char (match-end 0)))
5121 (if (re-search-forward page-delimiter nil 'move)
5124 (when (and (gnus-visual-p 'page-marker)
5125 (not (= (point-min) 1)))
5127 (goto-char (point-min))
5128 (gnus-insert-prev-page-button)))
5129 (when (and (gnus-visual-p 'page-marker)
5130 (< (+ (point-max) 2) (buffer-size)))
5132 (goto-char (point-max))
5133 (gnus-insert-next-page-button)))))
5135 ;; Article mode commands
5137 (defun gnus-article-goto-next-page ()
5138 "Show the next page of the article."
5140 (when (gnus-article-next-page)
5141 (goto-char (point-min))
5142 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5144 (defun gnus-article-goto-prev-page ()
5145 "Show the next page of the article."
5147 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5148 (gnus-article-prev-page nil)))
5150 (defun gnus-article-next-page (&optional lines)
5151 "Show the next page of the current article.
5152 If end of article, return non-nil. Otherwise return nil.
5153 Argument LINES specifies lines to be scrolled up."
5155 (let ((start (window-start))
5156 end-of-buffer end-of-page)
5158 (move-to-window-line -1)
5159 (if (<= (point) start)
5162 (setq start (point)))
5165 (unless (or (cond ((eq (1+ (buffer-size)) (point))
5166 (and (pos-visible-in-window-p)
5167 (setq end-of-buffer t)))
5169 (setq end-of-page t)))
5171 (move-to-window-line lines)
5172 (unless (search-backward "\n\n" nil t)
5173 (setq start (point)))))
5174 (cond (end-of-buffer t)
5176 (gnus-narrow-to-page 1)
5180 (set-window-start (selected-window) start)
5181 (let (window-pixel-scroll-increment)
5185 (defun gnus-article-prev-page (&optional lines)
5186 "Show previous page of current article.
5187 Argument LINES specifies lines to be scrolled down."
5189 (let (beginning-of-buffer beginning-of-page)
5191 (move-to-window-line 0)
5192 (cond ((eq 1 (point))
5193 (setq beginning-of-buffer t))
5195 (setq beginning-of-page t))))
5196 (cond (beginning-of-buffer)
5198 (gnus-narrow-to-page -1))
5201 (let (window-pixel-scroll-increment)
5202 (scroll-down lines))
5203 (beginning-of-buffer
5204 (goto-char (point-min))))))))
5206 (defun gnus-article-refer-article ()
5207 "Read article specified by message-id around point."
5209 (let ((point (point)))
5210 (search-forward ">" nil t) ;Move point to end of "<....>".
5211 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
5212 (let ((message-id (match-string 1)))
5214 (set-buffer gnus-summary-buffer)
5215 (gnus-summary-refer-article message-id))
5217 (error "No references around point"))))
5219 (defun gnus-article-show-summary ()
5220 "Reconfigure windows to show summary buffer."
5222 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5223 (error "There is no summary buffer for this article buffer")
5224 (gnus-article-set-globals)
5225 (gnus-configure-windows 'article)
5226 (gnus-summary-goto-subject gnus-current-article)
5227 (gnus-summary-position-point)))
5229 (defun gnus-article-describe-briefly ()
5230 "Describe article mode commands briefly."
5232 (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")))
5234 (defun gnus-article-summary-command ()
5235 "Execute the last keystroke in the summary buffer."
5237 (let ((obuf (current-buffer))
5238 (owin (current-window-configuration))
5240 (switch-to-buffer gnus-article-current-summary 'norecord)
5241 (setq func (lookup-key (current-local-map) (this-command-keys)))
5242 (call-interactively func)
5244 (set-window-configuration owin)
5245 (set-window-point (get-buffer-window (current-buffer)) (point))))
5247 (defun gnus-article-summary-command-nosave ()
5248 "Execute the last keystroke in the summary buffer."
5251 (pop-to-buffer gnus-article-current-summary 'norecord)
5252 (setq func (lookup-key (current-local-map) (this-command-keys)))
5253 (call-interactively func)))
5255 (defun gnus-article-check-buffer ()
5256 "Beep if not in an article buffer."
5257 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5258 (error "Command invoked outside of a Gnus article buffer")))
5260 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5261 "Read a summary buffer key sequence and execute it from the article buffer."
5263 (gnus-article-check-buffer)
5265 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5266 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5267 "=" "^" "\M-^" "|"))
5273 '("n" "Gn" "p" "Gp"))
5276 (set-buffer gnus-article-current-summary)
5277 (let (gnus-pick-mode)
5278 (push (or key last-command-event) unread-command-events)
5279 (setq keys (static-if (featurep 'xemacs)
5280 (events-to-keys (read-key-sequence nil))
5281 (read-key-sequence nil)))))
5284 (if (or (member keys nosaves)
5285 (member keys nosave-but-article)
5286 (member keys nosave-in-article))
5288 (save-window-excursion
5289 (pop-to-buffer gnus-article-current-summary 'norecord)
5290 ;; We disable the pick minor mode commands.
5291 (let (gnus-pick-mode)
5292 (setq func (lookup-key (current-local-map) keys))))
5296 (unless (member keys nosave-in-article)
5297 (set-buffer gnus-article-current-summary))
5298 (call-interactively func)
5299 (setq new-sum-point (point)))
5300 (when (member keys nosave-but-article)
5301 (pop-to-buffer gnus-article-buffer 'norecord)))
5302 ;; These commands should restore window configuration.
5303 (let ((obuf (current-buffer))
5304 (owin (current-window-configuration))
5306 (summary gnus-article-current-summary)
5307 func in-buffer selected)
5308 (if not-restore-window
5309 (pop-to-buffer summary 'norecord)
5310 (switch-to-buffer summary 'norecord))
5311 (setq in-buffer (current-buffer))
5312 ;; We disable the pick minor mode commands.
5313 (if (and (setq func (let (gnus-pick-mode)
5314 (lookup-key (current-local-map) keys)))
5317 (call-interactively func)
5318 (setq new-sum-point (point))
5319 (when (eq in-buffer (current-buffer))
5320 (setq selected (gnus-summary-select-article))
5322 (unless not-restore-window
5323 (set-window-configuration owin))
5324 (when (eq selected 'old)
5326 (set-window-start (get-buffer-window (current-buffer))
5328 (set-window-point (get-buffer-window (current-buffer))
5330 (let ((win (get-buffer-window gnus-article-current-summary)))
5332 (set-window-point win new-sum-point)))) )
5333 (switch-to-buffer gnus-article-buffer)
5336 (defun gnus-article-describe-key (key)
5337 "Display documentation of the function invoked by KEY. KEY is a string."
5338 (interactive "kDescribe key: ")
5339 (gnus-article-check-buffer)
5340 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5342 (set-buffer gnus-article-current-summary)
5343 (let (gnus-pick-mode)
5344 (if (featurep 'xemacs)
5346 (push (elt key 0) unread-command-events)
5347 (setq key (events-to-keys
5348 (read-key-sequence "Describe key: "))))
5349 (setq unread-command-events
5351 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5353 (setq key (read-key-sequence "Describe key: "))))
5355 (describe-key key)))
5357 (defun gnus-article-describe-key-briefly (key &optional insert)
5358 "Display documentation of the function invoked by KEY. KEY is a string."
5359 (interactive "kDescribe key: \nP")
5360 (gnus-article-check-buffer)
5361 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5363 (set-buffer gnus-article-current-summary)
5364 (let (gnus-pick-mode)
5365 (if (featurep 'xemacs)
5367 (push (elt key 0) unread-command-events)
5368 (setq key (events-to-keys
5369 (read-key-sequence "Describe key: "))))
5370 (setq unread-command-events
5372 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5374 (setq key (read-key-sequence "Describe key: "))))
5375 (describe-key-briefly key insert))
5376 (describe-key-briefly key insert)))
5378 (defun gnus-article-reply-with-original (&optional wide)
5379 "Start composing a reply mail to the current message.
5380 The text in the region will be yanked. If the region isn't active,
5381 the entire article will be yanked."
5383 (let ((article (cdr gnus-article-current))
5385 (if (not (gnus-mark-active-p))
5386 (with-current-buffer gnus-summary-buffer
5387 (gnus-summary-reply (list (list article)) wide))
5388 (setq contents (buffer-substring (point) (mark t)))
5389 ;; Deactivate active regions.
5390 (when (and (boundp 'transient-mark-mode)
5391 transient-mark-mode)
5392 (setq mark-active nil))
5393 (with-current-buffer gnus-summary-buffer
5395 (list (list article contents)) wide)))))
5397 (defun gnus-article-followup-with-original ()
5398 "Compose a followup to the current article.
5399 The text in the region will be yanked. If the region isn't active,
5400 the entire article will be yanked."
5402 (let ((article (cdr gnus-article-current))
5404 (if (not (gnus-mark-active-p))
5405 (with-current-buffer gnus-summary-buffer
5406 (gnus-summary-followup (list (list article))))
5407 (setq contents (buffer-substring (point) (mark t)))
5408 ;; Deactivate active regions.
5409 (when (and (boundp 'transient-mark-mode)
5410 transient-mark-mode)
5411 (setq mark-active nil))
5412 (with-current-buffer gnus-summary-buffer
5413 (gnus-summary-followup
5414 (list (list article contents)))))))
5416 (defun gnus-article-hide (&optional arg force)
5417 "Hide all the gruft in the current article.
5418 This means that PGP stuff, signatures, cited text and (some)
5419 headers will be hidden.
5420 If given a prefix, show the hidden text instead."
5421 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5422 (gnus-article-hide-headers arg)
5423 (gnus-article-hide-list-identifiers arg)
5424 (gnus-article-hide-pgp arg)
5425 (gnus-article-hide-citation-maybe arg force)
5426 (gnus-article-hide-signature arg))
5428 (defun gnus-article-maybe-highlight ()
5429 "Do some article highlighting if article highlighting is requested."
5430 (when (gnus-visual-p 'article-highlight 'highlight)
5431 (gnus-article-highlight-some)))
5433 (defun gnus-check-group-server ()
5434 ;; Make sure the connection to the server is alive.
5435 (unless (gnus-server-opened
5436 (gnus-find-method-for-group gnus-newsgroup-name))
5437 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5438 (gnus-request-group gnus-newsgroup-name t)))
5441 (autoload 'nneething-get-file-name "nneething"))
5443 (defun gnus-request-article-this-buffer (article group)
5444 "Get an article and insert it into this buffer."
5445 (let (do-update-line sparse-header)
5449 (gnus-kill-all-overlays)
5450 (setq group (or group gnus-newsgroup-name))
5452 ;; Using `gnus-request-article' directly will insert the article into
5453 ;; `nntp-server-buffer' - so we'll save some time by not having to
5454 ;; copy it from the server buffer into the article buffer.
5456 ;; We only request an article by message-id when we do not have the
5457 ;; headers for it, so we'll have to get those.
5458 (when (stringp article)
5459 (gnus-read-header article))
5461 ;; If the article number is negative, that means that this article
5462 ;; doesn't belong in this newsgroup (possibly), so we find its
5463 ;; message-id and request it by id instead of number.
5464 (when (and (numberp article)
5466 (get-buffer gnus-summary-buffer)
5467 (gnus-buffer-exists-p gnus-summary-buffer))
5469 (set-buffer gnus-summary-buffer)
5470 (let ((header (gnus-summary-article-header article)))
5473 ((memq article gnus-newsgroup-sparse)
5474 ;; This is a sparse gap article.
5475 (setq do-update-line article)
5476 (setq article (mail-header-id header))
5477 (setq sparse-header (gnus-read-header article))
5478 (setq gnus-newsgroup-sparse
5479 (delq article gnus-newsgroup-sparse)))
5481 ;; It's a real article.
5482 (setq article (mail-header-id header)))
5484 ;; It is an extracted pseudo-article.
5485 (setq article 'pseudo)
5486 (gnus-request-pseudo-article header))))
5488 (let ((method (gnus-find-method-for-group
5489 gnus-newsgroup-name)))
5490 (when (and (eq (car method) 'nneething)
5492 (let ((dir (nneething-get-file-name
5493 (mail-header-id header))))
5494 (when (and (stringp dir)
5495 (file-directory-p dir))
5496 (setq article 'nneething)
5497 (gnus-group-enter-directory dir))))))))
5500 ;; Refuse to select canceled articles.
5501 ((and (numberp article)
5503 (get-buffer gnus-summary-buffer)
5504 (gnus-buffer-exists-p gnus-summary-buffer)
5505 (eq (cdr (save-excursion
5506 (set-buffer gnus-summary-buffer)
5507 (assq article gnus-newsgroup-reads)))
5508 gnus-canceled-mark))
5510 ;; We first check `gnus-original-article-buffer'.
5511 ((and (get-buffer gnus-original-article-buffer)
5514 (set-buffer gnus-original-article-buffer)
5515 (and (equal (car gnus-original-article) group)
5516 (eq (cdr gnus-original-article) article))))
5517 (insert-buffer-substring gnus-original-article-buffer)
5519 ;; Check the backlog.
5520 ((and gnus-keep-backlog
5521 (gnus-backlog-request-article group article (current-buffer)))
5523 ;; Check asynchronous pre-fetch.
5524 ((gnus-async-request-fetched-article group article (current-buffer))
5525 (gnus-async-prefetch-next group article gnus-summary-buffer)
5526 (when (and (numberp article) gnus-keep-backlog)
5527 (gnus-backlog-enter-article group article (current-buffer)))
5530 ((and gnus-use-cache
5532 (gnus-cache-request-article article group))
5534 ;; Check the agent cache.
5535 ((and gnus-agent gnus-agent-cache gnus-plugged
5537 (gnus-agent-request-article article group))
5539 ;; Get the article and put into the article buffer.
5540 ((or (stringp article)
5542 (let ((gnus-override-method gnus-override-method)
5543 (methods (and (stringp article)
5544 gnus-refer-article-method))
5545 (backend (car (gnus-find-method-for-group
5546 gnus-newsgroup-name)))
5548 (buffer-read-only nil))
5549 (if (or (not (listp methods))
5550 (and (symbolp (car methods))
5551 (assq (car methods) nnoo-definition-alist)))
5552 (setq methods (list methods)))
5553 (when (and (null gnus-override-method)
5555 (setq gnus-override-method (pop methods)))
5557 (when (eq gnus-override-method 'current)
5558 (setq gnus-override-method
5559 (with-current-buffer gnus-summary-buffer
5560 gnus-current-select-method)))
5562 (gnus-kill-all-overlays)
5563 (let ((gnus-newsgroup-name group))
5564 (gnus-check-group-server))
5566 ((gnus-request-article article group (current-buffer))
5567 (when (numberp article)
5568 (gnus-async-prefetch-next group article
5569 gnus-summary-buffer)
5570 (when gnus-keep-backlog
5571 (gnus-backlog-enter-article
5572 group article (current-buffer))))
5573 (setq result 'article))
5575 (setq gnus-override-method (pop methods)))
5576 ((not (string-match "^400 "
5577 (nnheader-get-report backend)))
5578 ;; If we get 400 server disconnect, reconnect and
5579 ;; retry; otherwise, assume the article has expired.
5580 (setq result 'done))))
5581 (and (eq result 'article) 'article)))
5585 ;; Associate this article with the current summary buffer.
5586 (setq gnus-article-current-summary gnus-summary-buffer)
5588 ;; Take the article from the original article buffer
5589 ;; and place it in the buffer it's supposed to be in.
5590 (when (and (get-buffer gnus-article-buffer)
5591 (equal (buffer-name (current-buffer))
5592 (buffer-name (get-buffer gnus-article-buffer))))
5594 (if (get-buffer gnus-original-article-buffer)
5595 (set-buffer gnus-original-article-buffer)
5596 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5597 (buffer-disable-undo)
5598 (setq major-mode 'gnus-original-article-mode)
5599 (setq buffer-read-only t))
5600 (let (buffer-read-only)
5602 (insert-buffer-substring gnus-article-buffer))
5603 (setq gnus-original-article (cons group article)))
5606 (run-hooks 'gnus-article-decode-hook)
5607 ;; Mark article as decoded or not.
5608 (setq gnus-article-decoded-p gnus-article-decode-hook))
5610 ;; Update sparse articles.
5611 (when (and do-update-line
5612 (or (numberp article)
5614 (let ((buf (current-buffer)))
5615 (set-buffer gnus-summary-buffer)
5616 (gnus-summary-update-article do-update-line sparse-header)
5617 (gnus-summary-goto-subject do-update-line nil t)
5618 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5620 (set-buffer buf))))))
5626 (defcustom gnus-article-edit-mode-hook nil
5627 "Hook run in article edit mode buffers."
5628 :group 'gnus-article-various
5631 (defcustom gnus-article-edit-article-setup-function
5632 'gnus-article-mime-edit-article-setup
5633 "Function called to setup an editing article buffer."
5634 :group 'gnus-article-various
5637 (defvar gnus-article-edit-done-function nil)
5639 (defvar gnus-article-edit-mode-map nil)
5640 (defvar gnus-article-edit-mode nil)
5642 ;; Should we be using derived.el for this?
5643 (unless gnus-article-edit-mode-map
5644 (setq gnus-article-edit-mode-map (make-keymap))
5645 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5647 (gnus-define-keys gnus-article-edit-mode-map
5648 "\C-c?" describe-mode
5649 "\C-c\C-c" gnus-article-edit-done
5650 "\C-c\C-k" gnus-article-edit-exit
5651 "\C-c\C-f\C-t" message-goto-to
5652 "\C-c\C-f\C-o" message-goto-from
5653 "\C-c\C-f\C-b" message-goto-bcc
5654 ;;"\C-c\C-f\C-w" message-goto-fcc
5655 "\C-c\C-f\C-c" message-goto-cc
5656 "\C-c\C-f\C-s" message-goto-subject
5657 "\C-c\C-f\C-r" message-goto-reply-to
5658 "\C-c\C-f\C-n" message-goto-newsgroups
5659 "\C-c\C-f\C-d" message-goto-distribution
5660 "\C-c\C-f\C-f" message-goto-followup-to
5661 "\C-c\C-f\C-m" message-goto-mail-followup-to
5662 "\C-c\C-f\C-k" message-goto-keywords
5663 "\C-c\C-f\C-u" message-goto-summary
5664 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5665 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5666 "\C-c\C-b" message-goto-body
5667 "\C-c\C-i" message-goto-signature
5669 "\C-c\C-t" message-insert-to
5670 "\C-c\C-n" message-insert-newsgroups
5671 "\C-c\C-o" message-sort-headers
5672 "\C-c\C-e" message-elide-region
5673 "\C-c\C-v" message-delete-not-region
5674 "\C-c\C-z" message-kill-to-signature
5675 "\M-\r" message-newline-and-reformat
5676 "\C-c\C-a" mml-attach-file
5677 "\C-a" message-beginning-of-line
5679 "\M-;" comment-region)
5681 (gnus-define-keys (gnus-article-edit-wash-map
5682 "\C-c\C-w" gnus-article-edit-mode-map)
5683 "f" gnus-article-edit-full-stops))
5686 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5688 ["Fetch To" message-insert-to t]
5689 ["Fetch Newsgroups" message-insert-newsgroups t]
5691 ["To" message-goto-to t]
5692 ["From" message-goto-from t]
5693 ["Subject" message-goto-subject t]
5694 ["Cc" message-goto-cc t]
5695 ["Reply-To" message-goto-reply-to t]
5696 ["Summary" message-goto-summary t]
5697 ["Keywords" message-goto-keywords t]
5698 ["Newsgroups" message-goto-newsgroups t]
5699 ["Followup-To" message-goto-followup-to t]
5700 ["Mail-Followup-To" message-goto-mail-followup-to t]
5701 ["Distribution" message-goto-distribution t]
5702 ["Body" message-goto-body t]
5703 ["Signature" message-goto-signature t]))
5705 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5706 "Major mode for editing articles.
5707 This is an extended text-mode.
5709 \\{gnus-article-edit-mode-map}"
5710 (make-local-variable 'gnus-article-edit-done-function)
5711 (make-local-variable 'gnus-prev-winconf)
5712 (set (make-local-variable 'font-lock-defaults)
5713 '(message-font-lock-keywords t))
5714 (set (make-local-variable 'mail-header-separator) "")
5715 (set (make-local-variable 'gnus-article-edit-mode) t)
5716 (easy-menu-add message-mode-field-menu message-mode-map)
5717 (setq buffer-read-only nil)
5718 (buffer-enable-undo)
5721 (defun gnus-article-edit (&optional force)
5722 "Edit the current article.
5723 This will have permanent effect only in mail groups.
5724 If FORCE is non-nil, allow editing of articles even in read-only
5727 (when (and (not force)
5728 (gnus-group-read-only-p))
5729 (error "The current newsgroup does not support article editing"))
5730 (gnus-article-date-original)
5731 (gnus-article-edit-article
5733 `(lambda (no-highlight)
5735 (gnus-summary-edit-article-done
5736 ,(or (mail-header-references gnus-current-headers) "")
5737 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5739 (defun gnus-article-edit-article (start-func exit-func)
5740 "Start editing the contents of the current article buffer."
5741 (let ((winconf (current-window-configuration)))
5742 (set-buffer gnus-article-buffer)
5743 (gnus-article-edit-mode)
5744 (funcall start-func)
5745 (set-buffer-modified-p nil)
5746 (gnus-configure-windows 'edit-article)
5747 (setq gnus-article-edit-done-function exit-func)
5748 (setq gnus-prev-winconf winconf)
5749 (when gnus-article-edit-article-setup-function
5750 (funcall gnus-article-edit-article-setup-function))
5751 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5753 (defun gnus-article-edit-done (&optional arg)
5754 "Update the article edits and exit."
5756 (let ((func gnus-article-edit-done-function)
5757 (buf (current-buffer))
5758 (start (window-start))
5760 (winconf gnus-prev-winconf))
5761 (remove-hook 'gnus-article-mode-hook
5762 'gnus-article-mime-edit-article-unwind)
5763 (widen) ;; Widen it in case that users narrowed the buffer.
5766 ;; The cache and backlog have to be flushed somewhat.
5767 (when gnus-keep-backlog
5768 (gnus-backlog-remove-article
5769 (car gnus-article-current) (cdr gnus-article-current)))
5770 ;; Flush original article as well.
5772 (when (get-buffer gnus-original-article-buffer)
5773 (set-buffer gnus-original-article-buffer)
5774 (setq gnus-original-article nil)))
5775 (when gnus-use-cache
5776 (gnus-cache-update-article
5777 (car gnus-article-current) (cdr gnus-article-current)))
5778 ;; We remove all text props from the article buffer.
5779 (kill-all-local-variables)
5780 (gnus-set-text-properties (point-min) (point-max) nil)
5782 (set-window-configuration winconf)
5784 (set-window-start (get-buffer-window buf) start)
5785 (set-window-point (get-buffer-window buf) (point))))
5787 (defun gnus-article-edit-exit ()
5788 "Exit the article editing without updating."
5790 (when (or (not (buffer-modified-p))
5791 (yes-or-no-p "Article modified; kill anyway? "))
5792 (let ((curbuf (current-buffer))
5794 (window-start (window-start)))
5796 (if (gnus-buffer-live-p gnus-original-article-buffer)
5797 (insert-buffer-substring gnus-original-article-buffer))
5798 (let ((winconf gnus-prev-winconf))
5799 (kill-all-local-variables)
5801 (set-window-configuration winconf)
5802 ;; Tippy-toe some to make sure that point remains where it was.
5803 (save-current-buffer
5805 (set-window-start (get-buffer-window (current-buffer)) window-start)
5808 (defun gnus-article-edit-full-stops ()
5809 "Interactively repair spacing at end of sentences."
5812 (goto-char (point-min))
5813 (search-forward-regexp "^$" nil t)
5814 (let ((case-fold-search nil))
5815 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5818 ;;; Article editing with MIME-Edit
5821 (defcustom gnus-article-mime-edit-article-setup-hook nil
5822 "Hook run after setting up a MIME editing article buffer."
5823 :group 'gnus-article-various
5826 (defun gnus-article-mime-edit-article-unwind ()
5827 "Unwind `gnus-article-buffer' if article editing was given up."
5828 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5829 (when (featurep 'font-lock)
5830 (setq font-lock-defaults nil)
5831 (font-lock-mode -1))
5832 (when mime-edit-mode-flag
5833 (mime-edit-exit 'nomime 'no-error)
5836 (defun gnus-article-mime-edit-article-setup ()
5837 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
5838 after replacing with the original article."
5839 (setq gnus-show-mime t)
5840 (setq gnus-article-edit-done-function
5841 `(lambda (&rest args)
5842 (when mime-edit-mode-flag
5843 (let (mime-edit-insert-user-agent-field)
5846 (goto-char (point-min))
5847 (let (case-fold-search)
5848 (when (re-search-forward
5849 (format "^%s$" (regexp-quote mail-header-separator))
5851 (replace-match "")))
5852 (apply ,gnus-article-edit-done-function args)
5855 (buffer-substring-no-properties (point-min) (point-max))
5856 (set-buffer (get-buffer-create gnus-original-article-buffer))
5858 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5859 (set-buffer gnus-article-buffer)
5860 (gnus-article-prepare-display)))
5861 (substitute-key-definition 'gnus-article-edit-done
5862 'gnus-article-mime-edit-done
5863 gnus-article-edit-mode-map)
5864 (substitute-key-definition 'gnus-article-edit-exit
5865 'gnus-article-mime-edit-exit
5866 gnus-article-edit-mode-map)
5868 (insert-buffer-substring gnus-original-article-buffer)
5869 (unless (member (with-current-buffer gnus-summary-buffer
5870 gnus-newsgroup-name)
5871 '("nndraft:delayed" "nndraft:drafts"))
5872 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
5873 (fset 'mime-edit-decode-single-part-in-buffer
5874 (lambda (&rest args)
5875 (if (let ((content-type (car args)))
5876 (and (eq 'message (mime-content-type-primary-type
5878 (eq 'rfc822 (mime-content-type-subtype
5880 (setcar (cdr args) 'not-decode-text))
5884 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
5885 (when (featurep 'font-lock)
5886 (set (make-local-variable 'font-lock-defaults)
5887 '(message-font-lock-keywords t))
5888 (font-lock-set-defaults)
5889 (turn-on-font-lock))
5890 (set-buffer-modified-p nil)
5891 (delete-other-windows)
5892 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5893 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
5895 (defun gnus-article-mime-edit-done (&optional arg)
5896 "Update the article MIME edits and exit."
5898 (when (featurep 'font-lock)
5899 (setq font-lock-defaults nil)
5900 (font-lock-mode -1))
5901 (let ((inhibit-read-only t))
5902 (gnus-article-edit-done arg)))
5904 (defun gnus-article-mime-edit-exit ()
5905 "Exit the article MIME editing without updating."
5907 (when (or (not (buffer-modified-p))
5908 (yes-or-no-p "Article modified; kill anyway? "))
5909 (when (featurep 'font-lock)
5910 (setq font-lock-defaults nil)
5911 (font-lock-mode -1))
5912 (when mime-edit-mode-flag
5913 (let (mime-edit-insert-user-agent-field)
5916 (goto-char (point-min))
5917 (let (case-fold-search)
5918 (when (re-search-forward
5919 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
5920 (replace-match "")))
5921 (let ((winconf gnus-prev-winconf))
5923 (buffer-substring-no-properties (point-min) (point-max))
5924 (set-buffer (get-buffer-create gnus-original-article-buffer))
5926 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5927 (set-buffer gnus-article-buffer)
5928 (gnus-article-prepare-display)
5929 (set-window-configuration winconf))))
5932 ;;; Article highlights
5935 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5937 ;;; Internal Variables:
5939 (defcustom gnus-button-url-regexp
5940 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5941 "\\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:]]\\)"
5942 "\\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\\)\\)")
5943 "Regular expression that matches URLs."
5944 :group 'gnus-article-buttons
5947 (defcustom gnus-button-valid-fqdn-regexp
5948 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
5950 "\\([a-z][a-z]" ;; two letter country TDLs
5951 "\\|biz\\|com\\|edu\\|gov\\|int\\|mil\\|net\\|org"
5952 "\\|aero\\|coop\\|info\\|name\\|museum"
5953 "\\|arpa\\|pro\\|uucp\\|bitnet\\|bofh" ;; old style?
5955 "Regular expression that matches a valid FQDN."
5956 :group 'gnus-article-buttons
5959 (defcustom gnus-button-man-handler 'manual-entry
5960 "Function to use for displaying man pages.
5961 The function must take at least one argument with a string naming the
5963 :type '(choice (function-item :tag "Man" manual-entry)
5964 (function-item :tag "Woman" woman)
5965 (function :tag "Other"))
5966 :group 'gnus-article-buttons)
5968 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5969 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5970 If the default site is too slow, try to find a CTAN mirror, see
5971 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5972 the variable `gnus-button-handle-ctan'."
5973 :group 'gnus-article-buttons
5974 :link '(custom-manual "(gnus)Group Parameters")
5975 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5976 (const "http://tug.ctan.org/tex-archive/")
5977 (const "http://www.dante.de/CTAN/")
5978 (string :tag "Other")))
5980 (defcustom gnus-button-ctan-handler 'browse-url
5981 "Function to use for displaying CTAN links.
5982 The function must take one argument, the string naming the URL."
5983 :type '(choice (function-item :tag "Browse Url" browse-url)
5984 (function :tag "Other"))
5985 :group 'gnus-article-buttons)
5987 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5988 "Bogus strings removed from CTAN URLs."
5989 :group 'gnus-article-buttons
5990 :type '(choice (const "^/?tex-archive/\\|/")
5991 (regexp :tag "Other")))
5993 (defcustom gnus-button-mid-or-mail-regexp
5994 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
5995 gnus-button-valid-fqdn-regexp
5997 "Regular expression that matches a message ID or a mail address."
5998 :group 'gnus-article-buttons
6001 (defcustom gnus-button-prefer-mid-or-mail 'guess
6002 "What to do when the button on a string as \"foo123@bar.com\" is pushed.
6003 Strings like this can be either a message ID or a mail address. If the
6004 variable is set to the symbol `ask', query the user what do do. If it is the
6005 symbol `guess', Gnus will do a guess and query the user what do do if it is
6006 ambiguous. See the variable `gnus-button-guessed-mid-regexp' for details
6007 concerning the guessing. If it is one of the sybols `mid' or `mail', Gnus
6008 will always assume that the string is a message ID or a mail address,
6010 ;; FIXME: doc-string could/should be improved.
6011 :group 'gnus-article-buttons
6012 :type '(choice (const ask)
6017 (defcustom gnus-button-guessed-mid-regexp
6019 "^<?\\(slrn\\|Pine\\.\\)"
6020 "\\|\\.fsf@\\|\\.fsf_-_@\\|\\.ln@"
6021 "\\|@4ax\\.com\\|@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de"
6022 "\\|^<?.*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*@")
6023 "Regular expression that matches message IDs and not mail addresses."
6024 ;; TODO: Incorporate more matches from
6025 ;; <URL:http://piology.org/perl/id-or-mail.pl.html>. I.e. translate the
6026 ;; Perl-REs to Elisp-REs.
6027 :group 'gnus-article-buttons
6030 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6031 (let* ((pref gnus-button-prefer-mid-or-mail)
6032 (url-mid (concat "news" ":" mid-or-mail))
6033 (url-mailto (concat "mailto" ":" mid-or-mail)))
6034 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6035 ;; If it looks like a MID (well known readers or servers) use 'mid,
6036 ;; otherwise 'ask the user.
6037 (if (eq pref 'guess)
6038 (if (string-match gnus-button-guessed-mid-regexp mid-or-mail)
6042 (save-window-excursion
6043 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6046 (cond ((eq pref 'mid)
6047 (gnus-message 9 "calling `gnus-button-handle-news' %s" url-mid)
6048 (gnus-button-handle-news url-mid))
6050 (gnus-message 9 "calling `gnus-url-mailto' %s" url-mailto)
6051 (gnus-url-mailto url-mailto)))))
6053 (defun gnus-button-handle-custom (url)
6054 "Follow a Custom URL."
6055 (customize-apropos (gnus-url-unhex-string url)))
6057 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6059 (defun gnus-button-handle-describe-function (url)
6060 "Call describe-function when pushing the corresponding URL button."
6063 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6065 (defun gnus-button-handle-describe-variable (url)
6066 "Call describe-variable when pushing the corresponding URL button."
6069 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6071 ;; FIXME: Is is possible to implement this? Else it should be removed here
6072 ;; and in `gnus-button-alist'.
6073 (defun gnus-button-handle-describe-key (url)
6074 "Call describe-key when pushing the corresponding URL button."
6075 (error "not implemented"))
6077 (defun gnus-button-handle-apropos (url)
6078 "Call apropos when pushing the corresponding URL button."
6079 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6081 (defun gnus-button-handle-apropos-command (url)
6082 "Call apropos when pushing the corresponding URL button."
6084 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6086 (defun gnus-button-handle-apropos-variable (url)
6087 "Call apropos when pushing the corresponding URL button."
6089 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6090 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6092 (defun gnus-button-handle-apropos-documentation (url)
6093 "Call apropos when pushing the corresponding URL button."
6095 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6096 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6098 (defun gnus-button-handle-ctan (url)
6099 "Call `browse-url' when pushing a CTAN URL button."
6101 gnus-button-ctan-handler
6104 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6106 (defcustom gnus-button-tex-level 5
6107 "*Integer that says how many TeX-related buttons Gnus will show.
6108 The higher the number, the more buttons will appear and the more false
6109 positives are possible. Note that you can set this variable local to
6110 specifific groups. Setting it higher in TeX groups is probably a good idea.
6111 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6112 how to set variables in specific groups."
6113 :group 'gnus-article-buttons
6114 :link '(custom-manual "(gnus)Group Parameters")
6117 (defcustom gnus-button-man-level 5
6118 "*Integer that says how many man-related buttons Gnus will show.
6119 The higher the number, the more buttons will appear and the more false
6120 positives are possible. Note that you can set this variable local to
6121 specifific groups. Setting it higher in Unix groups is probably a good idea.
6122 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6123 how to set variables in specific groups."
6124 :group 'gnus-article-buttons
6125 :link '(custom-manual "(gnus)Group Parameters")
6128 (defcustom gnus-button-emacs-level 5
6129 "*Integer that says how many emacs-related buttons Gnus will show.
6130 The higher the number, the more buttons will appear and the more false
6131 positives are possible. Note that you can set this variable local to
6132 specifific groups. Setting it higher in Emacs or Gnus related groups is
6133 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6134 `gnus-parameters' on how to set variables in specific groups."
6135 :group 'gnus-article-buttons
6136 :link '(custom-manual "(gnus)Group Parameters")
6139 (defcustom gnus-button-mail-level 5
6140 "*Integer that says how many buttons for message IDs or mail addresses will appear.
6141 The higher the number, the more buttons will appear and the more false
6142 positives are possible."
6143 :group 'gnus-article-buttons
6146 (defcustom gnus-button-alist
6147 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6148 0 t gnus-button-handle-news 3)
6149 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6150 gnus-button-handle-news 2)
6151 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6153 gnus-button-fetch-group 4)
6154 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
6155 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
6156 t gnus-button-message-id 3)
6157 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
6158 ("mailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
6159 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
6161 ("\\bCTAN:[ \t\n]*\\([^>)!;:,\n\t ]*\\)" 0 (>= gnus-button-tex-level 1)
6162 gnus-button-handle-ctan 1)
6164 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
6165 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2)
6167 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
6168 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6169 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6170 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6171 ;; Emacs help commands
6172 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6173 ;; regexp doesn't match arguments containing ` '.
6174 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6175 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6176 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6177 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6178 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6179 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6180 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6181 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6182 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6183 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6184 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6185 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+" 0
6186 ;; this regexp needs to be fixed!
6187 (>= gnus-button-emacs-level 9) gnus-button-handle-describe-key 2)
6188 ;; This is how URLs _should_ be embedded in text...
6189 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
6191 (gnus-button-url-regexp 0 t browse-url 0)
6193 ("\\b\\([a-z][a-z]+\\)([1-9])\\W" 0
6194 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6195 gnus-button-handle-man 1)
6196 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6197 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W" 0
6198 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6199 gnus-button-handle-man 1)
6200 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6201 ;; SoWWWAnchor(3iv), XSelectInput(3X11)
6202 ("\\b\\([a-z][-_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W" 0
6203 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6204 ;; MID or mail: To avoid too many false positives we don't try to catch
6205 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6206 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6207 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6208 ;; so that non-ambiguous entries (see above) match first.
6209 (gnus-button-mid-or-mail-regexp
6210 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1))
6211 "*Alist of regexps matching buttons in article bodies.
6213 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6214 REGEXP: is the string (case insensitive) matching text around the button (can
6215 also be lisp expression evaluating to a string),
6216 BUTTON: is the number of the regexp grouping actually matching the button,
6217 FORM: is a lisp expression which must eval to true for the button to
6219 CALLBACK: is the function to call when the user push this button, and each
6220 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6222 CALLBACK can also be a variable, in that case the value of that
6223 variable it the real callback function."
6224 :group 'gnus-article-buttons
6225 :type '(repeat (list (choice regexp variable)
6226 (integer :tag "Button")
6228 (function :tag "Callback")
6231 (integer :tag "Regexp group")))))
6233 (defcustom gnus-header-button-alist
6234 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
6235 0 t gnus-button-message-id 0)
6236 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
6237 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6238 0 t gnus-button-mailto 0)
6239 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
6240 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
6241 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
6242 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
6243 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
6244 gnus-button-message-id 3))
6245 "*Alist of headers and regexps to match buttons in article heads.
6247 This alist is very similar to `gnus-button-alist', except that each
6248 alist has an additional HEADER element first in each entry:
6250 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6252 HEADER is a regexp to match a header. For a fuller explanation, see
6253 `gnus-button-alist'."
6254 :group 'gnus-article-buttons
6255 :group 'gnus-article-headers
6256 :type '(repeat (list (regexp :tag "Header")
6258 (integer :tag "Button")
6260 (function :tag "Callback")
6263 (integer :tag "Regexp group")))))
6265 (defvar gnus-button-regexp nil)
6266 (defvar gnus-button-marker-list nil)
6267 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6269 (defvar gnus-button-last nil)
6270 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6274 (defun gnus-article-push-button (event)
6275 "Check text under the mouse pointer for a callback function.
6276 If the text under the mouse pointer has a `gnus-callback' property,
6277 call it with the value of the `gnus-data' text property."
6279 (set-buffer (window-buffer (posn-window (event-start event))))
6280 (let* ((pos (posn-point (event-start event)))
6281 (data (get-text-property pos 'gnus-data))
6282 (fun (get-text-property pos 'gnus-callback)))
6285 (funcall fun data))))
6287 (defun gnus-article-press-button ()
6288 "Check text at point for a callback function.
6289 If the text at point has a `gnus-callback' property,
6290 call it with the value of the `gnus-data' text property."
6292 (let* ((data (get-text-property (point) 'gnus-data))
6293 (fun (get-text-property (point) 'gnus-callback)))
6295 (funcall fun data))))
6297 (defun gnus-article-prev-button (n)
6298 "Move point to N buttons backward.
6299 If N is negative, move forward instead."
6301 (gnus-article-next-button (- n)))
6303 (defun gnus-article-next-button (n)
6304 "Move point to N buttons forward.
6305 If N is negative, move backward instead."
6307 (let ((function (if (< n 0) 'previous-single-property-change
6308 'next-single-property-change))
6309 (inhibit-point-motion-hooks t)
6311 (limit (if (< n 0) (point-min) (point-max))))
6313 (while (and (not (= limit (point)))
6315 ;; Skip past the current button.
6316 (when (get-text-property (point) 'gnus-callback)
6317 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6318 ;; Go to the next (or previous) button.
6319 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6320 ;; Put point at the start of the button.
6321 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6322 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6323 ;; Skip past intangible buttons.
6324 (when (get-text-property (point) 'intangible)
6328 (gnus-message 5 "No more buttons"))
6331 (defun gnus-article-highlight (&optional force)
6332 "Highlight current article.
6333 This function calls `gnus-article-highlight-headers',
6334 `gnus-article-highlight-citation',
6335 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6336 do the highlighting. See the documentation for those functions."
6337 (interactive (list 'force))
6338 (gnus-article-highlight-headers)
6339 (gnus-article-highlight-citation force)
6340 (gnus-article-highlight-signature)
6341 (gnus-article-add-buttons force)
6342 (gnus-article-add-buttons-to-head))
6344 (defun gnus-article-highlight-some (&optional force)
6345 "Highlight current article.
6346 This function calls `gnus-article-highlight-headers',
6347 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6348 do the highlighting. See the documentation for those functions."
6349 (interactive (list 'force))
6350 (gnus-article-highlight-headers)
6351 (gnus-article-highlight-signature)
6352 (gnus-article-add-buttons))
6354 (defun gnus-article-highlight-headers ()
6355 "Highlight article headers as specified by `gnus-header-face-alist'."
6358 (set-buffer gnus-article-buffer)
6360 (let ((alist gnus-header-face-alist)
6361 (buffer-read-only nil)
6362 (case-fold-search t)
6363 (inhibit-point-motion-hooks t)
6364 entry regexp header-face field-face from hpoints fpoints)
6365 (article-narrow-to-head)
6366 (while (setq entry (pop alist))
6367 (goto-char (point-min))
6368 (setq regexp (concat "^\\("
6369 (if (string-equal "" (nth 0 entry))
6373 header-face (nth 1 entry)
6374 field-face (nth 2 entry))
6375 (while (and (re-search-forward regexp nil t)
6379 (unless (search-forward ":" nil t)
6381 (when (and header-face
6382 (not (memq (point) hpoints)))
6383 (push (point) hpoints)
6384 (gnus-put-text-property from (point) 'face header-face))
6385 (when (and field-face
6386 (not (memq (setq from (point)) fpoints)))
6388 (if (re-search-forward "^[^ \t]" nil t)
6390 (goto-char (point-max)))
6391 (gnus-put-text-property from (point) 'face field-face))))))))
6393 (defun gnus-article-highlight-signature ()
6394 "Highlight the signature in an article.
6395 It does this by highlighting everything after
6396 `gnus-signature-separator' using `gnus-signature-face'."
6398 (when gnus-signature-face
6400 (set-buffer gnus-article-buffer)
6401 (let ((buffer-read-only nil)
6402 (inhibit-point-motion-hooks t))
6404 (when (gnus-article-narrow-to-signature)
6405 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6406 'face gnus-signature-face)))))))
6408 (defun gnus-article-buttonize-signature ()
6409 "Add button to the signature."
6412 (set-buffer gnus-article-buffer)
6413 (let ((buffer-read-only nil)
6414 (inhibit-point-motion-hooks t))
6415 (when (gnus-article-search-signature)
6416 (gnus-article-add-button (match-beginning 0) (match-end 0)
6417 'gnus-signature-toggle
6418 (set-marker (make-marker)
6419 (1+ (match-end 0))))))))
6421 (defun gnus-button-in-region-p (b e prop)
6422 "Say whether PROP exists in the region."
6423 (text-property-not-all b e prop nil))
6425 (defun gnus-article-add-buttons (&optional force)
6426 "Find external references in the article and make buttons of them.
6427 \"External references\" are things like Message-IDs and URLs, as
6428 specified by `gnus-button-alist'."
6429 (interactive (list 'force))
6431 (set-buffer gnus-article-buffer)
6432 (let ((buffer-read-only nil)
6433 (inhibit-point-motion-hooks t)
6434 (case-fold-search t)
6435 (alist gnus-button-alist)
6437 ;; Remove all old markers.
6438 (let (marker entry new-list)
6439 (while (setq marker (pop gnus-button-marker-list))
6440 (if (or (< marker (point-min)) (>= marker (point-max)))
6441 (push marker new-list)
6443 (when (setq entry (gnus-button-entry))
6444 (put-text-property (match-beginning (nth 1 entry))
6445 (match-end (nth 1 entry))
6446 'gnus-callback nil))
6447 (set-marker marker nil)))
6448 (setq gnus-button-marker-list new-list))
6449 ;; We skip the headers.
6452 (while (setq entry (pop alist))
6453 (setq regexp (eval (car entry)))
6455 (while (re-search-forward regexp nil t)
6456 (let* ((start (and entry (match-beginning (nth 1 entry))))
6457 (end (and entry (match-end (nth 1 entry))))
6458 (from (match-beginning 0)))
6459 (when (and (or (eq t (nth 2 entry))
6460 (eval (nth 2 entry)))
6461 (not (gnus-button-in-region-p
6462 start end 'gnus-callback)))
6463 ;; That optional form returned non-nil, so we add the
6465 (gnus-article-add-button
6466 start end 'gnus-button-push
6467 (car (push (set-marker (make-marker) from)
6468 gnus-button-marker-list))))))))))
6470 ;; Add buttons to the head of an article.
6471 (defun gnus-article-add-buttons-to-head ()
6472 "Add buttons to the head of the article."
6475 (set-buffer gnus-article-buffer)
6477 (let ((buffer-read-only nil)
6478 (inhibit-point-motion-hooks t)
6479 (case-fold-search t)
6480 (alist gnus-header-button-alist)
6482 (article-narrow-to-head)
6484 ;; Each alist entry.
6485 (setq entry (car alist)
6487 (goto-char (point-min))
6488 (while (re-search-forward (car entry) nil t)
6489 ;; Each header matching the entry.
6490 (setq beg (match-beginning 0))
6491 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6492 (match-beginning 0))
6495 (while (re-search-forward (eval (nth 1 entry)) end t)
6496 ;; Each match within a header.
6497 (let* ((entry (cdr entry))
6498 (start (match-beginning (nth 1 entry)))
6499 (end (match-end (nth 1 entry)))
6500 (form (nth 2 entry)))
6501 (goto-char (match-end 0))
6503 (gnus-article-add-button
6504 start end (nth 3 entry)
6505 (buffer-substring (match-beginning (nth 4 entry))
6506 (match-end (nth 4 entry)))))))
6507 (goto-char end)))))))
6509 ;;; External functions:
6511 (defun gnus-article-add-button (from to fun &optional data)
6512 "Create a button between FROM and TO with callback FUN and data DATA."
6513 (when gnus-article-button-face
6514 (gnus-overlay-put (gnus-make-overlay from to)
6515 'face gnus-article-button-face))
6516 (gnus-add-text-properties
6518 (nconc (and gnus-article-mouse-face
6519 (list gnus-mouse-face-prop gnus-article-mouse-face))
6520 (list 'gnus-callback fun)
6521 (and data (list 'gnus-data data))))
6522 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6523 ;; Quote `:button-keymap' for Mule 2.3
6524 ;; but it won't work.
6525 ':button-keymap gnus-widget-button-keymap))
6527 ;;; Internal functions:
6529 (defun gnus-article-set-globals ()
6531 (set-buffer gnus-summary-buffer)
6532 (gnus-set-global-variables)))
6534 (defun gnus-signature-toggle (end)
6536 (set-buffer gnus-article-buffer)
6537 (let ((buffer-read-only nil)
6538 (inhibit-point-motion-hooks t)
6539 (limit (next-single-property-change end 'mime-view-entity
6541 (if (text-property-any end limit 'article-type 'signature)
6543 (gnus-delete-wash-type 'signature)
6544 (gnus-remove-text-properties-when
6545 'article-type 'signature end limit
6546 (cons 'article-type (cons 'signature
6547 gnus-hidden-properties))))
6548 (gnus-add-wash-type 'signature)
6549 (gnus-add-text-properties-when
6550 'article-type nil end limit
6551 (cons 'article-type (cons 'signature
6552 gnus-hidden-properties)))))
6553 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6554 (gnus-set-mode-line 'article))))
6556 (defun gnus-button-entry ()
6557 ;; Return the first entry in `gnus-button-alist' matching this place.
6558 (let ((alist gnus-button-alist)
6561 (setq entry (pop alist))
6562 (if (looking-at (eval (car entry)))
6567 (defun gnus-button-push (marker)
6568 ;; Push button starting at MARKER.
6571 (let* ((entry (gnus-button-entry))
6572 (inhibit-point-motion-hooks t)
6574 (args (mapcar (lambda (group)
6575 (let ((string (match-string group)))
6576 (gnus-set-text-properties
6577 0 (length string) nil string)
6584 (fboundp (symbol-value fun)))
6585 (apply (symbol-value fun) args))
6587 (gnus-message 1 "You must define `%S' to use this button"
6588 (cons fun args)))))))
6590 (defun gnus-parse-news-url (url)
6591 (let (scheme server group message-id articles)
6594 (goto-char (point-min))
6595 (when (looking-at "\\([A-Za-z]+\\):")
6596 (setq scheme (match-string 1))
6597 (goto-char (match-end 0)))
6598 (when (looking-at "//\\([^/]+\\)/")
6599 (setq server (match-string 1))
6600 (goto-char (match-end 0)))
6603 ((looking-at "\\(.*@.*\\)")
6604 (setq message-id (match-string 1)))
6605 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6606 (setq group (match-string 1)
6607 articles (split-string (match-string 2) "-")))
6608 ((looking-at "\\([^/]+\\)/?")
6609 (setq group (match-string 1)))
6611 (error "Unknown news URL syntax"))))
6612 (list scheme server group message-id articles)))
6614 (defun gnus-button-handle-news (url)
6616 (destructuring-bind (scheme server group message-id articles)
6617 (gnus-parse-news-url url)
6621 (set-buffer gnus-summary-buffer)
6623 (let ((gnus-refer-article-method (list (list 'nntp server))))
6624 (gnus-summary-refer-article message-id))
6625 (gnus-summary-refer-article message-id))))
6627 (gnus-button-fetch-group url)))))
6629 (defun gnus-button-handle-man (url)
6631 (funcall gnus-button-man-handler url))
6633 (defun gnus-button-handle-info (url)
6634 "Fetch an info URL."
6636 "^\\([^:/]+\\)?/\\(.*\\)"
6638 (gnus-info-find-node
6639 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6642 (gnus-url-unhex-string (match-string 2 url))))
6643 (error "Can't parse %s" url)))
6645 (defun gnus-button-message-id (message-id)
6648 (set-buffer gnus-summary-buffer)
6649 (gnus-summary-refer-article message-id)))
6651 (defun gnus-button-fetch-group (address)
6652 "Fetch GROUP specified by ADDRESS."
6653 (if (not (string-match "[:/]" address))
6654 ;; This is just a simple group url.
6655 (gnus-group-read-ephemeral-group address gnus-select-method)
6658 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6660 (error "Can't parse %s" address)
6661 (gnus-group-read-ephemeral-group
6662 (match-string 4 address)
6663 `(nntp ,(match-string 1 address)
6664 (nntp-address ,(match-string 1 address))
6665 (nntp-port-number ,(if (match-end 3)
6666 (match-string 3 address)
6669 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6671 (defun gnus-url-parse-query-string (query &optional downcase)
6672 (let (retval pairs cur key val)
6673 (setq pairs (split-string query "&"))
6675 (setq cur (car pairs)
6677 (if (not (string-match "=" cur))
6679 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6680 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6682 (setq key (downcase key)))
6683 (setq cur (assoc key retval))
6685 (setcdr cur (cons val (cdr cur)))
6686 (setq retval (cons (list key val) retval)))))
6689 (defun gnus-url-mailto (url)
6690 ;; Send mail to someone
6691 (when (string-match "mailto:/*\\(.*\\)" url)
6692 (setq url (substring url (match-beginning 1) nil)))
6693 (let (to args subject func)
6694 (if (string-match (regexp-quote "?") url)
6695 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6696 args (gnus-url-parse-query-string
6697 (substring url (match-end 0) nil) t))
6698 (setq to (gnus-url-unhex-string url)))
6699 (setq args (cons (list "to" to) args)
6700 subject (cdr-safe (assoc "subject" args)))
6703 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6706 (message-position-on-field (caar args)))
6707 (insert (mapconcat 'identity (cdar args) ", "))
6708 (setq args (cdr args)))
6711 (message-goto-subject))))
6713 (defun gnus-button-embedded-url (address)
6714 "Activate ADDRESS with `browse-url'."
6715 (browse-url (gnus-strip-whitespace address)))
6717 ;;; Next/prev buttons in the article buffer.
6719 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6720 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6722 (defvar gnus-prev-page-map
6723 (let ((map (make-sparse-keymap)))
6724 (unless (>= emacs-major-version 21)
6725 ;; XEmacs doesn't care.
6726 (set-keymap-parent map gnus-article-mode-map))
6727 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6728 (define-key map "\r" 'gnus-button-prev-page)
6731 (defun gnus-insert-prev-page-button ()
6733 (buffer-read-only nil)
6734 (situation (get-text-property (point-min) 'mime-view-situation)))
6736 gnus-prev-page-line-format nil
6737 `(,@(gnus-local-map-property gnus-prev-page-map)
6739 gnus-callback gnus-article-button-prev-page
6740 article-type annotation
6741 mime-view-situation ,situation))
6742 (widget-convert-button
6744 :action 'gnus-button-prev-page
6745 :button-keymap gnus-prev-page-map)))
6747 (defvar gnus-next-page-map
6748 (let ((map (make-sparse-keymap)))
6749 (unless (>= emacs-major-version 21)
6750 ;; XEmacs doesn't care.
6751 (set-keymap-parent map gnus-article-mode-map))
6752 (define-key map gnus-mouse-2 'gnus-button-next-page)
6753 (define-key map "\r" 'gnus-button-next-page)
6756 (defun gnus-button-next-page (&optional args more-args)
6757 "Go to the next page."
6759 (let ((win (selected-window)))
6760 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6761 (gnus-article-next-page)
6762 (select-window win)))
6764 (defun gnus-button-prev-page (&optional args more-args)
6765 "Go to the prev page."
6767 (let ((win (selected-window)))
6768 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6769 (gnus-article-prev-page)
6770 (select-window win)))
6772 (defun gnus-insert-next-page-button ()
6774 (buffer-read-only nil)
6775 (situation (get-text-property (point-min) 'mime-view-situation)))
6776 (gnus-eval-format gnus-next-page-line-format nil
6777 `(,@(gnus-local-map-property gnus-next-page-map)
6779 gnus-callback gnus-article-button-next-page
6780 article-type annotation
6781 mime-view-situation ,situation))
6782 (widget-convert-button
6784 :action 'gnus-button-next-page
6785 :button-keymap gnus-next-page-map)))
6787 (defun gnus-article-button-next-page (arg)
6788 "Go to the next page."
6790 (let ((win (selected-window)))
6791 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6792 (gnus-article-next-page)
6793 (select-window win)))
6795 (defun gnus-article-button-prev-page (arg)
6796 "Go to the prev page."
6798 (let ((win (selected-window)))
6799 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6800 (gnus-article-prev-page)
6801 (select-window win)))
6803 (defvar gnus-decode-header-methods
6804 '(mail-decode-encoded-word-region)
6805 "List of methods used to decode headers.
6807 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6808 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6809 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6810 whose names match REGEXP.
6813 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6814 mail-decode-encoded-word-region
6815 (\"chinese\" . rfc1843-decode-region))
6818 (defvar gnus-decode-header-methods-cache nil)
6820 (defun gnus-multi-decode-header (start end)
6821 "Apply the functions from `gnus-encoded-word-methods' that match."
6822 (unless (and gnus-decode-header-methods-cache
6823 (eq gnus-newsgroup-name
6824 (car gnus-decode-header-methods-cache)))
6825 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6828 (nconc gnus-decode-header-methods-cache (list x))
6829 (if (and gnus-newsgroup-name
6830 (string-match (car x) gnus-newsgroup-name))
6831 (nconc gnus-decode-header-methods-cache
6833 gnus-decode-header-methods))
6834 (let ((xlist gnus-decode-header-methods-cache))
6837 (narrow-to-region start end)
6839 (funcall (pop xlist) (point-min) (point-max))))))
6842 ;;; Treatment top-level handling.
6845 (defun gnus-treat-article (condition &optional part-number total-parts type)
6846 (let ((length (- (point-max) (point-min)))
6847 (alist gnus-treatment-function-alist)
6848 (article-goto-body-goes-to-point-min-p t)
6852 (let ((list gnus-article-treat-types))
6854 (when (string-match (pop list) type)
6855 (throw 'found t)))))))
6856 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6857 (entity (static-unless (featurep 'xemacs)
6858 (when (eq 'head condition)
6859 (get-text-property (point-min) 'mime-view-entity))))
6860 val elem buttonized)
6861 (gnus-run-hooks 'gnus-part-display-hook)
6862 (unless gnus-inhibit-treatment
6863 (dolist (elem alist)
6866 (when (gnus-buffer-live-p gnus-summary-buffer)
6867 (set-buffer gnus-summary-buffer))
6868 (symbol-value (car elem))))
6869 (when (and (or (consp val)
6871 (gnus-treat-predicate val)
6872 (or (not (get (car elem) 'highlight))
6874 (when (and (not buttonized)
6876 '(gnus-treat-hide-signature
6877 gnus-treat-highlight-signature)))
6878 (gnus-article-buttonize-signature)
6879 (setq buttonized t))
6881 (funcall (cadr elem)))))
6882 ;; FSF Emacsen does not inherit the existing text properties
6883 ;; in the new text, so we should do it for `mime-view-entity'.
6884 (static-unless (featurep 'xemacs)
6886 (put-text-property (point-min) (point-max)
6887 'mime-view-entity entity))))))
6889 ;; Dynamic variables.
6891 (defvar part-number)
6892 (defvar total-parts)
6897 (defun gnus-treat-predicate (val)
6902 (stringp (car val)))
6903 (apply 'gnus-or (mapcar `(lambda (s)
6904 (string-match s ,(or gnus-newsgroup-name "")))
6907 (let ((pred (pop val)))
6910 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6912 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6914 (not (gnus-treat-predicate (car val))))
6916 (equal (car val) type))
6918 (error "%S is not a valid predicate" pred)))))
6928 (eq part-number total-parts))
6932 (error "%S is not a valid value" val))))
6934 (defun gnus-article-encrypt-body (protocol &optional n)
6935 "Encrypt the article body."
6938 (or gnus-article-encrypt-protocol
6939 (completing-read "Encrypt protocol: "
6940 gnus-article-encrypt-protocol-alist
6942 current-prefix-arg))
6943 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6945 (error (format "Can't find the encrypt protocol %s" protocol)))
6946 (if (member gnus-newsgroup-name '("nndraft:delayed"
6949 (error "Can't encrypt the article in group %s"
6950 gnus-newsgroup-name))
6951 (gnus-summary-iterate n
6953 (set-buffer gnus-summary-buffer)
6954 (let ((mail-parse-charset gnus-newsgroup-charset)
6955 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6956 (summary-buffer gnus-summary-buffer)
6958 (gnus-set-global-variables)
6959 (when (gnus-group-read-only-p)
6960 (error "The current newsgroup does not support article encrypt"))
6961 (gnus-summary-show-article t)
6963 (or (mail-header-references gnus-current-headers) ""))
6964 (set-buffer gnus-article-buffer)
6965 (let* ((buffer-read-only nil)
6967 (mapcar (lambda (field)
6968 (and (save-restriction
6969 (message-narrow-to-head)
6970 (goto-char (point-min))
6971 (search-forward field nil t))
6973 (message-narrow-to-field)
6974 (buffer-substring (point-min) (point-max))
6975 (delete-region (point-min) (point-max))
6977 '("Content-Type:" "Content-Transfer-Encoding:"
6978 "Content-Disposition:"))))
6979 (message-narrow-to-head)
6980 (message-remove-header "MIME-Version")
6981 (goto-char (point-max))
6982 (setq point (point))
6983 (insert (apply 'concat headers))
6985 (narrow-to-region point (point-max))
6986 (let ((message-options message-options))
6987 (message-options-set 'message-sender user-mail-address)
6988 (message-options-set 'message-recipients user-mail-address)
6989 (message-options-set 'message-sign-encrypt 'not)
6991 (goto-char (point-min))
6992 (insert "MIME-Version: 1.0\n")
6994 (gnus-summary-edit-article-done
6995 references nil summary-buffer t))
6996 (when gnus-keep-backlog
6997 (gnus-backlog-remove-article
6998 (car gnus-article-current) (cdr gnus-article-current)))
7000 (when (get-buffer gnus-original-article-buffer)
7001 (set-buffer gnus-original-article-buffer)
7002 (setq gnus-original-article nil)))
7003 (when gnus-use-cache
7004 (gnus-cache-update-article
7005 (car gnus-article-current) (cdr gnus-article-current))))))))
7007 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7008 "The following specs can be used:
7009 %t The security MIME type
7012 %D Details if button is pressed")
7014 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7015 "The following specs can be used:
7016 %t The security MIME type
7019 %D Details if button is pressed")
7021 (defvar gnus-mime-security-button-line-format-alist
7022 '((?t gnus-tmp-type ?s)
7023 (?i gnus-tmp-info ?s)
7024 (?d gnus-tmp-details ?s)
7025 (?D gnus-tmp-pressed-details ?s)))
7027 (defvar gnus-mime-security-button-map
7028 (let ((map (make-sparse-keymap)))
7029 (unless (>= (string-to-number emacs-version) 21)
7030 (set-keymap-parent map gnus-article-mode-map))
7031 (define-key map gnus-mouse-2 'gnus-article-push-button)
7032 (define-key map "\r" 'gnus-article-press-button)
7035 (defvar gnus-mime-security-details-buffer nil)
7037 (defvar gnus-mime-security-button-pressed nil)
7039 (defvar gnus-mime-security-show-details-inline t
7040 "If non-nil, show details in the article buffer.")
7042 (defun gnus-mime-security-verify-or-decrypt (handle)
7043 (mm-remove-parts (cdr handle))
7044 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7045 point buffer-read-only)
7047 (goto-char (car region)))
7049 (narrow-to-region (point) (point))
7050 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7051 (let* ((mm-verify-option 'known)
7052 (mm-decrypt-option 'known)
7053 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7054 (unless (eq nparts (cdr handle))
7055 (mm-destroy-parts (cdr handle))
7056 (setcdr handle nparts))))
7057 (setq point (point))
7058 (gnus-mime-display-security handle)
7059 (goto-char (point-max)))
7061 (delete-region (point) (cdr region))
7062 (set-marker (car region) nil)
7063 (set-marker (cdr region) nil))
7066 (defun gnus-mime-security-show-details (handle)
7067 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7069 (if gnus-mime-security-show-details-inline
7070 (let ((gnus-mime-security-button-pressed t)
7071 (gnus-mime-security-button-line-format
7072 (get-text-property (point) 'gnus-line-format))
7075 (while (eq (get-text-property (point) 'gnus-line-format)
7076 gnus-mime-security-button-line-format)
7080 (narrow-to-region (point) (point))
7081 (gnus-insert-mime-security-button handle))
7082 (delete-region (point)
7083 (or (text-property-not-all
7086 gnus-mime-security-button-line-format)
7088 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7089 (with-current-buffer gnus-mime-security-details-buffer
7092 (setq gnus-mime-security-details-buffer
7093 (gnus-get-buffer-create "*MIME Security Details*")))
7094 (with-current-buffer gnus-mime-security-details-buffer
7096 (goto-char (point-min)))
7097 (pop-to-buffer gnus-mime-security-details-buffer))
7098 (gnus-message 5 "No details."))))
7100 (defun gnus-mime-security-press-button (handle)
7101 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7102 (gnus-mime-security-show-details handle)
7103 (gnus-mime-security-verify-or-decrypt handle)))
7105 (defun gnus-insert-mime-security-button (handle &optional displayed)
7106 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7109 (or (nth 2 (assoc protocol mm-verify-function-alist))
7110 (nth 2 (assoc protocol mm-decrypt-function-alist))
7112 (if (equal (car handle) "multipart/signed")
7113 " Signed" " Encrypted")
7116 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7119 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7120 gnus-tmp-pressed-details
7122 (setq gnus-tmp-details
7123 (if gnus-tmp-details
7124 (concat "\n" gnus-tmp-details) ""))
7125 (setq gnus-tmp-pressed-details
7126 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7131 gnus-mime-security-button-line-format
7132 gnus-mime-security-button-line-format-alist
7133 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7134 gnus-callback gnus-mime-security-press-button
7135 gnus-line-format ,gnus-mime-security-button-line-format
7136 article-type annotation
7139 (widget-convert-button
7142 :action 'gnus-widget-press-button
7143 :button-keymap gnus-mime-security-button-map
7145 (lambda (widget/window &optional overlay pos)
7146 ;; Needed to properly clear the message due to a bug in
7147 ;; wid-edit (XEmacs only).
7148 (if (boundp 'help-echo-owns-message)
7149 (setq help-echo-owns-message t))
7152 (aref gnus-mouse-2 0))))))
7154 (defun gnus-mime-display-security (handle)
7156 (narrow-to-region (point) (point))
7157 (unless (gnus-unbuttonized-mime-type-p (car handle))
7158 (gnus-insert-mime-security-button handle))
7159 (gnus-mime-display-mixed (cdr handle))
7162 (unless (gnus-unbuttonized-mime-type-p (car handle))
7163 (let ((gnus-mime-security-button-line-format
7164 gnus-mime-security-button-end-line-format))
7165 (gnus-insert-mime-security-button handle)))
7166 (mm-set-handle-multipart-parameter
7168 (cons (set-marker (make-marker) (point-min))
7169 (set-marker (make-marker) (point-max))))))
7175 (defun gnus-article-header-presentation-method (entity situation)
7176 (mime-insert-header entity)
7177 (article-decode-group-name))
7179 (set-alist 'mime-header-presentation-method-alist
7180 'gnus-original-article-mode
7181 #'gnus-article-header-presentation-method)
7183 (defun gnus-mime-preview-quitting-method ()
7184 (mime-preview-kill-buffer)
7185 (delete-other-windows)
7186 (gnus-article-show-summary)
7187 (gnus-summary-select-article gnus-show-all-headers t))
7189 (set-alist 'mime-preview-quitting-method-alist
7190 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7192 (set-alist 'mime-preview-following-method-alist
7193 'gnus-original-article-mode #'gnus-following-method)
7195 (set-alist 'mime-preview-over-to-previous-method-alist
7196 'gnus-original-article-mode
7198 (if (> (point-min) 1)
7199 (gnus-article-prev-page)
7200 (gnus-article-read-summary-keys
7201 nil (gnus-character-to-event ?P)))))
7203 (set-alist 'mime-preview-over-to-next-method-alist
7204 'gnus-original-article-mode'
7206 (if (< (point-max) (buffer-size))
7207 (gnus-article-next-page)
7208 (gnus-article-read-summary-keys
7209 nil (gnus-character-to-event ?N)))))
7219 (run-hooks 'gnus-art-load-hook)
7221 ;;; gnus-art.el ends here