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
118 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
119 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
120 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
121 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
122 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
123 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face"
124 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
125 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
126 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
127 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
128 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
129 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
130 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
131 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
132 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
133 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
134 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
135 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
136 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
137 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
138 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
139 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
140 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
141 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
142 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
143 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
144 "^X-Received:" "^Content-length:" "X-precedence:"
145 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
146 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
147 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
148 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
149 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
150 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:"
151 "^X-Request-PGP:" "^X-Fingerprint:" "^X-WRIEnvto:" "^X-WRIEnvfrom:"
152 "^X-Virus-Scanned:" "^X-Delivery-Agent:" "^Posted-Date:" "^X-Gateway:"
153 "^X-Local-Origin:" "^X-Local-Destination:" "^X-UserInfo1:"
154 "^X-Received-Date:" "^X-Hashcash:")
155 "*All headers that start with this regexp will be hidden.
156 This variable can also be a list of regexps of headers to be ignored.
157 If `gnus-visible-headers' is non-nil, this variable will be ignored."
158 :type '(choice :custom-show nil
161 :group 'gnus-article-hiding)
163 (defcustom gnus-visible-headers
164 "^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:"
165 "*All headers that do not match this regexp will be hidden.
166 This variable can also be a list of regexp of headers to remain visible.
167 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
168 :type '(repeat :value-to-internal (lambda (widget value)
169 (custom-split-regexp-maybe value))
170 :match (lambda (widget value)
172 (widget-editable-list-match widget value)))
174 :group 'gnus-article-hiding)
176 (defcustom gnus-sorted-header-list
177 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
178 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
179 "*This variable is a list of regular expressions.
180 If it is non-nil, headers that match the regular expressions will
181 be placed first in the article buffer in the sequence specified by
183 :type '(repeat regexp)
184 :group 'gnus-article-hiding)
186 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
187 "Headers that are only to be displayed if they have interesting data.
188 Possible values in this list are:
190 'empty Headers with no content.
191 'newsgroups Newsgroup identical to Gnus group.
192 'to-address To identical to To-address.
193 'followup-to Followup-to identical to Newsgroups.
194 'reply-to Reply-to identical to From.
195 'date Date less than four days old.
196 'long-to To and/or Cc longer than 1024 characters.
197 'many-to Multiple To and/or Cc."
198 :type '(set (const :tag "Headers with no content." empty)
199 (const :tag "Newsgroups identical to Gnus group." newsgroups)
200 (const :tag "To identical to To-address." to-address)
201 (const :tag "Followup-to identical to Newsgroups." followup-to)
202 (const :tag "Reply-to identical to From." reply-to)
203 (const :tag "Date less than four days old." date)
204 (const :tag "To and/or Cc longer than 1024 characters." long-to)
205 (const :tag "Multiple To and/or Cc headers." many-to))
206 :group 'gnus-article-hiding)
208 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
209 "Regexp matching signature separator.
210 This can also be a list of regexps. In that case, it will be checked
211 from head to tail looking for a separator. Searches will be done from
212 the end of the buffer."
213 :type '(repeat string)
214 :group 'gnus-article-signature)
216 (defcustom gnus-signature-limit nil
217 "Provide a limit to what is considered a signature.
218 If it is a number, no signature may not be longer (in characters) than
219 that number. If it is a floating point number, no signature may be
220 longer (in lines) than that number. If it is a function, the function
221 will be called without any parameters, and if it returns nil, there is
222 no signature in the buffer. If it is a string, it will be used as a
223 regexp. If it matches, the text in question is not a signature."
224 :type '(choice (integer :value 200)
226 (function :value fun)
227 (regexp :value ".*"))
228 :group 'gnus-article-signature)
230 (defcustom gnus-hidden-properties '(invisible t intangible t)
231 "Property list to use for hiding text."
233 :group 'gnus-article-hiding)
235 ;; Fixme: This isn't the right thing for mixed graphical and and
236 ;; non-graphical frames in a session.
237 (defcustom gnus-article-x-face-command
240 (if (or (gnus-image-type-available-p 'xface)
241 (gnus-image-type-available-p 'pbm))
242 'gnus-display-x-face-in-from
243 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
244 ((and (fboundp 'image-type-available-p)
245 (module-installed-p 'x-face-e21))
246 'x-face-decode-message-header)
247 ((gnus-image-type-available-p 'pbm)
248 'gnus-display-x-face-in-from)
250 (module-installed-p 'x-face-mule))
251 'x-face-mule-gnus-article-display-x-face)
253 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
255 "*String or function to be executed to display an X-Face header.
256 If it is a string, the command will be executed in a sub-shell
257 asynchronously. The compressed face will be piped to this command."
259 ,@(let (x-face-e21 x-face-mule)
260 (if (featurep 'xemacs)
262 (setq x-face-e21 (module-installed-p 'x-face-e21)
263 x-face-mule (module-installed-p 'x-face-mule)))
267 (if (or (gnus-image-type-available-p 'xface)
268 (gnus-image-type-available-p 'pbm))
269 '(function-item gnus-display-x-face-in-from))
271 (fboundp 'image-type-available-p))
273 :tag "x-face-decode-message-header (x-face-e21)"
274 x-face-decode-message-header))
277 x-face-mule-gnus-article-display-x-face))
281 :group 'gnus-article-washing)
283 (defcustom gnus-article-x-face-too-ugly nil
284 "Regexp matching posters whose face shouldn't be shown automatically."
285 :type '(choice regexp (const nil))
286 :group 'gnus-article-washing)
288 (defcustom gnus-article-banner-alist nil
289 "Banner alist for stripping.
291 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
293 :type '(repeat (cons symbol regexp))
294 :group 'gnus-article-washing)
296 (gnus-define-group-parameter
299 "Alist of regexps (to match group names) and banner."
300 :variable-group gnus-article-washing
302 '(choice :tag "Banner"
304 (const :tag "Remove signature" signature)
305 (symbol :tag "Item in `gnus-article-banner-alist'" none)
307 (const :tag "None" nil))
309 "If non-nil, specify how to remove `banners' from articles.
311 Symbol `signature' means to remove signatures delimited by
312 `gnus-signature-separator'. Any other symbol is used to look up a
313 regular expression to match the banner in `gnus-article-banner-alist'.
314 A string is used as a regular expression to match the banner
317 (defcustom gnus-article-address-banner-alist nil
318 "Alist of mail addresses and banners.
319 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
320 to match a mail address in the From: header, BANNER is one of a symbol
321 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
322 If ADDRESS matches author's mail address, it will remove things like
323 advertisements. For example:
325 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
329 (regexp :tag "Address")
330 (choice :tag "Banner" :value nil
331 (const :tag "Remove signature" signature)
332 (symbol :tag "Item in `gnus-article-banner-alist'" none)
334 (const :tag "None" nil))))
335 :group 'gnus-article-washing)
337 (defcustom gnus-emphasis-alist
339 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
344 ("_/" "/_" underline-italic)
345 ("_\\*" "\\*_" underline-bold)
346 ("\\*/" "/\\*" bold-italic)
347 ("_\\*/" "/\\*_" underline-bold-italic))))
351 (format format (car spec) (car (cdr spec)))
352 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
354 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
355 2 3 gnus-emphasis-strikethru)
356 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
357 2 3 gnus-emphasis-underline)))
358 "*Alist that says how to fontify certain phrases.
359 Each item looks like this:
361 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
363 The first element is a regular expression to be matched. The second
364 is a number that says what regular expression grouping used to find
365 the entire emphasized word. The third is a number that says what
366 regexp grouping should be displayed and highlighted. The fourth
367 is the face used for highlighting."
368 :type '(repeat (list :value ("" 0 0 default)
370 (integer :tag "Match group")
371 (integer :tag "Emphasize group")
373 :group 'gnus-article-emphasis)
375 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
376 "A regexp to describe whitespace which should not be emphasized.
377 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
378 The former avoids underlining of leading and trailing whitespace,
379 and the latter avoids underlining any whitespace at all."
381 :group 'gnus-article-emphasis
384 (defface gnus-emphasis-bold '((t (:bold t)))
385 "Face used for displaying strong emphasized text (*word*)."
386 :group 'gnus-article-emphasis)
388 (defface gnus-emphasis-italic '((t (:italic t)))
389 "Face used for displaying italic emphasized text (/word/)."
390 :group 'gnus-article-emphasis)
392 (defface gnus-emphasis-underline '((t (:underline t)))
393 "Face used for displaying underlined emphasized text (_word_)."
394 :group 'gnus-article-emphasis)
396 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
397 "Face used for displaying underlined bold emphasized text (_*word*_)."
398 :group 'gnus-article-emphasis)
400 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
401 "Face used for displaying underlined italic emphasized text (_/word/_)."
402 :group 'gnus-article-emphasis)
404 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
405 "Face used for displaying bold italic emphasized text (/*word*/)."
406 :group 'gnus-article-emphasis)
408 (defface gnus-emphasis-underline-bold-italic
409 '((t (:bold t :italic t :underline t)))
410 "Face used for displaying underlined bold italic emphasized text.
411 Example: (_/*word*/_)."
412 :group 'gnus-article-emphasis)
414 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
415 "Face used for displaying strike-through text (-word-)."
416 :group 'gnus-article-emphasis)
418 (defface gnus-emphasis-highlight-words
419 '((t (:background "black" :foreground "yellow")))
420 "Face used for displaying highlighted words."
421 :group 'gnus-article-emphasis)
423 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
424 "Format for display of Date headers in article bodies.
425 See `format-time-string' for the possible values.
427 The variable can also be function, which should return a complete Date
428 header. The function is called with one argument, the time, which can
429 be fed to `format-time-string'."
430 :type '(choice string symbol)
431 :link '(custom-manual "(gnus)Article Date")
432 :group 'gnus-article-washing)
435 (autoload 'mail-extract-address-components "mail-extr"))
437 (defcustom gnus-save-all-headers t
438 "*If non-nil, don't remove any headers before saving."
439 :group 'gnus-article-saving
442 (defcustom gnus-prompt-before-saving 'always
443 "*This variable says how much prompting is to be done when saving articles.
444 If it is nil, no prompting will be done, and the articles will be
445 saved to the default files. If this variable is `always', each and
446 every article that is saved will be preceded by a prompt, even when
447 saving large batches of articles. If this variable is neither nil not
448 `always', there the user will be prompted once for a file name for
449 each invocation of the saving commands."
450 :group 'gnus-article-saving
451 :type '(choice (item always)
452 (item :tag "never" nil)
453 (sexp :tag "once" :format "%t\n" :value t)))
455 (defcustom gnus-saved-headers gnus-visible-headers
456 "Headers to keep if `gnus-save-all-headers' is nil.
457 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
458 If that variable is nil, however, all headers that match this regexp
459 will be kept while the rest will be deleted before saving."
460 :group 'gnus-article-saving
463 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
464 "A function to save articles in your favourite format.
465 The function must be interactively callable (in other words, it must
466 be an Emacs command).
468 Gnus provides the following functions:
470 * gnus-summary-save-in-rmail (Rmail format)
471 * gnus-summary-save-in-mail (Unix mail format)
472 * gnus-summary-save-in-folder (MH folder)
473 * gnus-summary-save-in-file (article format)
474 * gnus-summary-save-body-in-file (article body)
475 * gnus-summary-save-in-vm (use VM's folder format)
476 * gnus-summary-write-to-file (article format -- overwrite)."
477 :group 'gnus-article-saving
478 :type '(radio (function-item gnus-summary-save-in-rmail)
479 (function-item gnus-summary-save-in-mail)
480 (function-item gnus-summary-save-in-folder)
481 (function-item gnus-summary-save-in-file)
482 (function-item gnus-summary-save-body-in-file)
483 (function-item gnus-summary-save-in-vm)
484 (function-item gnus-summary-write-to-file)))
486 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
487 "A function generating a file name to save articles in Rmail format.
488 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
489 :group 'gnus-article-saving
492 (defcustom gnus-mail-save-name 'gnus-plain-save-name
493 "A function generating a file name to save articles in Unix mail format.
494 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
495 :group 'gnus-article-saving
498 (defcustom gnus-folder-save-name 'gnus-folder-save-name
499 "A function generating a file name to save articles in MH folder.
500 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
501 :group 'gnus-article-saving
504 (defcustom gnus-file-save-name 'gnus-numeric-save-name
505 "A function generating a file name to save articles in article format.
506 The function is called with NEWSGROUP, HEADERS, and optional
508 :group 'gnus-article-saving
511 (defcustom gnus-split-methods
512 '((gnus-article-archive-name)
513 (gnus-article-nndoc-name))
514 "*Variable used to suggest where articles are to be saved.
515 For instance, if you would like to save articles related to Gnus in
516 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
517 you could set this variable to something like:
519 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
520 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
522 This variable is an alist where the where the key is the match and the
523 value is a list of possible files to save in if the match is non-nil.
525 If the match is a string, it is used as a regexp match on the
526 article. If the match is a symbol, that symbol will be funcalled
527 from the buffer of the article to be saved with the newsgroup as the
528 parameter. If it is a list, it will be evaled in the same buffer.
530 If this form or function returns a string, this string will be used as
531 a possible file name; and if it returns a non-nil list, that list will
532 be used as possible file names."
533 :group 'gnus-article-saving
534 :type '(repeat (choice (list :value (fun) function)
535 (cons :value ("" "") regexp (repeat string))
538 (defcustom gnus-article-display-method-for-mime
539 'gnus-article-display-mime-message
540 "Function to display a MIME message.
541 The function is called from the article buffer."
542 :group 'gnus-article-mime
545 (defcustom gnus-article-display-method-for-traditional
546 'gnus-article-display-traditional-message
547 "*Function to display a traditional message.
548 The function is called from the article buffer."
549 :group 'gnus-article-mime
552 (defcustom gnus-page-delimiter "^\^L"
553 "*Regexp describing what to use as article page delimiters.
554 The default value is \"^\^L\", which is a form linefeed at the
555 beginning of a line."
557 :group 'gnus-article-various)
559 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
560 "*The format specification for the article mode line.
561 See `gnus-summary-mode-line-format' for a closer description.
563 The following additional specs are available:
565 %w The article washing status.
566 %m The number of MIME parts in the article."
568 :group 'gnus-article-various)
570 (defcustom gnus-article-mode-hook nil
571 "*A hook for Gnus article mode."
573 :group 'gnus-article-various)
575 (when (featurep 'xemacs)
576 ;; Extracted from gnus-xmas-define in order to preserve user settings
577 (when (fboundp 'turn-off-scroll-in-place)
578 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
579 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
580 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
582 (defcustom gnus-article-menu-hook nil
583 "*Hook run after the creation of the article mode menu."
585 :group 'gnus-article-various)
587 (defcustom gnus-article-prepare-hook nil
588 "*A hook called after an article has been prepared in the article buffer."
590 :group 'gnus-article-various)
592 (defcustom gnus-article-hide-pgp-hook nil
593 "*A hook called after successfully hiding a PGP signature."
595 :group 'gnus-article-various)
597 (defcustom gnus-article-button-face 'bold
598 "Face used for highlighting buttons in the article buffer.
600 An article button is a piece of text that you can activate by pressing
601 `RET' or `mouse-2' above it."
603 :group 'gnus-article-buttons)
605 (defcustom gnus-article-mouse-face 'highlight
606 "Face used for mouse highlighting in the article buffer.
608 Article buttons will be displayed in this face when the cursor is
611 :group 'gnus-article-buttons)
613 (defcustom gnus-signature-face 'gnus-signature-face
614 "Face used for highlighting a signature in the article buffer.
615 Obsolete; use the face `gnus-signature-face' for customizations instead."
617 :group 'gnus-article-highlight
618 :group 'gnus-article-signature)
620 (defface gnus-signature-face
623 "Face used for highlighting a signature in the article buffer."
624 :group 'gnus-article-highlight
625 :group 'gnus-article-signature)
627 (defface gnus-header-from-face
630 (:foreground "spring green"))
633 (:foreground "red3"))
636 "Face used for displaying from headers."
637 :group 'gnus-article-headers
638 :group 'gnus-article-highlight)
640 (defface gnus-header-subject-face
643 (:foreground "SeaGreen3"))
646 (:foreground "red4"))
648 (:bold t :italic t)))
649 "Face used for displaying subject headers."
650 :group 'gnus-article-headers
651 :group 'gnus-article-highlight)
653 (defface gnus-header-newsgroups-face
656 (:foreground "yellow" :italic t))
659 (:foreground "MidnightBlue" :italic t))
662 "Face used for displaying newsgroups headers."
663 :group 'gnus-article-headers
664 :group 'gnus-article-highlight)
666 (defface gnus-header-name-face
669 (:foreground "SeaGreen"))
672 (:foreground "maroon"))
675 "Face used for displaying header names."
676 :group 'gnus-article-headers
677 :group 'gnus-article-highlight)
679 (defface gnus-header-content-face
682 (:foreground "forest green" :italic t))
685 (:foreground "indianred4" :italic t))
688 "Face used for displaying header content."
689 :group 'gnus-article-headers
690 :group 'gnus-article-highlight)
692 (defcustom gnus-header-face-alist
693 '(("From" nil gnus-header-from-face)
694 ("Subject" nil gnus-header-subject-face)
695 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
696 ("" gnus-header-name-face gnus-header-content-face))
697 "*Controls highlighting of article header.
699 An alist of the form (HEADER NAME CONTENT).
701 HEADER is a regular expression which should match the name of an
702 header header and NAME and CONTENT are either face names or nil.
704 The name of each header field will be displayed using the face
705 specified by the first element in the list where HEADER match the
706 header name and NAME is non-nil. Similarly, the content will be
707 displayed by the first non-nil matching CONTENT face."
708 :group 'gnus-article-headers
709 :group 'gnus-article-highlight
710 :type '(repeat (list (regexp :tag "Header")
712 (item :tag "skip" nil)
713 (face :value default))
714 (choice :tag "Content"
715 (item :tag "skip" nil)
716 (face :value default)))))
718 (defcustom gnus-article-decode-hook nil
719 "*Hook run to decode charsets in articles."
720 :group 'gnus-article-headers
723 (defcustom gnus-display-mime-function 'gnus-display-mime
724 "Function to display MIME articles."
725 :group 'gnus-article-mime
728 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
729 "Function used to decode headers.")
731 (defvar gnus-article-dumbquotes-map
751 "Table for MS-to-Latin1 translation.")
753 (defcustom gnus-ignored-mime-types nil
754 "List of MIME types that should be ignored by Gnus."
756 :group 'gnus-article-mime
757 :type '(repeat regexp))
759 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
760 "List of MIME types that should not be given buttons when rendered inline.
761 See also `gnus-buttonized-mime-types' which may override this variable."
763 :group 'gnus-article-mime
764 :type '(repeat regexp))
766 (defcustom gnus-buttonized-mime-types nil
767 "List of MIME types that should be given buttons when rendered inline.
768 If set, this variable overrides `gnus-unbuttonized-mime-types'.
769 To see e.g. security buttons you could set this to
770 `(\"multipart/signed\")'."
772 :group 'gnus-article-mime
773 :type '(repeat regexp))
775 (defcustom gnus-inhibit-mime-unbuttonizing nil
776 "If non-nil, all MIME parts get buttons.
777 When nil (the default value), then some MIME parts do not get buttons,
778 as described by the variables `gnus-buttonized-mime-types' and
779 `gnus-unbuttonized-mime-types'."
783 (defcustom gnus-body-boundary-delimiter "_"
784 "String used to delimit header and body.
785 This variable is used by `gnus-article-treat-body-boundary' which can
786 be controlled by `gnus-treat-body-boundary'."
787 :group 'gnus-article-various
788 :type '(choice (item :tag "None" :value nil)
791 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
792 "Defines the location of the faces database.
793 For information on obtaining this database of pretty pictures, please
794 see http://www.cs.indiana.edu/picons/ftp/index.html"
795 :type '(repeat directory)
796 :link '(url-link :tag "download"
797 "http://www.cs.indiana.edu/picons/ftp/index.html")
798 :link '(custom-manual "(gnus)Picons")
801 (defun gnus-picons-installed-p ()
802 "Say whether picons are installed on your machine."
803 (let ((installed nil))
804 (dolist (database gnus-picon-databases)
805 (when (file-exists-p database)
809 (defcustom gnus-article-mime-part-function nil
810 "Function called with a MIME handle as the argument.
811 This is meant for people who want to do something automatic based
812 on parts -- for instance, adding Vcard info to a database."
813 :group 'gnus-article-mime
816 (defcustom gnus-mime-multipart-functions nil
817 "An alist of MIME types to functions to display them."
819 :group 'gnus-article-mime
822 (defcustom gnus-article-date-lapsed-new-header nil
823 "Whether the X-Sent and Date headers can coexist.
824 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
825 either replace the old \"Date:\" header (if this variable is nil), or
826 be added below it (otherwise)."
828 :group 'gnus-article-headers
831 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
832 "Function called with a MIME handle as the argument.
833 This is meant for people who want to view first matched part.
834 For `undisplayed-alternative' (default), the first undisplayed
835 part or alternative part is used. For `undisplayed', the first
836 undisplayed part is used. For a function, the first part which
837 the function return `t' is used. For `nil', the first part is
840 :group 'gnus-article-mime
842 (item :tag "first" :value nil)
843 (item :tag "undisplayed" :value undisplayed)
844 (item :tag "undisplayed or alternative"
845 :value undisplayed-alternative)
848 (defcustom gnus-mime-action-alist
849 '(("save to file" . gnus-mime-save-part)
850 ("save and strip" . gnus-mime-save-part-and-strip)
851 ("display as text" . gnus-mime-inline-part)
852 ("view the part" . gnus-mime-view-part)
853 ("pipe to command" . gnus-mime-pipe-part)
854 ("toggle display" . gnus-article-press-button)
855 ("toggle display" . gnus-article-view-part-as-charset)
856 ("view as type" . gnus-mime-view-part-as-type)
857 ("view internally" . gnus-mime-view-part-internally)
858 ("view externally" . gnus-mime-view-part-externally))
859 "An alist of actions that run on the MIME attachment."
860 :group 'gnus-article-mime
861 :type '(repeat (cons (string :tag "name")
865 ;;; The treatment variables
868 (defvar gnus-part-display-hook nil
869 "Hook called on parts that are to receive treatment.")
871 (defvar gnus-article-treat-custom
872 '(choice (const :tag "Off" nil)
874 (const :tag "Header" head)
875 (const :tag "Last" last)
876 (const :tag "Mime" mime)
877 (integer :tag "Less")
878 (repeat :tag "Groups" regexp)
879 (sexp :tag "Predicate")))
881 (defvar gnus-article-treat-head-custom
882 '(choice (const :tag "Off" nil)
883 (const :tag "Header" head)))
885 (defvar gnus-article-treat-types '("text/plain")
888 (defvar gnus-inhibit-treatment nil
889 "Whether to inhibit treatment.")
891 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
892 "Highlight the signature.
893 Valid values are nil, t, `head', `last', an integer or a predicate.
894 See Info node `(gnus)Customizing Articles'."
895 :group 'gnus-article-treat
896 :link '(custom-manual "(gnus)Customizing Articles")
897 :type gnus-article-treat-custom)
898 (put 'gnus-treat-highlight-signature 'highlight t)
900 (defcustom gnus-treat-buttonize 100000
902 Valid values are nil, t, `head', `last', an integer or a predicate.
903 See Info node `(gnus)Customizing Articles'."
904 :group 'gnus-article-treat
905 :link '(custom-manual "(gnus)Customizing Articles")
906 :type gnus-article-treat-custom)
907 (put 'gnus-treat-buttonize 'highlight t)
909 (defcustom gnus-treat-buttonize-head 'head
910 "Add buttons to the head.
911 Valid values are nil, t, `head', `last', an integer or a predicate.
912 See Info node `(gnus)Customizing Articles' for details."
913 :group 'gnus-article-treat
914 :link '(custom-manual "(gnus)Customizing Articles")
915 :type gnus-article-treat-head-custom)
916 (put 'gnus-treat-buttonize-head 'highlight t)
918 (defcustom gnus-treat-emphasize
919 (and (or window-system
921 (>= (string-to-number emacs-version) 21))
924 Valid values are nil, t, `head', `last', an integer or a predicate.
925 See Info node `(gnus)Customizing Articles' for details."
926 :group 'gnus-article-treat
927 :link '(custom-manual "(gnus)Customizing Articles")
928 :type gnus-article-treat-custom)
929 (put 'gnus-treat-emphasize 'highlight t)
931 (defcustom gnus-treat-strip-cr nil
932 "Remove carriage returns.
933 Valid values are nil, t, `head', `last', an integer or a predicate.
934 See Info node `(gnus)Customizing Articles' for details."
935 :group 'gnus-article-treat
936 :link '(custom-manual "(gnus)Customizing Articles")
937 :type gnus-article-treat-custom)
939 (defcustom gnus-treat-unsplit-urls nil
940 "Remove newlines from within URLs.
941 Valid values are nil, t, `head', `last', an integer or a predicate.
942 See Info node `(gnus)Customizing Articles' for details."
943 :group 'gnus-article-treat
944 :link '(custom-manual "(gnus)Customizing Articles")
945 :type gnus-article-treat-custom)
947 (defcustom gnus-treat-leading-whitespace nil
948 "Remove leading whitespace in headers.
949 Valid values are nil, t, `head', `last', an integer or a predicate.
950 See Info node `(gnus)Customizing Articles' for details."
951 :group 'gnus-article-treat
952 :link '(custom-manual "(gnus)Customizing Articles")
953 :type gnus-article-treat-custom)
955 (defcustom gnus-treat-hide-headers 'head
957 Valid values are nil, t, `head', `last', an integer or a predicate.
958 See Info node `(gnus)Customizing Articles' for details."
959 :group 'gnus-article-treat
960 :link '(custom-manual "(gnus)Customizing Articles")
961 :type gnus-article-treat-head-custom)
963 (defcustom gnus-treat-hide-boring-headers nil
964 "Hide boring headers.
965 Valid values are nil, t, `head', `last', an integer or a predicate.
966 See Info node `(gnus)Customizing Articles' for details."
967 :group 'gnus-article-treat
968 :link '(custom-manual "(gnus)Customizing Articles")
969 :type gnus-article-treat-head-custom)
971 (defcustom gnus-treat-hide-signature nil
973 Valid values are nil, t, `head', `last', an integer or a predicate.
974 See Info node `(gnus)Customizing Articles' for details."
975 :group 'gnus-article-treat
976 :link '(custom-manual "(gnus)Customizing Articles")
977 :type gnus-article-treat-custom)
979 (defcustom gnus-treat-fill-article nil
981 Valid values are nil, t, `head', `last', an integer or a predicate.
982 See Info node `(gnus)Customizing Articles' for details."
983 :group 'gnus-article-treat
984 :link '(custom-manual "(gnus)Customizing Articles")
985 :type gnus-article-treat-custom)
987 (defcustom gnus-treat-hide-citation nil
989 Valid values are nil, t, `head', `last', an integer or a predicate.
990 See Info node `(gnus)Customizing Articles' for details."
991 :group 'gnus-article-treat
992 :link '(custom-manual "(gnus)Customizing Articles")
993 :type gnus-article-treat-custom)
995 (defcustom gnus-treat-hide-citation-maybe nil
997 Valid values are nil, t, `head', `last', an integer or a predicate.
998 See Info node `(gnus)Customizing Articles' for details."
999 :group 'gnus-article-treat
1000 :link '(custom-manual "(gnus)Customizing Articles")
1001 :type gnus-article-treat-custom)
1003 (defcustom gnus-treat-strip-list-identifiers 'head
1004 "Strip list identifiers from `gnus-list-identifiers`.
1005 Valid values are nil, t, `head', `last', an integer or a predicate.
1006 See Info node `(gnus)Customizing Articles' for details."
1008 :group 'gnus-article-treat
1009 :link '(custom-manual "(gnus)Customizing Articles")
1010 :type gnus-article-treat-custom)
1012 (defcustom gnus-treat-strip-pgp t
1013 "Strip PGP signatures.
1014 Valid values are nil, t, `head', `last', an integer or a predicate.
1015 See Info node `(gnus)Customizing Articles' for details."
1016 :group 'gnus-article-treat
1017 :link '(custom-manual "(gnus)Customizing Articles")
1018 :type gnus-article-treat-custom)
1020 (defcustom gnus-treat-strip-pem nil
1021 "Strip PEM signatures.
1022 Valid values are nil, t, `head', `last', an integer or a predicate.
1023 See Info node `(gnus)Customizing Articles' for details."
1024 :group 'gnus-article-treat
1025 :link '(custom-manual "(gnus)Customizing Articles")
1026 :type gnus-article-treat-custom)
1028 (defcustom gnus-treat-strip-banner t
1029 "Strip banners from articles.
1030 The banner to be stripped is specified in the `banner' group parameter.
1031 Valid values are nil, t, `head', `last', an integer or a predicate.
1032 See Info node `(gnus)Customizing Articles' for details."
1033 :group 'gnus-article-treat
1034 :link '(custom-manual "(gnus)Customizing Articles")
1035 :type gnus-article-treat-custom)
1037 (defcustom gnus-treat-highlight-headers 'head
1038 "Highlight the headers.
1039 Valid values are nil, t, `head', `last', an integer or a predicate.
1040 See Info node `(gnus)Customizing Articles' for details."
1041 :group 'gnus-article-treat
1042 :link '(custom-manual "(gnus)Customizing Articles")
1043 :type gnus-article-treat-head-custom)
1044 (put 'gnus-treat-highlight-headers 'highlight t)
1046 (defcustom gnus-treat-highlight-citation t
1047 "Highlight cited text.
1048 Valid values are nil, t, `head', `last', an integer or a predicate.
1049 See Info node `(gnus)Customizing Articles' for details."
1050 :group 'gnus-article-treat
1051 :link '(custom-manual "(gnus)Customizing Articles")
1052 :type gnus-article-treat-custom)
1053 (put 'gnus-treat-highlight-citation 'highlight t)
1055 (defcustom gnus-treat-date-ut nil
1056 "Display the Date in UT (GMT).
1057 Valid values are nil, t, `head', `last', an integer or a predicate.
1058 See Info node `(gnus)Customizing Articles' for details."
1059 :group 'gnus-article-treat
1060 :link '(custom-manual "(gnus)Customizing Articles")
1061 :type gnus-article-treat-head-custom)
1063 (defcustom gnus-treat-date-local nil
1064 "Display the Date in the local timezone.
1065 Valid values are nil, t, `head', `last', an integer or a predicate.
1066 See Info node `(gnus)Customizing Articles' for details."
1067 :group 'gnus-article-treat
1068 :link '(custom-manual "(gnus)Customizing Articles")
1069 :type gnus-article-treat-head-custom)
1071 (defcustom gnus-treat-date-english nil
1072 "Display the Date in a format that can be read aloud in English.
1073 Valid values are nil, t, `head', `last', an integer or a predicate.
1074 See Info node `(gnus)Customizing Articles' for details."
1075 :group 'gnus-article-treat
1076 :link '(custom-manual "(gnus)Customizing Articles")
1077 :type gnus-article-treat-head-custom)
1079 (defcustom gnus-treat-date-lapsed nil
1080 "Display the Date header in a way that says how much time has elapsed.
1081 Valid values are nil, t, `head', `last', an integer or a predicate.
1082 See Info node `(gnus)Customizing Articles' for details."
1083 :group 'gnus-article-treat
1084 :link '(custom-manual "(gnus)Customizing Articles")
1085 :type gnus-article-treat-head-custom)
1087 (defcustom gnus-treat-date-original nil
1088 "Display the date in the original timezone.
1089 Valid values are nil, t, `head', `last', an integer or a predicate.
1090 See Info node `(gnus)Customizing Articles' for details."
1091 :group 'gnus-article-treat
1092 :link '(custom-manual "(gnus)Customizing Articles")
1093 :type gnus-article-treat-head-custom)
1095 (defcustom gnus-treat-date-iso8601 nil
1096 "Display the date in the ISO8601 format.
1097 Valid values are nil, t, `head', `last', an integer or a predicate.
1098 See Info node `(gnus)Customizing Articles' for details."
1100 :group 'gnus-article-treat
1101 :link '(custom-manual "(gnus)Customizing Articles")
1102 :type gnus-article-treat-head-custom)
1104 (defcustom gnus-treat-date-user-defined nil
1105 "Display the date in a user-defined format.
1106 The format is defined by the `gnus-article-time-format' variable.
1107 Valid values are nil, t, `head', `last', an integer or a predicate.
1108 See Info node `(gnus)Customizing Articles' for details."
1109 :group 'gnus-article-treat
1110 :link '(custom-manual "(gnus)Customizing Articles")
1111 :type gnus-article-treat-head-custom)
1113 (defcustom gnus-treat-strip-headers-in-body t
1114 "Strip the X-No-Archive header line from the beginning of the body.
1115 Valid values are nil, t, `head', `last', an integer or a predicate.
1116 See Info node `(gnus)Customizing Articles' for details."
1118 :group 'gnus-article-treat
1119 :link '(custom-manual "(gnus)Customizing Articles")
1120 :type gnus-article-treat-custom)
1122 (defcustom gnus-treat-strip-trailing-blank-lines nil
1123 "Strip trailing blank lines.
1124 Valid values are nil, t, `head', `last', an integer or a predicate.
1125 See Info node `(gnus)Customizing Articles' for details."
1126 :group 'gnus-article-treat
1127 :link '(custom-manual "(gnus)Customizing Articles")
1128 :type gnus-article-treat-custom)
1130 (defcustom gnus-treat-strip-leading-blank-lines nil
1131 "Strip leading blank lines.
1132 Valid values are nil, t, `head', `last', an integer or a predicate.
1133 See Info node `(gnus)Customizing Articles' for details."
1134 :group 'gnus-article-treat
1135 :link '(custom-manual "(gnus)Customizing Articles")
1136 :type gnus-article-treat-custom)
1138 (defcustom gnus-treat-strip-multiple-blank-lines nil
1139 "Strip multiple blank lines.
1140 Valid values are nil, t, `head', `last', an integer or a predicate.
1141 See Info node `(gnus)Customizing Articles' for details."
1142 :group 'gnus-article-treat
1143 :link '(custom-manual "(gnus)Customizing Articles")
1144 :type gnus-article-treat-custom)
1146 (defcustom gnus-treat-unfold-headers 'head
1147 "Unfold folded header lines.
1148 Valid values are nil, t, `head', `last', an integer or a predicate.
1149 See Info node `(gnus)Customizing Articles' for details."
1150 :group 'gnus-article-treat
1151 :link '(custom-manual "(gnus)Customizing Articles")
1152 :type gnus-article-treat-custom)
1154 (defcustom gnus-treat-fold-headers nil
1156 Valid values are nil, t, `head', `last', an integer or a predicate.
1157 See Info node `(gnus)Customizing Articles' for details."
1158 :group 'gnus-article-treat
1159 :link '(custom-manual "(gnus)Customizing Articles")
1160 :type gnus-article-treat-custom)
1162 (defcustom gnus-treat-fold-newsgroups 'head
1163 "Fold the Newsgroups and Followup-To headers.
1164 Valid values are nil, t, `head', `last', an integer or a predicate.
1165 See Info node `(gnus)Customizing Articles' for details."
1166 :group 'gnus-article-treat
1167 :link '(custom-manual "(gnus)Customizing Articles")
1168 :type gnus-article-treat-custom)
1170 (defcustom gnus-treat-overstrike t
1171 "Treat overstrike highlighting.
1172 Valid values are nil, t, `head', `last', an integer or a predicate.
1173 See Info node `(gnus)Customizing Articles' for details."
1174 :group 'gnus-article-treat
1175 :link '(custom-manual "(gnus)Customizing Articles")
1176 :type gnus-article-treat-custom)
1177 (put 'gnus-treat-overstrike 'highlight t)
1179 (defcustom gnus-treat-display-xface
1180 (and (not noninteractive)
1181 (or (and (fboundp 'image-type-available-p)
1182 (image-type-available-p 'xbm)
1183 (string-match "^0x" (shell-command-to-string "uncompface")))
1184 (and (featurep 'xemacs)
1186 (eq 'x-face-mule-gnus-article-display-x-face
1187 gnus-article-x-face-command))
1189 "Display X-Face headers.
1190 Valid values are nil, t, `head', `last', an integer or a predicate.
1191 See Info node `(gnus)Customizing Articles' and Info node
1192 `(gnus)X-Face' for details."
1193 :group 'gnus-article-treat
1195 :link '(custom-manual "(gnus)Customizing Articles")
1196 :link '(custom-manual "(gnus)X-Face")
1197 :type gnus-article-treat-head-custom)
1198 (put 'gnus-treat-display-xface 'highlight t)
1200 (defcustom gnus-article-should-use-smiley-mule
1201 (not (or (featurep 'xemacs)
1202 (gnus-image-type-available-p 'xpm)
1203 (gnus-image-type-available-p 'pbm)))
1204 "If non-nil, gnus uses `smiley-mule' for displaying smileys rather than
1205 `smiley'. It defaults to t when Emacs 20 or earlier is running.
1206 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1207 even if you are using Emacs 21+. It has no effect on XEmacs."
1208 :group 'gnus-article-various
1210 :get (lambda (symbol)
1211 (and (default-value symbol)
1212 (not (featurep 'xemacs))
1213 (module-installed-p 'smiley-mule)
1215 :set (lambda (symbol value)
1216 (set-default symbol (and value
1217 (not (featurep 'xemacs))
1218 (module-installed-p 'smiley-mule)
1221 (defvar gnus-article-smiley-mule-loaded-p nil
1222 "Internal variable used to say whether `smiley-mule' is loaded (whether
1223 smiley functions are not overridden by `smiley').")
1225 (defcustom gnus-treat-display-grey-xface
1226 (and (not noninteractive)
1227 (or (featurep 'xemacs)
1228 (and (fboundp 'display-images-p)
1229 (display-images-p)))
1230 (string-match "^0x" (shell-command-to-string "uncompface"))
1232 "Display grey X-Face headers.
1233 Valid values are nil, t."
1234 :group 'gnus-article-treat
1237 (put 'gnus-treat-display-grey-xface 'highlight t)
1239 (defcustom gnus-treat-display-smileys
1240 (if (or (and (featurep 'xemacs)
1242 (gnus-image-type-available-p 'xpm)
1243 (gnus-image-type-available-p 'pbm)
1244 (and (not (featurep 'xemacs))
1246 (module-installed-p 'smiley-mule)))
1250 Valid values are nil, t, `head', `last', an integer or a predicate.
1251 See Info node `(gnus)Customizing Articles' and Info node
1252 `(gnus)Smileys' for details."
1253 :group 'gnus-article-treat
1255 :link '(custom-manual "(gnus)Customizing Articles")
1256 :link '(custom-manual "(gnus)Smileys")
1257 :type gnus-article-treat-custom)
1258 (put 'gnus-treat-display-smileys 'highlight t)
1260 (defcustom gnus-treat-from-picon
1261 (if (and (gnus-image-type-available-p 'xpm)
1262 (gnus-picons-installed-p))
1264 "Display picons in the From header.
1265 Valid values are nil, t, `head', `last', an integer or a predicate.
1266 See Info node `(gnus)Customizing Articles' and Info node
1267 `(gnus)Picons' for details."
1268 :group 'gnus-article-treat
1270 :link '(custom-manual "(gnus)Customizing Articles")
1271 :link '(custom-manual "(gnus)Picons")
1272 :type gnus-article-treat-head-custom)
1273 (put 'gnus-treat-from-picon 'highlight t)
1275 (defcustom gnus-treat-mail-picon
1276 (if (and (gnus-image-type-available-p 'xpm)
1277 (gnus-picons-installed-p))
1279 "Display picons in To and Cc headers.
1280 Valid values are nil, t, `head', `last', an integer or a predicate.
1281 See Info node `(gnus)Customizing Articles' and Info node
1282 `(gnus)Picons' for details."
1283 :group 'gnus-article-treat
1285 :link '(custom-manual "(gnus)Customizing Articles")
1286 :link '(custom-manual "(gnus)Picons")
1287 :type gnus-article-treat-head-custom)
1288 (put 'gnus-treat-mail-picon 'highlight t)
1290 (defcustom gnus-treat-newsgroups-picon
1291 (if (and (gnus-image-type-available-p 'xpm)
1292 (gnus-picons-installed-p))
1294 "Display picons in the Newsgroups and Followup-To headers.
1295 Valid values are nil, t, `head', `last', an integer or a predicate.
1296 See Info node `(gnus)Customizing Articles' and Info node
1297 `(gnus)Picons' for details."
1298 :group 'gnus-article-treat
1300 :link '(custom-manual "(gnus)Customizing Articles")
1301 :link '(custom-manual "(gnus)Picons")
1302 :type gnus-article-treat-head-custom)
1303 (put 'gnus-treat-newsgroups-picon 'highlight t)
1305 (defcustom gnus-treat-body-boundary
1306 (if (or gnus-treat-newsgroups-picon
1307 gnus-treat-mail-picon
1308 gnus-treat-from-picon)
1310 "Draw a boundary at the end of the headers.
1311 Valid values are nil, t, `head', `last', an integer or a predicate.
1312 See Info node `(gnus)Customizing Articles' for details."
1314 :group 'gnus-article-treat
1315 :link '(custom-manual "(gnus)Customizing Articles")
1316 :type gnus-article-treat-custom)
1318 (defcustom gnus-treat-capitalize-sentences nil
1319 "Capitalize sentence-starting words.
1320 Valid values are nil, t, `head', `last', an integer or a predicate.
1321 See Info node `(gnus)Customizing Articles' for details."
1323 :group 'gnus-article-treat
1324 :link '(custom-manual "(gnus)Customizing Articles")
1325 :type gnus-article-treat-custom)
1327 (defcustom gnus-treat-wash-html nil
1329 Valid values are nil, t, `head', `last', an integer or a predicate.
1330 See Info node `(gnus)Customizing Articles' for details."
1331 :group 'gnus-article-treat
1332 :link '(custom-manual "(gnus)Customizing Articles")
1333 :type gnus-article-treat-custom)
1335 (defcustom gnus-treat-fill-long-lines nil
1337 Valid values are nil, t, `head', `last', an integer or a predicate.
1338 See Info node `(gnus)Customizing Articles' for details."
1339 :group 'gnus-article-treat
1340 :link '(custom-manual "(gnus)Customizing Articles")
1341 :type gnus-article-treat-custom)
1343 (defcustom gnus-treat-play-sounds nil
1345 Valid values are nil, t, `head', `last', an integer or a predicate.
1346 See Info node `(gnus)Customizing Articles' for details."
1348 :group 'gnus-article-treat
1349 :link '(custom-manual "(gnus)Customizing Articles")
1350 :type gnus-article-treat-custom)
1352 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1353 "Decode an article as `default-mime-charset'. For instance, if you want to
1354 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1355 you could set this variable to something like: nil for don't decode, t for
1356 decode the body, '(or header t) for the whole article, etc."
1357 :group 'gnus-article-treat
1358 :type '(radio (const :tag "Off" nil)
1359 (const :tag "Decode body" t)
1360 (const :tag "Decode all" (or head t))))
1362 (defcustom gnus-treat-translate nil
1363 "Translate articles from one language to another.
1364 Valid values are nil, t, `head', `last', an integer or a predicate.
1365 See Info node `(gnus)Customizing Articles' for details."
1367 :group 'gnus-article-treat
1368 :link '(custom-manual "(gnus)Customizing Articles")
1369 :type gnus-article-treat-custom)
1371 (defcustom gnus-treat-x-pgp-sig nil
1373 To automatically treat X-PGP-Sig, set it to head.
1374 Valid values are nil, t, `head', `last', an integer or a predicate.
1375 See Info node `(gnus)Customizing Articles' for details."
1376 :group 'gnus-article-treat
1377 :group 'mime-security
1378 :type gnus-article-treat-custom)
1380 (defcustom gnus-treat-monafy nil
1381 "Display body part with mona font.
1382 Valid values are nil, t, `head', `last', an integer or a predicate.
1383 See Info node `(gnus)Customizing Articles' for details."
1384 :group 'gnus-article-treat
1385 :group 'mime-security
1386 :link '(custom-manual "(gnus)Customizing Articles")
1387 :type gnus-article-treat-custom)
1389 (defvar gnus-article-encrypt-protocol-alist
1390 '(("PGP" . mml2015-self-encrypt)))
1392 ;; Set to nil if more than one protocol added to
1393 ;; gnus-article-encrypt-protocol-alist.
1394 (defcustom gnus-article-encrypt-protocol "PGP"
1395 "The protocol used for encrypt articles.
1396 It is a string, such as \"PGP\". If nil, ask user."
1398 :group 'mime-security)
1400 (defvar gnus-article-wash-function nil
1401 "Function used for converting HTML into text.")
1403 ;;; Internal variables
1405 (defvar gnus-english-month-names
1406 '("January" "February" "March" "April" "May" "June" "July" "August"
1407 "September" "October" "November" "December"))
1409 (defvar article-goto-body-goes-to-point-min-p nil)
1410 (defvar gnus-article-wash-types nil)
1411 (defvar gnus-article-emphasis-alist nil)
1412 (defvar gnus-article-image-alist nil)
1414 (defvar gnus-article-mime-handle-alist-1 nil)
1415 (defvar gnus-treatment-function-alist
1416 '((gnus-treat-decode-article-as-default-mime-charset
1417 gnus-article-decode-article-as-default-mime-charset)
1418 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1419 (gnus-treat-monafy gnus-article-monafy)
1420 (gnus-treat-strip-banner gnus-article-strip-banner)
1421 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1422 (gnus-treat-buttonize gnus-article-add-buttons)
1423 (gnus-treat-fill-article gnus-article-fill-cited-article)
1424 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1425 (gnus-treat-strip-cr gnus-article-remove-cr)
1426 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1427 (gnus-treat-date-ut gnus-article-date-ut)
1428 (gnus-treat-date-local gnus-article-date-local)
1429 (gnus-treat-date-english gnus-article-date-english)
1430 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1431 (gnus-treat-date-original gnus-article-date-original)
1432 (gnus-treat-date-user-defined gnus-article-date-user)
1433 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1434 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1435 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1436 (gnus-treat-hide-signature gnus-article-hide-signature)
1437 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1438 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1439 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1440 (gnus-treat-strip-pem gnus-article-hide-pem)
1441 (gnus-treat-from-picon gnus-treat-from-picon)
1442 (gnus-treat-mail-picon gnus-treat-mail-picon)
1443 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1444 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1445 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1446 (gnus-treat-strip-trailing-blank-lines
1447 gnus-article-remove-trailing-blank-lines)
1448 (gnus-treat-strip-leading-blank-lines
1449 gnus-article-strip-leading-blank-lines)
1450 (gnus-treat-strip-multiple-blank-lines
1451 gnus-article-strip-multiple-blank-lines)
1452 (gnus-treat-overstrike gnus-article-treat-overstrike)
1453 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1454 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1455 ;; Displaying X-Face should be done after unfolding headers
1456 ;; to protect bitmap lines.
1457 (gnus-treat-display-xface gnus-article-display-x-face)
1458 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1459 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1460 (gnus-treat-display-smileys gnus-treat-smiley)
1461 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1462 (gnus-treat-wash-html gnus-article-wash-html)
1463 (gnus-treat-emphasize gnus-article-emphasize)
1464 (gnus-treat-hide-citation gnus-article-hide-citation)
1465 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1466 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1467 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1468 (gnus-treat-play-sounds gnus-earcon-display)))
1470 (defvar gnus-article-mime-handle-alist nil)
1471 (defvar article-lapsed-timer nil)
1472 (defvar gnus-article-current-summary nil)
1474 (defvar gnus-article-mode-syntax-table
1475 (let ((table (copy-syntax-table text-mode-syntax-table)))
1476 ;; This causes the citation match run O(2^n).
1477 ;; (modify-syntax-entry ?- "w" table)
1478 (modify-syntax-entry ?> ")<" table)
1479 (modify-syntax-entry ?< "(>" table)
1480 ;; make M-. in article buffers work for `foo' strings
1481 (modify-syntax-entry ?' " " table)
1482 (modify-syntax-entry ?` " " table)
1484 "Syntax table used in article mode buffers.
1485 Initialized from `text-mode-syntax-table.")
1487 (defvar gnus-save-article-buffer nil)
1489 (defvar gnus-article-mode-line-format-alist
1490 (nconc '((?w (gnus-article-wash-status) ?s)
1491 (?m (gnus-article-mime-part-status) ?s))
1492 gnus-summary-mode-line-format-alist))
1494 (defvar gnus-number-of-articles-to-be-saved nil)
1496 (defvar gnus-inhibit-hiding nil)
1498 ;;; Macros for dealing with the article buffer.
1500 (defmacro gnus-with-article-headers (&rest forms)
1502 (set-buffer gnus-article-buffer)
1504 (let ((buffer-read-only nil)
1505 (inhibit-point-motion-hooks t)
1506 (case-fold-search t))
1507 (article-narrow-to-head)
1510 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1511 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1513 (defmacro gnus-with-article-buffer (&rest forms)
1515 (set-buffer gnus-article-buffer)
1516 (let ((buffer-read-only nil))
1519 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1520 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1522 (defun gnus-article-goto-header (header)
1523 "Go to HEADER, which is a regular expression."
1524 (re-search-forward (concat "^\\(" header "\\):") nil t))
1526 (defsubst gnus-article-hide-text (b e props)
1527 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1528 (gnus-add-text-properties-when 'article-type nil b e props)
1529 (when (memq 'intangible props)
1531 (max (1- b) (point-min))
1532 b 'intangible (cddr (memq 'intangible props)))))
1534 (defsubst gnus-article-unhide-text (b e)
1535 "Remove hidden text properties from region between B and E."
1536 (remove-text-properties b e gnus-hidden-properties)
1537 (when (memq 'intangible gnus-hidden-properties)
1538 (put-text-property (max (1- b) (point-min))
1539 b 'intangible nil)))
1541 (defun gnus-article-hide-text-type (b e type)
1542 "Hide text of TYPE between B and E."
1543 (gnus-add-wash-type type)
1544 (gnus-article-hide-text
1545 b e (cons 'article-type (cons type gnus-hidden-properties))))
1547 (defun gnus-article-unhide-text-type (b e type)
1548 "Unhide text of TYPE between B and E."
1549 (gnus-delete-wash-type type)
1550 (remove-text-properties
1551 b e (cons 'article-type (cons type gnus-hidden-properties)))
1552 (when (memq 'intangible gnus-hidden-properties)
1553 (put-text-property (max (1- b) (point-min))
1554 b 'intangible nil)))
1556 (defun gnus-article-hide-text-of-type (type)
1557 "Hide text of TYPE in the current buffer."
1559 (let ((b (point-min))
1561 (while (setq b (text-property-any b e 'article-type type))
1562 (add-text-properties b (incf b) gnus-hidden-properties)))))
1564 (defun gnus-article-delete-text-of-type (type)
1565 "Delete text of TYPE in the current buffer."
1567 (let ((b (point-min)))
1568 (while (setq b (text-property-any b (point-max) 'article-type type))
1570 b (or (text-property-not-all b (point-max) 'article-type type)
1573 (defun gnus-article-delete-invisible-text ()
1574 "Delete all invisible text in the current buffer."
1576 (let ((b (point-min)))
1577 (while (setq b (text-property-any b (point-max) 'invisible t))
1579 b (or (text-property-not-all b (point-max) 'invisible t)
1582 (defun gnus-article-text-type-exists-p (type)
1583 "Say whether any text of type TYPE exists in the buffer."
1584 (text-property-any (point-min) (point-max) 'article-type type))
1586 (defsubst gnus-article-header-rank ()
1587 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1588 (let ((list gnus-sorted-header-list)
1591 (if (looking-at (car list))
1593 (setq list (cdr list))
1597 (defun article-hide-headers (&optional arg delete)
1598 "Hide unwanted headers and possibly sort them as well."
1599 (interactive (gnus-article-hidden-arg))
1600 ;; Lars said that this function might be inhibited.
1601 (if (gnus-article-check-hidden-text 'headers arg)
1603 ;; Show boring headers as well.
1604 (gnus-article-show-hidden-text 'boring-headers)
1605 (when (eq 1 (point-min))
1606 (set-window-start (get-buffer-window (current-buffer)) 1)))
1607 (unless gnus-inhibit-hiding
1610 (let ((inhibit-read-only t)
1611 (case-fold-search t)
1612 (max (1+ (length gnus-sorted-header-list)))
1613 (ignored (when (not gnus-visible-headers)
1614 (cond ((stringp gnus-ignored-headers)
1615 gnus-ignored-headers)
1616 ((listp gnus-ignored-headers)
1617 (mapconcat 'identity gnus-ignored-headers
1620 (cond ((stringp gnus-visible-headers)
1621 gnus-visible-headers)
1622 ((and gnus-visible-headers
1623 (listp gnus-visible-headers))
1624 (mapconcat 'identity gnus-visible-headers "\\|"))))
1625 (inhibit-point-motion-hooks t)
1627 ;; First we narrow to just the headers.
1628 (article-narrow-to-head)
1629 ;; Hide any "From " lines at the beginning of (mail) articles.
1630 (while (looking-at "From ")
1634 (delete-region (point-min) (point))
1635 (gnus-article-hide-text (point-min) (point)
1636 (nconc (list 'article-type 'headers)
1637 gnus-hidden-properties))))
1638 ;; Then treat the rest of the header lines.
1639 ;; Then we use the two regular expressions
1640 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1641 ;; select which header lines is to remain visible in the
1643 (while (re-search-forward "^[^ \t:]*:" nil t)
1645 ;; Mark the rank of the header.
1647 (point) (1+ (point)) 'message-rank
1648 (if (or (and visible (looking-at visible))
1650 (not (looking-at ignored))))
1651 (gnus-article-header-rank)
1654 (message-sort-headers-1)
1655 (when (setq beg (text-property-any
1656 (point-min) (point-max) 'message-rank (+ 2 max)))
1657 ;; We delete or make invisible the unwanted headers.
1658 (gnus-add-wash-type 'headers)
1661 (add-text-properties
1662 (point-min) (+ 5 (point-min))
1663 '(article-type headers dummy-invisible t))
1664 (delete-region beg (point-max)))
1665 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1667 (defun article-hide-boring-headers (&optional arg)
1668 "Toggle hiding of headers that aren't very interesting.
1669 If given a negative prefix, always show; if given a positive prefix,
1671 (interactive (gnus-article-hidden-arg))
1672 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1673 (not gnus-show-all-headers))
1676 (let ((buffer-read-only nil)
1677 (list gnus-boring-article-headers)
1678 (inhibit-point-motion-hooks t)
1680 (article-narrow-to-head)
1682 (setq elem (pop list))
1683 (goto-char (point-min))
1685 ;; Hide empty headers.
1687 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1689 (gnus-article-hide-text-type
1690 (progn (beginning-of-line) (point))
1693 (if (re-search-forward "^[^ \t]" nil t)
1697 ;; Hide boring Newsgroups header.
1698 ((eq elem 'newsgroups)
1699 (when (gnus-string-equal
1700 (gnus-fetch-field "newsgroups")
1701 (gnus-group-real-name
1702 (if (boundp 'gnus-newsgroup-name)
1705 (gnus-article-hide-header "newsgroups")))
1706 ((eq elem 'to-address)
1707 (let ((to (message-fetch-field "to"))
1709 (gnus-parameter-to-address
1710 (if (boundp 'gnus-newsgroup-name)
1711 gnus-newsgroup-name ""))))
1712 (when (and to to-address
1715 ;; only one address in To
1716 (nth 1 (mail-extract-address-components to))
1718 (gnus-article-hide-header "to"))))
1719 ((eq elem 'followup-to)
1720 (when (gnus-string-equal
1721 (message-fetch-field "followup-to")
1722 (message-fetch-field "newsgroups"))
1723 (gnus-article-hide-header "followup-to")))
1724 ((eq elem 'reply-to)
1725 (let ((from (message-fetch-field "from"))
1726 (reply-to (message-fetch-field "reply-to")))
1731 (nth 1 (mail-extract-address-components from))
1732 (nth 1 (mail-extract-address-components reply-to)))))
1733 (gnus-article-hide-header "reply-to"))))
1735 (let ((date (message-fetch-field "date")))
1737 (< (days-between (current-time-string) date)
1739 (gnus-article-hide-header "date"))))
1741 (let ((to (message-fetch-field "to"))
1742 (cc (message-fetch-field "cc")))
1743 (when (> (length to) 1024)
1744 (gnus-article-hide-header "to"))
1745 (when (> (length cc) 1024)
1746 (gnus-article-hide-header "cc"))))
1750 (goto-char (point-min))
1751 (while (re-search-forward "^to:" nil t)
1752 (setq to-count (1+ to-count)))
1753 (when (> to-count 1)
1754 (while (> to-count 0)
1755 (goto-char (point-min))
1757 (re-search-forward "^to:" nil nil to-count)
1759 (narrow-to-region (point) (point-max))
1760 (gnus-article-hide-header "to"))
1761 (setq to-count (1- to-count))))
1762 (goto-char (point-min))
1763 (while (re-search-forward "^cc:" nil t)
1764 (setq cc-count (1+ cc-count)))
1765 (when (> cc-count 1)
1766 (while (> cc-count 0)
1767 (goto-char (point-min))
1769 (re-search-forward "^cc:" nil nil cc-count)
1771 (narrow-to-region (point) (point-max))
1772 (gnus-article-hide-header "cc"))
1773 (setq cc-count (1- cc-count)))))))))))))
1775 (defun gnus-article-hide-header (header)
1777 (goto-char (point-min))
1778 (when (re-search-forward (concat "^" header ":") nil t)
1779 (gnus-article-hide-text-type
1780 (progn (beginning-of-line) (point))
1783 (if (re-search-forward "^[^ \t]" nil t)
1788 (defvar gnus-article-normalized-header-length 40
1789 "Length of normalized headers.")
1791 (defun article-normalize-headers ()
1792 "Make all header lines 40 characters long."
1794 (let ((buffer-read-only nil)
1798 (article-narrow-to-head)
1801 ((< (setq column (- (gnus-point-at-eol) (point)))
1802 gnus-article-normalized-header-length)
1804 (insert (make-string
1805 (- gnus-article-normalized-header-length column)
1807 ((> column gnus-article-normalized-header-length)
1808 (gnus-put-text-property
1810 (forward-char gnus-article-normalized-header-length)
1817 (forward-line 1))))))
1819 (defun article-treat-dumbquotes ()
1820 "Translate M****s*** sm*rtq**t*s into proper text.
1821 Note that this function guesses whether a character is a sm*rtq**t* or
1822 not, so it should only be used interactively.
1824 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1825 in an attempt to provide more quoting characters. If you see
1826 something like \\222 or \\264 where you're expecting some kind of
1827 apostrophe or quotation mark, then try this wash."
1829 (article-translate-strings gnus-article-dumbquotes-map))
1831 (defun article-translate-characters (from to)
1832 "Translate all characters in the body of the article according to FROM and TO.
1833 FROM is a string of characters to translate from; to is a string of
1834 characters to translate to."
1836 (when (article-goto-body)
1837 (let ((buffer-read-only nil)
1838 (x (make-string 225 ?x))
1840 (while (< (incf i) (length x))
1843 (while (< i (length from))
1844 (aset x (aref from i) (aref to i))
1846 (translate-region (point) (point-max) x)))))
1848 (defun article-translate-strings (map)
1849 "Translate all string in the body of the article according to MAP.
1850 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1852 (when (article-goto-body)
1853 (let ((buffer-read-only nil)
1855 (while (setq elem (pop map))
1857 (while (search-forward (car elem) nil t)
1858 (replace-match (cadr elem)))))))))
1860 (defun article-treat-overstrike ()
1861 "Translate overstrikes into bold text."
1864 (when (article-goto-body)
1865 (let ((buffer-read-only nil))
1866 (while (search-forward "\b" nil t)
1867 (let ((next (char-after))
1871 previous (char-after))
1875 ;; We do the boldification/underlining by hiding the
1876 ;; overstrikes and putting the proper text property
1880 (gnus-article-hide-text-type start (point) 'overstrike)
1881 (put-text-property (point) end 'face 'bold))
1883 (gnus-article-hide-text-type
1884 (1- (point)) (1+ (point)) 'overstrike)
1886 start (1- (point)) 'face 'underline))
1888 (gnus-article-hide-text-type start (point) 'overstrike)
1890 (point) end 'face 'underline)))))))))
1892 (defun gnus-article-treat-unfold-headers ()
1893 "Unfold folded message headers.
1894 Only the headers that fit into the current window width will be
1897 (gnus-with-article-headers
1901 (mail-header-narrow-to-field)
1902 (let ((header (buffer-substring (point-min) (point-max))))
1905 (goto-char (point-min))
1906 (while (re-search-forward "\n[\t ]" nil t)
1907 (replace-match " " t t)))
1908 (setq length (- (point-max) (point-min) 1)))
1909 (when (< length (window-width))
1910 (while (re-search-forward "\n[\t ]" nil t)
1911 (replace-match " " t t)))
1912 (goto-char (point-max)))))))
1914 (defun gnus-article-treat-fold-headers ()
1915 "Fold message headers."
1917 (gnus-with-article-headers
1920 (mail-header-narrow-to-field)
1921 (mail-header-fold-field)
1922 (goto-char (point-max))))))
1924 (defun gnus-treat-smiley ()
1925 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1927 (unless (featurep 'xemacs)
1928 (when (and (>= emacs-major-version 21)
1929 (not gnus-article-should-use-smiley-mule)
1930 gnus-article-smiley-mule-loaded-p)
1931 (load "smiley" nil t)
1932 (setq gnus-article-smiley-mule-loaded-p nil))
1933 (when (and gnus-article-should-use-smiley-mule
1934 (not gnus-article-smiley-mule-loaded-p))
1935 (load "smiley-mule" nil t)
1936 (setq gnus-article-smiley-mule-loaded-p t)))
1937 (gnus-with-article-buffer
1938 (if (memq 'smiley gnus-article-wash-types)
1939 (gnus-delete-images 'smiley)
1941 (let ((images (smiley-region (point) (point-max))))
1943 (gnus-add-wash-type 'smiley)
1944 (dolist (image images)
1945 (gnus-add-image 'smiley image)))))))
1947 (defun gnus-article-remove-images ()
1948 "Remove all images from the article buffer."
1950 (gnus-with-article-buffer
1951 (dolist (elem gnus-article-image-alist)
1952 (gnus-delete-images (car elem)))))
1954 (defun gnus-article-treat-fold-newsgroups ()
1955 "Unfold folded message headers.
1956 Only the headers that fit into the current window width will be
1959 (gnus-with-article-headers
1960 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1962 (mail-header-narrow-to-field)
1963 (while (re-search-forward ", *" nil t)
1964 (replace-match ", " t t))
1965 (mail-header-fold-field)
1966 (goto-char (point-max))))))
1968 (defun gnus-article-treat-body-boundary ()
1969 "Place a boundary line at the end of the headers."
1971 (when (and gnus-body-boundary-delimiter
1972 (> (length gnus-body-boundary-delimiter) 0))
1973 (gnus-with-article-headers
1974 (goto-char (point-max))
1975 (let ((start (point)))
1976 (insert "X-Boundary: ")
1977 (gnus-add-text-properties start (point) '(invisible t intangible t))
1979 (while (>= (1- (window-width)) (length str))
1980 (setq str (concat str gnus-body-boundary-delimiter)))
1981 (substring str 0 (1- (window-width))))
1983 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1985 (defun article-fill-long-lines ()
1986 "Fill lines that are wider than the window width."
1989 (let ((buffer-read-only nil)
1990 (width (window-width (get-buffer-window (current-buffer)))))
1993 (let ((adaptive-fill-mode nil)) ;Why? -sm
1996 (when (>= (current-column) (min fill-column width))
1997 (narrow-to-region (min (1+ (point)) (point-max))
1998 (gnus-point-at-bol))
1999 (let ((goback (point-marker)))
2000 (fill-paragraph nil)
2001 (goto-char (marker-position goback)))
2003 (forward-line 1)))))))
2005 (defun article-capitalize-sentences ()
2006 "Capitalize the first word in each sentence."
2009 (let ((buffer-read-only nil)
2010 (paragraph-start "^[\n\^L]"))
2014 (forward-sentence)))))
2016 (defun article-remove-cr ()
2017 "Remove trailing CRs and then translate remaining CRs into LFs."
2020 (let ((buffer-read-only nil))
2021 (goto-char (point-min))
2022 (while (re-search-forward "\r+$" nil t)
2023 (replace-match "" t t))
2024 (goto-char (point-min))
2025 (while (search-forward "\r" nil t)
2026 (replace-match "\n" t t)))))
2028 (defun article-remove-trailing-blank-lines ()
2029 "Remove all trailing blank lines from the article."
2032 (let ((buffer-read-only nil))
2033 (goto-char (point-max))
2037 (while (and (not (bobp))
2038 (looking-at "^[ \t]*$")
2039 (not (gnus-annotation-in-region-p
2040 (point) (gnus-point-at-eol))))
2045 (defun article-display-x-face (&optional force)
2046 "Look for an X-Face header and display it if present."
2047 (interactive (list 'force))
2048 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2049 (gnus-with-article-headers
2050 ;; Delete the old process, if any.
2051 (when (process-status "article-x-face")
2052 (delete-process "article-x-face"))
2053 (if (memq 'xface gnus-article-wash-types)
2054 ;; We have already displayed X-Faces, so we remove them
2056 (gnus-delete-images 'xface)
2058 (let (x-faces from face grey)
2060 (when (and wash-face-p
2062 (goto-char (point-min))
2063 (not (re-search-forward
2064 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2065 (gnus-buffer-live-p gnus-original-article-buffer))
2066 ;; If type `W f', use gnus-original-article-buffer,
2067 ;; otherwise use the current buffer because displaying
2068 ;; RFC822 parts calls this function too.
2069 (set-buffer gnus-original-article-buffer))
2071 (mail-narrow-to-head)
2072 (if gnus-treat-display-grey-xface
2074 (while (gnus-article-goto-header "X-Face\\(-[0-9]+\\)?")
2075 (if (match-beginning 2)
2078 (push (cons (- (string-to-number (match-string 2)))
2079 (mail-header-field-value))
2081 (push (cons 0 (mail-header-field-value)) x-faces)))
2082 (dolist (x-face (prog1
2084 (sort x-faces 'car-less-than-car)
2086 (setq x-faces nil)))
2087 (push (cdr x-face) x-faces)))
2088 (while (gnus-article-goto-header "X-Face")
2089 (push (mail-header-field-value) x-faces)))
2090 (setq from (message-fetch-field "from"))))
2092 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
2095 (setq image (gnus-create-image xpm 'xpm t))
2096 (gnus-article-goto-header "from")
2098 (insert "From: [no `from' set]\n")
2100 (gnus-add-wash-type 'xface)
2101 (gnus-add-image 'xface image)
2102 (gnus-put-image image)))
2103 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2104 ;; single external face.
2105 (when (stringp gnus-article-x-face-command)
2106 (setq x-faces (list (car x-faces))))
2107 (while (and (setq face (pop x-faces))
2108 gnus-article-x-face-command
2110 ;; Check whether this face is censored.
2111 (not gnus-article-x-face-too-ugly)
2112 (and gnus-article-x-face-too-ugly from
2113 (not (string-match gnus-article-x-face-too-ugly
2115 ;; We display the face.
2116 (if (symbolp gnus-article-x-face-command)
2117 ;; The command is a lisp function, so we call it.
2118 (if (gnus-functionp gnus-article-x-face-command)
2119 (funcall gnus-article-x-face-command face)
2120 (error "%s is not a function" gnus-article-x-face-command))
2121 ;; The command is a string, so we interpret the command
2122 ;; as a, well, command, and fork it off.
2123 (let ((process-connection-type nil))
2124 (process-kill-without-query
2126 "article-x-face" nil shell-file-name shell-command-switch
2127 gnus-article-x-face-command))
2130 (process-send-region "article-x-face"
2131 (point-min) (point-max)))
2132 (process-send-eof "article-x-face"))))))))))
2134 (defun article-decode-mime-words ()
2135 "Decode all MIME-encoded words in the article."
2138 (set-buffer gnus-article-buffer)
2139 (let ((inhibit-point-motion-hooks t)
2141 (mail-parse-charset gnus-newsgroup-charset)
2142 (mail-parse-ignored-charsets
2143 (save-excursion (set-buffer gnus-summary-buffer)
2144 gnus-newsgroup-ignored-charsets)))
2145 (mail-decode-encoded-word-region (point-min) (point-max)))))
2147 (defun article-decode-charset (&optional prompt)
2148 "Decode charset-encoded text in the article.
2149 If PROMPT (the prefix), prompt for a coding system to use."
2151 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2153 (mail-parse-charset gnus-newsgroup-charset)
2154 (mail-parse-ignored-charsets
2155 (save-excursion (condition-case nil
2156 (set-buffer gnus-summary-buffer)
2158 gnus-newsgroup-ignored-charsets))
2159 ct cte ctl charset format)
2162 (article-narrow-to-head)
2163 (setq ct (message-fetch-field "Content-Type" t)
2164 cte (message-fetch-field "Content-Transfer-Encoding" t)
2165 ctl (and ct (ignore-errors
2166 (mail-header-parse-content-type ct)))
2169 (mm-read-coding-system "Charset to decode: "))
2171 (mail-content-type-get ctl 'charset)))
2172 format (and ctl (mail-content-type-get ctl 'format)))
2174 (setq cte (mail-header-strip cte)))
2175 (if (and ctl (not (string-match "/" (car ctl))))
2177 (goto-char (point-max)))
2180 (narrow-to-region (point) (point-max))
2181 (when (and (eq mail-parse-charset 'gnus-decoded)
2182 (eq (mm-body-7-or-8) '8bit))
2183 ;; The text code could have been decoded.
2184 (setq charset mail-parse-charset))
2185 (when (and (or (not ctl)
2186 (equal (car ctl) "text/plain"))
2187 (not format)) ;; article with format will decode later.
2189 charset (and cte (intern (downcase
2190 (gnus-strip-whitespace cte))))
2193 (defun article-decode-encoded-words ()
2194 "Remove encoded-word encoding from headers."
2195 (let (buffer-read-only)
2196 (let ((charset (save-excursion
2197 (set-buffer gnus-summary-buffer)
2198 default-mime-charset)))
2199 (mime-decode-header-in-buffer charset))))
2201 (defun article-decode-group-name ()
2202 "Decode group names in `Newsgroups:'."
2203 (let ((inhibit-point-motion-hooks t)
2205 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2206 (when (and (or gnus-group-name-charset-method-alist
2207 gnus-group-name-charset-group-alist)
2208 (gnus-buffer-live-p gnus-original-article-buffer))
2209 (when (nnmail-fetch-field "Newsgroups")
2210 (nnheader-replace-header "Newsgroups"
2211 (gnus-decode-newsgroups
2212 (with-current-buffer
2213 gnus-original-article-buffer
2214 (nnmail-fetch-field "Newsgroups"))
2215 gnus-newsgroup-name method)))
2216 (when (nnmail-fetch-field "Followup-To")
2217 (nnheader-replace-header "Followup-To"
2218 (gnus-decode-newsgroups
2219 (with-current-buffer
2220 gnus-original-article-buffer
2221 (nnmail-fetch-field "Followup-To"))
2222 gnus-newsgroup-name method))))))
2224 (defun article-de-quoted-unreadable (&optional force read-charset)
2225 "Translate a quoted-printable-encoded article.
2226 If FORCE, decode the article whether it is marked as quoted-printable
2228 If READ-CHARSET, ask for a coding system."
2229 (interactive (list 'force current-prefix-arg))
2231 (let ((buffer-read-only nil) type charset)
2232 (if (gnus-buffer-live-p gnus-original-article-buffer)
2233 (with-current-buffer gnus-original-article-buffer
2235 (gnus-fetch-field "content-transfer-encoding"))
2236 (let* ((ct (gnus-fetch-field "content-type"))
2239 (mail-header-parse-content-type ct)))))
2240 (setq charset (and ctl
2241 (mail-content-type-get ctl 'charset)))
2242 (if (stringp charset)
2243 (setq charset (intern (downcase charset)))))))
2245 (setq charset (mm-read-coding-system "Charset: " charset)))
2247 (setq charset gnus-newsgroup-charset))
2249 (and type (let ((case-fold-search t))
2250 (string-match "quoted-printable" type))))
2252 (quoted-printable-decode-region
2253 (point) (point-max) (mm-charset-to-coding-system charset))))))
2255 (defun article-de-base64-unreadable (&optional force read-charset)
2256 "Translate a base64 article.
2257 If FORCE, decode the article whether it is marked as base64 not.
2258 If READ-CHARSET, ask for a coding system."
2259 (interactive (list 'force current-prefix-arg))
2261 (let ((buffer-read-only nil) type charset)
2262 (if (gnus-buffer-live-p gnus-original-article-buffer)
2263 (with-current-buffer gnus-original-article-buffer
2265 (gnus-fetch-field "content-transfer-encoding"))
2266 (let* ((ct (gnus-fetch-field "content-type"))
2269 (mail-header-parse-content-type ct)))))
2270 (setq charset (and ctl
2271 (mail-content-type-get ctl 'charset)))
2272 (if (stringp charset)
2273 (setq charset (intern (downcase charset)))))))
2275 (setq charset (mm-read-coding-system "Charset: " charset)))
2277 (setq charset gnus-newsgroup-charset))
2279 (and type (let ((case-fold-search t))
2280 (string-match "base64" type))))
2283 (narrow-to-region (point) (point-max))
2284 (base64-decode-region (point-min) (point-max))
2285 (mm-decode-coding-region
2286 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2291 (defun article-decode-HZ ()
2292 "Translate a HZ-encoded article."
2296 (let ((buffer-read-only nil))
2297 (rfc1843-decode-region (point-min) (point-max)))))
2299 (defun article-unsplit-urls ()
2300 "Remove the newlines that some other mailers insert into URLs."
2303 (let ((buffer-read-only nil))
2304 (goto-char (point-min))
2305 (while (re-search-forward
2306 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2307 (replace-match "\\1\\3" t)))
2308 (when (and gnus-display-mime-function (interactive-p))
2309 (funcall gnus-display-mime-function))))
2312 (defun article-wash-html (&optional read-charset)
2313 "Format an HTML article.
2314 If READ-CHARSET, ask for a coding system."
2317 (let ((buffer-read-only nil)
2319 (when (gnus-buffer-live-p gnus-original-article-buffer)
2320 (with-current-buffer gnus-original-article-buffer
2321 (let* ((ct (gnus-fetch-field "content-type"))
2324 (mail-header-parse-content-type ct)))))
2325 (setq charset (and ctl
2326 (mail-content-type-get ctl 'charset)))
2327 (when (stringp charset)
2328 (setq charset (intern (downcase charset)))))))
2330 (setq charset (mm-read-coding-system "Charset: " charset)))
2332 (setq charset gnus-newsgroup-charset))
2334 (save-window-excursion
2336 (narrow-to-region (point) (point-max))
2337 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2338 (entry (assq func mm-text-html-washer-alist)))
2340 (setq func (cdr entry)))
2342 ((gnus-functionp func)
2345 (apply (car func) (cdr func))))))))))
2347 (defun gnus-article-wash-html-with-w3 ()
2348 "Wash the current buffer with w3."
2350 (let ((w3-strict-width (window-width))
2351 (url-standalone-mode t)
2352 (url-gateway-unplugged t)
2353 (w3-honor-stylesheets nil))
2355 (w3-region (point-min) (point-max))
2358 (defun gnus-article-wash-html-with-w3m ()
2359 "Wash the current buffer with emacs-w3m."
2362 (narrow-to-region (point) (point-max))
2363 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2366 (w3m-display-inline-images mm-inline-text-html-with-images)
2367 w3m-force-redisplay)
2368 (w3m-region (point-min) (point-max)))
2369 (when mm-inline-text-html-with-w3m-keymap
2370 (add-text-properties
2371 (point-min) (point-max)
2372 (nconc (mm-w3m-local-map-property)
2373 '(mm-inline-text-html-with-w3m t))))))
2375 (defun article-hide-list-identifiers ()
2376 "Remove list identifies from the Subject header.
2377 The `gnus-list-identifiers' variable specifies what to do."
2379 (let ((inhibit-point-motion-hooks t)
2380 (regexp (if (consp gnus-list-identifiers)
2381 (mapconcat 'identity gnus-list-identifiers " *\\|")
2382 gnus-list-identifiers))
2387 (article-narrow-to-head)
2388 (goto-char (point-min))
2389 (while (re-search-forward
2390 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2392 (delete-region (match-beginning 2) (match-end 0))
2393 (beginning-of-line))
2394 (when (re-search-forward
2395 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2396 (delete-region (match-beginning 1) (match-end 1))))))))
2398 (defun article-hide-pgp ()
2399 "Remove any PGP headers and signatures in the current article."
2403 (let ((inhibit-point-motion-hooks t)
2404 buffer-read-only beg end)
2406 ;; Hide the "header".
2407 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2408 (gnus-add-wash-type 'pgp)
2409 (delete-region (match-beginning 0) (match-end 0))
2410 ;; Remove armor headers (rfc2440 6.2)
2411 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2414 ;; Hide the actual signature.
2415 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2416 (setq end (1+ (match-beginning 0)))
2419 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2421 ;; Perhaps we shouldn't hide to the end of the buffer
2422 ;; if there is no end to the signature?
2424 ;; Hide "- " PGP quotation markers.
2426 (narrow-to-region beg end)
2427 (goto-char (point-min))
2428 (while (re-search-forward "^- " nil t)
2430 (match-beginning 0) (match-end 0)))
2432 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2434 (defun article-hide-pem (&optional arg)
2435 "Toggle hiding of any PEM headers and signatures in the current article.
2436 If given a negative prefix, always show; if given a positive prefix,
2438 (interactive (gnus-article-hidden-arg))
2439 (unless (gnus-article-check-hidden-text 'pem arg)
2441 (let (buffer-read-only end)
2442 (goto-char (point-min))
2443 ;; Hide the horrendously ugly "header".
2444 (when (and (search-forward
2445 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2447 (setq end (1+ (match-beginning 0))))
2448 (gnus-add-wash-type 'pem)
2449 (gnus-article-hide-text-type
2451 (if (search-forward "\n\n" nil t)
2455 ;; Hide the trailer as well
2456 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2458 (gnus-article-hide-text-type
2459 (match-beginning 0) (match-end 0) 'pem)))))))
2461 (defun article-strip-banner ()
2462 "Strip the banner specified by the `banner' group parameter."
2466 (let ((inhibit-point-motion-hooks t)
2467 (banner (gnus-parameter-banner gnus-newsgroup-name))
2468 (gnus-signature-limit nil)
2469 buffer-read-only beg end)
2470 (when (and gnus-article-address-banner-alist
2473 (let ((from (save-restriction
2475 (article-narrow-to-head)
2476 (mail-fetch-field "from"))))
2479 (caar (mail-header-parse-addresses from))))
2481 (dolist (pair gnus-article-address-banner-alist)
2482 (when (string-match (car pair) from)
2483 (throw 'found (cdr pair)))))))))
2487 ((eq banner 'signature)
2488 (when (gnus-article-narrow-to-signature)
2491 (delete-region (point) (point-max))))
2493 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2494 (while (re-search-forward banner nil t)
2495 (delete-region (match-beginning 0) (match-end 0)))))
2497 (while (re-search-forward banner nil t)
2498 (delete-region (match-beginning 0) (match-end 0))))))))))
2500 (defun article-babel ()
2501 "Translate article using an online translation service."
2505 (set-buffer gnus-article-buffer)
2506 (when (article-goto-body)
2507 (let* ((buffer-read-only nil)
2510 (orig (buffer-substring start end))
2511 (trans (babel-as-string orig)))
2513 (narrow-to-region start end)
2514 (delete-region start end)
2517 (defun article-hide-signature (&optional arg)
2518 "Hide the signature in the current article.
2519 If given a negative prefix, always show; if given a positive prefix,
2521 (interactive (gnus-article-hidden-arg))
2527 (article-goto-body))
2528 (goto-char (point-min)))
2529 (unless (gnus-article-check-hidden-text 'signature arg)
2530 (let ((buffer-read-only nil)
2532 (while (setq button (text-property-any button (point-max)
2534 'gnus-signature-toggle))
2535 (setq button (text-property-not-all button (point-max)
2537 'gnus-signature-toggle))
2538 (when (and button (not (eobp)))
2539 (gnus-article-hide-text-type
2541 (next-single-property-change (1+ button) 'mime-view-entity
2544 (gnus-set-mode-line 'article))
2546 (defun article-strip-headers-in-body ()
2547 "Strip offensive headers from bodies."
2551 (let ((case-fold-search t))
2552 (when (looking-at "x-no-archive:")
2553 (gnus-delete-line)))))
2555 (defun article-strip-leading-blank-lines ()
2556 "Remove all blank lines from the beginning of the article."
2559 (let ((inhibit-point-motion-hooks t)
2561 (when (article-goto-body)
2562 (while (and (not (eobp))
2563 (looking-at "[ \t]*$"))
2564 (gnus-delete-line))))))
2566 (defun article-narrow-to-head ()
2567 "Narrow the buffer to the head of the message.
2568 Point is left at the beginning of the narrowed-to region."
2570 (goto-char (point-min))
2571 (if (search-forward "\n\n" nil 1)
2574 (goto-char (point-min)))
2576 (defun article-goto-body ()
2577 "Place point at the start of the body."
2578 (goto-char (point-min))
2580 ;; This variable is only bound when dealing with separate
2582 (article-goto-body-goes-to-point-min-p
2584 ((search-forward "\n\n" nil t)
2587 (goto-char (point-max))
2590 (defun article-strip-multiple-blank-lines ()
2591 "Replace consecutive blank lines with one empty line."
2594 (let ((inhibit-point-motion-hooks t)
2596 ;; First make all blank lines empty.
2598 (while (re-search-forward "^[ \t]+$" nil t)
2599 (unless (gnus-annotation-in-region-p
2600 (match-beginning 0) (match-end 0))
2601 (replace-match "" nil t)))
2602 ;; Then replace multiple empty lines with a single empty line.
2604 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2605 (unless (gnus-annotation-in-region-p
2606 (match-beginning 0) (match-end 0))
2607 (delete-region (match-beginning 1) (match-end 1)))))))
2609 (defun article-strip-leading-space ()
2610 "Remove all white space from the beginning of the lines in the article."
2613 (let ((inhibit-point-motion-hooks t)
2616 (while (re-search-forward "^[ \t]+" nil t)
2617 (replace-match "" t t)))))
2619 (defun article-strip-trailing-space ()
2620 "Remove all white space from the end of the lines in the article."
2623 (let ((inhibit-point-motion-hooks t)
2626 (while (re-search-forward "[ \t]+$" nil t)
2627 (replace-match "" t t)))))
2629 (defun article-strip-blank-lines ()
2630 "Strip leading, trailing and multiple blank lines."
2632 (article-strip-leading-blank-lines)
2633 (article-remove-trailing-blank-lines)
2634 (article-strip-multiple-blank-lines))
2636 (defun article-strip-all-blank-lines ()
2637 "Strip all blank lines."
2640 (let ((inhibit-point-motion-hooks t)
2643 (while (re-search-forward "^[ \t]*\n" nil t)
2644 (replace-match "" t t)))))
2646 (defun gnus-article-narrow-to-signature ()
2647 "Narrow to the signature; return t if a signature is found, else nil."
2648 (let ((inhibit-point-motion-hooks t))
2649 (when (gnus-article-search-signature)
2651 ;; Check whether we have some limits to what we consider
2652 ;; to be a signature.
2653 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2654 (list gnus-signature-limit)))
2656 (while (setq limit (pop limits))
2657 (if (or (and (integerp limit)
2658 (< (- (point-max) (point)) limit))
2660 (< (count-lines (point) (point-max)) limit))
2661 (and (gnus-functionp limit)
2663 (and (stringp limit)
2664 (not (re-search-forward limit nil t))))
2665 () ; This limit did not succeed.
2669 (narrow-to-region (point) (point-max))
2672 (defun gnus-article-search-signature ()
2673 "Search the current buffer for the signature separator.
2674 Put point at the beginning of the signature separator."
2675 (let ((cur (point)))
2676 (goto-char (point-max))
2677 (if (if (stringp gnus-signature-separator)
2678 (re-search-backward gnus-signature-separator nil t)
2679 (let ((seps gnus-signature-separator))
2681 (not (re-search-backward (car seps) nil t)))
2688 (defun gnus-article-hidden-arg ()
2689 "Return the current prefix arg as a number, or 0 if no prefix."
2690 (list (if current-prefix-arg
2691 (prefix-numeric-value current-prefix-arg)
2694 (defun gnus-article-check-hidden-text (type arg)
2695 "Return nil if hiding is necessary.
2696 Arg can be nil or a number. nil and positive means hide, negative
2697 means show, 0 means toggle."
2700 (let ((hide (gnus-article-hidden-text-p type)))
2706 (gnus-article-show-hidden-text type)
2709 (if (eq hide 'hidden)
2711 (gnus-article-show-hidden-text type)
2715 (defun gnus-article-hidden-text-p (type)
2716 "Say whether the current buffer contains hidden text of type TYPE."
2717 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2719 (not (get-text-property pos 'invisible))
2720 (not (get-text-property pos 'dummy-invisible)))
2722 (text-property-any (1+ pos) (point-max) 'article-type type)))
2727 (defun gnus-article-show-hidden-text (type &optional dummy)
2728 "Show all hidden text of type TYPE.
2729 Originally it is hide instead of DUMMY."
2730 (let ((buffer-read-only nil)
2731 (inhibit-point-motion-hooks t))
2732 (gnus-remove-text-properties-when
2734 (point-min) (point-max)
2735 (cons 'article-type (cons type
2736 gnus-hidden-properties)))
2737 (gnus-delete-wash-type type)))
2739 (defconst article-time-units
2740 `((year . ,(* 365.25 24 60 60))
2741 (week . ,(* 7 24 60 60))
2742 (day . ,(* 24 60 60))
2746 "Mapping from time units to seconds.")
2748 (defun gnus-article-forward-header ()
2749 "Move point to the start of the next header.
2750 If the current header is a continuation header, this can be several
2755 (if (looking-at "[ \t]+[^ \t]")
2759 (defun article-date-ut (&optional type highlight header)
2760 "Convert DATE date to universal time in the current article.
2761 If TYPE is `local', convert to local time; if it is `lapsed', output
2762 how much time has lapsed since DATE. For `lapsed', the value of
2763 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2764 should replace the \"Date:\" one, or should be added below it."
2765 (interactive (list 'ut t))
2766 (let* ((header (or header
2767 (and (eq 1 (point-min))
2768 (mail-header-date (save-excursion
2769 (set-buffer gnus-summary-buffer)
2770 gnus-current-headers)))
2771 (message-fetch-field "date")
2773 (date (if (vectorp header) (mail-header-date header)
2775 (inhibit-point-motion-hooks t)
2776 bface eface date-pos)
2777 (when (and date (not (string= date "")))
2780 (article-narrow-to-head)
2781 (when (or (and (eq type 'lapsed)
2782 gnus-article-date-lapsed-new-header
2783 ;; Attempt to get the face of X-Sent first.
2784 (re-search-forward "^X-Sent:[ \t]" nil t))
2785 (re-search-forward "^Date:[ \t]" nil t)
2786 ;; If Date is missing, try again for X-Sent.
2787 (re-search-forward "^X-Sent:[ \t]" nil t))
2788 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2789 date (or (get-text-property (gnus-point-at-bol)
2792 eface (get-text-property (1- (gnus-point-at-eol))
2794 (let ((buffer-read-only nil))
2795 ;; Delete any old X-Sent headers.
2796 (when (setq date-pos
2797 (text-property-any (point-min) (point-max)
2798 'article-date-lapsed t))
2799 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2800 (delete-region (match-beginning 0)
2801 (progn (forward-line 1) (point))))
2802 (goto-char (point-min))
2803 ;; Delete any old Date headers.
2804 (while (re-search-forward "^Date:[ \t]" nil t)
2806 (setq date-pos (match-beginning 0)))
2807 (unless (and (eq type 'lapsed)
2808 gnus-article-date-lapsed-new-header)
2809 (delete-region (match-beginning 0)
2810 (progn (message-next-header) (point)))))
2813 (goto-char date-pos)
2815 ;; Possibly, Date has been deleted.
2817 (when (and (eq type 'lapsed)
2818 gnus-article-date-lapsed-new-header
2819 (looking-at "Date:"))
2821 (goto-char (point-min)))
2822 (insert (article-make-date-line date type))
2823 (when (eq type 'lapsed)
2824 (put-text-property (gnus-point-at-bol) (point)
2825 'article-date-lapsed t))
2829 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2830 (put-text-property (match-beginning 1) (1+ (match-end 1))
2831 'original-date date)
2832 (put-text-property (match-beginning 1) (1+ (match-end 1))
2834 (put-text-property (match-beginning 2) (match-end 2)
2837 (defun article-make-date-line (date type)
2838 "Return a DATE line of TYPE."
2839 (unless (memq type '(local ut original user iso8601 lapsed english))
2840 (error "Unknown conversion type: %s" type))
2842 (let ((time (date-to-time date)))
2844 ;; Convert to the local timezone.
2846 (let ((tz (car (current-time-zone time))))
2847 (format "Date: %s %s%02d%02d" (current-time-string time)
2848 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2849 (/ (% (abs tz) 3600) 60))))
2850 ;; Convert to Universal Time.
2853 (current-time-string
2854 (let* ((e (parse-time-string date))
2855 (tm (apply 'encode-time e))
2857 (ls (- (cadr tm) (car (current-time-zone time)))))
2858 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2859 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2862 ;; Get the original date from the article.
2863 ((eq type 'original)
2864 (concat "Date: " (if (string-match "\n+$" date)
2865 (substring date 0 (match-beginning 0))
2867 ;; Let the user define the format.
2869 (let ((format (or (condition-case nil
2870 (with-current-buffer gnus-summary-buffer
2871 gnus-article-time-format)
2873 gnus-article-time-format)))
2874 (if (gnus-functionp format)
2875 (funcall format time)
2876 (concat "Date: " (format-time-string format time)))))
2879 (let ((tz (car (current-time-zone time))))
2882 (format-time-string "%Y%m%dT%H%M%S" time)
2883 (format "%s%02d%02d"
2884 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2885 (/ (% (abs tz) 3600) 60)))))
2886 ;; Do an X-Sent lapsed format.
2888 ;; If the date is seriously mangled, the timezone functions are
2889 ;; liable to bug out, so we ignore all errors.
2890 (let* ((now (current-time))
2891 (real-time (subtract-time now time))
2892 (real-sec (and real-time
2893 (+ (* (float (car real-time)) 65536)
2895 (sec (and real-time (abs real-sec)))
2905 ;; This is a bit convoluted, but basically we go
2906 ;; through the time units for years, weeks, etc,
2907 ;; and divide things to see whether that results
2908 ;; in positive answers.
2911 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2912 ;; The (remaining) seconds are too few to
2913 ;; be divided into this time unit.
2915 ;; It's big enough, so we output it.
2916 (setq sec (- sec (* num (cdr unit))))
2918 (concat (if prev ", " "") (int-to-string
2920 " " (symbol-name (car unit))
2921 (if (> num 1) "s" ""))
2923 article-time-units "")
2924 ;; If dates are odd, then it might appear like the
2925 ;; article was sent in the future.
2928 " in the future"))))))
2929 ;; Display the date in proper English
2931 (let ((dtime (decode-time time)))
2934 (number-to-string (nth 3 dtime))
2935 (let ((digit (% (nth 3 dtime) 10)))
2937 ((memq (nth 3 dtime) '(11 12 13)) "th")
2943 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2945 (number-to-string (nth 5 dtime))
2947 (format "%02d" (nth 2 dtime))
2949 (format "%02d" (nth 1 dtime)))))))
2951 (format "Date: %s (from T-gnus)" date))))
2953 (defun article-date-local (&optional highlight)
2954 "Convert the current article date to the local timezone."
2955 (interactive (list t))
2956 (article-date-ut 'local highlight))
2958 (defun article-date-english (&optional highlight)
2959 "Convert the current article date to something that is proper English."
2960 (interactive (list t))
2961 (article-date-ut 'english highlight))
2963 (defun article-date-original (&optional highlight)
2964 "Convert the current article date to what it was originally.
2965 This is only useful if you have used some other date conversion
2966 function and want to see what the date was before converting."
2967 (interactive (list t))
2968 (article-date-ut 'original highlight))
2970 (defun article-date-lapsed (&optional highlight)
2971 "Convert the current article date to time lapsed since it was sent."
2972 (interactive (list t))
2973 (article-date-ut 'lapsed highlight))
2975 (defun article-update-date-lapsed ()
2976 "Function to be run from a timer to update the lapsed time line."
2977 (let (deactivate-mark)
2982 (set-buffer (window-buffer w))
2983 (when (eq major-mode 'gnus-article-mode)
2984 (goto-char (point-min))
2985 (when (re-search-forward "^X-Sent:" nil t)
2986 (article-date-lapsed t))))
2989 (defun gnus-start-date-timer (&optional n)
2990 "Start a timer to update the X-Sent header in the article buffers.
2991 The numerical prefix says how frequently (in seconds) the function
2996 (gnus-stop-date-timer)
2997 (setq article-lapsed-timer
2998 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
3000 (defun gnus-stop-date-timer ()
3001 "Stop the X-Sent timer."
3003 (when article-lapsed-timer
3004 (nnheader-cancel-timer article-lapsed-timer)
3005 (setq article-lapsed-timer nil)))
3007 (defun article-date-user (&optional highlight)
3008 "Convert the current article date to the user-defined format.
3009 This format is defined by the `gnus-article-time-format' variable."
3010 (interactive (list t))
3011 (article-date-ut 'user highlight))
3013 (defun article-date-iso8601 (&optional highlight)
3014 "Convert the current article date to ISO8601."
3015 (interactive (list t))
3016 (article-date-ut 'iso8601 highlight))
3018 ;; (defun article-show-all ()
3019 ;; "Show all hidden text in the article buffer."
3023 ;; (let ((buffer-read-only nil))
3024 ;; (gnus-article-unhide-text (point-min) (point-max))
3025 ;; (gnus-remove-text-with-property 'gnus-prev)
3026 ;; (gnus-remove-text-with-property 'gnus-next))))
3028 (defun article-show-all-headers ()
3029 "Show all hidden headers in the article buffer."
3034 (article-narrow-to-head)
3035 (let ((buffer-read-only nil))
3036 (gnus-article-unhide-text (point-min) (point-max))))))
3038 (defun article-remove-leading-whitespace ()
3039 "Remove excessive whitespace from all headers."
3043 (let ((buffer-read-only nil))
3044 (article-narrow-to-head)
3045 (goto-char (point-min))
3046 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3047 (delete-region (match-beginning 1) (match-end 1)))))))
3049 (defun article-emphasize (&optional arg)
3050 "Emphasize text according to `gnus-emphasis-alist'."
3051 (interactive (gnus-article-hidden-arg))
3052 (unless (gnus-article-check-hidden-text 'emphasis arg)
3056 (with-current-buffer gnus-summary-buffer
3057 gnus-article-emphasis-alist)
3059 gnus-emphasis-alist))
3060 (buffer-read-only nil)
3061 (props (append '(article-type emphasis)
3062 gnus-hidden-properties))
3063 regexp elem beg invisible visible face)
3066 (while (setq elem (pop alist))
3068 (setq regexp (car elem)
3069 invisible (nth 1 elem)
3070 visible (nth 2 elem)
3072 (while (re-search-forward regexp nil t)
3073 (when (and (match-beginning visible) (match-beginning invisible))
3074 (gnus-article-hide-text
3075 (match-beginning invisible) (match-end invisible) props)
3076 (gnus-article-unhide-text-type
3077 (match-beginning visible) (match-end visible) 'emphasis)
3078 (gnus-put-overlay-excluding-newlines
3079 (match-beginning visible) (match-end visible) 'face face)
3080 (gnus-add-wash-type 'emphasis)
3081 (goto-char (match-end invisible)))))))))
3083 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3084 "Setup newsgroup emphasis alist."
3085 (unless gnus-article-emphasis-alist
3086 (let ((name (and gnus-newsgroup-name
3087 (gnus-group-real-name gnus-newsgroup-name))))
3088 (make-local-variable 'gnus-article-emphasis-alist)
3089 (setq gnus-article-emphasis-alist
3091 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3092 (while (setq elem (pop alist))
3093 (when (and name (string-match (car elem) name))
3095 highlight (copy-sequence (cdr elem)))))
3097 (copy-sequence highlight-words)
3098 (if gnus-newsgroup-name
3099 (copy-sequence (gnus-group-find-parameter
3100 gnus-newsgroup-name 'highlight-words t)))
3101 gnus-emphasis-alist)))))
3104 (defvar gnus-summary-article-menu)
3105 (defvar gnus-summary-post-menu))
3107 ;;; Saving functions.
3109 (defun gnus-article-save (save-buffer file &optional num)
3110 "Save the currently selected article."
3111 (unless gnus-save-all-headers
3112 ;; Remove headers according to `gnus-saved-headers'.
3113 (let ((gnus-visible-headers
3114 (or gnus-saved-headers gnus-visible-headers))
3115 (gnus-article-buffer save-buffer))
3117 (set-buffer save-buffer)
3118 (article-hide-headers 1 t))))
3119 (save-window-excursion
3120 (if (not gnus-default-article-saver)
3121 (error "No default saver is defined")
3122 ;; !!! Magic! The saving functions all save
3123 ;; `gnus-save-article-buffer' (or so they think), but we
3124 ;; bind that variable to our save-buffer.
3125 (set-buffer gnus-article-buffer)
3126 (let* ((gnus-save-article-buffer save-buffer)
3129 ((not gnus-prompt-before-saving) 'default)
3130 ((eq gnus-prompt-before-saving 'always) nil)
3132 (gnus-number-of-articles-to-be-saved
3133 (when (eq gnus-prompt-before-saving t)
3135 (set-buffer gnus-article-current-summary)
3136 (funcall gnus-default-article-saver filename)))))
3138 (defun gnus-read-save-file-name (prompt &optional filename
3139 function group headers variable)
3141 (funcall function group headers (symbol-value variable)))
3146 ((eq filename 'default)
3152 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3155 (if (and gnus-number-of-articles-to-be-saved
3156 (> gnus-number-of-articles-to-be-saved 1))
3157 (format "these %d articles"
3158 gnus-number-of-articles-to-be-saved)
3161 ;; Let the split methods have their say.
3163 ;; No split name was found.
3166 (concat prompt " (default "
3167 (file-name-nondirectory default-name) ") ")
3168 (file-name-directory default-name)
3170 ;; A single group name is returned.
3171 ((stringp split-name)
3173 (funcall function split-name headers
3174 (symbol-value variable)))
3176 (concat prompt " (default "
3177 (file-name-nondirectory default-name) ") ")
3178 (file-name-directory default-name)
3180 ;; A single split name was found
3181 ((= 1 (length split-name))
3182 (let* ((name (expand-file-name
3184 gnus-article-save-directory))
3185 (dir (cond ((file-directory-p name)
3186 (file-name-as-directory name))
3187 ((file-exists-p name) name)
3188 (t gnus-article-save-directory))))
3190 (concat prompt " (default " name ") ")
3192 ;; A list of splits was found.
3194 (setq split-name (nreverse split-name))
3196 (let ((file-name-history
3197 (nconc split-name file-name-history)))
3201 (concat prompt " (`M-p' for defaults) ")
3202 gnus-article-save-directory
3204 gnus-article-save-directory)))
3205 (car (push result file-name-history)))))))
3206 ;; Create the directory.
3207 (gnus-make-directory (file-name-directory file))
3208 ;; If we have read a directory, we append the default file name.
3209 (when (file-directory-p file)
3210 (setq file (expand-file-name (file-name-nondirectory
3212 (file-name-as-directory file))))
3213 ;; Possibly translate some characters.
3214 (nnheader-translate-file-chars file))))))
3215 (gnus-make-directory (file-name-directory result))
3216 (set variable result)))
3218 (defun gnus-article-archive-name (group)
3219 "Return the first instance of an \"Archive-name\" in the current buffer."
3220 (let ((case-fold-search t))
3221 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3222 (nnheader-concat gnus-article-save-directory
3223 (match-string 1)))))
3225 (defun gnus-article-nndoc-name (group)
3226 "If GROUP is an nndoc group, return the name of the parent group."
3227 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3228 (gnus-group-get-parameter group 'save-article-group)))
3230 (defun gnus-summary-save-in-rmail (&optional filename)
3231 "Append this article to Rmail file.
3232 Optional argument FILENAME specifies file name.
3233 Directory to save to is default to `gnus-article-save-directory'."
3234 (setq filename (gnus-read-save-file-name
3235 "Save %s in rmail file:" filename
3236 gnus-rmail-save-name gnus-newsgroup-name
3237 gnus-current-headers 'gnus-newsgroup-last-rmail))
3238 (gnus-eval-in-buffer-window gnus-save-article-buffer
3242 (gnus-output-to-rmail filename))))
3245 (defun gnus-summary-save-in-mail (&optional filename)
3246 "Append this article to Unix mail file.
3247 Optional argument FILENAME specifies file name.
3248 Directory to save to is default to `gnus-article-save-directory'."
3249 (setq filename (gnus-read-save-file-name
3250 "Save %s in Unix mail file:" filename
3251 gnus-mail-save-name gnus-newsgroup-name
3252 gnus-current-headers 'gnus-newsgroup-last-mail))
3253 (gnus-eval-in-buffer-window gnus-save-article-buffer
3257 (if (and (file-readable-p filename)
3258 (mail-file-babyl-p filename))
3259 (rmail-output-to-rmail-file filename t)
3260 (gnus-output-to-mail filename)))))
3263 (defun gnus-summary-save-in-file (&optional filename overwrite)
3264 "Append this article to file.
3265 Optional argument FILENAME specifies file name.
3266 Directory to save to is default to `gnus-article-save-directory'."
3267 (setq filename (gnus-read-save-file-name
3268 "Save %s in file:" filename
3269 gnus-file-save-name gnus-newsgroup-name
3270 gnus-current-headers 'gnus-newsgroup-last-file))
3271 (gnus-eval-in-buffer-window gnus-save-article-buffer
3275 (when (and overwrite
3276 (file-exists-p filename))
3277 (delete-file filename))
3278 (gnus-output-to-file filename))))
3281 (defun gnus-summary-write-to-file (&optional filename)
3282 "Write this article to a file, overwriting it if the file exists.
3283 Optional argument FILENAME specifies file name.
3284 The directory to save in defaults to `gnus-article-save-directory'."
3285 (gnus-summary-save-in-file nil t))
3287 (defun gnus-summary-save-body-in-file (&optional filename)
3288 "Append this article body to a file.
3289 Optional argument FILENAME specifies file name.
3290 The directory to save in defaults to `gnus-article-save-directory'."
3291 (setq filename (gnus-read-save-file-name
3292 "Save %s body in file:" filename
3293 gnus-file-save-name gnus-newsgroup-name
3294 gnus-current-headers 'gnus-newsgroup-last-file))
3295 (gnus-eval-in-buffer-window gnus-save-article-buffer
3299 (when (article-goto-body)
3300 (narrow-to-region (point) (point-max)))
3301 (gnus-output-to-file filename))))
3304 (defun gnus-summary-save-in-pipe (&optional command)
3305 "Pipe this article to subprocess."
3307 (cond ((and (eq command 'default)
3308 gnus-last-shell-command)
3309 gnus-last-shell-command)
3314 "Shell command on %s: "
3315 (if (and gnus-number-of-articles-to-be-saved
3316 (> gnus-number-of-articles-to-be-saved 1))
3317 (format "these %d articles"
3318 gnus-number-of-articles-to-be-saved)
3320 gnus-last-shell-command))))
3321 (when (string-equal command "")
3322 (if gnus-last-shell-command
3323 (setq command gnus-last-shell-command)
3324 (error "A command is required")))
3325 (gnus-eval-in-buffer-window gnus-article-buffer
3328 (shell-command-on-region (point-min) (point-max) command nil)))
3329 (setq gnus-last-shell-command command))
3331 (defun gnus-summary-pipe-to-muttprint (&optional command)
3332 "Pipe this article to muttprint."
3333 (setq command (read-string
3334 "Print using command: " gnus-summary-muttprint-program
3335 nil gnus-summary-muttprint-program))
3336 (gnus-summary-save-in-pipe command))
3338 ;;; Article file names when saving.
3340 (defun gnus-capitalize-newsgroup (newsgroup)
3341 "Capitalize NEWSGROUP name."
3342 (when (not (zerop (length newsgroup)))
3343 (concat (char-to-string (upcase (aref newsgroup 0)))
3344 (substring newsgroup 1))))
3346 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3347 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3348 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3349 Otherwise, it is like ~/News/news/group/num."
3352 (concat (if (gnus-use-long-file-name 'not-save)
3353 (gnus-capitalize-newsgroup newsgroup)
3354 (gnus-newsgroup-directory-form newsgroup))
3355 "/" (int-to-string (mail-header-number headers)))
3356 gnus-article-save-directory)))
3358 (string-equal (file-name-directory default)
3359 (file-name-directory last-file))
3360 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3362 (or last-file default))))
3364 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3365 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3366 If variable `gnus-use-long-file-name' is non-nil, it is
3367 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3370 (concat (if (gnus-use-long-file-name 'not-save)
3372 (gnus-newsgroup-directory-form newsgroup))
3373 "/" (int-to-string (mail-header-number headers)))
3374 gnus-article-save-directory)))
3376 (string-equal (file-name-directory default)
3377 (file-name-directory last-file))
3378 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3380 (or last-file default))))
3382 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3383 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3384 If variable `gnus-use-long-file-name' is non-nil, it is
3385 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3388 (if (gnus-use-long-file-name 'not-save)
3391 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3393 gnus-article-save-directory)))
3395 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3396 "Generate file name from sender."
3397 (let ((from (mail-header-from headers)))
3399 (if (and from (string-match "\\([^ <]+\\)@" from))
3400 (match-string 1 from)
3402 gnus-article-save-directory)))
3404 (defun article-verify-x-pgp-sig ()
3407 (if (gnus-buffer-live-p gnus-original-article-buffer)
3408 (let ((sig (with-current-buffer gnus-original-article-buffer
3409 (gnus-fetch-field "X-PGP-Sig")))
3413 (mml2015-clear-verify-function))
3415 (insert-buffer-substring gnus-original-article-buffer)
3416 (setq items (split-string sig))
3417 (message-narrow-to-head)
3418 (let ((inhibit-point-motion-hooks t)
3419 (case-fold-search t))
3420 ;; Don't verify multiple headers.
3421 (setq headers (mapconcat (lambda (header)
3423 (mail-fetch-field header) "\n"))
3424 (split-string (nth 1 items) ",") "")))
3425 (delete-region (point-min) (point-max))
3426 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3427 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3432 (if (looking-at "^-")
3435 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3436 (insert "Version: " (car items) "\n\n")
3437 (insert (mapconcat 'identity (cddr items) "\n"))
3438 (insert "\n-----END PGP SIGNATURE-----\n")
3439 (let ((mm-security-handle (list (format "multipart/signed"))))
3440 (mml2015-clean-buffer)
3441 (let ((coding-system-for-write (or gnus-newsgroup-charset
3443 (funcall (mml2015-clear-verify-function)))
3445 (or (mm-handle-multipart-ctl-parameter
3446 mm-security-handle 'gnus-details)
3447 (mm-handle-multipart-ctl-parameter
3448 mm-security-handle 'gnus-info)))))
3450 (let (buffer-read-only bface eface)
3452 (message-narrow-to-head)
3453 (goto-char (point-max))
3455 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3456 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3457 (message-remove-header "X-Gnus-PGP-Verify")
3458 (if (re-search-forward "^X-PGP-Sig:" nil t)
3460 (goto-char (point-max)))
3461 (narrow-to-region (point) (point))
3462 (insert "X-Gnus-PGP-Verify: " info "\n")
3463 (goto-char (point-min))
3466 (if (not (looking-at "^[ \t]"))
3470 (goto-char (point-min))
3471 (when (looking-at "\\([^:]+\\): *")
3472 (put-text-property (match-beginning 1) (1+ (match-end 1))
3474 (put-text-property (match-end 0) (point-max)
3475 'face eface)))))))))
3477 (defun article-verify-cancel-lock ()
3478 "Verify Cancel-Lock header."
3480 (if (gnus-buffer-live-p gnus-original-article-buffer)
3481 (canlock-verify gnus-original-article-buffer)))
3483 (defun article-monafy ()
3484 "Display body part with mona font."
3486 (unless (if (featurep 'xemacs)
3487 (find-face 'gnus-mona-face)
3488 (facep 'gnus-mona-face))
3489 (require 'navi2ch-mona)
3490 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3492 (let ((buffer-read-only nil))
3495 (gnus-make-overlay (point) (point-max))
3496 'face 'gnus-mona-face))))
3503 (setq afunc (car func)
3506 gfunc (intern (format "gnus-%s" func))))
3508 (when (fboundp afunc)
3509 `(lambda (&optional interactive &rest args)
3510 ,(documentation afunc t)
3511 (interactive (list t))
3513 (set-buffer gnus-article-buffer)
3515 (call-interactively ',afunc)
3516 (apply ',afunc args))))))))
3517 '(article-hide-headers
3518 article-verify-x-pgp-sig
3519 article-verify-cancel-lock
3521 article-hide-boring-headers
3522 article-treat-overstrike
3523 article-fill-long-lines
3524 article-capitalize-sentences
3526 article-remove-leading-whitespace
3527 article-display-x-face
3528 article-de-quoted-unreadable
3529 article-de-base64-unreadable
3532 article-unsplit-urls
3533 article-hide-list-identifiers
3535 article-strip-banner
3538 article-hide-signature
3539 article-strip-headers-in-body
3540 article-remove-trailing-blank-lines
3541 article-strip-leading-blank-lines
3542 article-strip-multiple-blank-lines
3543 article-strip-leading-space
3544 article-strip-trailing-space
3545 article-strip-blank-lines
3546 article-strip-all-blank-lines
3548 article-date-english
3549 article-date-iso8601
3550 article-date-original
3552 article-decode-mime-words
3553 article-decode-charset
3554 article-decode-encoded-words
3558 article-treat-dumbquotes
3559 article-normalize-headers
3560 (article-show-all-headers . gnus-article-show-all-headers)
3561 ;; (article-show-all . gnus-article-show-all)
3565 ;;; Gnus article mode
3568 (put 'gnus-article-mode 'mode-class 'special)
3570 (gnus-define-keys gnus-article-mode-map
3571 " " gnus-article-goto-next-page
3572 "\177" gnus-article-goto-prev-page
3573 [delete] gnus-article-goto-prev-page
3574 [backspace] gnus-article-goto-prev-page
3575 "\C-c^" gnus-article-refer-article
3576 "h" gnus-article-show-summary
3577 "s" gnus-article-show-summary
3578 "\C-c\C-m" gnus-article-mail
3579 "?" gnus-article-describe-briefly
3580 "e" gnus-summary-edit-article
3581 "<" beginning-of-buffer
3583 "\C-c\C-i" gnus-info-find-node
3585 "R" gnus-article-reply-with-original
3586 "F" gnus-article-followup-with-original
3587 "\C-hk" gnus-article-describe-key
3588 "\C-hc" gnus-article-describe-key-briefly
3590 "\C-d" gnus-article-read-summary-keys
3591 "\M-*" gnus-article-read-summary-keys
3592 "\M-#" gnus-article-read-summary-keys
3593 "\M-^" gnus-article-read-summary-keys
3594 "\M-g" gnus-article-read-summary-keys)
3596 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3600 (push (char-to-string key) keys)
3602 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3603 (setq key (car elem))
3604 (when (and (> (length key) 0)
3605 (not (eq 'menu-bar (aref key 0)))
3606 (symbolp (lookup-key gnus-summary-mode-map key)))
3609 (unless (lookup-key gnus-article-mode-map key)
3610 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3612 (defun gnus-article-make-menu-bar ()
3613 (unless (boundp 'gnus-article-commands-menu)
3614 (gnus-summary-make-menu-bar))
3615 (gnus-turn-off-edit-menu 'article)
3616 (unless (boundp 'gnus-article-article-menu)
3618 gnus-article-article-menu gnus-article-mode-map ""
3620 ["Scroll forwards" gnus-article-goto-next-page t]
3621 ["Scroll backwards" gnus-article-goto-prev-page t]
3622 ["Show summary" gnus-article-show-summary t]
3623 ["Fetch Message-ID at point" gnus-article-refer-article t]
3624 ["Mail to address at point" gnus-article-mail t]
3625 ["Send a bug report" gnus-bug t]))
3628 gnus-article-treatment-menu gnus-article-mode-map ""
3629 ;; Fixme: this should use :active (and maybe :visible).
3631 ["Hide headers" gnus-article-hide-headers t]
3632 ["Hide signature" gnus-article-hide-signature t]
3633 ["Hide citation" gnus-article-hide-citation t]
3634 ["Treat overstrike" gnus-article-treat-overstrike t]
3635 ["Remove carriage return" gnus-article-remove-cr t]
3636 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3637 ["Treat html" gnus-article-wash-html t]
3638 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3639 ["Decode HZ" gnus-article-decode-HZ t]))
3641 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3643 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3645 (gnus-run-hooks 'gnus-article-menu-hook)))
3647 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3650 (defun gnus-article-mode ()
3651 "Major mode for displaying an article.
3653 All normal editing commands are switched off.
3655 The following commands are available in addition to all summary mode
3657 \\<gnus-article-mode-map>
3658 \\[gnus-article-next-page]\t Scroll the article one page forwards
3659 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3660 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3661 \\[gnus-article-show-summary]\t Display the summary buffer
3662 \\[gnus-article-mail]\t Send a reply to the address near point
3663 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3664 \\[gnus-info-find-node]\t Go to the Gnus info node"
3666 (gnus-simplify-mode-line)
3667 (setq mode-name "Article")
3668 (setq major-mode 'gnus-article-mode)
3669 (make-local-variable 'minor-mode-alist)
3670 (unless (assq 'gnus-show-mime minor-mode-alist)
3671 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3672 (use-local-map gnus-article-mode-map)
3673 (when (gnus-visual-p 'article-menu 'menu)
3674 (gnus-article-make-menu-bar))
3675 (gnus-update-format-specifications nil 'article-mode)
3676 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3677 (make-local-variable 'gnus-page-broken)
3678 (make-local-variable 'gnus-button-marker-list)
3679 (make-local-variable 'gnus-article-current-summary)
3680 (make-local-variable 'gnus-article-mime-handles)
3681 (make-local-variable 'gnus-article-decoded-p)
3682 (make-local-variable 'gnus-article-mime-handle-alist)
3683 (make-local-variable 'gnus-article-wash-types)
3684 (make-local-variable 'gnus-article-image-alist)
3685 (make-local-variable 'gnus-article-charset)
3686 (make-local-variable 'gnus-article-ignored-charsets)
3687 (gnus-set-default-directory)
3688 (buffer-disable-undo)
3689 (setq buffer-read-only t)
3690 (set-syntax-table gnus-article-mode-syntax-table)
3691 (gnus-run-hooks 'gnus-article-mode-hook))
3693 (defun gnus-article-setup-buffer ()
3694 "Initialize the article buffer."
3695 (let* ((name (if gnus-single-article-buffer "*Article*"
3696 (concat "*Article " gnus-newsgroup-name "*")))
3698 (progn (string-match "\\*Article" name)
3699 (concat " *Original Article"
3700 (substring name (match-end 0))))))
3701 (setq gnus-article-buffer name)
3702 (setq gnus-original-article-buffer original)
3703 (setq gnus-article-mime-handle-alist nil)
3704 ;; This might be a variable local to the summary buffer.
3705 (unless gnus-single-article-buffer
3707 (set-buffer gnus-summary-buffer)
3708 (setq gnus-article-buffer name)
3709 (setq gnus-original-article-buffer original)
3710 (gnus-set-global-variables)))
3711 (gnus-article-setup-highlight-words)
3712 ;; Init original article buffer.
3714 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3715 (set-buffer-multibyte t)
3716 (setq major-mode 'gnus-original-article-mode)
3717 (make-local-variable 'gnus-original-article))
3718 (if (get-buffer name)
3721 (when (and gnus-article-edit-mode
3724 (y-or-n-p "Article mode edit in progress; discard? ")))
3725 (error "Action aborted"))
3726 (set (make-local-variable 'gnus-article-edit-mode) nil)
3727 (buffer-disable-undo)
3728 (setq buffer-read-only t)
3729 (unless (eq major-mode 'gnus-article-mode)
3730 (gnus-article-mode))
3733 (set-buffer (gnus-get-buffer-create name))
3735 (make-local-variable 'gnus-summary-buffer)
3736 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3737 (current-buffer)))))
3739 ;; Set article window start at LINE, where LINE is the number of lines
3740 ;; from the head of the article.
3741 (defun gnus-article-set-window-start (&optional line)
3743 (gnus-get-buffer-window gnus-article-buffer t)
3745 (set-buffer gnus-article-buffer)
3746 (goto-char (point-min))
3749 (gnus-message 6 "Moved to bookmark")
3750 (search-forward "\n\n" nil t)
3754 ;;; @@ article filters
3757 (defun gnus-article-display-mime-message ()
3758 "Article display method for MIME message."
3759 ;; called from `gnus-original-article-buffer'.
3760 (let (charset all-headers)
3761 (with-current-buffer gnus-summary-buffer
3762 (setq charset default-mime-charset
3763 all-headers gnus-have-all-headers))
3764 (make-local-variable 'default-mime-charset)
3765 (setq default-mime-charset charset)
3766 (with-current-buffer (get-buffer-create gnus-article-buffer)
3767 (make-local-variable 'default-mime-charset)
3768 (setq default-mime-charset charset))
3769 (mime-display-message mime-message-structure
3770 gnus-article-buffer nil gnus-article-mode-map)
3772 (gnus-article-hide-headers nil -1)))
3773 (run-hooks 'gnus-mime-article-prepare-hook))
3775 (defun gnus-article-display-traditional-message ()
3776 "Article display method for traditional message."
3777 (set-buffer gnus-article-buffer)
3778 (let (buffer-read-only)
3780 (insert-buffer-substring gnus-original-article-buffer)))
3782 (defun gnus-article-make-full-mail-header (&optional number charset)
3783 "Create a new mail header structure in a raw article buffer."
3784 (unless (and number charset)
3785 (save-current-buffer
3786 (set-buffer gnus-summary-buffer)
3788 (setq number (or (cdr gnus-article-current) 0)))
3790 (setq charset (or default-mime-charset 'x-ctext)))))
3791 (goto-char (point-min))
3792 (let ((header-end (if (search-forward "\n\n" nil t)
3794 (goto-char (point-max))))
3795 (chars (- (point-max) (point)))
3796 (lines (count-lines (point) (point-max)))
3797 (default-mime-charset charset)
3799 (narrow-to-region (point-min) header-end)
3800 (setq xref (std11-fetch-field "xref"))
3802 (make-full-mail-header
3804 (std11-fetch-field "subject")
3805 (std11-fetch-field "from")
3806 (std11-fetch-field "date")
3807 (std11-fetch-field "message-id")
3808 (std11-fetch-field "references")
3811 (when xref (concat "Xref: " xref)))
3814 (defun gnus-article-prepare (article &optional all-headers header)
3815 "Prepare ARTICLE in article mode buffer.
3816 ARTICLE should either be an article number or a Message-ID.
3817 If ARTICLE is an id, HEADER should be the article headers.
3818 If ALL-HEADERS is non-nil, no headers are hidden."
3820 ;; Make sure we start in a summary buffer.
3821 (unless (eq major-mode 'gnus-summary-mode)
3822 (set-buffer gnus-summary-buffer))
3823 (setq gnus-summary-buffer (current-buffer))
3824 (let* ((gnus-article (if header (mail-header-number header) article))
3825 (summary-buffer (current-buffer))
3826 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3827 (group gnus-newsgroup-name)
3830 (gnus-article-setup-buffer)
3831 (set-buffer gnus-article-buffer)
3832 ;; Deactivate active regions.
3833 (when (and (boundp 'transient-mark-mode)
3834 transient-mark-mode)
3835 (setq mark-active nil))
3836 (if (not (setq result (let ((buffer-read-only nil))
3837 (gnus-request-article-this-buffer
3839 ;; There is no such article.
3841 (when (and (numberp article)
3842 (not (memq article gnus-newsgroup-sparse)))
3843 (setq gnus-article-current
3844 (cons gnus-newsgroup-name article))
3845 (set-buffer gnus-summary-buffer)
3846 (setq gnus-current-article article)
3847 (if (memq article gnus-newsgroup-undownloaded)
3849 (gnus-summary-set-agent-mark article)
3850 (message "Message marked for downloading"))
3851 (gnus-summary-mark-article article gnus-canceled-mark)
3852 (unless (memq article gnus-newsgroup-sparse)
3853 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3854 (if (or (eq result 'pseudo)
3855 (eq result 'nneething))
3858 (set-buffer summary-buffer)
3859 (push article gnus-newsgroup-history)
3860 (setq gnus-last-article gnus-current-article
3861 gnus-current-article 0
3862 gnus-current-headers nil
3863 gnus-article-current nil)
3864 (if (eq result 'nneething)
3865 (gnus-configure-windows 'summary)
3866 (gnus-configure-windows 'article))
3867 (gnus-set-global-variables))
3868 (let ((gnus-article-mime-handle-alist-1
3869 gnus-article-mime-handle-alist))
3870 (gnus-set-mode-line 'article)))
3871 ;; The result from the `request' was an actual article -
3872 ;; or at least some text that is now displayed in the
3874 (when (and (numberp article)
3875 (not (eq article gnus-current-article)))
3876 ;; Seems like a new article has been selected.
3877 ;; `gnus-current-article' must be an article number.
3879 (set-buffer summary-buffer)
3880 (push article gnus-newsgroup-history)
3881 (setq gnus-last-article gnus-current-article
3882 gnus-current-article article
3883 gnus-current-headers
3884 (gnus-summary-article-header gnus-current-article)
3885 gnus-article-current
3886 (cons gnus-newsgroup-name gnus-current-article))
3887 (unless (vectorp gnus-current-headers)
3888 (setq gnus-current-headers nil))
3889 (gnus-summary-goto-subject gnus-current-article)
3890 (when (gnus-summary-show-thread)
3891 ;; If the summary buffer really was folded, the
3892 ;; previous goto may not actually have gone to
3893 ;; the right article, but the thread root instead.
3895 (gnus-summary-goto-subject gnus-current-article))
3896 (gnus-run-hooks 'gnus-mark-article-hook)
3897 (gnus-set-mode-line 'summary)
3898 (when (gnus-visual-p 'article-highlight 'highlight)
3899 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3900 ;; Set the global newsgroup variables here.
3901 (gnus-set-global-variables)
3902 (setq gnus-have-all-headers
3903 (or all-headers gnus-show-all-headers))))
3905 (gnus-configure-windows 'article))
3906 (when (or (numberp article)
3908 (gnus-article-prepare-display)
3910 (goto-char (point-min))
3911 (setq gnus-page-broken
3912 (when gnus-break-pages
3913 (gnus-narrow-to-page)
3915 (let ((gnus-article-mime-handle-alist-1
3916 gnus-article-mime-handle-alist))
3917 (gnus-set-mode-line 'article))
3921 (set-window-point (get-buffer-window (current-buffer)) (point))
3922 (gnus-configure-windows 'article)
3925 (defun gnus-article-prepare-mime-display (&optional number)
3926 (goto-char (point-min))
3927 (when (re-search-forward "^[^\t ]+:" nil t)
3928 (goto-char (match-beginning 0)))
3929 (let ((entity (if (eq 1 (point-min))
3930 (get-text-property 1 'mime-view-entity)
3931 (get-text-property (point) 'mime-view-entity)))
3932 last-entity child-entity next type)
3933 (setq child-entity (mime-entity-children entity))
3935 (setq last-entity (nth (1- (length child-entity))
3937 (setq last-entity entity))
3939 (narrow-to-region (point)
3940 (if (search-forward "\n\n" nil t)
3943 (gnus-treat-article 'head)
3944 (put-text-property (point-min) (point-max) 'article-treated-header t)
3945 (goto-char (point-max)))
3946 (while (and (not (eobp)) entity)
3947 (setq next (set-marker
3949 (next-single-property-change (point) 'mime-view-entity
3951 (let ((types (mime-entity-content-type entity)))
3952 (while (eq 'multipart (mime-content-type-primary-type types))
3953 (setq entity (car (mime-entity-children entity))
3954 types (mime-entity-content-type entity)))
3956 (setq type (format "%s/%s"
3957 (mime-content-type-primary-type types)
3958 (mime-content-type-subtype types)))))
3959 (if (string-equal type "message/rfc822")
3962 (let ((children (mime-entity-children entity))
3965 (setq last-children (nth (1- (length children)) children))
3968 (not (eq last-children
3969 (get-text-property next 'mime-view-entity)))
3971 (next-single-property-change next
3973 nil (point-max)))))))
3974 (setq next (next-single-property-change next 'mime-view-entity
3977 (narrow-to-region (point) next)
3978 (gnus-article-prepare-mime-display)
3979 (goto-char (point-max)))
3980 (setq entity (get-text-property (point) 'mime-view-entity)))
3982 (narrow-to-region (point) next)
3983 ;; Kludge. We have to count true number, but for now,
3984 ;; part number is here only to achieve `last'.
3985 (gnus-treat-article nil 1
3986 (if (eq entity last-entity)
3989 (goto-char (point-max)))
3990 (setq entity (get-text-property next 'mime-view-entity))))))
3993 (defun gnus-article-prepare-display ()
3994 "Make the current buffer look like a nice article."
3995 (let ((gnus-article-buffer (current-buffer))
3997 (unless (eq major-mode 'gnus-article-mode)
3998 (gnus-article-mode))
3999 (setq buffer-read-only nil
4000 gnus-button-marker-list nil
4001 gnus-article-wash-types nil
4002 gnus-article-image-alist nil)
4005 (static-if (featurep 'xemacs)
4006 (map-extents (lambda (extent maparg) (delete-extent extent)))
4007 (let ((lists (overlay-lists)))
4008 (dolist (overlay (nconc (car lists) (cdr lists)))
4009 (delete-overlay overlay)))))
4010 (gnus-run-hooks 'gnus-tmp-internal-hook))
4011 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4014 (inhibit-read-only t))
4015 (set-buffer gnus-original-article-buffer)
4017 (setq mime-message-structure gnus-current-headers)
4018 (mime-buffer-entity-set-buffer-internal mime-message-structure
4019 gnus-original-article-buffer)
4020 (mime-entity-set-representation-type-internal mime-message-structure
4021 'mime-buffer-entity)
4022 (luna-send mime-message-structure 'initialize-instance
4023 mime-message-structure)
4025 (let (mime-display-header-hook mime-display-text/plain-hook)
4026 (funcall gnus-article-display-method-for-mime))
4027 (funcall gnus-article-display-method-for-traditional))
4028 ;; Call the treatment functions.
4032 (gnus-article-prepare-mime-display)
4033 (narrow-to-region (goto-char (point-min))
4034 (if (search-forward "\n\n" nil t)
4037 (gnus-treat-article 'head)
4038 (put-text-property (point-min) (point-max) 'article-treated-header t)
4039 (goto-char (point-max))
4041 (narrow-to-region (point) (point-max))
4042 (gnus-treat-article nil))
4043 (put-text-property (point-min) (point-max) 'read-only nil)))
4044 (gnus-run-hooks 'gnus-article-prepare-hook))
4046 (defun gnus-article-decode-article-as-default-mime-charset ()
4047 "Decode an article as `default-mime-charset'. It won't work if the
4048 value of the variable `gnus-show-mime' is non-nil."
4049 (unless (or gnus-show-mime
4050 (member gnus-newsgroup-name '("nndraft:delayed"
4052 (set (make-local-variable 'default-mime-charset)
4053 (with-current-buffer gnus-summary-buffer
4054 default-mime-charset))
4055 (decode-mime-charset-region (point-min) (point-max)
4056 default-mime-charset)))
4059 ;;; Gnus MIME viewing functions
4062 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4063 "Format of the MIME buttons.
4065 Valid specifiers include:
4067 %T MIME type, along with additional info
4068 %n The `name' parameter
4069 %d The description, if any
4070 %l The length of the encoded part
4071 %p The part identifier number
4072 %e Dots if the part isn't displayed
4074 General format specifiers can also be used. See Info node
4075 `(gnus)Formatting Variables'.")
4077 (defvar gnus-mime-button-line-format-alist
4078 '((?t gnus-tmp-type ?s)
4079 (?T gnus-tmp-type-long ?s)
4080 (?n gnus-tmp-name ?s)
4081 (?d gnus-tmp-description ?s)
4083 (?l gnus-tmp-length ?d)
4084 (?e gnus-tmp-dots ?s)))
4086 (defvar gnus-mime-button-commands
4087 '((gnus-article-press-button "\r" "Toggle Display")
4088 (gnus-mime-view-part "v" "View Interactively...")
4089 (gnus-mime-view-part-as-type "t" "View As Type...")
4090 (gnus-mime-view-part-as-charset "C" "View As charset...")
4091 (gnus-mime-save-part "o" "Save...")
4092 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4093 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4094 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4095 (gnus-mime-view-part-internally "E" "View Internally")
4096 (gnus-mime-view-part-externally "e" "View Externally")
4097 (gnus-mime-print-part "p" "Print")
4098 (gnus-mime-pipe-part "|" "Pipe To Command...")
4099 (gnus-mime-action-on-part "." "Take action on the part")))
4101 (defun gnus-article-mime-part-status ()
4102 (with-current-buffer gnus-article-buffer
4103 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4106 (setq children (mime-entity-children entity))
4107 (setq children (length children)))
4110 (format " (%d parts)" children))
4113 (defvar gnus-mime-button-map
4114 (let ((map (make-sparse-keymap)))
4115 (unless (>= (string-to-number emacs-version) 21)
4116 ;; XEmacs doesn't care.
4117 (set-keymap-parent map gnus-article-mode-map))
4118 (define-key map gnus-mouse-2 'gnus-article-push-button)
4119 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4120 (dolist (c gnus-mime-button-commands)
4121 (define-key map (cadr c) (car c)))
4124 (defun gnus-mime-button-menu (event)
4125 "Construct a context-sensitive menu of MIME commands."
4127 (save-window-excursion
4128 (let ((pos (event-start event)))
4129 (select-window (posn-window pos))
4130 (goto-char (posn-point pos))
4131 (gnus-article-check-buffer)
4132 (let ((response (x-popup-menu
4134 ("" ,@(mapcar (lambda (c)
4135 (cons (caddr c) (car c)))
4136 gnus-mime-button-commands))))))
4138 (call-interactively response))))))
4140 (defun gnus-mime-view-all-parts (&optional handles)
4141 "View all the MIME parts."
4143 (save-current-buffer
4144 (set-buffer gnus-article-buffer)
4145 (let ((handles (or handles gnus-article-mime-handles))
4146 (mail-parse-charset gnus-newsgroup-charset)
4147 (mail-parse-ignored-charsets
4148 (with-current-buffer gnus-summary-buffer
4149 gnus-newsgroup-ignored-charsets)))
4151 (mm-remove-parts handles)
4152 (goto-char (point-min))
4153 (or (search-forward "\n\n") (goto-char (point-max)))
4154 (let (buffer-read-only)
4155 (delete-region (point) (point-max))
4156 (mm-display-parts handles))))))
4158 (defun gnus-mime-save-part-and-strip ()
4159 "Save the MIME part under point then replace it with an external body."
4161 (gnus-article-check-buffer)
4162 (let* ((data (get-text-property (point) 'gnus-data))
4164 (handles gnus-article-mime-handles))
4165 (if (mm-multiple-handles gnus-article-mime-handles)
4166 (error "This function is not implemented"))
4167 (setq file (and data (mm-save-part data)))
4169 (with-current-buffer (mm-handle-buffer data)
4171 (insert "Content-Type: " (mm-handle-media-type data))
4172 (mml-insert-parameter-string (cdr (mm-handle-type data))
4175 (insert "Content-ID: " (message-make-message-id) "\n")
4176 (insert "Content-Transfer-Encoding: binary\n")
4179 (cdr (mm-make-handle nil
4180 `("message/external-body"
4181 (access-type . "LOCAL-FILE")
4183 (set-buffer gnus-summary-buffer)
4184 (gnus-article-edit-article
4187 (let ((mail-parse-charset (or gnus-article-charset
4188 ',gnus-newsgroup-charset))
4189 (mail-parse-ignored-charsets
4190 (or gnus-article-ignored-charsets
4191 ',gnus-newsgroup-ignored-charsets))
4192 (mbl mml-buffer-list))
4193 (setq mml-buffer-list nil)
4194 (insert-buffer gnus-original-article-buffer)
4195 (mime-to-mml ',handles)
4196 (setq gnus-article-mime-handles nil)
4197 (let ((mbl1 mml-buffer-list))
4198 (setq mml-buffer-list mbl)
4199 (set (make-local-variable 'mml-buffer-list) mbl1))
4200 ;; LOCAL argument of add-hook differs between GNU Emacs
4201 ;; and XEmacs. make-local-hook makes sure they are local.
4202 (make-local-hook 'kill-buffer-hook)
4203 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4204 `(lambda (no-highlight)
4205 (let ((mail-parse-charset (or gnus-article-charset
4206 ',gnus-newsgroup-charset))
4207 (message-options message-options)
4208 (message-options-set-recipient)
4209 (mail-parse-ignored-charsets
4210 (or gnus-article-ignored-charsets
4211 ',gnus-newsgroup-ignored-charsets)))
4213 (mml-destroy-buffers)
4214 (remove-hook 'kill-buffer-hook
4215 'mml-destroy-buffers t)
4216 (kill-local-variable 'mml-buffer-list))
4217 (gnus-summary-edit-article-done
4218 ,(or (mail-header-references gnus-current-headers) "")
4219 ,(gnus-group-read-only-p)
4220 ,gnus-summary-buffer no-highlight))))))
4222 (defun gnus-mime-save-part ()
4223 "Save the MIME part under point."
4225 (gnus-article-check-buffer)
4226 (let ((data (get-text-property (point) 'gnus-data)))
4228 (mm-save-part data))))
4230 (defun gnus-mime-pipe-part ()
4231 "Pipe the MIME part under point to a process."
4233 (gnus-article-check-buffer)
4234 (let ((data (get-text-property (point) 'gnus-data)))
4236 (mm-pipe-part data))))
4238 (defun gnus-mime-view-part ()
4239 "Interactively choose a viewing method for the MIME part under point."
4241 (gnus-article-check-buffer)
4242 (let ((data (get-text-property (point) 'gnus-data)))
4244 (setq gnus-article-mime-handles
4246 gnus-article-mime-handles (setq data (copy-sequence data))))
4247 (mm-interactively-view-part data))))
4249 (defun gnus-mime-view-part-as-type-internal ()
4250 (gnus-article-check-buffer)
4251 (let* ((name (mail-content-type-get
4252 (mm-handle-type (get-text-property (point) 'gnus-data))
4254 (def-type (and name (mm-default-file-encoding name))))
4255 (and def-type (cons def-type 0))))
4257 (defun gnus-mime-view-part-as-type (&optional mime-type)
4258 "Choose a MIME media type, and view the part as such."
4261 (setq mime-type (completing-read
4262 "View as MIME type: "
4263 (mapcar #'list (mailcap-mime-types))
4265 (gnus-mime-view-part-as-type-internal))))
4266 (gnus-article-check-buffer)
4267 (let ((handle (get-text-property (point) 'gnus-data)))
4270 (mm-make-handle (mm-handle-buffer handle)
4271 (cons mime-type (cdr (mm-handle-type handle)))
4272 (mm-handle-encoding handle)
4273 (mm-handle-undisplayer handle)
4274 (mm-handle-disposition handle)
4275 (mm-handle-description handle)
4277 (mm-handle-id handle)))
4278 (setq gnus-article-mime-handles
4279 (mm-merge-handles gnus-article-mime-handles handle))
4280 (gnus-mm-display-part handle))))
4283 (require 'jka-compr))
4285 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4286 ;; emacs can do that itself.
4288 (defun gnus-mime-jka-compr-maybe-uncompress ()
4289 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4290 The uncompress method used is derived from `buffer-file-name'."
4291 (when (and (fboundp 'jka-compr-installed-p)
4292 (jka-compr-installed-p))
4293 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4295 (let ((basename (file-name-nondirectory buffer-file-name))
4296 (args (jka-compr-info-uncompress-args info))
4297 (prog (jka-compr-info-uncompress-program info))
4298 (message (jka-compr-info-uncompress-message info))
4299 (err-file (jka-compr-make-temp-name)))
4301 (message "%s %s..." message basename))
4303 (unless (memq (apply 'call-process-region
4304 (point-min) (point-max)
4306 t (list t err-file) nil
4308 jka-compr-acceptable-retval-list)
4309 (jka-compr-error prog args basename message err-file))
4310 (jka-compr-delete-temp-file err-file)))))))
4312 (defun gnus-mime-copy-part (&optional handle)
4313 "Put the MIME part under point into a new buffer."
4315 (gnus-article-check-buffer)
4316 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4317 (contents (and handle (mm-get-part handle)))
4319 (file-name-nondirectory
4321 (mail-content-type-get (mm-handle-type handle) 'name)
4322 (mail-content-type-get (mm-handle-disposition handle)
4325 (buffer (and base (generate-new-buffer base))))
4327 (switch-to-buffer buffer)
4329 ;; We do it this way to make `normal-mode' set the appropriate mode.
4332 (setq buffer-file-name (expand-file-name base))
4333 (gnus-mime-jka-compr-maybe-uncompress)
4335 (setq buffer-file-name nil))
4336 (goto-char (point-min)))))
4338 (defun gnus-mime-print-part (&optional handle filename)
4339 "Print the MIME part under point."
4340 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4341 (gnus-article-check-buffer)
4342 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4343 (contents (and handle (mm-get-part handle)))
4344 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4345 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
4350 (with-temp-file file
4352 (call-process shell-file-name nil
4353 (generate-new-buffer " *mm*")
4355 shell-command-switch
4357 printer file (mm-handle-type handle))))
4361 (gnus-print-buffer))
4362 (ps-despool filename)))))
4364 (defun gnus-mime-inline-part (&optional handle arg)
4365 "Insert the MIME part under point into the current buffer."
4366 (interactive (list nil current-prefix-arg))
4367 (gnus-article-check-buffer)
4368 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4373 (if (and (not arg) (mm-handle-undisplayer handle))
4374 (mm-remove-part handle)
4375 (setq contents (mm-get-part handle))
4378 (setq charset (or (mail-content-type-get
4379 (mm-handle-type handle) 'charset)
4380 gnus-newsgroup-charset)))
4382 (if (mm-handle-undisplayer handle)
4383 (mm-remove-part handle))
4386 gnus-summary-show-article-charset-alist))
4387 (mm-read-coding-system "Charset: ")))))
4389 (mm-insert-inline handle
4391 (setq charset (mm-charset-to-coding-system
4393 (not (eq charset 'ascii)))
4394 (mm-decode-coding-string contents charset)
4398 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4399 "Insert the MIME part under point into the current buffer using the
4401 (interactive (list nil current-prefix-arg))
4402 (gnus-article-check-buffer)
4403 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4408 (if (mm-handle-undisplayer handle)
4409 (mm-remove-part handle))
4410 (let ((gnus-newsgroup-charset
4412 gnus-summary-show-article-charset-alist))
4413 (mm-read-coding-system "Charset: ")))
4414 (gnus-newsgroup-ignored-charsets 'gnus-all))
4415 (gnus-article-press-button)))))
4417 (defun gnus-mime-view-part-externally (&optional handle)
4418 "View the MIME part under point with an external viewer."
4420 (gnus-article-check-buffer)
4421 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4422 (mm-user-display-methods nil)
4423 (mm-inlined-types nil)
4424 (mail-parse-charset gnus-newsgroup-charset)
4425 (mail-parse-ignored-charsets
4426 (save-excursion (set-buffer gnus-summary-buffer)
4427 gnus-newsgroup-ignored-charsets)))
4429 (if (mm-handle-undisplayer handle)
4430 (mm-remove-part handle)
4431 (mm-display-part handle)))))
4433 (defun gnus-mime-view-part-internally (&optional handle)
4434 "View the MIME part under point with an internal viewer.
4435 If no internal viewer is available, use an external viewer."
4437 (gnus-article-check-buffer)
4438 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4439 (mm-inlined-types '(".*"))
4440 (mm-inline-large-images t)
4441 (mail-parse-charset gnus-newsgroup-charset)
4442 (mail-parse-ignored-charsets
4443 (save-excursion (set-buffer gnus-summary-buffer)
4444 gnus-newsgroup-ignored-charsets)))
4446 (if (mm-handle-undisplayer handle)
4447 (mm-remove-part handle)
4448 (mm-display-part handle)))))
4450 (defun gnus-mime-action-on-part (&optional action)
4451 "Do something with the MIME attachment at \(point\)."
4453 (list (completing-read "Action: " gnus-mime-action-alist)))
4454 (gnus-article-check-buffer)
4455 (let ((action-pair (assoc action gnus-mime-action-alist)))
4457 (funcall (cdr action-pair)))))
4459 (defun gnus-article-part-wrapper (n function)
4460 (save-current-buffer
4461 (set-buffer gnus-article-buffer)
4462 (when (> n (length gnus-article-mime-handle-alist))
4463 (error "No such part"))
4464 (gnus-article-goto-part n)
4465 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4466 (funcall function handle))))
4468 (defun gnus-article-pipe-part (n)
4469 "Pipe MIME part N, which is the numerical prefix."
4471 (gnus-article-part-wrapper n 'mm-pipe-part))
4473 (defun gnus-article-save-part (n)
4474 "Save MIME part N, which is the numerical prefix."
4476 (gnus-article-part-wrapper n 'mm-save-part))
4478 (defun gnus-article-interactively-view-part (n)
4479 "View MIME part N interactively, which is the numerical prefix."
4481 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4483 (defun gnus-article-copy-part (n)
4484 "Copy MIME part N, which is the numerical prefix."
4486 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4488 (defun gnus-article-view-part-as-charset (n)
4489 "Copy MIME part N, which is the numerical prefix."
4491 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4493 (defun gnus-article-view-part-externally (n)
4494 "View MIME part N externally, which is the numerical prefix."
4496 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4498 (defun gnus-article-inline-part (n)
4499 "Inline MIME part N, which is the numerical prefix."
4501 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4503 (defun gnus-article-mime-match-handle-first (condition)
4505 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4506 (while (setq ihandle (pop alist))
4508 ((functionp condition)
4509 (funcall condition (cdr ihandle)))
4510 ((eq condition 'undisplayed)
4511 (not (or (mm-handle-undisplayer (cdr ihandle))
4512 (equal (mm-handle-media-type (cdr ihandle))
4513 "multipart/alternative"))))
4514 ((eq condition 'undisplayed-alternative)
4515 (not (mm-handle-undisplayer (cdr ihandle))))
4517 (gnus-article-goto-part (car ihandle))
4518 (or (not n) (< (car ihandle) n)))
4519 (setq n (car ihandle))))
4523 (defun gnus-article-view-part (&optional n)
4524 "View MIME part N, which is the numerical prefix."
4526 (save-current-buffer
4527 (set-buffer gnus-article-buffer)
4528 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4529 gnus-article-mime-match-handle-function)))
4530 (when (> n (length gnus-article-mime-handle-alist))
4531 (error "No such part"))
4532 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4533 (when (gnus-article-goto-part n)
4534 (if (equal (car handle) "multipart/alternative")
4535 (gnus-article-press-button)
4536 (when (eq (gnus-mm-display-part handle) 'internal)
4537 (gnus-set-window-start)))))))
4539 (defsubst gnus-article-mime-total-parts ()
4540 (if (bufferp (car gnus-article-mime-handles))
4542 (1- (length gnus-article-mime-handles))))
4544 (defun gnus-mm-display-part (handle)
4545 "Display HANDLE and fix MIME button."
4546 (let ((id (get-text-property (point) 'gnus-part))
4551 (let ((window (selected-window))
4552 (mail-parse-charset gnus-newsgroup-charset)
4553 (mail-parse-ignored-charsets
4554 (if (gnus-buffer-live-p gnus-summary-buffer)
4556 (set-buffer gnus-summary-buffer)
4557 gnus-newsgroup-ignored-charsets)
4561 (let ((win (gnus-get-buffer-window (current-buffer) t))
4564 (select-window win))
4567 (if (mm-handle-displayed-p handle)
4568 ;; This will remove the part.
4569 (mm-display-part handle)
4571 (narrow-to-region (point)
4572 (if (eobp) (point) (1+ (point))))
4573 (mm-display-part handle)
4574 ;; We narrow to the part itself and
4575 ;; then call the treatment functions.
4576 (goto-char (point-min))
4578 (narrow-to-region (point) (point-max))
4581 (gnus-article-mime-total-parts)
4582 (mm-handle-media-type handle)))))
4583 (if (window-live-p window)
4584 (select-window window)))))
4586 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4587 (gnus-insert-mime-button
4588 handle id (list (mm-handle-displayed-p handle)))
4589 (goto-char point))))
4591 (defun gnus-article-goto-part (n)
4592 "Go to MIME part N."
4593 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4595 (goto-char point))))
4597 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4598 (let ((gnus-tmp-name
4599 (or (mail-content-type-get (mm-handle-type handle) 'name)
4600 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4601 (mail-content-type-get (mm-handle-type handle) 'url)
4603 (gnus-tmp-type (mm-handle-media-type handle))
4604 (gnus-tmp-description
4605 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4608 (if (if displayed (car displayed)
4609 (mm-handle-displayed-p handle))
4611 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4613 gnus-tmp-type-long b e)
4614 (when (string-match ".*/" gnus-tmp-name)
4615 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4616 (setq gnus-tmp-type-long (concat gnus-tmp-type
4617 (and (not (equal gnus-tmp-name ""))
4618 (concat "; " gnus-tmp-name))))
4619 (unless (equal gnus-tmp-description "")
4620 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4625 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4626 `(,@(gnus-local-map-property gnus-mime-button-map)
4627 gnus-callback gnus-mm-display-part
4628 gnus-part ,gnus-tmp-id
4629 article-type annotation
4632 (widget-convert-button
4635 :action 'gnus-widget-press-button
4636 :button-keymap gnus-mime-button-map
4638 (lambda (widget/window &optional overlay pos)
4639 ;; Needed to properly clear the message due to a bug in
4640 ;; wid-edit (XEmacs only).
4641 (if (boundp 'help-echo-owns-message)
4642 (setq help-echo-owns-message t))
4644 "%S: %s the MIME part; %S: more options"
4645 (aref gnus-mouse-2 0)
4646 ;; XEmacs will get a single widget arg; Emacs 21 will get
4647 ;; window, overlay, position.
4648 (if (mm-handle-displayed-p
4650 (with-current-buffer (gnus-overlay-buffer overlay)
4651 (widget-get (widget-at (gnus-overlay-start overlay))
4653 (widget-get widget/window :mime-handle)))
4655 (aref gnus-down-mouse-3 0))))))
4657 (defun gnus-widget-press-button (elems el)
4658 (goto-char (widget-get elems :from))
4659 (gnus-article-press-button))
4661 (defvar gnus-displaying-mime nil)
4663 (defun gnus-display-mime (&optional ihandles)
4664 "Display the MIME parts."
4666 (save-selected-window
4667 (let ((window (get-buffer-window gnus-article-buffer))
4670 (select-window window)
4671 ;; We have to do this since selecting the window
4672 ;; may change the point. So we set the window point.
4673 (set-window-point window point)))
4674 (let* ((handles (or ihandles (mm-dissect-buffer
4675 nil gnus-article-loose-mime)
4677 buffer-read-only handle name type b e display)
4678 (when (and (not ihandles)
4679 (not gnus-displaying-mime))
4680 ;; Top-level call; we clean up.
4681 (when gnus-article-mime-handles
4682 (mm-destroy-parts gnus-article-mime-handles)
4683 (setq gnus-article-mime-handle-alist nil));; A trick.
4684 (setq gnus-article-mime-handles handles)
4685 ;; We allow users to glean info from the handles.
4686 (when gnus-article-mime-part-function
4687 (gnus-mime-part-function handles)))
4689 (or (not (stringp (car handles)))
4692 (when (and (not ihandles)
4693 (not gnus-displaying-mime))
4694 ;; Clean up for mime parts.
4696 (delete-region (point) (point-max)))
4697 (let ((gnus-displaying-mime t))
4698 (gnus-mime-display-part handles)))
4701 (narrow-to-region (point) (point-max))
4702 (gnus-treat-article nil 1 1)
4705 ;; Highlight the headers.
4709 (narrow-to-region (point-min) (point))
4710 (gnus-treat-article 'head))))))))
4712 (defvar gnus-mime-display-multipart-as-mixed nil)
4713 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4714 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4716 (defun gnus-mime-display-part (handle)
4719 ((not (stringp (car handle)))
4720 (gnus-mime-display-single handle))
4721 ;; User-defined multipart
4722 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4723 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4725 ;; multipart/alternative
4726 ((and (equal (car handle) "multipart/alternative")
4727 (not (or gnus-mime-display-multipart-as-mixed
4728 gnus-mime-display-multipart-alternative-as-mixed)))
4729 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4730 (push (cons id handle) gnus-article-mime-handle-alist)
4731 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4732 ;; multipart/related
4733 ((and (equal (car handle) "multipart/related")
4734 (not (or gnus-mime-display-multipart-as-mixed
4735 gnus-mime-display-multipart-related-as-mixed)))
4736 ;;;!!!We should find the start part, but we just default
4737 ;;;!!!to the first part.
4738 ;;(gnus-mime-display-part (cadr handle))
4739 ;;;!!! Most multipart/related is an HTML message plus images.
4740 ;;;!!! Unfortunately we are unable to let W3 display those
4741 ;;;!!! included images, so we just display it as a mixed multipart.
4742 ;;(gnus-mime-display-mixed (cdr handle))
4743 ;;;!!! No, w3 can display everything just fine.
4744 (gnus-mime-display-part (cadr handle)))
4745 ((equal (car handle) "multipart/signed")
4746 (gnus-add-wash-type 'signed)
4747 (gnus-mime-display-security handle))
4748 ((equal (car handle) "multipart/encrypted")
4749 (gnus-add-wash-type 'encrypted)
4750 (gnus-mime-display-security handle))
4751 ;; Other multiparts are handled like multipart/mixed.
4753 (gnus-mime-display-mixed (cdr handle)))))
4755 (defun gnus-mime-part-function (handles)
4756 (if (stringp (car handles))
4757 (mapcar 'gnus-mime-part-function (cdr handles))
4758 (funcall gnus-article-mime-part-function handles)))
4760 (defun gnus-mime-display-mixed (handles)
4761 (mapcar 'gnus-mime-display-part handles))
4763 (defun gnus-mime-display-single (handle)
4764 (let ((type (mm-handle-media-type handle))
4765 (ignored gnus-ignored-mime-types)
4772 (when (string-match (pop ignored) type)
4773 (throw 'ignored nil)))
4774 (if (and (setq not-attachment
4775 (and (not (mm-inline-override-p handle))
4776 (or (not (mm-handle-disposition handle))
4777 (equal (car (mm-handle-disposition handle))
4779 (mm-attachment-override-p handle))))
4780 (mm-automatic-display-p handle)
4782 (mm-inlinable-p handle)
4783 (mm-inlined-p handle))
4784 (mm-automatic-external-display-p type)))
4786 (when (equal (mm-handle-media-supertype handle) "text")
4788 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4790 (push (cons id handle) gnus-article-mime-handle-alist)
4791 (when (or (not display)
4792 (not (gnus-unbuttonized-mime-type-p type)))
4793 ;(gnus-article-insert-newline)
4794 (gnus-insert-mime-button
4795 handle id (list (or display (and not-attachment text))))
4796 (gnus-article-insert-newline)
4797 ;(gnus-article-insert-newline)
4798 ;; Remember modify the number of forward lines.
4806 (let ((mail-parse-charset gnus-newsgroup-charset)
4807 (mail-parse-ignored-charsets
4808 (save-excursion (condition-case ()
4809 (set-buffer gnus-summary-buffer)
4811 gnus-newsgroup-ignored-charsets)))
4812 (mm-display-part handle t))
4813 (goto-char (point-max)))
4814 ((and text not-attachment)
4818 (gnus-article-insert-newline)
4819 (mm-insert-inline handle (mm-get-part handle))
4820 (goto-char (point-max))))
4824 (narrow-to-region beg (point))
4827 (gnus-article-mime-total-parts)
4828 (mm-handle-media-type handle)))))))))
4830 (defun gnus-unbuttonized-mime-type-p (type)
4831 "Say whether TYPE is to be unbuttonized."
4832 (unless gnus-inhibit-mime-unbuttonizing
4834 (let ((types gnus-unbuttonized-mime-types))
4836 (when (string-match (pop types) type)
4837 (throw 'found t)))))
4839 (let ((types gnus-buttonized-mime-types))
4841 (when (string-match (pop types) type)
4842 (throw 'found t)))))))))
4844 (defun gnus-article-insert-newline ()
4845 "Insert a newline, but mark it as undeletable."
4846 (gnus-put-text-property
4847 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4849 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4850 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4853 handle buffer-read-only from props begend not-pref)
4854 (save-window-excursion
4857 (narrow-to-region (car ibegend)
4860 (goto-char (car ibegend))
4863 (delete-region (point-min) (point-max))
4864 (mm-remove-parts handles))
4865 (setq begend (list (point-marker)))
4867 (unless (setq not-pref (cadr (member preferred ihandles)))
4868 (setq not-pref (car ihandles)))
4871 (not (gnus-unbuttonized-mime-type-p
4872 "multipart/alternative")))
4873 (gnus-add-text-properties
4876 (insert (format "%d. " id))
4880 (unless ,(not ibegend)
4881 (setq gnus-article-mime-handle-alist
4882 ',gnus-article-mime-handle-alist))
4883 (gnus-mime-display-alternative
4884 ',ihandles ',not-pref ',begend ,id))
4885 ,@(gnus-local-map-property gnus-mime-button-map)
4886 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4887 face ,gnus-article-button-face
4890 (widget-convert-button 'link from (point)
4891 :action 'gnus-widget-press-button
4892 :button-keymap gnus-widget-button-keymap)
4894 (while (setq handle (pop handles))
4895 (gnus-add-text-properties
4898 (insert (format "(%c) %-18s"
4899 (if (equal handle preferred) ?* ? )
4900 (mm-handle-media-type handle)))
4904 (unless ,(not ibegend)
4905 (setq gnus-article-mime-handle-alist
4906 ',gnus-article-mime-handle-alist))
4907 (gnus-mime-display-alternative
4908 ',ihandles ',handle ',begend ,id))
4909 ,@(gnus-local-map-property gnus-mime-button-map)
4910 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4911 face ,gnus-article-button-face
4914 (widget-convert-button 'link from (point)
4915 :action 'gnus-widget-press-button
4916 :button-keymap gnus-widget-button-keymap)
4920 (if (stringp (car preferred))
4921 (gnus-display-mime preferred)
4922 (let ((mail-parse-charset gnus-newsgroup-charset)
4923 (mail-parse-ignored-charsets
4924 (save-excursion (set-buffer gnus-summary-buffer)
4925 gnus-newsgroup-ignored-charsets)))
4926 (mm-display-part preferred)
4930 (narrow-to-region (car begend) (point-max))
4932 nil (length gnus-article-mime-handle-alist)
4933 (gnus-article-mime-total-parts)
4934 (mm-handle-media-type handle))))))
4935 (goto-char (point-max))
4936 (setcdr begend (point-marker)))))
4938 (goto-char point))))
4940 (defconst gnus-article-wash-status-strings
4941 (let ((alist '((cite "c" "Possible hidden citation text"
4942 " " "All citation text visible")
4943 (headers "h" "Hidden headers"
4944 " " "All headers visible.")
4945 (pgp "p" "Encrypted or signed message status hidden"
4946 " " "No hidden encryption nor digital signature status")
4947 (signature "s" "Signature has been hidden"
4948 " " "Signature is visible")
4949 (overstrike "o" "Overstrike (^H) characters applied"
4950 " " "No overstrike characters applied")
4951 (gnus-show-mime "m" "Mime processing is activated"
4952 " " "Mime processing is not activated")
4953 (emphasis "e" "/*_Emphasis_*/ characters applied"
4954 " " "No /*_emphasis_*/ characters applied")))
4956 (dolist (entry alist result)
4957 (let ((key (nth 0 entry))
4958 (on (copy-sequence (nth 1 entry)))
4959 (on-help (nth 2 entry))
4960 (off (copy-sequence (nth 3 entry)))
4961 (off-help (nth 4 entry)))
4962 (put-text-property 0 1 'help-echo on-help on)
4963 (put-text-property 0 1 'help-echo off-help off)
4964 (push (list key on off) result))))
4965 "Alist of strings describing wash status in the mode line.
4966 Each entry has the form (KEY ON OF), where the KEY is a symbol
4967 representing the particular washing function, ON is the string to use
4968 in the article mode line when the washing function is active, and OFF
4969 is the string to use when it is inactive.")
4971 (defun gnus-article-wash-status-entry (key value)
4972 (let ((entry (assoc key gnus-article-wash-status-strings)))
4973 (if value (nth 1 entry) (nth 2 entry))))
4975 (defun gnus-article-wash-status ()
4976 "Return a string which display status of article washing."
4978 (set-buffer gnus-article-buffer)
4979 (let ((cite (memq 'cite gnus-article-wash-types))
4980 (headers (memq 'headers gnus-article-wash-types))
4981 (boring (memq 'boring-headers gnus-article-wash-types))
4982 (pgp (memq 'pgp gnus-article-wash-types))
4983 (pem (memq 'pem gnus-article-wash-types))
4984 (signed (memq 'signed gnus-article-wash-types))
4985 (encrypted (memq 'encrypted gnus-article-wash-types))
4986 (signature (memq 'signature gnus-article-wash-types))
4987 (overstrike (memq 'overstrike gnus-article-wash-types))
4988 (emphasis (memq 'emphasis gnus-article-wash-types)))
4990 (gnus-article-wash-status-entry 'cite cite)
4991 (gnus-article-wash-status-entry 'headers (or headers boring))
4992 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4993 (gnus-article-wash-status-entry 'signature signature)
4994 (gnus-article-wash-status-entry 'overstrike overstrike)
4995 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
4996 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4998 (defun gnus-add-wash-type (type)
4999 "Add a washing of TYPE to the current status."
5000 (add-to-list 'gnus-article-wash-types type))
5002 (defun gnus-delete-wash-type (type)
5003 "Add a washing of TYPE to the current status."
5004 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5006 (defun gnus-add-image (category image)
5007 "Add IMAGE of CATEGORY to the list of displayed images."
5008 (let ((entry (assq category gnus-article-image-alist)))
5010 (setq entry (list category))
5011 (push entry gnus-article-image-alist))
5012 (nconc entry (list image))))
5014 (defun gnus-delete-images (category)
5015 "Delete all images in CATEGORY."
5016 (let ((entry (assq category gnus-article-image-alist)))
5017 (dolist (image (cdr entry))
5018 (gnus-remove-image image))
5019 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5020 (gnus-delete-wash-type category)))
5022 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5024 (defun gnus-article-maybe-hide-headers ()
5025 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5026 Provided for backwards compatibility."
5027 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5028 (not (save-excursion (set-buffer gnus-summary-buffer)
5029 gnus-have-all-headers)))
5030 (not gnus-inhibit-hiding))
5031 (gnus-article-hide-headers)))
5035 (defun gnus-output-to-file (file-name)
5036 "Append the current article to a file named FILE-NAME."
5037 (let ((artbuf (current-buffer)))
5039 (insert-buffer-substring artbuf)
5040 ;; Append newline at end of the buffer as separator, and then
5042 (goto-char (point-max))
5044 (let ((file-name-coding-system nnmail-pathname-coding-system)
5045 (pathname-coding-system nnmail-pathname-coding-system))
5046 (write-region-as-binary (point-min) (point-max) file-name 'append))
5049 (defun gnus-narrow-to-page (&optional arg)
5050 "Narrow the article buffer to a page.
5051 If given a numerical ARG, move forward ARG pages."
5053 (setq arg (if arg (prefix-numeric-value arg) 0))
5055 (set-buffer gnus-article-buffer)
5056 (goto-char (point-min))
5058 ;; Remove any old next/prev buttons.
5059 (when (gnus-visual-p 'page-marker)
5060 (let ((buffer-read-only nil))
5061 (gnus-remove-text-with-property 'gnus-prev)
5062 (gnus-remove-text-with-property 'gnus-next)))
5065 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5067 (re-search-forward page-delimiter nil 'move arg)))
5068 (goto-char (match-end 0)))
5071 (if (re-search-forward page-delimiter nil 'move)
5074 (when (and (gnus-visual-p 'page-marker)
5075 (not (= (point-min) 1)))
5077 (goto-char (point-min))
5078 (gnus-insert-prev-page-button)))
5079 (when (and (gnus-visual-p 'page-marker)
5080 (< (+ (point-max) 2) (buffer-size)))
5082 (goto-char (point-max))
5083 (gnus-insert-next-page-button)))))
5085 ;; Article mode commands
5087 (defun gnus-article-goto-next-page ()
5088 "Show the next page of the article."
5090 (when (gnus-article-next-page)
5091 (goto-char (point-min))
5092 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5094 (defun gnus-article-goto-prev-page ()
5095 "Show the next page of the article."
5097 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5098 (gnus-article-prev-page nil)))
5100 (defun gnus-article-next-page (&optional lines)
5101 "Show the next page of the current article.
5102 If end of article, return non-nil. Otherwise return nil.
5103 Argument LINES specifies lines to be scrolled up."
5105 (let ((start (window-start))
5106 end-of-buffer end-of-page)
5108 (move-to-window-line -1)
5109 (if (<= (point) start)
5112 (setq start (point)))
5115 (unless (or (cond ((eq (1+ (buffer-size)) (point))
5116 (and (pos-visible-in-window-p)
5117 (setq end-of-buffer t)))
5119 (setq end-of-page t)))
5121 (move-to-window-line lines)
5122 (unless (search-backward "\n\n" nil t)
5123 (setq start (point)))))
5124 (cond (end-of-buffer t)
5126 (gnus-narrow-to-page 1)
5130 (set-window-start (selected-window) start)
5131 (let (window-pixel-scroll-increment)
5135 (defun gnus-article-prev-page (&optional lines)
5136 "Show previous page of current article.
5137 Argument LINES specifies lines to be scrolled down."
5139 (let (beginning-of-buffer beginning-of-page)
5141 (move-to-window-line 0)
5142 (cond ((eq 1 (point))
5143 (setq beginning-of-buffer t))
5145 (setq beginning-of-page t))))
5146 (cond (beginning-of-buffer)
5148 (gnus-narrow-to-page -1))
5151 (let (window-pixel-scroll-increment)
5152 (scroll-down lines))
5153 (beginning-of-buffer
5154 (goto-char (point-min))))))))
5156 (defun gnus-article-refer-article ()
5157 "Read article specified by message-id around point."
5159 (let ((point (point)))
5160 (search-forward ">" nil t) ;Move point to end of "<....>".
5161 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
5162 (let ((message-id (match-string 1)))
5164 (set-buffer gnus-summary-buffer)
5165 (gnus-summary-refer-article message-id))
5167 (error "No references around point"))))
5169 (defun gnus-article-show-summary ()
5170 "Reconfigure windows to show summary buffer."
5172 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5173 (error "There is no summary buffer for this article buffer")
5174 (gnus-article-set-globals)
5175 (gnus-configure-windows 'article)
5176 (gnus-summary-goto-subject gnus-current-article)
5177 (gnus-summary-position-point)))
5179 (defun gnus-article-describe-briefly ()
5180 "Describe article mode commands briefly."
5182 (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")))
5184 (defun gnus-article-summary-command ()
5185 "Execute the last keystroke in the summary buffer."
5187 (let ((obuf (current-buffer))
5188 (owin (current-window-configuration))
5190 (switch-to-buffer gnus-article-current-summary 'norecord)
5191 (setq func (lookup-key (current-local-map) (this-command-keys)))
5192 (call-interactively func)
5194 (set-window-configuration owin)
5195 (set-window-point (get-buffer-window (current-buffer)) (point))))
5197 (defun gnus-article-summary-command-nosave ()
5198 "Execute the last keystroke in the summary buffer."
5201 (pop-to-buffer gnus-article-current-summary 'norecord)
5202 (setq func (lookup-key (current-local-map) (this-command-keys)))
5203 (call-interactively func)))
5205 (defun gnus-article-check-buffer ()
5206 "Beep if not in an article buffer."
5207 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5208 (error "Command invoked outside of a Gnus article buffer")))
5210 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5211 "Read a summary buffer key sequence and execute it from the article buffer."
5213 (gnus-article-check-buffer)
5215 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5216 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5217 "=" "^" "\M-^" "|"))
5223 '("n" "Gn" "p" "Gp"))
5226 (set-buffer gnus-article-current-summary)
5227 (let (gnus-pick-mode)
5228 (push (or key last-command-event) unread-command-events)
5229 (setq keys (static-if (featurep 'xemacs)
5230 (events-to-keys (read-key-sequence nil))
5231 (read-key-sequence nil)))))
5234 (if (or (member keys nosaves)
5235 (member keys nosave-but-article)
5236 (member keys nosave-in-article))
5238 (save-window-excursion
5239 (pop-to-buffer gnus-article-current-summary 'norecord)
5240 ;; We disable the pick minor mode commands.
5241 (let (gnus-pick-mode)
5242 (setq func (lookup-key (current-local-map) keys))))
5246 (unless (member keys nosave-in-article)
5247 (set-buffer gnus-article-current-summary))
5248 (call-interactively func)
5249 (setq new-sum-point (point)))
5250 (when (member keys nosave-but-article)
5251 (pop-to-buffer gnus-article-buffer 'norecord)))
5252 ;; These commands should restore window configuration.
5253 (let ((obuf (current-buffer))
5254 (owin (current-window-configuration))
5256 (summary gnus-article-current-summary)
5257 func in-buffer selected)
5258 (if not-restore-window
5259 (pop-to-buffer summary 'norecord)
5260 (switch-to-buffer summary 'norecord))
5261 (setq in-buffer (current-buffer))
5262 ;; We disable the pick minor mode commands.
5263 (if (and (setq func (let (gnus-pick-mode)
5264 (lookup-key (current-local-map) keys)))
5267 (call-interactively func)
5268 (setq new-sum-point (point))
5269 (when (eq in-buffer (current-buffer))
5270 (setq selected (gnus-summary-select-article))
5272 (unless not-restore-window
5273 (set-window-configuration owin))
5274 (when (eq selected 'old)
5276 (set-window-start (get-buffer-window (current-buffer))
5278 (set-window-point (get-buffer-window (current-buffer))
5280 (let ((win (get-buffer-window gnus-article-current-summary)))
5282 (set-window-point win new-sum-point)))) )
5283 (switch-to-buffer gnus-article-buffer)
5286 (defun gnus-article-describe-key (key)
5287 "Display documentation of the function invoked by KEY. KEY is a string."
5288 (interactive "kDescribe key: ")
5289 (gnus-article-check-buffer)
5290 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5292 (set-buffer gnus-article-current-summary)
5293 (let (gnus-pick-mode)
5294 (if (featurep 'xemacs)
5296 (push (elt key 0) unread-command-events)
5297 (setq key (events-to-keys
5298 (read-key-sequence "Describe key: "))))
5299 (setq unread-command-events
5301 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5303 (setq key (read-key-sequence "Describe key: "))))
5305 (describe-key key)))
5307 (defun gnus-article-describe-key-briefly (key &optional insert)
5308 "Display documentation of the function invoked by KEY. KEY is a string."
5309 (interactive "kDescribe key: \nP")
5310 (gnus-article-check-buffer)
5311 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5313 (set-buffer gnus-article-current-summary)
5314 (let (gnus-pick-mode)
5315 (if (featurep 'xemacs)
5317 (push (elt key 0) unread-command-events)
5318 (setq key (events-to-keys
5319 (read-key-sequence "Describe key: "))))
5320 (setq unread-command-events
5322 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5324 (setq key (read-key-sequence "Describe key: "))))
5325 (describe-key-briefly key insert))
5326 (describe-key-briefly key insert)))
5328 (defun gnus-article-reply-with-original (&optional wide)
5329 "Start composing a reply mail to the current message.
5330 The text in the region will be yanked. If the region isn't active,
5331 the entire article will be yanked."
5333 (let ((article (cdr gnus-article-current)) cont)
5335 (with-current-buffer gnus-summary-buffer
5336 (gnus-summary-reply (list (list article)) wide))
5337 (setq cont (buffer-substring (point) (mark t)))
5338 ;; Deactivate active regions.
5339 (when (and (boundp 'transient-mark-mode)
5340 transient-mark-mode)
5341 (setq mark-active nil))
5342 (with-current-buffer gnus-summary-buffer
5344 (list (list article cont)) wide)))))
5346 (defun gnus-article-followup-with-original ()
5347 "Compose a followup to the current article.
5348 The text in the region will be yanked. If the region isn't active,
5349 the entire article will be yanked."
5351 (let ((article (cdr gnus-article-current)) cont)
5353 (with-current-buffer gnus-summary-buffer
5354 (gnus-summary-followup (list (list article))))
5355 (setq cont (buffer-substring (point) (mark t)))
5356 ;; Deactivate active regions.
5357 (when (and (boundp 'transient-mark-mode)
5358 transient-mark-mode)
5359 (setq mark-active nil))
5360 (with-current-buffer gnus-summary-buffer
5361 (gnus-summary-followup
5362 (list (list article cont)))))))
5364 (defun gnus-article-hide (&optional arg force)
5365 "Hide all the gruft in the current article.
5366 This means that PGP stuff, signatures, cited text and (some)
5367 headers will be hidden.
5368 If given a prefix, show the hidden text instead."
5369 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5370 (gnus-article-hide-headers arg)
5371 (gnus-article-hide-list-identifiers arg)
5372 (gnus-article-hide-pgp arg)
5373 (gnus-article-hide-citation-maybe arg force)
5374 (gnus-article-hide-signature arg))
5376 (defun gnus-article-maybe-highlight ()
5377 "Do some article highlighting if article highlighting is requested."
5378 (when (gnus-visual-p 'article-highlight 'highlight)
5379 (gnus-article-highlight-some)))
5381 (defun gnus-check-group-server ()
5382 ;; Make sure the connection to the server is alive.
5383 (unless (gnus-server-opened
5384 (gnus-find-method-for-group gnus-newsgroup-name))
5385 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5386 (gnus-request-group gnus-newsgroup-name t)))
5389 (autoload 'nneething-get-file-name "nneething"))
5391 (defun gnus-request-article-this-buffer (article group)
5392 "Get an article and insert it into this buffer."
5393 (let (do-update-line sparse-header)
5397 (gnus-kill-all-overlays)
5398 (setq group (or group gnus-newsgroup-name))
5400 ;; Using `gnus-request-article' directly will insert the article into
5401 ;; `nntp-server-buffer' - so we'll save some time by not having to
5402 ;; copy it from the server buffer into the article buffer.
5404 ;; We only request an article by message-id when we do not have the
5405 ;; headers for it, so we'll have to get those.
5406 (when (stringp article)
5407 (gnus-read-header article))
5409 ;; If the article number is negative, that means that this article
5410 ;; doesn't belong in this newsgroup (possibly), so we find its
5411 ;; message-id and request it by id instead of number.
5412 (when (and (numberp article)
5414 (get-buffer gnus-summary-buffer)
5415 (gnus-buffer-exists-p gnus-summary-buffer))
5417 (set-buffer gnus-summary-buffer)
5418 (let ((header (gnus-summary-article-header article)))
5421 ((memq article gnus-newsgroup-sparse)
5422 ;; This is a sparse gap article.
5423 (setq do-update-line article)
5424 (setq article (mail-header-id header))
5425 (setq sparse-header (gnus-read-header article))
5426 (setq gnus-newsgroup-sparse
5427 (delq article gnus-newsgroup-sparse)))
5429 ;; It's a real article.
5430 (setq article (mail-header-id header)))
5432 ;; It is an extracted pseudo-article.
5433 (setq article 'pseudo)
5434 (gnus-request-pseudo-article header))))
5436 (let ((method (gnus-find-method-for-group
5437 gnus-newsgroup-name)))
5438 (when (and (eq (car method) 'nneething)
5440 (let ((dir (nneething-get-file-name
5441 (mail-header-id header))))
5442 (when (and (stringp dir)
5443 (file-directory-p dir))
5444 (setq article 'nneething)
5445 (gnus-group-enter-directory dir))))))))
5448 ;; Refuse to select canceled articles.
5449 ((and (numberp article)
5451 (get-buffer gnus-summary-buffer)
5452 (gnus-buffer-exists-p gnus-summary-buffer)
5453 (eq (cdr (save-excursion
5454 (set-buffer gnus-summary-buffer)
5455 (assq article gnus-newsgroup-reads)))
5456 gnus-canceled-mark))
5458 ;; We first check `gnus-original-article-buffer'.
5459 ((and (get-buffer gnus-original-article-buffer)
5462 (set-buffer gnus-original-article-buffer)
5463 (and (equal (car gnus-original-article) group)
5464 (eq (cdr gnus-original-article) article))))
5465 (insert-buffer-substring gnus-original-article-buffer)
5467 ;; Check the backlog.
5468 ((and gnus-keep-backlog
5469 (gnus-backlog-request-article group article (current-buffer)))
5471 ;; Check asynchronous pre-fetch.
5472 ((gnus-async-request-fetched-article group article (current-buffer))
5473 (gnus-async-prefetch-next group article gnus-summary-buffer)
5474 (when (and (numberp article) gnus-keep-backlog)
5475 (gnus-backlog-enter-article group article (current-buffer)))
5478 ((and gnus-use-cache
5480 (gnus-cache-request-article article group))
5482 ;; Check the agent cache.
5483 ((and gnus-agent gnus-agent-cache gnus-plugged
5485 (gnus-agent-request-article article group))
5487 ;; Get the article and put into the article buffer.
5488 ((or (stringp article)
5490 (let ((gnus-override-method gnus-override-method)
5491 (methods (and (stringp article)
5492 gnus-refer-article-method))
5493 (backend (car (gnus-find-method-for-group
5494 gnus-newsgroup-name)))
5496 (buffer-read-only nil))
5497 (if (or (not (listp methods))
5498 (and (symbolp (car methods))
5499 (assq (car methods) nnoo-definition-alist)))
5500 (setq methods (list methods)))
5501 (when (and (null gnus-override-method)
5503 (setq gnus-override-method (pop methods)))
5505 (when (eq gnus-override-method 'current)
5506 (setq gnus-override-method
5507 (with-current-buffer gnus-summary-buffer
5508 gnus-current-select-method)))
5510 (gnus-kill-all-overlays)
5511 (let ((gnus-newsgroup-name group))
5512 (gnus-check-group-server))
5514 ((gnus-request-article article group (current-buffer))
5515 (when (numberp article)
5516 (gnus-async-prefetch-next group article
5517 gnus-summary-buffer)
5518 (when gnus-keep-backlog
5519 (gnus-backlog-enter-article
5520 group article (current-buffer))))
5521 (setq result 'article))
5523 (setq gnus-override-method (pop methods)))
5524 ((not (string-match "^400 "
5525 (nnheader-get-report backend)))
5526 ;; If we get 400 server disconnect, reconnect and
5527 ;; retry; otherwise, assume the article has expired.
5528 (setq result 'done))))
5529 (and (eq result 'article) 'article)))
5533 ;; Associate this article with the current summary buffer.
5534 (setq gnus-article-current-summary gnus-summary-buffer)
5536 ;; Take the article from the original article buffer
5537 ;; and place it in the buffer it's supposed to be in.
5538 (when (and (get-buffer gnus-article-buffer)
5539 (equal (buffer-name (current-buffer))
5540 (buffer-name (get-buffer gnus-article-buffer))))
5542 (if (get-buffer gnus-original-article-buffer)
5543 (set-buffer gnus-original-article-buffer)
5544 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5545 (buffer-disable-undo)
5546 (setq major-mode 'gnus-original-article-mode)
5547 (setq buffer-read-only t))
5548 (let (buffer-read-only)
5550 (insert-buffer-substring gnus-article-buffer))
5551 (setq gnus-original-article (cons group article)))
5554 (run-hooks 'gnus-article-decode-hook)
5555 ;; Mark article as decoded or not.
5556 (setq gnus-article-decoded-p gnus-article-decode-hook))
5558 ;; Update sparse articles.
5559 (when (and do-update-line
5560 (or (numberp article)
5562 (let ((buf (current-buffer)))
5563 (set-buffer gnus-summary-buffer)
5564 (gnus-summary-update-article do-update-line sparse-header)
5565 (gnus-summary-goto-subject do-update-line nil t)
5566 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5568 (set-buffer buf))))))
5574 (defcustom gnus-article-edit-mode-hook nil
5575 "Hook run in article edit mode buffers."
5576 :group 'gnus-article-various
5579 (defcustom gnus-article-edit-article-setup-function
5580 'gnus-article-mime-edit-article-setup
5581 "Function called to setup an editing article buffer."
5582 :group 'gnus-article-various
5585 (defvar gnus-article-edit-done-function nil)
5587 (defvar gnus-article-edit-mode-map nil)
5588 (defvar gnus-article-edit-mode nil)
5590 ;; Should we be using derived.el for this?
5591 (unless gnus-article-edit-mode-map
5592 (setq gnus-article-edit-mode-map (make-keymap))
5593 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5595 (gnus-define-keys gnus-article-edit-mode-map
5596 "\C-c?" describe-mode
5597 "\C-c\C-c" gnus-article-edit-done
5598 "\C-c\C-k" gnus-article-edit-exit
5599 "\C-c\C-f\C-t" message-goto-to
5600 "\C-c\C-f\C-o" message-goto-from
5601 "\C-c\C-f\C-b" message-goto-bcc
5602 ;;"\C-c\C-f\C-w" message-goto-fcc
5603 "\C-c\C-f\C-c" message-goto-cc
5604 "\C-c\C-f\C-s" message-goto-subject
5605 "\C-c\C-f\C-r" message-goto-reply-to
5606 "\C-c\C-f\C-n" message-goto-newsgroups
5607 "\C-c\C-f\C-d" message-goto-distribution
5608 "\C-c\C-f\C-f" message-goto-followup-to
5609 "\C-c\C-f\C-m" message-goto-mail-followup-to
5610 "\C-c\C-f\C-k" message-goto-keywords
5611 "\C-c\C-f\C-u" message-goto-summary
5612 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5613 "\C-c\C-f\C-a" message-gen-unsubscribed-mft
5614 "\C-c\C-b" message-goto-body
5615 "\C-c\C-i" message-goto-signature
5617 "\C-c\C-t" message-insert-to
5618 "\C-c\C-n" message-insert-newsgroups
5619 "\C-c\C-o" message-sort-headers
5620 "\C-c\C-e" message-elide-region
5621 "\C-c\C-v" message-delete-not-region
5622 "\C-c\C-z" message-kill-to-signature
5623 "\M-\r" message-newline-and-reformat
5624 "\C-c\C-a" mml-attach-file
5625 "\C-a" message-beginning-of-line
5627 "\M-;" comment-region)
5629 (gnus-define-keys (gnus-article-edit-wash-map
5630 "\C-c\C-w" gnus-article-edit-mode-map)
5631 "f" gnus-article-edit-full-stops))
5634 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5636 ["Fetch To" message-insert-to t]
5637 ["Fetch Newsgroups" message-insert-newsgroups t]
5639 ["To" message-goto-to t]
5640 ["From" message-goto-from t]
5641 ["Subject" message-goto-subject t]
5642 ["Cc" message-goto-cc t]
5643 ["Reply-To" message-goto-reply-to t]
5644 ["Summary" message-goto-summary t]
5645 ["Keywords" message-goto-keywords t]
5646 ["Newsgroups" message-goto-newsgroups t]
5647 ["Followup-To" message-goto-followup-to t]
5648 ["Mail-Followup-To" message-goto-mail-followup-to t]
5649 ["Distribution" message-goto-distribution t]
5650 ["Body" message-goto-body t]
5651 ["Signature" message-goto-signature t]))
5653 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5654 "Major mode for editing articles.
5655 This is an extended text-mode.
5657 \\{gnus-article-edit-mode-map}"
5658 (make-local-variable 'gnus-article-edit-done-function)
5659 (make-local-variable 'gnus-prev-winconf)
5660 (set (make-local-variable 'font-lock-defaults)
5661 '(message-font-lock-keywords t))
5662 (set (make-local-variable 'mail-header-separator) "")
5663 (set (make-local-variable 'gnus-article-edit-mode) t)
5664 (easy-menu-add message-mode-field-menu message-mode-map)
5665 (setq buffer-read-only nil)
5666 (buffer-enable-undo)
5669 (defun gnus-article-edit (&optional force)
5670 "Edit the current article.
5671 This will have permanent effect only in mail groups.
5672 If FORCE is non-nil, allow editing of articles even in read-only
5675 (when (and (not force)
5676 (gnus-group-read-only-p))
5677 (error "The current newsgroup does not support article editing"))
5678 (gnus-article-date-original)
5679 (gnus-article-edit-article
5681 `(lambda (no-highlight)
5683 (gnus-summary-edit-article-done
5684 ,(or (mail-header-references gnus-current-headers) "")
5685 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5687 (defun gnus-article-edit-article (start-func exit-func)
5688 "Start editing the contents of the current article buffer."
5689 (let ((winconf (current-window-configuration)))
5690 (set-buffer gnus-article-buffer)
5691 (gnus-article-edit-mode)
5692 (funcall start-func)
5693 (set-buffer-modified-p nil)
5694 (gnus-configure-windows 'edit-article)
5695 (setq gnus-article-edit-done-function exit-func)
5696 (setq gnus-prev-winconf winconf)
5697 (when gnus-article-edit-article-setup-function
5698 (funcall gnus-article-edit-article-setup-function))
5699 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5701 (defun gnus-article-edit-done (&optional arg)
5702 "Update the article edits and exit."
5704 (let ((func gnus-article-edit-done-function)
5705 (buf (current-buffer))
5706 (start (window-start))
5708 (winconf gnus-prev-winconf))
5709 (remove-hook 'gnus-article-mode-hook
5710 'gnus-article-mime-edit-article-unwind)
5711 (widen) ;; Widen it in case that users narrowed the buffer.
5714 ;; The cache and backlog have to be flushed somewhat.
5715 (when gnus-keep-backlog
5716 (gnus-backlog-remove-article
5717 (car gnus-article-current) (cdr gnus-article-current)))
5718 ;; Flush original article as well.
5720 (when (get-buffer gnus-original-article-buffer)
5721 (set-buffer gnus-original-article-buffer)
5722 (setq gnus-original-article nil)))
5723 (when gnus-use-cache
5724 (gnus-cache-update-article
5725 (car gnus-article-current) (cdr gnus-article-current)))
5726 ;; We remove all text props from the article buffer.
5727 (kill-all-local-variables)
5728 (gnus-set-text-properties (point-min) (point-max) nil)
5730 (set-window-configuration winconf)
5732 (set-window-start (get-buffer-window buf) start)
5733 (set-window-point (get-buffer-window buf) (point))))
5735 (defun gnus-article-edit-exit ()
5736 "Exit the article editing without updating."
5738 (when (or (not (buffer-modified-p))
5739 (yes-or-no-p "Article modified; kill anyway? "))
5740 (let ((curbuf (current-buffer))
5742 (window-start (window-start)))
5744 (if (gnus-buffer-live-p gnus-original-article-buffer)
5745 (insert-buffer-substring gnus-original-article-buffer))
5746 (let ((winconf gnus-prev-winconf))
5747 (kill-all-local-variables)
5749 (set-window-configuration winconf)
5750 ;; Tippy-toe some to make sure that point remains where it was.
5751 (save-current-buffer
5753 (set-window-start (get-buffer-window (current-buffer)) window-start)
5756 (defun gnus-article-edit-full-stops ()
5757 "Interactively repair spacing at end of sentences."
5760 (goto-char (point-min))
5761 (search-forward-regexp "^$" nil t)
5762 (let ((case-fold-search nil))
5763 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5766 ;;; Article editing with MIME-Edit
5769 (defcustom gnus-article-mime-edit-article-setup-hook nil
5770 "Hook run after setting up a MIME editing article buffer."
5771 :group 'gnus-article-various
5774 (defun gnus-article-mime-edit-article-unwind ()
5775 "Unwind `gnus-article-buffer' if article editing was given up."
5776 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5777 (when (featurep 'font-lock)
5778 (setq font-lock-defaults nil)
5779 (font-lock-mode -1))
5780 (when mime-edit-mode-flag
5781 (mime-edit-exit 'nomime 'no-error)
5784 (defun gnus-article-mime-edit-article-setup ()
5785 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
5786 after replacing with the original article."
5787 (setq gnus-show-mime t)
5788 (setq gnus-article-edit-done-function
5789 `(lambda (&rest args)
5790 (when mime-edit-mode-flag
5791 (let (mime-edit-insert-user-agent-field)
5794 (goto-char (point-min))
5795 (let (case-fold-search)
5796 (when (re-search-forward
5797 (format "^%s$" (regexp-quote mail-header-separator))
5799 (replace-match "")))
5800 (apply ,gnus-article-edit-done-function args)
5803 (buffer-substring-no-properties (point-min) (point-max))
5804 (set-buffer (get-buffer-create gnus-original-article-buffer))
5806 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5807 (set-buffer gnus-article-buffer)
5808 (gnus-article-prepare-display)))
5809 (substitute-key-definition 'gnus-article-edit-done
5810 'gnus-article-mime-edit-done
5811 gnus-article-edit-mode-map)
5812 (substitute-key-definition 'gnus-article-edit-exit
5813 'gnus-article-mime-edit-exit
5814 gnus-article-edit-mode-map)
5816 (insert-buffer-substring gnus-original-article-buffer)
5817 (unless (member (with-current-buffer gnus-summary-buffer
5818 gnus-newsgroup-name)
5819 '("nndraft:delayed" "nndraft:drafts"))
5820 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
5821 (fset 'mime-edit-decode-single-part-in-buffer
5822 (lambda (&rest args)
5823 (if (let ((content-type (car args)))
5824 (and (eq 'message (mime-content-type-primary-type
5826 (eq 'rfc822 (mime-content-type-subtype
5828 (setcar (cdr args) 'not-decode-text))
5832 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
5833 (when (featurep 'font-lock)
5834 (set (make-local-variable 'font-lock-defaults)
5835 '(message-font-lock-keywords t))
5836 (font-lock-set-defaults)
5837 (turn-on-font-lock))
5838 (set-buffer-modified-p nil)
5839 (delete-other-windows)
5840 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5841 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
5843 (defun gnus-article-mime-edit-done (&optional arg)
5844 "Update the article MIME edits and exit."
5846 (when (featurep 'font-lock)
5847 (setq font-lock-defaults nil)
5848 (font-lock-mode -1))
5849 (let ((inhibit-read-only t))
5850 (gnus-article-edit-done arg)))
5852 (defun gnus-article-mime-edit-exit ()
5853 "Exit the article MIME editing without updating."
5855 (when (or (not (buffer-modified-p))
5856 (yes-or-no-p "Article modified; kill anyway? "))
5857 (when (featurep 'font-lock)
5858 (setq font-lock-defaults nil)
5859 (font-lock-mode -1))
5860 (when mime-edit-mode-flag
5861 (let (mime-edit-insert-user-agent-field)
5864 (goto-char (point-min))
5865 (let (case-fold-search)
5866 (when (re-search-forward
5867 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
5868 (replace-match "")))
5869 (let ((winconf gnus-prev-winconf))
5871 (buffer-substring-no-properties (point-min) (point-max))
5872 (set-buffer (get-buffer-create gnus-original-article-buffer))
5874 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5875 (set-buffer gnus-article-buffer)
5876 (gnus-article-prepare-display)
5877 (set-window-configuration winconf))))
5880 ;;; Article highlights
5883 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5885 ;;; Internal Variables:
5887 (defcustom gnus-button-url-regexp
5888 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5889 "\\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:]]\\)"
5890 "\\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\\)\\)")
5891 "Regular expression that matches URLs."
5892 :group 'gnus-article-buttons
5895 (defcustom gnus-button-valid-fqdn-regexp
5896 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
5898 "\\([a-z][a-z]" ;; two letter country TDLs
5899 "\\|biz\\|com\\|edu\\|gov\\|int\\|mil\\|net\\|org"
5900 "\\|aero\\|coop\\|info\\|name\\|museum"
5901 "\\|arpa\\|pro\\|uucp\\|bitnet\\|bofh" ;; old style?
5903 "Regular expression that matches a valid FQDN."
5904 :group 'gnus-article-buttons
5907 (defcustom gnus-button-man-handler 'manual-entry
5908 "Function to use for displaying man pages.
5909 The function must take at least one argument with a string naming the
5911 :type '(choice (function-item :tag "Man" manual-entry)
5912 (function-item :tag "Woman" woman)
5913 (function :tag "Other"))
5914 :group 'gnus-article-buttons)
5916 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5917 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5918 If the default site is too slow, try to find a CTAN mirror, see
5919 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5920 the variable `gnus-button-handle-ctan'."
5921 :group 'gnus-article-buttons
5922 :link '(custom-manual "(gnus)Group Parameters")
5923 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5924 (const "http://tug.ctan.org/tex-archive/")
5925 (const "http://www.dante.de/CTAN/")
5926 (string :tag "Other")))
5928 (defcustom gnus-button-ctan-handler 'browse-url
5929 "Function to use for displaying CTAN links.
5930 The function must take one argument, the string naming the URL."
5931 :type '(choice (function-item :tag "Browse Url" browse-url)
5932 (function :tag "Other"))
5933 :group 'gnus-article-buttons)
5935 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5936 "Bogus strings removed from CTAN URLs."
5937 :group 'gnus-article-buttons
5938 :type '(choice (const "^/?tex-archive/\\|/")
5939 (regexp :tag "Other")))
5941 (defcustom gnus-button-mid-or-mail-regexp
5942 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
5943 gnus-button-valid-fqdn-regexp
5945 "Regular expression that matches a message ID or a mail address."
5946 :group 'gnus-article-buttons
5949 (defcustom gnus-button-prefer-mid-or-mail 'guess
5950 "What to do when the button on a string as \"foo123@bar.com\" is pushed.
5951 Strings like this can be either a message ID or a mail address. If the
5952 variable is set to the symbol `ask', query the user what do do. If it is the
5953 symbol `guess', Gnus will do a guess and query the user what do do if it is
5954 ambiguous. See the variable `gnus-button-guessed-mid-regexp' for details
5955 concerning the guessing. If it is one of the sybols `mid' or `mail', Gnus
5956 will always assume that the string is a message ID or a mail address,
5958 ;; FIXME: doc-string could/should be improved.
5959 :group 'gnus-article-buttons
5960 :type '(choice (const ask)
5965 (defcustom gnus-button-guessed-mid-regexp
5967 "^<?\\(slrn\\|Pine\\.\\)"
5968 "\\|\\.fsf@\\|\\.fsf_-_@\\|\\.ln@"
5969 "\\|@4ax\\.com\\|@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de"
5970 "\\|^<?.*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*@")
5971 "Regular expression that matches message IDs and not mail addresses."
5972 ;; TODO: Incorporate more matches from
5973 ;; <URL:http://piology.org/perl/id-or-mail.pl.html>. I.e. translate the
5974 ;; Perl-REs to Elisp-REs.
5975 :group 'gnus-article-buttons
5978 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5979 (let* ((pref gnus-button-prefer-mid-or-mail)
5980 (url-mid (concat "news" ":" mid-or-mail))
5981 (url-mailto (concat "mailto" ":" mid-or-mail)))
5982 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5983 ;; If it looks like a MID (well known readers or servers) use 'mid,
5984 ;; otherwise 'ask the user.
5985 (if (eq pref 'guess)
5986 (if (string-match gnus-button-guessed-mid-regexp mid-or-mail)
5990 (save-window-excursion
5991 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5994 (cond ((eq pref 'mid)
5995 (gnus-message 9 "calling `gnus-button-handle-news' %s" url-mid)
5996 (gnus-button-handle-news url-mid))
5998 (gnus-message 9 "calling `gnus-url-mailto' %s" url-mailto)
5999 (gnus-url-mailto url-mailto)))))
6001 (defun gnus-button-handle-custom (url)
6002 "Follow a Custom URL."
6003 (customize-apropos (gnus-url-unhex-string url)))
6005 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6007 (defun gnus-button-handle-describe-function (url)
6008 "Call describe-function when pushing the corresponding URL button."
6011 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6013 (defun gnus-button-handle-describe-variable (url)
6014 "Call describe-variable when pushing the corresponding URL button."
6017 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6019 ;; FIXME: Is is possible to implement this? Else it should be removed here
6020 ;; and in `gnus-button-alist'.
6021 (defun gnus-button-handle-describe-key (url)
6022 "Call describe-key when pushing the corresponding URL button."
6023 (error "not implemented"))
6025 (defun gnus-button-handle-apropos (url)
6026 "Call apropos when pushing the corresponding URL button."
6027 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6029 (defun gnus-button-handle-apropos-command (url)
6030 "Call apropos when pushing the corresponding URL button."
6032 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6034 (defun gnus-button-handle-apropos-variable (url)
6035 "Call apropos when pushing the corresponding URL button."
6037 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6038 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6040 (defun gnus-button-handle-apropos-documentation (url)
6041 "Call apropos when pushing the corresponding URL button."
6043 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6044 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6046 (defun gnus-button-handle-ctan (url)
6047 "Call `browse-url' when pushing a CTAN URL button."
6049 gnus-button-ctan-handler
6052 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6054 (defcustom gnus-button-tex-level 5
6055 "*Integer that says how many TeX-related buttons Gnus will show.
6056 The higher the number, the more buttons will appear and the more false
6057 positives are possible. Note that you can set this variable local to
6058 specifific groups. Setting it higher in TeX groups is probably a good idea.
6059 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6060 how to set variables in specific groups."
6061 :group 'gnus-article-buttons
6062 :link '(custom-manual "(gnus)Group Parameters")
6065 (defcustom gnus-button-man-level 5
6066 "*Integer that says how many man-related buttons Gnus will show.
6067 The higher the number, the more buttons will appear and the more false
6068 positives are possible. Note that you can set this variable local to
6069 specifific groups. Setting it higher in Unix groups is probably a good idea.
6070 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6071 how to set variables in specific groups."
6072 :group 'gnus-article-buttons
6073 :link '(custom-manual "(gnus)Group Parameters")
6076 (defcustom gnus-button-emacs-level 5
6077 "*Integer that says how many emacs-related buttons Gnus will show.
6078 The higher the number, the more buttons will appear and the more false
6079 positives are possible. Note that you can set this variable local to
6080 specifific groups. Setting it higher in Emacs or Gnus related groups is
6081 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6082 `gnus-parameters' on how to set variables in specific groups."
6083 :group 'gnus-article-buttons
6084 :link '(custom-manual "(gnus)Group Parameters")
6087 (defcustom gnus-button-mail-level 5
6088 "*Integer that says how many buttons for message IDs or mail addresses will appear.
6089 The higher the number, the more buttons will appear and the more false
6090 positives are possible."
6091 :group 'gnus-article-buttons
6094 (defcustom gnus-button-alist
6095 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6096 0 t gnus-button-handle-news 3)
6097 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6098 gnus-button-handle-news 2)
6099 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6101 gnus-button-fetch-group 4)
6102 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
6103 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
6104 t gnus-button-message-id 3)
6105 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
6106 ("mailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
6107 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
6109 ("\\bCTAN:[ \t\n]*\\([^>)!;:,\n\t ]*\\)" 0 (>= gnus-button-tex-level 1)
6110 gnus-button-handle-ctan 1)
6112 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
6113 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2)
6115 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
6116 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6117 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6118 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6119 ;; Emacs help commands
6120 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6121 ;; regexp doesn't match arguments containing ` '.
6122 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6123 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6124 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6125 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6126 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6127 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6128 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6129 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6130 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6131 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6132 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6133 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+" 0
6134 ;; this regexp needs to be fixed!
6135 (>= gnus-button-emacs-level 9) gnus-button-handle-describe-key 2)
6136 ;; This is how URLs _should_ be embedded in text...
6137 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
6139 (gnus-button-url-regexp 0 t browse-url 0)
6141 ("\\b\\([a-z][a-z]+\\)([1-9])\\W" 0
6142 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6143 gnus-button-handle-man 1)
6144 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6145 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W" 0
6146 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6147 gnus-button-handle-man 1)
6148 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6149 ;; SoWWWAnchor(3iv), XSelectInput(3X11)
6150 ("\\b\\([a-z][-_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W" 0
6151 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6152 ;; MID or mail: To avoid too many false positives we don't try to catch
6153 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6154 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6155 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6156 ;; so that non-ambiguous entries (see above) match first.
6157 (gnus-button-mid-or-mail-regexp
6158 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1))
6159 "*Alist of regexps matching buttons in article bodies.
6161 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6162 REGEXP: is the string (case insensitive) matching text around the button (can
6163 also be lisp expression evaluating to a string),
6164 BUTTON: is the number of the regexp grouping actually matching the button,
6165 FORM: is a lisp expression which must eval to true for the button to
6167 CALLBACK: is the function to call when the user push this button, and each
6168 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6170 CALLBACK can also be a variable, in that case the value of that
6171 variable it the real callback function."
6172 :group 'gnus-article-buttons
6173 :type '(repeat (list (choice regexp variable)
6174 (integer :tag "Button")
6176 (function :tag "Callback")
6179 (integer :tag "Regexp group")))))
6181 (defcustom gnus-header-button-alist
6182 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
6183 0 t gnus-button-message-id 0)
6184 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
6185 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6186 0 t gnus-button-mailto 0)
6187 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
6188 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
6189 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
6190 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
6191 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
6192 gnus-button-message-id 3))
6193 "*Alist of headers and regexps to match buttons in article heads.
6195 This alist is very similar to `gnus-button-alist', except that each
6196 alist has an additional HEADER element first in each entry:
6198 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6200 HEADER is a regexp to match a header. For a fuller explanation, see
6201 `gnus-button-alist'."
6202 :group 'gnus-article-buttons
6203 :group 'gnus-article-headers
6204 :type '(repeat (list (regexp :tag "Header")
6206 (integer :tag "Button")
6208 (function :tag "Callback")
6211 (integer :tag "Regexp group")))))
6213 (defvar gnus-button-regexp nil)
6214 (defvar gnus-button-marker-list nil)
6215 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6217 (defvar gnus-button-last nil)
6218 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6222 (defun gnus-article-push-button (event)
6223 "Check text under the mouse pointer for a callback function.
6224 If the text under the mouse pointer has a `gnus-callback' property,
6225 call it with the value of the `gnus-data' text property."
6227 (set-buffer (window-buffer (posn-window (event-start event))))
6228 (let* ((pos (posn-point (event-start event)))
6229 (data (get-text-property pos 'gnus-data))
6230 (fun (get-text-property pos 'gnus-callback)))
6233 (funcall fun data))))
6235 (defun gnus-article-press-button ()
6236 "Check text at point for a callback function.
6237 If the text at point has a `gnus-callback' property,
6238 call it with the value of the `gnus-data' text property."
6240 (let* ((data (get-text-property (point) 'gnus-data))
6241 (fun (get-text-property (point) 'gnus-callback)))
6243 (funcall fun data))))
6245 (defun gnus-article-prev-button (n)
6246 "Move point to N buttons backward.
6247 If N is negative, move forward instead."
6249 (gnus-article-next-button (- n)))
6251 (defun gnus-article-next-button (n)
6252 "Move point to N buttons forward.
6253 If N is negative, move backward instead."
6255 (let ((function (if (< n 0) 'previous-single-property-change
6256 'next-single-property-change))
6257 (inhibit-point-motion-hooks t)
6259 (limit (if (< n 0) (point-min) (point-max))))
6261 (while (and (not (= limit (point)))
6263 ;; Skip past the current button.
6264 (when (get-text-property (point) 'gnus-callback)
6265 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6266 ;; Go to the next (or previous) button.
6267 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6268 ;; Put point at the start of the button.
6269 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6270 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6271 ;; Skip past intangible buttons.
6272 (when (get-text-property (point) 'intangible)
6276 (gnus-message 5 "No more buttons"))
6279 (defun gnus-article-highlight (&optional force)
6280 "Highlight current article.
6281 This function calls `gnus-article-highlight-headers',
6282 `gnus-article-highlight-citation',
6283 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6284 do the highlighting. See the documentation for those functions."
6285 (interactive (list 'force))
6286 (gnus-article-highlight-headers)
6287 (gnus-article-highlight-citation force)
6288 (gnus-article-highlight-signature)
6289 (gnus-article-add-buttons force)
6290 (gnus-article-add-buttons-to-head))
6292 (defun gnus-article-highlight-some (&optional force)
6293 "Highlight current article.
6294 This function calls `gnus-article-highlight-headers',
6295 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6296 do the highlighting. See the documentation for those functions."
6297 (interactive (list 'force))
6298 (gnus-article-highlight-headers)
6299 (gnus-article-highlight-signature)
6300 (gnus-article-add-buttons))
6302 (defun gnus-article-highlight-headers ()
6303 "Highlight article headers as specified by `gnus-header-face-alist'."
6306 (set-buffer gnus-article-buffer)
6308 (let ((alist gnus-header-face-alist)
6309 (buffer-read-only nil)
6310 (case-fold-search t)
6311 (inhibit-point-motion-hooks t)
6312 entry regexp header-face field-face from hpoints fpoints)
6313 (article-narrow-to-head)
6314 (while (setq entry (pop alist))
6315 (goto-char (point-min))
6316 (setq regexp (concat "^\\("
6317 (if (string-equal "" (nth 0 entry))
6321 header-face (nth 1 entry)
6322 field-face (nth 2 entry))
6323 (while (and (re-search-forward regexp nil t)
6327 (unless (search-forward ":" nil t)
6329 (when (and header-face
6330 (not (memq (point) hpoints)))
6331 (push (point) hpoints)
6332 (gnus-put-text-property from (point) 'face header-face))
6333 (when (and field-face
6334 (not (memq (setq from (point)) fpoints)))
6336 (if (re-search-forward "^[^ \t]" nil t)
6338 (goto-char (point-max)))
6339 (gnus-put-text-property from (point) 'face field-face))))))))
6341 (defun gnus-article-highlight-signature ()
6342 "Highlight the signature in an article.
6343 It does this by highlighting everything after
6344 `gnus-signature-separator' using `gnus-signature-face'."
6346 (when gnus-signature-face
6348 (set-buffer gnus-article-buffer)
6349 (let ((buffer-read-only nil)
6350 (inhibit-point-motion-hooks t))
6352 (when (gnus-article-narrow-to-signature)
6353 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6354 'face gnus-signature-face)))))))
6356 (defun gnus-article-buttonize-signature ()
6357 "Add button to the signature."
6360 (set-buffer gnus-article-buffer)
6361 (let ((buffer-read-only nil)
6362 (inhibit-point-motion-hooks t))
6363 (when (gnus-article-search-signature)
6364 (gnus-article-add-button (match-beginning 0) (match-end 0)
6365 'gnus-signature-toggle
6366 (set-marker (make-marker)
6367 (1+ (match-end 0))))))))
6369 (defun gnus-button-in-region-p (b e prop)
6370 "Say whether PROP exists in the region."
6371 (text-property-not-all b e prop nil))
6373 (defun gnus-article-add-buttons (&optional force)
6374 "Find external references in the article and make buttons of them.
6375 \"External references\" are things like Message-IDs and URLs, as
6376 specified by `gnus-button-alist'."
6377 (interactive (list 'force))
6379 (set-buffer gnus-article-buffer)
6380 (let ((buffer-read-only nil)
6381 (inhibit-point-motion-hooks t)
6382 (case-fold-search t)
6383 (alist gnus-button-alist)
6385 ;; Remove all old markers.
6386 (let (marker entry new-list)
6387 (while (setq marker (pop gnus-button-marker-list))
6388 (if (or (< marker (point-min)) (>= marker (point-max)))
6389 (push marker new-list)
6391 (when (setq entry (gnus-button-entry))
6392 (put-text-property (match-beginning (nth 1 entry))
6393 (match-end (nth 1 entry))
6394 'gnus-callback nil))
6395 (set-marker marker nil)))
6396 (setq gnus-button-marker-list new-list))
6397 ;; We skip the headers.
6400 (while (setq entry (pop alist))
6401 (setq regexp (eval (car entry)))
6403 (while (re-search-forward regexp nil t)
6404 (let* ((start (and entry (match-beginning (nth 1 entry))))
6405 (end (and entry (match-end (nth 1 entry))))
6406 (from (match-beginning 0)))
6407 (when (and (or (eq t (nth 2 entry))
6408 (eval (nth 2 entry)))
6409 (not (gnus-button-in-region-p
6410 start end 'gnus-callback)))
6411 ;; That optional form returned non-nil, so we add the
6413 (gnus-article-add-button
6414 start end 'gnus-button-push
6415 (car (push (set-marker (make-marker) from)
6416 gnus-button-marker-list))))))))))
6418 ;; Add buttons to the head of an article.
6419 (defun gnus-article-add-buttons-to-head ()
6420 "Add buttons to the head of the article."
6423 (set-buffer gnus-article-buffer)
6425 (let ((buffer-read-only nil)
6426 (inhibit-point-motion-hooks t)
6427 (case-fold-search t)
6428 (alist gnus-header-button-alist)
6430 (article-narrow-to-head)
6432 ;; Each alist entry.
6433 (setq entry (car alist)
6435 (goto-char (point-min))
6436 (while (re-search-forward (car entry) nil t)
6437 ;; Each header matching the entry.
6438 (setq beg (match-beginning 0))
6439 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6440 (match-beginning 0))
6443 (while (re-search-forward (eval (nth 1 entry)) end t)
6444 ;; Each match within a header.
6445 (let* ((entry (cdr entry))
6446 (start (match-beginning (nth 1 entry)))
6447 (end (match-end (nth 1 entry)))
6448 (form (nth 2 entry)))
6449 (goto-char (match-end 0))
6451 (gnus-article-add-button
6452 start end (nth 3 entry)
6453 (buffer-substring (match-beginning (nth 4 entry))
6454 (match-end (nth 4 entry)))))))
6455 (goto-char end)))))))
6457 ;;; External functions:
6459 (defun gnus-article-add-button (from to fun &optional data)
6460 "Create a button between FROM and TO with callback FUN and data DATA."
6461 (when gnus-article-button-face
6462 (gnus-overlay-put (gnus-make-overlay from to)
6463 'face gnus-article-button-face))
6464 (gnus-add-text-properties
6466 (nconc (and gnus-article-mouse-face
6467 (list gnus-mouse-face-prop gnus-article-mouse-face))
6468 (list 'gnus-callback fun)
6469 (and data (list 'gnus-data data))))
6470 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6471 ;; Quote `:button-keymap' for Mule 2.3
6472 ;; but it won't work.
6473 ':button-keymap gnus-widget-button-keymap))
6475 ;;; Internal functions:
6477 (defun gnus-article-set-globals ()
6479 (set-buffer gnus-summary-buffer)
6480 (gnus-set-global-variables)))
6482 (defun gnus-signature-toggle (end)
6484 (set-buffer gnus-article-buffer)
6485 (let ((buffer-read-only nil)
6486 (inhibit-point-motion-hooks t)
6487 (limit (next-single-property-change end 'mime-view-entity
6489 (if (text-property-any end limit 'article-type 'signature)
6491 (gnus-delete-wash-type 'signature)
6492 (gnus-remove-text-properties-when
6493 'article-type 'signature end limit
6494 (cons 'article-type (cons 'signature
6495 gnus-hidden-properties))))
6496 (gnus-add-wash-type 'signature)
6497 (gnus-add-text-properties-when
6498 'article-type nil end limit
6499 (cons 'article-type (cons 'signature
6500 gnus-hidden-properties)))))
6501 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6502 (gnus-set-mode-line 'article))))
6504 (defun gnus-button-entry ()
6505 ;; Return the first entry in `gnus-button-alist' matching this place.
6506 (let ((alist gnus-button-alist)
6509 (setq entry (pop alist))
6510 (if (looking-at (eval (car entry)))
6515 (defun gnus-button-push (marker)
6516 ;; Push button starting at MARKER.
6519 (let* ((entry (gnus-button-entry))
6520 (inhibit-point-motion-hooks t)
6522 (args (mapcar (lambda (group)
6523 (let ((string (match-string group)))
6524 (gnus-set-text-properties
6525 0 (length string) nil string)
6532 (fboundp (symbol-value fun)))
6533 (apply (symbol-value fun) args))
6535 (gnus-message 1 "You must define `%S' to use this button"
6536 (cons fun args)))))))
6538 (defun gnus-parse-news-url (url)
6539 (let (scheme server group message-id articles)
6542 (goto-char (point-min))
6543 (when (looking-at "\\([A-Za-z]+\\):")
6544 (setq scheme (match-string 1))
6545 (goto-char (match-end 0)))
6546 (when (looking-at "//\\([^/]+\\)/")
6547 (setq server (match-string 1))
6548 (goto-char (match-end 0)))
6551 ((looking-at "\\(.*@.*\\)")
6552 (setq message-id (match-string 1)))
6553 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6554 (setq group (match-string 1)
6555 articles (split-string (match-string 2) "-")))
6556 ((looking-at "\\([^/]+\\)/?")
6557 (setq group (match-string 1)))
6559 (error "Unknown news URL syntax"))))
6560 (list scheme server group message-id articles)))
6562 (defun gnus-button-handle-news (url)
6564 (destructuring-bind (scheme server group message-id articles)
6565 (gnus-parse-news-url url)
6569 (set-buffer gnus-summary-buffer)
6571 (let ((gnus-refer-article-method (list (list 'nntp server))))
6572 (gnus-summary-refer-article message-id))
6573 (gnus-summary-refer-article message-id))))
6575 (gnus-button-fetch-group url)))))
6577 (defun gnus-button-handle-man (url)
6579 (funcall gnus-button-man-handler url))
6581 (defun gnus-button-handle-info (url)
6582 "Fetch an info URL."
6584 "^\\([^:/]+\\)?/\\(.*\\)"
6586 (gnus-info-find-node
6587 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6590 (gnus-url-unhex-string (match-string 2 url))))
6591 (error "Can't parse %s" url)))
6593 (defun gnus-button-message-id (message-id)
6596 (set-buffer gnus-summary-buffer)
6597 (gnus-summary-refer-article message-id)))
6599 (defun gnus-button-fetch-group (address)
6600 "Fetch GROUP specified by ADDRESS."
6601 (if (not (string-match "[:/]" address))
6602 ;; This is just a simple group url.
6603 (gnus-group-read-ephemeral-group address gnus-select-method)
6606 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6608 (error "Can't parse %s" address)
6609 (gnus-group-read-ephemeral-group
6610 (match-string 4 address)
6611 `(nntp ,(match-string 1 address)
6612 (nntp-address ,(match-string 1 address))
6613 (nntp-port-number ,(if (match-end 3)
6614 (match-string 3 address)
6617 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6619 (defun gnus-url-parse-query-string (query &optional downcase)
6620 (let (retval pairs cur key val)
6621 (setq pairs (split-string query "&"))
6623 (setq cur (car pairs)
6625 (if (not (string-match "=" cur))
6627 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6628 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6630 (setq key (downcase key)))
6631 (setq cur (assoc key retval))
6633 (setcdr cur (cons val (cdr cur)))
6634 (setq retval (cons (list key val) retval)))))
6637 (defun gnus-url-mailto (url)
6638 ;; Send mail to someone
6639 (when (string-match "mailto:/*\\(.*\\)" url)
6640 (setq url (substring url (match-beginning 1) nil)))
6641 (let (to args subject func)
6642 (if (string-match (regexp-quote "?") url)
6643 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6644 args (gnus-url-parse-query-string
6645 (substring url (match-end 0) nil) t))
6646 (setq to (gnus-url-unhex-string url)))
6647 (setq args (cons (list "to" to) args)
6648 subject (cdr-safe (assoc "subject" args)))
6651 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6654 (message-position-on-field (caar args)))
6655 (insert (mapconcat 'identity (cdar args) ", "))
6656 (setq args (cdr args)))
6659 (message-goto-subject))))
6661 (defun gnus-button-embedded-url (address)
6662 "Activate ADDRESS with `browse-url'."
6663 (browse-url (gnus-strip-whitespace address)))
6665 ;;; Next/prev buttons in the article buffer.
6667 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6668 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6670 (defvar gnus-prev-page-map
6671 (let ((map (make-sparse-keymap)))
6672 (unless (>= emacs-major-version 21)
6673 ;; XEmacs doesn't care.
6674 (set-keymap-parent map gnus-article-mode-map))
6675 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6676 (define-key map "\r" 'gnus-button-prev-page)
6679 (defun gnus-insert-prev-page-button ()
6681 (buffer-read-only nil)
6682 (situation (get-text-property (point-min) 'mime-view-situation)))
6684 gnus-prev-page-line-format nil
6685 `(,@(gnus-local-map-property gnus-prev-page-map)
6687 gnus-callback gnus-article-button-prev-page
6688 article-type annotation
6689 mime-view-situation ,situation))
6690 (widget-convert-button
6692 :action 'gnus-button-prev-page
6693 :button-keymap gnus-prev-page-map)))
6695 (defvar gnus-next-page-map
6696 (let ((map (make-sparse-keymap)))
6697 (unless (>= emacs-major-version 21)
6698 ;; XEmacs doesn't care.
6699 (set-keymap-parent map gnus-article-mode-map))
6700 (define-key map gnus-mouse-2 'gnus-button-next-page)
6701 (define-key map "\r" 'gnus-button-next-page)
6704 (defun gnus-button-next-page (&optional args more-args)
6705 "Go to the next page."
6707 (let ((win (selected-window)))
6708 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6709 (gnus-article-next-page)
6710 (select-window win)))
6712 (defun gnus-button-prev-page (&optional args more-args)
6713 "Go to the prev page."
6715 (let ((win (selected-window)))
6716 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6717 (gnus-article-prev-page)
6718 (select-window win)))
6720 (defun gnus-insert-next-page-button ()
6722 (buffer-read-only nil)
6723 (situation (get-text-property (point-min) 'mime-view-situation)))
6724 (gnus-eval-format gnus-next-page-line-format nil
6725 `(,@(gnus-local-map-property gnus-next-page-map)
6727 gnus-callback gnus-article-button-next-page
6728 article-type annotation
6729 mime-view-situation ,situation))
6730 (widget-convert-button
6732 :action 'gnus-button-next-page
6733 :button-keymap gnus-next-page-map)))
6735 (defun gnus-article-button-next-page (arg)
6736 "Go to the next page."
6738 (let ((win (selected-window)))
6739 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6740 (gnus-article-next-page)
6741 (select-window win)))
6743 (defun gnus-article-button-prev-page (arg)
6744 "Go to the prev page."
6746 (let ((win (selected-window)))
6747 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6748 (gnus-article-prev-page)
6749 (select-window win)))
6751 (defvar gnus-decode-header-methods
6752 '(mail-decode-encoded-word-region)
6753 "List of methods used to decode headers.
6755 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6756 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6757 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6758 whose names match REGEXP.
6761 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6762 mail-decode-encoded-word-region
6763 (\"chinese\" . rfc1843-decode-region))
6766 (defvar gnus-decode-header-methods-cache nil)
6768 (defun gnus-multi-decode-header (start end)
6769 "Apply the functions from `gnus-encoded-word-methods' that match."
6770 (unless (and gnus-decode-header-methods-cache
6771 (eq gnus-newsgroup-name
6772 (car gnus-decode-header-methods-cache)))
6773 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6776 (nconc gnus-decode-header-methods-cache (list x))
6777 (if (and gnus-newsgroup-name
6778 (string-match (car x) gnus-newsgroup-name))
6779 (nconc gnus-decode-header-methods-cache
6781 gnus-decode-header-methods))
6782 (let ((xlist gnus-decode-header-methods-cache))
6785 (narrow-to-region start end)
6787 (funcall (pop xlist) (point-min) (point-max))))))
6790 ;;; Treatment top-level handling.
6793 (defun gnus-treat-article (condition &optional part-number total-parts type)
6794 (let ((length (- (point-max) (point-min)))
6795 (alist gnus-treatment-function-alist)
6796 (article-goto-body-goes-to-point-min-p t)
6800 (let ((list gnus-article-treat-types))
6802 (when (string-match (pop list) type)
6803 (throw 'found t)))))))
6804 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6805 (entity (static-unless (featurep 'xemacs)
6806 (when (eq 'head condition)
6807 (get-text-property (point-min) 'mime-view-entity))))
6808 val elem buttonized)
6809 (gnus-run-hooks 'gnus-part-display-hook)
6810 (unless gnus-inhibit-treatment
6811 (dolist (elem alist)
6814 (when (gnus-buffer-live-p gnus-summary-buffer)
6815 (set-buffer gnus-summary-buffer))
6816 (symbol-value (car elem))))
6817 (when (and (or (consp val)
6819 (gnus-treat-predicate val)
6820 (or (not (get (car elem) 'highlight))
6822 (when (and (not buttonized)
6824 '(gnus-treat-hide-signature
6825 gnus-treat-highlight-signature)))
6826 (gnus-article-buttonize-signature)
6827 (setq buttonized t))
6829 (funcall (cadr elem)))))
6830 ;; FSF Emacsen does not inherit the existing text properties
6831 ;; in the new text, so we should do it for `mime-view-entity'.
6832 (static-unless (featurep 'xemacs)
6834 (put-text-property (point-min) (point-max)
6835 'mime-view-entity entity))))))
6837 ;; Dynamic variables.
6839 (defvar part-number)
6840 (defvar total-parts)
6845 (defun gnus-treat-predicate (val)
6852 (stringp (car val)))
6853 (apply 'gnus-or (mapcar `(lambda (s)
6854 (string-match s ,(or gnus-newsgroup-name "")))
6857 (let ((pred (pop val)))
6860 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6862 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6864 (not (gnus-treat-predicate (car val))))
6866 (equal (car val) type))
6868 (error "%S is not a valid predicate" pred)))))
6876 (eq part-number total-parts))
6880 (error "%S is not a valid value" val))))
6882 (defun gnus-article-encrypt-body (protocol &optional n)
6883 "Encrypt the article body."
6886 (or gnus-article-encrypt-protocol
6887 (completing-read "Encrypt protocol: "
6888 gnus-article-encrypt-protocol-alist
6890 current-prefix-arg))
6891 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6893 (error (format "Can't find the encrypt protocol %s" protocol)))
6894 (if (member gnus-newsgroup-name '("nndraft:delayed"
6897 (error "Can't encrypt the article in group %s"
6898 gnus-newsgroup-name))
6899 (gnus-summary-iterate n
6901 (set-buffer gnus-summary-buffer)
6902 (let ((mail-parse-charset gnus-newsgroup-charset)
6903 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6904 (summary-buffer gnus-summary-buffer)
6906 (gnus-set-global-variables)
6907 (when (gnus-group-read-only-p)
6908 (error "The current newsgroup does not support article encrypt"))
6909 (gnus-summary-show-article t)
6911 (or (mail-header-references gnus-current-headers) ""))
6912 (set-buffer gnus-article-buffer)
6913 (let* ((buffer-read-only nil)
6915 (mapcar (lambda (field)
6916 (and (save-restriction
6917 (message-narrow-to-head)
6918 (goto-char (point-min))
6919 (search-forward field nil t))
6921 (message-narrow-to-field)
6922 (buffer-substring (point-min) (point-max))
6923 (delete-region (point-min) (point-max))
6925 '("Content-Type:" "Content-Transfer-Encoding:"
6926 "Content-Disposition:"))))
6927 (message-narrow-to-head)
6928 (message-remove-header "MIME-Version")
6929 (goto-char (point-max))
6930 (setq point (point))
6931 (insert (apply 'concat headers))
6933 (narrow-to-region point (point-max))
6934 (let ((message-options message-options))
6935 (message-options-set 'message-sender user-mail-address)
6936 (message-options-set 'message-recipients user-mail-address)
6937 (message-options-set 'message-sign-encrypt 'not)
6939 (goto-char (point-min))
6940 (insert "MIME-Version: 1.0\n")
6942 (gnus-summary-edit-article-done
6943 references nil summary-buffer t))
6944 (when gnus-keep-backlog
6945 (gnus-backlog-remove-article
6946 (car gnus-article-current) (cdr gnus-article-current)))
6948 (when (get-buffer gnus-original-article-buffer)
6949 (set-buffer gnus-original-article-buffer)
6950 (setq gnus-original-article nil)))
6951 (when gnus-use-cache
6952 (gnus-cache-update-article
6953 (car gnus-article-current) (cdr gnus-article-current))))))))
6955 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6956 "The following specs can be used:
6957 %t The security MIME type
6960 %D Details if button is pressed")
6962 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6963 "The following specs can be used:
6964 %t The security MIME type
6967 %D Details if button is pressed")
6969 (defvar gnus-mime-security-button-line-format-alist
6970 '((?t gnus-tmp-type ?s)
6971 (?i gnus-tmp-info ?s)
6972 (?d gnus-tmp-details ?s)
6973 (?D gnus-tmp-pressed-details ?s)))
6975 (defvar gnus-mime-security-button-map
6976 (let ((map (make-sparse-keymap)))
6977 (unless (>= (string-to-number emacs-version) 21)
6978 (set-keymap-parent map gnus-article-mode-map))
6979 (define-key map gnus-mouse-2 'gnus-article-push-button)
6980 (define-key map "\r" 'gnus-article-press-button)
6983 (defvar gnus-mime-security-details-buffer nil)
6985 (defvar gnus-mime-security-button-pressed nil)
6987 (defvar gnus-mime-security-show-details-inline t
6988 "If non-nil, show details in the article buffer.")
6990 (defun gnus-mime-security-verify-or-decrypt (handle)
6991 (mm-remove-parts (cdr handle))
6992 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6993 point buffer-read-only)
6995 (goto-char (car region)))
6997 (narrow-to-region (point) (point))
6998 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6999 (let* ((mm-verify-option 'known)
7000 (mm-decrypt-option 'known)
7001 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7002 (unless (eq nparts (cdr handle))
7003 (mm-destroy-parts (cdr handle))
7004 (setcdr handle nparts))))
7005 (setq point (point))
7006 (gnus-mime-display-security handle)
7007 (goto-char (point-max)))
7009 (delete-region (point) (cdr region))
7010 (set-marker (car region) nil)
7011 (set-marker (cdr region) nil))
7014 (defun gnus-mime-security-show-details (handle)
7015 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7017 (if gnus-mime-security-show-details-inline
7018 (let ((gnus-mime-security-button-pressed t)
7019 (gnus-mime-security-button-line-format
7020 (get-text-property (point) 'gnus-line-format))
7023 (while (eq (get-text-property (point) 'gnus-line-format)
7024 gnus-mime-security-button-line-format)
7028 (narrow-to-region (point) (point))
7029 (gnus-insert-mime-security-button handle))
7030 (delete-region (point)
7031 (or (text-property-not-all
7034 gnus-mime-security-button-line-format)
7036 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7037 (with-current-buffer gnus-mime-security-details-buffer
7040 (setq gnus-mime-security-details-buffer
7041 (gnus-get-buffer-create "*MIME Security Details*")))
7042 (with-current-buffer gnus-mime-security-details-buffer
7044 (goto-char (point-min)))
7045 (pop-to-buffer gnus-mime-security-details-buffer))
7046 (gnus-message 5 "No details."))))
7048 (defun gnus-mime-security-press-button (handle)
7049 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7050 (gnus-mime-security-show-details handle)
7051 (gnus-mime-security-verify-or-decrypt handle)))
7053 (defun gnus-insert-mime-security-button (handle &optional displayed)
7054 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7057 (or (nth 2 (assoc protocol mm-verify-function-alist))
7058 (nth 2 (assoc protocol mm-decrypt-function-alist))
7060 (if (equal (car handle) "multipart/signed")
7061 " Signed" " Encrypted")
7064 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7067 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7068 gnus-tmp-pressed-details
7070 (setq gnus-tmp-details
7071 (if gnus-tmp-details
7072 (concat "\n" gnus-tmp-details) ""))
7073 (setq gnus-tmp-pressed-details
7074 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7079 gnus-mime-security-button-line-format
7080 gnus-mime-security-button-line-format-alist
7081 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7082 gnus-callback gnus-mime-security-press-button
7083 gnus-line-format ,gnus-mime-security-button-line-format
7084 article-type annotation
7087 (widget-convert-button
7090 :action 'gnus-widget-press-button
7091 :button-keymap gnus-mime-security-button-map
7093 (lambda (widget/window &optional overlay pos)
7094 ;; Needed to properly clear the message due to a bug in
7095 ;; wid-edit (XEmacs only).
7096 (if (boundp 'help-echo-owns-message)
7097 (setq help-echo-owns-message t))
7100 (aref gnus-mouse-2 0))))))
7102 (defun gnus-mime-display-security (handle)
7104 (narrow-to-region (point) (point))
7105 (unless (gnus-unbuttonized-mime-type-p (car handle))
7106 (gnus-insert-mime-security-button handle))
7107 (gnus-mime-display-mixed (cdr handle))
7110 (unless (gnus-unbuttonized-mime-type-p (car handle))
7111 (let ((gnus-mime-security-button-line-format
7112 gnus-mime-security-button-end-line-format))
7113 (gnus-insert-mime-security-button handle)))
7114 (mm-set-handle-multipart-parameter
7116 (cons (set-marker (make-marker) (point-min))
7117 (set-marker (make-marker) (point-max))))))
7123 (defun gnus-article-header-presentation-method (entity situation)
7124 (mime-insert-header entity)
7125 (article-decode-group-name))
7127 (set-alist 'mime-header-presentation-method-alist
7128 'gnus-original-article-mode
7129 #'gnus-article-header-presentation-method)
7131 (defun gnus-mime-preview-quitting-method ()
7132 (mime-preview-kill-buffer)
7133 (delete-other-windows)
7134 (gnus-article-show-summary)
7135 (gnus-summary-select-article gnus-show-all-headers t))
7137 (set-alist 'mime-preview-quitting-method-alist
7138 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7140 (set-alist 'mime-preview-following-method-alist
7141 'gnus-original-article-mode #'gnus-following-method)
7143 (set-alist 'mime-preview-over-to-previous-method-alist
7144 'gnus-original-article-mode
7146 (if (> (point-min) 1)
7147 (gnus-article-prev-page)
7148 (gnus-article-read-summary-keys
7149 nil (gnus-character-to-event ?P)))))
7151 (set-alist 'mime-preview-over-to-next-method-alist
7152 'gnus-original-article-mode'
7154 (if (< (point-max) (buffer-size))
7155 (gnus-article-next-page)
7156 (gnus-article-read-summary-keys
7157 nil (gnus-character-to-event ?N)))))
7167 (run-hooks 'gnus-art-load-hook)
7169 ;;; gnus-art.el ends here