1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
31 (defvar tool-bar-map))
46 (autoload 'gnus-msg-mail "gnus-msg" nil t)
47 (autoload 'gnus-button-mailto "gnus-msg")
48 (autoload 'gnus-button-reply "gnus-msg" nil t)
49 (autoload 'parse-time-string "parse-time" nil nil)
51 (defgroup gnus-article nil
53 :link '(custom-manual "(gnus)Article Buffer")
56 (defgroup gnus-article-treat nil
57 "Treating article parts."
58 :link '(custom-manual "(gnus)Article Hiding")
61 (defgroup gnus-article-hiding nil
62 "Hiding article parts."
63 :link '(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-highlight nil
67 "Article highlighting."
68 :link '(custom-manual "(gnus)Article Highlighting")
72 (defgroup gnus-article-signature nil
74 :link '(custom-manual "(gnus)Article Signature")
77 (defgroup gnus-article-headers nil
79 :link '(custom-manual "(gnus)Hiding Headers")
82 (defgroup gnus-article-washing nil
83 "Special commands on articles."
84 :link '(custom-manual "(gnus)Article Washing")
87 (defgroup gnus-article-emphasis nil
88 "Fontisizing articles."
89 :link '(custom-manual "(gnus)Article Fontisizing")
92 (defgroup gnus-article-saving nil
94 :link '(custom-manual "(gnus)Saving Articles")
97 (defgroup gnus-article-mime nil
98 "Worshiping the MIME wonder."
99 :link '(custom-manual "(gnus)Using MIME")
100 :group 'gnus-article)
102 (defgroup gnus-article-buttons nil
103 "Pushable buttons in the article buffer."
104 :link '(custom-manual "(gnus)Article Buttons")
105 :group 'gnus-article)
107 (defgroup gnus-article-various nil
108 "Other article options."
109 :link '(custom-manual "(gnus)Misc Article")
110 :group 'gnus-article)
112 (defcustom gnus-ignored-headers
115 (concat "^" header ":"))
116 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
117 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
118 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
119 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
120 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
121 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
122 "X-Attribution" "X-Originating-IP" "Delivered-To"
123 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
124 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
125 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
126 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
127 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
128 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
129 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
130 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
131 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
132 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
133 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
134 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
135 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
136 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
137 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
138 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
139 "List-[A-Za-z]+" "X-Listprocessor-Version"
140 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
141 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
142 "X-Received" "Content-length" "X-precedence"
143 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
144 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
145 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
146 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
147 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
148 "X-Content-length" "X-Posting-Agent" "Original-Received"
149 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
150 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
151 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
152 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
153 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
154 "*All headers that start with this regexp will be hidden.
155 This variable can also be a list of regexps of headers to be ignored.
156 If `gnus-visible-headers' is non-nil, this variable will be ignored."
157 :type '(choice :custom-show nil
160 :group 'gnus-article-hiding)
162 (defcustom gnus-visible-headers
163 "^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:"
164 "*All headers that do not match this regexp will be hidden.
165 This variable can also be a list of regexp of headers to remain visible.
166 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
167 :type '(repeat :value-to-internal (lambda (widget value)
168 (custom-split-regexp-maybe value))
169 :match (lambda (widget value)
171 (widget-editable-list-match widget value)))
173 :group 'gnus-article-hiding)
175 (defcustom gnus-sorted-header-list
176 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
177 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
178 "*This variable is a list of regular expressions.
179 If it is non-nil, headers that match the regular expressions will
180 be placed first in the article buffer in the sequence specified by
182 :type '(repeat regexp)
183 :group 'gnus-article-hiding)
185 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
186 "Headers that are only to be displayed if they have interesting data.
187 Possible values in this list are:
189 'empty Headers with no content.
190 'newsgroups Newsgroup identical to Gnus group.
191 'to-address To identical to To-address.
192 'to-list To identical to To-list.
193 'cc-list CC identical to To-list.
194 'followup-to Followup-to identical to Newsgroups.
195 'reply-to Reply-to identical to From.
196 'date Date less than four days old.
197 'long-to To and/or Cc longer than 1024 characters.
198 'many-to Multiple To and/or Cc."
199 :type '(set (const :tag "Headers with no content." empty)
200 (const :tag "Newsgroups identical to Gnus group." newsgroups)
201 (const :tag "To identical to To-address." to-address)
202 (const :tag "To identical to To-list." to-list)
203 (const :tag "CC identical to To-list." cc-list)
204 (const :tag "Followup-to identical to Newsgroups." followup-to)
205 (const :tag "Reply-to identical to From." reply-to)
206 (const :tag "Date less than four days old." date)
207 (const :tag "To and/or Cc longer than 1024 characters." long-to)
208 (const :tag "Multiple To and/or Cc headers." many-to))
209 :group 'gnus-article-hiding)
211 (defcustom gnus-article-skip-boring nil
212 "Skip over text that is not worth reading.
213 By default, if you set this t, then Gnus will display citations and
214 signatures, but will never scroll down to show you a page consisting
215 only of boring text. Boring text is controlled by
216 `gnus-article-boring-faces'."
219 :group 'gnus-article-hiding)
221 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
222 "Regexp matching signature separator.
223 This can also be a list of regexps. In that case, it will be checked
224 from head to tail looking for a separator. Searches will be done from
225 the end of the buffer."
226 :type '(repeat string)
227 :group 'gnus-article-signature)
229 (defcustom gnus-signature-limit nil
230 "Provide a limit to what is considered a signature.
231 If it is a number, no signature may not be longer (in characters) than
232 that number. If it is a floating point number, no signature may be
233 longer (in lines) than that number. If it is a function, the function
234 will be called without any parameters, and if it returns nil, there is
235 no signature in the buffer. If it is a string, it will be used as a
236 regexp. If it matches, the text in question is not a signature."
237 :type '(choice (integer :value 200)
239 (function :value fun)
240 (regexp :value ".*"))
241 :group 'gnus-article-signature)
243 (defcustom gnus-hidden-properties '(invisible t intangible t)
244 "Property list to use for hiding text."
246 :group 'gnus-article-hiding)
248 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
249 ;; frames in a session.
250 (defcustom gnus-article-x-face-command
251 (if (featurep 'xemacs)
252 (if (or (gnus-image-type-available-p 'xface)
253 (gnus-image-type-available-p 'pbm))
254 'gnus-display-x-face-in-from
255 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
256 (if (gnus-image-type-available-p 'pbm)
257 'gnus-display-x-face-in-from
258 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
260 "*String or function to be executed to display an X-Face header.
261 If it is a string, the command will be executed in a sub-shell
262 asynchronously. The compressed face will be piped to this command."
263 :type `(choice string
264 (function-item gnus-display-x-face-in-from)
268 :group 'gnus-article-washing)
270 (defcustom gnus-article-x-face-too-ugly nil
271 "Regexp matching posters whose face shouldn't be shown automatically."
272 :type '(choice regexp (const nil))
273 :group 'gnus-article-washing)
275 (defcustom gnus-article-banner-alist nil
276 "Banner alist for stripping.
278 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
280 :type '(repeat (cons symbol regexp))
281 :group 'gnus-article-washing)
283 (gnus-define-group-parameter
286 "Alist of regexps (to match group names) and banner."
287 :variable-group gnus-article-washing
289 '(choice :tag "Banner"
291 (const :tag "Remove signature" signature)
292 (symbol :tag "Item in `gnus-article-banner-alist'" none)
294 (const :tag "None" nil))
296 "If non-nil, specify how to remove `banners' from articles.
298 Symbol `signature' means to remove signatures delimited by
299 `gnus-signature-separator'. Any other symbol is used to look up a
300 regular expression to match the banner in `gnus-article-banner-alist'.
301 A string is used as a regular expression to match the banner
304 (defcustom gnus-article-address-banner-alist nil
305 "Alist of mail addresses and banners.
306 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
307 to match a mail address in the From: header, BANNER is one of a symbol
308 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
309 If ADDRESS matches author's mail address, it will remove things like
310 advertisements. For example:
312 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
316 (regexp :tag "Address")
317 (choice :tag "Banner" :value nil
318 (const :tag "Remove signature" signature)
319 (symbol :tag "Item in `gnus-article-banner-alist'" none)
321 (const :tag "None" nil))))
323 :group 'gnus-article-washing)
325 (defmacro gnus-emphasis-custom-with-format (&rest body)
327 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
328 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
331 (defun gnus-emphasis-custom-value-to-external (value)
332 (gnus-emphasis-custom-with-format
333 (if (consp (car value))
334 (list (format format (car (car value)) (cdr (car value)))
336 (if (nth 1 value) 2 3)
340 (defun gnus-emphasis-custom-value-to-internal (value)
341 (gnus-emphasis-custom-with-format
342 (let ((regexp (concat "\\`"
343 (format (regexp-quote format)
344 "\\([^()]+\\)" "\\([^()]+\\)")
347 (if (string-match regexp (setq pattern (car value)))
348 (list (cons (match-string 1 pattern) (match-string 2 pattern))
353 (defcustom gnus-emphasis-alist
355 '(("\\*" "\\*" bold nil 2)
358 ("_/" "/_" underline-italic)
359 ("_\\*" "\\*_" underline-bold)
360 ("\\*/" "/\\*" bold-italic)
361 ("_\\*/" "/\\*_" underline-bold-italic))))
363 (gnus-emphasis-custom-with-format
364 (mapcar (lambda (spec)
365 (list (format format (car spec) (cadr spec))
368 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
370 '(;; I've never seen anyone use this strikethru convention whereas I've
371 ;; several times seen it triggered by normal text. --Stef
372 ;; Miles suggests that this form is sometimes used but for italics,
373 ;; so maybe we should map it to `italic'.
374 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
375 ;; 2 3 gnus-emphasis-strikethru)
376 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
377 2 3 gnus-emphasis-underline))))
378 "*Alist that says how to fontify certain phrases.
379 Each item looks like this:
381 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
383 The first element is a regular expression to be matched. The second
384 is a number that says what regular expression grouping used to find
385 the entire emphasized word. The third is a number that says what
386 regexp grouping should be displayed and highlighted. The fourth
387 is the face used for highlighting."
391 :format "%[Customizing Style%]\n%v"
393 (group :tag "Default"
394 :value ("" 0 0 default)
397 (let ((value (widget-get
398 (cadr (widget-get (widget-get widget :parent)
401 (if (not (eq (nth 2 value) 'default))
405 (gnus-emphasis-custom-value-to-external value))))
406 (widget-group-value-create widget))
408 (integer :format "Match group: %v")
409 (integer :format "Emphasize group: %v")
412 :value (("_" . "_") nil default)
414 (regexp :format "Start regexp: %v")
415 (regexp :format "End regexp: %v"))
416 (boolean :format "Show start and end patterns: %[%v%]\n"
417 :on " On " :off " Off ")
419 :get (lambda (symbol)
420 (mapcar 'gnus-emphasis-custom-value-to-internal
421 (default-value symbol)))
422 :set (lambda (symbol value)
423 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
425 :group 'gnus-article-emphasis)
427 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
428 "A regexp to describe whitespace which should not be emphasized.
429 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
430 The former avoids underlining of leading and trailing whitespace,
431 and the latter avoids underlining any whitespace at all."
433 :group 'gnus-article-emphasis
436 (defface gnus-emphasis-bold '((t (:bold t)))
437 "Face used for displaying strong emphasized text (*word*)."
438 :group 'gnus-article-emphasis)
440 (defface gnus-emphasis-italic '((t (:italic t)))
441 "Face used for displaying italic emphasized text (/word/)."
442 :group 'gnus-article-emphasis)
444 (defface gnus-emphasis-underline '((t (:underline t)))
445 "Face used for displaying underlined emphasized text (_word_)."
446 :group 'gnus-article-emphasis)
448 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
449 "Face used for displaying underlined bold emphasized text (_*word*_)."
450 :group 'gnus-article-emphasis)
452 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
453 "Face used for displaying underlined italic emphasized text (_/word/_)."
454 :group 'gnus-article-emphasis)
456 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
457 "Face used for displaying bold italic emphasized text (/*word*/)."
458 :group 'gnus-article-emphasis)
460 (defface gnus-emphasis-underline-bold-italic
461 '((t (:bold t :italic t :underline t)))
462 "Face used for displaying underlined bold italic emphasized text.
463 Example: (_/*word*/_)."
464 :group 'gnus-article-emphasis)
466 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
467 '((t (:strikethru t)))
468 '((t (:strike-through t))))
469 "Face used for displaying strike-through text (-word-)."
470 :group 'gnus-article-emphasis)
472 (defface gnus-emphasis-highlight-words
473 '((t (:background "black" :foreground "yellow")))
474 "Face used for displaying highlighted words."
475 :group 'gnus-article-emphasis)
477 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
478 "Format for display of Date headers in article bodies.
479 See `format-time-string' for the possible values.
481 The variable can also be function, which should return a complete Date
482 header. The function is called with one argument, the time, which can
483 be fed to `format-time-string'."
484 :type '(choice string symbol)
485 :link '(custom-manual "(gnus)Article Date")
486 :group 'gnus-article-washing)
488 (defcustom gnus-save-all-headers t
489 "*If non-nil, don't remove any headers before saving."
490 :group 'gnus-article-saving
493 (defcustom gnus-prompt-before-saving 'always
494 "*This variable says how much prompting is to be done when saving articles.
495 If it is nil, no prompting will be done, and the articles will be
496 saved to the default files. If this variable is `always', each and
497 every article that is saved will be preceded by a prompt, even when
498 saving large batches of articles. If this variable is neither nil not
499 `always', there the user will be prompted once for a file name for
500 each invocation of the saving commands."
501 :group 'gnus-article-saving
502 :type '(choice (item always)
503 (item :tag "never" nil)
504 (sexp :tag "once" :format "%t\n" :value t)))
506 (defcustom gnus-saved-headers gnus-visible-headers
507 "Headers to keep if `gnus-save-all-headers' is nil.
508 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
509 If that variable is nil, however, all headers that match this regexp
510 will be kept while the rest will be deleted before saving."
511 :group 'gnus-article-saving
514 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
515 "A function to save articles in your favourite format.
516 The function must be interactively callable (in other words, it must
517 be an Emacs command).
519 Gnus provides the following functions:
521 * gnus-summary-save-in-rmail (Rmail format)
522 * gnus-summary-save-in-mail (Unix mail format)
523 * gnus-summary-save-in-folder (MH folder)
524 * gnus-summary-save-in-file (article format)
525 * gnus-summary-save-body-in-file (article body)
526 * gnus-summary-save-in-vm (use VM's folder format)
527 * gnus-summary-write-to-file (article format -- overwrite)."
528 :group 'gnus-article-saving
529 :type '(radio (function-item gnus-summary-save-in-rmail)
530 (function-item gnus-summary-save-in-mail)
531 (function-item gnus-summary-save-in-folder)
532 (function-item gnus-summary-save-in-file)
533 (function-item gnus-summary-save-body-in-file)
534 (function-item gnus-summary-save-in-vm)
535 (function-item gnus-summary-write-to-file)))
537 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
538 "A function generating a file name to save articles in Rmail format.
539 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
540 :group 'gnus-article-saving
543 (defcustom gnus-mail-save-name 'gnus-plain-save-name
544 "A function generating a file name to save articles in Unix mail format.
545 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
546 :group 'gnus-article-saving
549 (defcustom gnus-folder-save-name 'gnus-folder-save-name
550 "A function generating a file name to save articles in MH folder.
551 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
552 :group 'gnus-article-saving
555 (defcustom gnus-file-save-name 'gnus-numeric-save-name
556 "A function generating a file name to save articles in article format.
557 The function is called with NEWSGROUP, HEADERS, and optional
559 :group 'gnus-article-saving
562 (defcustom gnus-split-methods
563 '((gnus-article-archive-name)
564 (gnus-article-nndoc-name))
565 "*Variable used to suggest where articles are to be saved.
566 For instance, if you would like to save articles related to Gnus in
567 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
568 you could set this variable to something like:
570 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
571 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
573 This variable is an alist where the where the key is the match and the
574 value is a list of possible files to save in if the match is non-nil.
576 If the match is a string, it is used as a regexp match on the
577 article. If the match is a symbol, that symbol will be funcalled
578 from the buffer of the article to be saved with the newsgroup as the
579 parameter. If it is a list, it will be evaled in the same buffer.
581 If this form or function returns a string, this string will be used as
582 a possible file name; and if it returns a non-nil list, that list will
583 be used as possible file names."
584 :group 'gnus-article-saving
585 :type '(repeat (choice (list :value (fun) function)
586 (cons :value ("" "") regexp (repeat string))
589 (defcustom gnus-page-delimiter "^\^L"
590 "*Regexp describing what to use as article page delimiters.
591 The default value is \"^\^L\", which is a form linefeed at the
592 beginning of a line."
594 :group 'gnus-article-various)
596 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
597 "*The format specification for the article mode line.
598 See `gnus-summary-mode-line-format' for a closer description.
600 The following additional specs are available:
602 %w The article washing status.
603 %m The number of MIME parts in the article."
605 :group 'gnus-article-various)
607 (defcustom gnus-article-mode-hook nil
608 "*A hook for Gnus article mode."
610 :group 'gnus-article-various)
612 (when (featurep 'xemacs)
613 ;; Extracted from gnus-xmas-define in order to preserve user settings
614 (when (fboundp 'turn-off-scroll-in-place)
615 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
616 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
617 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
619 (defcustom gnus-article-menu-hook nil
620 "*Hook run after the creation of the article mode menu."
622 :group 'gnus-article-various)
624 (defcustom gnus-article-prepare-hook nil
625 "*A hook called after an article has been prepared in the article buffer."
627 :group 'gnus-article-various)
629 (make-obsolete-variable 'gnus-article-hide-pgp-hook
630 "This variable is obsolete in Gnus 5.10.")
632 (defcustom gnus-article-button-face 'bold
633 "Face used for highlighting buttons in the article buffer.
635 An article button is a piece of text that you can activate by pressing
636 `RET' or `mouse-2' above it."
638 :group 'gnus-article-buttons)
640 (defcustom gnus-article-mouse-face 'highlight
641 "Face used for mouse highlighting in the article buffer.
643 Article buttons will be displayed in this face when the cursor is
646 :group 'gnus-article-buttons)
648 (defcustom gnus-signature-face 'gnus-signature
649 "Face used for highlighting a signature in the article buffer.
650 Obsolete; use the face `gnus-signature' for customizations instead."
652 :group 'gnus-article-highlight
653 :group 'gnus-article-signature)
655 (defface gnus-signature
658 "Face used for highlighting a signature in the article buffer."
659 :group 'gnus-article-highlight
660 :group 'gnus-article-signature)
661 ;; backward-compatibility alias
662 (put 'gnus-signature-face 'face-alias 'gnus-signature)
664 (defface gnus-header-from
667 (:foreground "spring green"))
670 (:foreground "red3"))
673 "Face used for displaying from headers."
674 :group 'gnus-article-headers
675 :group 'gnus-article-highlight)
676 ;; backward-compatibility alias
677 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
679 (defface gnus-header-subject
682 (:foreground "SeaGreen3"))
685 (:foreground "red4"))
687 (:bold t :italic t)))
688 "Face used for displaying subject headers."
689 :group 'gnus-article-headers
690 :group 'gnus-article-highlight)
691 ;; backward-compatibility alias
692 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
694 (defface gnus-header-newsgroups
697 (:foreground "yellow" :italic t))
700 (:foreground "MidnightBlue" :italic t))
703 "Face used for displaying newsgroups headers.
704 In the default setup this face is only used for crossposted
706 :group 'gnus-article-headers
707 :group 'gnus-article-highlight)
708 ;; backward-compatibility alias
709 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
711 (defface gnus-header-name
714 (:foreground "SeaGreen"))
717 (:foreground "maroon"))
720 "Face used for displaying header names."
721 :group 'gnus-article-headers
722 :group 'gnus-article-highlight)
723 ;; backward-compatibility alias
724 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
726 (defface gnus-header-content
729 (:foreground "forest green" :italic t))
732 (:foreground "indianred4" :italic t))
734 (:italic t))) "Face used for displaying header content."
735 :group 'gnus-article-headers
736 :group 'gnus-article-highlight)
737 ;; backward-compatibility alias
738 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
740 (defcustom gnus-header-face-alist
741 '(("From" nil gnus-header-from)
742 ("Subject" nil gnus-header-subject)
743 ("Newsgroups:.*," nil gnus-header-newsgroups)
744 ("" gnus-header-name gnus-header-content))
745 "*Controls highlighting of article headers.
747 An alist of the form (HEADER NAME CONTENT).
749 HEADER is a regular expression which should match the name of a
750 header and NAME and CONTENT are either face names or nil.
752 The name of each header field will be displayed using the face
753 specified by the first element in the list where HEADER matches
754 the header name and NAME is non-nil. Similarly, the content will
755 be displayed by the first non-nil matching CONTENT face."
756 :group 'gnus-article-headers
757 :group 'gnus-article-highlight
758 :type '(repeat (list (regexp :tag "Header")
760 (item :tag "skip" nil)
761 (face :value default))
762 (choice :tag "Content"
763 (item :tag "skip" nil)
764 (face :value default)))))
766 (defcustom gnus-article-decode-hook
767 '(article-decode-charset article-decode-encoded-words
768 article-decode-group-name article-decode-idna-rhs)
769 "*Hook run to decode charsets in articles."
770 :group 'gnus-article-headers
773 (defcustom gnus-display-mime-function 'gnus-display-mime
774 "Function to display MIME articles."
775 :group 'gnus-article-mime
778 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
779 "Function used to decode headers.")
781 (defvar gnus-article-dumbquotes-map
801 "Table for MS-to-Latin1 translation.")
803 (defcustom gnus-ignored-mime-types nil
804 "List of MIME types that should be ignored by Gnus."
806 :group 'gnus-article-mime
807 :type '(repeat regexp))
809 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
810 "List of MIME types that should not be given buttons when rendered inline.
811 See also `gnus-buttonized-mime-types' which may override this variable.
812 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
814 :group 'gnus-article-mime
815 :type '(repeat regexp))
817 (defcustom gnus-buttonized-mime-types nil
818 "List of MIME types that should be given buttons when rendered inline.
819 If set, this variable overrides `gnus-unbuttonized-mime-types'.
820 To see e.g. security buttons you could set this to
821 `(\"multipart/signed\")'.
822 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
824 :group 'gnus-article-mime
825 :type '(repeat regexp))
827 (defcustom gnus-inhibit-mime-unbuttonizing nil
828 "If non-nil, all MIME parts get buttons.
829 When nil (the default value), then some MIME parts do not get buttons,
830 as described by the variables `gnus-buttonized-mime-types' and
831 `gnus-unbuttonized-mime-types'."
833 :group 'gnus-article-mime
836 (defcustom gnus-body-boundary-delimiter "_"
837 "String used to delimit header and body.
838 This variable is used by `gnus-article-treat-body-boundary' which can
839 be controlled by `gnus-treat-body-boundary'."
841 :group 'gnus-article-various
842 :type '(choice (item :tag "None" :value nil)
845 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
846 "Defines the location of the faces database.
847 For information on obtaining this database of pretty pictures, please
848 see http://www.cs.indiana.edu/picons/ftp/index.html"
850 :type '(repeat directory)
851 :link '(url-link :tag "download"
852 "http://www.cs.indiana.edu/picons/ftp/index.html")
853 :link '(custom-manual "(gnus)Picons")
856 (defun gnus-picons-installed-p ()
857 "Say whether picons are installed on your machine."
858 (let ((installed nil))
859 (dolist (database gnus-picon-databases)
860 (when (file-exists-p database)
864 (defcustom gnus-article-mime-part-function nil
865 "Function called with a MIME handle as the argument.
866 This is meant for people who want to do something automatic based
867 on parts -- for instance, adding Vcard info to a database."
868 :group 'gnus-article-mime
871 (defcustom gnus-mime-multipart-functions nil
872 "An alist of MIME types to functions to display them."
874 :group 'gnus-article-mime
877 (defcustom gnus-article-date-lapsed-new-header nil
878 "Whether the X-Sent and Date headers can coexist.
879 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
880 either replace the old \"Date:\" header (if this variable is nil), or
881 be added below it (otherwise)."
883 :group 'gnus-article-headers
886 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
887 "Function called with a MIME handle as the argument.
888 This is meant for people who want to view first matched part.
889 For `undisplayed-alternative' (default), the first undisplayed
890 part or alternative part is used. For `undisplayed', the first
891 undisplayed part is used. For a function, the first part which
892 the function return t is used. For nil, the first part is
895 :group 'gnus-article-mime
897 (item :tag "first" :value nil)
898 (item :tag "undisplayed" :value undisplayed)
899 (item :tag "undisplayed or alternative"
900 :value undisplayed-alternative)
903 (defcustom gnus-mime-action-alist
904 '(("save to file" . gnus-mime-save-part)
905 ("save and strip" . gnus-mime-save-part-and-strip)
906 ("delete part" . gnus-mime-delete-part)
907 ("display as text" . gnus-mime-inline-part)
908 ("view the part" . gnus-mime-view-part)
909 ("pipe to command" . gnus-mime-pipe-part)
910 ("toggle display" . gnus-article-press-button)
911 ("toggle display" . gnus-article-view-part-as-charset)
912 ("view as type" . gnus-mime-view-part-as-type)
913 ("view internally" . gnus-mime-view-part-internally)
914 ("view externally" . gnus-mime-view-part-externally))
915 "An alist of actions that run on the MIME attachment."
916 :group 'gnus-article-mime
917 :type '(repeat (cons (string :tag "name")
921 ;;; The treatment variables
924 (defvar gnus-part-display-hook nil
925 "Hook called on parts that are to receive treatment.")
927 (defvar gnus-article-treat-custom
928 '(choice (const :tag "Off" nil)
930 (const :tag "Header" head)
931 (const :tag "Last" last)
932 (integer :tag "Less")
933 (repeat :tag "Groups" regexp)
934 (sexp :tag "Predicate")))
936 (defvar gnus-article-treat-head-custom
937 '(choice (const :tag "Off" nil)
938 (const :tag "Header" head)))
940 (defvar gnus-article-treat-types '("text/plain")
943 (defvar gnus-inhibit-treatment nil
944 "Whether to inhibit treatment.")
946 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
947 "Highlight the signature.
948 Valid values are nil, t, `head', `last', an integer or a predicate.
949 See Info node `(gnus)Customizing Articles'."
950 :group 'gnus-article-treat
951 :link '(custom-manual "(gnus)Customizing Articles")
952 :type gnus-article-treat-custom)
953 (put 'gnus-treat-highlight-signature 'highlight t)
955 (defcustom gnus-treat-buttonize 100000
957 Valid values are nil, t, `head', `last', an integer or a predicate.
958 See Info node `(gnus)Customizing Articles'."
959 :group 'gnus-article-treat
960 :link '(custom-manual "(gnus)Customizing Articles")
961 :type gnus-article-treat-custom)
962 (put 'gnus-treat-buttonize 'highlight t)
964 (defcustom gnus-treat-buttonize-head 'head
965 "Add buttons to the head.
966 Valid values are nil, t, `head', `last', an integer or a predicate.
967 See Info node `(gnus)Customizing Articles' for details."
968 :group 'gnus-article-treat
969 :link '(custom-manual "(gnus)Customizing Articles")
970 :type gnus-article-treat-head-custom)
971 (put 'gnus-treat-buttonize-head 'highlight t)
973 (defcustom gnus-treat-emphasize
974 (and (or window-system
976 (>= (string-to-number emacs-version) 21))
979 Valid values are nil, t, `head', `last', an integer or a predicate.
980 See Info node `(gnus)Customizing Articles' for details."
981 :group 'gnus-article-treat
982 :link '(custom-manual "(gnus)Customizing Articles")
983 :type gnus-article-treat-custom)
984 (put 'gnus-treat-emphasize 'highlight t)
986 (defcustom gnus-treat-strip-cr nil
987 "Remove carriage returns.
988 Valid values are nil, t, `head', `last', an integer or a predicate.
989 See Info node `(gnus)Customizing Articles' for details."
991 :group 'gnus-article-treat
992 :link '(custom-manual "(gnus)Customizing Articles")
993 :type gnus-article-treat-custom)
995 (defcustom gnus-treat-unsplit-urls nil
996 "Remove newlines from within URLs.
997 Valid values are nil, t, `head', `last', an integer or a predicate.
998 See Info node `(gnus)Customizing Articles' for details."
1000 :group 'gnus-article-treat
1001 :link '(custom-manual "(gnus)Customizing Articles")
1002 :type gnus-article-treat-custom)
1004 (defcustom gnus-treat-leading-whitespace nil
1005 "Remove leading whitespace in headers.
1006 Valid values are nil, t, `head', `last', an integer or a predicate.
1007 See Info node `(gnus)Customizing Articles' for details."
1009 :group 'gnus-article-treat
1010 :link '(custom-manual "(gnus)Customizing Articles")
1011 :type gnus-article-treat-custom)
1013 (defcustom gnus-treat-hide-headers 'head
1015 Valid values are nil, t, `head', `last', an integer or a predicate.
1016 See Info node `(gnus)Customizing Articles' for details."
1017 :group 'gnus-article-treat
1018 :link '(custom-manual "(gnus)Customizing Articles")
1019 :type gnus-article-treat-head-custom)
1021 (defcustom gnus-treat-hide-boring-headers nil
1022 "Hide boring headers.
1023 Valid values are nil, t, `head', `last', an integer or a predicate.
1024 See Info node `(gnus)Customizing Articles' for details."
1025 :group 'gnus-article-treat
1026 :link '(custom-manual "(gnus)Customizing Articles")
1027 :type gnus-article-treat-head-custom)
1029 (defcustom gnus-treat-hide-signature nil
1030 "Hide the signature.
1031 Valid values are nil, t, `head', `last', an integer or a predicate.
1032 See Info node `(gnus)Customizing Articles' for details."
1033 :group 'gnus-article-treat
1034 :link '(custom-manual "(gnus)Customizing Articles")
1035 :type gnus-article-treat-custom)
1037 (defcustom gnus-treat-fill-article nil
1039 Valid values are nil, t, `head', `last', an integer or a predicate.
1040 See Info node `(gnus)Customizing Articles' for details."
1041 :group 'gnus-article-treat
1042 :link '(custom-manual "(gnus)Customizing Articles")
1043 :type gnus-article-treat-custom)
1045 (defcustom gnus-treat-hide-citation nil
1047 Valid values are nil, t, `head', `last', an integer or a predicate.
1048 See Info node `(gnus)Customizing Articles' for details."
1049 :group 'gnus-article-treat
1050 :link '(custom-manual "(gnus)Customizing Articles")
1051 :type gnus-article-treat-custom)
1053 (defcustom gnus-treat-hide-citation-maybe nil
1055 Valid values are nil, t, `head', `last', an integer or a predicate.
1056 See Info node `(gnus)Customizing Articles' for details."
1057 :group 'gnus-article-treat
1058 :link '(custom-manual "(gnus)Customizing Articles")
1059 :type gnus-article-treat-custom)
1061 (defcustom gnus-treat-strip-list-identifiers 'head
1062 "Strip list identifiers from `gnus-list-identifiers`.
1063 Valid values are nil, t, `head', `last', an integer or a predicate.
1064 See Info node `(gnus)Customizing Articles' for details."
1066 :group 'gnus-article-treat
1067 :link '(custom-manual "(gnus)Customizing Articles")
1068 :type gnus-article-treat-custom)
1070 (make-obsolete-variable 'gnus-treat-strip-pgp
1071 "This option is obsolete in Gnus 5.10.")
1073 (defcustom gnus-treat-strip-pem nil
1074 "Strip PEM signatures.
1075 Valid values are nil, t, `head', `last', an integer or a predicate.
1076 See Info node `(gnus)Customizing Articles' for details."
1077 :group 'gnus-article-treat
1078 :link '(custom-manual "(gnus)Customizing Articles")
1079 :type gnus-article-treat-custom)
1081 (defcustom gnus-treat-strip-banner t
1082 "Strip banners from articles.
1083 The banner to be stripped is specified in the `banner' group parameter.
1084 Valid values are nil, t, `head', `last', an integer or a predicate.
1085 See Info node `(gnus)Customizing Articles' for details."
1086 :group 'gnus-article-treat
1087 :link '(custom-manual "(gnus)Customizing Articles")
1088 :type gnus-article-treat-custom)
1090 (defcustom gnus-treat-highlight-headers 'head
1091 "Highlight the headers.
1092 Valid values are nil, t, `head', `last', an integer or a predicate.
1093 See Info node `(gnus)Customizing Articles' for details."
1094 :group 'gnus-article-treat
1095 :link '(custom-manual "(gnus)Customizing Articles")
1096 :type gnus-article-treat-head-custom)
1097 (put 'gnus-treat-highlight-headers 'highlight t)
1099 (defcustom gnus-treat-highlight-citation t
1100 "Highlight cited text.
1101 Valid values are nil, t, `head', `last', an integer or a predicate.
1102 See Info node `(gnus)Customizing Articles' for details."
1103 :group 'gnus-article-treat
1104 :link '(custom-manual "(gnus)Customizing Articles")
1105 :type gnus-article-treat-custom)
1106 (put 'gnus-treat-highlight-citation 'highlight t)
1108 (defcustom gnus-treat-date-ut nil
1109 "Display the Date in UT (GMT).
1110 Valid values are nil, t, `head', `last', an integer or a predicate.
1111 See Info node `(gnus)Customizing Articles' for details."
1112 :group 'gnus-article-treat
1113 :link '(custom-manual "(gnus)Customizing Articles")
1114 :type gnus-article-treat-head-custom)
1116 (defcustom gnus-treat-date-local nil
1117 "Display the Date in the local timezone.
1118 Valid values are nil, t, `head', `last', an integer or a predicate.
1119 See Info node `(gnus)Customizing Articles' for details."
1120 :group 'gnus-article-treat
1121 :link '(custom-manual "(gnus)Customizing Articles")
1122 :type gnus-article-treat-head-custom)
1124 (defcustom gnus-treat-date-english nil
1125 "Display the Date in a format that can be read aloud in English.
1126 Valid values are nil, t, `head', `last', an integer or a predicate.
1127 See Info node `(gnus)Customizing Articles' for details."
1129 :group 'gnus-article-treat
1130 :link '(custom-manual "(gnus)Customizing Articles")
1131 :type gnus-article-treat-head-custom)
1133 (defcustom gnus-treat-date-lapsed nil
1134 "Display the Date header in a way that says how much time has elapsed.
1135 Valid values are nil, t, `head', `last', an integer or a predicate.
1136 See Info node `(gnus)Customizing Articles' for details."
1137 :group 'gnus-article-treat
1138 :link '(custom-manual "(gnus)Customizing Articles")
1139 :type gnus-article-treat-head-custom)
1141 (defcustom gnus-treat-date-original nil
1142 "Display the date in the original timezone.
1143 Valid values are nil, t, `head', `last', an integer or a predicate.
1144 See Info node `(gnus)Customizing Articles' for details."
1145 :group 'gnus-article-treat
1146 :link '(custom-manual "(gnus)Customizing Articles")
1147 :type gnus-article-treat-head-custom)
1149 (defcustom gnus-treat-date-iso8601 nil
1150 "Display the date in the ISO8601 format.
1151 Valid values are nil, t, `head', `last', an integer or a predicate.
1152 See Info node `(gnus)Customizing Articles' for details."
1154 :group 'gnus-article-treat
1155 :link '(custom-manual "(gnus)Customizing Articles")
1156 :type gnus-article-treat-head-custom)
1158 (defcustom gnus-treat-date-user-defined nil
1159 "Display the date in a user-defined format.
1160 The format is defined by the `gnus-article-time-format' variable.
1161 Valid values are nil, t, `head', `last', an integer or a predicate.
1162 See Info node `(gnus)Customizing Articles' for details."
1163 :group 'gnus-article-treat
1164 :link '(custom-manual "(gnus)Customizing Articles")
1165 :type gnus-article-treat-head-custom)
1167 (defcustom gnus-treat-strip-headers-in-body t
1168 "Strip the X-No-Archive header line from the beginning of the body.
1169 Valid values are nil, t, `head', `last', an integer or a predicate.
1170 See Info node `(gnus)Customizing Articles' for details."
1172 :group 'gnus-article-treat
1173 :link '(custom-manual "(gnus)Customizing Articles")
1174 :type gnus-article-treat-custom)
1176 (defcustom gnus-treat-strip-trailing-blank-lines nil
1177 "Strip trailing blank lines.
1178 Valid values are nil, t, `head', `last', an integer or a predicate.
1179 See Info node `(gnus)Customizing Articles' for details."
1180 :group 'gnus-article-treat
1181 :link '(custom-manual "(gnus)Customizing Articles")
1182 :type gnus-article-treat-custom)
1184 (defcustom gnus-treat-strip-leading-blank-lines nil
1185 "Strip leading blank lines.
1186 Valid values are nil, t, `head', `last', an integer or a predicate.
1187 See Info node `(gnus)Customizing Articles' for details."
1188 :group 'gnus-article-treat
1189 :link '(custom-manual "(gnus)Customizing Articles")
1190 :type gnus-article-treat-custom)
1192 (defcustom gnus-treat-strip-multiple-blank-lines nil
1193 "Strip multiple blank lines.
1194 Valid values are nil, t, `head', `last', an integer or a predicate.
1195 See Info node `(gnus)Customizing Articles' for details."
1196 :group 'gnus-article-treat
1197 :link '(custom-manual "(gnus)Customizing Articles")
1198 :type gnus-article-treat-custom)
1200 (defcustom gnus-treat-unfold-headers 'head
1201 "Unfold folded header lines.
1202 Valid values are nil, t, `head', `last', an integer or a predicate.
1203 See Info node `(gnus)Customizing Articles' for details."
1205 :group 'gnus-article-treat
1206 :link '(custom-manual "(gnus)Customizing Articles")
1207 :type gnus-article-treat-custom)
1209 (defcustom gnus-treat-fold-headers nil
1211 Valid values are nil, t, `head', `last', an integer or a predicate.
1212 See Info node `(gnus)Customizing Articles' for details."
1214 :group 'gnus-article-treat
1215 :link '(custom-manual "(gnus)Customizing Articles")
1216 :type gnus-article-treat-custom)
1218 (defcustom gnus-treat-fold-newsgroups 'head
1219 "Fold the Newsgroups and Followup-To headers.
1220 Valid values are nil, t, `head', `last', an integer or a predicate.
1221 See Info node `(gnus)Customizing Articles' for details."
1223 :group 'gnus-article-treat
1224 :link '(custom-manual "(gnus)Customizing Articles")
1225 :type gnus-article-treat-custom)
1227 (defcustom gnus-treat-overstrike t
1228 "Treat overstrike highlighting.
1229 Valid values are nil, t, `head', `last', an integer or a predicate.
1230 See Info node `(gnus)Customizing Articles' for details."
1231 :group 'gnus-article-treat
1232 :link '(custom-manual "(gnus)Customizing Articles")
1233 :type gnus-article-treat-custom)
1234 (put 'gnus-treat-overstrike 'highlight t)
1236 (make-obsolete-variable 'gnus-treat-display-xface
1237 'gnus-treat-display-x-face)
1239 (defcustom gnus-treat-display-x-face
1240 (and (not noninteractive)
1241 (or (and (fboundp 'image-type-available-p)
1242 (image-type-available-p 'xbm)
1243 (string-match "^0x" (shell-command-to-string "uncompface"))
1244 (executable-find "icontopbm"))
1245 (and (featurep 'xemacs)
1248 "Display X-Face headers.
1249 Valid values are nil, t, `head', `last', an integer or a predicate.
1250 See Info node `(gnus)Customizing Articles' and Info node
1251 `(gnus)X-Face' for details."
1252 :group 'gnus-article-treat
1254 :link '(custom-manual "(gnus)Customizing Articles")
1255 :link '(custom-manual "(gnus)X-Face")
1256 :type gnus-article-treat-head-custom
1257 :set (lambda (symbol value)
1260 (cond ((or (boundp symbol) (get symbol 'saved-value))
1262 ((boundp 'gnus-treat-display-xface)
1264 ** gnus-treat-display-xface is an obsolete variable;\
1265 use gnus-treat-display-x-face instead")
1266 (default-value 'gnus-treat-display-xface))
1267 ((get 'gnus-treat-display-xface 'saved-value)
1269 ** gnus-treat-display-xface is an obsolete variable;\
1270 use gnus-treat-display-x-face instead")
1271 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1274 (put 'gnus-treat-display-x-face 'highlight t)
1276 (defcustom gnus-treat-display-face
1277 (and (not noninteractive)
1278 (or (and (fboundp 'image-type-available-p)
1279 (image-type-available-p 'png))
1280 (and (featurep 'xemacs)
1283 "Display Face headers.
1284 Valid values are nil, t, `head', `last', an integer or a predicate.
1285 See Info node `(gnus)Customizing Articles' and Info node
1286 `(gnus)X-Face' for details."
1287 :group 'gnus-article-treat
1289 :link '(custom-manual "(gnus)Customizing Articles")
1290 :link '(custom-manual "(gnus)X-Face")
1291 :type gnus-article-treat-head-custom)
1292 (put 'gnus-treat-display-face 'highlight t)
1294 (defcustom gnus-treat-display-smileys
1295 (if (or (and (featurep 'xemacs)
1297 (and (fboundp 'image-type-available-p)
1298 (image-type-available-p 'pbm)))
1301 Valid values are nil, t, `head', `last', an integer or a predicate.
1302 See Info node `(gnus)Customizing Articles' and Info node
1303 `(gnus)Smileys' for details."
1304 :group 'gnus-article-treat
1306 :link '(custom-manual "(gnus)Customizing Articles")
1307 :link '(custom-manual "(gnus)Smileys")
1308 :type gnus-article-treat-custom)
1309 (put 'gnus-treat-display-smileys 'highlight t)
1311 (defcustom gnus-treat-from-picon
1312 (if (and (gnus-image-type-available-p 'xpm)
1313 (gnus-picons-installed-p))
1315 "Display picons in the From header.
1316 Valid values are nil, t, `head', `last', an integer or a predicate.
1317 See Info node `(gnus)Customizing Articles' and Info node
1318 `(gnus)Picons' for details."
1320 :group 'gnus-article-treat
1322 :link '(custom-manual "(gnus)Customizing Articles")
1323 :link '(custom-manual "(gnus)Picons")
1324 :type gnus-article-treat-head-custom)
1325 (put 'gnus-treat-from-picon 'highlight t)
1327 (defcustom gnus-treat-mail-picon
1328 (if (and (gnus-image-type-available-p 'xpm)
1329 (gnus-picons-installed-p))
1331 "Display picons in To and Cc headers.
1332 Valid values are nil, t, `head', `last', an integer or a predicate.
1333 See Info node `(gnus)Customizing Articles' and Info node
1334 `(gnus)Picons' for details."
1336 :group 'gnus-article-treat
1338 :link '(custom-manual "(gnus)Customizing Articles")
1339 :link '(custom-manual "(gnus)Picons")
1340 :type gnus-article-treat-head-custom)
1341 (put 'gnus-treat-mail-picon 'highlight t)
1343 (defcustom gnus-treat-newsgroups-picon
1344 (if (and (gnus-image-type-available-p 'xpm)
1345 (gnus-picons-installed-p))
1347 "Display picons in the Newsgroups and Followup-To headers.
1348 Valid values are nil, t, `head', `last', an integer or a predicate.
1349 See Info node `(gnus)Customizing Articles' and Info node
1350 `(gnus)Picons' for details."
1352 :group 'gnus-article-treat
1354 :link '(custom-manual "(gnus)Customizing Articles")
1355 :link '(custom-manual "(gnus)Picons")
1356 :type gnus-article-treat-head-custom)
1357 (put 'gnus-treat-newsgroups-picon 'highlight t)
1359 (defcustom gnus-treat-body-boundary
1360 (if (or gnus-treat-newsgroups-picon
1361 gnus-treat-mail-picon
1362 gnus-treat-from-picon)
1364 "Draw a boundary at the end of the headers.
1365 Valid values are nil and `head'.
1366 See Info node `(gnus)Customizing Articles' for details."
1368 :group 'gnus-article-treat
1369 :link '(custom-manual "(gnus)Customizing Articles")
1370 :type gnus-article-treat-head-custom)
1372 (defcustom gnus-treat-capitalize-sentences nil
1373 "Capitalize sentence-starting words.
1374 Valid values are nil, t, `head', `last', an integer or a predicate.
1375 See Info node `(gnus)Customizing Articles' for details."
1377 :group 'gnus-article-treat
1378 :link '(custom-manual "(gnus)Customizing Articles")
1379 :type gnus-article-treat-custom)
1381 (defcustom gnus-treat-wash-html nil
1383 Valid values are nil, t, `head', `last', an integer or a predicate.
1384 See Info node `(gnus)Customizing Articles' for details."
1386 :group 'gnus-article-treat
1387 :link '(custom-manual "(gnus)Customizing Articles")
1388 :type gnus-article-treat-custom)
1390 (defcustom gnus-treat-fill-long-lines nil
1392 Valid values are nil, t, `head', `last', an integer or a predicate.
1393 See Info node `(gnus)Customizing Articles' for details."
1394 :group 'gnus-article-treat
1395 :link '(custom-manual "(gnus)Customizing Articles")
1396 :type gnus-article-treat-custom)
1398 (defcustom gnus-treat-play-sounds nil
1400 Valid values are nil, t, `head', `last', an integer or a predicate.
1401 See Info node `(gnus)Customizing Articles' for details."
1403 :group 'gnus-article-treat
1404 :link '(custom-manual "(gnus)Customizing Articles")
1405 :type gnus-article-treat-custom)
1407 (defcustom gnus-treat-translate nil
1408 "Translate articles from one language to another.
1409 Valid values are nil, t, `head', `last', an integer or a predicate.
1410 See Info node `(gnus)Customizing Articles' for details."
1412 :group 'gnus-article-treat
1413 :link '(custom-manual "(gnus)Customizing Articles")
1414 :type gnus-article-treat-custom)
1416 (defcustom gnus-treat-x-pgp-sig nil
1418 To automatically treat X-PGP-Sig, set it to head.
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 :group 'mime-security
1424 :link '(custom-manual "(gnus)Customizing Articles")
1425 :type gnus-article-treat-custom)
1427 (defvar gnus-article-encrypt-protocol-alist
1428 '(("PGP" . mml2015-self-encrypt)))
1430 ;; Set to nil if more than one protocol added to
1431 ;; gnus-article-encrypt-protocol-alist.
1432 (defcustom gnus-article-encrypt-protocol "PGP"
1433 "The protocol used for encrypt articles.
1434 It is a string, such as \"PGP\". If nil, ask user."
1437 :group 'mime-security)
1439 (defvar gnus-article-wash-function nil
1440 "Function used for converting HTML into text.")
1442 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1443 (mm-coding-system-p 'utf-8)
1444 (executable-find idna-program))
1445 "Whether IDNA decoding of headers is used when viewing messages.
1446 This requires GNU Libidn, and by default only enabled if it is found."
1448 :group 'gnus-article-headers
1451 (defcustom gnus-article-over-scroll nil
1452 "If non-nil, allow scrolling the article buffer even when there no more text."
1454 :group 'gnus-article
1457 ;;; Internal variables
1459 (defvar gnus-english-month-names
1460 '("January" "February" "March" "April" "May" "June" "July" "August"
1461 "September" "October" "November" "December"))
1463 (defvar article-goto-body-goes-to-point-min-p nil)
1464 (defvar gnus-article-wash-types nil)
1465 (defvar gnus-article-emphasis-alist nil)
1466 (defvar gnus-article-image-alist nil)
1468 (defvar gnus-article-mime-handle-alist-1 nil)
1469 (defvar gnus-treatment-function-alist
1470 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1471 (gnus-treat-strip-banner gnus-article-strip-banner)
1472 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1473 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1474 (gnus-treat-buttonize gnus-article-add-buttons)
1475 (gnus-treat-fill-article gnus-article-fill-cited-article)
1476 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1477 (gnus-treat-strip-cr gnus-article-remove-cr)
1478 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1479 (gnus-treat-date-ut gnus-article-date-ut)
1480 (gnus-treat-date-local gnus-article-date-local)
1481 (gnus-treat-date-english gnus-article-date-english)
1482 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1483 (gnus-treat-date-original gnus-article-date-original)
1484 (gnus-treat-date-user-defined gnus-article-date-user)
1485 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1486 (gnus-treat-display-x-face gnus-article-display-x-face)
1487 (gnus-treat-display-face gnus-article-display-face)
1488 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1489 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1490 (gnus-treat-hide-signature gnus-article-hide-signature)
1491 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1492 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1493 (gnus-treat-strip-pem gnus-article-hide-pem)
1494 (gnus-treat-from-picon gnus-treat-from-picon)
1495 (gnus-treat-mail-picon gnus-treat-mail-picon)
1496 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1497 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1498 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1499 (gnus-treat-strip-trailing-blank-lines
1500 gnus-article-remove-trailing-blank-lines)
1501 (gnus-treat-strip-leading-blank-lines
1502 gnus-article-strip-leading-blank-lines)
1503 (gnus-treat-strip-multiple-blank-lines
1504 gnus-article-strip-multiple-blank-lines)
1505 (gnus-treat-overstrike gnus-article-treat-overstrike)
1506 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1507 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1508 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1509 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1510 (gnus-treat-display-smileys gnus-treat-smiley)
1511 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1512 (gnus-treat-wash-html gnus-article-wash-html)
1513 (gnus-treat-emphasize gnus-article-emphasize)
1514 (gnus-treat-hide-citation gnus-article-hide-citation)
1515 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1516 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1517 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1518 (gnus-treat-play-sounds gnus-earcon-display)))
1520 (defvar gnus-article-mime-handle-alist nil)
1521 (defvar article-lapsed-timer nil)
1522 (defvar gnus-article-current-summary nil)
1524 (defvar gnus-article-mode-syntax-table
1525 (let ((table (copy-syntax-table text-mode-syntax-table)))
1526 ;; This causes the citation match run O(2^n).
1527 ;; (modify-syntax-entry ?- "w" table)
1528 (modify-syntax-entry ?> ")<" table)
1529 (modify-syntax-entry ?< "(>" table)
1530 ;; make M-. in article buffers work for `foo' strings
1531 (modify-syntax-entry ?' " " table)
1532 (modify-syntax-entry ?` " " table)
1534 "Syntax table used in article mode buffers.
1535 Initialized from `text-mode-syntax-table.")
1537 (defvar gnus-save-article-buffer nil)
1539 (defvar gnus-article-mode-line-format-alist
1540 (nconc '((?w (gnus-article-wash-status) ?s)
1541 (?m (gnus-article-mime-part-status) ?s))
1542 gnus-summary-mode-line-format-alist))
1544 (defvar gnus-number-of-articles-to-be-saved nil)
1546 (defvar gnus-inhibit-hiding nil)
1548 (defvar gnus-article-edit-mode nil)
1550 ;;; Macros for dealing with the article buffer.
1552 (defmacro gnus-with-article-headers (&rest forms)
1554 (set-buffer gnus-article-buffer)
1556 (let ((inhibit-read-only t)
1557 (inhibit-point-motion-hooks t)
1558 (case-fold-search t))
1559 (article-narrow-to-head)
1562 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1563 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1565 (defmacro gnus-with-article-buffer (&rest forms)
1567 (set-buffer gnus-article-buffer)
1568 (let ((inhibit-read-only t))
1571 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1572 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1574 (defun gnus-article-goto-header (header)
1575 "Go to HEADER, which is a regular expression."
1576 (re-search-forward (concat "^\\(" header "\\):") nil t))
1578 (defsubst gnus-article-hide-text (b e props)
1579 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1580 (gnus-add-text-properties-when 'article-type nil b e props)
1581 (when (memq 'intangible props)
1583 (max (1- b) (point-min))
1584 b 'intangible (cddr (memq 'intangible props)))))
1586 (defsubst gnus-article-unhide-text (b e)
1587 "Remove hidden text properties from region between B and E."
1588 (remove-text-properties b e gnus-hidden-properties)
1589 (when (memq 'intangible gnus-hidden-properties)
1590 (put-text-property (max (1- b) (point-min))
1591 b 'intangible nil)))
1593 (defun gnus-article-hide-text-type (b e type)
1594 "Hide text of TYPE between B and E."
1595 (gnus-add-wash-type type)
1596 (gnus-article-hide-text
1597 b e (cons 'article-type (cons type gnus-hidden-properties))))
1599 (defun gnus-article-unhide-text-type (b e type)
1600 "Unhide text of TYPE between B and E."
1601 (gnus-delete-wash-type type)
1602 (remove-text-properties
1603 b e (cons 'article-type (cons type gnus-hidden-properties)))
1604 (when (memq 'intangible gnus-hidden-properties)
1605 (put-text-property (max (1- b) (point-min))
1606 b 'intangible nil)))
1608 (defun gnus-article-hide-text-of-type (type)
1609 "Hide text of TYPE in the current buffer."
1611 (let ((b (point-min))
1613 (while (setq b (text-property-any b e 'article-type type))
1614 (add-text-properties b (incf b) gnus-hidden-properties)))))
1616 (defun gnus-article-delete-text-of-type (type)
1617 "Delete text of TYPE in the current buffer."
1619 (let ((b (point-min)))
1620 (while (setq b (text-property-any b (point-max) 'article-type type))
1622 b (or (text-property-not-all b (point-max) 'article-type type)
1625 (defun gnus-article-delete-invisible-text ()
1626 "Delete all invisible text in the current buffer."
1628 (let ((b (point-min)))
1629 (while (setq b (text-property-any b (point-max) 'invisible t))
1631 b (or (text-property-not-all b (point-max) 'invisible t)
1634 (defun gnus-article-text-type-exists-p (type)
1635 "Say whether any text of type TYPE exists in the buffer."
1636 (text-property-any (point-min) (point-max) 'article-type type))
1638 (defsubst gnus-article-header-rank ()
1639 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1640 (let ((list gnus-sorted-header-list)
1643 (if (looking-at (car list))
1645 (setq list (cdr list))
1649 (defun article-hide-headers (&optional arg delete)
1650 "Hide unwanted headers and possibly sort them as well."
1652 ;; This function might be inhibited.
1653 (unless gnus-inhibit-hiding
1654 (let ((inhibit-read-only nil)
1655 (case-fold-search t)
1656 (max (1+ (length gnus-sorted-header-list)))
1657 (inhibit-point-motion-hooks t)
1658 (cur (current-buffer))
1659 ignored visible beg)
1661 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1662 ;; group parameters, so we should go to the summary buffer.
1665 (progn (set-buffer gnus-summary-buffer) t)
1667 (setq ignored (when (not gnus-visible-headers)
1668 (cond ((stringp gnus-ignored-headers)
1669 gnus-ignored-headers)
1670 ((listp gnus-ignored-headers)
1671 (mapconcat 'identity
1672 gnus-ignored-headers
1674 visible (cond ((stringp gnus-visible-headers)
1675 gnus-visible-headers)
1676 ((and gnus-visible-headers
1677 (listp gnus-visible-headers))
1678 (mapconcat 'identity
1679 gnus-visible-headers
1683 ;; First we narrow to just the headers.
1684 (article-narrow-to-head)
1685 ;; Hide any "From " lines at the beginning of (mail) articles.
1686 (while (looking-at "From ")
1689 (delete-region (point-min) (point)))
1690 ;; Then treat the rest of the header lines.
1691 ;; Then we use the two regular expressions
1692 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1693 ;; select which header lines is to remain visible in the
1695 (while (re-search-forward "^[^ \t:]*:" nil t)
1697 ;; Mark the rank of the header.
1699 (point) (1+ (point)) 'message-rank
1700 (if (or (and visible (looking-at visible))
1702 (not (looking-at ignored))))
1703 (gnus-article-header-rank)
1706 (message-sort-headers-1)
1707 (when (setq beg (text-property-any
1708 (point-min) (point-max) 'message-rank (+ 2 max)))
1709 ;; We delete the unwanted headers.
1710 (gnus-add-wash-type 'headers)
1711 (add-text-properties (point-min) (+ 5 (point-min))
1712 '(article-type headers dummy-invisible t))
1713 (delete-region beg (point-max))))))))
1715 (defun article-hide-boring-headers (&optional arg)
1716 "Toggle hiding of headers that aren't very interesting.
1717 If given a negative prefix, always show; if given a positive prefix,
1719 (interactive (gnus-article-hidden-arg))
1720 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1721 (not gnus-show-all-headers))
1724 (let ((inhibit-read-only t)
1725 (list gnus-boring-article-headers)
1726 (inhibit-point-motion-hooks t)
1728 (article-narrow-to-head)
1730 (setq elem (pop list))
1731 (goto-char (point-min))
1733 ;; Hide empty headers.
1735 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1737 (gnus-article-hide-text-type
1741 (if (re-search-forward "^[^ \t]" nil t)
1745 ;; Hide boring Newsgroups header.
1746 ((eq elem 'newsgroups)
1747 (when (gnus-string-equal
1748 (gnus-fetch-field "newsgroups")
1749 (gnus-group-real-name
1750 (if (boundp 'gnus-newsgroup-name)
1753 (gnus-article-hide-header "newsgroups")))
1754 ((eq elem 'to-address)
1755 (let ((to (message-fetch-field "to"))
1757 (gnus-parameter-to-address
1758 (if (boundp 'gnus-newsgroup-name)
1759 gnus-newsgroup-name ""))))
1760 (when (and to to-address
1763 ;; only one address in To
1764 (nth 1 (mail-extract-address-components to))
1766 (gnus-article-hide-header "to"))))
1768 (let ((to (message-fetch-field "to"))
1770 (gnus-parameter-to-list
1771 (if (boundp 'gnus-newsgroup-name)
1772 gnus-newsgroup-name ""))))
1773 (when (and to to-list
1776 ;; only one address in To
1777 (nth 1 (mail-extract-address-components to))
1779 (gnus-article-hide-header "to"))))
1781 (let ((cc (message-fetch-field "cc"))
1783 (gnus-parameter-to-list
1784 (if (boundp 'gnus-newsgroup-name)
1785 gnus-newsgroup-name ""))))
1786 (when (and cc to-list
1789 ;; only one address in CC
1790 (nth 1 (mail-extract-address-components cc))
1792 (gnus-article-hide-header "cc"))))
1793 ((eq elem 'followup-to)
1794 (when (gnus-string-equal
1795 (message-fetch-field "followup-to")
1796 (message-fetch-field "newsgroups"))
1797 (gnus-article-hide-header "followup-to")))
1798 ((eq elem 'reply-to)
1799 (if (gnus-group-find-parameter
1800 gnus-newsgroup-name 'broken-reply-to)
1801 (gnus-article-hide-header "reply-to")
1802 (let ((from (message-fetch-field "from"))
1803 (reply-to (message-fetch-field "reply-to")))
1810 (lambda (x) (downcase (cadr x)))
1811 (mail-extract-address-components from t))
1814 (lambda (x) (downcase (cadr x)))
1815 (mail-extract-address-components reply-to t))
1817 (gnus-article-hide-header "reply-to")))))
1819 (let ((date (message-fetch-field "date")))
1821 (< (days-between (current-time-string) date)
1823 (gnus-article-hide-header "date"))))
1825 (let ((to (message-fetch-field "to"))
1826 (cc (message-fetch-field "cc")))
1827 (when (> (length to) 1024)
1828 (gnus-article-hide-header "to"))
1829 (when (> (length cc) 1024)
1830 (gnus-article-hide-header "cc"))))
1834 (goto-char (point-min))
1835 (while (re-search-forward "^to:" nil t)
1836 (setq to-count (1+ to-count)))
1837 (when (> to-count 1)
1838 (while (> to-count 0)
1839 (goto-char (point-min))
1841 (re-search-forward "^to:" nil nil to-count)
1843 (narrow-to-region (point) (point-max))
1844 (gnus-article-hide-header "to"))
1845 (setq to-count (1- to-count))))
1846 (goto-char (point-min))
1847 (while (re-search-forward "^cc:" nil t)
1848 (setq cc-count (1+ cc-count)))
1849 (when (> cc-count 1)
1850 (while (> cc-count 0)
1851 (goto-char (point-min))
1853 (re-search-forward "^cc:" nil nil cc-count)
1855 (narrow-to-region (point) (point-max))
1856 (gnus-article-hide-header "cc"))
1857 (setq cc-count (1- cc-count)))))))))))))
1859 (defun gnus-article-hide-header (header)
1861 (goto-char (point-min))
1862 (when (re-search-forward (concat "^" header ":") nil t)
1863 (gnus-article-hide-text-type
1867 (if (re-search-forward "^[^ \t]" nil t)
1872 (defvar gnus-article-normalized-header-length 40
1873 "Length of normalized headers.")
1875 (defun article-normalize-headers ()
1876 "Make all header lines 40 characters long."
1878 (let ((inhibit-read-only t)
1882 (article-narrow-to-head)
1885 ((< (setq column (- (gnus-point-at-eol) (point)))
1886 gnus-article-normalized-header-length)
1888 (insert (make-string
1889 (- gnus-article-normalized-header-length column)
1891 ((> column gnus-article-normalized-header-length)
1892 (gnus-put-text-property
1894 (forward-char gnus-article-normalized-header-length)
1901 (forward-line 1))))))
1903 (defun article-treat-dumbquotes ()
1904 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1905 Note that this function guesses whether a character is a sm*rtq**t* or
1906 not, so it should only be used interactively.
1908 Sm*rtq**t*s are M****s***'s unilateral extension to the
1909 iso-8859-1 character map in an attempt to provide more quoting
1910 characters. If you see something like \\222 or \\264 where
1911 you're expecting some kind of apostrophe or quotation mark, then
1914 (article-translate-strings gnus-article-dumbquotes-map))
1916 (defun article-translate-characters (from to)
1917 "Translate all characters in the body of the article according to FROM and TO.
1918 FROM is a string of characters to translate from; to is a string of
1919 characters to translate to."
1921 (when (article-goto-body)
1922 (let ((inhibit-read-only t)
1923 (x (make-string 225 ?x))
1925 (while (< (incf i) (length x))
1928 (while (< i (length from))
1929 (aset x (aref from i) (aref to i))
1931 (translate-region (point) (point-max) x)))))
1933 (defun article-translate-strings (map)
1934 "Translate all string in the body of the article according to MAP.
1935 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1937 (when (article-goto-body)
1938 (let ((inhibit-read-only t)
1940 (while (setq elem (pop map))
1942 (while (search-forward (car elem) nil t)
1943 (replace-match (cadr elem)))))))))
1945 (defun article-treat-overstrike ()
1946 "Translate overstrikes into bold text."
1949 (when (article-goto-body)
1950 (let ((inhibit-read-only t))
1951 (while (search-forward "\b" nil t)
1952 (let ((next (char-after))
1953 (previous (char-after (- (point) 2))))
1954 ;; We do the boldification/underlining by hiding the
1955 ;; overstrikes and putting the proper text property
1959 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1960 (put-text-property (point) (1+ (point)) 'face 'bold))
1962 (gnus-article-hide-text-type
1963 (1- (point)) (1+ (point)) 'overstrike)
1965 (- (point) 2) (1- (point)) 'face 'underline))
1967 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1969 (point) (1+ (point)) 'face 'underline)))))))))
1971 (defun gnus-article-treat-unfold-headers ()
1972 "Unfold folded message headers.
1973 Only the headers that fit into the current window width will be
1976 (gnus-with-article-headers
1980 (mail-header-narrow-to-field)
1981 (let ((header (buffer-string)))
1984 (goto-char (point-min))
1985 (while (re-search-forward "\n[\t ]" nil t)
1986 (replace-match " " t t)))
1987 (setq length (- (point-max) (point-min) 1)))
1988 (when (< length (window-width))
1989 (while (re-search-forward "\n[\t ]" nil t)
1990 (replace-match " " t t)))
1991 (goto-char (point-max)))))))
1993 (defun gnus-article-treat-fold-headers ()
1994 "Fold message headers."
1996 (gnus-with-article-headers
1999 (mail-header-narrow-to-field)
2000 (mail-header-fold-field)
2001 (goto-char (point-max))))))
2003 (defun gnus-treat-smiley ()
2004 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2006 (gnus-with-article-buffer
2007 (if (memq 'smiley gnus-article-wash-types)
2008 (gnus-delete-images 'smiley)
2010 (let ((images (smiley-region (point) (point-max))))
2012 (gnus-add-wash-type 'smiley)
2013 (dolist (image images)
2014 (gnus-add-image 'smiley image)))))))
2016 (defun gnus-article-remove-images ()
2017 "Remove all images from the article buffer."
2019 (gnus-with-article-buffer
2020 (dolist (elem gnus-article-image-alist)
2021 (gnus-delete-images (car elem)))))
2023 (defun gnus-article-treat-fold-newsgroups ()
2024 "Unfold folded message headers.
2025 Only the headers that fit into the current window width will be
2028 (gnus-with-article-headers
2029 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2031 (mail-header-narrow-to-field)
2032 (while (re-search-forward ", *" nil t)
2033 (replace-match ", " t t))
2034 (mail-header-fold-field)
2035 (goto-char (point-max))))))
2037 (defun gnus-article-treat-body-boundary ()
2038 "Place a boundary line at the end of the headers."
2040 (when (and gnus-body-boundary-delimiter
2041 (> (length gnus-body-boundary-delimiter) 0))
2042 (gnus-with-article-headers
2043 (goto-char (point-max))
2044 (let ((start (point)))
2045 (insert "X-Boundary: ")
2046 (gnus-add-text-properties start (point) '(invisible t intangible t))
2048 (while (>= (1- (window-width)) (length str))
2049 (setq str (concat str gnus-body-boundary-delimiter)))
2050 (substring str 0 (1- (window-width))))
2052 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2054 (defun article-fill-long-lines ()
2055 "Fill lines that are wider than the window width."
2058 (let ((inhibit-read-only t)
2059 (width (window-width (get-buffer-window (current-buffer)))))
2062 (let ((adaptive-fill-mode nil)) ;Why? -sm
2065 (when (>= (current-column) (min fill-column width))
2066 (narrow-to-region (min (1+ (point)) (point-max))
2067 (gnus-point-at-bol))
2068 (let ((goback (point-marker)))
2069 (fill-paragraph nil)
2070 (goto-char (marker-position goback)))
2072 (forward-line 1)))))))
2074 (defun article-capitalize-sentences ()
2075 "Capitalize the first word in each sentence."
2078 (let ((inhibit-read-only t)
2079 (paragraph-start "^[\n\^L]"))
2083 (forward-sentence)))))
2085 (defun article-remove-cr ()
2086 "Remove trailing CRs and then translate remaining CRs into LFs."
2089 (let ((inhibit-read-only t))
2090 (goto-char (point-min))
2091 (while (re-search-forward "\r+$" nil t)
2092 (replace-match "" t t))
2093 (goto-char (point-min))
2094 (while (search-forward "\r" nil t)
2095 (replace-match "\n" t t)))))
2097 (defun article-remove-trailing-blank-lines ()
2098 "Remove all trailing blank lines from the article."
2101 (let ((inhibit-read-only t))
2102 (goto-char (point-max))
2106 (while (and (not (bobp))
2107 (looking-at "^[ \t]*$")
2108 (not (gnus-annotation-in-region-p
2109 (point) (gnus-point-at-eol))))
2114 (defun article-display-face ()
2115 "Display any Face headers in the header."
2117 (let ((wash-face-p buffer-read-only))
2118 (gnus-with-article-headers
2119 ;; When displaying parts, this function can be called several times on
2120 ;; the same article, without any intended toggle semantic (as typing `W
2121 ;; D d' would have). So face deletion must occur only when we come from
2122 ;; an interactive command, that is when the *Article* buffer is
2124 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2125 (gnus-delete-images 'face)
2126 (let (face faces from)
2127 (save-current-buffer
2128 (when (and wash-face-p
2129 (gnus-buffer-live-p gnus-original-article-buffer)
2130 (not (re-search-forward "^Face:[\t ]*" nil t)))
2131 (set-buffer gnus-original-article-buffer))
2133 (mail-narrow-to-head)
2134 (while (gnus-article-goto-header "Face")
2135 (push (mail-header-field-value) faces))))
2137 (goto-char (point-min))
2138 (let ((from (gnus-article-goto-header "from"))
2143 (insert "[no `from' set]\n"))
2145 (when (setq png (gnus-convert-face-to-png (pop faces)))
2146 (setq image (gnus-create-image png 'png t))
2148 (gnus-add-wash-type 'face)
2149 (gnus-add-image 'face image)
2150 (gnus-put-image image nil 'face))))))))))
2152 (defun article-display-x-face (&optional force)
2153 "Look for an X-Face header and display it if present."
2154 (interactive (list 'force))
2155 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2156 (gnus-with-article-headers
2157 ;; Delete the old process, if any.
2158 (when (process-status "article-x-face")
2159 (delete-process "article-x-face"))
2160 ;; See the comment in `article-display-face'.
2161 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2162 ;; We have already displayed X-Faces, so we remove them
2164 (gnus-delete-images 'xface)
2166 (let (x-faces from face)
2167 (save-current-buffer
2168 (when (and wash-face-p
2169 (gnus-buffer-live-p gnus-original-article-buffer)
2170 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2171 ;; If type `W f', use gnus-original-article-buffer,
2172 ;; otherwise use the current buffer because displaying
2173 ;; RFC822 parts calls this function too.
2174 (set-buffer gnus-original-article-buffer))
2176 (mail-narrow-to-head)
2177 (while (gnus-article-goto-header "X-Face")
2178 (push (mail-header-field-value) x-faces))
2179 (setq from (message-fetch-field "from"))))
2180 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2181 ;; single external face.
2182 (when (stringp gnus-article-x-face-command)
2183 (setq x-faces (list (car x-faces))))
2185 gnus-article-x-face-command
2187 ;; Check whether this face is censored.
2188 (not gnus-article-x-face-too-ugly)
2190 (not (string-match gnus-article-x-face-too-ugly
2192 (while (setq face (pop x-faces))
2193 ;; We display the face.
2194 (cond ((stringp gnus-article-x-face-command)
2195 ;; The command is a string, so we interpret the command
2196 ;; as a, well, command, and fork it off.
2197 (let ((process-connection-type nil))
2198 (gnus-set-process-query-on-exit-flag
2200 "article-x-face" nil shell-file-name
2201 shell-command-switch gnus-article-x-face-command)
2205 (process-send-region "article-x-face"
2206 (point-min) (point-max)))
2207 (process-send-eof "article-x-face")))
2208 ((functionp gnus-article-x-face-command)
2209 ;; The command is a lisp function, so we call it.
2210 (funcall gnus-article-x-face-command face))
2212 (error "%s is not a function"
2213 gnus-article-x-face-command))))))))))
2215 (defun article-decode-mime-words ()
2216 "Decode all MIME-encoded words in the article."
2219 (set-buffer gnus-article-buffer)
2220 (let ((inhibit-point-motion-hooks t)
2221 (inhibit-read-only t)
2222 (mail-parse-charset gnus-newsgroup-charset)
2223 (mail-parse-ignored-charsets
2224 (save-excursion (set-buffer gnus-summary-buffer)
2225 gnus-newsgroup-ignored-charsets)))
2226 (mail-decode-encoded-word-region (point-min) (point-max)))))
2228 (defun article-decode-charset (&optional prompt)
2229 "Decode charset-encoded text in the article.
2230 If PROMPT (the prefix), prompt for a coding system to use."
2232 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2233 (inhibit-read-only t)
2234 (mail-parse-charset gnus-newsgroup-charset)
2235 (mail-parse-ignored-charsets
2236 (save-excursion (condition-case nil
2237 (set-buffer gnus-summary-buffer)
2239 gnus-newsgroup-ignored-charsets))
2240 ct cte ctl charset format)
2243 (article-narrow-to-head)
2244 (setq ct (message-fetch-field "Content-Type" t)
2245 cte (message-fetch-field "Content-Transfer-Encoding" t)
2246 ctl (and ct (ignore-errors
2247 (mail-header-parse-content-type ct)))
2250 (mm-read-coding-system "Charset to decode: "))
2252 (mail-content-type-get ctl 'charset)))
2253 format (and ctl (mail-content-type-get ctl 'format)))
2255 (setq cte (mail-header-strip cte)))
2256 (if (and ctl (not (string-match "/" (car ctl))))
2258 (goto-char (point-max)))
2261 (narrow-to-region (point) (point-max))
2262 (when (and (eq mail-parse-charset 'gnus-decoded)
2263 (eq (mm-body-7-or-8) '8bit))
2264 ;; The text code could have been decoded.
2265 (setq charset mail-parse-charset))
2266 (when (and (or (not ctl)
2267 (equal (car ctl) "text/plain"))
2268 (not format)) ;; article with format will decode later.
2270 charset (and cte (intern (downcase
2271 (gnus-strip-whitespace cte))))
2274 (defun article-decode-encoded-words ()
2275 "Remove encoded-word encoding from headers."
2276 (let ((inhibit-point-motion-hooks t)
2277 (mail-parse-charset gnus-newsgroup-charset)
2278 (mail-parse-ignored-charsets
2279 (save-excursion (condition-case nil
2280 (set-buffer gnus-summary-buffer)
2282 gnus-newsgroup-ignored-charsets))
2283 (inhibit-read-only t))
2285 (article-narrow-to-head)
2286 (funcall gnus-decode-header-function (point-min) (point-max)))))
2288 (defun article-decode-group-name ()
2289 "Decode group names in `Newsgroups:'."
2290 (let ((inhibit-point-motion-hooks t)
2291 (inhibit-read-only t)
2292 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2293 (when (and (or gnus-group-name-charset-method-alist
2294 gnus-group-name-charset-group-alist)
2295 (gnus-buffer-live-p gnus-original-article-buffer))
2297 (article-narrow-to-head)
2298 (with-current-buffer gnus-original-article-buffer
2299 (goto-char (point-min)))
2300 (while (re-search-forward
2301 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2302 (replace-match (save-match-data
2303 (gnus-decode-newsgroups
2304 ;; XXX how to use data in article buffer?
2305 (with-current-buffer gnus-original-article-buffer
2307 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2310 gnus-newsgroup-name method))
2312 (goto-char (point-min))
2313 (with-current-buffer gnus-original-article-buffer
2314 (goto-char (point-min)))
2315 (while (re-search-forward
2316 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2317 (replace-match (save-match-data
2318 (gnus-decode-newsgroups
2319 ;; XXX how to use data in article buffer?
2320 (with-current-buffer gnus-original-article-buffer
2322 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2325 gnus-newsgroup-name method))
2328 (autoload 'idna-to-unicode "idna")
2330 (defun article-decode-idna-rhs ()
2331 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2334 (let ((inhibit-point-motion-hooks t)
2335 (inhibit-read-only t))
2336 (article-narrow-to-head)
2337 (goto-char (point-min))
2338 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2340 (when (save-match-data
2341 (and (setq ace (match-string 1))
2343 (and (re-search-backward "^[^ \t]" nil t)
2344 (looking-at "From\\|To\\|Cc")))
2345 (setq unicode (idna-to-unicode ace))))
2346 (unless (string= ace unicode)
2347 (replace-match unicode nil nil nil 1)))))))))
2349 (defun article-de-quoted-unreadable (&optional force read-charset)
2350 "Translate a quoted-printable-encoded article.
2351 If FORCE, decode the article whether it is marked as quoted-printable
2353 If READ-CHARSET, ask for a coding system."
2354 (interactive (list 'force current-prefix-arg))
2356 (let ((inhibit-read-only t) type charset)
2357 (if (gnus-buffer-live-p gnus-original-article-buffer)
2358 (with-current-buffer gnus-original-article-buffer
2360 (gnus-fetch-field "content-transfer-encoding"))
2361 (let* ((ct (gnus-fetch-field "content-type"))
2364 (mail-header-parse-content-type ct)))))
2365 (setq charset (and ctl
2366 (mail-content-type-get ctl 'charset)))
2367 (if (stringp charset)
2368 (setq charset (intern (downcase charset)))))))
2370 (setq charset (mm-read-coding-system "Charset: " charset)))
2372 (setq charset gnus-newsgroup-charset))
2374 (and type (let ((case-fold-search t))
2375 (string-match "quoted-printable" type))))
2377 (quoted-printable-decode-region
2378 (point) (point-max) (mm-charset-to-coding-system charset))))))
2380 (defun article-de-base64-unreadable (&optional force read-charset)
2381 "Translate a base64 article.
2382 If FORCE, decode the article whether it is marked as base64 not.
2383 If READ-CHARSET, ask for a coding system."
2384 (interactive (list 'force current-prefix-arg))
2386 (let ((inhibit-read-only t) type charset)
2387 (if (gnus-buffer-live-p gnus-original-article-buffer)
2388 (with-current-buffer gnus-original-article-buffer
2390 (gnus-fetch-field "content-transfer-encoding"))
2391 (let* ((ct (gnus-fetch-field "content-type"))
2394 (mail-header-parse-content-type ct)))))
2395 (setq charset (and ctl
2396 (mail-content-type-get ctl 'charset)))
2397 (if (stringp charset)
2398 (setq charset (intern (downcase charset)))))))
2400 (setq charset (mm-read-coding-system "Charset: " charset)))
2402 (setq charset gnus-newsgroup-charset))
2404 (and type (let ((case-fold-search t))
2405 (string-match "base64" type))))
2408 (narrow-to-region (point) (point-max))
2409 (base64-decode-region (point-min) (point-max))
2410 (mm-decode-coding-region
2411 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2416 (defun article-decode-HZ ()
2417 "Translate a HZ-encoded article."
2421 (let ((inhibit-read-only t))
2422 (rfc1843-decode-region (point-min) (point-max)))))
2424 (defun article-unsplit-urls ()
2425 "Remove the newlines that some other mailers insert into URLs."
2428 (let ((inhibit-read-only t))
2429 (goto-char (point-min))
2430 (while (re-search-forward
2431 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2432 (replace-match "\\1\\3" t)))
2433 (when (interactive-p)
2434 (gnus-treat-article nil))))
2437 (defun article-wash-html (&optional read-charset)
2438 "Format an HTML article.
2439 If READ-CHARSET, ask for a coding system."
2442 (let ((inhibit-read-only t)
2444 (when (gnus-buffer-live-p gnus-original-article-buffer)
2445 (with-current-buffer gnus-original-article-buffer
2446 (let* ((ct (gnus-fetch-field "content-type"))
2449 (mail-header-parse-content-type ct)))))
2450 (setq charset (and ctl
2451 (mail-content-type-get ctl 'charset)))
2452 (when (stringp charset)
2453 (setq charset (intern (downcase charset)))))))
2455 (setq charset (mm-read-coding-system "Charset: " charset)))
2457 (setq charset gnus-newsgroup-charset))
2459 (save-window-excursion
2461 (narrow-to-region (point) (point-max))
2462 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2463 (entry (assq func mm-text-html-washer-alist)))
2465 (setq func (cdr entry)))
2470 (apply (car func) (cdr func))))))))))
2472 (defun gnus-article-wash-html-with-w3 ()
2473 "Wash the current buffer with w3."
2475 (let ((w3-strict-width (window-width))
2476 (url-standalone-mode t)
2477 (url-gateway-unplugged t)
2478 (w3-honor-stylesheets nil))
2480 (w3-region (point-min) (point-max))
2483 (defun gnus-article-wash-html-with-w3m ()
2484 "Wash the current buffer with emacs-w3m."
2487 (narrow-to-region (point) (point-max))
2488 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2489 w3m-force-redisplay)
2490 (w3m-region (point-min) (point-max)))
2491 (when (and mm-inline-text-html-with-w3m-keymap
2492 (boundp 'w3m-minor-mode-map)
2494 (add-text-properties
2495 (point-min) (point-max)
2496 (list 'keymap w3m-minor-mode-map
2497 ;; Put the mark meaning this part was rendered by emacs-w3m.
2498 'mm-inline-text-html-with-w3m t)))))
2500 (defun article-hide-list-identifiers ()
2501 "Remove list identifies from the Subject header.
2502 The `gnus-list-identifiers' variable specifies what to do."
2504 (let ((inhibit-point-motion-hooks t)
2505 (regexp (if (consp gnus-list-identifiers)
2506 (mapconcat 'identity gnus-list-identifiers " *\\|")
2507 gnus-list-identifiers))
2508 (inhibit-read-only t))
2512 (article-narrow-to-head)
2513 (goto-char (point-min))
2514 (while (re-search-forward
2515 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2517 (delete-region (match-beginning 2) (match-end 0))
2518 (beginning-of-line))
2519 (when (re-search-forward
2520 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2521 (delete-region (match-beginning 1) (match-end 1))))))))
2523 (defun article-hide-pem (&optional arg)
2524 "Toggle hiding of any PEM headers and signatures in the current article.
2525 If given a negative prefix, always show; if given a positive prefix,
2527 (interactive (gnus-article-hidden-arg))
2528 (unless (gnus-article-check-hidden-text 'pem arg)
2530 (let ((inhibit-read-only t) end)
2531 (goto-char (point-min))
2532 ;; Hide the horrendously ugly "header".
2533 (when (and (search-forward
2534 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2536 (setq end (1+ (match-beginning 0))))
2537 (gnus-add-wash-type 'pem)
2538 (gnus-article-hide-text-type
2540 (if (search-forward "\n\n" nil t)
2544 ;; Hide the trailer as well
2545 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2547 (gnus-article-hide-text-type
2548 (match-beginning 0) (match-end 0) 'pem)))))))
2550 (defun article-strip-banner ()
2551 "Strip the banners specified by the `banner' group parameter and by
2552 `gnus-article-address-banner-alist'."
2556 (let ((inhibit-point-motion-hooks t))
2557 (when (gnus-parameter-banner gnus-newsgroup-name)
2558 (article-really-strip-banner
2559 (gnus-parameter-banner gnus-newsgroup-name)))
2560 (when gnus-article-address-banner-alist
2561 (article-really-strip-banner
2562 (let ((from (save-restriction
2564 (article-narrow-to-head)
2565 (mail-fetch-field "from"))))
2568 (caar (mail-header-parse-addresses from))))
2570 (dolist (pair gnus-article-address-banner-alist)
2571 (when (string-match (car pair) from)
2572 (throw 'found (cdr pair)))))))))))))
2574 (defun article-really-strip-banner (banner)
2575 "Strip the banner specified by the argument."
2578 (let ((inhibit-point-motion-hooks t)
2579 (gnus-signature-limit nil)
2580 (inhibit-read-only t))
2583 ((eq banner 'signature)
2584 (when (gnus-article-narrow-to-signature)
2587 (delete-region (point) (point-max))))
2589 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2590 (while (re-search-forward banner nil t)
2591 (delete-region (match-beginning 0) (match-end 0)))))
2593 (while (re-search-forward banner nil t)
2594 (delete-region (match-beginning 0) (match-end 0)))))))))
2596 (defun article-babel ()
2597 "Translate article using an online translation service."
2601 (set-buffer gnus-article-buffer)
2602 (when (article-goto-body)
2603 (let* ((inhibit-read-only t)
2606 (orig (buffer-substring start end))
2607 (trans (babel-as-string orig)))
2609 (narrow-to-region start end)
2610 (delete-region start end)
2613 (defun article-hide-signature (&optional arg)
2614 "Hide the signature in the current article.
2615 If given a negative prefix, always show; if given a positive prefix,
2617 (interactive (gnus-article-hidden-arg))
2618 (unless (gnus-article-check-hidden-text 'signature arg)
2621 (let ((inhibit-read-only t))
2622 (when (gnus-article-narrow-to-signature)
2623 (gnus-article-hide-text-type
2624 (point-min) (point-max) 'signature))))))
2625 (gnus-set-mode-line 'article))
2627 (defun article-strip-headers-in-body ()
2628 "Strip offensive headers from bodies."
2632 (let ((case-fold-search t))
2633 (when (looking-at "x-no-archive:")
2634 (gnus-delete-line)))))
2636 (defun article-strip-leading-blank-lines ()
2637 "Remove all blank lines from the beginning of the article."
2640 (let ((inhibit-point-motion-hooks t)
2641 (inhibit-read-only t))
2642 (when (article-goto-body)
2643 (while (and (not (eobp))
2644 (looking-at "[ \t]*$"))
2645 (gnus-delete-line))))))
2647 (defun article-narrow-to-head ()
2648 "Narrow the buffer to the head of the message.
2649 Point is left at the beginning of the narrowed-to region."
2651 (goto-char (point-min))
2652 (if (search-forward "\n\n" nil 1)
2655 (goto-char (point-min)))
2657 (defun article-goto-body ()
2658 "Place point at the start of the body."
2659 (goto-char (point-min))
2661 ;; This variable is only bound when dealing with separate
2663 (article-goto-body-goes-to-point-min-p
2665 ((search-forward "\n\n" nil t)
2668 (goto-char (point-max))
2671 (defun article-strip-multiple-blank-lines ()
2672 "Replace consecutive blank lines with one empty line."
2675 (let ((inhibit-point-motion-hooks t)
2676 (inhibit-read-only t))
2677 ;; First make all blank lines empty.
2679 (while (re-search-forward "^[ \t]+$" nil t)
2680 (unless (gnus-annotation-in-region-p
2681 (match-beginning 0) (match-end 0))
2682 (replace-match "" nil t)))
2683 ;; Then replace multiple empty lines with a single empty line.
2685 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2686 (unless (gnus-annotation-in-region-p
2687 (match-beginning 0) (match-end 0))
2688 (delete-region (match-beginning 1) (match-end 1)))))))
2690 (defun article-strip-leading-space ()
2691 "Remove all white space from the beginning of the lines in the article."
2694 (let ((inhibit-point-motion-hooks t)
2695 (inhibit-read-only t))
2697 (while (re-search-forward "^[ \t]+" nil t)
2698 (replace-match "" t t)))))
2700 (defun article-strip-trailing-space ()
2701 "Remove all white space from the end of the lines in the article."
2704 (let ((inhibit-point-motion-hooks t)
2705 (inhibit-read-only t))
2707 (while (re-search-forward "[ \t]+$" nil t)
2708 (replace-match "" t t)))))
2710 (defun article-strip-blank-lines ()
2711 "Strip leading, trailing and multiple blank lines."
2713 (article-strip-leading-blank-lines)
2714 (article-remove-trailing-blank-lines)
2715 (article-strip-multiple-blank-lines))
2717 (defun article-strip-all-blank-lines ()
2718 "Strip all blank lines."
2721 (let ((inhibit-point-motion-hooks t)
2722 (inhibit-read-only t))
2724 (while (re-search-forward "^[ \t]*\n" nil t)
2725 (replace-match "" t t)))))
2727 (defun gnus-article-narrow-to-signature ()
2728 "Narrow to the signature; return t if a signature is found, else nil."
2729 (let ((inhibit-point-motion-hooks t))
2730 (when (gnus-article-search-signature)
2732 ;; Check whether we have some limits to what we consider
2733 ;; to be a signature.
2734 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2735 (list gnus-signature-limit)))
2737 (while (setq limit (pop limits))
2738 (if (or (and (integerp limit)
2739 (< (- (point-max) (point)) limit))
2741 (< (count-lines (point) (point-max)) limit))
2742 (and (functionp limit)
2744 (and (stringp limit)
2745 (not (re-search-forward limit nil t))))
2746 () ; This limit did not succeed.
2750 (narrow-to-region (point) (point-max))
2753 (defun gnus-article-search-signature ()
2754 "Search the current buffer for the signature separator.
2755 Put point at the beginning of the signature separator."
2756 (let ((cur (point)))
2757 (goto-char (point-max))
2758 (if (if (stringp gnus-signature-separator)
2759 (re-search-backward gnus-signature-separator nil t)
2760 (let ((seps gnus-signature-separator))
2762 (not (re-search-backward (car seps) nil t)))
2769 (defun gnus-article-hidden-arg ()
2770 "Return the current prefix arg as a number, or 0 if no prefix."
2771 (list (if current-prefix-arg
2772 (prefix-numeric-value current-prefix-arg)
2775 (defun gnus-article-check-hidden-text (type arg)
2776 "Return nil if hiding is necessary.
2777 Arg can be nil or a number. nil and positive means hide, negative
2778 means show, 0 means toggle."
2781 (let ((hide (gnus-article-hidden-text-p type)))
2787 (gnus-article-show-hidden-text type)
2790 (if (eq hide 'hidden)
2792 (gnus-article-show-hidden-text type)
2796 (defun gnus-article-hidden-text-p (type)
2797 "Say whether the current buffer contains hidden text of type TYPE."
2798 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2800 (not (get-text-property pos 'invisible))
2801 (not (get-text-property pos 'dummy-invisible)))
2803 (text-property-any (1+ pos) (point-max) 'article-type type)))
2808 (defun gnus-article-show-hidden-text (type &optional dummy)
2809 "Show all hidden text of type TYPE.
2810 Originally it is hide instead of DUMMY."
2811 (let ((inhibit-read-only t)
2812 (inhibit-point-motion-hooks t))
2813 (gnus-remove-text-properties-when
2815 (point-min) (point-max)
2816 (cons 'article-type (cons type
2817 gnus-hidden-properties)))
2818 (gnus-delete-wash-type type)))
2820 (defconst article-time-units
2821 `((year . ,(* 365.25 24 60 60))
2822 (week . ,(* 7 24 60 60))
2823 (day . ,(* 24 60 60))
2827 "Mapping from time units to seconds.")
2829 (defun gnus-article-forward-header ()
2830 "Move point to the start of the next header.
2831 If the current header is a continuation header, this can be several
2836 (if (looking-at "[ \t]+[^ \t]")
2840 (defun article-date-ut (&optional type highlight)
2841 "Convert DATE date to universal time in the current article.
2842 If TYPE is `local', convert to local time; if it is `lapsed', output
2843 how much time has lapsed since DATE. For `lapsed', the value of
2844 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2845 should replace the \"Date:\" one, or should be added below it."
2846 (interactive (list 'ut t))
2847 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2848 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
2852 (article-lapsed-timer
2856 (case-fold-search t)
2857 (inhibit-read-only t)
2858 (inhibit-point-motion-hooks t)
2859 pos date bface eface)
2863 (goto-char (point-min))
2864 (while (or (setq date (get-text-property (setq pos (point))
2866 (when (setq pos (next-single-property-change
2867 (point) 'original-date))
2868 (setq date (get-text-property pos 'original-date))
2870 (narrow-to-region pos (or (text-property-any pos (point-max)
2873 (goto-char (point-min))
2874 (when (re-search-forward tdate-regexp nil t)
2875 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2876 eface (get-text-property (1- (gnus-point-at-eol)) 'face)))
2877 (goto-char (point-min))
2879 ;; Delete any old Date headers.
2880 (while (re-search-forward date-regexp nil t)
2882 (delete-region (gnus-point-at-bol)
2884 (gnus-article-forward-header)
2886 (delete-region (gnus-point-at-bol)
2888 (gnus-article-forward-header)
2891 (setq pos (point))))
2892 (when (and (not pos)
2893 (re-search-forward tdate-regexp nil t))
2895 (gnus-goto-char pos)
2896 (insert (article-make-date-line date (or type 'ut)))
2902 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2903 (put-text-property (match-beginning 1) (1+ (match-end 1))
2905 (put-text-property (match-beginning 2) (match-end 2)
2907 (put-text-property (point-min) (1- (point-max)) 'original-date date)
2908 (goto-char (point-max))
2911 (defun article-make-date-line (date type)
2912 "Return a DATE line of TYPE."
2913 (unless (memq type '(local ut original user iso8601 lapsed english))
2914 (error "Unknown conversion type: %s" type))
2916 (let ((time (date-to-time date)))
2918 ;; Convert to the local timezone.
2920 (let ((tz (car (current-time-zone time))))
2921 (format "Date: %s %s%02d%02d" (current-time-string time)
2922 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2923 (/ (% (abs tz) 3600) 60))))
2924 ;; Convert to Universal Time.
2927 (current-time-string
2928 (let* ((e (parse-time-string date))
2929 (tm (apply 'encode-time e))
2931 (ls (- (cadr tm) (car (current-time-zone time)))))
2932 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2933 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2936 ;; Get the original date from the article.
2937 ((eq type 'original)
2938 (concat "Date: " (if (string-match "\n+$" date)
2939 (substring date 0 (match-beginning 0))
2941 ;; Let the user define the format.
2943 (let ((format (or (condition-case nil
2944 (with-current-buffer gnus-summary-buffer
2945 gnus-article-time-format)
2947 gnus-article-time-format)))
2948 (if (functionp format)
2949 (funcall format time)
2950 (concat "Date: " (format-time-string format time)))))
2953 (let ((tz (car (current-time-zone time))))
2956 (format-time-string "%Y%m%dT%H%M%S" time)
2957 (format "%s%02d%02d"
2958 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2959 (/ (% (abs tz) 3600) 60)))))
2960 ;; Do an X-Sent lapsed format.
2962 ;; If the date is seriously mangled, the timezone functions are
2963 ;; liable to bug out, so we ignore all errors.
2964 (let* ((now (current-time))
2965 (real-time (subtract-time now time))
2966 (real-sec (and real-time
2967 (+ (* (float (car real-time)) 65536)
2969 (sec (and real-time (abs real-sec)))
2979 ;; This is a bit convoluted, but basically we go
2980 ;; through the time units for years, weeks, etc,
2981 ;; and divide things to see whether that results
2982 ;; in positive answers.
2985 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2986 ;; The (remaining) seconds are too few to
2987 ;; be divided into this time unit.
2989 ;; It's big enough, so we output it.
2990 (setq sec (- sec (* num (cdr unit))))
2992 (concat (if prev ", " "") (int-to-string
2994 " " (symbol-name (car unit))
2995 (if (> num 1) "s" ""))
2997 article-time-units "")
2998 ;; If dates are odd, then it might appear like the
2999 ;; article was sent in the future.
3002 " in the future"))))))
3003 ;; Display the date in proper English
3005 (let ((dtime (decode-time time)))
3008 (number-to-string (nth 3 dtime))
3009 (let ((digit (% (nth 3 dtime) 10)))
3011 ((memq (nth 3 dtime) '(11 12 13)) "th")
3017 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3019 (number-to-string (nth 5 dtime))
3021 (format "%02d" (nth 2 dtime))
3023 (format "%02d" (nth 1 dtime)))))))
3025 (format "Date: %s (from Gnus)" date))))
3027 (defun article-date-local (&optional highlight)
3028 "Convert the current article date to the local timezone."
3029 (interactive (list t))
3030 (article-date-ut 'local highlight))
3032 (defun article-date-english (&optional highlight)
3033 "Convert the current article date to something that is proper English."
3034 (interactive (list t))
3035 (article-date-ut 'english highlight))
3037 (defun article-date-original (&optional highlight)
3038 "Convert the current article date to what it was originally.
3039 This is only useful if you have used some other date conversion
3040 function and want to see what the date was before converting."
3041 (interactive (list t))
3042 (article-date-ut 'original highlight))
3044 (defun article-date-lapsed (&optional highlight)
3045 "Convert the current article date to time lapsed since it was sent."
3046 (interactive (list t))
3047 (article-date-ut 'lapsed highlight))
3049 (defun article-update-date-lapsed ()
3050 "Function to be run from a timer to update the lapsed time line."
3052 (let (deactivate-mark)
3057 (set-buffer (window-buffer w))
3058 (when (eq major-mode 'gnus-article-mode)
3059 (let ((mark (point-marker)))
3060 (goto-char (point-min))
3061 (when (re-search-forward "^X-Sent:" nil t)
3062 (article-date-lapsed t))
3063 (goto-char (marker-position mark))
3064 (move-marker mark nil))))
3067 (defun gnus-start-date-timer (&optional n)
3068 "Start a timer to update the X-Sent header in the article buffers.
3069 The numerical prefix says how frequently (in seconds) the function
3074 (gnus-stop-date-timer)
3075 (setq article-lapsed-timer
3076 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
3078 (defun gnus-stop-date-timer ()
3079 "Stop the X-Sent timer."
3081 (when article-lapsed-timer
3082 (nnheader-cancel-timer article-lapsed-timer)
3083 (setq article-lapsed-timer nil)))
3085 (defun article-date-user (&optional highlight)
3086 "Convert the current article date to the user-defined format.
3087 This format is defined by the `gnus-article-time-format' variable."
3088 (interactive (list t))
3089 (article-date-ut 'user highlight))
3091 (defun article-date-iso8601 (&optional highlight)
3092 "Convert the current article date to ISO8601."
3093 (interactive (list t))
3094 (article-date-ut 'iso8601 highlight))
3096 (defmacro gnus-article-save-original-date (&rest forms)
3097 "Save the original date as a text property and evaluate FORMS."
3098 `(let* ((case-fold-search t)
3100 (goto-char (point-min))
3101 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3104 (date (when (and start
3105 (re-search-forward "[\t ]*\n\\([^\t ]\\|\\'\\)"
3107 (buffer-substring-no-properties start
3108 (match-beginning 0)))))
3109 (goto-char (point-max))
3110 (skip-chars-backward "\n")
3111 (put-text-property (point-min) (point) 'original-date date)
3113 (goto-char (point-max))
3114 (skip-chars-backward "\n")
3115 (put-text-property (point-min) (point) 'original-date date)))
3117 ;; (defun article-show-all ()
3118 ;; "Show all hidden text in the article buffer."
3121 ;; (let ((inhibit-read-only t))
3122 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3124 (defun article-remove-leading-whitespace ()
3125 "Remove excessive whitespace from all headers."
3129 (let ((inhibit-read-only t))
3130 (article-narrow-to-head)
3131 (goto-char (point-min))
3132 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3133 (delete-region (match-beginning 1) (match-end 1)))))))
3135 (defun article-emphasize (&optional arg)
3136 "Emphasize text according to `gnus-emphasis-alist'."
3137 (interactive (gnus-article-hidden-arg))
3138 (unless (gnus-article-check-hidden-text 'emphasis arg)
3142 (with-current-buffer gnus-summary-buffer
3143 gnus-article-emphasis-alist)
3145 gnus-emphasis-alist))
3146 (inhibit-read-only t)
3147 (props (append '(article-type emphasis)
3148 gnus-hidden-properties))
3149 regexp elem beg invisible visible face)
3152 (while (setq elem (pop alist))
3154 (setq regexp (car elem)
3155 invisible (nth 1 elem)
3156 visible (nth 2 elem)
3158 (while (re-search-forward regexp nil t)
3159 (when (and (match-beginning visible) (match-beginning invisible))
3160 (gnus-article-hide-text
3161 (match-beginning invisible) (match-end invisible) props)
3162 (gnus-article-unhide-text-type
3163 (match-beginning visible) (match-end visible) 'emphasis)
3164 (gnus-put-overlay-excluding-newlines
3165 (match-beginning visible) (match-end visible) 'face face)
3166 (gnus-add-wash-type 'emphasis)
3167 (goto-char (match-end invisible)))))))))
3169 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3170 "Setup newsgroup emphasis alist."
3171 (unless gnus-article-emphasis-alist
3172 (let ((name (and gnus-newsgroup-name
3173 (gnus-group-real-name gnus-newsgroup-name))))
3174 (make-local-variable 'gnus-article-emphasis-alist)
3175 (setq gnus-article-emphasis-alist
3177 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3178 (while (setq elem (pop alist))
3179 (when (and name (string-match (car elem) name))
3181 highlight (copy-sequence (cdr elem)))))
3183 (copy-sequence highlight-words)
3184 (if gnus-newsgroup-name
3185 (copy-sequence (gnus-group-find-parameter
3186 gnus-newsgroup-name 'highlight-words t)))
3187 gnus-emphasis-alist)))))
3190 (defvar gnus-summary-article-menu)
3191 (defvar gnus-summary-post-menu))
3193 ;;; Saving functions.
3195 (defun gnus-article-save (save-buffer file &optional num)
3196 "Save the currently selected article."
3197 (unless gnus-save-all-headers
3198 ;; Remove headers according to `gnus-saved-headers'.
3199 (let ((gnus-visible-headers
3200 (or gnus-saved-headers gnus-visible-headers))
3201 (gnus-article-buffer save-buffer))
3203 (set-buffer save-buffer)
3204 (article-hide-headers 1 t))))
3205 (save-window-excursion
3206 (if (not gnus-default-article-saver)
3207 (error "No default saver is defined")
3208 ;; !!! Magic! The saving functions all save
3209 ;; `gnus-save-article-buffer' (or so they think), but we
3210 ;; bind that variable to our save-buffer.
3211 (set-buffer gnus-article-buffer)
3212 (let* ((gnus-save-article-buffer save-buffer)
3215 ((not gnus-prompt-before-saving) 'default)
3216 ((eq gnus-prompt-before-saving 'always) nil)
3218 (gnus-number-of-articles-to-be-saved
3219 (when (eq gnus-prompt-before-saving t)
3221 (set-buffer gnus-article-current-summary)
3222 (funcall gnus-default-article-saver filename)))))
3224 (defun gnus-read-save-file-name (prompt &optional filename
3225 function group headers variable)
3227 (funcall function group headers (symbol-value variable)))
3232 ((eq filename 'default)
3238 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3241 (if (and gnus-number-of-articles-to-be-saved
3242 (> gnus-number-of-articles-to-be-saved 1))
3243 (format "these %d articles"
3244 gnus-number-of-articles-to-be-saved)
3247 ;; Let the split methods have their say.
3249 ;; No split name was found.
3252 (concat prompt " (default "
3253 (file-name-nondirectory default-name) ") ")
3254 (file-name-directory default-name)
3256 ;; A single group name is returned.
3257 ((stringp split-name)
3259 (funcall function split-name headers
3260 (symbol-value variable)))
3262 (concat prompt " (default "
3263 (file-name-nondirectory default-name) ") ")
3264 (file-name-directory default-name)
3266 ;; A single split name was found
3267 ((= 1 (length split-name))
3268 (let* ((name (expand-file-name
3270 gnus-article-save-directory))
3271 (dir (cond ((file-directory-p name)
3272 (file-name-as-directory name))
3273 ((file-exists-p name) name)
3274 (t gnus-article-save-directory))))
3276 (concat prompt " (default " name ") ")
3278 ;; A list of splits was found.
3280 (setq split-name (nreverse split-name))
3282 (let ((file-name-history
3283 (nconc split-name file-name-history)))
3287 (concat prompt " (`M-p' for defaults) ")
3288 gnus-article-save-directory
3290 gnus-article-save-directory)))
3291 (car (push result file-name-history)))))))
3292 ;; Create the directory.
3293 (gnus-make-directory (file-name-directory file))
3294 ;; If we have read a directory, we append the default file name.
3295 (when (file-directory-p file)
3296 (setq file (expand-file-name (file-name-nondirectory
3298 (file-name-as-directory file))))
3299 ;; Possibly translate some characters.
3300 (nnheader-translate-file-chars file))))))
3301 (gnus-make-directory (file-name-directory result))
3302 (set variable result)))
3304 (defun gnus-article-archive-name (group)
3305 "Return the first instance of an \"Archive-name\" in the current buffer."
3306 (let ((case-fold-search t))
3307 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3308 (nnheader-concat gnus-article-save-directory
3309 (match-string 1)))))
3311 (defun gnus-article-nndoc-name (group)
3312 "If GROUP is an nndoc group, return the name of the parent group."
3313 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3314 (gnus-group-get-parameter group 'save-article-group)))
3316 (defun gnus-summary-save-in-rmail (&optional filename)
3317 "Append this article to Rmail file.
3318 Optional argument FILENAME specifies file name.
3319 Directory to save to is default to `gnus-article-save-directory'."
3320 (setq filename (gnus-read-save-file-name
3321 "Save %s in rmail file:" filename
3322 gnus-rmail-save-name gnus-newsgroup-name
3323 gnus-current-headers 'gnus-newsgroup-last-rmail))
3324 (gnus-eval-in-buffer-window gnus-save-article-buffer
3328 (gnus-output-to-rmail filename))))
3331 (defun gnus-summary-save-in-mail (&optional filename)
3332 "Append this article to Unix mail file.
3333 Optional argument FILENAME specifies file name.
3334 Directory to save to is default to `gnus-article-save-directory'."
3335 (setq filename (gnus-read-save-file-name
3336 "Save %s in Unix mail file:" filename
3337 gnus-mail-save-name gnus-newsgroup-name
3338 gnus-current-headers 'gnus-newsgroup-last-mail))
3339 (gnus-eval-in-buffer-window gnus-save-article-buffer
3343 (if (and (file-readable-p filename)
3344 (file-regular-p filename)
3345 (mail-file-babyl-p filename))
3346 (rmail-output-to-rmail-file filename t)
3347 (gnus-output-to-mail filename)))))
3350 (defun gnus-summary-save-in-file (&optional filename overwrite)
3351 "Append this article to file.
3352 Optional argument FILENAME specifies file name.
3353 Directory to save to is default to `gnus-article-save-directory'."
3354 (setq filename (gnus-read-save-file-name
3355 "Save %s in file:" filename
3356 gnus-file-save-name gnus-newsgroup-name
3357 gnus-current-headers 'gnus-newsgroup-last-file))
3358 (gnus-eval-in-buffer-window gnus-save-article-buffer
3362 (when (and overwrite
3363 (file-exists-p filename))
3364 (delete-file filename))
3365 (gnus-output-to-file filename))))
3368 (defun gnus-summary-write-to-file (&optional filename)
3369 "Write this article to a file, overwriting it if the file exists.
3370 Optional argument FILENAME specifies file name.
3371 The directory to save in defaults to `gnus-article-save-directory'."
3372 (gnus-summary-save-in-file nil t))
3374 (defun gnus-summary-save-body-in-file (&optional filename)
3375 "Append this article body to a file.
3376 Optional argument FILENAME specifies file name.
3377 The directory to save in defaults to `gnus-article-save-directory'."
3378 (setq filename (gnus-read-save-file-name
3379 "Save %s body in file:" filename
3380 gnus-file-save-name gnus-newsgroup-name
3381 gnus-current-headers 'gnus-newsgroup-last-file))
3382 (gnus-eval-in-buffer-window gnus-save-article-buffer
3386 (when (article-goto-body)
3387 (narrow-to-region (point) (point-max)))
3388 (gnus-output-to-file filename))))
3391 (defun gnus-summary-save-in-pipe (&optional command)
3392 "Pipe this article to subprocess."
3394 (cond ((and (eq command 'default)
3395 gnus-last-shell-command)
3396 gnus-last-shell-command)
3401 "Shell command on %s: "
3402 (if (and gnus-number-of-articles-to-be-saved
3403 (> gnus-number-of-articles-to-be-saved 1))
3404 (format "these %d articles"
3405 gnus-number-of-articles-to-be-saved)
3407 gnus-last-shell-command))))
3408 (when (string-equal command "")
3409 (if gnus-last-shell-command
3410 (setq command gnus-last-shell-command)
3411 (error "A command is required")))
3412 (gnus-eval-in-buffer-window gnus-article-buffer
3415 (shell-command-on-region (point-min) (point-max) command nil)))
3416 (setq gnus-last-shell-command command))
3418 (defmacro gnus-read-string (prompt &optional initial-contents history
3420 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3421 (if (and (featurep 'xemacs)
3422 (< emacs-minor-version 2))
3423 `(read-string ,prompt ,initial-contents ,history)
3424 `(read-string ,prompt ,initial-contents ,history ,default-value)))
3426 (defun gnus-summary-pipe-to-muttprint (&optional command)
3427 "Pipe this article to muttprint."
3428 (setq command (gnus-read-string
3429 "Print using command: " gnus-summary-muttprint-program
3430 nil gnus-summary-muttprint-program))
3431 (gnus-summary-save-in-pipe command))
3433 ;;; Article file names when saving.
3435 (defun gnus-capitalize-newsgroup (newsgroup)
3436 "Capitalize NEWSGROUP name."
3437 (when (not (zerop (length newsgroup)))
3438 (concat (char-to-string (upcase (aref newsgroup 0)))
3439 (substring newsgroup 1))))
3441 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3442 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3443 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3444 Otherwise, it is like ~/News/news/group/num."
3447 (concat (if (gnus-use-long-file-name 'not-save)
3448 (gnus-capitalize-newsgroup newsgroup)
3449 (gnus-newsgroup-directory-form newsgroup))
3450 "/" (int-to-string (mail-header-number headers)))
3451 gnus-article-save-directory)))
3453 (string-equal (file-name-directory default)
3454 (file-name-directory last-file))
3455 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3457 (or last-file default))))
3459 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3460 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3461 If variable `gnus-use-long-file-name' is non-nil, it is
3462 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3465 (concat (if (gnus-use-long-file-name 'not-save)
3467 (gnus-newsgroup-directory-form newsgroup))
3468 "/" (int-to-string (mail-header-number headers)))
3469 gnus-article-save-directory)))
3471 (string-equal (file-name-directory default)
3472 (file-name-directory last-file))
3473 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3475 (or last-file default))))
3477 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3478 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3479 If variable `gnus-use-long-file-name' is non-nil, it is
3480 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3483 (if (gnus-use-long-file-name 'not-save)
3486 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3488 gnus-article-save-directory)))
3490 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3491 "Generate file name from sender."
3492 (let ((from (mail-header-from headers)))
3494 (if (and from (string-match "\\([^ <]+\\)@" from))
3495 (match-string 1 from)
3497 gnus-article-save-directory)))
3499 (defun article-verify-x-pgp-sig ()
3502 (if (gnus-buffer-live-p gnus-original-article-buffer)
3503 (let ((sig (with-current-buffer gnus-original-article-buffer
3504 (gnus-fetch-field "X-PGP-Sig")))
3508 (mml2015-clear-verify-function))
3510 (insert-buffer-substring gnus-original-article-buffer)
3511 (setq items (split-string sig))
3512 (message-narrow-to-head)
3513 (let ((inhibit-point-motion-hooks t)
3514 (case-fold-search t))
3515 ;; Don't verify multiple headers.
3516 (setq headers (mapconcat (lambda (header)
3518 (mail-fetch-field header)
3520 (split-string (nth 1 items) ",") "")))
3521 (delete-region (point-min) (point-max))
3522 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3523 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3528 (if (looking-at "^-")
3531 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3532 (insert "Version: " (car items) "\n\n")
3533 (insert (mapconcat 'identity (cddr items) "\n"))
3534 (insert "\n-----END PGP SIGNATURE-----\n")
3535 (let ((mm-security-handle (list (format "multipart/signed"))))
3536 (mml2015-clean-buffer)
3537 (let ((coding-system-for-write (or gnus-newsgroup-charset
3539 (funcall (mml2015-clear-verify-function)))
3541 (or (mm-handle-multipart-ctl-parameter
3542 mm-security-handle 'gnus-details)
3543 (mm-handle-multipart-ctl-parameter
3544 mm-security-handle 'gnus-info)))))
3546 (let ((inhibit-read-only t) bface eface)
3548 (message-narrow-to-head)
3549 (goto-char (point-max))
3551 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3552 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3553 (message-remove-header "X-Gnus-PGP-Verify")
3554 (if (re-search-forward "^X-PGP-Sig:" nil t)
3556 (goto-char (point-max)))
3557 (narrow-to-region (point) (point))
3558 (insert "X-Gnus-PGP-Verify: " info "\n")
3559 (goto-char (point-min))
3562 (if (not (looking-at "^[ \t]"))
3566 (goto-char (point-min))
3567 (when (looking-at "\\([^:]+\\): *")
3568 (put-text-property (match-beginning 1) (1+ (match-end 1))
3570 (put-text-property (match-end 0) (point-max)
3571 'face eface)))))))))
3573 (defun article-verify-cancel-lock ()
3574 "Verify Cancel-Lock header."
3576 (if (gnus-buffer-live-p gnus-original-article-buffer)
3577 (canlock-verify gnus-original-article-buffer)))
3584 (setq afunc (car func)
3587 gfunc (intern (format "gnus-%s" func))))
3589 (when (fboundp afunc)
3590 `(lambda (&optional interactive &rest args)
3591 ,(documentation afunc t)
3592 (interactive (list t))
3594 (set-buffer gnus-article-buffer)
3596 (call-interactively ',afunc)
3597 (apply ',afunc args))))))))
3598 '(article-hide-headers
3599 article-verify-x-pgp-sig
3600 article-verify-cancel-lock
3601 article-hide-boring-headers
3602 article-treat-overstrike
3603 article-fill-long-lines
3604 article-capitalize-sentences
3606 article-remove-leading-whitespace
3607 article-display-x-face
3608 article-display-face
3609 article-de-quoted-unreadable
3610 article-de-base64-unreadable
3613 article-unsplit-urls
3614 article-hide-list-identifiers
3615 article-strip-banner
3618 article-hide-signature
3619 article-strip-headers-in-body
3620 article-remove-trailing-blank-lines
3621 article-strip-leading-blank-lines
3622 article-strip-multiple-blank-lines
3623 article-strip-leading-space
3624 article-strip-trailing-space
3625 article-strip-blank-lines
3626 article-strip-all-blank-lines
3628 article-date-english
3629 article-date-iso8601
3630 article-date-original
3632 article-decode-mime-words
3633 article-decode-charset
3634 article-decode-encoded-words
3638 article-treat-dumbquotes
3639 article-normalize-headers
3640 ;; (article-show-all . gnus-article-show-all-headers)
3644 ;;; Gnus article mode
3647 (put 'gnus-article-mode 'mode-class 'special)
3649 (set-keymap-parent gnus-article-mode-map widget-keymap)
3651 (gnus-define-keys gnus-article-mode-map
3652 " " gnus-article-goto-next-page
3653 "\177" gnus-article-goto-prev-page
3654 [delete] gnus-article-goto-prev-page
3655 [backspace] gnus-article-goto-prev-page
3656 "\C-c^" gnus-article-refer-article
3657 "h" gnus-article-show-summary
3658 "s" gnus-article-show-summary
3659 "\C-c\C-m" gnus-article-mail
3660 "?" gnus-article-describe-briefly
3661 "e" gnus-summary-edit-article
3662 "<" beginning-of-buffer
3664 "\C-c\C-i" gnus-info-find-node
3666 "R" gnus-article-reply-with-original
3667 "F" gnus-article-followup-with-original
3668 "\C-hk" gnus-article-describe-key
3669 "\C-hc" gnus-article-describe-key-briefly
3671 "\C-d" gnus-article-read-summary-keys
3672 "\M-*" gnus-article-read-summary-keys
3673 "\M-#" gnus-article-read-summary-keys
3674 "\M-^" gnus-article-read-summary-keys
3675 "\M-g" gnus-article-read-summary-keys)
3677 (substitute-key-definition
3678 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3680 (defun gnus-article-make-menu-bar ()
3681 (unless (boundp 'gnus-article-commands-menu)
3682 (gnus-summary-make-menu-bar))
3683 (gnus-turn-off-edit-menu 'article)
3684 (unless (boundp 'gnus-article-article-menu)
3686 gnus-article-article-menu gnus-article-mode-map ""
3688 ["Scroll forwards" gnus-article-goto-next-page t]
3689 ["Scroll backwards" gnus-article-goto-prev-page t]
3690 ["Show summary" gnus-article-show-summary t]
3691 ["Fetch Message-ID at point" gnus-article-refer-article t]
3692 ["Mail to address at point" gnus-article-mail t]
3693 ["Send a bug report" gnus-bug t]))
3696 gnus-article-treatment-menu gnus-article-mode-map ""
3697 ;; Fixme: this should use :active (and maybe :visible).
3699 ["Hide headers" gnus-article-hide-headers t]
3700 ["Hide signature" gnus-article-hide-signature t]
3701 ["Hide citation" gnus-article-hide-citation t]
3702 ["Treat overstrike" gnus-article-treat-overstrike t]
3703 ["Remove carriage return" gnus-article-remove-cr t]
3704 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3705 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3706 ["Remove base64" gnus-article-de-base64-unreadable t]
3707 ["Treat html" gnus-article-wash-html t]
3708 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3709 ["Decode HZ" gnus-article-decode-HZ t]))
3711 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3713 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3715 (gnus-run-hooks 'gnus-article-menu-hook)))
3717 (defun gnus-article-mode ()
3718 "Major mode for displaying an article.
3720 All normal editing commands are switched off.
3722 The following commands are available in addition to all summary mode
3724 \\<gnus-article-mode-map>
3725 \\[gnus-article-next-page]\t Scroll the article one page forwards
3726 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3727 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3728 \\[gnus-article-show-summary]\t Display the summary buffer
3729 \\[gnus-article-mail]\t Send a reply to the address near point
3730 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3731 \\[gnus-info-find-node]\t Go to the Gnus info node"
3733 (kill-all-local-variables)
3734 (gnus-simplify-mode-line)
3735 (setq mode-name "Article")
3736 (setq major-mode 'gnus-article-mode)
3737 (make-local-variable 'minor-mode-alist)
3738 (use-local-map gnus-article-mode-map)
3739 (when (gnus-visual-p 'article-menu 'menu)
3740 (gnus-article-make-menu-bar)
3741 (when gnus-summary-tool-bar-map
3742 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3743 (gnus-update-format-specifications nil 'article-mode)
3744 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3745 (set (make-local-variable 'gnus-page-broken) nil)
3746 (make-local-variable 'gnus-button-marker-list)
3747 (make-local-variable 'gnus-article-current-summary)
3748 (make-local-variable 'gnus-article-mime-handles)
3749 (make-local-variable 'gnus-article-decoded-p)
3750 (make-local-variable 'gnus-article-mime-handle-alist)
3751 (make-local-variable 'gnus-article-wash-types)
3752 (make-local-variable 'gnus-article-image-alist)
3753 (make-local-variable 'gnus-article-charset)
3754 (make-local-variable 'gnus-article-ignored-charsets)
3755 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3756 (set (make-local-variable 'nobreak-char-display) nil)
3757 (gnus-set-default-directory)
3758 (buffer-disable-undo)
3759 (setq buffer-read-only t)
3760 (set-syntax-table gnus-article-mode-syntax-table)
3761 (mm-enable-multibyte)
3762 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3764 (defun gnus-article-setup-buffer ()
3765 "Initialize the article buffer."
3766 (let* ((name (if gnus-single-article-buffer "*Article*"
3767 (concat "*Article " gnus-newsgroup-name "*")))
3769 (progn (string-match "\\*Article" name)
3770 (concat " *Original Article"
3771 (substring name (match-end 0))))))
3772 (setq gnus-article-buffer name)
3773 (setq gnus-original-article-buffer original)
3774 (setq gnus-article-mime-handle-alist nil)
3775 ;; This might be a variable local to the summary buffer.
3776 (unless gnus-single-article-buffer
3778 (set-buffer gnus-summary-buffer)
3779 (setq gnus-article-buffer name)
3780 (setq gnus-original-article-buffer original)
3781 (gnus-set-global-variables)))
3782 (gnus-article-setup-highlight-words)
3783 ;; Init original article buffer.
3785 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3786 (mm-enable-multibyte)
3787 (setq major-mode 'gnus-original-article-mode)
3788 (make-local-variable 'gnus-original-article))
3789 (if (and (get-buffer name)
3790 (with-current-buffer name
3791 (if gnus-article-edit-mode
3792 (if (y-or-n-p "Article mode edit in progress; discard? ")
3794 (set-buffer-modified-p nil)
3795 (gnus-kill-buffer name)
3798 (error "Action aborted"))
3802 (set (make-local-variable 'gnus-article-edit-mode) nil)
3803 (when gnus-article-mime-handles
3804 (mm-destroy-parts gnus-article-mime-handles)
3805 (setq gnus-article-mime-handles nil))
3806 ;; Set it to nil in article-buffer!
3807 (setq gnus-article-mime-handle-alist nil)
3808 (buffer-disable-undo)
3809 (setq buffer-read-only t)
3810 ;; This list just keeps growing if we don't reset it.
3811 (setq gnus-button-marker-list nil)
3812 (unless (eq major-mode 'gnus-article-mode)
3813 (gnus-article-mode))
3816 (set-buffer (gnus-get-buffer-create name))
3818 (make-local-variable 'gnus-summary-buffer)
3819 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3820 (current-buffer)))))
3822 ;; Set article window start at LINE, where LINE is the number of lines
3823 ;; from the head of the article.
3824 (defun gnus-article-set-window-start (&optional line)
3826 (gnus-get-buffer-window gnus-article-buffer t)
3828 (set-buffer gnus-article-buffer)
3829 (goto-char (point-min))
3832 (gnus-message 6 "Moved to bookmark")
3833 (search-forward "\n\n" nil t)
3837 (defun gnus-article-prepare (article &optional all-headers header)
3838 "Prepare ARTICLE in article mode buffer.
3839 ARTICLE should either be an article number or a Message-ID.
3840 If ARTICLE is an id, HEADER should be the article headers.
3841 If ALL-HEADERS is non-nil, no headers are hidden."
3843 ;; Make sure we start in a summary buffer.
3844 (unless (eq major-mode 'gnus-summary-mode)
3845 (set-buffer gnus-summary-buffer))
3846 (setq gnus-summary-buffer (current-buffer))
3847 (let* ((gnus-article (if header (mail-header-number header) article))
3848 (summary-buffer (current-buffer))
3849 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3850 (group gnus-newsgroup-name)
3853 (gnus-article-setup-buffer)
3854 (set-buffer gnus-article-buffer)
3855 ;; Deactivate active regions.
3856 (when (and (boundp 'transient-mark-mode)
3857 transient-mark-mode)
3858 (setq mark-active nil))
3859 (if (not (setq result (let ((inhibit-read-only t))
3860 (gnus-request-article-this-buffer
3862 ;; There is no such article.
3864 (when (and (numberp article)
3865 (not (memq article gnus-newsgroup-sparse)))
3866 (setq gnus-article-current
3867 (cons gnus-newsgroup-name article))
3868 (set-buffer gnus-summary-buffer)
3869 (setq gnus-current-article article)
3870 (if (and (memq article gnus-newsgroup-undownloaded)
3871 (not (gnus-online (gnus-find-method-for-group
3872 gnus-newsgroup-name))))
3874 (gnus-summary-set-agent-mark article)
3875 (message "Message marked for downloading"))
3876 (gnus-summary-mark-article article gnus-canceled-mark)
3877 (unless (memq article gnus-newsgroup-sparse)
3878 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3879 (if (or (eq result 'pseudo)
3880 (eq result 'nneething))
3883 (set-buffer summary-buffer)
3884 (push article gnus-newsgroup-history)
3885 (setq gnus-last-article gnus-current-article
3886 gnus-current-article 0
3887 gnus-current-headers nil
3888 gnus-article-current nil)
3889 (if (eq result 'nneething)
3890 (gnus-configure-windows 'summary)
3891 (gnus-configure-windows 'article))
3892 (gnus-set-global-variables))
3893 (let ((gnus-article-mime-handle-alist-1
3894 gnus-article-mime-handle-alist))
3895 (gnus-set-mode-line 'article)))
3896 ;; The result from the `request' was an actual article -
3897 ;; or at least some text that is now displayed in the
3899 (when (and (numberp article)
3900 (not (eq article gnus-current-article)))
3901 ;; Seems like a new article has been selected.
3902 ;; `gnus-current-article' must be an article number.
3904 (set-buffer summary-buffer)
3905 (push article gnus-newsgroup-history)
3906 (setq gnus-last-article gnus-current-article
3907 gnus-current-article article
3908 gnus-current-headers
3909 (gnus-summary-article-header gnus-current-article)
3910 gnus-article-current
3911 (cons gnus-newsgroup-name gnus-current-article))
3912 (unless (vectorp gnus-current-headers)
3913 (setq gnus-current-headers nil))
3914 (gnus-summary-goto-subject gnus-current-article)
3915 (when (gnus-summary-show-thread)
3916 ;; If the summary buffer really was folded, the
3917 ;; previous goto may not actually have gone to
3918 ;; the right article, but the thread root instead.
3920 (gnus-summary-goto-subject gnus-current-article))
3921 (gnus-run-hooks 'gnus-mark-article-hook)
3922 (gnus-set-mode-line 'summary)
3923 (when (gnus-visual-p 'article-highlight 'highlight)
3924 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3925 ;; Set the global newsgroup variables here.
3926 (gnus-set-global-variables)
3927 (setq gnus-have-all-headers
3928 (or all-headers gnus-show-all-headers))))
3930 (gnus-configure-windows 'article))
3931 (when (or (numberp article)
3933 (gnus-article-prepare-display)
3935 (goto-char (point-min))
3936 (when gnus-break-pages
3937 (gnus-narrow-to-page)))
3938 (let ((gnus-article-mime-handle-alist-1
3939 gnus-article-mime-handle-alist))
3940 (gnus-set-mode-line 'article))
3944 (set-window-point (get-buffer-window (current-buffer)) (point))
3945 (gnus-configure-windows 'article)
3949 (defun gnus-article-prepare-display ()
3950 "Make the current buffer look like a nice article."
3951 ;; Hooks for getting information from the article.
3952 ;; This hook must be called before being narrowed.
3953 (let ((gnus-article-buffer (current-buffer))
3955 (inhibit-read-only t))
3956 (unless (eq major-mode 'gnus-article-mode)
3957 (gnus-article-mode))
3958 (setq buffer-read-only nil
3959 gnus-article-wash-types nil
3960 gnus-article-image-alist nil)
3961 (gnus-run-hooks 'gnus-tmp-internal-hook)
3962 (when gnus-display-mime-function
3963 (funcall gnus-display-mime-function))
3964 (gnus-run-hooks 'gnus-article-prepare-hook)))
3967 ;;; Gnus MIME viewing functions
3970 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3971 "Format of the MIME buttons.
3973 Valid specifiers include:
3975 %T MIME type, along with additional info
3976 %n The `name' parameter
3977 %d The description, if any
3978 %l The length of the encoded part
3979 %p The part identifier number
3980 %e Dots if the part isn't displayed
3982 General format specifiers can also be used. See Info node
3983 `(gnus)Formatting Variables'.")
3985 (defvar gnus-mime-button-line-format-alist
3986 '((?t gnus-tmp-type ?s)
3987 (?T gnus-tmp-type-long ?s)
3988 (?n gnus-tmp-name ?s)
3989 (?d gnus-tmp-description ?s)
3991 (?l gnus-tmp-length ?d)
3992 (?e gnus-tmp-dots ?s)))
3994 (defvar gnus-mime-button-commands
3995 '((gnus-article-press-button "\r" "Toggle Display")
3996 (gnus-mime-view-part "v" "View Interactively...")
3997 (gnus-mime-view-part-as-type "t" "View As Type...")
3998 (gnus-mime-view-part-as-charset "C" "View As charset...")
3999 (gnus-mime-save-part "o" "Save...")
4000 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4001 (gnus-mime-delete-part "d" "Delete part")
4002 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4003 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4004 (gnus-mime-view-part-internally "E" "View Internally")
4005 (gnus-mime-view-part-externally "e" "View Externally")
4006 (gnus-mime-print-part "p" "Print")
4007 (gnus-mime-pipe-part "|" "Pipe To Command...")
4008 (gnus-mime-action-on-part "." "Take action on the part...")))
4010 (defun gnus-article-mime-part-status ()
4011 (if gnus-article-mime-handle-alist-1
4012 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4014 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4017 (defvar gnus-mime-button-map
4018 (let ((map (make-sparse-keymap)))
4019 (unless (>= (string-to-number emacs-version) 21)
4020 ;; XEmacs doesn't care.
4021 (set-keymap-parent map gnus-article-mode-map))
4022 (define-key map gnus-mouse-2 'gnus-article-push-button)
4023 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4024 (dolist (c gnus-mime-button-commands)
4025 (define-key map (cadr c) (car c)))
4029 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4031 ,@(mapcar (lambda (c)
4032 (vector (caddr c) (car c) :enable t))
4033 gnus-mime-button-commands)))
4036 (define-compiler-macro popup-menu (&whole form
4037 menu &optional position prefix)
4038 (if (and (fboundp 'popup-menu)
4039 (not (memq 'popup-menu (assoc "lmenu" load-history))))
4041 ;; Gnus is probably running under Emacs 20.
4042 `(let* ((menu (cdr ,menu))
4043 (response (x-popup-menu
4045 (cons "" (mapcar (lambda (c)
4046 (cons (caddr c) (car c)))
4049 (call-interactively (nth 3 (assq response menu))))))))
4051 (defun gnus-mime-button-menu (event prefix)
4052 "Construct a context-sensitive menu of MIME commands."
4053 (interactive "e\nP")
4054 (save-window-excursion
4055 (let ((pos (event-start event)))
4056 (select-window (posn-window pos))
4057 (goto-char (posn-point pos))
4058 (gnus-article-check-buffer)
4059 (popup-menu gnus-mime-button-menu nil prefix))))
4061 (defun gnus-mime-view-all-parts (&optional handles)
4062 "View all the MIME parts."
4064 (save-current-buffer
4065 (set-buffer gnus-article-buffer)
4066 (let ((handles (or handles gnus-article-mime-handles))
4067 (mail-parse-charset gnus-newsgroup-charset)
4068 (mail-parse-ignored-charsets
4069 (with-current-buffer gnus-summary-buffer
4070 gnus-newsgroup-ignored-charsets)))
4072 (mm-remove-parts handles)
4073 (goto-char (point-min))
4074 (or (search-forward "\n\n") (goto-char (point-max)))
4075 (let ((inhibit-read-only t))
4076 (delete-region (point) (point-max))
4077 (mm-display-parts handles))))))
4079 (defun gnus-mime-save-part-and-strip ()
4080 "Save the MIME part under point then replace it with an external body."
4082 (gnus-article-check-buffer)
4083 (when (gnus-group-read-only-p)
4084 (error "The current group does not support deleting of parts"))
4085 (when (mm-complicated-handles gnus-article-mime-handles)
4087 The current article has a complicated MIME structure, giving up..."))
4088 (when (gnus-yes-or-no-p "\
4089 Deleting parts may malfunction or destroy the article; continue? ")
4090 (let* ((data (get-text-property (point) 'gnus-data))
4092 (handles gnus-article-mime-handles))
4093 (setq file (and data (mm-save-part data)))
4095 (with-current-buffer (mm-handle-buffer data)
4097 (insert "Content-Type: " (mm-handle-media-type data))
4098 (mml-insert-parameter-string (cdr (mm-handle-type data))
4101 (insert "Content-ID: " (message-make-message-id) "\n")
4102 (insert "Content-Transfer-Encoding: binary\n")
4105 (cdr (mm-make-handle nil
4106 `("message/external-body"
4107 (access-type . "LOCAL-FILE")
4109 (set-buffer gnus-summary-buffer)
4110 (gnus-article-edit-article
4113 (let ((mail-parse-charset (or gnus-article-charset
4114 ',gnus-newsgroup-charset))
4115 (mail-parse-ignored-charsets
4116 (or gnus-article-ignored-charsets
4117 ',gnus-newsgroup-ignored-charsets))
4118 (mbl mml-buffer-list))
4119 (setq mml-buffer-list nil)
4120 (insert-buffer gnus-original-article-buffer)
4121 (mime-to-mml ',handles)
4122 (setq gnus-article-mime-handles nil)
4123 (let ((mbl1 mml-buffer-list))
4124 (setq mml-buffer-list mbl)
4125 (set (make-local-variable 'mml-buffer-list) mbl1))
4126 (gnus-make-local-hook 'kill-buffer-hook)
4127 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4128 `(lambda (no-highlight)
4129 (let ((mail-parse-charset (or gnus-article-charset
4130 ',gnus-newsgroup-charset))
4131 (message-options message-options)
4132 (message-options-set-recipient)
4133 (mail-parse-ignored-charsets
4134 (or gnus-article-ignored-charsets
4135 ',gnus-newsgroup-ignored-charsets)))
4137 (mml-destroy-buffers)
4138 (remove-hook 'kill-buffer-hook
4139 'mml-destroy-buffers t)
4140 (kill-local-variable 'mml-buffer-list))
4141 (gnus-summary-edit-article-done
4142 ,(or (mail-header-references gnus-current-headers) "")
4143 ,(gnus-group-read-only-p)
4144 ,gnus-summary-buffer no-highlight)))))))
4146 (defun gnus-mime-delete-part ()
4147 "Delete the MIME part under point.
4148 Replace it with some information about the removed part."
4150 (gnus-article-check-buffer)
4151 (when (gnus-group-read-only-p)
4152 (error "The current group does not support deleting of parts"))
4153 (when (mm-complicated-handles gnus-article-mime-handles)
4155 The current article has a complicated MIME structure, giving up..."))
4156 (when (gnus-yes-or-no-p "\
4157 Deleting parts may malfunction or destroy the article; continue? ")
4158 (let* ((data (get-text-property (point) 'gnus-data))
4159 (handles gnus-article-mime-handles)
4163 (mail-decode-encoded-word-string (or (mm-handle-description data)
4166 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4168 (type (mm-handle-media-type data)))
4170 (error "No MIME part under point"))
4171 (with-current-buffer (mm-handle-buffer data)
4172 (let ((bsize (format "%s" (buffer-size))))
4177 "| The following attachment has been deleted:\n"
4179 "| Type: " type "\n"
4180 "| Filename: " filename "\n"
4181 "| Size (encoded): " bsize " Byte\n"
4182 "| Description: " description "\n"
4185 (cdr (mm-make-handle
4186 nil `("text/plain") nil nil
4188 (format "Deleted attachment (%s bytes)" bsize))))))
4189 (set-buffer gnus-summary-buffer)
4190 ;; FIXME: maybe some of the following code (borrowed from
4191 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4192 (gnus-article-edit-article
4195 (let ((mail-parse-charset (or gnus-article-charset
4196 ',gnus-newsgroup-charset))
4197 (mail-parse-ignored-charsets
4198 (or gnus-article-ignored-charsets
4199 ',gnus-newsgroup-ignored-charsets))
4200 (mbl mml-buffer-list))
4201 (setq mml-buffer-list nil)
4202 (insert-buffer gnus-original-article-buffer)
4203 (mime-to-mml ',handles)
4204 (setq gnus-article-mime-handles nil)
4205 (let ((mbl1 mml-buffer-list))
4206 (setq mml-buffer-list mbl)
4207 (set (make-local-variable 'mml-buffer-list) mbl1))
4208 (gnus-make-local-hook 'kill-buffer-hook)
4209 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4210 `(lambda (no-highlight)
4211 (let ((mail-parse-charset (or gnus-article-charset
4212 ',gnus-newsgroup-charset))
4213 (message-options message-options)
4214 (message-options-set-recipient)
4215 (mail-parse-ignored-charsets
4216 (or gnus-article-ignored-charsets
4217 ',gnus-newsgroup-ignored-charsets)))
4219 (mml-destroy-buffers)
4220 (remove-hook 'kill-buffer-hook
4221 'mml-destroy-buffers t)
4222 (kill-local-variable 'mml-buffer-list))
4223 (gnus-summary-edit-article-done
4224 ,(or (mail-header-references gnus-current-headers) "")
4225 ,(gnus-group-read-only-p)
4226 ,gnus-summary-buffer no-highlight)))))
4227 ;; Not in `gnus-mime-save-part-and-strip':
4228 (gnus-article-edit-done)
4229 (gnus-summary-expand-window)
4230 (gnus-summary-show-article))
4232 (defun gnus-mime-save-part ()
4233 "Save the MIME part under point."
4235 (gnus-article-check-buffer)
4236 (let ((data (get-text-property (point) 'gnus-data)))
4238 (mm-save-part data))))
4240 (defun gnus-mime-pipe-part ()
4241 "Pipe the MIME part under point to a process."
4243 (gnus-article-check-buffer)
4244 (let ((data (get-text-property (point) 'gnus-data)))
4246 (mm-pipe-part data))))
4248 (defun gnus-mime-view-part ()
4249 "Interactively choose a viewing method for the MIME part under point."
4251 (gnus-article-check-buffer)
4252 (let ((data (get-text-property (point) 'gnus-data)))
4254 (setq gnus-article-mime-handles
4256 gnus-article-mime-handles (setq data (copy-sequence data))))
4257 (mm-interactively-view-part data))))
4259 (defun gnus-mime-view-part-as-type-internal ()
4260 (gnus-article-check-buffer)
4261 (let* ((name (mail-content-type-get
4262 (mm-handle-type (get-text-property (point) 'gnus-data))
4264 (def-type (and name (mm-default-file-encoding name))))
4265 (and def-type (cons def-type 0))))
4267 (defun gnus-mime-view-part-as-type (&optional mime-type)
4268 "Choose a MIME media type, and view the part as such."
4271 (setq mime-type (completing-read
4272 "View as MIME type: "
4273 (mapcar #'list (mailcap-mime-types))
4275 (gnus-mime-view-part-as-type-internal))))
4276 (gnus-article-check-buffer)
4277 (let ((handle (get-text-property (point) 'gnus-data)))
4280 (mm-make-handle (mm-handle-buffer handle)
4281 (cons mime-type (cdr (mm-handle-type handle)))
4282 (mm-handle-encoding handle)
4283 (mm-handle-undisplayer handle)
4284 (mm-handle-disposition handle)
4285 (mm-handle-description handle)
4287 (mm-handle-id handle)))
4288 (setq gnus-article-mime-handles
4289 (mm-merge-handles gnus-article-mime-handles handle))
4290 (gnus-mm-display-part handle))))
4293 (require 'jka-compr))
4295 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4296 ;; emacs can do that itself.
4298 (defun gnus-mime-jka-compr-maybe-uncompress ()
4299 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4300 The uncompress method used is derived from `buffer-file-name'."
4301 (when (and (fboundp 'jka-compr-installed-p)
4302 (jka-compr-installed-p))
4303 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4305 (let ((basename (file-name-nondirectory buffer-file-name))
4306 (args (jka-compr-info-uncompress-args info))
4307 (prog (jka-compr-info-uncompress-program info))
4308 (message (jka-compr-info-uncompress-message info))
4309 (err-file (jka-compr-make-temp-name)))
4311 (message "%s %s..." message basename))
4313 (unless (memq (apply 'call-process-region
4314 (point-min) (point-max)
4316 t (list t err-file) nil
4318 jka-compr-acceptable-retval-list)
4319 (jka-compr-error prog args basename message err-file))
4320 (jka-compr-delete-temp-file err-file)))))))
4322 (defun gnus-mime-copy-part (&optional handle)
4323 "Put the MIME part under point into a new buffer.
4324 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4327 (gnus-article-check-buffer)
4328 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4329 (contents (and handle (mm-get-part handle)))
4331 (file-name-nondirectory
4333 (mail-content-type-get (mm-handle-type handle) 'name)
4334 (mail-content-type-get (mm-handle-disposition handle)
4337 (buffer (and base (generate-new-buffer base))))
4339 (switch-to-buffer buffer)
4341 ;; We do it this way to make `normal-mode' set the appropriate mode.
4344 (setq buffer-file-name (expand-file-name base))
4345 (gnus-mime-jka-compr-maybe-uncompress)
4347 (setq buffer-file-name nil))
4348 (goto-char (point-min)))))
4350 (defun gnus-mime-print-part (&optional handle filename)
4351 "Print the MIME part under point."
4352 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4353 (gnus-article-check-buffer)
4354 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4355 (contents (and handle (mm-get-part handle)))
4356 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4357 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4362 (mm-save-part-to-file handle file)
4363 (call-process shell-file-name nil
4364 (generate-new-buffer " *mm*")
4366 shell-command-switch
4368 printer file (mm-handle-type handle))))
4372 (gnus-print-buffer))
4373 (ps-despool filename)))))
4375 (defun gnus-mime-inline-part (&optional handle arg)
4376 "Insert the MIME part under point into the current buffer."
4377 (interactive (list nil current-prefix-arg))
4378 (gnus-article-check-buffer)
4379 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4382 (inhibit-read-only t))
4384 (if (and (not arg) (mm-handle-undisplayer handle))
4385 (mm-remove-part handle)
4386 (setq contents (mm-get-part handle))
4389 (setq charset (or (mail-content-type-get
4390 (mm-handle-type handle) 'charset)
4391 gnus-newsgroup-charset)))
4393 (if (mm-handle-undisplayer handle)
4394 (mm-remove-part handle))
4397 gnus-summary-show-article-charset-alist))
4398 (mm-read-coding-system "Charset: "))))
4400 (if (mm-handle-undisplayer handle)
4401 (mm-remove-part handle))))
4406 (setq charset (mm-charset-to-coding-system
4408 (not (eq charset 'ascii)))
4409 (mm-decode-coding-string contents charset)
4410 (mm-string-to-multibyte contents)))
4413 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4414 "Insert the MIME part under point into the current buffer using the
4416 (interactive (list nil current-prefix-arg))
4417 (gnus-article-check-buffer)
4418 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4421 (inhibit-read-only t))
4423 (if (mm-handle-undisplayer handle)
4424 (mm-remove-part handle))
4425 (let ((gnus-newsgroup-charset
4427 gnus-summary-show-article-charset-alist))
4428 (mm-read-coding-system "Charset: ")))
4429 (gnus-newsgroup-ignored-charsets 'gnus-all))
4430 (gnus-article-press-button)))))
4432 (defun gnus-mime-view-part-externally (&optional handle)
4433 "View the MIME part under point with an external viewer."
4435 (gnus-article-check-buffer)
4436 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4437 (mm-user-display-methods nil)
4438 (mm-inlined-types nil)
4439 (mail-parse-charset gnus-newsgroup-charset)
4440 (mail-parse-ignored-charsets
4441 (save-excursion (set-buffer gnus-summary-buffer)
4442 gnus-newsgroup-ignored-charsets)))
4444 (if (mm-handle-undisplayer handle)
4445 (mm-remove-part handle)
4446 (mm-display-part handle)))))
4448 (defun gnus-mime-view-part-internally (&optional handle)
4449 "View the MIME part under point with an internal viewer.
4450 If no internal viewer is available, use an external viewer."
4452 (gnus-article-check-buffer)
4453 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4454 (mm-inlined-types '(".*"))
4455 (mm-inline-large-images t)
4456 (mail-parse-charset gnus-newsgroup-charset)
4457 (mail-parse-ignored-charsets
4458 (save-excursion (set-buffer gnus-summary-buffer)
4459 gnus-newsgroup-ignored-charsets))
4460 (inhibit-read-only t))
4462 (if (mm-handle-undisplayer handle)
4463 (mm-remove-part handle)
4464 (mm-display-part handle)))))
4466 (defun gnus-mime-action-on-part (&optional action)
4467 "Do something with the MIME attachment at \(point\)."
4469 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4470 (gnus-article-check-buffer)
4471 (let ((action-pair (assoc action gnus-mime-action-alist)))
4473 (funcall (cdr action-pair)))))
4475 (defun gnus-article-part-wrapper (n function)
4476 (save-current-buffer
4477 (set-buffer gnus-article-buffer)
4478 (when (> n (length gnus-article-mime-handle-alist))
4479 (error "No such part"))
4480 (gnus-article-goto-part n)
4481 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4482 (funcall function handle))))
4484 (defun gnus-article-pipe-part (n)
4485 "Pipe MIME part N, which is the numerical prefix."
4487 (gnus-article-part-wrapper n 'mm-pipe-part))
4489 (defun gnus-article-save-part (n)
4490 "Save MIME part N, which is the numerical prefix."
4492 (gnus-article-part-wrapper n 'mm-save-part))
4494 (defun gnus-article-interactively-view-part (n)
4495 "View MIME part N interactively, which is the numerical prefix."
4497 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4499 (defun gnus-article-copy-part (n)
4500 "Copy MIME part N, which is the numerical prefix."
4502 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4504 (defun gnus-article-view-part-as-charset (n)
4505 "View MIME part N using a specified charset.
4506 N is the numerical prefix."
4508 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4510 (defun gnus-article-view-part-externally (n)
4511 "View MIME part N externally, which is the numerical prefix."
4513 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4515 (defun gnus-article-inline-part (n)
4516 "Inline MIME part N, which is the numerical prefix."
4518 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4520 (defun gnus-article-mime-match-handle-first (condition)
4522 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4523 (while (setq ihandle (pop alist))
4525 ((functionp condition)
4526 (funcall condition (cdr ihandle)))
4527 ((eq condition 'undisplayed)
4528 (not (or (mm-handle-undisplayer (cdr ihandle))
4529 (equal (mm-handle-media-type (cdr ihandle))
4530 "multipart/alternative"))))
4531 ((eq condition 'undisplayed-alternative)
4532 (not (mm-handle-undisplayer (cdr ihandle))))
4534 (gnus-article-goto-part (car ihandle))
4535 (or (not n) (< (car ihandle) n)))
4536 (setq n (car ihandle))))
4540 (defun gnus-article-view-part (&optional n)
4541 "View MIME part N, which is the numerical prefix."
4543 (save-current-buffer
4544 (set-buffer gnus-article-buffer)
4545 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4546 gnus-article-mime-match-handle-function)))
4547 (when (> n (length gnus-article-mime-handle-alist))
4548 (error "No such part"))
4549 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4550 (when (gnus-article-goto-part n)
4551 (if (equal (car handle) "multipart/alternative")
4552 (gnus-article-press-button)
4553 (when (eq (gnus-mm-display-part handle) 'internal)
4554 (gnus-set-window-start)))))))
4556 (defsubst gnus-article-mime-total-parts ()
4557 (if (bufferp (car gnus-article-mime-handles))
4559 (1- (length gnus-article-mime-handles))))
4561 (defun gnus-mm-display-part (handle)
4562 "Display HANDLE and fix MIME button."
4563 (let ((id (get-text-property (point) 'gnus-part))
4565 (inhibit-read-only t))
4568 (let ((window (selected-window))
4569 (mail-parse-charset gnus-newsgroup-charset)
4570 (mail-parse-ignored-charsets
4571 (if (gnus-buffer-live-p gnus-summary-buffer)
4573 (set-buffer gnus-summary-buffer)
4574 gnus-newsgroup-ignored-charsets)
4578 (let ((win (gnus-get-buffer-window (current-buffer) t))
4581 (select-window win))
4584 (if (mm-handle-displayed-p handle)
4585 ;; This will remove the part.
4586 (mm-display-part handle)
4588 (narrow-to-region (point)
4589 (if (eobp) (point) (1+ (point))))
4590 (mm-display-part handle)
4591 ;; We narrow to the part itself and
4592 ;; then call the treatment functions.
4593 (goto-char (point-min))
4595 (narrow-to-region (point) (point-max))
4598 (gnus-article-mime-total-parts)
4599 (mm-handle-media-type handle)))))
4600 (if (window-live-p window)
4601 (select-window window)))))
4604 (gnus-insert-mime-button
4605 handle id (list (mm-handle-displayed-p handle)))
4606 (goto-char point))))
4608 (defun gnus-article-goto-part (n)
4609 "Go to MIME part N."
4610 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4612 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4613 (let ((gnus-tmp-name
4614 (or (mail-content-type-get (mm-handle-type handle) 'name)
4615 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4616 (mail-content-type-get (mm-handle-type handle) 'url)
4618 (gnus-tmp-type (mm-handle-media-type handle))
4619 (gnus-tmp-description
4620 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4623 (if (if displayed (car displayed)
4624 (mm-handle-displayed-p handle))
4626 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4628 gnus-tmp-type-long b e)
4629 (when (string-match ".*/" gnus-tmp-name)
4630 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4631 (setq gnus-tmp-type-long (concat gnus-tmp-type
4632 (and (not (equal gnus-tmp-name ""))
4633 (concat "; " gnus-tmp-name))))
4634 (unless (equal gnus-tmp-description "")
4635 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4640 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4641 `(,@(gnus-local-map-property gnus-mime-button-map)
4642 gnus-callback gnus-mm-display-part
4643 gnus-part ,gnus-tmp-id
4644 article-type annotation
4647 ;; Exclude a newline.
4650 (widget-convert-button
4653 :action 'gnus-widget-press-button
4654 :button-keymap gnus-mime-button-map
4656 (lambda (widget/window &optional overlay pos)
4657 ;; Needed to properly clear the message due to a bug in
4658 ;; wid-edit (XEmacs only).
4659 (if (boundp 'help-echo-owns-message)
4660 (setq help-echo-owns-message t))
4662 "%S: %s the MIME part; %S: more options"
4663 (aref gnus-mouse-2 0)
4664 ;; XEmacs will get a single widget arg; Emacs 21 will get
4665 ;; window, overlay, position.
4666 (if (mm-handle-displayed-p
4668 (with-current-buffer (gnus-overlay-buffer overlay)
4669 (widget-get (widget-at (gnus-overlay-start overlay))
4671 (widget-get widget/window :mime-handle)))
4673 (aref gnus-down-mouse-3 0))))))
4675 (defun gnus-widget-press-button (elems el)
4676 (goto-char (widget-get elems :from))
4677 (gnus-article-press-button))
4679 (defvar gnus-displaying-mime nil)
4681 (defun gnus-display-mime (&optional ihandles)
4682 "Display the MIME parts."
4684 (save-selected-window
4685 (let ((window (get-buffer-window gnus-article-buffer))
4688 (select-window window)
4689 ;; We have to do this since selecting the window
4690 ;; may change the point. So we set the window point.
4691 (set-window-point window point)))
4692 (let* ((handles (or ihandles
4693 (mm-dissect-buffer nil gnus-article-loose-mime)
4694 (and gnus-article-emulate-mime
4696 (inhibit-read-only t) handle name type b e display)
4697 (when (and (not ihandles)
4698 (not gnus-displaying-mime))
4699 ;; Top-level call; we clean up.
4700 (when gnus-article-mime-handles
4701 (mm-destroy-parts gnus-article-mime-handles)
4702 (setq gnus-article-mime-handle-alist nil));; A trick.
4703 (setq gnus-article-mime-handles handles)
4704 ;; We allow users to glean info from the handles.
4705 (when gnus-article-mime-part-function
4706 (gnus-mime-part-function handles)))
4708 (or (not (stringp (car handles)))
4711 (when (and (not ihandles)
4712 (not gnus-displaying-mime))
4713 ;; Clean up for mime parts.
4715 (delete-region (point) (point-max)))
4716 (let ((gnus-displaying-mime t))
4717 (gnus-mime-display-part handles)))
4720 (narrow-to-region (point) (point-max))
4721 (gnus-treat-article nil 1 1)
4724 ;; Highlight the headers.
4728 (narrow-to-region (point-min) (point))
4729 (gnus-article-save-original-date
4730 (gnus-treat-article 'head)))))))))
4732 (defcustom gnus-mime-display-multipart-as-mixed nil
4733 "Display \"multipart\" parts as \"multipart/mixed\".
4735 If t, it overrides nil values of
4736 `gnus-mime-display-multipart-alternative-as-mixed' and
4737 `gnus-mime-display-multipart-related-as-mixed'."
4738 :group 'gnus-article-mime
4741 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4742 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4744 :group 'gnus-article-mime
4747 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4748 "Display \"multipart/related\" parts as \"multipart/mixed\".
4750 If displaying \"text/html\" is discouraged \(see
4751 `mm-discouraged-alternatives'\) images or other material inside a
4752 \"multipart/related\" part might be overlooked when this variable is nil."
4754 :group 'gnus-article-mime
4757 (defun gnus-mime-display-part (handle)
4760 ((not (stringp (car handle)))
4761 (gnus-mime-display-single handle))
4762 ;; User-defined multipart
4763 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4764 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4766 ;; multipart/alternative
4767 ((and (equal (car handle) "multipart/alternative")
4768 (not (or gnus-mime-display-multipart-as-mixed
4769 gnus-mime-display-multipart-alternative-as-mixed)))
4770 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4771 (push (cons id handle) gnus-article-mime-handle-alist)
4772 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4773 ;; multipart/related
4774 ((and (equal (car handle) "multipart/related")
4775 (not (or gnus-mime-display-multipart-as-mixed
4776 gnus-mime-display-multipart-related-as-mixed)))
4777 ;;;!!!We should find the start part, but we just default
4778 ;;;!!!to the first part.
4779 ;;(gnus-mime-display-part (cadr handle))
4780 ;;;!!! Most multipart/related is an HTML message plus images.
4781 ;;;!!! Unfortunately we are unable to let W3 display those
4782 ;;;!!! included images, so we just display it as a mixed multipart.
4783 ;;(gnus-mime-display-mixed (cdr handle))
4784 ;;;!!! No, w3 can display everything just fine.
4785 (gnus-mime-display-part (cadr handle)))
4786 ((equal (car handle) "multipart/signed")
4787 (gnus-add-wash-type 'signed)
4788 (gnus-mime-display-security handle))
4789 ((equal (car handle) "multipart/encrypted")
4790 (gnus-add-wash-type 'encrypted)
4791 (gnus-mime-display-security handle))
4792 ;; Other multiparts are handled like multipart/mixed.
4794 (gnus-mime-display-mixed (cdr handle)))))
4796 (defun gnus-mime-part-function (handles)
4797 (if (stringp (car handles))
4798 (mapcar 'gnus-mime-part-function (cdr handles))
4799 (funcall gnus-article-mime-part-function handles)))
4801 (defun gnus-mime-display-mixed (handles)
4802 (mapcar 'gnus-mime-display-part handles))
4804 (defun gnus-mime-display-single (handle)
4805 (let ((type (mm-handle-media-type handle))
4806 (ignored gnus-ignored-mime-types)
4813 (when (string-match (pop ignored) type)
4814 (throw 'ignored nil)))
4815 (if (and (setq not-attachment
4816 (and (not (mm-inline-override-p handle))
4817 (or (not (mm-handle-disposition handle))
4818 (equal (car (mm-handle-disposition handle))
4820 (mm-attachment-override-p handle))))
4821 (mm-automatic-display-p handle)
4823 (mm-inlinable-p handle)
4824 (mm-inlined-p handle))
4825 (mm-automatic-external-display-p type)))
4827 (when (equal (mm-handle-media-supertype handle) "text")
4829 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4831 (push (cons id handle) gnus-article-mime-handle-alist)
4832 (when (or (not display)
4833 (not (gnus-unbuttonized-mime-type-p type)))
4834 ;(gnus-article-insert-newline)
4835 (gnus-insert-mime-button
4836 handle id (list (or display (and not-attachment text))))
4837 (gnus-article-insert-newline)
4838 ;(gnus-article-insert-newline)
4839 ;; Remember modify the number of forward lines.
4847 (let ((mail-parse-charset gnus-newsgroup-charset)
4848 (mail-parse-ignored-charsets
4849 (save-excursion (condition-case ()
4850 (set-buffer gnus-summary-buffer)
4852 gnus-newsgroup-ignored-charsets)))
4853 (mm-display-part handle t))
4854 (goto-char (point-max)))
4855 ((and text not-attachment)
4859 (gnus-article-insert-newline)
4860 (mm-insert-inline handle (mm-get-part handle))
4861 (goto-char (point-max))))
4865 (narrow-to-region beg (point))
4868 (gnus-article-mime-total-parts)
4869 (mm-handle-media-type handle)))))))))
4871 (defun gnus-unbuttonized-mime-type-p (type)
4872 "Say whether TYPE is to be unbuttonized."
4873 (unless gnus-inhibit-mime-unbuttonizing
4875 (let ((types gnus-unbuttonized-mime-types))
4877 (when (string-match (pop types) type)
4878 (throw 'found t)))))
4880 (let ((types gnus-buttonized-mime-types))
4882 (when (string-match (pop types) type)
4883 (throw 'found t)))))))))
4885 (defun gnus-article-insert-newline ()
4886 "Insert a newline, but mark it as undeletable."
4887 (gnus-put-text-property
4888 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4890 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4891 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4894 handle (inhibit-read-only t) from props begend not-pref)
4895 (save-window-excursion
4898 (narrow-to-region (car ibegend)
4901 (goto-char (car ibegend))
4904 (delete-region (point-min) (point-max))
4905 (mm-remove-parts handles))
4906 (setq begend (list (point-marker)))
4908 (unless (setq not-pref (cadr (member preferred ihandles)))
4909 (setq not-pref (car ihandles)))
4912 (not (gnus-unbuttonized-mime-type-p
4913 "multipart/alternative")))
4914 (gnus-add-text-properties
4917 (insert (format "%d. " id))
4921 (unless ,(not ibegend)
4922 (setq gnus-article-mime-handle-alist
4923 ',gnus-article-mime-handle-alist))
4924 (gnus-mime-display-alternative
4925 ',ihandles ',not-pref ',begend ,id))
4926 ,@(gnus-local-map-property gnus-mime-button-map)
4927 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4928 face ,gnus-article-button-face
4931 (widget-convert-button 'link from (point)
4932 :action 'gnus-widget-press-button
4933 :button-keymap gnus-widget-button-keymap)
4935 (while (setq handle (pop handles))
4936 (gnus-add-text-properties
4939 (insert (format "(%c) %-18s"
4940 (if (equal handle preferred) ?* ? )
4941 (mm-handle-media-type handle)))
4945 (unless ,(not ibegend)
4946 (setq gnus-article-mime-handle-alist
4947 ',gnus-article-mime-handle-alist))
4948 (gnus-mime-display-alternative
4949 ',ihandles ',handle ',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)
4961 (if (stringp (car preferred))
4962 (gnus-display-mime preferred)
4963 (let ((mail-parse-charset gnus-newsgroup-charset)
4964 (mail-parse-ignored-charsets
4965 (save-excursion (set-buffer gnus-summary-buffer)
4966 gnus-newsgroup-ignored-charsets)))
4967 (mm-display-part preferred)
4971 (narrow-to-region (car begend) (point-max))
4973 nil (length gnus-article-mime-handle-alist)
4974 (gnus-article-mime-total-parts)
4975 (mm-handle-media-type handle))))))
4976 (goto-char (point-max))
4977 (setcdr begend (point-marker)))))
4979 (goto-char point))))
4981 (defconst gnus-article-wash-status-strings
4982 (let ((alist '((cite "c" "Possible hidden citation text"
4983 " " "All citation text visible")
4984 (headers "h" "Hidden headers"
4985 " " "All headers visible.")
4986 (pgp "p" "Encrypted or signed message status hidden"
4987 " " "No hidden encryption nor digital signature status")
4988 (signature "s" "Signature has been hidden"
4989 " " "Signature is visible")
4990 (overstrike "o" "Overstrike (^H) characters applied"
4991 " " "No overstrike characters applied")
4992 (emphasis "e" "/*_Emphasis_*/ characters applied"
4993 " " "No /*_emphasis_*/ characters applied")))
4995 (dolist (entry alist result)
4996 (let ((key (nth 0 entry))
4997 (on (copy-sequence (nth 1 entry)))
4998 (on-help (nth 2 entry))
4999 (off (copy-sequence (nth 3 entry)))
5000 (off-help (nth 4 entry)))
5001 (put-text-property 0 1 'help-echo on-help on)
5002 (put-text-property 0 1 'help-echo off-help off)
5003 (push (list key on off) result))))
5004 "Alist of strings describing wash status in the mode line.
5005 Each entry has the form (KEY ON OF), where the KEY is a symbol
5006 representing the particular washing function, ON is the string to use
5007 in the article mode line when the washing function is active, and OFF
5008 is the string to use when it is inactive.")
5010 (defun gnus-article-wash-status-entry (key value)
5011 (let ((entry (assoc key gnus-article-wash-status-strings)))
5012 (if value (nth 1 entry) (nth 2 entry))))
5014 (defun gnus-article-wash-status ()
5015 "Return a string which display status of article washing."
5017 (set-buffer gnus-article-buffer)
5018 (let ((cite (memq 'cite gnus-article-wash-types))
5019 (headers (memq 'headers gnus-article-wash-types))
5020 (boring (memq 'boring-headers gnus-article-wash-types))
5021 (pgp (memq 'pgp gnus-article-wash-types))
5022 (pem (memq 'pem gnus-article-wash-types))
5023 (signed (memq 'signed gnus-article-wash-types))
5024 (encrypted (memq 'encrypted gnus-article-wash-types))
5025 (signature (memq 'signature gnus-article-wash-types))
5026 (overstrike (memq 'overstrike gnus-article-wash-types))
5027 (emphasis (memq 'emphasis gnus-article-wash-types)))
5029 (gnus-article-wash-status-entry 'cite cite)
5030 (gnus-article-wash-status-entry 'headers (or headers boring))
5031 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5032 (gnus-article-wash-status-entry 'signature signature)
5033 (gnus-article-wash-status-entry 'overstrike overstrike)
5034 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5036 (defun gnus-add-wash-type (type)
5037 "Add a washing of TYPE to the current status."
5038 (add-to-list 'gnus-article-wash-types type))
5040 (defun gnus-delete-wash-type (type)
5041 "Add a washing of TYPE to the current status."
5042 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5044 (defun gnus-add-image (category image)
5045 "Add IMAGE of CATEGORY to the list of displayed images."
5046 (let ((entry (assq category gnus-article-image-alist)))
5048 (setq entry (list category))
5049 (push entry gnus-article-image-alist))
5050 (nconc entry (list image))))
5052 (defun gnus-delete-images (category)
5053 "Delete all images in CATEGORY."
5054 (let ((entry (assq category gnus-article-image-alist)))
5055 (dolist (image (cdr entry))
5056 (gnus-remove-image image category))
5057 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5058 (gnus-delete-wash-type category)))
5060 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5062 (defun gnus-article-maybe-hide-headers ()
5063 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5064 Provided for backwards compatibility."
5065 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5066 (not (save-excursion (set-buffer gnus-summary-buffer)
5067 gnus-have-all-headers)))
5068 (not gnus-inhibit-hiding))
5069 (gnus-article-hide-headers)))
5073 (defun gnus-output-to-file (file-name)
5074 "Append the current article to a file named FILE-NAME."
5075 (let ((artbuf (current-buffer)))
5077 (insert-buffer-substring artbuf)
5078 ;; Append newline at end of the buffer as separator, and then
5080 (goto-char (point-max))
5082 (let ((file-name-coding-system nnmail-pathname-coding-system))
5083 (mm-append-to-file (point-min) (point-max) file-name))
5086 (defun gnus-narrow-to-page (&optional arg)
5087 "Narrow the article buffer to a page.
5088 If given a numerical ARG, move forward ARG pages."
5090 (setq arg (if arg (prefix-numeric-value arg) 0))
5092 (set-buffer gnus-article-buffer)
5093 (goto-char (point-min))
5095 ;; Remove any old next/prev buttons.
5096 (when (gnus-visual-p 'page-marker)
5097 (let ((inhibit-read-only t))
5098 (gnus-remove-text-with-property 'gnus-prev)
5099 (gnus-remove-text-with-property 'gnus-next)))
5102 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5104 (re-search-forward page-delimiter nil 'move arg)))
5105 (goto-char (match-end 0))
5107 (goto-char (point-min))
5108 (setq gnus-page-broken
5109 (and (re-search-forward page-delimiter nil t) t))))
5110 (when gnus-page-broken
5113 (if (re-search-forward page-delimiter nil 'move)
5116 (when (and (gnus-visual-p 'page-marker)
5117 (> (point-min) (save-restriction (widen) (point-min))))
5119 (goto-char (point-min))
5120 (gnus-insert-prev-page-button)))
5121 (when (and (gnus-visual-p 'page-marker)
5122 (< (point-max) (save-restriction (widen) (point-max))))
5124 (goto-char (point-max))
5125 (gnus-insert-next-page-button))))))
5127 ;; Article mode commands
5129 (defun gnus-article-goto-next-page ()
5130 "Show the next page of the article."
5132 (when (gnus-article-next-page)
5133 (goto-char (point-min))
5134 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5137 (defun gnus-article-goto-prev-page ()
5138 "Show the previous page of the article."
5141 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5142 (gnus-article-prev-page nil)))
5144 ;; This is cleaner but currently breaks `gnus-pick-mode':
5146 ;; (defun gnus-article-goto-next-page ()
5147 ;; "Show the next page of the article."
5149 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5150 ;; (gnus-summary-next-page)))
5152 ;; (defun gnus-article-goto-prev-page ()
5153 ;; "Show the next page of the article."
5155 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5156 ;; (gnus-summary-prev-page)))
5158 (defun gnus-article-next-page (&optional lines)
5159 "Show the next page of the current article.
5160 If end of article, return non-nil. Otherwise return nil.
5161 Argument LINES specifies lines to be scrolled up."
5163 (move-to-window-line (max (- -1 scroll-margin) (- -1 (window-body-height))))
5166 (and (pos-visible-in-window-p) ;Not continuation line.
5167 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5168 ;; Nothing in this page.
5169 (if (or (not gnus-page-broken)
5174 (eobp)))) ;Real end-of-buffer?
5176 (when gnus-article-over-scroll
5177 (gnus-article-next-page-1 lines))
5179 (gnus-narrow-to-page 1) ;Go to next page.
5181 ;; More in this page.
5182 (gnus-article-next-page-1 lines)
5185 (defun gnus-article-next-page-1 (lines)
5186 (let ((scroll-in-place nil))
5190 ;; Long lines may cause an end-of-buffer error.
5191 (goto-char (point-max)))))
5192 (move-to-window-line (min scroll-margin (window-body-height))))
5194 (defun gnus-article-prev-page (&optional lines)
5195 "Show previous page of current article.
5196 Argument LINES specifies lines to be scrolled down."
5198 (move-to-window-line (min scroll-margin (window-body-height)))
5199 (if (and gnus-page-broken
5201 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5203 (gnus-narrow-to-page -1) ;Go to previous page.
5204 (goto-char (point-max))
5206 (let ((scroll-in-place nil))
5210 (beginning-of-buffer
5211 (goto-char (point-min))))
5212 (move-to-window-line (min scroll-margin (window-body-height)))))))
5214 (defun gnus-article-only-boring-p ()
5215 "Decide whether there is only boring text remaining in the article.
5216 Something \"interesting\" is a word of at least two letters that does
5217 not have a face in `gnus-article-boring-faces'."
5218 (when (and gnus-article-skip-boring
5219 (boundp 'gnus-article-boring-faces)
5220 (symbol-value 'gnus-article-boring-faces))
5223 (while (re-search-forward "\\b\\w\\w" nil t)
5225 (when (not (gnus-intersection
5226 (gnus-faces-at (point))
5227 (symbol-value 'gnus-article-boring-faces)))
5228 (throw 'only-boring nil)))
5229 (throw 'only-boring t)))))
5231 (defun gnus-article-refer-article ()
5232 "Read article specified by message-id around point."
5235 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5236 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5237 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5238 (let ((msg-id (concat "<" (match-string 0) ">")))
5239 (set-buffer gnus-summary-buffer)
5240 (gnus-summary-refer-article msg-id))
5241 (error "No references around point"))))
5243 (defun gnus-article-show-summary ()
5244 "Reconfigure windows to show summary buffer."
5246 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5247 (error "There is no summary buffer for this article buffer")
5248 (gnus-article-set-globals)
5249 (gnus-configure-windows 'article)
5250 (gnus-summary-goto-subject gnus-current-article)
5251 (gnus-summary-position-point)))
5253 (defun gnus-article-describe-briefly ()
5254 "Describe article mode commands briefly."
5256 (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")))
5258 (defun gnus-article-summary-command ()
5259 "Execute the last keystroke in the summary buffer."
5261 (let ((obuf (current-buffer))
5262 (owin (current-window-configuration))
5264 (switch-to-buffer gnus-article-current-summary 'norecord)
5265 (setq func (lookup-key (current-local-map) (this-command-keys)))
5266 (call-interactively func)
5268 (set-window-configuration owin)
5269 (set-window-point (get-buffer-window (current-buffer)) (point))))
5271 (defun gnus-article-summary-command-nosave ()
5272 "Execute the last keystroke in the summary buffer."
5275 (pop-to-buffer gnus-article-current-summary 'norecord)
5276 (setq func (lookup-key (current-local-map) (this-command-keys)))
5277 (call-interactively func)))
5279 (defun gnus-article-check-buffer ()
5280 "Beep if not in an article buffer."
5281 (unless (equal major-mode 'gnus-article-mode)
5282 (error "Command invoked outside of a Gnus article buffer")))
5284 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5285 "Read a summary buffer key sequence and execute it from the article buffer."
5287 (gnus-article-check-buffer)
5289 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5290 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5291 "=" "^" "\M-^" "|"))
5297 '("n" "Gn" "p" "Gp"))
5300 (set-buffer gnus-article-current-summary)
5301 (let (gnus-pick-mode)
5302 (push (or key last-command-event) unread-command-events)
5303 (setq keys (if (featurep 'xemacs)
5304 (events-to-keys (read-key-sequence nil))
5305 (read-key-sequence nil)))))
5309 (if (or (member keys nosaves)
5310 (member keys nosave-but-article)
5311 (member keys nosave-in-article))
5313 (save-window-excursion
5314 (pop-to-buffer gnus-article-current-summary 'norecord)
5315 ;; We disable the pick minor mode commands.
5316 (let (gnus-pick-mode)
5317 (setq func (lookup-key (current-local-map) keys))))
5321 (unless (member keys nosave-in-article)
5322 (set-buffer gnus-article-current-summary))
5323 (call-interactively func)
5324 (setq new-sum-point (point)))
5325 (when (member keys nosave-but-article)
5326 (pop-to-buffer gnus-article-buffer 'norecord)))
5327 ;; These commands should restore window configuration.
5328 (let ((obuf (current-buffer))
5329 (owin (current-window-configuration))
5331 win func in-buffer selected new-sum-start new-sum-hscroll)
5332 (cond (not-restore-window
5333 (pop-to-buffer gnus-article-current-summary 'norecord))
5334 ((setq win (get-buffer-window gnus-article-current-summary))
5335 (select-window win))
5337 (switch-to-buffer gnus-article-current-summary 'norecord)))
5338 (setq in-buffer (current-buffer))
5339 ;; We disable the pick minor mode commands.
5340 (if (and (setq func (let (gnus-pick-mode)
5341 (lookup-key (current-local-map) keys)))
5344 (call-interactively func)
5345 (when (eq win (selected-window))
5346 (setq new-sum-point (point)
5347 new-sum-start (window-start win)
5348 new-sum-hscroll (window-hscroll win)))
5349 (when (eq in-buffer (current-buffer))
5350 (setq selected (gnus-summary-select-article))
5352 (unless not-restore-window
5353 (set-window-configuration owin))
5354 (when (eq selected 'old)
5356 (set-window-start (get-buffer-window (current-buffer))
5358 (set-window-point (get-buffer-window (current-buffer))
5360 (when (and (not not-restore-window)
5362 (set-window-point win new-sum-point)
5363 (set-window-start win new-sum-start)
5364 (set-window-hscroll win new-sum-hscroll))))
5365 (set-window-configuration owin)
5368 (defun gnus-article-describe-key (key)
5369 "Display documentation of the function invoked by KEY. KEY is a string."
5370 (interactive "kDescribe key: ")
5371 (gnus-article-check-buffer)
5372 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5374 (set-buffer gnus-article-current-summary)
5375 (let (gnus-pick-mode)
5376 (if (featurep 'xemacs)
5378 (push (elt key 0) unread-command-events)
5379 (setq key (events-to-keys
5380 (read-key-sequence "Describe key: "))))
5381 (setq unread-command-events
5383 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5384 (string-to-list key)))
5385 (setq key (read-key-sequence "Describe key: "))))
5387 (describe-key key)))
5389 (defun gnus-article-describe-key-briefly (key &optional insert)
5390 "Display documentation of the function invoked by KEY. KEY is a string."
5391 (interactive "kDescribe key: \nP")
5392 (gnus-article-check-buffer)
5393 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5395 (set-buffer gnus-article-current-summary)
5396 (let (gnus-pick-mode)
5397 (if (featurep 'xemacs)
5399 (push (elt key 0) unread-command-events)
5400 (setq key (events-to-keys
5401 (read-key-sequence "Describe key: "))))
5402 (setq unread-command-events
5404 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5405 (string-to-list key)))
5406 (setq key (read-key-sequence "Describe key: "))))
5407 (describe-key-briefly key insert))
5408 (describe-key-briefly key insert)))
5410 (defun gnus-article-reply-with-original (&optional wide)
5411 "Start composing a reply mail to the current message.
5412 The text in the region will be yanked. If the region isn't active,
5413 the entire article will be yanked."
5415 (let ((article (cdr gnus-article-current))
5417 (if (not (gnus-mark-active-p))
5418 (with-current-buffer gnus-summary-buffer
5419 (gnus-summary-reply (list (list article)) wide))
5420 (setq contents (buffer-substring (point) (mark t)))
5421 ;; Deactivate active regions.
5422 (when (and (boundp 'transient-mark-mode)
5423 transient-mark-mode)
5424 (setq mark-active nil))
5425 (with-current-buffer gnus-summary-buffer
5427 (list (list article contents)) wide)))))
5429 (defun gnus-article-followup-with-original ()
5430 "Compose a followup to the current article.
5431 The text in the region will be yanked. If the region isn't active,
5432 the entire article will be yanked."
5434 (let ((article (cdr gnus-article-current))
5436 (if (not (gnus-mark-active-p))
5437 (with-current-buffer gnus-summary-buffer
5438 (gnus-summary-followup (list (list article))))
5439 (setq contents (buffer-substring (point) (mark t)))
5440 ;; Deactivate active regions.
5441 (when (and (boundp 'transient-mark-mode)
5442 transient-mark-mode)
5443 (setq mark-active nil))
5444 (with-current-buffer gnus-summary-buffer
5445 (gnus-summary-followup
5446 (list (list article contents)))))))
5448 (defun gnus-article-hide (&optional arg force)
5449 "Hide all the gruft in the current article.
5450 This means that signatures, cited text and (some) headers will be
5452 If given a prefix, show the hidden text instead."
5453 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5454 (gnus-article-hide-headers arg)
5455 (gnus-article-hide-list-identifiers arg)
5456 (gnus-article-hide-citation-maybe arg force)
5457 (gnus-article-hide-signature arg))
5459 (defun gnus-article-maybe-highlight ()
5460 "Do some article highlighting if article highlighting is requested."
5461 (when (gnus-visual-p 'article-highlight 'highlight)
5462 (gnus-article-highlight-some)))
5464 (defun gnus-check-group-server ()
5465 ;; Make sure the connection to the server is alive.
5466 (unless (gnus-server-opened
5467 (gnus-find-method-for-group gnus-newsgroup-name))
5468 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5469 (gnus-request-group gnus-newsgroup-name t)))
5472 (autoload 'nneething-get-file-name "nneething"))
5474 (defun gnus-request-article-this-buffer (article group)
5475 "Get an article and insert it into this buffer."
5476 (let (do-update-line sparse-header)
5480 (gnus-kill-all-overlays)
5481 (setq group (or group gnus-newsgroup-name))
5483 ;; Using `gnus-request-article' directly will insert the article into
5484 ;; `nntp-server-buffer' - so we'll save some time by not having to
5485 ;; copy it from the server buffer into the article buffer.
5487 ;; We only request an article by message-id when we do not have the
5488 ;; headers for it, so we'll have to get those.
5489 (when (stringp article)
5490 (gnus-read-header article))
5492 ;; If the article number is negative, that means that this article
5493 ;; doesn't belong in this newsgroup (possibly), so we find its
5494 ;; message-id and request it by id instead of number.
5495 (when (and (numberp article)
5497 (get-buffer gnus-summary-buffer)
5498 (gnus-buffer-exists-p gnus-summary-buffer))
5500 (set-buffer gnus-summary-buffer)
5501 (let ((header (gnus-summary-article-header article)))
5504 ((memq article gnus-newsgroup-sparse)
5505 ;; This is a sparse gap article.
5506 (setq do-update-line article)
5507 (setq article (mail-header-id header))
5508 (setq sparse-header (gnus-read-header article))
5509 (setq gnus-newsgroup-sparse
5510 (delq article gnus-newsgroup-sparse)))
5512 ;; It's a real article.
5513 (setq article (mail-header-id header)))
5515 ;; It is an extracted pseudo-article.
5516 (setq article 'pseudo)
5517 (gnus-request-pseudo-article header))))
5519 (let ((method (gnus-find-method-for-group
5520 gnus-newsgroup-name)))
5521 (when (and (eq (car method) 'nneething)
5523 (let ((dir (nneething-get-file-name
5524 (mail-header-id header))))
5525 (when (and (stringp dir)
5526 (file-directory-p dir))
5527 (setq article 'nneething)
5528 (gnus-group-enter-directory dir))))))))
5531 ;; Refuse to select canceled articles.
5532 ((and (numberp article)
5534 (get-buffer gnus-summary-buffer)
5535 (gnus-buffer-exists-p gnus-summary-buffer)
5536 (eq (cdr (save-excursion
5537 (set-buffer gnus-summary-buffer)
5538 (assq article gnus-newsgroup-reads)))
5539 gnus-canceled-mark))
5541 ;; We first check `gnus-original-article-buffer'.
5542 ((and (get-buffer gnus-original-article-buffer)
5545 (set-buffer gnus-original-article-buffer)
5546 (and (equal (car gnus-original-article) group)
5547 (eq (cdr gnus-original-article) article))))
5548 (insert-buffer-substring gnus-original-article-buffer)
5550 ;; Check the backlog.
5551 ((and gnus-keep-backlog
5552 (gnus-backlog-request-article group article (current-buffer)))
5554 ;; Check asynchronous pre-fetch.
5555 ((gnus-async-request-fetched-article group article (current-buffer))
5556 (gnus-async-prefetch-next group article gnus-summary-buffer)
5557 (when (and (numberp article) gnus-keep-backlog)
5558 (gnus-backlog-enter-article group article (current-buffer)))
5561 ((and gnus-use-cache
5563 (gnus-cache-request-article article group))
5565 ;; Check the agent cache.
5566 ((gnus-agent-request-article article group)
5568 ;; Get the article and put into the article buffer.
5569 ((or (stringp article)
5571 (let ((gnus-override-method gnus-override-method)
5572 (methods (and (stringp article)
5573 gnus-refer-article-method))
5574 (backend (car (gnus-find-method-for-group
5575 gnus-newsgroup-name)))
5577 (inhibit-read-only t))
5578 (if (or (not (listp methods))
5579 (and (symbolp (car methods))
5580 (assq (car methods) nnoo-definition-alist)))
5581 (setq methods (list methods)))
5582 (when (and (null gnus-override-method)
5584 (setq gnus-override-method (pop methods)))
5586 (when (eq gnus-override-method 'current)
5587 (setq gnus-override-method
5588 (with-current-buffer gnus-summary-buffer
5589 gnus-current-select-method)))
5591 (gnus-kill-all-overlays)
5592 (let ((gnus-newsgroup-name group))
5593 (gnus-check-group-server))
5595 ((gnus-request-article article group (current-buffer))
5596 (when (numberp article)
5597 (gnus-async-prefetch-next group article
5598 gnus-summary-buffer)
5599 (when gnus-keep-backlog
5600 (gnus-backlog-enter-article
5601 group article (current-buffer))))
5602 (setq result 'article))
5604 (setq gnus-override-method (pop methods)))
5605 ((not (string-match "^400 "
5606 (nnheader-get-report backend)))
5607 ;; If we get 400 server disconnect, reconnect and
5608 ;; retry; otherwise, assume the article has expired.
5609 (setq result 'done))))
5610 (and (eq result 'article) 'article)))
5614 ;; Associate this article with the current summary buffer.
5615 (setq gnus-article-current-summary gnus-summary-buffer)
5617 ;; Take the article from the original article buffer
5618 ;; and place it in the buffer it's supposed to be in.
5619 (when (and (get-buffer gnus-article-buffer)
5620 (equal (buffer-name (current-buffer))
5621 (buffer-name (get-buffer gnus-article-buffer))))
5623 (if (get-buffer gnus-original-article-buffer)
5624 (set-buffer gnus-original-article-buffer)
5625 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5626 (buffer-disable-undo)
5627 (setq major-mode 'gnus-original-article-mode)
5628 (setq buffer-read-only t))
5629 (let ((inhibit-read-only t))
5631 (insert-buffer-substring gnus-article-buffer))
5632 (setq gnus-original-article (cons group article)))
5635 (run-hooks 'gnus-article-decode-hook)
5636 ;; Mark article as decoded or not.
5637 (setq gnus-article-decoded-p gnus-article-decode-hook))
5639 ;; Update sparse articles.
5640 (when (and do-update-line
5641 (or (numberp article)
5643 (let ((buf (current-buffer)))
5644 (set-buffer gnus-summary-buffer)
5645 (gnus-summary-update-article do-update-line sparse-header)
5646 (gnus-summary-goto-subject do-update-line nil t)
5647 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5649 (set-buffer buf))))))
5655 (defcustom gnus-article-edit-mode-hook nil
5656 "Hook run in article edit mode buffers."
5657 :group 'gnus-article-various
5660 (defvar gnus-article-edit-done-function nil)
5662 (defvar gnus-article-edit-mode-map nil)
5663 (defvar gnus-article-edit-mode nil)
5665 ;; Should we be using derived.el for this?
5666 (unless gnus-article-edit-mode-map
5667 (setq gnus-article-edit-mode-map (make-keymap))
5668 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5670 (gnus-define-keys gnus-article-edit-mode-map
5671 "\C-c?" describe-mode
5672 "\C-c\C-c" gnus-article-edit-done
5673 "\C-c\C-k" gnus-article-edit-exit
5674 "\C-c\C-f\C-t" message-goto-to
5675 "\C-c\C-f\C-o" message-goto-from
5676 "\C-c\C-f\C-b" message-goto-bcc
5677 ;;"\C-c\C-f\C-w" message-goto-fcc
5678 "\C-c\C-f\C-c" message-goto-cc
5679 "\C-c\C-f\C-s" message-goto-subject
5680 "\C-c\C-f\C-r" message-goto-reply-to
5681 "\C-c\C-f\C-n" message-goto-newsgroups
5682 "\C-c\C-f\C-d" message-goto-distribution
5683 "\C-c\C-f\C-f" message-goto-followup-to
5684 "\C-c\C-f\C-m" message-goto-mail-followup-to
5685 "\C-c\C-f\C-k" message-goto-keywords
5686 "\C-c\C-f\C-u" message-goto-summary
5687 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5688 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5689 "\C-c\C-b" message-goto-body
5690 "\C-c\C-i" message-goto-signature
5692 "\C-c\C-t" message-insert-to
5693 "\C-c\C-n" message-insert-newsgroups
5694 "\C-c\C-o" message-sort-headers
5695 "\C-c\C-e" message-elide-region
5696 "\C-c\C-v" message-delete-not-region
5697 "\C-c\C-z" message-kill-to-signature
5698 "\M-\r" message-newline-and-reformat
5699 "\C-c\C-a" mml-attach-file
5700 "\C-a" message-beginning-of-line
5702 "\M-;" comment-region)
5704 (gnus-define-keys (gnus-article-edit-wash-map
5705 "\C-c\C-w" gnus-article-edit-mode-map)
5706 "f" gnus-article-edit-full-stops))
5709 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5711 ["Fetch To" message-insert-to t]
5712 ["Fetch Newsgroups" message-insert-newsgroups t]
5714 ["To" message-goto-to t]
5715 ["From" message-goto-from t]
5716 ["Subject" message-goto-subject t]
5717 ["Cc" message-goto-cc t]
5718 ["Reply-To" message-goto-reply-to t]
5719 ["Summary" message-goto-summary t]
5720 ["Keywords" message-goto-keywords t]
5721 ["Newsgroups" message-goto-newsgroups t]
5722 ["Followup-To" message-goto-followup-to t]
5723 ["Mail-Followup-To" message-goto-mail-followup-to t]
5724 ["Distribution" message-goto-distribution t]
5725 ["Body" message-goto-body t]
5726 ["Signature" message-goto-signature t]))
5728 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5729 "Major mode for editing articles.
5730 This is an extended text-mode.
5732 \\{gnus-article-edit-mode-map}"
5733 (make-local-variable 'gnus-article-edit-done-function)
5734 (make-local-variable 'gnus-prev-winconf)
5735 (set (make-local-variable 'font-lock-defaults)
5736 '(message-font-lock-keywords t))
5737 (set (make-local-variable 'mail-header-separator) "")
5738 (set (make-local-variable 'gnus-article-edit-mode) t)
5739 (easy-menu-add message-mode-field-menu message-mode-map)
5741 (setq buffer-read-only nil)
5742 (buffer-enable-undo)
5745 (defun gnus-article-edit (&optional force)
5746 "Edit the current article.
5747 This will have permanent effect only in mail groups.
5748 If FORCE is non-nil, allow editing of articles even in read-only
5751 (when (and (not force)
5752 (gnus-group-read-only-p))
5753 (error "The current newsgroup does not support article editing"))
5754 (gnus-article-date-original)
5755 (gnus-article-edit-article
5757 `(lambda (no-highlight)
5759 (gnus-summary-edit-article-done
5760 ,(or (mail-header-references gnus-current-headers) "")
5761 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5763 (defun gnus-article-edit-article (start-func exit-func)
5764 "Start editing the contents of the current article buffer."
5765 (let ((winconf (current-window-configuration)))
5766 (set-buffer gnus-article-buffer)
5767 (let ((message-auto-save-directory
5768 ;; Don't associate the article buffer with a draft file.
5770 (gnus-article-edit-mode))
5771 (funcall start-func)
5772 (set-buffer-modified-p nil)
5773 (gnus-configure-windows 'edit-article)
5774 (setq gnus-article-edit-done-function exit-func)
5775 (setq gnus-prev-winconf winconf)
5776 (gnus-message 6 "C-c C-c to end edits")))
5778 (defun gnus-article-edit-done (&optional arg)
5779 "Update the article edits and exit."
5781 (let ((func gnus-article-edit-done-function)
5782 (buf (current-buffer))
5783 (start (window-start))
5785 (winconf gnus-prev-winconf))
5786 (widen) ;; Widen it in case that users narrowed the buffer.
5789 ;; The cache and backlog have to be flushed somewhat.
5790 (when gnus-keep-backlog
5791 (gnus-backlog-remove-article
5792 (car gnus-article-current) (cdr gnus-article-current)))
5793 ;; Flush original article as well.
5795 (when (get-buffer gnus-original-article-buffer)
5796 (set-buffer gnus-original-article-buffer)
5797 (setq gnus-original-article nil)))
5798 (when gnus-use-cache
5799 (gnus-cache-update-article
5800 (car gnus-article-current) (cdr gnus-article-current)))
5801 ;; We remove all text props from the article buffer.
5802 (kill-all-local-variables)
5803 (gnus-set-text-properties (point-min) (point-max) nil)
5805 (set-window-configuration winconf)
5807 (set-window-start (get-buffer-window buf) start)
5808 (set-window-point (get-buffer-window buf) (point)))
5809 (gnus-summary-show-article))
5811 (defun gnus-article-edit-exit ()
5812 "Exit the article editing without updating."
5814 (when (or (not (buffer-modified-p))
5815 (yes-or-no-p "Article modified; kill anyway? "))
5816 (let ((curbuf (current-buffer))
5818 (window-start (window-start)))
5820 (if (gnus-buffer-live-p gnus-original-article-buffer)
5821 (insert-buffer gnus-original-article-buffer))
5822 (let ((winconf gnus-prev-winconf))
5823 (kill-all-local-variables)
5825 (set-window-configuration winconf)
5826 ;; Tippy-toe some to make sure that point remains where it was.
5827 (save-current-buffer
5829 (set-window-start (get-buffer-window (current-buffer)) window-start)
5831 (gnus-summary-show-article)))
5833 (defun gnus-article-edit-full-stops ()
5834 "Interactively repair spacing at end of sentences."
5837 (goto-char (point-min))
5838 (search-forward-regexp "^$" nil t)
5839 (let ((case-fold-search nil))
5840 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5843 ;;; Article highlights
5846 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5848 ;;; Internal Variables:
5850 (defcustom gnus-button-url-regexp
5851 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5852 "\\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:]]\\)"
5853 "\\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\\)\\)")
5854 "Regular expression that matches URLs."
5855 :group 'gnus-article-buttons
5858 (defcustom gnus-button-valid-fqdn-regexp
5859 message-valid-fqdn-regexp
5860 "Regular expression that matches a valid FQDN."
5862 :group 'gnus-article-buttons
5865 (defcustom gnus-button-man-handler 'manual-entry
5866 "Function to use for displaying man pages.
5867 The function must take at least one argument with a string naming the
5870 :type '(choice (function-item :tag "Man" manual-entry)
5871 (function-item :tag "Woman" woman)
5872 (function :tag "Other"))
5873 :group 'gnus-article-buttons)
5875 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5876 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5877 If the default site is too slow, try to find a CTAN mirror, see
5878 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5879 the variable `gnus-button-handle-ctan'."
5881 :group 'gnus-article-buttons
5882 :link '(custom-manual "(gnus)Group Parameters")
5883 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5884 (const "http://tug.ctan.org/tex-archive/")
5885 (const "http://www.dante.de/CTAN/")
5886 (string :tag "Other")))
5888 (defcustom gnus-button-ctan-handler 'browse-url
5889 "Function to use for displaying CTAN links.
5890 The function must take one argument, the string naming the URL."
5892 :type '(choice (function-item :tag "Browse Url" browse-url)
5893 (function :tag "Other"))
5894 :group 'gnus-article-buttons)
5896 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5897 "Bogus strings removed from CTAN URLs."
5899 :group 'gnus-article-buttons
5900 :type '(choice (const "^/?tex-archive/\\|/")
5901 (regexp :tag "Other")))
5903 (defcustom gnus-button-ctan-directory-regexp
5905 "\\("; Cannot use `\(?: ... \)' (compatibility with Emacs 20).
5906 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5907 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5908 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5910 "Regular expression for ctan directories.
5911 It should match all directories in the top level of `gnus-ctan-url'."
5913 :group 'gnus-article-buttons
5916 (defcustom gnus-button-mid-or-mail-regexp
5917 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
5918 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5919 gnus-button-valid-fqdn-regexp
5921 "Regular expression that matches a message ID or a mail address."
5923 :group 'gnus-article-buttons
5926 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5927 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5928 Strings like this can be either a message ID or a mail address. If it is one
5929 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5930 message ID or a mail address, respectively. If this variable is set to the
5931 symbol `ask', always query the user what do do. If it is a function, this
5932 function will be called with the string as it's only argument. The function
5933 must return `mid', `mail', `invalid' or `ask'."
5935 :group 'gnus-article-buttons
5936 :type '(choice (function-item :tag "Heuristic function"
5937 gnus-button-mid-or-mail-heuristic)
5942 (defcustom gnus-button-mid-or-mail-heuristic-alist
5943 '((-10.0 . ".+\\$.+@")
5946 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5947 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5948 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5949 (-1.0 . "^[^a-z]+@")
5951 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5952 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5953 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5954 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5957 (-1.0 . "^[0-9][0-9]")
5959 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5960 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5961 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5962 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5964 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5965 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5968 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5970 ;; compensation for TDMA dated mail addresses:
5971 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5973 (-20.0 . "\\.fsf@") ;; Gnus
5976 (-20.0 . "_-_") ;; Subject change in thread
5978 (-20.0 . "\\.ln@") ;; leafnode
5979 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5980 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5982 ;; (5.0 . "") ;; $local_part_len <= 7
5983 (10.0 . "^[^0-9]+@")
5984 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5985 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5988 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5990 (0.5 . "^[A-Z][a-z]")
5991 (0.5 . "^[A-Z][a-z][a-z]")
5992 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5993 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5994 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5996 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5997 address. The REGEXP is processed with `case-fold-search' set to nil."
5999 :group 'gnus-article-buttons
6000 :type '(repeat (cons (number :tag "Rate")
6001 (regexp :tag "Regexp"))))
6003 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6004 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6005 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6006 address, `ask' if unsure and `invalid' if the string is invalid."
6007 (let ((case-fold-search nil)
6008 (list gnus-button-mid-or-mail-heuristic-alist)
6009 (result 0) rate regexp lpartlen elem)
6011 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6012 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6013 ;; Certain special cases...
6016 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6017 "^[0-9]+\\.[0-9]+@compuserve\\|"
6018 "@public\\.gmane\\.org")
6020 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6021 (setq result 'mail))
6022 (when (string-match "@.*@\\| " mid-or-mail)
6023 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6024 (setq result 'invalid))
6025 ;; Nothing more to do, if result is not a number here...
6026 (when (numberp result)
6028 (setq elem (car list)
6032 (when (string-match regexp mid-or-mail)
6033 (setq result (+ result rate))
6035 9 "`%s' matched `%s', rate `%s', result `%s'."
6036 mid-or-mail regexp rate result)))
6037 (when (<= lpartlen 7)
6038 (setq result (+ result 5.0))
6039 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6040 mid-or-mail result))
6041 (when (>= lpartlen 12)
6042 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6044 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6045 ;; Long local part should contain realname if e-mail address,
6046 ;; too many digits: message-id.
6047 ;; $score -= 5.0 + 0.1 * $local_part_len;
6048 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6049 (setq result (+ result rate))
6051 9 "Many digits in `%s', rate `%s', result `%s'."
6052 mid-or-mail rate result))
6053 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6055 ;; Too few vowels [^aeiouy]{4,}.*\@
6056 (setq result (+ result -5.0))
6058 9 "Few vowels in `%s', rate `%s', result `%s'."
6059 mid-or-mail -5.0 result))
6061 (setq result (+ result 5.0))
6063 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6064 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6065 ;; Maybe we should make this a customizable alist: (condition . 'result)
6067 ((symbolp result) result)
6068 ;; Now convert number into proper results:
6069 ((< result -10.0) 'mid)
6070 ((> result 10.0) 'mail)
6073 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6074 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6075 (url-mid (concat "news" ":" mid-or-mail))
6076 (url-mailto (concat "mailto" ":" mid-or-mail)))
6077 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6078 (when (fboundp pref)
6080 ;; get rid of surrounding angles...
6082 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6083 (if (or (eq 'mid guessed) (eq 'mail guessed))
6087 (save-window-excursion
6088 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6091 (cond ((eq pref 'mid)
6092 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6093 (gnus-button-handle-news url-mid))
6095 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6096 (gnus-url-mailto url-mailto))
6097 (t (gnus-message 3 "Invalid string.")))))
6099 (defun gnus-button-handle-custom (url)
6100 "Follow a Custom URL."
6101 (customize-apropos (gnus-url-unhex-string url)))
6103 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6105 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6108 (defun gnus-button-handle-describe-function (url)
6109 "Call `describe-function' when pushing the corresponding URL button."
6112 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6114 (defun gnus-button-handle-describe-variable (url)
6115 "Call `describe-variable' when pushing the corresponding URL button."
6118 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6120 (defun gnus-button-handle-symbol (url)
6121 "Display help on variable or function.
6122 Calls `describe-variable' or `describe-function'."
6123 (let ((sym (intern url)))
6125 ((fboundp sym) (describe-function sym))
6126 ((boundp sym) (describe-variable sym))
6127 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6129 (defun gnus-button-handle-describe-key (url)
6130 "Call `describe-key' when pushing the corresponding URL button."
6132 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6133 (keys (ignore-errors (eval `(kbd ,key-string)))))
6136 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6138 (defun gnus-button-handle-apropos (url)
6139 "Call `apropos' when pushing the corresponding URL button."
6140 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6142 (defun gnus-button-handle-apropos-command (url)
6143 "Call `apropos' when pushing the corresponding URL button."
6145 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6147 (defun gnus-button-handle-apropos-variable (url)
6148 "Call `apropos' when pushing the corresponding URL button."
6150 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6151 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6153 (defun gnus-button-handle-apropos-documentation (url)
6154 "Call `apropos' when pushing the corresponding URL button."
6156 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6157 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6159 (defun gnus-button-handle-library (url)
6160 "Call `locate-library' when pushing the corresponding URL button."
6161 (gnus-message 9 "url=`%s'" url)
6162 (let* ((lib (locate-library url))
6163 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6165 (gnus-message 1 "Cannot locale library `%s'." url)
6166 (find-file-read-only file))))
6168 (defun gnus-button-handle-ctan (url)
6169 "Call `browse-url' when pushing a CTAN URL button."
6171 gnus-button-ctan-handler
6174 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6176 (defcustom gnus-button-tex-level 5
6177 "*Integer that says how many TeX-related buttons Gnus will show.
6178 The higher the number, the more buttons will appear and the more false
6179 positives are possible. Note that you can set this variable local to
6180 specific groups. Setting it higher in TeX groups is probably a good idea.
6181 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6182 how to set variables in specific groups."
6184 :group 'gnus-article-buttons
6185 :link '(custom-manual "(gnus)Group Parameters")
6188 (defcustom gnus-button-man-level 5
6189 "*Integer that says how many man-related buttons Gnus will show.
6190 The higher the number, the more buttons will appear and the more false
6191 positives are possible. Note that you can set this variable local to
6192 specific groups. Setting it higher in Unix groups is probably a good idea.
6193 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6194 how to set variables in specific groups."
6196 :group 'gnus-article-buttons
6197 :link '(custom-manual "(gnus)Group Parameters")
6200 (defcustom gnus-button-emacs-level 5
6201 "*Integer that says how many emacs-related buttons Gnus will show.
6202 The higher the number, the more buttons will appear and the more false
6203 positives are possible. Note that you can set this variable local to
6204 specific groups. Setting it higher in Emacs or Gnus related groups is
6205 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6206 `gnus-parameters' on how to set variables in specific groups."
6208 :group 'gnus-article-buttons
6209 :link '(custom-manual "(gnus)Group Parameters")
6212 (defcustom gnus-button-message-level 5
6213 "*Integer that says how many buttons for news or mail messages will appear.
6214 The higher the number, the more buttons will appear and the more false
6215 positives are possible."
6216 ;; mail addresses, MIDs, URLs for news, ...
6218 :group 'gnus-article-buttons
6221 (defcustom gnus-button-browse-level 5
6222 "*Integer that says how many buttons for browsing will appear.
6223 The higher the number, the more buttons will appear and the more false
6224 positives are possible."
6225 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6227 :group 'gnus-article-buttons
6230 (defcustom gnus-button-alist
6231 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6232 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6233 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6234 gnus-button-handle-news 2)
6235 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6236 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6237 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6238 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6239 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6240 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6241 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6242 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6243 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6244 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6245 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6246 ;; RFC 2368 (The mailto URL scheme)
6247 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6248 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6249 ("\\bmailto:\\([^ \n\t]+\\)"
6250 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6252 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6253 gnus-button-ctan-directory-regexp
6254 "[^][>)!;:,'\n\t ]+\\)")
6255 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6256 ((concat "\\btex-archive/\\("
6257 gnus-button-ctan-directory-regexp
6258 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6259 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6262 gnus-button-ctan-directory-regexp
6263 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6264 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6265 ;; This is info (home-grown style) <info://foo/bar+baz>
6266 ("\\binfo://\\([^'\">\n\t ]+\\)"
6267 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6268 ;; Info GNOME style <info:foo#bar_baz>
6269 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6270 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6271 ;; Info KDE style <info:(foo)bar baz>
6272 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6273 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6274 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6275 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6276 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6277 ;; Info links like `C-h i d m CC Mode RET'
6278 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6280 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6281 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6282 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6283 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6284 ;; Emacs help commands
6285 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6286 ;; regexp doesn't match arguments containing ` '.
6287 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6288 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6289 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6290 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6291 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6292 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6293 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6294 ;; The following entries may lead to many false positives so don't enable
6295 ;; them by default (use a high button level).
6296 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6297 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6298 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6299 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6300 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6301 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6302 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6303 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6304 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6305 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6306 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6307 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6308 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6309 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6310 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6311 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6312 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6313 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6314 ;; Unlike the other regexps we really have to require quoting
6315 ;; here to determine where it ends.
6316 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6317 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6318 ("<URL: *\\([^<>]*\\)>"
6319 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6320 ;; RFC 2396 (2.4.3., delims) ...
6321 ("\"URL: *\\([^\"]*\\)\""
6322 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6323 ;; RFC 2396 (2.4.3., delims) ...
6324 ("\"URL: *\\([^\"]*\\)\""
6325 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6327 (gnus-button-url-regexp
6328 0 (>= gnus-button-browse-level 0) browse-url 0)
6330 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6331 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6332 gnus-button-handle-man 1)
6333 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6334 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6335 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6336 gnus-button-handle-man 1)
6337 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6338 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6339 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6340 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6341 ;; MID or mail: To avoid too many false positives we don't try to catch
6342 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6343 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6344 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6345 ;; so that non-ambiguous entries (see above) match first.
6346 (gnus-button-mid-or-mail-regexp
6347 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6348 "*Alist of regexps matching buttons in article bodies.
6350 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6351 REGEXP: is the string (case insensitive) matching text around the button (can
6352 also be Lisp expression evaluating to a string),
6353 BUTTON: is the number of the regexp grouping actually matching the button,
6354 FORM: is a Lisp expression which must eval to true for the button to
6356 CALLBACK: is the function to call when the user push this button, and each
6357 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6359 CALLBACK can also be a variable, in that case the value of that
6360 variable it the real callback function."
6361 :group 'gnus-article-buttons
6362 :type '(repeat (list (choice regexp variable sexp)
6363 (integer :tag "Button")
6365 (function :tag "Callback")
6368 (integer :tag "Regexp group")))))
6370 (defcustom gnus-header-button-alist
6371 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6372 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6373 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6374 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6375 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6376 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6377 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6378 0 (>= gnus-button-browse-level 0) browse-url 0)
6379 ("^Subject:" gnus-button-url-regexp
6380 0 (>= gnus-button-browse-level 0) browse-url 0)
6381 ("^[^:]+:" gnus-button-url-regexp
6382 0 (>= gnus-button-browse-level 0) browse-url 0)
6383 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6384 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6385 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6386 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6387 "*Alist of headers and regexps to match buttons in article heads.
6389 This alist is very similar to `gnus-button-alist', except that each
6390 alist has an additional HEADER element first in each entry:
6392 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6394 HEADER is a regexp to match a header. For a fuller explanation, see
6395 `gnus-button-alist'."
6396 :group 'gnus-article-buttons
6397 :group 'gnus-article-headers
6398 :type '(repeat (list (regexp :tag "Header")
6399 (choice regexp variable)
6400 (integer :tag "Button")
6402 (function :tag "Callback")
6405 (integer :tag "Regexp group")))))
6407 (defvar gnus-button-regexp nil)
6408 (defvar gnus-button-marker-list nil)
6409 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6411 (defvar gnus-button-last nil)
6412 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6416 (defun gnus-article-push-button (event)
6417 "Check text under the mouse pointer for a callback function.
6418 If the text under the mouse pointer has a `gnus-callback' property,
6419 call it with the value of the `gnus-data' text property."
6421 (set-buffer (window-buffer (posn-window (event-start event))))
6422 (let* ((pos (posn-point (event-start event)))
6423 (data (get-text-property pos 'gnus-data))
6424 (fun (get-text-property pos 'gnus-callback)))
6427 (funcall fun data))))
6429 (defun gnus-article-press-button ()
6430 "Check text at point for a callback function.
6431 If the text at point has a `gnus-callback' property,
6432 call it with the value of the `gnus-data' text property."
6434 (let ((data (get-text-property (point) 'gnus-data))
6435 (fun (get-text-property (point) 'gnus-callback)))
6437 (funcall fun data))))
6439 (defun gnus-article-highlight (&optional force)
6440 "Highlight current article.
6441 This function calls `gnus-article-highlight-headers',
6442 `gnus-article-highlight-citation',
6443 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6444 do the highlighting. See the documentation for those functions."
6445 (interactive (list 'force))
6446 (gnus-article-highlight-headers)
6447 (gnus-article-highlight-citation force)
6448 (gnus-article-highlight-signature)
6449 (gnus-article-add-buttons force)
6450 (gnus-article-add-buttons-to-head))
6452 (defun gnus-article-highlight-some (&optional force)
6453 "Highlight current article.
6454 This function calls `gnus-article-highlight-headers',
6455 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6456 do the highlighting. See the documentation for those functions."
6457 (interactive (list 'force))
6458 (gnus-article-highlight-headers)
6459 (gnus-article-highlight-signature)
6460 (gnus-article-add-buttons))
6462 (defun gnus-article-highlight-headers ()
6463 "Highlight article headers as specified by `gnus-header-face-alist'."
6466 (set-buffer gnus-article-buffer)
6468 (let ((alist gnus-header-face-alist)
6469 (inhibit-read-only t)
6470 (case-fold-search t)
6471 (inhibit-point-motion-hooks t)
6472 entry regexp header-face field-face from hpoints fpoints)
6473 (article-narrow-to-head)
6474 (while (setq entry (pop alist))
6475 (goto-char (point-min))
6476 (setq regexp (concat "^\\("
6477 (if (string-equal "" (nth 0 entry))
6481 header-face (nth 1 entry)
6482 field-face (nth 2 entry))
6483 (while (and (re-search-forward regexp nil t)
6487 (unless (search-forward ":" nil t)
6489 (when (and header-face
6490 (not (memq (point) hpoints)))
6491 (push (point) hpoints)
6492 (gnus-put-text-property from (point) 'face header-face))
6493 (when (and field-face
6494 (not (memq (setq from (point)) fpoints)))
6496 (if (re-search-forward "^[^ \t]" nil t)
6498 (goto-char (point-max)))
6499 (gnus-put-text-property from (point) 'face field-face))))))))
6501 (defun gnus-article-highlight-signature ()
6502 "Highlight the signature in an article.
6503 It does this by highlighting everything after
6504 `gnus-signature-separator' using the face `gnus-signature'."
6507 (set-buffer gnus-article-buffer)
6508 (let ((inhibit-read-only t)
6509 (inhibit-point-motion-hooks t))
6511 (when (and gnus-signature-face
6512 (gnus-article-narrow-to-signature))
6513 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6514 'face gnus-signature-face)
6516 (gnus-article-search-signature)
6517 (let ((start (match-beginning 0))
6518 (end (set-marker (make-marker) (1+ (match-end 0)))))
6519 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6522 (defun gnus-button-in-region-p (b e prop)
6523 "Say whether PROP exists in the region."
6524 (text-property-not-all b e prop nil))
6526 (defun gnus-article-add-buttons (&optional force)
6527 "Find external references in the article and make buttons of them.
6528 \"External references\" are things like Message-IDs and URLs, as
6529 specified by `gnus-button-alist'."
6530 (interactive (list 'force))
6532 (set-buffer gnus-article-buffer)
6533 (let ((inhibit-read-only t)
6534 (inhibit-point-motion-hooks t)
6535 (case-fold-search t)
6536 (alist gnus-button-alist)
6538 ;; Remove all old markers.
6539 (let (marker entry new-list)
6540 (while (setq marker (pop gnus-button-marker-list))
6541 (if (or (< marker (point-min)) (>= marker (point-max)))
6542 (push marker new-list)
6544 (when (setq entry (gnus-button-entry))
6545 (put-text-property (match-beginning (nth 1 entry))
6546 (match-end (nth 1 entry))
6547 'gnus-callback nil))
6548 (set-marker marker nil)))
6549 (setq gnus-button-marker-list new-list))
6550 ;; We skip the headers.
6553 (while (setq entry (pop alist))
6554 (setq regexp (eval (car entry)))
6556 (while (re-search-forward regexp nil t)
6557 (let* ((start (and entry (match-beginning (nth 1 entry))))
6558 (end (and entry (match-end (nth 1 entry))))
6559 (from (match-beginning 0)))
6560 (when (and (or (eq t (nth 2 entry))
6561 (eval (nth 2 entry)))
6562 (not (gnus-button-in-region-p
6563 start end 'gnus-callback)))
6564 ;; That optional form returned non-nil, so we add the
6566 (gnus-article-add-button
6567 start end 'gnus-button-push
6568 (car (push (set-marker (make-marker) from)
6569 gnus-button-marker-list))))))))))
6571 ;; Add buttons to the head of an article.
6572 (defun gnus-article-add-buttons-to-head ()
6573 "Add buttons to the head of the article."
6576 (set-buffer gnus-article-buffer)
6578 (let ((inhibit-read-only t)
6579 (inhibit-point-motion-hooks t)
6580 (case-fold-search t)
6581 (alist gnus-header-button-alist)
6583 (article-narrow-to-head)
6585 ;; Each alist entry.
6586 (setq entry (car alist)
6588 (goto-char (point-min))
6589 (while (re-search-forward (car entry) nil t)
6590 ;; Each header matching the entry.
6591 (setq beg (match-beginning 0))
6592 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6593 (match-beginning 0))
6596 (while (re-search-forward (eval (nth 1 entry)) end t)
6597 ;; Each match within a header.
6598 (let* ((entry (cdr entry))
6599 (start (match-beginning (nth 1 entry)))
6600 (end (match-end (nth 1 entry)))
6601 (form (nth 2 entry)))
6602 (goto-char (match-end 0))
6604 (gnus-article-add-button
6605 start end (nth 3 entry)
6606 (buffer-substring (match-beginning (nth 4 entry))
6607 (match-end (nth 4 entry)))))))
6608 (goto-char end)))))))
6610 ;;; External functions:
6612 (defun gnus-article-add-button (from to fun &optional data)
6613 "Create a button between FROM and TO with callback FUN and data DATA."
6614 (when gnus-article-button-face
6615 (gnus-overlay-put (gnus-make-overlay from to)
6616 'face gnus-article-button-face))
6617 (gnus-add-text-properties
6619 (nconc (and gnus-article-mouse-face
6620 (list gnus-mouse-face-prop gnus-article-mouse-face))
6621 (list 'gnus-callback fun)
6622 (and data (list 'gnus-data data))))
6623 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6624 :button-keymap gnus-widget-button-keymap))
6626 ;;; Internal functions:
6628 (defun gnus-article-set-globals ()
6630 (set-buffer gnus-summary-buffer)
6631 (gnus-set-global-variables)))
6633 (defun gnus-signature-toggle (end)
6635 (set-buffer gnus-article-buffer)
6636 (let ((inhibit-read-only t)
6637 (inhibit-point-motion-hooks t))
6638 (if (text-property-any end (point-max) 'article-type 'signature)
6640 (gnus-delete-wash-type 'signature)
6641 (gnus-remove-text-properties-when
6642 'article-type 'signature end (point-max)
6643 (cons 'article-type (cons 'signature
6644 gnus-hidden-properties))))
6645 (gnus-add-wash-type 'signature)
6646 (gnus-add-text-properties-when
6647 'article-type nil end (point-max)
6648 (cons 'article-type (cons 'signature
6649 gnus-hidden-properties)))))
6650 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6651 (gnus-set-mode-line 'article))))
6653 (defun gnus-button-entry ()
6654 ;; Return the first entry in `gnus-button-alist' matching this place.
6655 (let ((alist gnus-button-alist)
6658 (setq entry (pop alist))
6659 (if (looking-at (eval (car entry)))
6664 (defun gnus-button-push (marker)
6665 ;; Push button starting at MARKER.
6668 (let* ((entry (gnus-button-entry))
6669 (inhibit-point-motion-hooks t)
6671 (args (mapcar (lambda (group)
6672 (let ((string (match-string group)))
6673 (gnus-set-text-properties
6674 0 (length string) nil string)
6681 (fboundp (symbol-value fun)))
6682 (apply (symbol-value fun) args))
6684 (gnus-message 1 "You must define `%S' to use this button"
6685 (cons fun args)))))))
6687 (defun gnus-parse-news-url (url)
6688 (let (scheme server port group message-id articles)
6691 (goto-char (point-min))
6692 (when (looking-at "\\([A-Za-z]+\\):")
6693 (setq scheme (match-string 1))
6694 (goto-char (match-end 0)))
6695 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
6696 (setq server (match-string 1))
6697 (setq port (if (stringp (match-string 3))
6698 (string-to-number (match-string 3))
6700 (goto-char (match-end 0)))
6703 ((looking-at "\\(.*@.*\\)")
6704 (setq message-id (match-string 1)))
6705 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6706 (setq group (match-string 1)
6707 articles (split-string (match-string 2) "-")))
6708 ((looking-at "\\([^/]+\\)/?")
6709 (setq group (match-string 1)))
6711 (error "Unknown news URL syntax"))))
6712 (list scheme server port group message-id articles)))
6714 (defun gnus-button-handle-news (url)
6716 (destructuring-bind (scheme server port group message-id articles)
6717 (gnus-parse-news-url url)
6721 (set-buffer gnus-summary-buffer)
6723 (let ((gnus-refer-article-method
6724 (nconc (list (list 'nntp server))
6725 gnus-refer-article-method))
6726 (nntp-port-number (or port "nntp")))
6727 (gnus-message 7 "Fetching %s with %s"
6728 message-id gnus-refer-article-method)
6729 (gnus-summary-refer-article message-id))
6730 (gnus-summary-refer-article message-id))))
6732 (gnus-button-fetch-group url)))))
6734 (defun gnus-button-handle-man (url)
6736 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6737 (when (eq gnus-button-man-handler 'woman)
6738 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
6739 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6740 (funcall gnus-button-man-handler url))
6742 (defun gnus-button-handle-info-url (url)
6743 "Fetch an info URL."
6744 (setq url (mm-subst-char-in-string ?+ ?\ url))
6746 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6747 (gnus-info-find-node
6748 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6750 ")" (gnus-url-unhex-string (match-string 2 url)))))
6751 ((string-match "([^)\"]+)[^\"]+" url)
6753 (gnus-replace-in-string
6754 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6755 (gnus-info-find-node url))
6756 (t (error "Can't parse %s" url))))
6758 (defun gnus-button-handle-info-url-gnome (url)
6759 "Fetch GNOME style info URL."
6760 (setq url (mm-subst-char-in-string ?_ ?\ url))
6761 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6762 (gnus-info-find-node
6764 (gnus-url-unhex-string
6765 (match-string 1 url))
6767 (or (gnus-url-unhex-string
6768 (match-string 2 url))
6770 (error "Can't parse %s" url)))
6772 (defun gnus-button-handle-info-url-kde (url)
6773 "Fetch KDE style info URL."
6774 (gnus-info-find-node (gnus-url-unhex-string url)))
6776 (defun gnus-button-handle-info-keystrokes (url)
6777 "Call `info' when pushing the corresponding URL button."
6778 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6783 (defun gnus-button-message-id (message-id)
6786 (set-buffer gnus-summary-buffer)
6787 (gnus-summary-refer-article message-id)))
6789 (defun gnus-button-fetch-group (address)
6790 "Fetch GROUP specified by ADDRESS."
6791 (if (not (string-match "[:/]" address))
6792 ;; This is just a simple group url.
6793 (gnus-group-read-ephemeral-group address gnus-select-method)
6796 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6798 (error "Can't parse %s" address)
6799 (gnus-group-read-ephemeral-group
6800 (match-string 4 address)
6801 `(nntp ,(match-string 1 address)
6802 (nntp-address ,(match-string 1 address))
6803 (nntp-port-number ,(if (match-end 3)
6804 (match-string 3 address)
6807 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
6809 (defun gnus-url-parse-query-string (query &optional downcase)
6810 (let (retval pairs cur key val)
6811 (setq pairs (split-string query "&"))
6813 (setq cur (car pairs)
6815 (if (not (string-match "=" cur))
6817 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6818 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6820 (setq key (downcase key)))
6821 (setq cur (assoc key retval))
6823 (setcdr cur (cons val (cdr cur)))
6824 (setq retval (cons (list key val) retval)))))
6827 (defun gnus-url-mailto (url)
6828 ;; Send mail to someone
6829 (when (string-match "mailto:/*\\(.*\\)" url)
6830 (setq url (substring url (match-beginning 1) nil)))
6831 (let (to args subject func)
6832 (setq args (gnus-url-parse-query-string
6833 (if (string-match "^\\?" url)
6835 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6836 (concat "to=" (match-string 1 url) "&"
6837 (match-string 2 url))
6838 (concat "to=" url)))
6840 subject (cdr-safe (assoc "subject" args)))
6843 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6846 (message-position-on-field (caar args)))
6847 (insert (gnus-replace-in-string
6848 (mapconcat 'identity (reverse (cdar args)) ", ")
6850 (setq args (cdr args)))
6853 (message-goto-subject))))
6855 (defun gnus-button-embedded-url (address)
6856 "Activate ADDRESS with `browse-url'."
6857 (browse-url (gnus-strip-whitespace address)))
6859 ;;; Next/prev buttons in the article buffer.
6861 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6862 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6864 (defvar gnus-prev-page-map
6865 (let ((map (make-sparse-keymap)))
6866 (unless (>= emacs-major-version 21)
6867 ;; XEmacs doesn't care.
6868 (set-keymap-parent map gnus-article-mode-map))
6869 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6870 (define-key map "\r" 'gnus-button-prev-page)
6873 (defvar gnus-next-page-map
6874 (let ((map (make-sparse-keymap)))
6875 (unless (>= emacs-major-version 21)
6876 ;; XEmacs doesn't care.
6877 (set-keymap-parent map gnus-article-mode-map))
6878 (define-key map gnus-mouse-2 'gnus-button-next-page)
6879 (define-key map "\r" 'gnus-button-next-page)
6882 (defun gnus-insert-prev-page-button ()
6884 (inhibit-read-only t))
6886 gnus-prev-page-line-format nil
6887 `(,@(gnus-local-map-property gnus-prev-page-map)
6889 gnus-callback gnus-article-button-prev-page
6890 article-type annotation))
6891 (widget-convert-button
6893 ;; Exclude a newline.
6896 :action 'gnus-button-prev-page
6897 :button-keymap gnus-prev-page-map)))
6899 (defun gnus-button-next-page (&optional args more-args)
6900 "Go to the next page."
6902 (let ((win (selected-window)))
6903 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6904 (gnus-article-next-page)
6905 (select-window win)))
6907 (defun gnus-button-prev-page (&optional args more-args)
6908 "Go to the prev page."
6910 (let ((win (selected-window)))
6911 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6912 (gnus-article-prev-page)
6913 (select-window win)))
6915 (defun gnus-insert-next-page-button ()
6917 (inhibit-read-only t))
6918 (gnus-eval-format gnus-next-page-line-format nil
6919 `(,@(gnus-local-map-property gnus-next-page-map)
6921 gnus-callback gnus-article-button-next-page
6922 article-type annotation))
6923 (widget-convert-button
6925 ;; Exclude a newline.
6928 :action 'gnus-button-next-page
6929 :button-keymap gnus-next-page-map)))
6931 (defun gnus-article-button-next-page (arg)
6932 "Go to the next page."
6934 (let ((win (selected-window)))
6935 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6936 (gnus-article-next-page)
6937 (select-window win)))
6939 (defun gnus-article-button-prev-page (arg)
6940 "Go to the prev page."
6942 (let ((win (selected-window)))
6943 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6944 (gnus-article-prev-page)
6945 (select-window win)))
6947 (defvar gnus-decode-header-methods
6948 '(mail-decode-encoded-word-region)
6949 "List of methods used to decode headers.
6951 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6952 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
6953 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6954 whose names match REGEXP.
6957 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6958 mail-decode-encoded-word-region
6959 (\"chinese\" . rfc1843-decode-region))
6962 (defvar gnus-decode-header-methods-cache nil)
6964 (defun gnus-multi-decode-header (start end)
6965 "Apply the functions from `gnus-encoded-word-methods' that match."
6966 (unless (and gnus-decode-header-methods-cache
6967 (eq gnus-newsgroup-name
6968 (car gnus-decode-header-methods-cache)))
6969 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6972 (nconc gnus-decode-header-methods-cache (list x))
6973 (if (and gnus-newsgroup-name
6974 (string-match (car x) gnus-newsgroup-name))
6975 (nconc gnus-decode-header-methods-cache
6977 gnus-decode-header-methods))
6978 (let ((xlist gnus-decode-header-methods-cache))
6981 (narrow-to-region start end)
6983 (funcall (pop xlist) (point-min) (point-max))))))
6986 ;;; Treatment top-level handling.
6989 (defun gnus-treat-article (condition &optional part-number total-parts type)
6990 (let ((length (- (point-max) (point-min)))
6991 (alist gnus-treatment-function-alist)
6992 (article-goto-body-goes-to-point-min-p t)
6996 (let ((list gnus-article-treat-types))
6998 (when (string-match (pop list) type)
6999 (throw 'found t)))))))
7000 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7002 (gnus-run-hooks 'gnus-part-display-hook)
7003 (dolist (elem alist)
7006 (when (gnus-buffer-live-p gnus-summary-buffer)
7007 (set-buffer gnus-summary-buffer))
7008 (symbol-value (car elem))))
7009 (when (and (or (consp val)
7011 (gnus-treat-predicate val)
7012 (or (not (get (car elem) 'highlight))
7015 (funcall (cadr elem)))))))
7017 ;; Dynamic variables.
7019 (defvar part-number)
7020 (defvar total-parts)
7025 (defun gnus-treat-predicate (val)
7032 (stringp (car val)))
7033 (apply 'gnus-or (mapcar `(lambda (s)
7034 (string-match s ,(or gnus-newsgroup-name "")))
7037 (let ((pred (pop val)))
7040 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7042 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7044 (not (gnus-treat-predicate (car val))))
7046 (equal (car val) type))
7048 (error "%S is not a valid predicate" pred)))))
7054 (eq part-number total-parts))
7058 (error "%S is not a valid value" val))))
7060 (defun gnus-article-encrypt-body (protocol &optional n)
7061 "Encrypt the article body."
7064 (or gnus-article-encrypt-protocol
7065 (completing-read "Encrypt protocol: "
7066 gnus-article-encrypt-protocol-alist
7068 current-prefix-arg))
7069 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7071 (error "Can't find the encrypt protocol %s" protocol))
7072 (if (member gnus-newsgroup-name '("nndraft:delayed"
7075 (error "Can't encrypt the article in group %s"
7076 gnus-newsgroup-name))
7077 (gnus-summary-iterate n
7079 (set-buffer gnus-summary-buffer)
7080 (let ((mail-parse-charset gnus-newsgroup-charset)
7081 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7082 (summary-buffer gnus-summary-buffer)
7084 (gnus-set-global-variables)
7085 (when (gnus-group-read-only-p)
7086 (error "The current newsgroup does not support article encrypt"))
7087 (gnus-summary-show-article t)
7089 (or (mail-header-references gnus-current-headers) ""))
7090 (set-buffer gnus-article-buffer)
7091 (let* ((inhibit-read-only t)
7093 (mapcar (lambda (field)
7094 (and (save-restriction
7095 (message-narrow-to-head)
7096 (goto-char (point-min))
7097 (search-forward field nil t))
7099 (message-narrow-to-field)
7101 (delete-region (point-min) (point-max))
7103 '("Content-Type:" "Content-Transfer-Encoding:"
7104 "Content-Disposition:"))))
7105 (message-narrow-to-head)
7106 (message-remove-header "MIME-Version")
7107 (goto-char (point-max))
7108 (setq point (point))
7109 (insert (apply 'concat headers))
7111 (narrow-to-region point (point-max))
7112 (let ((message-options message-options))
7113 (message-options-set 'message-sender user-mail-address)
7114 (message-options-set 'message-recipients user-mail-address)
7115 (message-options-set 'message-sign-encrypt 'not)
7117 (goto-char (point-min))
7118 (insert "MIME-Version: 1.0\n")
7120 (gnus-summary-edit-article-done
7121 references nil summary-buffer t))
7122 (when gnus-keep-backlog
7123 (gnus-backlog-remove-article
7124 (car gnus-article-current) (cdr gnus-article-current)))
7126 (when (get-buffer gnus-original-article-buffer)
7127 (set-buffer gnus-original-article-buffer)
7128 (setq gnus-original-article nil)))
7129 (when gnus-use-cache
7130 (gnus-cache-update-article
7131 (car gnus-article-current) (cdr gnus-article-current))))))))
7133 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7134 "The following specs can be used:
7135 %t The security MIME type
7138 %D Details if button is pressed")
7140 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7141 "The following specs can be used:
7142 %t The security MIME type
7145 %D Details if button is pressed")
7147 (defvar gnus-mime-security-button-line-format-alist
7148 '((?t gnus-tmp-type ?s)
7149 (?i gnus-tmp-info ?s)
7150 (?d gnus-tmp-details ?s)
7151 (?D gnus-tmp-pressed-details ?s)))
7153 (defvar gnus-mime-security-button-map
7154 (let ((map (make-sparse-keymap)))
7155 (unless (>= (string-to-number emacs-version) 21)
7156 (set-keymap-parent map gnus-article-mode-map))
7157 (define-key map gnus-mouse-2 'gnus-article-push-button)
7158 (define-key map "\r" 'gnus-article-press-button)
7161 (defvar gnus-mime-security-details-buffer nil)
7163 (defvar gnus-mime-security-button-pressed nil)
7165 (defvar gnus-mime-security-show-details-inline t
7166 "If non-nil, show details in the article buffer.")
7168 (defun gnus-mime-security-verify-or-decrypt (handle)
7169 (mm-remove-parts (cdr handle))
7170 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7171 point (inhibit-read-only t))
7173 (goto-char (car region)))
7175 (narrow-to-region (point) (point))
7176 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7177 (let* ((mm-verify-option 'known)
7178 (mm-decrypt-option 'known)
7179 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7180 (unless (eq nparts (cdr handle))
7181 (mm-destroy-parts (cdr handle))
7182 (setcdr handle nparts))))
7183 (setq point (point))
7184 (gnus-mime-display-security handle)
7185 (goto-char (point-max)))
7187 (delete-region (point) (cdr region))
7188 (set-marker (car region) nil)
7189 (set-marker (cdr region) nil))
7192 (defun gnus-mime-security-show-details (handle)
7193 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7195 (gnus-message 5 "No details.")
7196 (if gnus-mime-security-show-details-inline
7197 (let ((gnus-mime-security-button-pressed
7198 (not (get-text-property (point) 'gnus-mime-details)))
7199 (gnus-mime-security-button-line-format
7200 (get-text-property (point) 'gnus-line-format))
7201 (inhibit-read-only t))
7203 (while (eq (get-text-property (point) 'gnus-line-format)
7204 gnus-mime-security-button-line-format)
7208 (narrow-to-region (point) (point))
7209 (gnus-insert-mime-security-button handle))
7210 (delete-region (point)
7211 (or (text-property-not-all
7214 gnus-mime-security-button-line-format)
7217 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7218 (with-current-buffer gnus-mime-security-details-buffer
7221 (setq gnus-mime-security-details-buffer
7222 (gnus-get-buffer-create "*MIME Security Details*")))
7223 (with-current-buffer gnus-mime-security-details-buffer
7225 (goto-char (point-min)))
7226 (pop-to-buffer gnus-mime-security-details-buffer)))))
7228 (defun gnus-mime-security-press-button (handle)
7230 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7231 (gnus-mime-security-show-details handle)
7232 (gnus-mime-security-verify-or-decrypt handle))))
7234 (defun gnus-insert-mime-security-button (handle &optional displayed)
7235 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7238 (or (nth 2 (assoc protocol mm-verify-function-alist))
7239 (nth 2 (assoc protocol mm-decrypt-function-alist))
7241 (if (equal (car handle) "multipart/signed")
7242 " Signed" " Encrypted")
7245 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7248 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7249 gnus-tmp-pressed-details
7251 (setq gnus-tmp-details
7252 (if gnus-tmp-details
7253 (concat "\n" gnus-tmp-details)
7255 (setq gnus-tmp-pressed-details
7256 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7261 gnus-mime-security-button-line-format
7262 gnus-mime-security-button-line-format-alist
7263 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7264 gnus-callback gnus-mime-security-press-button
7265 gnus-line-format ,gnus-mime-security-button-line-format
7266 gnus-mime-details ,gnus-mime-security-button-pressed
7267 article-type annotation
7270 ;; Exclude a newline.
7273 (widget-convert-button
7276 :action 'gnus-widget-press-button
7277 :button-keymap gnus-mime-security-button-map
7279 (lambda (widget/window &optional overlay pos)
7280 ;; Needed to properly clear the message due to a bug in
7281 ;; wid-edit (XEmacs only).
7282 (when (boundp 'help-echo-owns-message)
7283 (setq help-echo-owns-message t))
7286 (aref gnus-mouse-2 0))))))
7288 (defun gnus-mime-display-security (handle)
7290 (narrow-to-region (point) (point))
7291 (unless (gnus-unbuttonized-mime-type-p (car handle))
7292 (gnus-insert-mime-security-button handle))
7293 (gnus-mime-display-mixed (cdr handle))
7296 (unless (gnus-unbuttonized-mime-type-p (car handle))
7297 (let ((gnus-mime-security-button-line-format
7298 gnus-mime-security-button-end-line-format))
7299 (gnus-insert-mime-security-button handle)))
7300 (mm-set-handle-multipart-parameter
7302 (cons (set-marker (make-marker) (point-min))
7303 (set-marker (make-marker) (point-max))))))
7309 (run-hooks 'gnus-art-load-hook)
7311 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7312 ;;; gnus-art.el ends here