1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
33 (defvar w3m-minor-mode-map))
48 (autoload 'gnus-msg-mail "gnus-msg" nil t)
49 (autoload 'gnus-button-mailto "gnus-msg")
50 (autoload 'gnus-button-reply "gnus-msg" nil t)
51 (autoload 'parse-time-string "parse-time" nil nil)
53 (defgroup gnus-article nil
55 :link '(custom-manual "(gnus)Article Buffer")
58 (defgroup gnus-article-treat nil
59 "Treating article parts."
60 :link '(custom-manual "(gnus)Article Hiding")
63 (defgroup gnus-article-hiding nil
64 "Hiding article parts."
65 :link '(custom-manual "(gnus)Article Hiding")
68 (defgroup gnus-article-highlight nil
69 "Article highlighting."
70 :link '(custom-manual "(gnus)Article Highlighting")
74 (defgroup gnus-article-signature nil
76 :link '(custom-manual "(gnus)Article Signature")
79 (defgroup gnus-article-headers nil
81 :link '(custom-manual "(gnus)Hiding Headers")
84 (defgroup gnus-article-washing nil
85 "Special commands on articles."
86 :link '(custom-manual "(gnus)Article Washing")
89 (defgroup gnus-article-emphasis nil
90 "Fontisizing articles."
91 :link '(custom-manual "(gnus)Article Fontisizing")
94 (defgroup gnus-article-saving nil
96 :link '(custom-manual "(gnus)Saving Articles")
99 (defgroup gnus-article-mime nil
100 "Worshiping the MIME wonder."
101 :link '(custom-manual "(gnus)Using MIME")
102 :group 'gnus-article)
104 (defgroup gnus-article-buttons nil
105 "Pushable buttons in the article buffer."
106 :link '(custom-manual "(gnus)Article Buttons")
107 :group 'gnus-article)
109 (defgroup gnus-article-various nil
110 "Other article options."
111 :link '(custom-manual "(gnus)Misc Article")
112 :group 'gnus-article)
114 (defcustom gnus-ignored-headers
117 (concat "^" header ":"))
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" "Face" "X-DMCA-Notifications"
155 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
156 "*All headers that start with this regexp will be hidden.
157 This variable can also be a list of regexps of headers to be ignored.
158 If `gnus-visible-headers' is non-nil, this variable will be ignored."
159 :type '(choice :custom-show nil
162 :group 'gnus-article-hiding)
164 (defcustom gnus-visible-headers
165 "^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:"
166 "*All headers that do not match this regexp will be hidden.
167 This variable can also be a list of regexp of headers to remain visible.
168 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
169 :type '(repeat :value-to-internal (lambda (widget value)
170 (custom-split-regexp-maybe value))
171 :match (lambda (widget value)
173 (widget-editable-list-match widget value)))
175 :group 'gnus-article-hiding)
177 (defcustom gnus-sorted-header-list
178 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
179 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
180 "*This variable is a list of regular expressions.
181 If it is non-nil, headers that match the regular expressions will
182 be placed first in the article buffer in the sequence specified by
184 :type '(repeat regexp)
185 :group 'gnus-article-hiding)
187 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
188 "Headers that are only to be displayed if they have interesting data.
189 Possible values in this list are:
191 'empty Headers with no content.
192 'newsgroups Newsgroup identical to Gnus group.
193 'to-address To identical to To-address.
194 'to-list To identical to To-list.
195 'cc-list CC identical to To-list.
196 'followup-to Followup-to identical to Newsgroups.
197 'reply-to Reply-to identical to From.
198 'date Date less than four days old.
199 'long-to To and/or Cc longer than 1024 characters.
200 'many-to Multiple To and/or Cc."
201 :type '(set (const :tag "Headers with no content." empty)
202 (const :tag "Newsgroups identical to Gnus group." newsgroups)
203 (const :tag "To identical to To-address." to-address)
204 (const :tag "To identical to To-list." to-list)
205 (const :tag "CC identical to To-list." cc-list)
206 (const :tag "Followup-to identical to Newsgroups." followup-to)
207 (const :tag "Reply-to identical to From." reply-to)
208 (const :tag "Date less than four days old." date)
209 (const :tag "To and/or Cc longer than 1024 characters." long-to)
210 (const :tag "Multiple To and/or Cc headers." many-to))
211 :group 'gnus-article-hiding)
213 (defcustom gnus-article-skip-boring nil
214 "Skip over text that is not worth reading.
215 By default, if you set this t, then Gnus will display citations and
216 signatures, but will never scroll down to show you a page consisting
217 only of boring text. Boring text is controlled by
218 `gnus-article-boring-faces'."
221 :group 'gnus-article-hiding)
223 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
224 "Regexp matching signature separator.
225 This can also be a list of regexps. In that case, it will be checked
226 from head to tail looking for a separator. Searches will be done from
227 the end of the buffer."
228 :type '(repeat string)
229 :group 'gnus-article-signature)
231 (defcustom gnus-signature-limit nil
232 "Provide a limit to what is considered a signature.
233 If it is a number, no signature may not be longer (in characters) than
234 that number. If it is a floating point number, no signature may be
235 longer (in lines) than that number. If it is a function, the function
236 will be called without any parameters, and if it returns nil, there is
237 no signature in the buffer. If it is a string, it will be used as a
238 regexp. If it matches, the text in question is not a signature."
239 :type '(choice (const nil)
242 (function :value fun)
243 (regexp :value ".*"))
244 :group 'gnus-article-signature)
246 (defcustom gnus-hidden-properties '(invisible t intangible t)
247 "Property list to use for hiding text."
249 :group 'gnus-article-hiding)
251 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
252 ;; frames in a session.
253 (defcustom gnus-article-x-face-command
254 (if (featurep 'xemacs)
255 (if (or (gnus-image-type-available-p 'xface)
256 (gnus-image-type-available-p 'pbm))
257 'gnus-display-x-face-in-from
258 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
259 (if (gnus-image-type-available-p 'pbm)
260 'gnus-display-x-face-in-from
261 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
263 "*String or function to be executed to display an X-Face header.
264 If it is a string, the command will be executed in a sub-shell
265 asynchronously. The compressed face will be piped to this command."
266 :type `(choice string
267 (function-item gnus-display-x-face-in-from)
271 :group 'gnus-article-washing)
273 (defcustom gnus-article-x-face-too-ugly nil
274 "Regexp matching posters whose face shouldn't be shown automatically."
275 :type '(choice regexp (const nil))
276 :group 'gnus-article-washing)
278 (defcustom gnus-article-banner-alist nil
279 "Banner alist for stripping.
281 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
283 :type '(repeat (cons symbol regexp))
284 :group 'gnus-article-washing)
286 (gnus-define-group-parameter
289 "Alist of regexps (to match group names) and banner."
290 :variable-group gnus-article-washing
292 '(choice :tag "Banner"
294 (const :tag "Remove signature" signature)
295 (symbol :tag "Item in `gnus-article-banner-alist'" none)
297 (const :tag "None" nil))
299 "If non-nil, specify how to remove `banners' from articles.
301 Symbol `signature' means to remove signatures delimited by
302 `gnus-signature-separator'. Any other symbol is used to look up a
303 regular expression to match the banner in `gnus-article-banner-alist'.
304 A string is used as a regular expression to match the banner
307 (defcustom gnus-article-address-banner-alist nil
308 "Alist of mail addresses and banners.
309 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
310 to match a mail address in the From: header, BANNER is one of a symbol
311 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
312 If ADDRESS matches author's mail address, it will remove things like
313 advertisements. For example:
315 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
319 (regexp :tag "Address")
320 (choice :tag "Banner" :value nil
321 (const :tag "Remove signature" signature)
322 (symbol :tag "Item in `gnus-article-banner-alist'" none)
324 (const :tag "None" nil))))
326 :group 'gnus-article-washing)
328 (defmacro gnus-emphasis-custom-with-format (&rest body)
330 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
331 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
334 (defun gnus-emphasis-custom-value-to-external (value)
335 (gnus-emphasis-custom-with-format
336 (if (consp (car value))
337 (list (format format (car (car value)) (cdr (car value)))
339 (if (nth 1 value) 2 3)
343 (defun gnus-emphasis-custom-value-to-internal (value)
344 (gnus-emphasis-custom-with-format
345 (let ((regexp (concat "\\`"
346 (format (regexp-quote format)
347 "\\([^()]+\\)" "\\([^()]+\\)")
350 (if (string-match regexp (setq pattern (car value)))
351 (list (cons (match-string 1 pattern) (match-string 2 pattern))
356 (defcustom gnus-emphasis-alist
358 '(("\\*" "\\*" bold nil 2)
361 ("_/" "/_" underline-italic)
362 ("_\\*" "\\*_" underline-bold)
363 ("\\*/" "/\\*" bold-italic)
364 ("_\\*/" "/\\*_" underline-bold-italic))))
366 (gnus-emphasis-custom-with-format
367 (mapcar (lambda (spec)
368 (list (format format (car spec) (cadr spec))
371 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
373 '(;; I've never seen anyone use this strikethru convention whereas I've
374 ;; several times seen it triggered by normal text. --Stef
375 ;; Miles suggests that this form is sometimes used but for italics,
376 ;; so maybe we should map it to `italic'.
377 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
378 ;; 2 3 gnus-emphasis-strikethru)
379 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
380 2 3 gnus-emphasis-underline))))
381 "*Alist that says how to fontify certain phrases.
382 Each item looks like this:
384 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
386 The first element is a regular expression to be matched. The second
387 is a number that says what regular expression grouping used to find
388 the entire emphasized word. The third is a number that says what
389 regexp grouping should be displayed and highlighted. The fourth
390 is the face used for highlighting."
394 :format "%[Customizing Style%]\n%v"
396 (group :tag "Default"
397 :value ("" 0 0 default)
400 (let ((value (widget-get
401 (cadr (widget-get (widget-get widget :parent)
404 (if (not (eq (nth 2 value) 'default))
408 (gnus-emphasis-custom-value-to-external value))))
409 (widget-group-value-create widget))
411 (integer :format "Match group: %v")
412 (integer :format "Emphasize group: %v")
415 :value (("_" . "_") nil default)
417 (regexp :format "Start regexp: %v")
418 (regexp :format "End regexp: %v"))
419 (boolean :format "Show start and end patterns: %[%v%]\n"
420 :on " On " :off " Off ")
422 :get (lambda (symbol)
423 (mapcar 'gnus-emphasis-custom-value-to-internal
424 (default-value symbol)))
425 :set (lambda (symbol value)
426 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
428 :group 'gnus-article-emphasis)
430 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
431 "A regexp to describe whitespace which should not be emphasized.
432 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
433 The former avoids underlining of leading and trailing whitespace,
434 and the latter avoids underlining any whitespace at all."
436 :group 'gnus-article-emphasis
439 (defface gnus-emphasis-bold '((t (:bold t)))
440 "Face used for displaying strong emphasized text (*word*)."
441 :group 'gnus-article-emphasis)
443 (defface gnus-emphasis-italic '((t (:italic t)))
444 "Face used for displaying italic emphasized text (/word/)."
445 :group 'gnus-article-emphasis)
447 (defface gnus-emphasis-underline '((t (:underline t)))
448 "Face used for displaying underlined emphasized text (_word_)."
449 :group 'gnus-article-emphasis)
451 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
452 "Face used for displaying underlined bold emphasized text (_*word*_)."
453 :group 'gnus-article-emphasis)
455 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
456 "Face used for displaying underlined italic emphasized text (_/word/_)."
457 :group 'gnus-article-emphasis)
459 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
460 "Face used for displaying bold italic emphasized text (/*word*/)."
461 :group 'gnus-article-emphasis)
463 (defface gnus-emphasis-underline-bold-italic
464 '((t (:bold t :italic t :underline t)))
465 "Face used for displaying underlined bold italic emphasized text.
466 Example: (_/*word*/_)."
467 :group 'gnus-article-emphasis)
469 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
470 '((t (:strikethru t)))
471 '((t (:strike-through t))))
472 "Face used for displaying strike-through text (-word-)."
473 :group 'gnus-article-emphasis)
475 (defface gnus-emphasis-highlight-words
476 '((t (:background "black" :foreground "yellow")))
477 "Face used for displaying highlighted words."
478 :group 'gnus-article-emphasis)
480 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
481 "Format for display of Date headers in article bodies.
482 See `format-time-string' for the possible values.
484 The variable can also be function, which should return a complete Date
485 header. The function is called with one argument, the time, which can
486 be fed to `format-time-string'."
487 :type '(choice string symbol)
488 :link '(custom-manual "(gnus)Article Date")
489 :group 'gnus-article-washing)
491 (defcustom gnus-save-all-headers t
492 "*If non-nil, don't remove any headers before saving."
493 :group 'gnus-article-saving
496 (defcustom gnus-prompt-before-saving 'always
497 "*This variable says how much prompting is to be done when saving articles.
498 If it is nil, no prompting will be done, and the articles will be
499 saved to the default files. If this variable is `always', each and
500 every article that is saved will be preceded by a prompt, even when
501 saving large batches of articles. If this variable is neither nil not
502 `always', there the user will be prompted once for a file name for
503 each invocation of the saving commands."
504 :group 'gnus-article-saving
505 :type '(choice (item always)
506 (item :tag "never" nil)
507 (sexp :tag "once" :format "%t\n" :value t)))
509 (defcustom gnus-saved-headers gnus-visible-headers
510 "Headers to keep if `gnus-save-all-headers' is nil.
511 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
512 If that variable is nil, however, all headers that match this regexp
513 will be kept while the rest will be deleted before saving."
514 :group 'gnus-article-saving
517 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
518 "A function to save articles in your favourite format.
519 The function must be interactively callable (in other words, it must
520 be an Emacs command).
522 Gnus provides the following functions:
524 * gnus-summary-save-in-rmail (Rmail format)
525 * gnus-summary-save-in-mail (Unix mail format)
526 * gnus-summary-save-in-folder (MH folder)
527 * gnus-summary-save-in-file (article format)
528 * gnus-summary-save-body-in-file (article body)
529 * gnus-summary-save-in-vm (use VM's folder format)
530 * gnus-summary-write-to-file (article format -- overwrite)."
531 :group 'gnus-article-saving
532 :type '(radio (function-item gnus-summary-save-in-rmail)
533 (function-item gnus-summary-save-in-mail)
534 (function-item gnus-summary-save-in-folder)
535 (function-item gnus-summary-save-in-file)
536 (function-item gnus-summary-save-body-in-file)
537 (function-item gnus-summary-save-in-vm)
538 (function-item gnus-summary-write-to-file)))
540 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
541 "A function generating a file name to save articles in Rmail format.
542 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
543 :group 'gnus-article-saving
546 (defcustom gnus-mail-save-name 'gnus-plain-save-name
547 "A function generating a file name to save articles in Unix mail format.
548 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
549 :group 'gnus-article-saving
552 (defcustom gnus-folder-save-name 'gnus-folder-save-name
553 "A function generating a file name to save articles in MH folder.
554 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
555 :group 'gnus-article-saving
558 (defcustom gnus-file-save-name 'gnus-numeric-save-name
559 "A function generating a file name to save articles in article format.
560 The function is called with NEWSGROUP, HEADERS, and optional
562 :group 'gnus-article-saving
565 (defcustom gnus-split-methods
566 '((gnus-article-archive-name)
567 (gnus-article-nndoc-name))
568 "*Variable used to suggest where articles are to be saved.
569 For instance, if you would like to save articles related to Gnus in
570 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
571 you could set this variable to something like:
573 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
574 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
576 This variable is an alist where the where the key is the match and the
577 value is a list of possible files to save in if the match is non-nil.
579 If the match is a string, it is used as a regexp match on the
580 article. If the match is a symbol, that symbol will be funcalled
581 from the buffer of the article to be saved with the newsgroup as the
582 parameter. If it is a list, it will be evaled in the same buffer.
584 If this form or function returns a string, this string will be used as
585 a possible file name; and if it returns a non-nil list, that list will
586 be used as possible file names."
587 :group 'gnus-article-saving
588 :type '(repeat (choice (list :value (fun) function)
589 (cons :value ("" "") regexp (repeat string))
592 (defcustom gnus-page-delimiter "^\^L"
593 "*Regexp describing what to use as article page delimiters.
594 The default value is \"^\^L\", which is a form linefeed at the
595 beginning of a line."
597 :group 'gnus-article-various)
599 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
600 "*The format specification for the article mode line.
601 See `gnus-summary-mode-line-format' for a closer description.
603 The following additional specs are available:
605 %w The article washing status.
606 %m The number of MIME parts in the article."
608 :group 'gnus-article-various)
610 (defcustom gnus-article-mode-hook nil
611 "*A hook for Gnus article mode."
613 :group 'gnus-article-various)
615 (when (featurep 'xemacs)
616 ;; Extracted from gnus-xmas-define in order to preserve user settings
617 (when (fboundp 'turn-off-scroll-in-place)
618 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
619 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
620 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
622 (defcustom gnus-article-menu-hook nil
623 "*Hook run after the creation of the article mode menu."
625 :group 'gnus-article-various)
627 (defcustom gnus-article-prepare-hook nil
628 "*A hook called after an article has been prepared in the article buffer."
630 :group 'gnus-article-various)
632 (make-obsolete-variable 'gnus-article-hide-pgp-hook
633 "This variable is obsolete in Gnus 5.10.")
635 (defcustom gnus-article-button-face 'bold
636 "Face used for highlighting buttons in the article buffer.
638 An article button is a piece of text that you can activate by pressing
639 `RET' or `mouse-2' above it."
641 :group 'gnus-article-buttons)
643 (defcustom gnus-article-mouse-face 'highlight
644 "Face used for mouse highlighting in the article buffer.
646 Article buttons will be displayed in this face when the cursor is
649 :group 'gnus-article-buttons)
651 (defcustom gnus-signature-face 'gnus-signature
652 "Face used for highlighting a signature in the article buffer.
653 Obsolete; use the face `gnus-signature' for customizations instead."
655 :group 'gnus-article-highlight
656 :group 'gnus-article-signature)
658 (defface gnus-signature
661 "Face used for highlighting a signature in the article buffer."
662 :group 'gnus-article-highlight
663 :group 'gnus-article-signature)
664 ;; backward-compatibility alias
665 (put 'gnus-signature-face 'face-alias 'gnus-signature)
667 (defface gnus-header-from
670 (:foreground "spring green"))
673 (:foreground "red3"))
676 "Face used for displaying from headers."
677 :group 'gnus-article-headers
678 :group 'gnus-article-highlight)
679 ;; backward-compatibility alias
680 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
682 (defface gnus-header-subject
685 (:foreground "SeaGreen3"))
688 (:foreground "red4"))
690 (:bold t :italic t)))
691 "Face used for displaying subject headers."
692 :group 'gnus-article-headers
693 :group 'gnus-article-highlight)
694 ;; backward-compatibility alias
695 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
697 (defface gnus-header-newsgroups
700 (:foreground "yellow" :italic t))
703 (:foreground "MidnightBlue" :italic t))
706 "Face used for displaying newsgroups headers.
707 In the default setup this face is only used for crossposted
709 :group 'gnus-article-headers
710 :group 'gnus-article-highlight)
711 ;; backward-compatibility alias
712 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
714 (defface gnus-header-name
717 (:foreground "SeaGreen"))
720 (:foreground "maroon"))
723 "Face used for displaying header names."
724 :group 'gnus-article-headers
725 :group 'gnus-article-highlight)
726 ;; backward-compatibility alias
727 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
729 (defface gnus-header-content
732 (:foreground "forest green" :italic t))
735 (:foreground "indianred4" :italic t))
737 (:italic t))) "Face used for displaying header content."
738 :group 'gnus-article-headers
739 :group 'gnus-article-highlight)
740 ;; backward-compatibility alias
741 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
743 (defcustom gnus-header-face-alist
744 '(("From" nil gnus-header-from)
745 ("Subject" nil gnus-header-subject)
746 ("Newsgroups:.*," nil gnus-header-newsgroups)
747 ("" gnus-header-name gnus-header-content))
748 "*Controls highlighting of article headers.
750 An alist of the form (HEADER NAME CONTENT).
752 HEADER is a regular expression which should match the name of a
753 header and NAME and CONTENT are either face names or nil.
755 The name of each header field will be displayed using the face
756 specified by the first element in the list where HEADER matches
757 the header name and NAME is non-nil. Similarly, the content will
758 be displayed by the first non-nil matching CONTENT face."
759 :group 'gnus-article-headers
760 :group 'gnus-article-highlight
761 :type '(repeat (list (regexp :tag "Header")
763 (item :tag "skip" nil)
764 (face :value default))
765 (choice :tag "Content"
766 (item :tag "skip" nil)
767 (face :value default)))))
769 (defcustom gnus-article-decode-hook
770 '(article-decode-charset article-decode-encoded-words
771 article-decode-group-name article-decode-idna-rhs)
772 "*Hook run to decode charsets in articles."
773 :group 'gnus-article-headers
776 (defcustom gnus-display-mime-function 'gnus-display-mime
777 "Function to display MIME articles."
778 :group 'gnus-article-mime
781 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
782 "Function used to decode headers.")
784 (defvar gnus-article-dumbquotes-map
804 "Table for MS-to-Latin1 translation.")
806 (defcustom gnus-ignored-mime-types nil
807 "List of MIME types that should be ignored by Gnus."
809 :group 'gnus-article-mime
810 :type '(repeat regexp))
812 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
813 "List of MIME types that should not be given buttons when rendered inline.
814 See also `gnus-buttonized-mime-types' which may override this variable.
815 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
817 :group 'gnus-article-mime
818 :type '(repeat regexp))
820 (defcustom gnus-buttonized-mime-types nil
821 "List of MIME types that should be given buttons when rendered inline.
822 If set, this variable overrides `gnus-unbuttonized-mime-types'.
823 To see e.g. security buttons you could set this to
824 `(\"multipart/signed\")'.
825 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
827 :group 'gnus-article-mime
828 :type '(repeat regexp))
830 (defcustom gnus-inhibit-mime-unbuttonizing nil
831 "If non-nil, all MIME parts get buttons.
832 When nil (the default value), then some MIME parts do not get buttons,
833 as described by the variables `gnus-buttonized-mime-types' and
834 `gnus-unbuttonized-mime-types'."
836 :group 'gnus-article-mime
839 (defcustom gnus-body-boundary-delimiter "_"
840 "String used to delimit header and body.
841 This variable is used by `gnus-article-treat-body-boundary' which can
842 be controlled by `gnus-treat-body-boundary'."
844 :group 'gnus-article-various
845 :type '(choice (item :tag "None" :value nil)
848 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
850 "Defines the location of the faces database.
851 For information on obtaining this database of pretty pictures, please
852 see http://www.cs.indiana.edu/picons/ftp/index.html"
854 :type '(repeat directory)
855 :link '(url-link :tag "download"
856 "http://www.cs.indiana.edu/picons/ftp/index.html")
857 :link '(custom-manual "(gnus)Picons")
860 (defun gnus-picons-installed-p ()
861 "Say whether picons are installed on your machine."
862 (let ((installed nil))
863 (dolist (database gnus-picon-databases)
864 (when (file-exists-p database)
868 (defcustom gnus-article-mime-part-function nil
869 "Function called with a MIME handle as the argument.
870 This is meant for people who want to do something automatic based
871 on parts -- for instance, adding Vcard info to a database."
872 :group 'gnus-article-mime
873 :type '(choice (const nil)
876 (defcustom gnus-mime-multipart-functions nil
877 "An alist of MIME types to functions to display them."
879 :group 'gnus-article-mime
882 (defcustom gnus-article-date-lapsed-new-header nil
883 "Whether the X-Sent and Date headers can coexist.
884 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
885 either replace the old \"Date:\" header (if this variable is nil), or
886 be added below it (otherwise)."
888 :group 'gnus-article-headers
891 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
892 "Function called with a MIME handle as the argument.
893 This is meant for people who want to view first matched part.
894 For `undisplayed-alternative' (default), the first undisplayed
895 part or alternative part is used. For `undisplayed', the first
896 undisplayed part is used. For a function, the first part which
897 the function return t is used. For nil, the first part is
900 :group 'gnus-article-mime
902 (item :tag "first" :value nil)
903 (item :tag "undisplayed" :value undisplayed)
904 (item :tag "undisplayed or alternative"
905 :value undisplayed-alternative)
908 (defcustom gnus-mime-action-alist
909 '(("save to file" . gnus-mime-save-part)
910 ("save and strip" . gnus-mime-save-part-and-strip)
911 ("delete part" . gnus-mime-delete-part)
912 ("display as text" . gnus-mime-inline-part)
913 ("view the part" . gnus-mime-view-part)
914 ("pipe to command" . gnus-mime-pipe-part)
915 ("toggle display" . gnus-article-press-button)
916 ("toggle display" . gnus-article-view-part-as-charset)
917 ("view as type" . gnus-mime-view-part-as-type)
918 ("view internally" . gnus-mime-view-part-internally)
919 ("view externally" . gnus-mime-view-part-externally))
920 "An alist of actions that run on the MIME attachment."
921 :group 'gnus-article-mime
922 :type '(repeat (cons (string :tag "name")
926 ;;; The treatment variables
929 (defvar gnus-part-display-hook nil
930 "Hook called on parts that are to receive treatment.")
932 (defvar gnus-article-treat-custom
933 '(choice (const :tag "Off" nil)
935 (const :tag "Header" head)
936 (const :tag "Last" last)
937 (integer :tag "Less")
938 (repeat :tag "Groups" regexp)
939 (sexp :tag "Predicate")))
941 (defvar gnus-article-treat-head-custom
942 '(choice (const :tag "Off" nil)
943 (const :tag "Header" head)))
945 (defvar gnus-article-treat-types '("text/plain")
948 (defvar gnus-inhibit-treatment nil
949 "Whether to inhibit treatment.")
951 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
952 "Highlight the signature.
953 Valid values are nil, t, `head', `last', an integer or a predicate.
954 See Info node `(gnus)Customizing Articles'."
955 :group 'gnus-article-treat
956 :link '(custom-manual "(gnus)Customizing Articles")
957 :type gnus-article-treat-custom)
958 (put 'gnus-treat-highlight-signature 'highlight t)
960 (defcustom gnus-treat-buttonize 100000
962 Valid values are nil, t, `head', `last', an integer or a predicate.
963 See Info node `(gnus)Customizing Articles'."
964 :group 'gnus-article-treat
965 :link '(custom-manual "(gnus)Customizing Articles")
966 :type gnus-article-treat-custom)
967 (put 'gnus-treat-buttonize 'highlight t)
969 (defcustom gnus-treat-buttonize-head 'head
970 "Add buttons to the head.
971 Valid values are nil, t, `head', `last', an integer or a predicate.
972 See Info node `(gnus)Customizing Articles' for details."
973 :group 'gnus-article-treat
974 :link '(custom-manual "(gnus)Customizing Articles")
975 :type gnus-article-treat-head-custom)
976 (put 'gnus-treat-buttonize-head 'highlight t)
978 (defcustom gnus-treat-emphasize
979 (and (or window-system
981 (>= (string-to-number emacs-version) 21))
984 Valid values are nil, t, `head', `last', an integer or a predicate.
985 See Info node `(gnus)Customizing Articles' for details."
986 :group 'gnus-article-treat
987 :link '(custom-manual "(gnus)Customizing Articles")
988 :type gnus-article-treat-custom)
989 (put 'gnus-treat-emphasize 'highlight t)
991 (defcustom gnus-treat-strip-cr nil
992 "Remove carriage returns.
993 Valid values are nil, t, `head', `last', an integer or a predicate.
994 See Info node `(gnus)Customizing Articles' for details."
996 :group 'gnus-article-treat
997 :link '(custom-manual "(gnus)Customizing Articles")
998 :type gnus-article-treat-custom)
1000 (defcustom gnus-treat-unsplit-urls nil
1001 "Remove newlines from within URLs.
1002 Valid values are nil, t, `head', `last', an integer or a predicate.
1003 See Info node `(gnus)Customizing Articles' for details."
1005 :group 'gnus-article-treat
1006 :link '(custom-manual "(gnus)Customizing Articles")
1007 :type gnus-article-treat-custom)
1009 (defcustom gnus-treat-leading-whitespace nil
1010 "Remove leading whitespace in headers.
1011 Valid values are nil, t, `head', `last', an integer or a predicate.
1012 See Info node `(gnus)Customizing Articles' for details."
1014 :group 'gnus-article-treat
1015 :link '(custom-manual "(gnus)Customizing Articles")
1016 :type gnus-article-treat-custom)
1018 (defcustom gnus-treat-hide-headers 'head
1020 Valid values are nil, t, `head', `last', an integer or a predicate.
1021 See Info node `(gnus)Customizing Articles' for details."
1022 :group 'gnus-article-treat
1023 :link '(custom-manual "(gnus)Customizing Articles")
1024 :type gnus-article-treat-head-custom)
1026 (defcustom gnus-treat-hide-boring-headers nil
1027 "Hide boring headers.
1028 Valid values are nil, t, `head', `last', an integer or a predicate.
1029 See Info node `(gnus)Customizing Articles' for details."
1030 :group 'gnus-article-treat
1031 :link '(custom-manual "(gnus)Customizing Articles")
1032 :type gnus-article-treat-head-custom)
1034 (defcustom gnus-treat-hide-signature nil
1035 "Hide the signature.
1036 Valid values are nil, t, `head', `last', an integer or a predicate.
1037 See Info node `(gnus)Customizing Articles' for details."
1038 :group 'gnus-article-treat
1039 :link '(custom-manual "(gnus)Customizing Articles")
1040 :type gnus-article-treat-custom)
1042 (defcustom gnus-treat-fill-article nil
1044 Valid values are nil, t, `head', `last', an integer or a predicate.
1045 See Info node `(gnus)Customizing Articles' for details."
1046 :group 'gnus-article-treat
1047 :link '(custom-manual "(gnus)Customizing Articles")
1048 :type gnus-article-treat-custom)
1050 (defcustom gnus-treat-hide-citation nil
1052 Valid values are nil, t, `head', `last', an integer or a predicate.
1053 See Info node `(gnus)Customizing Articles' for details."
1054 :group 'gnus-article-treat
1055 :link '(custom-manual "(gnus)Customizing Articles")
1056 :type gnus-article-treat-custom)
1058 (defcustom gnus-treat-hide-citation-maybe nil
1060 Valid values are nil, t, `head', `last', an integer or a predicate.
1061 See Info node `(gnus)Customizing Articles' for details."
1062 :group 'gnus-article-treat
1063 :link '(custom-manual "(gnus)Customizing Articles")
1064 :type gnus-article-treat-custom)
1066 (defcustom gnus-treat-strip-list-identifiers 'head
1067 "Strip list identifiers from `gnus-list-identifiers`.
1068 Valid values are nil, t, `head', `last', an integer or a predicate.
1069 See Info node `(gnus)Customizing Articles' for details."
1071 :group 'gnus-article-treat
1072 :link '(custom-manual "(gnus)Customizing Articles")
1073 :type gnus-article-treat-custom)
1075 (make-obsolete-variable 'gnus-treat-strip-pgp
1076 "This option is obsolete in Gnus 5.10.")
1078 (defcustom gnus-treat-strip-pem nil
1079 "Strip PEM signatures.
1080 Valid values are nil, t, `head', `last', an integer or a predicate.
1081 See Info node `(gnus)Customizing Articles' for details."
1082 :group 'gnus-article-treat
1083 :link '(custom-manual "(gnus)Customizing Articles")
1084 :type gnus-article-treat-custom)
1086 (defcustom gnus-treat-strip-banner t
1087 "Strip banners from articles.
1088 The banner to be stripped is specified in the `banner' group parameter.
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-custom)
1095 (defcustom gnus-treat-highlight-headers 'head
1096 "Highlight the headers.
1097 Valid values are nil, t, `head', `last', an integer or a predicate.
1098 See Info node `(gnus)Customizing Articles' for details."
1099 :group 'gnus-article-treat
1100 :link '(custom-manual "(gnus)Customizing Articles")
1101 :type gnus-article-treat-head-custom)
1102 (put 'gnus-treat-highlight-headers 'highlight t)
1104 (defcustom gnus-treat-highlight-citation t
1105 "Highlight cited text.
1106 Valid values are nil, t, `head', `last', an integer or a predicate.
1107 See Info node `(gnus)Customizing Articles' for details."
1108 :group 'gnus-article-treat
1109 :link '(custom-manual "(gnus)Customizing Articles")
1110 :type gnus-article-treat-custom)
1111 (put 'gnus-treat-highlight-citation 'highlight t)
1113 (defcustom gnus-treat-date-ut nil
1114 "Display the Date in UT (GMT).
1115 Valid values are nil, t, `head', `last', an integer or a predicate.
1116 See Info node `(gnus)Customizing Articles' for details."
1117 :group 'gnus-article-treat
1118 :link '(custom-manual "(gnus)Customizing Articles")
1119 :type gnus-article-treat-head-custom)
1121 (defcustom gnus-treat-date-local nil
1122 "Display the Date in the local timezone.
1123 Valid values are nil, t, `head', `last', an integer or a predicate.
1124 See Info node `(gnus)Customizing Articles' for details."
1125 :group 'gnus-article-treat
1126 :link '(custom-manual "(gnus)Customizing Articles")
1127 :type gnus-article-treat-head-custom)
1129 (defcustom gnus-treat-date-english nil
1130 "Display the Date in a format that can be read aloud in English.
1131 Valid values are nil, t, `head', `last', an integer or a predicate.
1132 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-head-custom)
1138 (defcustom gnus-treat-date-lapsed nil
1139 "Display the Date header in a way that says how much time has elapsed.
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-head-custom)
1146 (defcustom gnus-treat-date-original nil
1147 "Display the date in the original timezone.
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-head-custom)
1154 (defcustom gnus-treat-date-iso8601 nil
1155 "Display the date in the ISO8601 format.
1156 Valid values are nil, t, `head', `last', an integer or a predicate.
1157 See Info node `(gnus)Customizing Articles' for details."
1159 :group 'gnus-article-treat
1160 :link '(custom-manual "(gnus)Customizing Articles")
1161 :type gnus-article-treat-head-custom)
1163 (defcustom gnus-treat-date-user-defined nil
1164 "Display the date in a user-defined format.
1165 The format is defined by the `gnus-article-time-format' variable.
1166 Valid values are nil, t, `head', `last', an integer or a predicate.
1167 See Info node `(gnus)Customizing Articles' for details."
1168 :group 'gnus-article-treat
1169 :link '(custom-manual "(gnus)Customizing Articles")
1170 :type gnus-article-treat-head-custom)
1172 (defcustom gnus-treat-strip-headers-in-body t
1173 "Strip the X-No-Archive header line from the beginning of the body.
1174 Valid values are nil, t, `head', `last', an integer or a predicate.
1175 See Info node `(gnus)Customizing Articles' for details."
1177 :group 'gnus-article-treat
1178 :link '(custom-manual "(gnus)Customizing Articles")
1179 :type gnus-article-treat-custom)
1181 (defcustom gnus-treat-strip-trailing-blank-lines nil
1182 "Strip trailing blank lines.
1183 Valid values are nil, t, `head', `last', an integer or a predicate.
1184 See Info node `(gnus)Customizing Articles' for details.
1186 When set to t, it also strips trailing blanks in all MIME parts.
1187 Consider to use `last' instead."
1188 :group 'gnus-article-treat
1189 :link '(custom-manual "(gnus)Customizing Articles")
1190 :type gnus-article-treat-custom)
1192 (defcustom gnus-treat-strip-leading-blank-lines nil
1193 "Strip leading blank lines.
1194 Valid values are nil, t, `head', `last', an integer or a predicate.
1195 See Info node `(gnus)Customizing Articles' for details.
1197 When set to t, it also strips trailing blanks in all MIME parts."
1198 :group 'gnus-article-treat
1199 :link '(custom-manual "(gnus)Customizing Articles")
1200 :type gnus-article-treat-custom)
1202 (defcustom gnus-treat-strip-multiple-blank-lines nil
1203 "Strip multiple blank lines.
1204 Valid values are nil, t, `head', `last', an integer or a predicate.
1205 See Info node `(gnus)Customizing Articles' for details."
1206 :group 'gnus-article-treat
1207 :link '(custom-manual "(gnus)Customizing Articles")
1208 :type gnus-article-treat-custom)
1210 (defcustom gnus-treat-unfold-headers 'head
1211 "Unfold folded header lines.
1212 Valid values are nil, t, `head', `last', an integer or a predicate.
1213 See Info node `(gnus)Customizing Articles' for details."
1215 :group 'gnus-article-treat
1216 :link '(custom-manual "(gnus)Customizing Articles")
1217 :type gnus-article-treat-custom)
1219 (defcustom gnus-treat-fold-headers nil
1221 Valid values are nil, t, `head', `last', an integer or a predicate.
1222 See Info node `(gnus)Customizing Articles' for details."
1224 :group 'gnus-article-treat
1225 :link '(custom-manual "(gnus)Customizing Articles")
1226 :type gnus-article-treat-custom)
1228 (defcustom gnus-treat-fold-newsgroups 'head
1229 "Fold the Newsgroups and Followup-To headers.
1230 Valid values are nil, t, `head', `last', an integer or a predicate.
1231 See Info node `(gnus)Customizing Articles' for details."
1233 :group 'gnus-article-treat
1234 :link '(custom-manual "(gnus)Customizing Articles")
1235 :type gnus-article-treat-custom)
1237 (defcustom gnus-treat-overstrike t
1238 "Treat overstrike highlighting.
1239 Valid values are nil, t, `head', `last', an integer or a predicate.
1240 See Info node `(gnus)Customizing Articles' for details."
1241 :group 'gnus-article-treat
1242 :link '(custom-manual "(gnus)Customizing Articles")
1243 :type gnus-article-treat-custom)
1244 (put 'gnus-treat-overstrike 'highlight t)
1246 (make-obsolete-variable 'gnus-treat-display-xface
1247 'gnus-treat-display-x-face)
1249 (defcustom gnus-treat-display-x-face
1250 (and (not noninteractive)
1251 (or (and (fboundp 'image-type-available-p)
1252 (image-type-available-p 'xbm)
1253 (string-match "^0x" (shell-command-to-string "uncompface"))
1254 (executable-find "icontopbm"))
1255 (and (featurep 'xemacs)
1258 "Display X-Face headers.
1259 Valid values are nil, t, `head', `last', an integer or a predicate.
1260 See Info node `(gnus)Customizing Articles' and Info node
1261 `(gnus)X-Face' for details."
1262 :group 'gnus-article-treat
1264 :link '(custom-manual "(gnus)Customizing Articles")
1265 :link '(custom-manual "(gnus)X-Face")
1266 :type gnus-article-treat-head-custom
1267 :set (lambda (symbol value)
1270 (cond ((or (boundp symbol) (get symbol 'saved-value))
1272 ((boundp 'gnus-treat-display-xface)
1274 ** gnus-treat-display-xface is an obsolete variable;\
1275 use gnus-treat-display-x-face instead")
1276 (default-value 'gnus-treat-display-xface))
1277 ((get 'gnus-treat-display-xface 'saved-value)
1279 ** gnus-treat-display-xface is an obsolete variable;\
1280 use gnus-treat-display-x-face instead")
1281 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1284 (put 'gnus-treat-display-x-face 'highlight t)
1286 (defcustom gnus-treat-display-face
1287 (and (not noninteractive)
1288 (or (and (fboundp 'image-type-available-p)
1289 (image-type-available-p 'png))
1290 (and (featurep 'xemacs)
1293 "Display Face headers.
1294 Valid values are nil, t, `head', `last', an integer or a predicate.
1295 See Info node `(gnus)Customizing Articles' and Info node
1296 `(gnus)X-Face' for details."
1297 :group 'gnus-article-treat
1299 :link '(custom-manual "(gnus)Customizing Articles")
1300 :link '(custom-manual "(gnus)X-Face")
1301 :type gnus-article-treat-head-custom)
1302 (put 'gnus-treat-display-face 'highlight t)
1304 (defcustom gnus-treat-display-smileys
1305 (if (or (and (featurep 'xemacs)
1307 (and (fboundp 'image-type-available-p)
1308 (image-type-available-p 'pbm)))
1311 Valid values are nil, t, `head', `last', an integer or a predicate.
1312 See Info node `(gnus)Customizing Articles' and Info node
1313 `(gnus)Smileys' for details."
1314 :group 'gnus-article-treat
1316 :link '(custom-manual "(gnus)Customizing Articles")
1317 :link '(custom-manual "(gnus)Smileys")
1318 :type gnus-article-treat-custom)
1319 (put 'gnus-treat-display-smileys 'highlight t)
1321 (defcustom gnus-treat-from-picon
1322 (if (and (gnus-image-type-available-p 'xpm)
1323 (gnus-picons-installed-p))
1325 "Display picons in the From header.
1326 Valid values are nil, t, `head', `last', an integer or a predicate.
1327 See Info node `(gnus)Customizing Articles' and Info node
1328 `(gnus)Picons' for details."
1330 :group 'gnus-article-treat
1332 :link '(custom-manual "(gnus)Customizing Articles")
1333 :link '(custom-manual "(gnus)Picons")
1334 :type gnus-article-treat-head-custom)
1335 (put 'gnus-treat-from-picon 'highlight t)
1337 (defcustom gnus-treat-mail-picon
1338 (if (and (gnus-image-type-available-p 'xpm)
1339 (gnus-picons-installed-p))
1341 "Display picons in To and Cc headers.
1342 Valid values are nil, t, `head', `last', an integer or a predicate.
1343 See Info node `(gnus)Customizing Articles' and Info node
1344 `(gnus)Picons' for details."
1346 :group 'gnus-article-treat
1348 :link '(custom-manual "(gnus)Customizing Articles")
1349 :link '(custom-manual "(gnus)Picons")
1350 :type gnus-article-treat-head-custom)
1351 (put 'gnus-treat-mail-picon 'highlight t)
1353 (defcustom gnus-treat-newsgroups-picon
1354 (if (and (gnus-image-type-available-p 'xpm)
1355 (gnus-picons-installed-p))
1357 "Display picons in the Newsgroups and Followup-To headers.
1358 Valid values are nil, t, `head', `last', an integer or a predicate.
1359 See Info node `(gnus)Customizing Articles' and Info node
1360 `(gnus)Picons' for details."
1362 :group 'gnus-article-treat
1364 :link '(custom-manual "(gnus)Customizing Articles")
1365 :link '(custom-manual "(gnus)Picons")
1366 :type gnus-article-treat-head-custom)
1367 (put 'gnus-treat-newsgroups-picon 'highlight t)
1369 (defcustom gnus-treat-body-boundary
1370 (if (or gnus-treat-newsgroups-picon
1371 gnus-treat-mail-picon
1372 gnus-treat-from-picon)
1374 "Draw a boundary at the end of the headers.
1375 Valid values are nil and `head'.
1376 See Info node `(gnus)Customizing Articles' for details."
1378 :group 'gnus-article-treat
1379 :link '(custom-manual "(gnus)Customizing Articles")
1380 :type gnus-article-treat-head-custom)
1382 (defcustom gnus-treat-capitalize-sentences nil
1383 "Capitalize sentence-starting words.
1384 Valid values are nil, t, `head', `last', an integer or a predicate.
1385 See Info node `(gnus)Customizing Articles' for details."
1387 :group 'gnus-article-treat
1388 :link '(custom-manual "(gnus)Customizing Articles")
1389 :type gnus-article-treat-custom)
1391 (defcustom gnus-treat-wash-html nil
1393 Valid values are nil, t, `head', `last', an integer or a predicate.
1394 See Info node `(gnus)Customizing Articles' for details."
1396 :group 'gnus-article-treat
1397 :link '(custom-manual "(gnus)Customizing Articles")
1398 :type gnus-article-treat-custom)
1400 (defcustom gnus-treat-fill-long-lines nil
1402 Valid values are nil, t, `head', `last', an integer or a predicate.
1403 See Info node `(gnus)Customizing Articles' for details."
1404 :group 'gnus-article-treat
1405 :link '(custom-manual "(gnus)Customizing Articles")
1406 :type gnus-article-treat-custom)
1408 (defcustom gnus-treat-play-sounds nil
1410 Valid values are nil, t, `head', `last', an integer or a predicate.
1411 See Info node `(gnus)Customizing Articles' for details."
1413 :group 'gnus-article-treat
1414 :link '(custom-manual "(gnus)Customizing Articles")
1415 :type gnus-article-treat-custom)
1417 (defcustom gnus-treat-translate nil
1418 "Translate articles from one language to another.
1419 Valid values are nil, t, `head', `last', an integer or a predicate.
1420 See Info node `(gnus)Customizing Articles' for details."
1422 :group 'gnus-article-treat
1423 :link '(custom-manual "(gnus)Customizing Articles")
1424 :type gnus-article-treat-custom)
1426 (defcustom gnus-treat-x-pgp-sig nil
1428 To automatically treat X-PGP-Sig, set it to head.
1429 Valid values are nil, t, `head', `last', an integer or a predicate.
1430 See Info node `(gnus)Customizing Articles' for details."
1432 :group 'gnus-article-treat
1433 :group 'mime-security
1434 :link '(custom-manual "(gnus)Customizing Articles")
1435 :type gnus-article-treat-custom)
1437 (defvar gnus-article-encrypt-protocol-alist
1438 '(("PGP" . mml2015-self-encrypt)))
1440 ;; Set to nil if more than one protocol added to
1441 ;; gnus-article-encrypt-protocol-alist.
1442 (defcustom gnus-article-encrypt-protocol "PGP"
1443 "The protocol used for encrypt articles.
1444 It is a string, such as \"PGP\". If nil, ask user."
1447 :group 'mime-security)
1449 (defvar gnus-article-wash-function nil
1450 "Function used for converting HTML into text.")
1452 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1453 (mm-coding-system-p 'utf-8)
1454 (executable-find idna-program))
1455 "Whether IDNA decoding of headers is used when viewing messages.
1456 This requires GNU Libidn, and by default only enabled if it is found."
1458 :group 'gnus-article-headers
1461 (defcustom gnus-article-over-scroll nil
1462 "If non-nil, allow scrolling the article buffer even when there no more text."
1464 :group 'gnus-article
1467 ;;; Internal variables
1469 (defvar gnus-english-month-names
1470 '("January" "February" "March" "April" "May" "June" "July" "August"
1471 "September" "October" "November" "December"))
1473 (defvar article-goto-body-goes-to-point-min-p nil)
1474 (defvar gnus-article-wash-types nil)
1475 (defvar gnus-article-emphasis-alist nil)
1476 (defvar gnus-article-image-alist nil)
1478 (defvar gnus-article-mime-handle-alist-1 nil)
1479 (defvar gnus-treatment-function-alist
1480 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1481 (gnus-treat-strip-banner gnus-article-strip-banner)
1482 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1483 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1484 (gnus-treat-buttonize gnus-article-add-buttons)
1485 (gnus-treat-fill-article gnus-article-fill-cited-article)
1486 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1487 (gnus-treat-strip-cr gnus-article-remove-cr)
1488 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1489 (gnus-treat-date-ut gnus-article-date-ut)
1490 (gnus-treat-date-local gnus-article-date-local)
1491 (gnus-treat-date-english gnus-article-date-english)
1492 (gnus-treat-date-original gnus-article-date-original)
1493 (gnus-treat-date-user-defined gnus-article-date-user)
1494 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1495 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1496 (gnus-treat-display-x-face gnus-article-display-x-face)
1497 (gnus-treat-display-face gnus-article-display-face)
1498 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1499 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1500 (gnus-treat-hide-signature gnus-article-hide-signature)
1501 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1502 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1503 (gnus-treat-strip-pem gnus-article-hide-pem)
1504 (gnus-treat-from-picon gnus-treat-from-picon)
1505 (gnus-treat-mail-picon gnus-treat-mail-picon)
1506 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1507 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1508 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1509 (gnus-treat-strip-trailing-blank-lines
1510 gnus-article-remove-trailing-blank-lines)
1511 (gnus-treat-strip-leading-blank-lines
1512 gnus-article-strip-leading-blank-lines)
1513 (gnus-treat-strip-multiple-blank-lines
1514 gnus-article-strip-multiple-blank-lines)
1515 (gnus-treat-overstrike gnus-article-treat-overstrike)
1516 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1517 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1518 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1519 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1520 (gnus-treat-display-smileys gnus-treat-smiley)
1521 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1522 (gnus-treat-wash-html gnus-article-wash-html)
1523 (gnus-treat-emphasize gnus-article-emphasize)
1524 (gnus-treat-hide-citation gnus-article-hide-citation)
1525 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1526 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1527 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1528 (gnus-treat-play-sounds gnus-earcon-display)))
1530 (defvar gnus-article-mime-handle-alist nil)
1531 (defvar article-lapsed-timer nil)
1532 (defvar gnus-article-current-summary nil)
1534 (defvar gnus-article-mode-syntax-table
1535 (let ((table (copy-syntax-table text-mode-syntax-table)))
1536 ;; This causes the citation match run O(2^n).
1537 ;; (modify-syntax-entry ?- "w" table)
1538 (modify-syntax-entry ?> ")<" table)
1539 (modify-syntax-entry ?< "(>" table)
1540 ;; make M-. in article buffers work for `foo' strings
1541 (modify-syntax-entry ?' " " table)
1542 (modify-syntax-entry ?` " " table)
1544 "Syntax table used in article mode buffers.
1545 Initialized from `text-mode-syntax-table.")
1547 (defvar gnus-save-article-buffer nil)
1549 (defvar gnus-article-mode-line-format-alist
1550 (nconc '((?w (gnus-article-wash-status) ?s)
1551 (?m (gnus-article-mime-part-status) ?s))
1552 gnus-summary-mode-line-format-alist))
1554 (defvar gnus-number-of-articles-to-be-saved nil)
1556 (defvar gnus-inhibit-hiding nil)
1558 (defvar gnus-article-edit-mode nil)
1560 ;;; Macros for dealing with the article buffer.
1562 (defmacro gnus-with-article-headers (&rest forms)
1564 (set-buffer gnus-article-buffer)
1566 (let ((inhibit-read-only t)
1567 (inhibit-point-motion-hooks t)
1568 (case-fold-search t))
1569 (article-narrow-to-head)
1572 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1573 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1575 (defmacro gnus-with-article-buffer (&rest forms)
1577 (set-buffer gnus-article-buffer)
1578 (let ((inhibit-read-only t))
1581 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1582 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1584 (defun gnus-article-goto-header (header)
1585 "Go to HEADER, which is a regular expression."
1586 (re-search-forward (concat "^\\(" header "\\):") nil t))
1588 (defsubst gnus-article-hide-text (b e props)
1589 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1590 (gnus-add-text-properties-when 'article-type nil b e props)
1591 (when (memq 'intangible props)
1593 (max (1- b) (point-min))
1594 b 'intangible (cddr (memq 'intangible props)))))
1596 (defsubst gnus-article-unhide-text (b e)
1597 "Remove hidden text properties from region between B and E."
1598 (remove-text-properties b e gnus-hidden-properties)
1599 (when (memq 'intangible gnus-hidden-properties)
1600 (put-text-property (max (1- b) (point-min))
1601 b 'intangible nil)))
1603 (defun gnus-article-hide-text-type (b e type)
1604 "Hide text of TYPE between B and E."
1605 (gnus-add-wash-type type)
1606 (gnus-article-hide-text
1607 b e (cons 'article-type (cons type gnus-hidden-properties))))
1609 (defun gnus-article-unhide-text-type (b e type)
1610 "Unhide text of TYPE between B and E."
1611 (gnus-delete-wash-type type)
1612 (remove-text-properties
1613 b e (cons 'article-type (cons type gnus-hidden-properties)))
1614 (when (memq 'intangible gnus-hidden-properties)
1615 (put-text-property (max (1- b) (point-min))
1616 b 'intangible nil)))
1618 (defun gnus-article-hide-text-of-type (type)
1619 "Hide text of TYPE in the current buffer."
1621 (let ((b (point-min))
1623 (while (setq b (text-property-any b e 'article-type type))
1624 (add-text-properties b (incf b) gnus-hidden-properties)))))
1626 (defun gnus-article-delete-text-of-type (type)
1627 "Delete text of TYPE in the current buffer."
1629 (let ((b (point-min)))
1630 (while (setq b (text-property-any b (point-max) 'article-type type))
1632 b (or (text-property-not-all b (point-max) 'article-type type)
1635 (defun gnus-article-delete-invisible-text ()
1636 "Delete all invisible text in the current buffer."
1638 (let ((b (point-min)))
1639 (while (setq b (text-property-any b (point-max) 'invisible t))
1641 b (or (text-property-not-all b (point-max) 'invisible t)
1644 (defun gnus-article-text-type-exists-p (type)
1645 "Say whether any text of type TYPE exists in the buffer."
1646 (text-property-any (point-min) (point-max) 'article-type type))
1648 (defsubst gnus-article-header-rank ()
1649 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1650 (let ((list gnus-sorted-header-list)
1653 (if (looking-at (car list))
1655 (setq list (cdr list))
1659 (defun article-hide-headers (&optional arg delete)
1660 "Hide unwanted headers and possibly sort them as well."
1662 ;; This function might be inhibited.
1663 (unless gnus-inhibit-hiding
1664 (let ((inhibit-read-only nil)
1665 (case-fold-search t)
1666 (max (1+ (length gnus-sorted-header-list)))
1667 (inhibit-point-motion-hooks t)
1668 (cur (current-buffer))
1669 ignored visible beg)
1671 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1672 ;; group parameters, so we should go to the summary buffer.
1675 (progn (set-buffer gnus-summary-buffer) t)
1677 (setq ignored (when (not gnus-visible-headers)
1678 (cond ((stringp gnus-ignored-headers)
1679 gnus-ignored-headers)
1680 ((listp gnus-ignored-headers)
1681 (mapconcat 'identity
1682 gnus-ignored-headers
1684 visible (cond ((stringp gnus-visible-headers)
1685 gnus-visible-headers)
1686 ((and gnus-visible-headers
1687 (listp gnus-visible-headers))
1688 (mapconcat 'identity
1689 gnus-visible-headers
1693 ;; First we narrow to just the headers.
1694 (article-narrow-to-head)
1695 ;; Hide any "From " lines at the beginning of (mail) articles.
1696 (while (looking-at "From ")
1699 (delete-region (point-min) (point)))
1700 ;; Then treat the rest of the header lines.
1701 ;; Then we use the two regular expressions
1702 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1703 ;; select which header lines is to remain visible in the
1705 (while (re-search-forward "^[^ \t:]*:" nil t)
1707 ;; Mark the rank of the header.
1709 (point) (1+ (point)) 'message-rank
1710 (if (or (and visible (looking-at visible))
1712 (not (looking-at ignored))))
1713 (gnus-article-header-rank)
1716 (message-sort-headers-1)
1717 (when (setq beg (text-property-any
1718 (point-min) (point-max) 'message-rank (+ 2 max)))
1719 ;; We delete the unwanted headers.
1720 (gnus-add-wash-type 'headers)
1721 (add-text-properties (point-min) (+ 5 (point-min))
1722 '(article-type headers dummy-invisible t))
1723 (delete-region beg (point-max))))))))
1725 (defun article-hide-boring-headers (&optional arg)
1726 "Toggle hiding of headers that aren't very interesting.
1727 If given a negative prefix, always show; if given a positive prefix,
1729 (interactive (gnus-article-hidden-arg))
1730 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1731 (not gnus-show-all-headers))
1734 (let ((inhibit-read-only t)
1735 (list gnus-boring-article-headers)
1736 (inhibit-point-motion-hooks t)
1738 (article-narrow-to-head)
1740 (setq elem (pop list))
1741 (goto-char (point-min))
1743 ;; Hide empty headers.
1745 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1747 (gnus-article-hide-text-type
1751 (if (re-search-forward "^[^ \t]" nil t)
1755 ;; Hide boring Newsgroups header.
1756 ((eq elem 'newsgroups)
1757 (when (gnus-string-equal
1758 (gnus-fetch-field "newsgroups")
1759 (gnus-group-real-name
1760 (if (boundp 'gnus-newsgroup-name)
1763 (gnus-article-hide-header "newsgroups")))
1764 ((eq elem 'to-address)
1765 (let ((to (message-fetch-field "to"))
1767 (gnus-parameter-to-address
1768 (if (boundp 'gnus-newsgroup-name)
1769 gnus-newsgroup-name ""))))
1770 (when (and to to-address
1773 ;; only one address in To
1774 (nth 1 (mail-extract-address-components to))
1776 (gnus-article-hide-header "to"))))
1778 (let ((to (message-fetch-field "to"))
1780 (gnus-parameter-to-list
1781 (if (boundp 'gnus-newsgroup-name)
1782 gnus-newsgroup-name ""))))
1783 (when (and to to-list
1786 ;; only one address in To
1787 (nth 1 (mail-extract-address-components to))
1789 (gnus-article-hide-header "to"))))
1791 (let ((cc (message-fetch-field "cc"))
1793 (gnus-parameter-to-list
1794 (if (boundp 'gnus-newsgroup-name)
1795 gnus-newsgroup-name ""))))
1796 (when (and cc to-list
1799 ;; only one address in CC
1800 (nth 1 (mail-extract-address-components cc))
1802 (gnus-article-hide-header "cc"))))
1803 ((eq elem 'followup-to)
1804 (when (gnus-string-equal
1805 (message-fetch-field "followup-to")
1806 (message-fetch-field "newsgroups"))
1807 (gnus-article-hide-header "followup-to")))
1808 ((eq elem 'reply-to)
1809 (if (gnus-group-find-parameter
1810 gnus-newsgroup-name 'broken-reply-to)
1811 (gnus-article-hide-header "reply-to")
1812 (let ((from (message-fetch-field "from"))
1813 (reply-to (message-fetch-field "reply-to")))
1820 (lambda (x) (downcase (cadr x)))
1821 (mail-extract-address-components from t))
1824 (lambda (x) (downcase (cadr x)))
1825 (mail-extract-address-components reply-to t))
1827 (gnus-article-hide-header "reply-to")))))
1829 (let ((date (message-fetch-field "date")))
1831 (< (days-between (current-time-string) date)
1833 (gnus-article-hide-header "date"))))
1835 (let ((to (message-fetch-field "to"))
1836 (cc (message-fetch-field "cc")))
1837 (when (> (length to) 1024)
1838 (gnus-article-hide-header "to"))
1839 (when (> (length cc) 1024)
1840 (gnus-article-hide-header "cc"))))
1844 (goto-char (point-min))
1845 (while (re-search-forward "^to:" nil t)
1846 (setq to-count (1+ to-count)))
1847 (when (> to-count 1)
1848 (while (> to-count 0)
1849 (goto-char (point-min))
1851 (re-search-forward "^to:" nil nil to-count)
1853 (narrow-to-region (point) (point-max))
1854 (gnus-article-hide-header "to"))
1855 (setq to-count (1- to-count))))
1856 (goto-char (point-min))
1857 (while (re-search-forward "^cc:" nil t)
1858 (setq cc-count (1+ cc-count)))
1859 (when (> cc-count 1)
1860 (while (> cc-count 0)
1861 (goto-char (point-min))
1863 (re-search-forward "^cc:" nil nil cc-count)
1865 (narrow-to-region (point) (point-max))
1866 (gnus-article-hide-header "cc"))
1867 (setq cc-count (1- cc-count)))))))))))))
1869 (defun gnus-article-hide-header (header)
1871 (goto-char (point-min))
1872 (when (re-search-forward (concat "^" header ":") nil t)
1873 (gnus-article-hide-text-type
1877 (if (re-search-forward "^[^ \t]" nil t)
1882 (defvar gnus-article-normalized-header-length 40
1883 "Length of normalized headers.")
1885 (defun article-normalize-headers ()
1886 "Make all header lines 40 characters long."
1888 (let ((inhibit-read-only t)
1892 (article-narrow-to-head)
1895 ((< (setq column (- (gnus-point-at-eol) (point)))
1896 gnus-article-normalized-header-length)
1898 (insert (make-string
1899 (- gnus-article-normalized-header-length column)
1901 ((> column gnus-article-normalized-header-length)
1902 (gnus-put-text-property
1904 (forward-char gnus-article-normalized-header-length)
1911 (forward-line 1))))))
1913 (defun article-treat-dumbquotes ()
1914 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1915 Note that this function guesses whether a character is a sm*rtq**t* or
1916 not, so it should only be used interactively.
1918 Sm*rtq**t*s are M****s***'s unilateral extension to the
1919 iso-8859-1 character map in an attempt to provide more quoting
1920 characters. If you see something like \\222 or \\264 where
1921 you're expecting some kind of apostrophe or quotation mark, then
1924 (article-translate-strings gnus-article-dumbquotes-map))
1926 (defun article-translate-characters (from to)
1927 "Translate all characters in the body of the article according to FROM and TO.
1928 FROM is a string of characters to translate from; to is a string of
1929 characters to translate to."
1931 (when (article-goto-body)
1932 (let ((inhibit-read-only t)
1933 (x (make-string 225 ?x))
1935 (while (< (incf i) (length x))
1938 (while (< i (length from))
1939 (aset x (aref from i) (aref to i))
1941 (translate-region (point) (point-max) x)))))
1943 (defun article-translate-strings (map)
1944 "Translate all string in the body of the article according to MAP.
1945 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1947 (when (article-goto-body)
1948 (let ((inhibit-read-only t)
1950 (while (setq elem (pop map))
1952 (while (search-forward (car elem) nil t)
1953 (replace-match (cadr elem)))))))))
1955 (defun article-treat-overstrike ()
1956 "Translate overstrikes into bold text."
1959 (when (article-goto-body)
1960 (let ((inhibit-read-only t))
1961 (while (search-forward "\b" nil t)
1962 (let ((next (char-after))
1963 (previous (char-after (- (point) 2))))
1964 ;; We do the boldification/underlining by hiding the
1965 ;; overstrikes and putting the proper text property
1969 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1970 (put-text-property (point) (1+ (point)) 'face 'bold))
1972 (gnus-article-hide-text-type
1973 (1- (point)) (1+ (point)) 'overstrike)
1975 (- (point) 2) (1- (point)) 'face 'underline))
1977 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1979 (point) (1+ (point)) 'face 'underline)))))))))
1981 (defun gnus-article-treat-unfold-headers ()
1982 "Unfold folded message headers.
1983 Only the headers that fit into the current window width will be
1986 (gnus-with-article-headers
1990 (mail-header-narrow-to-field)
1991 (let ((header (buffer-string)))
1994 (goto-char (point-min))
1995 (while (re-search-forward "\n[\t ]" nil t)
1996 (replace-match " " t t)))
1997 (setq length (- (point-max) (point-min) 1)))
1998 (when (< length (window-width))
1999 (while (re-search-forward "\n[\t ]" nil t)
2000 (replace-match " " t t)))
2001 (goto-char (point-max)))))))
2003 (defun gnus-article-treat-fold-headers ()
2004 "Fold message headers."
2006 (gnus-with-article-headers
2009 (mail-header-narrow-to-field)
2010 (mail-header-fold-field)
2011 (goto-char (point-max))))))
2013 (defun gnus-treat-smiley ()
2014 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2016 (gnus-with-article-buffer
2017 (if (memq 'smiley gnus-article-wash-types)
2018 (gnus-delete-images 'smiley)
2020 (let ((images (smiley-region (point) (point-max))))
2022 (gnus-add-wash-type 'smiley)
2023 (dolist (image images)
2024 (gnus-add-image 'smiley image)))))))
2026 (defun gnus-article-remove-images ()
2027 "Remove all images from the article buffer."
2029 (gnus-with-article-buffer
2030 (dolist (elem gnus-article-image-alist)
2031 (gnus-delete-images (car elem)))))
2033 (defun gnus-article-treat-fold-newsgroups ()
2034 "Unfold folded message headers.
2035 Only the headers that fit into the current window width will be
2038 (gnus-with-article-headers
2039 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2041 (mail-header-narrow-to-field)
2042 (while (re-search-forward ", *" nil t)
2043 (replace-match ", " t t))
2044 (mail-header-fold-field)
2045 (goto-char (point-max))))))
2047 (defun gnus-article-treat-body-boundary ()
2048 "Place a boundary line at the end of the headers."
2050 (when (and gnus-body-boundary-delimiter
2051 (> (length gnus-body-boundary-delimiter) 0))
2052 (gnus-with-article-headers
2053 (goto-char (point-max))
2054 (let ((start (point)))
2055 (insert "X-Boundary: ")
2056 (gnus-add-text-properties start (point) '(invisible t intangible t))
2058 (while (>= (1- (window-width)) (length str))
2059 (setq str (concat str gnus-body-boundary-delimiter)))
2060 (substring str 0 (1- (window-width))))
2062 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2064 (defun article-fill-long-lines ()
2065 "Fill lines that are wider than the window width."
2068 (let ((inhibit-read-only t)
2069 (width (window-width (get-buffer-window (current-buffer)))))
2072 (let ((adaptive-fill-mode nil)) ;Why? -sm
2075 (when (>= (current-column) (min fill-column width))
2076 (narrow-to-region (min (1+ (point)) (point-max))
2077 (gnus-point-at-bol))
2078 (let ((goback (point-marker)))
2079 (fill-paragraph nil)
2080 (goto-char (marker-position goback)))
2082 (forward-line 1)))))))
2084 (defun article-capitalize-sentences ()
2085 "Capitalize the first word in each sentence."
2088 (let ((inhibit-read-only t)
2089 (paragraph-start "^[\n\^L]"))
2093 (forward-sentence)))))
2095 (defun article-remove-cr ()
2096 "Remove trailing CRs and then translate remaining CRs into LFs."
2099 (let ((inhibit-read-only t))
2100 (goto-char (point-min))
2101 (while (re-search-forward "\r+$" nil t)
2102 (replace-match "" t t))
2103 (goto-char (point-min))
2104 (while (search-forward "\r" nil t)
2105 (replace-match "\n" t t)))))
2107 (defun article-remove-trailing-blank-lines ()
2108 "Remove all trailing blank lines from the article."
2111 (let ((inhibit-read-only t))
2112 (goto-char (point-max))
2116 (while (and (not (bobp))
2117 (looking-at "^[ \t]*$")
2118 (not (gnus-annotation-in-region-p
2119 (point) (gnus-point-at-eol))))
2124 (defun article-display-face ()
2125 "Display any Face headers in the header."
2127 (let ((wash-face-p buffer-read-only))
2128 (gnus-with-article-headers
2129 ;; When displaying parts, this function can be called several times on
2130 ;; the same article, without any intended toggle semantic (as typing `W
2131 ;; D d' would have). So face deletion must occur only when we come from
2132 ;; an interactive command, that is when the *Article* buffer is
2134 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2135 (gnus-delete-images 'face)
2136 (let (face faces from)
2137 (save-current-buffer
2138 (when (and wash-face-p
2139 (gnus-buffer-live-p gnus-original-article-buffer)
2140 (not (re-search-forward "^Face:[\t ]*" nil t)))
2141 (set-buffer gnus-original-article-buffer))
2143 (mail-narrow-to-head)
2144 (while (gnus-article-goto-header "Face")
2145 (push (mail-header-field-value) faces))))
2147 (goto-char (point-min))
2148 (let ((from (gnus-article-goto-header "from"))
2153 (insert "[no `from' set]\n"))
2155 (when (setq png (gnus-convert-face-to-png (pop faces)))
2156 (setq image (gnus-create-image png 'png t))
2158 (gnus-add-wash-type 'face)
2159 (gnus-add-image 'face image)
2160 (gnus-put-image image nil 'face))))))))))
2162 (defun article-display-x-face (&optional force)
2163 "Look for an X-Face header and display it if present."
2164 (interactive (list 'force))
2165 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2166 (gnus-with-article-headers
2167 ;; Delete the old process, if any.
2168 (when (process-status "article-x-face")
2169 (delete-process "article-x-face"))
2170 ;; See the comment in `article-display-face'.
2171 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2172 ;; We have already displayed X-Faces, so we remove them
2174 (gnus-delete-images 'xface)
2176 (let (x-faces from face)
2177 (save-current-buffer
2178 (when (and wash-face-p
2179 (gnus-buffer-live-p gnus-original-article-buffer)
2180 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2181 ;; If type `W f', use gnus-original-article-buffer,
2182 ;; otherwise use the current buffer because displaying
2183 ;; RFC822 parts calls this function too.
2184 (set-buffer gnus-original-article-buffer))
2186 (mail-narrow-to-head)
2187 (while (gnus-article-goto-header "X-Face")
2188 (push (mail-header-field-value) x-faces))
2189 (setq from (message-fetch-field "from"))))
2190 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2191 ;; single external face.
2192 (when (stringp gnus-article-x-face-command)
2193 (setq x-faces (list (car x-faces))))
2195 gnus-article-x-face-command
2197 ;; Check whether this face is censored.
2198 (not gnus-article-x-face-too-ugly)
2200 (not (string-match gnus-article-x-face-too-ugly
2202 (while (setq face (pop x-faces))
2203 ;; We display the face.
2204 (cond ((stringp gnus-article-x-face-command)
2205 ;; The command is a string, so we interpret the command
2206 ;; as a, well, command, and fork it off.
2207 (let ((process-connection-type nil))
2208 (gnus-set-process-query-on-exit-flag
2210 "article-x-face" nil shell-file-name
2211 shell-command-switch gnus-article-x-face-command)
2215 (process-send-region "article-x-face"
2216 (point-min) (point-max)))
2217 (process-send-eof "article-x-face")))
2218 ((functionp gnus-article-x-face-command)
2219 ;; The command is a lisp function, so we call it.
2220 (funcall gnus-article-x-face-command face))
2222 (error "%s is not a function"
2223 gnus-article-x-face-command))))))))))
2225 (defun article-decode-mime-words ()
2226 "Decode all MIME-encoded words in the article."
2229 (set-buffer gnus-article-buffer)
2230 (let ((inhibit-point-motion-hooks t)
2231 (inhibit-read-only t)
2232 (mail-parse-charset gnus-newsgroup-charset)
2233 (mail-parse-ignored-charsets
2234 (save-excursion (set-buffer gnus-summary-buffer)
2235 gnus-newsgroup-ignored-charsets)))
2236 (mail-decode-encoded-word-region (point-min) (point-max)))))
2238 (defun article-decode-charset (&optional prompt)
2239 "Decode charset-encoded text in the article.
2240 If PROMPT (the prefix), prompt for a coding system to use."
2242 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2243 (inhibit-read-only t)
2244 (mail-parse-charset gnus-newsgroup-charset)
2245 (mail-parse-ignored-charsets
2246 (save-excursion (condition-case nil
2247 (set-buffer gnus-summary-buffer)
2249 gnus-newsgroup-ignored-charsets))
2250 ct cte ctl charset format)
2253 (article-narrow-to-head)
2254 (setq ct (message-fetch-field "Content-Type" t)
2255 cte (message-fetch-field "Content-Transfer-Encoding" t)
2256 ctl (and ct (ignore-errors
2257 (mail-header-parse-content-type ct)))
2260 (mm-read-coding-system "Charset to decode: "))
2262 (mail-content-type-get ctl 'charset)))
2263 format (and ctl (mail-content-type-get ctl 'format)))
2265 (setq cte (mail-header-strip cte)))
2266 (if (and ctl (not (string-match "/" (car ctl))))
2268 (goto-char (point-max)))
2271 (narrow-to-region (point) (point-max))
2272 (when (and (eq mail-parse-charset 'gnus-decoded)
2273 (eq (mm-body-7-or-8) '8bit))
2274 ;; The text code could have been decoded.
2275 (setq charset mail-parse-charset))
2276 (when (and (or (not ctl)
2277 (equal (car ctl) "text/plain"))
2278 (not format)) ;; article with format will decode later.
2280 charset (and cte (intern (downcase
2281 (gnus-strip-whitespace cte))))
2284 (defun article-decode-encoded-words ()
2285 "Remove encoded-word encoding from headers."
2286 (let ((inhibit-point-motion-hooks t)
2287 (mail-parse-charset gnus-newsgroup-charset)
2288 (mail-parse-ignored-charsets
2289 (save-excursion (condition-case nil
2290 (set-buffer gnus-summary-buffer)
2292 gnus-newsgroup-ignored-charsets))
2293 (inhibit-read-only t))
2295 (article-narrow-to-head)
2296 (funcall gnus-decode-header-function (point-min) (point-max)))))
2298 (defun article-decode-group-name ()
2299 "Decode group names in `Newsgroups:'."
2300 (let ((inhibit-point-motion-hooks t)
2301 (inhibit-read-only t)
2302 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2303 (when (and (or gnus-group-name-charset-method-alist
2304 gnus-group-name-charset-group-alist)
2305 (gnus-buffer-live-p gnus-original-article-buffer))
2307 (article-narrow-to-head)
2308 (with-current-buffer gnus-original-article-buffer
2309 (goto-char (point-min)))
2310 (while (re-search-forward
2311 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2312 (replace-match (save-match-data
2313 (gnus-decode-newsgroups
2314 ;; XXX how to use data in article buffer?
2315 (with-current-buffer gnus-original-article-buffer
2317 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2320 gnus-newsgroup-name method))
2322 (goto-char (point-min))
2323 (with-current-buffer gnus-original-article-buffer
2324 (goto-char (point-min)))
2325 (while (re-search-forward
2326 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2327 (replace-match (save-match-data
2328 (gnus-decode-newsgroups
2329 ;; XXX how to use data in article buffer?
2330 (with-current-buffer gnus-original-article-buffer
2332 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2335 gnus-newsgroup-name method))
2338 (autoload 'idna-to-unicode "idna")
2340 (defun article-decode-idna-rhs ()
2341 "Decode IDNA strings in RHS in various headers in current buffer.
2342 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2343 Mail-Reply-To: and Mail-Followup-To:."
2346 (let ((inhibit-point-motion-hooks t)
2347 (inhibit-read-only t))
2348 (article-narrow-to-head)
2349 (goto-char (point-min))
2350 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2352 (when (save-match-data
2353 (and (setq ace (match-string 1))
2355 (and (re-search-backward "^[^ \t]" nil t)
2356 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2357 (setq unicode (idna-to-unicode ace))))
2358 (unless (string= ace unicode)
2359 (replace-match unicode nil nil nil 1)))))))))
2361 (defun article-de-quoted-unreadable (&optional force read-charset)
2362 "Translate a quoted-printable-encoded article.
2363 If FORCE, decode the article whether it is marked as quoted-printable
2365 If READ-CHARSET, ask for a coding system."
2366 (interactive (list 'force current-prefix-arg))
2368 (let ((inhibit-read-only t) type charset)
2369 (if (gnus-buffer-live-p gnus-original-article-buffer)
2370 (with-current-buffer gnus-original-article-buffer
2372 (gnus-fetch-field "content-transfer-encoding"))
2373 (let* ((ct (gnus-fetch-field "content-type"))
2376 (mail-header-parse-content-type ct)))))
2377 (setq charset (and ctl
2378 (mail-content-type-get ctl 'charset)))
2379 (if (stringp charset)
2380 (setq charset (intern (downcase charset)))))))
2382 (setq charset (mm-read-coding-system "Charset: " charset)))
2384 (setq charset gnus-newsgroup-charset))
2386 (and type (let ((case-fold-search t))
2387 (string-match "quoted-printable" type))))
2389 (quoted-printable-decode-region
2390 (point) (point-max) (mm-charset-to-coding-system charset))))))
2392 (defun article-de-base64-unreadable (&optional force read-charset)
2393 "Translate a base64 article.
2394 If FORCE, decode the article whether it is marked as base64 not.
2395 If READ-CHARSET, ask for a coding system."
2396 (interactive (list 'force current-prefix-arg))
2398 (let ((inhibit-read-only t) type charset)
2399 (if (gnus-buffer-live-p gnus-original-article-buffer)
2400 (with-current-buffer gnus-original-article-buffer
2402 (gnus-fetch-field "content-transfer-encoding"))
2403 (let* ((ct (gnus-fetch-field "content-type"))
2406 (mail-header-parse-content-type ct)))))
2407 (setq charset (and ctl
2408 (mail-content-type-get ctl 'charset)))
2409 (if (stringp charset)
2410 (setq charset (intern (downcase charset)))))))
2412 (setq charset (mm-read-coding-system "Charset: " charset)))
2414 (setq charset gnus-newsgroup-charset))
2416 (and type (let ((case-fold-search t))
2417 (string-match "base64" type))))
2420 (narrow-to-region (point) (point-max))
2421 (base64-decode-region (point-min) (point-max))
2422 (mm-decode-coding-region
2423 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2428 (defun article-decode-HZ ()
2429 "Translate a HZ-encoded article."
2433 (let ((inhibit-read-only t))
2434 (rfc1843-decode-region (point-min) (point-max)))))
2436 (defun article-unsplit-urls ()
2437 "Remove the newlines that some other mailers insert into URLs."
2440 (let ((inhibit-read-only t))
2441 (goto-char (point-min))
2442 (while (re-search-forward
2443 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2444 (replace-match "\\1\\3" t)))
2445 (when (interactive-p)
2446 (gnus-treat-article nil))))
2449 (defun article-wash-html (&optional read-charset)
2450 "Format an HTML article.
2451 If READ-CHARSET, ask for a coding system."
2454 (let ((inhibit-read-only t)
2456 (when (gnus-buffer-live-p gnus-original-article-buffer)
2457 (with-current-buffer gnus-original-article-buffer
2458 (let* ((ct (gnus-fetch-field "content-type"))
2461 (mail-header-parse-content-type ct)))))
2462 (setq charset (and ctl
2463 (mail-content-type-get ctl 'charset)))
2464 (when (stringp charset)
2465 (setq charset (intern (downcase charset)))))))
2467 (setq charset (mm-read-coding-system "Charset: " charset)))
2469 (setq charset gnus-newsgroup-charset))
2471 (save-window-excursion
2473 (narrow-to-region (point) (point-max))
2474 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2475 (entry (assq func mm-text-html-washer-alist)))
2477 (setq func (cdr entry)))
2482 (apply (car func) (cdr func))))))))))
2484 (defun gnus-article-wash-html-with-w3 ()
2485 "Wash the current buffer with w3."
2487 (let ((w3-strict-width (window-width))
2488 (url-standalone-mode t)
2489 (url-gateway-unplugged t)
2490 (w3-honor-stylesheets nil))
2492 (w3-region (point-min) (point-max))
2495 (defun gnus-article-wash-html-with-w3m ()
2496 "Wash the current buffer with emacs-w3m."
2499 (narrow-to-region (point) (point-max))
2500 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2501 w3m-force-redisplay)
2502 (w3m-region (point-min) (point-max)))
2503 (when (and mm-inline-text-html-with-w3m-keymap
2504 (boundp 'w3m-minor-mode-map)
2506 (add-text-properties
2507 (point-min) (point-max)
2508 (list 'keymap w3m-minor-mode-map
2509 ;; Put the mark meaning this part was rendered by emacs-w3m.
2510 'mm-inline-text-html-with-w3m t)))))
2512 (defun article-hide-list-identifiers ()
2513 "Remove list identifies from the Subject header.
2514 The `gnus-list-identifiers' variable specifies what to do."
2516 (let ((inhibit-point-motion-hooks t)
2517 (regexp (if (consp gnus-list-identifiers)
2518 (mapconcat 'identity gnus-list-identifiers " *\\|")
2519 gnus-list-identifiers))
2520 (inhibit-read-only t))
2524 (article-narrow-to-head)
2525 (goto-char (point-min))
2526 (while (re-search-forward
2527 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2529 (delete-region (match-beginning 2) (match-end 0))
2530 (beginning-of-line))
2531 (when (re-search-forward
2532 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2533 (delete-region (match-beginning 1) (match-end 1))))))))
2535 (defun article-hide-pem (&optional arg)
2536 "Toggle hiding of any PEM headers and signatures in the current article.
2537 If given a negative prefix, always show; if given a positive prefix,
2539 (interactive (gnus-article-hidden-arg))
2540 (unless (gnus-article-check-hidden-text 'pem arg)
2542 (let ((inhibit-read-only t) end)
2543 (goto-char (point-min))
2544 ;; Hide the horrendously ugly "header".
2545 (when (and (search-forward
2546 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2548 (setq end (1+ (match-beginning 0))))
2549 (gnus-add-wash-type 'pem)
2550 (gnus-article-hide-text-type
2552 (if (search-forward "\n\n" nil t)
2556 ;; Hide the trailer as well
2557 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2559 (gnus-article-hide-text-type
2560 (match-beginning 0) (match-end 0) 'pem)))))))
2562 (defun article-strip-banner ()
2563 "Strip the banners specified by the `banner' group parameter and by
2564 `gnus-article-address-banner-alist'."
2568 (let ((inhibit-point-motion-hooks t))
2569 (when (gnus-parameter-banner gnus-newsgroup-name)
2570 (article-really-strip-banner
2571 (gnus-parameter-banner gnus-newsgroup-name)))
2572 (when gnus-article-address-banner-alist
2573 (article-really-strip-banner
2574 (let ((from (save-restriction
2576 (article-narrow-to-head)
2577 (mail-fetch-field "from"))))
2580 (caar (mail-header-parse-addresses from))))
2582 (dolist (pair gnus-article-address-banner-alist)
2583 (when (string-match (car pair) from)
2584 (throw 'found (cdr pair)))))))))))))
2586 (defun article-really-strip-banner (banner)
2587 "Strip the banner specified by the argument."
2590 (let ((inhibit-point-motion-hooks t)
2591 (gnus-signature-limit nil)
2592 (inhibit-read-only t))
2595 ((eq banner 'signature)
2596 (when (gnus-article-narrow-to-signature)
2599 (delete-region (point) (point-max))))
2601 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2602 (while (re-search-forward banner nil t)
2603 (delete-region (match-beginning 0) (match-end 0)))))
2605 (while (re-search-forward banner nil t)
2606 (delete-region (match-beginning 0) (match-end 0)))))))))
2608 (defun article-babel ()
2609 "Translate article using an online translation service."
2613 (set-buffer gnus-article-buffer)
2614 (when (article-goto-body)
2615 (let* ((inhibit-read-only t)
2618 (orig (buffer-substring start end))
2619 (trans (babel-as-string orig)))
2621 (narrow-to-region start end)
2622 (delete-region start end)
2625 (defun article-hide-signature (&optional arg)
2626 "Hide the signature in the current article.
2627 If given a negative prefix, always show; if given a positive prefix,
2629 (interactive (gnus-article-hidden-arg))
2630 (unless (gnus-article-check-hidden-text 'signature arg)
2633 (let ((inhibit-read-only t))
2634 (when (gnus-article-narrow-to-signature)
2635 (gnus-article-hide-text-type
2636 (point-min) (point-max) 'signature))))))
2637 (gnus-set-mode-line 'article))
2639 (defun article-strip-headers-in-body ()
2640 "Strip offensive headers from bodies."
2644 (let ((case-fold-search t))
2645 (when (looking-at "x-no-archive:")
2646 (gnus-delete-line)))))
2648 (defun article-strip-leading-blank-lines ()
2649 "Remove all blank lines from the beginning of the article."
2652 (let ((inhibit-point-motion-hooks t)
2653 (inhibit-read-only t))
2654 (when (article-goto-body)
2655 (while (and (not (eobp))
2656 (looking-at "[ \t]*$"))
2657 (gnus-delete-line))))))
2659 (defun article-narrow-to-head ()
2660 "Narrow the buffer to the head of the message.
2661 Point is left at the beginning of the narrowed-to region."
2663 (goto-char (point-min))
2664 (if (search-forward "\n\n" nil 1)
2667 (goto-char (point-min)))
2669 (defun article-goto-body ()
2670 "Place point at the start of the body."
2671 (goto-char (point-min))
2673 ;; This variable is only bound when dealing with separate
2675 (article-goto-body-goes-to-point-min-p
2677 ((search-forward "\n\n" nil t)
2680 (goto-char (point-max))
2683 (defun article-strip-multiple-blank-lines ()
2684 "Replace consecutive blank lines with one empty line."
2687 (let ((inhibit-point-motion-hooks t)
2688 (inhibit-read-only t))
2689 ;; First make all blank lines empty.
2691 (while (re-search-forward "^[ \t]+$" nil t)
2692 (unless (gnus-annotation-in-region-p
2693 (match-beginning 0) (match-end 0))
2694 (replace-match "" nil t)))
2695 ;; Then replace multiple empty lines with a single empty line.
2697 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2698 (unless (gnus-annotation-in-region-p
2699 (match-beginning 0) (match-end 0))
2700 (delete-region (match-beginning 1) (match-end 1)))))))
2702 (defun article-strip-leading-space ()
2703 "Remove all white space from the beginning of the lines in the article."
2706 (let ((inhibit-point-motion-hooks t)
2707 (inhibit-read-only t))
2709 (while (re-search-forward "^[ \t]+" nil t)
2710 (replace-match "" t t)))))
2712 (defun article-strip-trailing-space ()
2713 "Remove all white space from the end of the lines in the article."
2716 (let ((inhibit-point-motion-hooks t)
2717 (inhibit-read-only t))
2719 (while (re-search-forward "[ \t]+$" nil t)
2720 (replace-match "" t t)))))
2722 (defun article-strip-blank-lines ()
2723 "Strip leading, trailing and multiple blank lines."
2725 (article-strip-leading-blank-lines)
2726 (article-remove-trailing-blank-lines)
2727 (article-strip-multiple-blank-lines))
2729 (defun article-strip-all-blank-lines ()
2730 "Strip all blank lines."
2733 (let ((inhibit-point-motion-hooks t)
2734 (inhibit-read-only t))
2736 (while (re-search-forward "^[ \t]*\n" nil t)
2737 (replace-match "" t t)))))
2739 (defun gnus-article-narrow-to-signature ()
2740 "Narrow to the signature; return t if a signature is found, else nil."
2741 (let ((inhibit-point-motion-hooks t))
2742 (when (gnus-article-search-signature)
2744 ;; Check whether we have some limits to what we consider
2745 ;; to be a signature.
2746 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2747 (list gnus-signature-limit)))
2749 (while (setq limit (pop limits))
2750 (if (or (and (integerp limit)
2751 (< (- (point-max) (point)) limit))
2753 (< (count-lines (point) (point-max)) limit))
2754 (and (functionp limit)
2756 (and (stringp limit)
2757 (not (re-search-forward limit nil t))))
2758 () ; This limit did not succeed.
2762 (narrow-to-region (point) (point-max))
2765 (defun gnus-article-search-signature ()
2766 "Search the current buffer for the signature separator.
2767 Put point at the beginning of the signature separator."
2768 (let ((cur (point)))
2769 (goto-char (point-max))
2770 (if (if (stringp gnus-signature-separator)
2771 (re-search-backward gnus-signature-separator nil t)
2772 (let ((seps gnus-signature-separator))
2774 (not (re-search-backward (car seps) nil t)))
2781 (defun gnus-article-hidden-arg ()
2782 "Return the current prefix arg as a number, or 0 if no prefix."
2783 (list (if current-prefix-arg
2784 (prefix-numeric-value current-prefix-arg)
2787 (defun gnus-article-check-hidden-text (type arg)
2788 "Return nil if hiding is necessary.
2789 Arg can be nil or a number. nil and positive means hide, negative
2790 means show, 0 means toggle."
2793 (let ((hide (gnus-article-hidden-text-p type)))
2799 (gnus-article-show-hidden-text type)
2802 (if (eq hide 'hidden)
2804 (gnus-article-show-hidden-text type)
2808 (defun gnus-article-hidden-text-p (type)
2809 "Say whether the current buffer contains hidden text of type TYPE."
2810 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2812 (not (get-text-property pos 'invisible))
2813 (not (get-text-property pos 'dummy-invisible)))
2815 (text-property-any (1+ pos) (point-max) 'article-type type)))
2820 (defun gnus-article-show-hidden-text (type &optional dummy)
2821 "Show all hidden text of type TYPE.
2822 Originally it is hide instead of DUMMY."
2823 (let ((inhibit-read-only t)
2824 (inhibit-point-motion-hooks t))
2825 (gnus-remove-text-properties-when
2827 (point-min) (point-max)
2828 (cons 'article-type (cons type
2829 gnus-hidden-properties)))
2830 (gnus-delete-wash-type type)))
2832 (defconst article-time-units
2833 `((year . ,(* 365.25 24 60 60))
2834 (week . ,(* 7 24 60 60))
2835 (day . ,(* 24 60 60))
2839 "Mapping from time units to seconds.")
2841 (defun gnus-article-forward-header ()
2842 "Move point to the start of the next header.
2843 If the current header is a continuation header, this can be several
2848 (if (looking-at "[ \t]+[^ \t]")
2852 (defun article-date-ut (&optional type highlight)
2853 "Convert DATE date to universal time in the current article.
2854 If TYPE is `local', convert to local time; if it is `lapsed', output
2855 how much time has lapsed since DATE. For `lapsed', the value of
2856 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2857 should replace the \"Date:\" one, or should be added below it."
2858 (interactive (list 'ut t))
2859 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2860 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
2864 (article-lapsed-timer
2868 (case-fold-search t)
2869 (inhibit-read-only t)
2870 (inhibit-point-motion-hooks t)
2871 pos date bface eface)
2875 (goto-char (point-min))
2876 (while (or (setq date (get-text-property (setq pos (point))
2878 (when (setq pos (next-single-property-change
2879 (point) 'original-date))
2880 (setq date (get-text-property pos 'original-date))
2882 (narrow-to-region pos (or (text-property-any pos (point-max)
2885 (goto-char (point-min))
2886 (when (re-search-forward tdate-regexp nil t)
2887 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2888 eface (get-text-property (1- (gnus-point-at-eol)) 'face)))
2889 (goto-char (point-min))
2891 ;; Delete any old Date headers.
2892 (while (re-search-forward date-regexp nil t)
2894 (delete-region (gnus-point-at-bol)
2896 (gnus-article-forward-header)
2898 (delete-region (gnus-point-at-bol)
2900 (gnus-article-forward-header)
2903 (setq pos (point))))
2904 (when (and (not pos)
2905 (re-search-forward tdate-regexp nil t))
2907 (gnus-goto-char pos)
2908 (insert (article-make-date-line date (or type 'ut)))
2914 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2915 (put-text-property (match-beginning 1) (1+ (match-end 1))
2917 (put-text-property (match-beginning 2) (match-end 2)
2919 (put-text-property (point-min) (1- (point-max)) 'original-date date)
2920 (goto-char (point-max))
2923 (defun article-make-date-line (date type)
2924 "Return a DATE line of TYPE."
2925 (unless (memq type '(local ut original user iso8601 lapsed english))
2926 (error "Unknown conversion type: %s" type))
2928 (let ((time (date-to-time date)))
2930 ;; Convert to the local timezone.
2932 (let ((tz (car (current-time-zone time))))
2933 (format "Date: %s %s%02d%02d" (current-time-string time)
2934 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2935 (/ (% (abs tz) 3600) 60))))
2936 ;; Convert to Universal Time.
2939 (current-time-string
2940 (let* ((e (parse-time-string date))
2941 (tm (apply 'encode-time e))
2943 (ls (- (cadr tm) (car (current-time-zone time)))))
2944 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2945 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2948 ;; Get the original date from the article.
2949 ((eq type 'original)
2950 (concat "Date: " (if (string-match "\n+$" date)
2951 (substring date 0 (match-beginning 0))
2953 ;; Let the user define the format.
2955 (let ((format (or (condition-case nil
2956 (with-current-buffer gnus-summary-buffer
2957 gnus-article-time-format)
2959 gnus-article-time-format)))
2960 (if (functionp format)
2961 (funcall format time)
2962 (concat "Date: " (format-time-string format time)))))
2965 (let ((tz (car (current-time-zone time))))
2968 (format-time-string "%Y%m%dT%H%M%S" time)
2969 (format "%s%02d%02d"
2970 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2971 (/ (% (abs tz) 3600) 60)))))
2972 ;; Do an X-Sent lapsed format.
2974 ;; If the date is seriously mangled, the timezone functions are
2975 ;; liable to bug out, so we ignore all errors.
2976 (let* ((now (current-time))
2977 (real-time (subtract-time now time))
2978 (real-sec (and real-time
2979 (+ (* (float (car real-time)) 65536)
2981 (sec (and real-time (abs real-sec)))
2991 ;; This is a bit convoluted, but basically we go
2992 ;; through the time units for years, weeks, etc,
2993 ;; and divide things to see whether that results
2994 ;; in positive answers.
2997 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2998 ;; The (remaining) seconds are too few to
2999 ;; be divided into this time unit.
3001 ;; It's big enough, so we output it.
3002 (setq sec (- sec (* num (cdr unit))))
3004 (concat (if prev ", " "") (int-to-string
3006 " " (symbol-name (car unit))
3007 (if (> num 1) "s" ""))
3009 article-time-units "")
3010 ;; If dates are odd, then it might appear like the
3011 ;; article was sent in the future.
3014 " in the future"))))))
3015 ;; Display the date in proper English
3017 (let ((dtime (decode-time time)))
3020 (number-to-string (nth 3 dtime))
3021 (let ((digit (% (nth 3 dtime) 10)))
3023 ((memq (nth 3 dtime) '(11 12 13)) "th")
3029 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3031 (number-to-string (nth 5 dtime))
3033 (format "%02d" (nth 2 dtime))
3035 (format "%02d" (nth 1 dtime)))))))
3037 (format "Date: %s (from Gnus)" date))))
3039 (defun article-date-local (&optional highlight)
3040 "Convert the current article date to the local timezone."
3041 (interactive (list t))
3042 (article-date-ut 'local highlight))
3044 (defun article-date-english (&optional highlight)
3045 "Convert the current article date to something that is proper English."
3046 (interactive (list t))
3047 (article-date-ut 'english highlight))
3049 (defun article-date-original (&optional highlight)
3050 "Convert the current article date to what it was originally.
3051 This is only useful if you have used some other date conversion
3052 function and want to see what the date was before converting."
3053 (interactive (list t))
3054 (article-date-ut 'original highlight))
3056 (defun article-date-lapsed (&optional highlight)
3057 "Convert the current article date to time lapsed since it was sent."
3058 (interactive (list t))
3059 (article-date-ut 'lapsed highlight))
3061 (defun article-update-date-lapsed ()
3062 "Function to be run from a timer to update the lapsed time line."
3064 (let (deactivate-mark)
3069 (set-buffer (window-buffer w))
3070 (when (eq major-mode 'gnus-article-mode)
3071 (let ((mark (point-marker)))
3072 (goto-char (point-min))
3073 (when (re-search-forward "^X-Sent:" nil t)
3074 (article-date-lapsed t))
3075 (goto-char (marker-position mark))
3076 (move-marker mark nil))))
3079 (defun gnus-start-date-timer (&optional n)
3080 "Start a timer to update the X-Sent header in the article buffers.
3081 The numerical prefix says how frequently (in seconds) the function
3086 (gnus-stop-date-timer)
3087 (setq article-lapsed-timer
3088 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
3090 (defun gnus-stop-date-timer ()
3091 "Stop the X-Sent timer."
3093 (when article-lapsed-timer
3094 (nnheader-cancel-timer article-lapsed-timer)
3095 (setq article-lapsed-timer nil)))
3097 (defun article-date-user (&optional highlight)
3098 "Convert the current article date to the user-defined format.
3099 This format is defined by the `gnus-article-time-format' variable."
3100 (interactive (list t))
3101 (article-date-ut 'user highlight))
3103 (defun article-date-iso8601 (&optional highlight)
3104 "Convert the current article date to ISO8601."
3105 (interactive (list t))
3106 (article-date-ut 'iso8601 highlight))
3108 (defmacro gnus-article-save-original-date (&rest forms)
3109 "Save the original date as a text property and evaluate FORMS."
3110 `(let* ((case-fold-search t)
3112 (goto-char (point-min))
3113 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3116 (date (when (and start
3117 (re-search-forward "[\t ]*\n\\([^\t ]\\|\\'\\)"
3119 (buffer-substring-no-properties start
3120 (match-beginning 0)))))
3121 (goto-char (point-max))
3122 (skip-chars-backward "\n")
3123 (put-text-property (point-min) (point) 'original-date date)
3125 (goto-char (point-max))
3126 (skip-chars-backward "\n")
3127 (put-text-property (point-min) (point) 'original-date date)))
3129 ;; (defun article-show-all ()
3130 ;; "Show all hidden text in the article buffer."
3133 ;; (let ((inhibit-read-only t))
3134 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3136 (defun article-remove-leading-whitespace ()
3137 "Remove excessive whitespace from all headers."
3141 (let ((inhibit-read-only t))
3142 (article-narrow-to-head)
3143 (goto-char (point-min))
3144 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3145 (delete-region (match-beginning 1) (match-end 1)))))))
3147 (defun article-emphasize (&optional arg)
3148 "Emphasize text according to `gnus-emphasis-alist'."
3149 (interactive (gnus-article-hidden-arg))
3150 (unless (gnus-article-check-hidden-text 'emphasis arg)
3154 (with-current-buffer gnus-summary-buffer
3155 gnus-article-emphasis-alist)
3157 gnus-emphasis-alist))
3158 (inhibit-read-only t)
3159 (props (append '(article-type emphasis)
3160 gnus-hidden-properties))
3161 regexp elem beg invisible visible face)
3164 (while (setq elem (pop alist))
3166 (setq regexp (car elem)
3167 invisible (nth 1 elem)
3168 visible (nth 2 elem)
3170 (while (re-search-forward regexp nil t)
3171 (when (and (match-beginning visible) (match-beginning invisible))
3172 (gnus-article-hide-text
3173 (match-beginning invisible) (match-end invisible) props)
3174 (gnus-article-unhide-text-type
3175 (match-beginning visible) (match-end visible) 'emphasis)
3176 (gnus-put-overlay-excluding-newlines
3177 (match-beginning visible) (match-end visible) 'face face)
3178 (gnus-add-wash-type 'emphasis)
3179 (goto-char (match-end invisible)))))))))
3181 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3182 "Setup newsgroup emphasis alist."
3183 (unless gnus-article-emphasis-alist
3184 (let ((name (and gnus-newsgroup-name
3185 (gnus-group-real-name gnus-newsgroup-name))))
3186 (make-local-variable 'gnus-article-emphasis-alist)
3187 (setq gnus-article-emphasis-alist
3189 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3190 (while (setq elem (pop alist))
3191 (when (and name (string-match (car elem) name))
3193 highlight (copy-sequence (cdr elem)))))
3195 (copy-sequence highlight-words)
3196 (if gnus-newsgroup-name
3197 (copy-sequence (gnus-group-find-parameter
3198 gnus-newsgroup-name 'highlight-words t)))
3199 gnus-emphasis-alist)))))
3202 (defvar gnus-summary-article-menu)
3203 (defvar gnus-summary-post-menu))
3205 ;;; Saving functions.
3207 (defun gnus-article-save (save-buffer file &optional num)
3208 "Save the currently selected article."
3209 (unless gnus-save-all-headers
3210 ;; Remove headers according to `gnus-saved-headers'.
3211 (let ((gnus-visible-headers
3212 (or gnus-saved-headers gnus-visible-headers))
3213 (gnus-article-buffer save-buffer))
3215 (set-buffer save-buffer)
3216 (article-hide-headers 1 t))))
3217 (save-window-excursion
3218 (if (not gnus-default-article-saver)
3219 (error "No default saver is defined")
3220 ;; !!! Magic! The saving functions all save
3221 ;; `gnus-save-article-buffer' (or so they think), but we
3222 ;; bind that variable to our save-buffer.
3223 (set-buffer gnus-article-buffer)
3224 (let* ((gnus-save-article-buffer save-buffer)
3227 ((not gnus-prompt-before-saving) 'default)
3228 ((eq gnus-prompt-before-saving 'always) nil)
3230 (gnus-number-of-articles-to-be-saved
3231 (when (eq gnus-prompt-before-saving t)
3233 (set-buffer gnus-article-current-summary)
3234 (funcall gnus-default-article-saver filename)))))
3236 (defun gnus-read-save-file-name (prompt &optional filename
3237 function group headers variable)
3239 (funcall function group headers (symbol-value variable)))
3244 ((eq filename 'default)
3250 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3253 (if (and gnus-number-of-articles-to-be-saved
3254 (> gnus-number-of-articles-to-be-saved 1))
3255 (format "these %d articles"
3256 gnus-number-of-articles-to-be-saved)
3259 ;; Let the split methods have their say.
3261 ;; No split name was found.
3264 (concat prompt " (default "
3265 (file-name-nondirectory default-name) "): ")
3266 (file-name-directory default-name)
3268 ;; A single group name is returned.
3269 ((stringp split-name)
3271 (funcall function split-name headers
3272 (symbol-value variable)))
3274 (concat prompt " (default "
3275 (file-name-nondirectory default-name) "): ")
3276 (file-name-directory default-name)
3278 ;; A single split name was found
3279 ((= 1 (length split-name))
3280 (let* ((name (expand-file-name
3282 gnus-article-save-directory))
3283 (dir (cond ((file-directory-p name)
3284 (file-name-as-directory name))
3285 ((file-exists-p name) name)
3286 (t gnus-article-save-directory))))
3288 (concat prompt " (default " name "): ")
3290 ;; A list of splits was found.
3292 (setq split-name (nreverse split-name))
3294 (let ((file-name-history
3295 (nconc split-name file-name-history)))
3299 (concat prompt " (`M-p' for defaults): ")
3300 gnus-article-save-directory
3302 gnus-article-save-directory)))
3303 (car (push result file-name-history)))))))
3304 ;; Create the directory.
3305 (gnus-make-directory (file-name-directory file))
3306 ;; If we have read a directory, we append the default file name.
3307 (when (file-directory-p file)
3308 (setq file (expand-file-name (file-name-nondirectory
3310 (file-name-as-directory file))))
3311 ;; Possibly translate some characters.
3312 (nnheader-translate-file-chars file))))))
3313 (gnus-make-directory (file-name-directory result))
3314 (set variable result)))
3316 (defun gnus-article-archive-name (group)
3317 "Return the first instance of an \"Archive-name\" in the current buffer."
3318 (let ((case-fold-search t))
3319 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3320 (nnheader-concat gnus-article-save-directory
3321 (match-string 1)))))
3323 (defun gnus-article-nndoc-name (group)
3324 "If GROUP is an nndoc group, return the name of the parent group."
3325 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3326 (gnus-group-get-parameter group 'save-article-group)))
3328 (defun gnus-summary-save-in-rmail (&optional filename)
3329 "Append this article to Rmail file.
3330 Optional argument FILENAME specifies file name.
3331 Directory to save to is default to `gnus-article-save-directory'."
3332 (setq filename (gnus-read-save-file-name
3333 "Save %s in rmail file" filename
3334 gnus-rmail-save-name gnus-newsgroup-name
3335 gnus-current-headers 'gnus-newsgroup-last-rmail))
3336 (gnus-eval-in-buffer-window gnus-save-article-buffer
3340 (gnus-output-to-rmail filename))))
3343 (defun gnus-summary-save-in-mail (&optional filename)
3344 "Append this article to Unix mail file.
3345 Optional argument FILENAME specifies file name.
3346 Directory to save to is default to `gnus-article-save-directory'."
3347 (setq filename (gnus-read-save-file-name
3348 "Save %s in Unix mail file" filename
3349 gnus-mail-save-name gnus-newsgroup-name
3350 gnus-current-headers 'gnus-newsgroup-last-mail))
3351 (gnus-eval-in-buffer-window gnus-save-article-buffer
3355 (if (and (file-readable-p filename)
3356 (file-regular-p filename)
3357 (mail-file-babyl-p filename))
3358 (rmail-output-to-rmail-file filename t)
3359 (gnus-output-to-mail filename)))))
3362 (defun gnus-summary-save-in-file (&optional filename overwrite)
3363 "Append this article to file.
3364 Optional argument FILENAME specifies file name.
3365 Directory to save to is default to `gnus-article-save-directory'."
3366 (setq filename (gnus-read-save-file-name
3367 "Save %s in file" filename
3368 gnus-file-save-name gnus-newsgroup-name
3369 gnus-current-headers 'gnus-newsgroup-last-file))
3370 (gnus-eval-in-buffer-window gnus-save-article-buffer
3374 (when (and overwrite
3375 (file-exists-p filename))
3376 (delete-file filename))
3377 (gnus-output-to-file filename))))
3380 (defun gnus-summary-write-to-file (&optional filename)
3381 "Write this article to a file, overwriting it if the file exists.
3382 Optional argument FILENAME specifies file name.
3383 The directory to save in defaults to `gnus-article-save-directory'."
3384 (gnus-summary-save-in-file nil t))
3386 (defun gnus-summary-save-body-in-file (&optional filename)
3387 "Append this article body to a file.
3388 Optional argument FILENAME specifies file name.
3389 The directory to save in defaults to `gnus-article-save-directory'."
3390 (setq filename (gnus-read-save-file-name
3391 "Save %s body in file" filename
3392 gnus-file-save-name gnus-newsgroup-name
3393 gnus-current-headers 'gnus-newsgroup-last-file))
3394 (gnus-eval-in-buffer-window gnus-save-article-buffer
3398 (when (article-goto-body)
3399 (narrow-to-region (point) (point-max)))
3400 (gnus-output-to-file filename))))
3403 (defun gnus-summary-save-in-pipe (&optional command)
3404 "Pipe this article to subprocess."
3406 (cond ((and (eq command 'default)
3407 gnus-last-shell-command)
3408 gnus-last-shell-command)
3413 "Shell command on %s: "
3414 (if (and gnus-number-of-articles-to-be-saved
3415 (> gnus-number-of-articles-to-be-saved 1))
3416 (format "these %d articles"
3417 gnus-number-of-articles-to-be-saved)
3419 gnus-last-shell-command))))
3420 (when (string-equal command "")
3421 (if gnus-last-shell-command
3422 (setq command gnus-last-shell-command)
3423 (error "A command is required")))
3424 (gnus-eval-in-buffer-window gnus-article-buffer
3427 (shell-command-on-region (point-min) (point-max) command nil)))
3428 (setq gnus-last-shell-command command))
3430 (defmacro gnus-read-string (prompt &optional initial-contents history
3432 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3433 (if (and (featurep 'xemacs)
3434 (< emacs-minor-version 2))
3435 `(read-string ,prompt ,initial-contents ,history)
3436 `(read-string ,prompt ,initial-contents ,history ,default-value)))
3438 (defun gnus-summary-pipe-to-muttprint (&optional command)
3439 "Pipe this article to muttprint."
3440 (setq command (gnus-read-string
3441 "Print using command: " gnus-summary-muttprint-program
3442 nil gnus-summary-muttprint-program))
3443 (gnus-summary-save-in-pipe command))
3445 ;;; Article file names when saving.
3447 (defun gnus-capitalize-newsgroup (newsgroup)
3448 "Capitalize NEWSGROUP name."
3449 (when (not (zerop (length newsgroup)))
3450 (concat (char-to-string (upcase (aref newsgroup 0)))
3451 (substring newsgroup 1))))
3453 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3454 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3455 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3456 Otherwise, it is like ~/News/news/group/num."
3459 (concat (if (gnus-use-long-file-name 'not-save)
3460 (gnus-capitalize-newsgroup newsgroup)
3461 (gnus-newsgroup-directory-form newsgroup))
3462 "/" (int-to-string (mail-header-number headers)))
3463 gnus-article-save-directory)))
3465 (string-equal (file-name-directory default)
3466 (file-name-directory last-file))
3467 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3469 (or last-file default))))
3471 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3472 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3473 If variable `gnus-use-long-file-name' is non-nil, it is
3474 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3477 (concat (if (gnus-use-long-file-name 'not-save)
3479 (gnus-newsgroup-directory-form newsgroup))
3480 "/" (int-to-string (mail-header-number headers)))
3481 gnus-article-save-directory)))
3483 (string-equal (file-name-directory default)
3484 (file-name-directory last-file))
3485 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3487 (or last-file default))))
3489 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3490 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3491 If variable `gnus-use-long-file-name' is non-nil, it is
3492 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3495 (if (gnus-use-long-file-name 'not-save)
3498 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3500 gnus-article-save-directory)))
3502 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3503 "Generate file name from sender."
3504 (let ((from (mail-header-from headers)))
3506 (if (and from (string-match "\\([^ <]+\\)@" from))
3507 (match-string 1 from)
3509 gnus-article-save-directory)))
3511 (defun article-verify-x-pgp-sig ()
3514 (if (gnus-buffer-live-p gnus-original-article-buffer)
3515 (let ((sig (with-current-buffer gnus-original-article-buffer
3516 (gnus-fetch-field "X-PGP-Sig")))
3520 (mml2015-clear-verify-function))
3522 (insert-buffer-substring gnus-original-article-buffer)
3523 (setq items (split-string sig))
3524 (message-narrow-to-head)
3525 (let ((inhibit-point-motion-hooks t)
3526 (case-fold-search t))
3527 ;; Don't verify multiple headers.
3528 (setq headers (mapconcat (lambda (header)
3530 (mail-fetch-field header)
3532 (split-string (nth 1 items) ",") "")))
3533 (delete-region (point-min) (point-max))
3534 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3535 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3540 (if (looking-at "^-")
3543 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3544 (insert "Version: " (car items) "\n\n")
3545 (insert (mapconcat 'identity (cddr items) "\n"))
3546 (insert "\n-----END PGP SIGNATURE-----\n")
3547 (let ((mm-security-handle (list (format "multipart/signed"))))
3548 (mml2015-clean-buffer)
3549 (let ((coding-system-for-write (or gnus-newsgroup-charset
3551 (funcall (mml2015-clear-verify-function)))
3553 (or (mm-handle-multipart-ctl-parameter
3554 mm-security-handle 'gnus-details)
3555 (mm-handle-multipart-ctl-parameter
3556 mm-security-handle 'gnus-info)))))
3558 (let ((inhibit-read-only t) bface eface)
3560 (message-narrow-to-head)
3561 (goto-char (point-max))
3563 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3564 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3565 (message-remove-header "X-Gnus-PGP-Verify")
3566 (if (re-search-forward "^X-PGP-Sig:" nil t)
3568 (goto-char (point-max)))
3569 (narrow-to-region (point) (point))
3570 (insert "X-Gnus-PGP-Verify: " info "\n")
3571 (goto-char (point-min))
3574 (if (not (looking-at "^[ \t]"))
3578 (goto-char (point-min))
3579 (when (looking-at "\\([^:]+\\): *")
3580 (put-text-property (match-beginning 1) (1+ (match-end 1))
3582 (put-text-property (match-end 0) (point-max)
3583 'face eface)))))))))
3585 (defun article-verify-cancel-lock ()
3586 "Verify Cancel-Lock header."
3588 (if (gnus-buffer-live-p gnus-original-article-buffer)
3589 (canlock-verify gnus-original-article-buffer)))
3596 (setq afunc (car func)
3599 gfunc (intern (format "gnus-%s" func))))
3601 (when (fboundp afunc)
3602 `(lambda (&optional interactive &rest args)
3603 ,(documentation afunc t)
3604 (interactive (list t))
3606 (set-buffer gnus-article-buffer)
3608 (call-interactively ',afunc)
3609 (apply ',afunc args))))))))
3610 '(article-hide-headers
3611 article-verify-x-pgp-sig
3612 article-verify-cancel-lock
3613 article-hide-boring-headers
3614 article-treat-overstrike
3615 article-fill-long-lines
3616 article-capitalize-sentences
3618 article-remove-leading-whitespace
3619 article-display-x-face
3620 article-display-face
3621 article-de-quoted-unreadable
3622 article-de-base64-unreadable
3625 article-unsplit-urls
3626 article-hide-list-identifiers
3627 article-strip-banner
3630 article-hide-signature
3631 article-strip-headers-in-body
3632 article-remove-trailing-blank-lines
3633 article-strip-leading-blank-lines
3634 article-strip-multiple-blank-lines
3635 article-strip-leading-space
3636 article-strip-trailing-space
3637 article-strip-blank-lines
3638 article-strip-all-blank-lines
3640 article-date-english
3641 article-date-iso8601
3642 article-date-original
3644 article-decode-mime-words
3645 article-decode-charset
3646 article-decode-encoded-words
3650 article-treat-dumbquotes
3651 article-normalize-headers
3652 ;; (article-show-all . gnus-article-show-all-headers)
3656 ;;; Gnus article mode
3659 (put 'gnus-article-mode 'mode-class 'special)
3661 (set-keymap-parent gnus-article-mode-map widget-keymap)
3663 (gnus-define-keys gnus-article-mode-map
3664 " " gnus-article-goto-next-page
3665 "\177" gnus-article-goto-prev-page
3666 [delete] gnus-article-goto-prev-page
3667 [backspace] gnus-article-goto-prev-page
3668 "\C-c^" gnus-article-refer-article
3669 "h" gnus-article-show-summary
3670 "s" gnus-article-show-summary
3671 "\C-c\C-m" gnus-article-mail
3672 "?" gnus-article-describe-briefly
3673 "e" gnus-summary-edit-article
3674 "<" beginning-of-buffer
3676 "\C-c\C-i" gnus-info-find-node
3678 "R" gnus-article-reply-with-original
3679 "F" gnus-article-followup-with-original
3680 "\C-hk" gnus-article-describe-key
3681 "\C-hc" gnus-article-describe-key-briefly
3683 "\C-d" gnus-article-read-summary-keys
3684 "\M-*" gnus-article-read-summary-keys
3685 "\M-#" gnus-article-read-summary-keys
3686 "\M-^" gnus-article-read-summary-keys
3687 "\M-g" gnus-article-read-summary-keys)
3689 (substitute-key-definition
3690 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3692 (defun gnus-article-make-menu-bar ()
3693 (unless (boundp 'gnus-article-commands-menu)
3694 (gnus-summary-make-menu-bar))
3695 (gnus-turn-off-edit-menu 'article)
3696 (unless (boundp 'gnus-article-article-menu)
3698 gnus-article-article-menu gnus-article-mode-map ""
3700 ["Scroll forwards" gnus-article-goto-next-page t]
3701 ["Scroll backwards" gnus-article-goto-prev-page t]
3702 ["Show summary" gnus-article-show-summary t]
3703 ["Fetch Message-ID at point" gnus-article-refer-article t]
3704 ["Mail to address at point" gnus-article-mail t]
3705 ["Send a bug report" gnus-bug t]))
3708 gnus-article-treatment-menu gnus-article-mode-map ""
3709 ;; Fixme: this should use :active (and maybe :visible).
3711 ["Hide headers" gnus-article-hide-headers t]
3712 ["Hide signature" gnus-article-hide-signature t]
3713 ["Hide citation" gnus-article-hide-citation t]
3714 ["Treat overstrike" gnus-article-treat-overstrike t]
3715 ["Remove carriage return" gnus-article-remove-cr t]
3716 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3717 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3718 ["Remove base64" gnus-article-de-base64-unreadable t]
3719 ["Treat html" gnus-article-wash-html t]
3720 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3721 ["Decode HZ" gnus-article-decode-HZ t]))
3723 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3725 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3727 (gnus-run-hooks 'gnus-article-menu-hook)))
3729 (defun gnus-article-mode ()
3730 "Major mode for displaying an article.
3732 All normal editing commands are switched off.
3734 The following commands are available in addition to all summary mode
3736 \\<gnus-article-mode-map>
3737 \\[gnus-article-next-page]\t Scroll the article one page forwards
3738 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3739 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3740 \\[gnus-article-show-summary]\t Display the summary buffer
3741 \\[gnus-article-mail]\t Send a reply to the address near point
3742 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3743 \\[gnus-info-find-node]\t Go to the Gnus info node"
3745 (kill-all-local-variables)
3746 (gnus-simplify-mode-line)
3747 (setq mode-name "Article")
3748 (setq major-mode 'gnus-article-mode)
3749 (make-local-variable 'minor-mode-alist)
3750 (use-local-map gnus-article-mode-map)
3751 (when (gnus-visual-p 'article-menu 'menu)
3752 (gnus-article-make-menu-bar)
3753 (when gnus-summary-tool-bar-map
3754 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3755 (gnus-update-format-specifications nil 'article-mode)
3756 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3757 (set (make-local-variable 'gnus-page-broken) nil)
3758 (make-local-variable 'gnus-button-marker-list)
3759 (make-local-variable 'gnus-article-current-summary)
3760 (make-local-variable 'gnus-article-mime-handles)
3761 (make-local-variable 'gnus-article-decoded-p)
3762 (make-local-variable 'gnus-article-mime-handle-alist)
3763 (make-local-variable 'gnus-article-wash-types)
3764 (make-local-variable 'gnus-article-image-alist)
3765 (make-local-variable 'gnus-article-charset)
3766 (make-local-variable 'gnus-article-ignored-charsets)
3767 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3768 (set (make-local-variable 'nobreak-char-display) nil)
3769 (gnus-set-default-directory)
3770 (buffer-disable-undo)
3771 (setq buffer-read-only t)
3772 (set-syntax-table gnus-article-mode-syntax-table)
3773 (mm-enable-multibyte)
3774 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3776 (defun gnus-article-setup-buffer ()
3777 "Initialize the article buffer."
3778 (let* ((name (if gnus-single-article-buffer "*Article*"
3779 (concat "*Article " gnus-newsgroup-name "*")))
3781 (progn (string-match "\\*Article" name)
3782 (concat " *Original Article"
3783 (substring name (match-end 0))))))
3784 (setq gnus-article-buffer name)
3785 (setq gnus-original-article-buffer original)
3786 (setq gnus-article-mime-handle-alist nil)
3787 ;; This might be a variable local to the summary buffer.
3788 (unless gnus-single-article-buffer
3790 (set-buffer gnus-summary-buffer)
3791 (setq gnus-article-buffer name)
3792 (setq gnus-original-article-buffer original)
3793 (gnus-set-global-variables)))
3794 (gnus-article-setup-highlight-words)
3795 ;; Init original article buffer.
3797 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3798 (mm-enable-multibyte)
3799 (setq major-mode 'gnus-original-article-mode)
3800 (make-local-variable 'gnus-original-article))
3801 (if (and (get-buffer name)
3802 (with-current-buffer name
3803 (if gnus-article-edit-mode
3804 (if (y-or-n-p "Article mode edit in progress; discard? ")
3806 (set-buffer-modified-p nil)
3807 (gnus-kill-buffer name)
3810 (error "Action aborted"))
3814 (set (make-local-variable 'gnus-article-edit-mode) nil)
3815 (when gnus-article-mime-handles
3816 (mm-destroy-parts gnus-article-mime-handles)
3817 (setq gnus-article-mime-handles nil))
3818 ;; Set it to nil in article-buffer!
3819 (setq gnus-article-mime-handle-alist nil)
3820 (buffer-disable-undo)
3821 (setq buffer-read-only t)
3822 ;; This list just keeps growing if we don't reset it.
3823 (setq gnus-button-marker-list nil)
3824 (unless (eq major-mode 'gnus-article-mode)
3825 (gnus-article-mode))
3828 (set-buffer (gnus-get-buffer-create name))
3830 (make-local-variable 'gnus-summary-buffer)
3831 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3832 (current-buffer)))))
3834 ;; Set article window start at LINE, where LINE is the number of lines
3835 ;; from the head of the article.
3836 (defun gnus-article-set-window-start (&optional line)
3838 (gnus-get-buffer-window gnus-article-buffer t)
3840 (set-buffer gnus-article-buffer)
3841 (goto-char (point-min))
3844 (gnus-message 6 "Moved to bookmark")
3845 (search-forward "\n\n" nil t)
3849 (defun gnus-article-prepare (article &optional all-headers header)
3850 "Prepare ARTICLE in article mode buffer.
3851 ARTICLE should either be an article number or a Message-ID.
3852 If ARTICLE is an id, HEADER should be the article headers.
3853 If ALL-HEADERS is non-nil, no headers are hidden."
3855 ;; Make sure we start in a summary buffer.
3856 (unless (eq major-mode 'gnus-summary-mode)
3857 (set-buffer gnus-summary-buffer))
3858 (setq gnus-summary-buffer (current-buffer))
3859 (let* ((gnus-article (if header (mail-header-number header) article))
3860 (summary-buffer (current-buffer))
3861 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3862 (group gnus-newsgroup-name)
3865 (gnus-article-setup-buffer)
3866 (set-buffer gnus-article-buffer)
3867 ;; Deactivate active regions.
3868 (when (and (boundp 'transient-mark-mode)
3869 transient-mark-mode)
3870 (setq mark-active nil))
3871 (if (not (setq result (let ((inhibit-read-only t))
3872 (gnus-request-article-this-buffer
3874 ;; There is no such article.
3876 (when (and (numberp article)
3877 (not (memq article gnus-newsgroup-sparse)))
3878 (setq gnus-article-current
3879 (cons gnus-newsgroup-name article))
3880 (set-buffer gnus-summary-buffer)
3881 (setq gnus-current-article article)
3882 (if (and (memq article gnus-newsgroup-undownloaded)
3883 (not (gnus-online (gnus-find-method-for-group
3884 gnus-newsgroup-name))))
3886 (gnus-summary-set-agent-mark article)
3887 (message "Message marked for downloading"))
3888 (gnus-summary-mark-article article gnus-canceled-mark)
3889 (unless (memq article gnus-newsgroup-sparse)
3890 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3891 (if (or (eq result 'pseudo)
3892 (eq result 'nneething))
3895 (set-buffer summary-buffer)
3896 (push article gnus-newsgroup-history)
3897 (setq gnus-last-article gnus-current-article
3898 gnus-current-article 0
3899 gnus-current-headers nil
3900 gnus-article-current nil)
3901 (if (eq result 'nneething)
3902 (gnus-configure-windows 'summary)
3903 (gnus-configure-windows 'article))
3904 (gnus-set-global-variables))
3905 (let ((gnus-article-mime-handle-alist-1
3906 gnus-article-mime-handle-alist))
3907 (gnus-set-mode-line 'article)))
3908 ;; The result from the `request' was an actual article -
3909 ;; or at least some text that is now displayed in the
3911 (when (and (numberp article)
3912 (not (eq article gnus-current-article)))
3913 ;; Seems like a new article has been selected.
3914 ;; `gnus-current-article' must be an article number.
3916 (set-buffer summary-buffer)
3917 (push article gnus-newsgroup-history)
3918 (setq gnus-last-article gnus-current-article
3919 gnus-current-article article
3920 gnus-current-headers
3921 (gnus-summary-article-header gnus-current-article)
3922 gnus-article-current
3923 (cons gnus-newsgroup-name gnus-current-article))
3924 (unless (vectorp gnus-current-headers)
3925 (setq gnus-current-headers nil))
3926 (gnus-summary-goto-subject gnus-current-article)
3927 (when (gnus-summary-show-thread)
3928 ;; If the summary buffer really was folded, the
3929 ;; previous goto may not actually have gone to
3930 ;; the right article, but the thread root instead.
3932 (gnus-summary-goto-subject gnus-current-article))
3933 (gnus-run-hooks 'gnus-mark-article-hook)
3934 (gnus-set-mode-line 'summary)
3935 (when (gnus-visual-p 'article-highlight 'highlight)
3936 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3937 ;; Set the global newsgroup variables here.
3938 (gnus-set-global-variables)
3939 (setq gnus-have-all-headers
3940 (or all-headers gnus-show-all-headers))))
3942 (gnus-configure-windows 'article))
3943 (when (or (numberp article)
3945 (gnus-article-prepare-display)
3947 (goto-char (point-min))
3948 (when gnus-break-pages
3949 (gnus-narrow-to-page)))
3950 (let ((gnus-article-mime-handle-alist-1
3951 gnus-article-mime-handle-alist))
3952 (gnus-set-mode-line 'article))
3956 (set-window-point (get-buffer-window (current-buffer)) (point))
3957 (gnus-configure-windows 'article)
3961 (defun gnus-article-prepare-display ()
3962 "Make the current buffer look like a nice article."
3963 ;; Hooks for getting information from the article.
3964 ;; This hook must be called before being narrowed.
3965 (let ((gnus-article-buffer (current-buffer))
3967 (inhibit-read-only t))
3968 (unless (eq major-mode 'gnus-article-mode)
3969 (gnus-article-mode))
3970 (setq buffer-read-only nil
3971 gnus-article-wash-types nil
3972 gnus-article-image-alist nil)
3973 (gnus-run-hooks 'gnus-tmp-internal-hook)
3974 (when gnus-display-mime-function
3975 (funcall gnus-display-mime-function))
3976 (gnus-run-hooks 'gnus-article-prepare-hook)))
3979 ;;; Gnus MIME viewing functions
3982 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3983 "Format of the MIME buttons.
3985 Valid specifiers include:
3987 %T MIME type, along with additional info
3988 %n The `name' parameter
3989 %d The description, if any
3990 %l The length of the encoded part
3991 %p The part identifier number
3992 %e Dots if the part isn't displayed
3994 General format specifiers can also be used. See Info node
3995 `(gnus)Formatting Variables'.")
3997 (defvar gnus-mime-button-line-format-alist
3998 '((?t gnus-tmp-type ?s)
3999 (?T gnus-tmp-type-long ?s)
4000 (?n gnus-tmp-name ?s)
4001 (?d gnus-tmp-description ?s)
4003 (?l gnus-tmp-length ?d)
4004 (?e gnus-tmp-dots ?s)))
4006 (defvar gnus-mime-button-commands
4007 '((gnus-article-press-button "\r" "Toggle Display")
4008 (gnus-mime-view-part "v" "View Interactively...")
4009 (gnus-mime-view-part-as-type "t" "View As Type...")
4010 (gnus-mime-view-part-as-charset "C" "View As charset...")
4011 (gnus-mime-save-part "o" "Save...")
4012 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4013 (gnus-mime-delete-part "d" "Delete part")
4014 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4015 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4016 (gnus-mime-view-part-internally "E" "View Internally")
4017 (gnus-mime-view-part-externally "e" "View Externally")
4018 (gnus-mime-print-part "p" "Print")
4019 (gnus-mime-pipe-part "|" "Pipe To Command...")
4020 (gnus-mime-action-on-part "." "Take action on the part...")))
4022 (defun gnus-article-mime-part-status ()
4023 (if gnus-article-mime-handle-alist-1
4024 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4026 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4029 (defvar gnus-mime-button-map
4030 (let ((map (make-sparse-keymap)))
4031 (unless (>= (string-to-number emacs-version) 21)
4032 ;; XEmacs doesn't care.
4033 (set-keymap-parent map gnus-article-mode-map))
4034 (define-key map gnus-mouse-2 'gnus-article-push-button)
4035 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4036 (dolist (c gnus-mime-button-commands)
4037 (define-key map (cadr c) (car c)))
4041 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4043 ,@(mapcar (lambda (c)
4044 (vector (caddr c) (car c) :enable t))
4045 gnus-mime-button-commands)))
4048 (define-compiler-macro popup-menu (&whole form
4049 menu &optional position prefix)
4050 (if (and (fboundp 'popup-menu)
4051 (not (memq 'popup-menu (assoc "lmenu" load-history))))
4053 ;; Gnus is probably running under Emacs 20.
4054 `(let* ((menu (cdr ,menu))
4055 (response (x-popup-menu
4057 (cons "" (mapcar (lambda (c)
4058 (cons (caddr c) (car c)))
4061 (call-interactively (nth 3 (assq response menu))))))))
4063 (defun gnus-mime-button-menu (event prefix)
4064 "Construct a context-sensitive menu of MIME commands."
4065 (interactive "e\nP")
4066 (save-window-excursion
4067 (let ((pos (event-start event)))
4068 (select-window (posn-window pos))
4069 (goto-char (posn-point pos))
4070 (gnus-article-check-buffer)
4071 (popup-menu gnus-mime-button-menu nil prefix))))
4073 (defun gnus-mime-view-all-parts (&optional handles)
4074 "View all the MIME parts."
4076 (save-current-buffer
4077 (set-buffer gnus-article-buffer)
4078 (let ((handles (or handles gnus-article-mime-handles))
4079 (mail-parse-charset gnus-newsgroup-charset)
4080 (mail-parse-ignored-charsets
4081 (with-current-buffer gnus-summary-buffer
4082 gnus-newsgroup-ignored-charsets)))
4084 (mm-remove-parts handles)
4085 (goto-char (point-min))
4086 (or (search-forward "\n\n") (goto-char (point-max)))
4087 (let ((inhibit-read-only t))
4088 (delete-region (point) (point-max))
4089 (mm-display-parts handles))))))
4091 (defun gnus-mime-save-part-and-strip ()
4092 "Save the MIME part under point then replace it with an external body."
4094 (gnus-article-check-buffer)
4095 (when (gnus-group-read-only-p)
4096 (error "The current group does not support deleting of parts"))
4097 (when (mm-complicated-handles gnus-article-mime-handles)
4099 The current article has a complicated MIME structure, giving up..."))
4100 (when (gnus-yes-or-no-p "\
4101 Deleting parts may malfunction or destroy the article; continue? ")
4102 (let* ((data (get-text-property (point) 'gnus-data))
4104 (handles gnus-article-mime-handles))
4105 (setq file (and data (mm-save-part data)))
4107 (with-current-buffer (mm-handle-buffer data)
4109 (insert "Content-Type: " (mm-handle-media-type data))
4110 (mml-insert-parameter-string (cdr (mm-handle-type data))
4113 (insert "Content-ID: " (message-make-message-id) "\n")
4114 (insert "Content-Transfer-Encoding: binary\n")
4117 (cdr (mm-make-handle nil
4118 `("message/external-body"
4119 (access-type . "LOCAL-FILE")
4121 (set-buffer gnus-summary-buffer)
4122 (gnus-article-edit-article
4125 (let ((mail-parse-charset (or gnus-article-charset
4126 ',gnus-newsgroup-charset))
4127 (mail-parse-ignored-charsets
4128 (or gnus-article-ignored-charsets
4129 ',gnus-newsgroup-ignored-charsets))
4130 (mbl mml-buffer-list))
4131 (setq mml-buffer-list nil)
4132 (insert-buffer-substring gnus-original-article-buffer)
4133 (mime-to-mml ',handles)
4134 (setq gnus-article-mime-handles nil)
4135 (let ((mbl1 mml-buffer-list))
4136 (setq mml-buffer-list mbl)
4137 (set (make-local-variable 'mml-buffer-list) mbl1))
4138 (gnus-make-local-hook 'kill-buffer-hook)
4139 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4140 `(lambda (no-highlight)
4141 (let ((mail-parse-charset (or gnus-article-charset
4142 ',gnus-newsgroup-charset))
4143 (message-options message-options)
4144 (message-options-set-recipient)
4145 (mail-parse-ignored-charsets
4146 (or gnus-article-ignored-charsets
4147 ',gnus-newsgroup-ignored-charsets)))
4149 (mml-destroy-buffers)
4150 (remove-hook 'kill-buffer-hook
4151 'mml-destroy-buffers t)
4152 (kill-local-variable 'mml-buffer-list))
4153 (gnus-summary-edit-article-done
4154 ,(or (mail-header-references gnus-current-headers) "")
4155 ,(gnus-group-read-only-p)
4156 ,gnus-summary-buffer no-highlight)))))))
4158 (defun gnus-mime-delete-part ()
4159 "Delete the MIME part under point.
4160 Replace it with some information about the removed part."
4162 (gnus-article-check-buffer)
4163 (when (gnus-group-read-only-p)
4164 (error "The current group does not support deleting of parts"))
4165 (when (mm-complicated-handles gnus-article-mime-handles)
4167 The current article has a complicated MIME structure, giving up..."))
4168 (when (gnus-yes-or-no-p "\
4169 Deleting parts may malfunction or destroy the article; continue? ")
4170 (let* ((data (get-text-property (point) 'gnus-data))
4171 (handles gnus-article-mime-handles)
4175 (mail-decode-encoded-word-string (or (mm-handle-description data)
4178 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4180 (type (mm-handle-media-type data)))
4182 (error "No MIME part under point"))
4183 (with-current-buffer (mm-handle-buffer data)
4184 (let ((bsize (format "%s" (buffer-size))))
4189 "| The following attachment has been deleted:\n"
4191 "| Type: " type "\n"
4192 "| Filename: " filename "\n"
4193 "| Size (encoded): " bsize " Byte\n"
4194 "| Description: " description "\n"
4197 (cdr (mm-make-handle
4198 nil `("text/plain") nil nil
4200 (format "Deleted attachment (%s bytes)" bsize))))))
4201 (set-buffer gnus-summary-buffer)
4202 ;; FIXME: maybe some of the following code (borrowed from
4203 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4204 (gnus-article-edit-article
4207 (let ((mail-parse-charset (or gnus-article-charset
4208 ',gnus-newsgroup-charset))
4209 (mail-parse-ignored-charsets
4210 (or gnus-article-ignored-charsets
4211 ',gnus-newsgroup-ignored-charsets))
4212 (mbl mml-buffer-list))
4213 (setq mml-buffer-list nil)
4214 (insert-buffer-substring gnus-original-article-buffer)
4215 (mime-to-mml ',handles)
4216 (setq gnus-article-mime-handles nil)
4217 (let ((mbl1 mml-buffer-list))
4218 (setq mml-buffer-list mbl)
4219 (set (make-local-variable 'mml-buffer-list) mbl1))
4220 (gnus-make-local-hook 'kill-buffer-hook)
4221 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4222 `(lambda (no-highlight)
4223 (let ((mail-parse-charset (or gnus-article-charset
4224 ',gnus-newsgroup-charset))
4225 (message-options message-options)
4226 (message-options-set-recipient)
4227 (mail-parse-ignored-charsets
4228 (or gnus-article-ignored-charsets
4229 ',gnus-newsgroup-ignored-charsets)))
4231 (mml-destroy-buffers)
4232 (remove-hook 'kill-buffer-hook
4233 'mml-destroy-buffers t)
4234 (kill-local-variable 'mml-buffer-list))
4235 (gnus-summary-edit-article-done
4236 ,(or (mail-header-references gnus-current-headers) "")
4237 ,(gnus-group-read-only-p)
4238 ,gnus-summary-buffer no-highlight)))))
4239 ;; Not in `gnus-mime-save-part-and-strip':
4240 (gnus-article-edit-done)
4241 (gnus-summary-expand-window)
4242 (gnus-summary-show-article))
4244 (defun gnus-mime-save-part ()
4245 "Save the MIME part under point."
4247 (gnus-article-check-buffer)
4248 (let ((data (get-text-property (point) 'gnus-data)))
4250 (mm-save-part data))))
4252 (defun gnus-mime-pipe-part ()
4253 "Pipe the MIME part under point to a process."
4255 (gnus-article-check-buffer)
4256 (let ((data (get-text-property (point) 'gnus-data)))
4258 (mm-pipe-part data))))
4260 (defun gnus-mime-view-part ()
4261 "Interactively choose a viewing method for the MIME part under point."
4263 (gnus-article-check-buffer)
4264 (let ((data (get-text-property (point) 'gnus-data)))
4266 (setq gnus-article-mime-handles
4268 gnus-article-mime-handles (setq data (copy-sequence data))))
4269 (mm-interactively-view-part data))))
4271 (defun gnus-mime-view-part-as-type-internal ()
4272 (gnus-article-check-buffer)
4273 (let* ((name (mail-content-type-get
4274 (mm-handle-type (get-text-property (point) 'gnus-data))
4276 (def-type (and name (mm-default-file-encoding name))))
4277 (and def-type (cons def-type 0))))
4279 (defun gnus-mime-view-part-as-type (&optional mime-type)
4280 "Choose a MIME media type, and view the part as such."
4283 (setq mime-type (completing-read
4284 "View as MIME type: "
4285 (mapcar #'list (mailcap-mime-types))
4287 (gnus-mime-view-part-as-type-internal))))
4288 (gnus-article-check-buffer)
4289 (let ((handle (get-text-property (point) 'gnus-data)))
4292 (mm-make-handle (mm-handle-buffer handle)
4293 (cons mime-type (cdr (mm-handle-type handle)))
4294 (mm-handle-encoding handle)
4295 (mm-handle-undisplayer handle)
4296 (mm-handle-disposition handle)
4297 (mm-handle-description handle)
4299 (mm-handle-id handle)))
4300 (setq gnus-article-mime-handles
4301 (mm-merge-handles gnus-article-mime-handles handle))
4302 (gnus-mm-display-part handle))))
4305 (require 'jka-compr))
4307 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4308 ;; emacs can do that itself.
4310 (defun gnus-mime-jka-compr-maybe-uncompress ()
4311 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4312 The uncompress method used is derived from `buffer-file-name'."
4313 (when (and (fboundp 'jka-compr-installed-p)
4314 (jka-compr-installed-p))
4315 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4317 (let ((basename (file-name-nondirectory buffer-file-name))
4318 (args (jka-compr-info-uncompress-args info))
4319 (prog (jka-compr-info-uncompress-program info))
4320 (message (jka-compr-info-uncompress-message info))
4321 (err-file (jka-compr-make-temp-name)))
4323 (message "%s %s..." message basename))
4325 (unless (memq (apply 'call-process-region
4326 (point-min) (point-max)
4328 t (list t err-file) nil
4330 jka-compr-acceptable-retval-list)
4331 (jka-compr-error prog args basename message err-file))
4332 (jka-compr-delete-temp-file err-file)))))))
4334 (defun gnus-mime-copy-part (&optional handle)
4335 "Put the MIME part under point into a new buffer.
4336 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4339 (gnus-article-check-buffer)
4340 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4341 (contents (and handle (mm-get-part handle)))
4343 (file-name-nondirectory
4345 (mail-content-type-get (mm-handle-type handle) 'name)
4346 (mail-content-type-get (mm-handle-disposition handle)
4349 (buffer (and base (generate-new-buffer base))))
4351 (switch-to-buffer buffer)
4353 ;; We do it this way to make `normal-mode' set the appropriate mode.
4356 (setq buffer-file-name (expand-file-name base))
4357 (gnus-mime-jka-compr-maybe-uncompress)
4359 (setq buffer-file-name nil))
4360 (goto-char (point-min)))))
4362 (defun gnus-mime-print-part (&optional handle filename)
4363 "Print the MIME part under point."
4364 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4365 (gnus-article-check-buffer)
4366 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4367 (contents (and handle (mm-get-part handle)))
4368 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4369 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4374 (mm-save-part-to-file handle file)
4375 (call-process shell-file-name nil
4376 (generate-new-buffer " *mm*")
4378 shell-command-switch
4380 printer file (mm-handle-type handle))))
4384 (gnus-print-buffer))
4385 (ps-despool filename)))))
4387 (defun gnus-mime-inline-part (&optional handle arg)
4388 "Insert the MIME part under point into the current buffer."
4389 (interactive (list nil current-prefix-arg))
4390 (gnus-article-check-buffer)
4391 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4394 (inhibit-read-only t))
4396 (if (and (not arg) (mm-handle-undisplayer handle))
4397 (mm-remove-part handle)
4398 (setq contents (mm-get-part handle))
4401 (setq charset (or (mail-content-type-get
4402 (mm-handle-type handle) 'charset)
4403 gnus-newsgroup-charset)))
4405 (if (mm-handle-undisplayer handle)
4406 (mm-remove-part handle))
4409 gnus-summary-show-article-charset-alist))
4410 (mm-read-coding-system "Charset: "))))
4412 (if (mm-handle-undisplayer handle)
4413 (mm-remove-part handle))))
4418 (setq charset (mm-charset-to-coding-system
4420 (not (eq charset 'ascii)))
4421 (mm-decode-coding-string contents charset)
4422 (mm-string-to-multibyte contents)))
4425 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4426 "Insert the MIME part under point into the current buffer using the
4428 (interactive (list nil current-prefix-arg))
4429 (gnus-article-check-buffer)
4430 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4433 (inhibit-read-only t))
4435 (if (mm-handle-undisplayer handle)
4436 (mm-remove-part handle))
4437 (let ((gnus-newsgroup-charset
4439 gnus-summary-show-article-charset-alist))
4440 (mm-read-coding-system "Charset: ")))
4441 (gnus-newsgroup-ignored-charsets 'gnus-all))
4442 (gnus-article-press-button)))))
4444 (defun gnus-mime-view-part-externally (&optional handle)
4445 "View the MIME part under point with an external viewer."
4447 (gnus-article-check-buffer)
4448 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4449 (mm-user-display-methods nil)
4450 (mm-inlined-types nil)
4451 (mail-parse-charset gnus-newsgroup-charset)
4452 (mail-parse-ignored-charsets
4453 (save-excursion (set-buffer gnus-summary-buffer)
4454 gnus-newsgroup-ignored-charsets)))
4456 (if (mm-handle-undisplayer handle)
4457 (mm-remove-part handle)
4458 (mm-display-part handle)))))
4460 (defun gnus-mime-view-part-internally (&optional handle)
4461 "View the MIME part under point with an internal viewer.
4462 If no internal viewer is available, use an external viewer."
4464 (gnus-article-check-buffer)
4465 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4466 (mm-inlined-types '(".*"))
4467 (mm-inline-large-images t)
4468 (mail-parse-charset gnus-newsgroup-charset)
4469 (mail-parse-ignored-charsets
4470 (save-excursion (set-buffer gnus-summary-buffer)
4471 gnus-newsgroup-ignored-charsets))
4472 (inhibit-read-only t))
4474 (if (mm-handle-undisplayer handle)
4475 (mm-remove-part handle)
4476 (mm-display-part handle)))))
4478 (defun gnus-mime-action-on-part (&optional action)
4479 "Do something with the MIME attachment at \(point\)."
4481 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4482 (gnus-article-check-buffer)
4483 (let ((action-pair (assoc action gnus-mime-action-alist)))
4485 (funcall (cdr action-pair)))))
4487 (defun gnus-article-part-wrapper (n function)
4488 (save-current-buffer
4489 (set-buffer gnus-article-buffer)
4490 (when (> n (length gnus-article-mime-handle-alist))
4491 (error "No such part"))
4492 (gnus-article-goto-part n)
4493 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4494 (funcall function handle))))
4496 (defun gnus-article-pipe-part (n)
4497 "Pipe MIME part N, which is the numerical prefix."
4499 (gnus-article-part-wrapper n 'mm-pipe-part))
4501 (defun gnus-article-save-part (n)
4502 "Save MIME part N, which is the numerical prefix."
4504 (gnus-article-part-wrapper n 'mm-save-part))
4506 (defun gnus-article-interactively-view-part (n)
4507 "View MIME part N interactively, which is the numerical prefix."
4509 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4511 (defun gnus-article-copy-part (n)
4512 "Copy MIME part N, which is the numerical prefix."
4514 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4516 (defun gnus-article-view-part-as-charset (n)
4517 "View MIME part N using a specified charset.
4518 N is the numerical prefix."
4520 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4522 (defun gnus-article-view-part-externally (n)
4523 "View MIME part N externally, which is the numerical prefix."
4525 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4527 (defun gnus-article-inline-part (n)
4528 "Inline MIME part N, which is the numerical prefix."
4530 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4532 (defun gnus-article-mime-match-handle-first (condition)
4534 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4535 (while (setq ihandle (pop alist))
4537 ((functionp condition)
4538 (funcall condition (cdr ihandle)))
4539 ((eq condition 'undisplayed)
4540 (not (or (mm-handle-undisplayer (cdr ihandle))
4541 (equal (mm-handle-media-type (cdr ihandle))
4542 "multipart/alternative"))))
4543 ((eq condition 'undisplayed-alternative)
4544 (not (mm-handle-undisplayer (cdr ihandle))))
4546 (gnus-article-goto-part (car ihandle))
4547 (or (not n) (< (car ihandle) n)))
4548 (setq n (car ihandle))))
4552 (defun gnus-article-view-part (&optional n)
4553 "View MIME part N, which is the numerical prefix."
4555 (save-current-buffer
4556 (set-buffer gnus-article-buffer)
4557 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4558 gnus-article-mime-match-handle-function)))
4559 (when (> n (length gnus-article-mime-handle-alist))
4560 (error "No such part"))
4561 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4562 (when (gnus-article-goto-part n)
4563 (if (equal (car handle) "multipart/alternative")
4564 (gnus-article-press-button)
4565 (when (eq (gnus-mm-display-part handle) 'internal)
4566 (gnus-set-window-start)))))))
4568 (defsubst gnus-article-mime-total-parts ()
4569 (if (bufferp (car gnus-article-mime-handles))
4571 (1- (length gnus-article-mime-handles))))
4573 (defun gnus-mm-display-part (handle)
4574 "Display HANDLE and fix MIME button."
4575 (let ((id (get-text-property (point) 'gnus-part))
4577 (inhibit-read-only t))
4580 (let ((window (selected-window))
4581 (mail-parse-charset gnus-newsgroup-charset)
4582 (mail-parse-ignored-charsets
4583 (if (gnus-buffer-live-p gnus-summary-buffer)
4585 (set-buffer gnus-summary-buffer)
4586 gnus-newsgroup-ignored-charsets)
4590 (let ((win (gnus-get-buffer-window (current-buffer) t))
4593 (select-window win))
4596 (if (mm-handle-displayed-p handle)
4597 ;; This will remove the part.
4598 (mm-display-part handle)
4600 (narrow-to-region (point)
4601 (if (eobp) (point) (1+ (point))))
4602 (mm-display-part handle)
4603 ;; We narrow to the part itself and
4604 ;; then call the treatment functions.
4605 (goto-char (point-min))
4607 (narrow-to-region (point) (point-max))
4610 (gnus-article-mime-total-parts)
4611 (mm-handle-media-type handle)))))
4612 (if (window-live-p window)
4613 (select-window window)))))
4616 (gnus-insert-mime-button
4617 handle id (list (mm-handle-displayed-p handle)))
4618 (goto-char point))))
4620 (defun gnus-article-goto-part (n)
4621 "Go to MIME part N."
4622 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4624 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4625 (let ((gnus-tmp-name
4626 (or (mail-content-type-get (mm-handle-type handle) 'name)
4627 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4628 (mail-content-type-get (mm-handle-type handle) 'url)
4630 (gnus-tmp-type (mm-handle-media-type handle))
4631 (gnus-tmp-description
4632 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4635 (if (if displayed (car displayed)
4636 (mm-handle-displayed-p handle))
4638 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4640 gnus-tmp-type-long b e)
4641 (when (string-match ".*/" gnus-tmp-name)
4642 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4643 (setq gnus-tmp-type-long (concat gnus-tmp-type
4644 (and (not (equal gnus-tmp-name ""))
4645 (concat "; " gnus-tmp-name))))
4646 (unless (equal gnus-tmp-description "")
4647 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4652 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4653 `(,@(gnus-local-map-property gnus-mime-button-map)
4654 gnus-callback gnus-mm-display-part
4655 gnus-part ,gnus-tmp-id
4656 article-type annotation
4659 ;; Exclude a newline.
4662 (widget-convert-button
4665 :action 'gnus-widget-press-button
4666 :button-keymap gnus-mime-button-map
4668 (lambda (widget/window &optional overlay pos)
4669 ;; Needed to properly clear the message due to a bug in
4670 ;; wid-edit (XEmacs only).
4671 (if (boundp 'help-echo-owns-message)
4672 (setq help-echo-owns-message t))
4674 "%S: %s the MIME part; %S: more options"
4675 (aref gnus-mouse-2 0)
4676 ;; XEmacs will get a single widget arg; Emacs 21 will get
4677 ;; window, overlay, position.
4678 (if (mm-handle-displayed-p
4680 (with-current-buffer (gnus-overlay-buffer overlay)
4681 (widget-get (widget-at (gnus-overlay-start overlay))
4683 (widget-get widget/window :mime-handle)))
4685 (aref gnus-down-mouse-3 0))))))
4687 (defun gnus-widget-press-button (elems el)
4688 (goto-char (widget-get elems :from))
4689 (gnus-article-press-button))
4691 (defvar gnus-displaying-mime nil)
4693 (defun gnus-display-mime (&optional ihandles)
4694 "Display the MIME parts."
4696 (save-selected-window
4697 (let ((window (get-buffer-window gnus-article-buffer))
4700 (select-window window)
4701 ;; We have to do this since selecting the window
4702 ;; may change the point. So we set the window point.
4703 (set-window-point window point)))
4704 (let* ((handles (or ihandles
4705 (mm-dissect-buffer nil gnus-article-loose-mime)
4706 (and gnus-article-emulate-mime
4708 (inhibit-read-only t) handle name type b e display)
4709 (when (and (not ihandles)
4710 (not gnus-displaying-mime))
4711 ;; Top-level call; we clean up.
4712 (when gnus-article-mime-handles
4713 (mm-destroy-parts gnus-article-mime-handles)
4714 (setq gnus-article-mime-handle-alist nil));; A trick.
4715 (setq gnus-article-mime-handles handles)
4716 ;; We allow users to glean info from the handles.
4717 (when gnus-article-mime-part-function
4718 (gnus-mime-part-function handles)))
4720 (or (not (stringp (car handles)))
4723 (when (and (not ihandles)
4724 (not gnus-displaying-mime))
4725 ;; Clean up for mime parts.
4727 (delete-region (point) (point-max)))
4728 (let ((gnus-displaying-mime t))
4729 (gnus-mime-display-part handles)))
4732 (narrow-to-region (point) (point-max))
4733 (gnus-treat-article nil 1 1)
4736 ;; Highlight the headers.
4740 (narrow-to-region (point-min) (point))
4741 (gnus-article-save-original-date
4742 (gnus-treat-article 'head)))))))))
4744 (defcustom gnus-mime-display-multipart-as-mixed nil
4745 "Display \"multipart\" parts as \"multipart/mixed\".
4747 If t, it overrides nil values of
4748 `gnus-mime-display-multipart-alternative-as-mixed' and
4749 `gnus-mime-display-multipart-related-as-mixed'."
4750 :group 'gnus-article-mime
4753 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4754 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4756 :group 'gnus-article-mime
4759 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4760 "Display \"multipart/related\" parts as \"multipart/mixed\".
4762 If displaying \"text/html\" is discouraged \(see
4763 `mm-discouraged-alternatives'\) images or other material inside a
4764 \"multipart/related\" part might be overlooked when this variable is nil."
4766 :group 'gnus-article-mime
4769 (defun gnus-mime-display-part (handle)
4771 ;; Maybe a broken MIME message.
4774 ((not (stringp (car handle)))
4775 (gnus-mime-display-single handle))
4776 ;; User-defined multipart
4777 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4778 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4780 ;; multipart/alternative
4781 ((and (equal (car handle) "multipart/alternative")
4782 (not (or gnus-mime-display-multipart-as-mixed
4783 gnus-mime-display-multipart-alternative-as-mixed)))
4784 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4785 (push (cons id handle) gnus-article-mime-handle-alist)
4786 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4787 ;; multipart/related
4788 ((and (equal (car handle) "multipart/related")
4789 (not (or gnus-mime-display-multipart-as-mixed
4790 gnus-mime-display-multipart-related-as-mixed)))
4791 ;;;!!!We should find the start part, but we just default
4792 ;;;!!!to the first part.
4793 ;;(gnus-mime-display-part (cadr handle))
4794 ;;;!!! Most multipart/related is an HTML message plus images.
4795 ;;;!!! Unfortunately we are unable to let W3 display those
4796 ;;;!!! included images, so we just display it as a mixed multipart.
4797 ;;(gnus-mime-display-mixed (cdr handle))
4798 ;;;!!! No, w3 can display everything just fine.
4799 (gnus-mime-display-part (cadr handle)))
4800 ((equal (car handle) "multipart/signed")
4801 (gnus-add-wash-type 'signed)
4802 (gnus-mime-display-security handle))
4803 ((equal (car handle) "multipart/encrypted")
4804 (gnus-add-wash-type 'encrypted)
4805 (gnus-mime-display-security handle))
4806 ;; Other multiparts are handled like multipart/mixed.
4808 (gnus-mime-display-mixed (cdr handle)))))
4810 (defun gnus-mime-part-function (handles)
4811 (if (stringp (car handles))
4812 (mapcar 'gnus-mime-part-function (cdr handles))
4813 (funcall gnus-article-mime-part-function handles)))
4815 (defun gnus-mime-display-mixed (handles)
4816 (mapcar 'gnus-mime-display-part handles))
4818 (defun gnus-mime-display-single (handle)
4819 (let ((type (mm-handle-media-type handle))
4820 (ignored gnus-ignored-mime-types)
4827 (when (string-match (pop ignored) type)
4828 (throw 'ignored nil)))
4829 (if (and (setq not-attachment
4830 (and (not (mm-inline-override-p handle))
4831 (or (not (mm-handle-disposition handle))
4832 (equal (car (mm-handle-disposition handle))
4834 (mm-attachment-override-p handle))))
4835 (mm-automatic-display-p handle)
4837 (mm-inlinable-p handle)
4838 (mm-inlined-p handle))
4839 (mm-automatic-external-display-p type)))
4841 (when (equal (mm-handle-media-supertype handle) "text")
4843 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4845 (push (cons id handle) gnus-article-mime-handle-alist)
4846 (when (or (not display)
4847 (not (gnus-unbuttonized-mime-type-p type)))
4848 ;(gnus-article-insert-newline)
4849 (gnus-insert-mime-button
4850 handle id (list (or display (and not-attachment text))))
4851 (gnus-article-insert-newline)
4852 ;(gnus-article-insert-newline)
4853 ;; Remember modify the number of forward lines.
4861 (let ((mail-parse-charset gnus-newsgroup-charset)
4862 (mail-parse-ignored-charsets
4863 (save-excursion (condition-case ()
4864 (set-buffer gnus-summary-buffer)
4866 gnus-newsgroup-ignored-charsets)))
4867 (mm-display-part handle t))
4868 (goto-char (point-max)))
4869 ((and text not-attachment)
4873 (gnus-article-insert-newline)
4876 (let ((charset (mail-content-type-get (mm-handle-type handle)
4878 (cond ((not charset)
4879 (mm-string-as-multibyte (mm-get-part handle)))
4880 ((eq charset 'gnus-decoded)
4881 (with-current-buffer (mm-handle-buffer handle)
4884 (mm-decode-string (mm-get-part handle) charset)))))
4885 (goto-char (point-max))))
4889 (narrow-to-region beg (point))
4892 (gnus-article-mime-total-parts)
4893 (mm-handle-media-type handle)))))))))
4895 (defun gnus-unbuttonized-mime-type-p (type)
4896 "Say whether TYPE is to be unbuttonized."
4897 (unless gnus-inhibit-mime-unbuttonizing
4899 (let ((types gnus-unbuttonized-mime-types))
4901 (when (string-match (pop types) type)
4902 (throw 'found t)))))
4904 (let ((types gnus-buttonized-mime-types))
4906 (when (string-match (pop types) type)
4907 (throw 'found t)))))))))
4909 (defun gnus-article-insert-newline ()
4910 "Insert a newline, but mark it as undeletable."
4911 (gnus-put-text-property
4912 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4914 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4915 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4918 handle (inhibit-read-only t) from props begend not-pref)
4919 (save-window-excursion
4922 (narrow-to-region (car ibegend)
4925 (goto-char (car ibegend))
4928 (delete-region (point-min) (point-max))
4929 (mm-remove-parts handles))
4930 (setq begend (list (point-marker)))
4932 (unless (setq not-pref (cadr (member preferred ihandles)))
4933 (setq not-pref (car ihandles)))
4936 (not (gnus-unbuttonized-mime-type-p
4937 "multipart/alternative")))
4938 (gnus-add-text-properties
4941 (insert (format "%d. " id))
4945 (unless ,(not ibegend)
4946 (setq gnus-article-mime-handle-alist
4947 ',gnus-article-mime-handle-alist))
4948 (gnus-mime-display-alternative
4949 ',ihandles ',not-pref ',begend ,id))
4950 ,@(gnus-local-map-property gnus-mime-button-map)
4951 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4952 face ,gnus-article-button-face
4955 (widget-convert-button 'link from (point)
4956 :action 'gnus-widget-press-button
4957 :button-keymap gnus-widget-button-keymap)
4959 (while (setq handle (pop handles))
4960 (gnus-add-text-properties
4963 (insert (format "(%c) %-18s"
4964 (if (equal handle preferred) ?* ? )
4965 (mm-handle-media-type handle)))
4969 (unless ,(not ibegend)
4970 (setq gnus-article-mime-handle-alist
4971 ',gnus-article-mime-handle-alist))
4972 (gnus-mime-display-alternative
4973 ',ihandles ',handle ',begend ,id))
4974 ,@(gnus-local-map-property gnus-mime-button-map)
4975 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4976 face ,gnus-article-button-face
4979 (widget-convert-button 'link from (point)
4980 :action 'gnus-widget-press-button
4981 :button-keymap gnus-widget-button-keymap)
4985 (if (stringp (car preferred))
4986 (gnus-display-mime preferred)
4987 (let ((mail-parse-charset gnus-newsgroup-charset)
4988 (mail-parse-ignored-charsets
4989 (save-excursion (set-buffer gnus-summary-buffer)
4990 gnus-newsgroup-ignored-charsets)))
4991 (mm-display-part preferred)
4995 (narrow-to-region (car begend) (point-max))
4997 nil (length gnus-article-mime-handle-alist)
4998 (gnus-article-mime-total-parts)
4999 (mm-handle-media-type handle))))))
5000 (goto-char (point-max))
5001 (setcdr begend (point-marker)))))
5003 (goto-char point))))
5005 (defconst gnus-article-wash-status-strings
5006 (let ((alist '((cite "c" "Possible hidden citation text"
5007 " " "All citation text visible")
5008 (headers "h" "Hidden headers"
5009 " " "All headers visible.")
5010 (pgp "p" "Encrypted or signed message status hidden"
5011 " " "No hidden encryption nor digital signature status")
5012 (signature "s" "Signature has been hidden"
5013 " " "Signature is visible")
5014 (overstrike "o" "Overstrike (^H) characters applied"
5015 " " "No overstrike characters applied")
5016 (emphasis "e" "/*_Emphasis_*/ characters applied"
5017 " " "No /*_emphasis_*/ characters applied")))
5019 (dolist (entry alist result)
5020 (let ((key (nth 0 entry))
5021 (on (copy-sequence (nth 1 entry)))
5022 (on-help (nth 2 entry))
5023 (off (copy-sequence (nth 3 entry)))
5024 (off-help (nth 4 entry)))
5025 (put-text-property 0 1 'help-echo on-help on)
5026 (put-text-property 0 1 'help-echo off-help off)
5027 (push (list key on off) result))))
5028 "Alist of strings describing wash status in the mode line.
5029 Each entry has the form (KEY ON OF), where the KEY is a symbol
5030 representing the particular washing function, ON is the string to use
5031 in the article mode line when the washing function is active, and OFF
5032 is the string to use when it is inactive.")
5034 (defun gnus-article-wash-status-entry (key value)
5035 (let ((entry (assoc key gnus-article-wash-status-strings)))
5036 (if value (nth 1 entry) (nth 2 entry))))
5038 (defun gnus-article-wash-status ()
5039 "Return a string which display status of article washing."
5041 (set-buffer gnus-article-buffer)
5042 (let ((cite (memq 'cite gnus-article-wash-types))
5043 (headers (memq 'headers gnus-article-wash-types))
5044 (boring (memq 'boring-headers gnus-article-wash-types))
5045 (pgp (memq 'pgp gnus-article-wash-types))
5046 (pem (memq 'pem gnus-article-wash-types))
5047 (signed (memq 'signed gnus-article-wash-types))
5048 (encrypted (memq 'encrypted gnus-article-wash-types))
5049 (signature (memq 'signature gnus-article-wash-types))
5050 (overstrike (memq 'overstrike gnus-article-wash-types))
5051 (emphasis (memq 'emphasis gnus-article-wash-types)))
5053 (gnus-article-wash-status-entry 'cite cite)
5054 (gnus-article-wash-status-entry 'headers (or headers boring))
5055 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5056 (gnus-article-wash-status-entry 'signature signature)
5057 (gnus-article-wash-status-entry 'overstrike overstrike)
5058 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5060 (defun gnus-add-wash-type (type)
5061 "Add a washing of TYPE to the current status."
5062 (add-to-list 'gnus-article-wash-types type))
5064 (defun gnus-delete-wash-type (type)
5065 "Add a washing of TYPE to the current status."
5066 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5068 (defun gnus-add-image (category image)
5069 "Add IMAGE of CATEGORY to the list of displayed images."
5070 (let ((entry (assq category gnus-article-image-alist)))
5072 (setq entry (list category))
5073 (push entry gnus-article-image-alist))
5074 (nconc entry (list image))))
5076 (defun gnus-delete-images (category)
5077 "Delete all images in CATEGORY."
5078 (let ((entry (assq category gnus-article-image-alist)))
5079 (dolist (image (cdr entry))
5080 (gnus-remove-image image category))
5081 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5082 (gnus-delete-wash-type category)))
5084 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5086 (defun gnus-article-maybe-hide-headers ()
5087 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5088 Provided for backwards compatibility."
5089 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5090 (not (save-excursion (set-buffer gnus-summary-buffer)
5091 gnus-have-all-headers)))
5092 (not gnus-inhibit-hiding))
5093 (gnus-article-hide-headers)))
5097 (defun gnus-output-to-file (file-name)
5098 "Append the current article to a file named FILE-NAME."
5099 (let ((artbuf (current-buffer)))
5101 (insert-buffer-substring artbuf)
5102 ;; Append newline at end of the buffer as separator, and then
5104 (goto-char (point-max))
5106 (let ((file-name-coding-system nnmail-pathname-coding-system))
5107 (mm-append-to-file (point-min) (point-max) file-name))
5110 (defun gnus-narrow-to-page (&optional arg)
5111 "Narrow the article buffer to a page.
5112 If given a numerical ARG, move forward ARG pages."
5114 (setq arg (if arg (prefix-numeric-value arg) 0))
5116 (set-buffer gnus-article-buffer)
5117 (goto-char (point-min))
5119 ;; Remove any old next/prev buttons.
5120 (when (gnus-visual-p 'page-marker)
5121 (let ((inhibit-read-only t))
5122 (gnus-remove-text-with-property 'gnus-prev)
5123 (gnus-remove-text-with-property 'gnus-next)))
5126 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5128 (re-search-forward page-delimiter nil 'move arg)))
5129 (goto-char (match-end 0))
5131 (goto-char (point-min))
5132 (setq gnus-page-broken
5133 (and (re-search-forward page-delimiter nil t) t))))
5134 (when gnus-page-broken
5137 (if (re-search-forward page-delimiter nil 'move)
5140 (when (and (gnus-visual-p 'page-marker)
5141 (> (point-min) (save-restriction (widen) (point-min))))
5143 (goto-char (point-min))
5144 (gnus-insert-prev-page-button)))
5145 (when (and (gnus-visual-p 'page-marker)
5146 (< (point-max) (save-restriction (widen) (point-max))))
5148 (goto-char (point-max))
5149 (gnus-insert-next-page-button))))))
5151 ;; Article mode commands
5153 (defun gnus-article-goto-next-page ()
5154 "Show the next page of the article."
5156 (when (gnus-article-next-page)
5157 (goto-char (point-min))
5158 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5161 (defun gnus-article-goto-prev-page ()
5162 "Show the previous page of the article."
5165 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5166 (gnus-article-prev-page nil)))
5168 ;; This is cleaner but currently breaks `gnus-pick-mode':
5170 ;; (defun gnus-article-goto-next-page ()
5171 ;; "Show the next page of the article."
5173 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5174 ;; (gnus-summary-next-page)))
5176 ;; (defun gnus-article-goto-prev-page ()
5177 ;; "Show the next page of the article."
5179 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5180 ;; (gnus-summary-prev-page)))
5182 (defun gnus-article-next-page (&optional lines)
5183 "Show the next page of the current article.
5184 If end of article, return non-nil. Otherwise return nil.
5185 Argument LINES specifies lines to be scrolled up."
5187 (move-to-window-line -1)
5190 (and (pos-visible-in-window-p) ;Not continuation line.
5191 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5192 ;; Nothing in this page.
5193 (if (or (not gnus-page-broken)
5198 (eobp)))) ;Real end-of-buffer?
5200 (when gnus-article-over-scroll
5201 (gnus-article-next-page-1 lines))
5203 (gnus-narrow-to-page 1) ;Go to next page.
5205 ;; More in this page.
5206 (gnus-article-next-page-1 lines)
5209 (defmacro gnus-article-beginning-of-window ()
5210 "Move point to the beginning of the window.
5211 In Emacs, the point is placed at the line number which `scroll-margin'
5213 (if (featurep 'xemacs)
5214 '(move-to-window-line 0)
5215 '(move-to-window-line
5216 (min (max 0 scroll-margin)
5217 (max 1 (- (window-height)
5218 (if mode-line-format 1 0)
5219 (if (and (boundp 'header-line-format)
5220 (symbol-value 'header-line-format))
5223 (defun gnus-article-next-page-1 (lines)
5224 (when (and (not (featurep 'xemacs))
5227 (numberp (symbol-value 'scroll-margin))
5228 (> (symbol-value 'scroll-margin) 0))
5229 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5230 ;; too many number of lines if `scroll-margin' is set as two or greater.
5231 (setq lines (min lines
5232 (max 0 (- (count-lines (window-start) (point-max))
5233 (symbol-value 'scroll-margin))))))
5235 (let ((scroll-in-place nil))
5238 ;; Long lines may cause an end-of-buffer error.
5239 (goto-char (point-max))))
5240 (gnus-article-beginning-of-window))
5242 (defun gnus-article-prev-page (&optional lines)
5243 "Show previous page of current article.
5244 Argument LINES specifies lines to be scrolled down."
5246 (move-to-window-line 0)
5247 (if (and gnus-page-broken
5249 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5251 (gnus-narrow-to-page -1) ;Go to previous page.
5252 (goto-char (point-max))
5256 (let ((scroll-in-place nil))
5257 (scroll-down lines))
5258 (beginning-of-buffer
5259 (goto-char (point-min))))
5260 (gnus-article-beginning-of-window))))
5262 (defun gnus-article-only-boring-p ()
5263 "Decide whether there is only boring text remaining in the article.
5264 Something \"interesting\" is a word of at least two letters that does
5265 not have a face in `gnus-article-boring-faces'."
5266 (when (and gnus-article-skip-boring
5267 (boundp 'gnus-article-boring-faces)
5268 (symbol-value 'gnus-article-boring-faces))
5271 (while (re-search-forward "\\b\\w\\w" nil t)
5273 (when (not (gnus-intersection
5274 (gnus-faces-at (point))
5275 (symbol-value 'gnus-article-boring-faces)))
5276 (throw 'only-boring nil)))
5277 (throw 'only-boring t)))))
5279 (defun gnus-article-refer-article ()
5280 "Read article specified by message-id around point."
5283 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5284 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5285 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5286 (let ((msg-id (concat "<" (match-string 0) ">")))
5287 (set-buffer gnus-summary-buffer)
5288 (gnus-summary-refer-article msg-id))
5289 (error "No references around point"))))
5291 (defun gnus-article-show-summary ()
5292 "Reconfigure windows to show summary buffer."
5294 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5295 (error "There is no summary buffer for this article buffer")
5296 (gnus-article-set-globals)
5297 (gnus-configure-windows 'article)
5298 (gnus-summary-goto-subject gnus-current-article)
5299 (gnus-summary-position-point)))
5301 (defun gnus-article-describe-briefly ()
5302 "Describe article mode commands briefly."
5304 (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")))
5306 (defun gnus-article-summary-command ()
5307 "Execute the last keystroke in the summary buffer."
5309 (let ((obuf (current-buffer))
5310 (owin (current-window-configuration))
5312 (switch-to-buffer gnus-article-current-summary 'norecord)
5313 (setq func (lookup-key (current-local-map) (this-command-keys)))
5314 (call-interactively func)
5316 (set-window-configuration owin)
5317 (set-window-point (get-buffer-window (current-buffer)) (point))))
5319 (defun gnus-article-summary-command-nosave ()
5320 "Execute the last keystroke in the summary buffer."
5323 (pop-to-buffer gnus-article-current-summary 'norecord)
5324 (setq func (lookup-key (current-local-map) (this-command-keys)))
5325 (call-interactively func)))
5327 (defun gnus-article-check-buffer ()
5328 "Beep if not in an article buffer."
5329 (unless (equal major-mode 'gnus-article-mode)
5330 (error "Command invoked outside of a Gnus article buffer")))
5332 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5333 "Read a summary buffer key sequence and execute it from the article buffer."
5335 (gnus-article-check-buffer)
5337 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5338 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5339 "=" "^" "\M-^" "|"))
5345 '("n" "Gn" "p" "Gp"))
5348 (set-buffer gnus-article-current-summary)
5349 (let (gnus-pick-mode)
5350 (push (or key last-command-event) unread-command-events)
5351 (setq keys (if (featurep 'xemacs)
5352 (events-to-keys (read-key-sequence nil))
5353 (read-key-sequence nil)))))
5357 (if (or (member keys nosaves)
5358 (member keys nosave-but-article)
5359 (member keys nosave-in-article))
5361 (save-window-excursion
5362 (pop-to-buffer gnus-article-current-summary 'norecord)
5363 ;; We disable the pick minor mode commands.
5364 (let (gnus-pick-mode)
5365 (setq func (lookup-key (current-local-map) keys))))
5369 (unless (member keys nosave-in-article)
5370 (set-buffer gnus-article-current-summary))
5371 (call-interactively func)
5372 (setq new-sum-point (point)))
5373 (when (member keys nosave-but-article)
5374 (pop-to-buffer gnus-article-buffer 'norecord)))
5375 ;; These commands should restore window configuration.
5376 (let ((obuf (current-buffer))
5377 (owin (current-window-configuration))
5379 win func in-buffer selected new-sum-start new-sum-hscroll)
5380 (cond (not-restore-window
5381 (pop-to-buffer gnus-article-current-summary 'norecord))
5382 ((setq win (get-buffer-window gnus-article-current-summary))
5383 (select-window win))
5385 (switch-to-buffer gnus-article-current-summary 'norecord)))
5386 (setq in-buffer (current-buffer))
5387 ;; We disable the pick minor mode commands.
5388 (if (and (setq func (let (gnus-pick-mode)
5389 (lookup-key (current-local-map) keys)))
5392 (call-interactively func)
5393 (when (eq win (selected-window))
5394 (setq new-sum-point (point)
5395 new-sum-start (window-start win)
5396 new-sum-hscroll (window-hscroll win)))
5397 (when (eq in-buffer (current-buffer))
5398 (setq selected (gnus-summary-select-article))
5400 (unless not-restore-window
5401 (set-window-configuration owin))
5402 (when (eq selected 'old)
5404 (set-window-start (get-buffer-window (current-buffer))
5406 (set-window-point (get-buffer-window (current-buffer))
5408 (when (and (not not-restore-window)
5410 (set-window-point win new-sum-point)
5411 (set-window-start win new-sum-start)
5412 (set-window-hscroll win new-sum-hscroll))))
5413 (set-window-configuration owin)
5416 (defun gnus-article-describe-key (key)
5417 "Display documentation of the function invoked by KEY. KEY is a string."
5418 (interactive "kDescribe key: ")
5419 (gnus-article-check-buffer)
5420 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5422 (set-buffer gnus-article-current-summary)
5423 (let (gnus-pick-mode)
5424 (if (featurep 'xemacs)
5426 (push (elt key 0) unread-command-events)
5427 (setq key (events-to-keys
5428 (read-key-sequence "Describe key: "))))
5429 (setq unread-command-events
5431 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5432 (string-to-list key)))
5433 (setq key (read-key-sequence "Describe key: "))))
5435 (describe-key key)))
5437 (defun gnus-article-describe-key-briefly (key &optional insert)
5438 "Display documentation of the function invoked by KEY. KEY is a string."
5439 (interactive "kDescribe key: \nP")
5440 (gnus-article-check-buffer)
5441 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5443 (set-buffer gnus-article-current-summary)
5444 (let (gnus-pick-mode)
5445 (if (featurep 'xemacs)
5447 (push (elt key 0) unread-command-events)
5448 (setq key (events-to-keys
5449 (read-key-sequence "Describe key: "))))
5450 (setq unread-command-events
5452 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5453 (string-to-list key)))
5454 (setq key (read-key-sequence "Describe key: "))))
5455 (describe-key-briefly key insert))
5456 (describe-key-briefly key insert)))
5458 (defun gnus-article-reply-with-original (&optional wide)
5459 "Start composing a reply mail to the current message.
5460 The text in the region will be yanked. If the region isn't active,
5461 the entire article will be yanked."
5463 (let ((article (cdr gnus-article-current))
5465 (if (not (gnus-mark-active-p))
5466 (with-current-buffer gnus-summary-buffer
5467 (gnus-summary-reply (list (list article)) wide))
5468 (setq contents (buffer-substring (point) (mark t)))
5469 ;; Deactivate active regions.
5470 (when (and (boundp 'transient-mark-mode)
5471 transient-mark-mode)
5472 (setq mark-active nil))
5473 (with-current-buffer gnus-summary-buffer
5475 (list (list article contents)) wide)))))
5477 (defun gnus-article-followup-with-original ()
5478 "Compose a followup to the current article.
5479 The text in the region will be yanked. If the region isn't active,
5480 the entire article will be yanked."
5482 (let ((article (cdr gnus-article-current))
5484 (if (not (gnus-mark-active-p))
5485 (with-current-buffer gnus-summary-buffer
5486 (gnus-summary-followup (list (list article))))
5487 (setq contents (buffer-substring (point) (mark t)))
5488 ;; Deactivate active regions.
5489 (when (and (boundp 'transient-mark-mode)
5490 transient-mark-mode)
5491 (setq mark-active nil))
5492 (with-current-buffer gnus-summary-buffer
5493 (gnus-summary-followup
5494 (list (list article contents)))))))
5496 (defun gnus-article-hide (&optional arg force)
5497 "Hide all the gruft in the current article.
5498 This means that signatures, cited text and (some) headers will be
5500 If given a prefix, show the hidden text instead."
5501 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5502 (gnus-article-hide-headers arg)
5503 (gnus-article-hide-list-identifiers arg)
5504 (gnus-article-hide-citation-maybe arg force)
5505 (gnus-article-hide-signature arg))
5507 (defun gnus-article-maybe-highlight ()
5508 "Do some article highlighting if article highlighting is requested."
5509 (when (gnus-visual-p 'article-highlight 'highlight)
5510 (gnus-article-highlight-some)))
5512 (defun gnus-check-group-server ()
5513 ;; Make sure the connection to the server is alive.
5514 (unless (gnus-server-opened
5515 (gnus-find-method-for-group gnus-newsgroup-name))
5516 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5517 (gnus-request-group gnus-newsgroup-name t)))
5520 (autoload 'nneething-get-file-name "nneething"))
5522 (defun gnus-request-article-this-buffer (article group)
5523 "Get an article and insert it into this buffer."
5524 (let (do-update-line sparse-header)
5528 (gnus-kill-all-overlays)
5529 (setq group (or group gnus-newsgroup-name))
5531 ;; Using `gnus-request-article' directly will insert the article into
5532 ;; `nntp-server-buffer' - so we'll save some time by not having to
5533 ;; copy it from the server buffer into the article buffer.
5535 ;; We only request an article by message-id when we do not have the
5536 ;; headers for it, so we'll have to get those.
5537 (when (stringp article)
5538 (gnus-read-header article))
5540 ;; If the article number is negative, that means that this article
5541 ;; doesn't belong in this newsgroup (possibly), so we find its
5542 ;; message-id and request it by id instead of number.
5543 (when (and (numberp article)
5545 (get-buffer gnus-summary-buffer)
5546 (gnus-buffer-exists-p gnus-summary-buffer))
5548 (set-buffer gnus-summary-buffer)
5549 (let ((header (gnus-summary-article-header article)))
5552 ((memq article gnus-newsgroup-sparse)
5553 ;; This is a sparse gap article.
5554 (setq do-update-line article)
5555 (setq article (mail-header-id header))
5556 (setq sparse-header (gnus-read-header article))
5557 (setq gnus-newsgroup-sparse
5558 (delq article gnus-newsgroup-sparse)))
5560 ;; It's a real article.
5561 (setq article (mail-header-id header)))
5563 ;; It is an extracted pseudo-article.
5564 (setq article 'pseudo)
5565 (gnus-request-pseudo-article header))))
5567 (let ((method (gnus-find-method-for-group
5568 gnus-newsgroup-name)))
5569 (when (and (eq (car method) 'nneething)
5571 (let ((dir (nneething-get-file-name
5572 (mail-header-id header))))
5573 (when (and (stringp dir)
5574 (file-directory-p dir))
5575 (setq article 'nneething)
5576 (gnus-group-enter-directory dir))))))))
5579 ;; Refuse to select canceled articles.
5580 ((and (numberp article)
5582 (get-buffer gnus-summary-buffer)
5583 (gnus-buffer-exists-p gnus-summary-buffer)
5584 (eq (cdr (save-excursion
5585 (set-buffer gnus-summary-buffer)
5586 (assq article gnus-newsgroup-reads)))
5587 gnus-canceled-mark))
5589 ;; We first check `gnus-original-article-buffer'.
5590 ((and (get-buffer gnus-original-article-buffer)
5593 (set-buffer gnus-original-article-buffer)
5594 (and (equal (car gnus-original-article) group)
5595 (eq (cdr gnus-original-article) article))))
5596 (insert-buffer-substring gnus-original-article-buffer)
5598 ;; Check the backlog.
5599 ((and gnus-keep-backlog
5600 (gnus-backlog-request-article group article (current-buffer)))
5602 ;; Check asynchronous pre-fetch.
5603 ((gnus-async-request-fetched-article group article (current-buffer))
5604 (gnus-async-prefetch-next group article gnus-summary-buffer)
5605 (when (and (numberp article) gnus-keep-backlog)
5606 (gnus-backlog-enter-article group article (current-buffer)))
5609 ((and gnus-use-cache
5611 (gnus-cache-request-article article group))
5613 ;; Check the agent cache.
5614 ((gnus-agent-request-article article group)
5616 ;; Get the article and put into the article buffer.
5617 ((or (stringp article)
5619 (let ((gnus-override-method gnus-override-method)
5620 (methods (and (stringp article)
5621 gnus-refer-article-method))
5622 (backend (car (gnus-find-method-for-group
5623 gnus-newsgroup-name)))
5625 (inhibit-read-only t))
5626 (if (or (not (listp methods))
5627 (and (symbolp (car methods))
5628 (assq (car methods) nnoo-definition-alist)))
5629 (setq methods (list methods)))
5630 (when (and (null gnus-override-method)
5632 (setq gnus-override-method (pop methods)))
5634 (when (eq gnus-override-method 'current)
5635 (setq gnus-override-method
5636 (with-current-buffer gnus-summary-buffer
5637 gnus-current-select-method)))
5639 (gnus-kill-all-overlays)
5640 (let ((gnus-newsgroup-name group))
5641 (gnus-check-group-server))
5643 ((gnus-request-article article group (current-buffer))
5644 (when (numberp article)
5645 (gnus-async-prefetch-next group article
5646 gnus-summary-buffer)
5647 (when gnus-keep-backlog
5648 (gnus-backlog-enter-article
5649 group article (current-buffer))))
5650 (setq result 'article))
5652 (setq gnus-override-method (pop methods)))
5653 ((not (string-match "^400 "
5654 (nnheader-get-report backend)))
5655 ;; If we get 400 server disconnect, reconnect and
5656 ;; retry; otherwise, assume the article has expired.
5657 (setq result 'done))))
5658 (and (eq result 'article) 'article)))
5662 ;; Associate this article with the current summary buffer.
5663 (setq gnus-article-current-summary gnus-summary-buffer)
5665 ;; Take the article from the original article buffer
5666 ;; and place it in the buffer it's supposed to be in.
5667 (when (and (get-buffer gnus-article-buffer)
5668 (equal (buffer-name (current-buffer))
5669 (buffer-name (get-buffer gnus-article-buffer))))
5671 (if (get-buffer gnus-original-article-buffer)
5672 (set-buffer gnus-original-article-buffer)
5673 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5674 (buffer-disable-undo)
5675 (setq major-mode 'gnus-original-article-mode)
5676 (setq buffer-read-only t))
5677 (let ((inhibit-read-only t))
5679 (insert-buffer-substring gnus-article-buffer))
5680 (setq gnus-original-article (cons group article)))
5683 (run-hooks 'gnus-article-decode-hook)
5684 ;; Mark article as decoded or not.
5685 (setq gnus-article-decoded-p gnus-article-decode-hook))
5687 ;; Update sparse articles.
5688 (when (and do-update-line
5689 (or (numberp article)
5691 (let ((buf (current-buffer)))
5692 (set-buffer gnus-summary-buffer)
5693 (gnus-summary-update-article do-update-line sparse-header)
5694 (gnus-summary-goto-subject do-update-line nil t)
5695 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5697 (set-buffer buf))))))
5703 (defcustom gnus-article-edit-mode-hook nil
5704 "Hook run in article edit mode buffers."
5705 :group 'gnus-article-various
5708 (defvar gnus-article-edit-done-function nil)
5710 (defvar gnus-article-edit-mode-map nil)
5711 (defvar gnus-article-edit-mode nil)
5713 ;; Should we be using derived.el for this?
5714 (unless gnus-article-edit-mode-map
5715 (setq gnus-article-edit-mode-map (make-keymap))
5716 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5718 (gnus-define-keys gnus-article-edit-mode-map
5719 "\C-c?" describe-mode
5720 "\C-c\C-c" gnus-article-edit-done
5721 "\C-c\C-k" gnus-article-edit-exit
5722 "\C-c\C-f\C-t" message-goto-to
5723 "\C-c\C-f\C-o" message-goto-from
5724 "\C-c\C-f\C-b" message-goto-bcc
5725 ;;"\C-c\C-f\C-w" message-goto-fcc
5726 "\C-c\C-f\C-c" message-goto-cc
5727 "\C-c\C-f\C-s" message-goto-subject
5728 "\C-c\C-f\C-r" message-goto-reply-to
5729 "\C-c\C-f\C-n" message-goto-newsgroups
5730 "\C-c\C-f\C-d" message-goto-distribution
5731 "\C-c\C-f\C-f" message-goto-followup-to
5732 "\C-c\C-f\C-m" message-goto-mail-followup-to
5733 "\C-c\C-f\C-k" message-goto-keywords
5734 "\C-c\C-f\C-u" message-goto-summary
5735 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5736 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5737 "\C-c\C-b" message-goto-body
5738 "\C-c\C-i" message-goto-signature
5740 "\C-c\C-t" message-insert-to
5741 "\C-c\C-n" message-insert-newsgroups
5742 "\C-c\C-o" message-sort-headers
5743 "\C-c\C-e" message-elide-region
5744 "\C-c\C-v" message-delete-not-region
5745 "\C-c\C-z" message-kill-to-signature
5746 "\M-\r" message-newline-and-reformat
5747 "\C-c\C-a" mml-attach-file
5748 "\C-a" message-beginning-of-line
5750 "\M-;" comment-region)
5752 (gnus-define-keys (gnus-article-edit-wash-map
5753 "\C-c\C-w" gnus-article-edit-mode-map)
5754 "f" gnus-article-edit-full-stops))
5757 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5759 ["Fetch To" message-insert-to t]
5760 ["Fetch Newsgroups" message-insert-newsgroups t]
5762 ["To" message-goto-to t]
5763 ["From" message-goto-from t]
5764 ["Subject" message-goto-subject t]
5765 ["Cc" message-goto-cc t]
5766 ["Reply-To" message-goto-reply-to t]
5767 ["Summary" message-goto-summary t]
5768 ["Keywords" message-goto-keywords t]
5769 ["Newsgroups" message-goto-newsgroups t]
5770 ["Followup-To" message-goto-followup-to t]
5771 ["Mail-Followup-To" message-goto-mail-followup-to t]
5772 ["Distribution" message-goto-distribution t]
5773 ["Body" message-goto-body t]
5774 ["Signature" message-goto-signature t]))
5776 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5777 "Major mode for editing articles.
5778 This is an extended text-mode.
5780 \\{gnus-article-edit-mode-map}"
5781 (make-local-variable 'gnus-article-edit-done-function)
5782 (make-local-variable 'gnus-prev-winconf)
5783 (set (make-local-variable 'font-lock-defaults)
5784 '(message-font-lock-keywords t))
5785 (set (make-local-variable 'mail-header-separator) "")
5786 (set (make-local-variable 'gnus-article-edit-mode) t)
5787 (easy-menu-add message-mode-field-menu message-mode-map)
5789 (setq buffer-read-only nil)
5790 (buffer-enable-undo)
5793 (defun gnus-article-edit (&optional force)
5794 "Edit the current article.
5795 This will have permanent effect only in mail groups.
5796 If FORCE is non-nil, allow editing of articles even in read-only
5799 (when (and (not force)
5800 (gnus-group-read-only-p))
5801 (error "The current newsgroup does not support article editing"))
5802 (gnus-article-date-original)
5803 (gnus-article-edit-article
5805 `(lambda (no-highlight)
5807 (gnus-summary-edit-article-done
5808 ,(or (mail-header-references gnus-current-headers) "")
5809 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5811 (defun gnus-article-edit-article (start-func exit-func)
5812 "Start editing the contents of the current article buffer."
5813 (let ((winconf (current-window-configuration)))
5814 (set-buffer gnus-article-buffer)
5815 (let ((message-auto-save-directory
5816 ;; Don't associate the article buffer with a draft file.
5818 (gnus-article-edit-mode))
5819 (funcall start-func)
5820 (set-buffer-modified-p nil)
5821 (gnus-configure-windows 'edit-article)
5822 (setq gnus-article-edit-done-function exit-func)
5823 (setq gnus-prev-winconf winconf)
5824 (gnus-message 6 "C-c C-c to end edits")))
5826 (defun gnus-article-edit-done (&optional arg)
5827 "Update the article edits and exit."
5829 (let ((func gnus-article-edit-done-function)
5830 (buf (current-buffer))
5831 (start (window-start))
5833 (winconf gnus-prev-winconf))
5834 (widen) ;; Widen it in case that users narrowed the buffer.
5837 ;; The cache and backlog have to be flushed somewhat.
5838 (when gnus-keep-backlog
5839 (gnus-backlog-remove-article
5840 (car gnus-article-current) (cdr gnus-article-current)))
5841 ;; Flush original article as well.
5843 (when (get-buffer gnus-original-article-buffer)
5844 (set-buffer gnus-original-article-buffer)
5845 (setq gnus-original-article nil)))
5846 (when gnus-use-cache
5847 (gnus-cache-update-article
5848 (car gnus-article-current) (cdr gnus-article-current)))
5849 ;; We remove all text props from the article buffer.
5850 (kill-all-local-variables)
5851 (gnus-set-text-properties (point-min) (point-max) nil)
5853 (set-window-configuration winconf)
5855 (set-window-start (get-buffer-window buf) start)
5856 (set-window-point (get-buffer-window buf) (point)))
5857 (gnus-summary-show-article))
5859 (defun gnus-article-edit-exit ()
5860 "Exit the article editing without updating."
5862 (when (or (not (buffer-modified-p))
5863 (yes-or-no-p "Article modified; kill anyway? "))
5864 (let ((curbuf (current-buffer))
5866 (window-start (window-start)))
5868 (if (gnus-buffer-live-p gnus-original-article-buffer)
5869 (insert-buffer-substring gnus-original-article-buffer))
5870 (let ((winconf gnus-prev-winconf))
5871 (kill-all-local-variables)
5873 (set-window-configuration winconf)
5874 ;; Tippy-toe some to make sure that point remains where it was.
5875 (save-current-buffer
5877 (set-window-start (get-buffer-window (current-buffer)) window-start)
5879 (gnus-summary-show-article)))
5881 (defun gnus-article-edit-full-stops ()
5882 "Interactively repair spacing at end of sentences."
5885 (goto-char (point-min))
5886 (search-forward-regexp "^$" nil t)
5887 (let ((case-fold-search nil))
5888 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5891 ;;; Article highlights
5894 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5896 ;;; Internal Variables:
5898 (defcustom gnus-button-url-regexp
5899 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5900 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~%&*+\\/[:word:]]\\)"
5901 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)\\)")
5902 "Regular expression that matches URLs."
5903 :group 'gnus-article-buttons
5906 (defcustom gnus-button-valid-fqdn-regexp
5907 message-valid-fqdn-regexp
5908 "Regular expression that matches a valid FQDN."
5910 :group 'gnus-article-buttons
5913 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5914 (defcustom gnus-button-valid-localpart-regexp
5915 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*"
5916 "Regular expression that matches a localpart of mail addresses or MIDs."
5918 :group 'gnus-article-buttons
5921 (defcustom gnus-button-man-handler 'manual-entry
5922 "Function to use for displaying man pages.
5923 The function must take at least one argument with a string naming the
5926 :type '(choice (function-item :tag "Man" manual-entry)
5927 (function-item :tag "Woman" woman)
5928 (function :tag "Other"))
5929 :group 'gnus-article-buttons)
5931 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5932 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5933 If the default site is too slow, try to find a CTAN mirror, see
5934 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5935 the variable `gnus-button-handle-ctan'."
5937 :group 'gnus-article-buttons
5938 :link '(custom-manual "(gnus)Group Parameters")
5939 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5940 (const "http://tug.ctan.org/tex-archive/")
5941 (const "http://www.dante.de/CTAN/")
5942 (string :tag "Other")))
5944 (defcustom gnus-button-ctan-handler 'browse-url
5945 "Function to use for displaying CTAN links.
5946 The function must take one argument, the string naming the URL."
5948 :type '(choice (function-item :tag "Browse Url" browse-url)
5949 (function :tag "Other"))
5950 :group 'gnus-article-buttons)
5952 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5953 "Bogus strings removed from CTAN URLs."
5955 :group 'gnus-article-buttons
5956 :type '(choice (const "^/?tex-archive/\\|/")
5957 (regexp :tag "Other")))
5959 (defcustom gnus-button-ctan-directory-regexp
5961 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
5962 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
5963 "languages" "macros" "nonfree" "obsolete" "support" "systems"
5964 "tds" "tools" "usergrps" "web") t)
5965 "Regular expression for ctan directories.
5966 It should match all directories in the top level of `gnus-ctan-url'."
5968 :group 'gnus-article-buttons
5971 (defcustom gnus-button-mid-or-mail-regexp
5972 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
5973 gnus-button-valid-fqdn-regexp
5975 "Regular expression that matches a message ID or a mail address."
5977 :group 'gnus-article-buttons
5980 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5981 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5982 Strings like this can be either a message ID or a mail address. If it is one
5983 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5984 message ID or a mail address, respectively. If this variable is set to the
5985 symbol `ask', always query the user what do do. If it is a function, this
5986 function will be called with the string as it's only argument. The function
5987 must return `mid', `mail', `invalid' or `ask'."
5989 :group 'gnus-article-buttons
5990 :type '(choice (function-item :tag "Heuristic function"
5991 gnus-button-mid-or-mail-heuristic)
5996 (defcustom gnus-button-mid-or-mail-heuristic-alist
5997 '((-10.0 . ".+\\$.+@")
6000 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6001 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6002 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6003 (-1.0 . "^[^a-z]+@")
6005 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6006 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6007 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6008 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6011 (-1.0 . "^[0-9][0-9]")
6013 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6014 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6015 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6016 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6018 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6019 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6022 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6024 ;; compensation for TDMA dated mail addresses:
6025 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6027 (-20.0 . "\\.fsf@") ;; Gnus
6030 (-20.0 . "_-_") ;; Subject change in thread
6032 (-20.0 . "\\.ln@") ;; leafnode
6033 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6034 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6036 ;; (5.0 . "") ;; $local_part_len <= 7
6037 (10.0 . "^[^0-9]+@")
6038 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6039 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6042 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6044 (0.5 . "^[A-Z][a-z]")
6045 (0.5 . "^[A-Z][a-z][a-z]")
6046 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6047 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6048 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6050 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6051 address. The REGEXP is processed with `case-fold-search' set to nil."
6053 :group 'gnus-article-buttons
6054 :type '(repeat (cons (number :tag "Rate")
6055 (regexp :tag "Regexp"))))
6057 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6058 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6059 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6060 address, `ask' if unsure and `invalid' if the string is invalid."
6061 (let ((case-fold-search nil)
6062 (list gnus-button-mid-or-mail-heuristic-alist)
6063 (result 0) rate regexp lpartlen elem)
6065 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6066 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6067 ;; Certain special cases...
6070 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6071 "^[0-9]+\\.[0-9]+@compuserve\\|"
6072 "@public\\.gmane\\.org")
6074 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6075 (setq result 'mail))
6076 (when (string-match "@.*@\\| " mid-or-mail)
6077 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6078 (setq result 'invalid))
6079 ;; Nothing more to do, if result is not a number here...
6080 (when (numberp result)
6082 (setq elem (car list)
6086 (when (string-match regexp mid-or-mail)
6087 (setq result (+ result rate))
6089 9 "`%s' matched `%s', rate `%s', result `%s'."
6090 mid-or-mail regexp rate result)))
6091 (when (<= lpartlen 7)
6092 (setq result (+ result 5.0))
6093 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6094 mid-or-mail result))
6095 (when (>= lpartlen 12)
6096 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6098 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6099 ;; Long local part should contain realname if e-mail address,
6100 ;; too many digits: message-id.
6101 ;; $score -= 5.0 + 0.1 * $local_part_len;
6102 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6103 (setq result (+ result rate))
6105 9 "Many digits in `%s', rate `%s', result `%s'."
6106 mid-or-mail rate result))
6107 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6109 ;; Too few vowels [^aeiouy]{4,}.*\@
6110 (setq result (+ result -5.0))
6112 9 "Few vowels in `%s', rate `%s', result `%s'."
6113 mid-or-mail -5.0 result))
6115 (setq result (+ result 5.0))
6117 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6118 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6119 ;; Maybe we should make this a customizable alist: (condition . 'result)
6121 ((symbolp result) result)
6122 ;; Now convert number into proper results:
6123 ((< result -10.0) 'mid)
6124 ((> result 10.0) 'mail)
6127 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6128 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6129 (url-mid (concat "news" ":" mid-or-mail))
6130 (url-mailto (concat "mailto" ":" mid-or-mail)))
6131 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6132 (when (fboundp pref)
6134 ;; get rid of surrounding angles...
6136 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6137 (if (or (eq 'mid guessed) (eq 'mail guessed))
6141 (save-window-excursion
6142 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6145 (cond ((eq pref 'mid)
6146 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6147 (gnus-button-handle-news url-mid))
6149 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6150 (gnus-url-mailto url-mailto))
6151 (t (gnus-message 3 "Invalid string.")))))
6153 (defun gnus-button-handle-custom (url)
6154 "Follow a Custom URL."
6155 (customize-apropos (gnus-url-unhex-string url)))
6157 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6159 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6162 (defun gnus-button-handle-describe-function (url)
6163 "Call `describe-function' when pushing the corresponding URL button."
6166 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6168 (defun gnus-button-handle-describe-variable (url)
6169 "Call `describe-variable' when pushing the corresponding URL button."
6172 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6174 (defun gnus-button-handle-symbol (url)
6175 "Display help on variable or function.
6176 Calls `describe-variable' or `describe-function'."
6177 (let ((sym (intern url)))
6179 ((fboundp sym) (describe-function sym))
6180 ((boundp sym) (describe-variable sym))
6181 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6183 (defun gnus-button-handle-describe-key (url)
6184 "Call `describe-key' when pushing the corresponding URL button."
6186 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6187 (keys (ignore-errors (eval `(kbd ,key-string)))))
6190 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6192 (defun gnus-button-handle-apropos (url)
6193 "Call `apropos' when pushing the corresponding URL button."
6194 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6196 (defun gnus-button-handle-apropos-command (url)
6197 "Call `apropos' when pushing the corresponding URL button."
6199 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6201 (defun gnus-button-handle-apropos-variable (url)
6202 "Call `apropos' when pushing the corresponding URL button."
6204 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6205 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6207 (defun gnus-button-handle-apropos-documentation (url)
6208 "Call `apropos' when pushing the corresponding URL button."
6210 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6211 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6213 (defun gnus-button-handle-library (url)
6214 "Call `locate-library' when pushing the corresponding URL button."
6215 (gnus-message 9 "url=`%s'" url)
6216 (let* ((lib (locate-library url))
6217 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6219 (gnus-message 1 "Cannot locale library `%s'." url)
6220 (find-file-read-only file))))
6222 (defun gnus-button-handle-ctan (url)
6223 "Call `browse-url' when pushing a CTAN URL button."
6225 gnus-button-ctan-handler
6228 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6230 (defcustom gnus-button-tex-level 5
6231 "*Integer that says how many TeX-related buttons Gnus will show.
6232 The higher the number, the more buttons will appear and the more false
6233 positives are possible. Note that you can set this variable local to
6234 specific groups. Setting it higher in TeX groups is probably a good idea.
6235 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6236 how to set variables in specific groups."
6238 :group 'gnus-article-buttons
6239 :link '(custom-manual "(gnus)Group Parameters")
6242 (defcustom gnus-button-man-level 5
6243 "*Integer that says how many man-related buttons Gnus will show.
6244 The higher the number, the more buttons will appear and the more false
6245 positives are possible. Note that you can set this variable local to
6246 specific groups. Setting it higher in Unix groups is probably a good idea.
6247 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6248 how to set variables in specific groups."
6250 :group 'gnus-article-buttons
6251 :link '(custom-manual "(gnus)Group Parameters")
6254 (defcustom gnus-button-emacs-level 5
6255 "*Integer that says how many emacs-related buttons Gnus will show.
6256 The higher the number, the more buttons will appear and the more false
6257 positives are possible. Note that you can set this variable local to
6258 specific groups. Setting it higher in Emacs or Gnus related groups is
6259 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6260 `gnus-parameters' on how to set variables in specific groups."
6262 :group 'gnus-article-buttons
6263 :link '(custom-manual "(gnus)Group Parameters")
6266 (defcustom gnus-button-message-level 5
6267 "*Integer that says how many buttons for news or mail messages will appear.
6268 The higher the number, the more buttons will appear and the more false
6269 positives are possible."
6270 ;; mail addresses, MIDs, URLs for news, ...
6272 :group 'gnus-article-buttons
6275 (defcustom gnus-button-browse-level 5
6276 "*Integer that says how many buttons for browsing will appear.
6277 The higher the number, the more buttons will appear and the more false
6278 positives are possible."
6279 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6281 :group 'gnus-article-buttons
6284 (defcustom gnus-button-alist
6285 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6286 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6287 ((concat "\\b\\(nntp\\|news\\):\\("
6288 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6289 0 t gnus-button-handle-news 2)
6290 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6291 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6292 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6293 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6294 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6295 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6296 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6297 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6298 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6299 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6300 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6301 ;; RFC 2368 (The mailto URL scheme)
6302 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6303 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6304 ("\\bmailto:\\([^ \n\t]+\\)"
6305 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6307 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6308 gnus-button-ctan-directory-regexp
6309 "[^][>)!;:,'\n\t ]+\\)")
6310 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6311 ((concat "\\btex-archive/\\("
6312 gnus-button-ctan-directory-regexp
6313 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6314 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6317 gnus-button-ctan-directory-regexp
6318 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6319 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6320 ;; This is info (home-grown style) <info://foo/bar+baz>
6321 ("\\binfo://\\([^'\">\n\t ]+\\)"
6322 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6323 ;; Info GNOME style <info:foo#bar_baz>
6324 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6325 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6326 ;; Info KDE style <info:(foo)bar baz>
6327 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6328 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6329 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6330 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6331 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6332 ;; Info links like `C-h i d m CC Mode RET'
6333 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6335 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6336 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6337 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6338 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6339 ;; Emacs help commands
6340 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6341 ;; regexp doesn't match arguments containing ` '.
6342 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6343 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6344 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6345 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6346 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6347 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6348 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6349 ;; The following entries may lead to many false positives so don't enable
6350 ;; them by default (use a high button level).
6351 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6352 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6353 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6354 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6355 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6356 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6357 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6358 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6359 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6360 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6361 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6362 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6363 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6364 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6365 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6366 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6367 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6368 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6369 ;; Unlike the other regexps we really have to require quoting
6370 ;; here to determine where it ends.
6371 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6372 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6373 ("<URL: *\\([^<>]*\\)>"
6374 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6375 ;; RFC 2396 (2.4.3., delims) ...
6376 ("\"URL: *\\([^\"]*\\)\""
6377 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6378 ;; RFC 2396 (2.4.3., delims) ...
6379 ("\"URL: *\\([^\"]*\\)\""
6380 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6382 (gnus-button-url-regexp
6383 0 (>= gnus-button-browse-level 0) browse-url 0)
6385 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6386 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6387 gnus-button-handle-man 1)
6388 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6389 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6390 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6391 gnus-button-handle-man 1)
6392 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6393 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6394 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6395 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6396 ;; MID or mail: To avoid too many false positives we don't try to catch
6397 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6398 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6399 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6400 ;; so that non-ambiguous entries (see above) match first.
6401 (gnus-button-mid-or-mail-regexp
6402 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6403 "*Alist of regexps matching buttons in article bodies.
6405 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6406 REGEXP: is the string (case insensitive) matching text around the button (can
6407 also be Lisp expression evaluating to a string),
6408 BUTTON: is the number of the regexp grouping actually matching the button,
6409 FORM: is a Lisp expression which must eval to true for the button to
6411 CALLBACK: is the function to call when the user push this button, and each
6412 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6414 CALLBACK can also be a variable, in that case the value of that
6415 variable it the real callback function."
6416 :group 'gnus-article-buttons
6417 :type '(repeat (list (choice regexp variable sexp)
6418 (integer :tag "Button")
6420 (function :tag "Callback")
6423 (integer :tag "Regexp group")))))
6425 (defcustom gnus-header-button-alist
6426 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6427 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6428 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6429 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6430 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6431 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6432 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6433 0 (>= gnus-button-browse-level 0) browse-url 0)
6434 ("^Subject:" gnus-button-url-regexp
6435 0 (>= gnus-button-browse-level 0) browse-url 0)
6436 ("^[^:]+:" gnus-button-url-regexp
6437 0 (>= gnus-button-browse-level 0) browse-url 0)
6438 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6439 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6440 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6441 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6442 "*Alist of headers and regexps to match buttons in article heads.
6444 This alist is very similar to `gnus-button-alist', except that each
6445 alist has an additional HEADER element first in each entry:
6447 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6449 HEADER is a regexp to match a header. For a fuller explanation, see
6450 `gnus-button-alist'."
6451 :group 'gnus-article-buttons
6452 :group 'gnus-article-headers
6453 :type '(repeat (list (regexp :tag "Header")
6454 (choice regexp variable)
6455 (integer :tag "Button")
6457 (function :tag "Callback")
6460 (integer :tag "Regexp group")))))
6462 (defvar gnus-button-regexp nil)
6463 (defvar gnus-button-marker-list nil)
6464 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6466 (defvar gnus-button-last nil)
6467 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6471 (defun gnus-article-push-button (event)
6472 "Check text under the mouse pointer for a callback function.
6473 If the text under the mouse pointer has a `gnus-callback' property,
6474 call it with the value of the `gnus-data' text property."
6476 (set-buffer (window-buffer (posn-window (event-start event))))
6477 (let* ((pos (posn-point (event-start event)))
6478 (data (get-text-property pos 'gnus-data))
6479 (fun (get-text-property pos 'gnus-callback)))
6482 (funcall fun data))))
6484 (defun gnus-article-press-button ()
6485 "Check text at point for a callback function.
6486 If the text at point has a `gnus-callback' property,
6487 call it with the value of the `gnus-data' text property."
6489 (let ((data (get-text-property (point) 'gnus-data))
6490 (fun (get-text-property (point) 'gnus-callback)))
6492 (funcall fun data))))
6494 (defun gnus-article-highlight (&optional force)
6495 "Highlight current article.
6496 This function calls `gnus-article-highlight-headers',
6497 `gnus-article-highlight-citation',
6498 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6499 do the highlighting. See the documentation for those functions."
6500 (interactive (list 'force))
6501 (gnus-article-highlight-headers)
6502 (gnus-article-highlight-citation force)
6503 (gnus-article-highlight-signature)
6504 (gnus-article-add-buttons force)
6505 (gnus-article-add-buttons-to-head))
6507 (defun gnus-article-highlight-some (&optional force)
6508 "Highlight current article.
6509 This function calls `gnus-article-highlight-headers',
6510 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6511 do the highlighting. See the documentation for those functions."
6512 (interactive (list 'force))
6513 (gnus-article-highlight-headers)
6514 (gnus-article-highlight-signature)
6515 (gnus-article-add-buttons))
6517 (defun gnus-article-highlight-headers ()
6518 "Highlight article headers as specified by `gnus-header-face-alist'."
6521 (set-buffer gnus-article-buffer)
6523 (let ((alist gnus-header-face-alist)
6524 (inhibit-read-only t)
6525 (case-fold-search t)
6526 (inhibit-point-motion-hooks t)
6527 entry regexp header-face field-face from hpoints fpoints)
6528 (article-narrow-to-head)
6529 (while (setq entry (pop alist))
6530 (goto-char (point-min))
6531 (setq regexp (concat "^\\("
6532 (if (string-equal "" (nth 0 entry))
6536 header-face (nth 1 entry)
6537 field-face (nth 2 entry))
6538 (while (and (re-search-forward regexp nil t)
6542 (unless (search-forward ":" nil t)
6544 (when (and header-face
6545 (not (memq (point) hpoints)))
6546 (push (point) hpoints)
6547 (gnus-put-text-property from (point) 'face header-face))
6548 (when (and field-face
6549 (not (memq (setq from (point)) fpoints)))
6551 (if (re-search-forward "^[^ \t]" nil t)
6553 (goto-char (point-max)))
6554 (gnus-put-text-property from (point) 'face field-face))))))))
6556 (defun gnus-article-highlight-signature ()
6557 "Highlight the signature in an article.
6558 It does this by highlighting everything after
6559 `gnus-signature-separator' using the face `gnus-signature'."
6562 (set-buffer gnus-article-buffer)
6563 (let ((inhibit-read-only t)
6564 (inhibit-point-motion-hooks t))
6566 (when (and gnus-signature-face
6567 (gnus-article-narrow-to-signature))
6568 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6569 'face gnus-signature-face)
6571 (gnus-article-search-signature)
6572 (let ((start (match-beginning 0))
6573 (end (set-marker (make-marker) (1+ (match-end 0)))))
6574 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6577 (defun gnus-button-in-region-p (b e prop)
6578 "Say whether PROP exists in the region."
6579 (text-property-not-all b e prop nil))
6581 (defun gnus-article-add-buttons (&optional force)
6582 "Find external references in the article and make buttons of them.
6583 \"External references\" are things like Message-IDs and URLs, as
6584 specified by `gnus-button-alist'."
6585 (interactive (list 'force))
6587 (set-buffer gnus-article-buffer)
6588 (let ((inhibit-read-only t)
6589 (inhibit-point-motion-hooks t)
6590 (case-fold-search t)
6591 (alist gnus-button-alist)
6593 ;; Remove all old markers.
6594 (let (marker entry new-list)
6595 (while (setq marker (pop gnus-button-marker-list))
6596 (if (or (< marker (point-min)) (>= marker (point-max)))
6597 (push marker new-list)
6599 (when (setq entry (gnus-button-entry))
6600 (put-text-property (match-beginning (nth 1 entry))
6601 (match-end (nth 1 entry))
6602 'gnus-callback nil))
6603 (set-marker marker nil)))
6604 (setq gnus-button-marker-list new-list))
6605 ;; We skip the headers.
6608 (while (setq entry (pop alist))
6609 (setq regexp (eval (car entry)))
6611 (while (re-search-forward regexp nil t)
6612 (let* ((start (and entry (match-beginning (nth 1 entry))))
6613 (end (and entry (match-end (nth 1 entry))))
6614 (from (match-beginning 0)))
6615 (when (and (or (eq t (nth 2 entry))
6616 (eval (nth 2 entry)))
6617 (not (gnus-button-in-region-p
6618 start end 'gnus-callback)))
6619 ;; That optional form returned non-nil, so we add the
6621 (gnus-article-add-button
6622 start end 'gnus-button-push
6623 (car (push (set-marker (make-marker) from)
6624 gnus-button-marker-list))))))))))
6626 ;; Add buttons to the head of an article.
6627 (defun gnus-article-add-buttons-to-head ()
6628 "Add buttons to the head of the article."
6631 (set-buffer gnus-article-buffer)
6633 (let ((inhibit-read-only t)
6634 (inhibit-point-motion-hooks t)
6635 (case-fold-search t)
6636 (alist gnus-header-button-alist)
6638 (article-narrow-to-head)
6640 ;; Each alist entry.
6641 (setq entry (car alist)
6643 (goto-char (point-min))
6644 (while (re-search-forward (car entry) nil t)
6645 ;; Each header matching the entry.
6646 (setq beg (match-beginning 0))
6647 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6648 (match-beginning 0))
6651 (while (re-search-forward (eval (nth 1 entry)) end t)
6652 ;; Each match within a header.
6653 (let* ((entry (cdr entry))
6654 (start (match-beginning (nth 1 entry)))
6655 (end (match-end (nth 1 entry)))
6656 (form (nth 2 entry)))
6657 (goto-char (match-end 0))
6659 (gnus-article-add-button
6660 start end (nth 3 entry)
6661 (buffer-substring (match-beginning (nth 4 entry))
6662 (match-end (nth 4 entry)))))))
6663 (goto-char end)))))))
6665 ;;; External functions:
6667 (defun gnus-article-add-button (from to fun &optional data)
6668 "Create a button between FROM and TO with callback FUN and data DATA."
6669 (when gnus-article-button-face
6670 (gnus-overlay-put (gnus-make-overlay from to)
6671 'face gnus-article-button-face))
6672 (gnus-add-text-properties
6674 (nconc (and gnus-article-mouse-face
6675 (list gnus-mouse-face-prop gnus-article-mouse-face))
6676 (list 'gnus-callback fun)
6677 (and data (list 'gnus-data data))))
6678 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6679 :button-keymap gnus-widget-button-keymap))
6681 ;;; Internal functions:
6683 (defun gnus-article-set-globals ()
6685 (set-buffer gnus-summary-buffer)
6686 (gnus-set-global-variables)))
6688 (defun gnus-signature-toggle (end)
6690 (set-buffer gnus-article-buffer)
6691 (let ((inhibit-read-only t)
6692 (inhibit-point-motion-hooks t))
6693 (if (text-property-any end (point-max) 'article-type 'signature)
6695 (gnus-delete-wash-type 'signature)
6696 (gnus-remove-text-properties-when
6697 'article-type 'signature end (point-max)
6698 (cons 'article-type (cons 'signature
6699 gnus-hidden-properties))))
6700 (gnus-add-wash-type 'signature)
6701 (gnus-add-text-properties-when
6702 'article-type nil end (point-max)
6703 (cons 'article-type (cons 'signature
6704 gnus-hidden-properties)))))
6705 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6706 (gnus-set-mode-line 'article))))
6708 (defun gnus-button-entry ()
6709 ;; Return the first entry in `gnus-button-alist' matching this place.
6710 (let ((alist gnus-button-alist)
6713 (setq entry (pop alist))
6714 (if (looking-at (eval (car entry)))
6719 (defun gnus-button-push (marker)
6720 ;; Push button starting at MARKER.
6723 (let* ((entry (gnus-button-entry))
6724 (inhibit-point-motion-hooks t)
6726 (args (mapcar (lambda (group)
6727 (let ((string (match-string group)))
6728 (gnus-set-text-properties
6729 0 (length string) nil string)
6736 (fboundp (symbol-value fun)))
6737 (apply (symbol-value fun) args))
6739 (gnus-message 1 "You must define `%S' to use this button"
6740 (cons fun args)))))))
6742 (defun gnus-parse-news-url (url)
6743 (let (scheme server port group message-id articles)
6746 (goto-char (point-min))
6747 (when (looking-at "\\([A-Za-z]+\\):")
6748 (setq scheme (match-string 1))
6749 (goto-char (match-end 0)))
6750 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
6751 (setq server (match-string 1))
6752 (setq port (if (stringp (match-string 3))
6753 (string-to-number (match-string 3))
6755 (goto-char (match-end 0)))
6758 ((looking-at "\\(.*@.*\\)")
6759 (setq message-id (match-string 1)))
6760 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6761 (setq group (match-string 1)
6762 articles (split-string (match-string 2) "-")))
6763 ((looking-at "\\([^/]+\\)/?")
6764 (setq group (match-string 1)))
6766 (error "Unknown news URL syntax"))))
6767 (list scheme server port group message-id articles)))
6769 (defun gnus-button-handle-news (url)
6771 (destructuring-bind (scheme server port group message-id articles)
6772 (gnus-parse-news-url url)
6776 (set-buffer gnus-summary-buffer)
6778 (let ((gnus-refer-article-method
6779 (nconc (list (list 'nntp server))
6780 gnus-refer-article-method))
6781 (nntp-port-number (or port "nntp")))
6782 (gnus-message 7 "Fetching %s with %s"
6783 message-id gnus-refer-article-method)
6784 (gnus-summary-refer-article message-id))
6785 (gnus-summary-refer-article message-id))))
6787 (gnus-button-fetch-group url)))))
6789 (defun gnus-button-handle-man (url)
6791 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6792 (when (eq gnus-button-man-handler 'woman)
6793 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
6794 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6795 (funcall gnus-button-man-handler url))
6797 (defun gnus-button-handle-info-url (url)
6798 "Fetch an info URL."
6799 (setq url (mm-subst-char-in-string ?+ ?\ url))
6801 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6802 (gnus-info-find-node
6803 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6805 ")" (gnus-url-unhex-string (match-string 2 url)))))
6806 ((string-match "([^)\"]+)[^\"]+" url)
6808 (gnus-replace-in-string
6809 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6810 (gnus-info-find-node url))
6811 (t (error "Can't parse %s" url))))
6813 (defun gnus-button-handle-info-url-gnome (url)
6814 "Fetch GNOME style info URL."
6815 (setq url (mm-subst-char-in-string ?_ ?\ url))
6816 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6817 (gnus-info-find-node
6819 (gnus-url-unhex-string
6820 (match-string 1 url))
6822 (or (gnus-url-unhex-string
6823 (match-string 2 url))
6825 (error "Can't parse %s" url)))
6827 (defun gnus-button-handle-info-url-kde (url)
6828 "Fetch KDE style info URL."
6829 (gnus-info-find-node (gnus-url-unhex-string url)))
6831 (defun gnus-button-handle-info-keystrokes (url)
6832 "Call `info' when pushing the corresponding URL button."
6833 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6838 (defun gnus-button-message-id (message-id)
6841 (set-buffer gnus-summary-buffer)
6842 (gnus-summary-refer-article message-id)))
6844 (defun gnus-button-fetch-group (address)
6845 "Fetch GROUP specified by ADDRESS."
6846 (if (not (string-match "[:/]" address))
6847 ;; This is just a simple group url.
6848 (gnus-group-read-ephemeral-group address gnus-select-method)
6851 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6853 (error "Can't parse %s" address)
6854 (gnus-group-read-ephemeral-group
6855 (match-string 4 address)
6856 `(nntp ,(match-string 1 address)
6857 (nntp-address ,(match-string 1 address))
6858 (nntp-port-number ,(if (match-end 3)
6859 (match-string 3 address)
6862 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
6864 (defun gnus-url-parse-query-string (query &optional downcase)
6865 (let (retval pairs cur key val)
6866 (setq pairs (split-string query "&"))
6868 (setq cur (car pairs)
6870 (if (not (string-match "=" cur))
6872 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6873 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6875 (setq key (downcase key)))
6876 (setq cur (assoc key retval))
6878 (setcdr cur (cons val (cdr cur)))
6879 (setq retval (cons (list key val) retval)))))
6882 (defun gnus-url-mailto (url)
6883 ;; Send mail to someone
6884 (when (string-match "mailto:/*\\(.*\\)" url)
6885 (setq url (substring url (match-beginning 1) nil)))
6886 (let (to args subject func)
6887 (setq args (gnus-url-parse-query-string
6888 (if (string-match "^\\?" url)
6890 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6891 (concat "to=" (match-string 1 url) "&"
6892 (match-string 2 url))
6893 (concat "to=" url)))
6895 subject (cdr-safe (assoc "subject" args)))
6898 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6901 (message-position-on-field (caar args)))
6902 (insert (gnus-replace-in-string
6903 (mapconcat 'identity (reverse (cdar args)) ", ")
6905 (setq args (cdr args)))
6908 (message-goto-subject))))
6910 (defun gnus-button-embedded-url (address)
6911 "Activate ADDRESS with `browse-url'."
6912 (browse-url (gnus-strip-whitespace address)))
6914 ;;; Next/prev buttons in the article buffer.
6916 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6917 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6919 (defvar gnus-prev-page-map
6920 (let ((map (make-sparse-keymap)))
6921 (unless (>= emacs-major-version 21)
6922 ;; XEmacs doesn't care.
6923 (set-keymap-parent map gnus-article-mode-map))
6924 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6925 (define-key map "\r" 'gnus-button-prev-page)
6928 (defvar gnus-next-page-map
6929 (let ((map (make-sparse-keymap)))
6930 (unless (>= emacs-major-version 21)
6931 ;; XEmacs doesn't care.
6932 (set-keymap-parent map gnus-article-mode-map))
6933 (define-key map gnus-mouse-2 'gnus-button-next-page)
6934 (define-key map "\r" 'gnus-button-next-page)
6937 (defun gnus-insert-prev-page-button ()
6939 (inhibit-read-only t))
6941 gnus-prev-page-line-format nil
6942 `(,@(gnus-local-map-property gnus-prev-page-map)
6944 gnus-callback gnus-article-button-prev-page
6945 article-type annotation))
6946 (widget-convert-button
6948 ;; Exclude a newline.
6951 :action 'gnus-button-prev-page
6952 :button-keymap gnus-prev-page-map)))
6954 (defun gnus-button-next-page (&optional args more-args)
6955 "Go to the next page."
6957 (let ((win (selected-window)))
6958 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6959 (gnus-article-next-page)
6960 (select-window win)))
6962 (defun gnus-button-prev-page (&optional args more-args)
6963 "Go to the prev page."
6965 (let ((win (selected-window)))
6966 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6967 (gnus-article-prev-page)
6968 (select-window win)))
6970 (defun gnus-insert-next-page-button ()
6972 (inhibit-read-only t))
6973 (gnus-eval-format gnus-next-page-line-format nil
6974 `(,@(gnus-local-map-property gnus-next-page-map)
6976 gnus-callback gnus-article-button-next-page
6977 article-type annotation))
6978 (widget-convert-button
6980 ;; Exclude a newline.
6983 :action 'gnus-button-next-page
6984 :button-keymap gnus-next-page-map)))
6986 (defun gnus-article-button-next-page (arg)
6987 "Go to the next page."
6989 (let ((win (selected-window)))
6990 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6991 (gnus-article-next-page)
6992 (select-window win)))
6994 (defun gnus-article-button-prev-page (arg)
6995 "Go to the prev page."
6997 (let ((win (selected-window)))
6998 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6999 (gnus-article-prev-page)
7000 (select-window win)))
7002 (defvar gnus-decode-header-methods
7003 '(mail-decode-encoded-word-region)
7004 "List of methods used to decode headers.
7006 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7007 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7008 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7009 whose names match REGEXP.
7012 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7013 mail-decode-encoded-word-region
7014 (\"chinese\" . rfc1843-decode-region))
7017 (defvar gnus-decode-header-methods-cache nil)
7019 (defun gnus-multi-decode-header (start end)
7020 "Apply the functions from `gnus-encoded-word-methods' that match."
7021 (unless (and gnus-decode-header-methods-cache
7022 (eq gnus-newsgroup-name
7023 (car gnus-decode-header-methods-cache)))
7024 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7027 (nconc gnus-decode-header-methods-cache (list x))
7028 (if (and gnus-newsgroup-name
7029 (string-match (car x) gnus-newsgroup-name))
7030 (nconc gnus-decode-header-methods-cache
7032 gnus-decode-header-methods))
7033 (let ((xlist gnus-decode-header-methods-cache))
7036 (narrow-to-region start end)
7038 (funcall (pop xlist) (point-min) (point-max))))))
7041 ;;; Treatment top-level handling.
7044 (defun gnus-treat-article (condition &optional part-number total-parts type)
7045 (let ((length (- (point-max) (point-min)))
7046 (alist gnus-treatment-function-alist)
7047 (article-goto-body-goes-to-point-min-p t)
7051 (let ((list gnus-article-treat-types))
7053 (when (string-match (pop list) type)
7054 (throw 'found t)))))))
7055 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7057 (gnus-run-hooks 'gnus-part-display-hook)
7058 (dolist (elem alist)
7061 (when (gnus-buffer-live-p gnus-summary-buffer)
7062 (set-buffer gnus-summary-buffer))
7063 (symbol-value (car elem))))
7064 (when (and (or (consp val)
7066 (gnus-treat-predicate val)
7067 (or (not (get (car elem) 'highlight))
7070 (funcall (cadr elem)))))))
7072 ;; Dynamic variables.
7074 (defvar part-number)
7075 (defvar total-parts)
7080 (defun gnus-treat-predicate (val)
7087 (stringp (car val)))
7088 (apply 'gnus-or (mapcar `(lambda (s)
7089 (string-match s ,(or gnus-newsgroup-name "")))
7092 (let ((pred (pop val)))
7095 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7097 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7099 (not (gnus-treat-predicate (car val))))
7101 (equal (car val) type))
7103 (error "%S is not a valid predicate" pred)))))
7109 (eq part-number total-parts))
7113 (error "%S is not a valid value" val))))
7115 (defun gnus-article-encrypt-body (protocol &optional n)
7116 "Encrypt the article body."
7119 (or gnus-article-encrypt-protocol
7120 (completing-read "Encrypt protocol: "
7121 gnus-article-encrypt-protocol-alist
7123 current-prefix-arg))
7124 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7126 (error "Can't find the encrypt protocol %s" protocol))
7127 (if (member gnus-newsgroup-name '("nndraft:delayed"
7130 (error "Can't encrypt the article in group %s"
7131 gnus-newsgroup-name))
7132 (gnus-summary-iterate n
7134 (set-buffer gnus-summary-buffer)
7135 (let ((mail-parse-charset gnus-newsgroup-charset)
7136 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7137 (summary-buffer gnus-summary-buffer)
7139 (gnus-set-global-variables)
7140 (when (gnus-group-read-only-p)
7141 (error "The current newsgroup does not support article encrypt"))
7142 (gnus-summary-show-article t)
7144 (or (mail-header-references gnus-current-headers) ""))
7145 (set-buffer gnus-article-buffer)
7146 (let* ((inhibit-read-only t)
7148 (mapcar (lambda (field)
7149 (and (save-restriction
7150 (message-narrow-to-head)
7151 (goto-char (point-min))
7152 (search-forward field nil t))
7154 (message-narrow-to-field)
7156 (delete-region (point-min) (point-max))
7158 '("Content-Type:" "Content-Transfer-Encoding:"
7159 "Content-Disposition:"))))
7160 (message-narrow-to-head)
7161 (message-remove-header "MIME-Version")
7162 (goto-char (point-max))
7163 (setq point (point))
7164 (insert (apply 'concat headers))
7166 (narrow-to-region point (point-max))
7167 (let ((message-options message-options))
7168 (message-options-set 'message-sender user-mail-address)
7169 (message-options-set 'message-recipients user-mail-address)
7170 (message-options-set 'message-sign-encrypt 'not)
7172 (goto-char (point-min))
7173 (insert "MIME-Version: 1.0\n")
7175 (gnus-summary-edit-article-done
7176 references nil summary-buffer t))
7177 (when gnus-keep-backlog
7178 (gnus-backlog-remove-article
7179 (car gnus-article-current) (cdr gnus-article-current)))
7181 (when (get-buffer gnus-original-article-buffer)
7182 (set-buffer gnus-original-article-buffer)
7183 (setq gnus-original-article nil)))
7184 (when gnus-use-cache
7185 (gnus-cache-update-article
7186 (car gnus-article-current) (cdr gnus-article-current))))))))
7188 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7189 "The following specs can be used:
7190 %t The security MIME type
7193 %D Details if button is pressed")
7195 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7196 "The following specs can be used:
7197 %t The security MIME type
7200 %D Details if button is pressed")
7202 (defvar gnus-mime-security-button-line-format-alist
7203 '((?t gnus-tmp-type ?s)
7204 (?i gnus-tmp-info ?s)
7205 (?d gnus-tmp-details ?s)
7206 (?D gnus-tmp-pressed-details ?s)))
7208 (defvar gnus-mime-security-button-map
7209 (let ((map (make-sparse-keymap)))
7210 (unless (>= (string-to-number emacs-version) 21)
7211 (set-keymap-parent map gnus-article-mode-map))
7212 (define-key map gnus-mouse-2 'gnus-article-push-button)
7213 (define-key map "\r" 'gnus-article-press-button)
7216 (defvar gnus-mime-security-details-buffer nil)
7218 (defvar gnus-mime-security-button-pressed nil)
7220 (defvar gnus-mime-security-show-details-inline t
7221 "If non-nil, show details in the article buffer.")
7223 (defun gnus-mime-security-verify-or-decrypt (handle)
7224 (mm-remove-parts (cdr handle))
7225 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7226 point (inhibit-read-only t))
7228 (goto-char (car region)))
7230 (narrow-to-region (point) (point))
7231 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7232 (let* ((mm-verify-option 'known)
7233 (mm-decrypt-option 'known)
7234 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7235 (unless (eq nparts (cdr handle))
7236 (mm-destroy-parts (cdr handle))
7237 (setcdr handle nparts))))
7238 (setq point (point))
7239 (gnus-mime-display-security handle)
7240 (goto-char (point-max)))
7242 (delete-region (point) (cdr region))
7243 (set-marker (car region) nil)
7244 (set-marker (cdr region) nil))
7247 (defun gnus-mime-security-show-details (handle)
7248 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7250 (gnus-message 5 "No details.")
7251 (if gnus-mime-security-show-details-inline
7252 (let ((gnus-mime-security-button-pressed
7253 (not (get-text-property (point) 'gnus-mime-details)))
7254 (gnus-mime-security-button-line-format
7255 (get-text-property (point) 'gnus-line-format))
7256 (inhibit-read-only t))
7258 (while (eq (get-text-property (point) 'gnus-line-format)
7259 gnus-mime-security-button-line-format)
7263 (narrow-to-region (point) (point))
7264 (gnus-insert-mime-security-button handle))
7265 (delete-region (point)
7266 (or (text-property-not-all
7269 gnus-mime-security-button-line-format)
7272 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7273 (with-current-buffer gnus-mime-security-details-buffer
7276 (setq gnus-mime-security-details-buffer
7277 (gnus-get-buffer-create "*MIME Security Details*")))
7278 (with-current-buffer gnus-mime-security-details-buffer
7280 (goto-char (point-min)))
7281 (pop-to-buffer gnus-mime-security-details-buffer)))))
7283 (defun gnus-mime-security-press-button (handle)
7285 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7286 (gnus-mime-security-show-details handle)
7287 (gnus-mime-security-verify-or-decrypt handle))))
7289 (defun gnus-insert-mime-security-button (handle &optional displayed)
7290 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7293 (or (nth 2 (assoc protocol mm-verify-function-alist))
7294 (nth 2 (assoc protocol mm-decrypt-function-alist))
7296 (if (equal (car handle) "multipart/signed")
7297 " Signed" " Encrypted")
7300 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7303 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7304 gnus-tmp-pressed-details
7306 (setq gnus-tmp-details
7307 (if gnus-tmp-details
7308 (concat "\n" gnus-tmp-details)
7310 (setq gnus-tmp-pressed-details
7311 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7316 gnus-mime-security-button-line-format
7317 gnus-mime-security-button-line-format-alist
7318 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7319 gnus-callback gnus-mime-security-press-button
7320 gnus-line-format ,gnus-mime-security-button-line-format
7321 gnus-mime-details ,gnus-mime-security-button-pressed
7322 article-type annotation
7325 ;; Exclude a newline.
7328 (widget-convert-button
7331 :action 'gnus-widget-press-button
7332 :button-keymap gnus-mime-security-button-map
7334 (lambda (widget/window &optional overlay pos)
7335 ;; Needed to properly clear the message due to a bug in
7336 ;; wid-edit (XEmacs only).
7337 (when (boundp 'help-echo-owns-message)
7338 (setq help-echo-owns-message t))
7341 (aref gnus-mouse-2 0))))))
7343 (defun gnus-mime-display-security (handle)
7345 (narrow-to-region (point) (point))
7346 (unless (gnus-unbuttonized-mime-type-p (car handle))
7347 (gnus-insert-mime-security-button handle))
7348 (gnus-mime-display-mixed (cdr handle))
7351 (unless (gnus-unbuttonized-mime-type-p (car handle))
7352 (let ((gnus-mime-security-button-line-format
7353 gnus-mime-security-button-end-line-format))
7354 (gnus-insert-mime-security-button handle)))
7355 (mm-set-handle-multipart-parameter
7357 (cons (set-marker (make-marker) (point-min))
7358 (set-marker (make-marker) (point-max))))))
7364 (run-hooks 'gnus-art-load-hook)
7366 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7367 ;;; gnus-art.el ends here