1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
33 (defvar w3m-minor-mode-map))
36 ;; Avoid the "Recursive load suspected" error in Emacs 21.1.
38 (let ((recursive-load-depth-limit 100))
51 (autoload 'gnus-msg-mail "gnus-msg" nil t)
52 (autoload 'gnus-button-mailto "gnus-msg")
53 (autoload 'gnus-button-reply "gnus-msg" nil t)
54 (autoload 'parse-time-string "parse-time" nil nil)
55 (autoload 'ansi-color-apply-on-region "ansi-color")
57 (defgroup gnus-article nil
59 :link '(custom-manual "(gnus)Article Buffer")
62 (defgroup gnus-article-treat nil
63 "Treating article parts."
64 :link '(custom-manual "(gnus)Article Hiding")
67 (defgroup gnus-article-hiding nil
68 "Hiding article parts."
69 :link '(custom-manual "(gnus)Article Hiding")
72 (defgroup gnus-article-highlight nil
73 "Article highlighting."
74 :link '(custom-manual "(gnus)Article Highlighting")
78 (defgroup gnus-article-signature nil
80 :link '(custom-manual "(gnus)Article Signature")
83 (defgroup gnus-article-headers nil
85 :link '(custom-manual "(gnus)Hiding Headers")
88 (defgroup gnus-article-washing nil
89 "Special commands on articles."
90 :link '(custom-manual "(gnus)Article Washing")
93 (defgroup gnus-article-emphasis nil
94 "Fontisizing articles."
95 :link '(custom-manual "(gnus)Article Fontisizing")
98 (defgroup gnus-article-saving nil
100 :link '(custom-manual "(gnus)Saving Articles")
101 :group 'gnus-article)
103 (defgroup gnus-article-mime nil
104 "Worshiping the MIME wonder."
105 :link '(custom-manual "(gnus)Using MIME")
106 :group 'gnus-article)
108 (defgroup gnus-article-buttons nil
109 "Pushable buttons in the article buffer."
110 :link '(custom-manual "(gnus)Article Buttons")
111 :group 'gnus-article)
113 (defgroup gnus-article-various nil
114 "Other article options."
115 :link '(custom-manual "(gnus)Misc Article")
116 :group 'gnus-article)
118 (defcustom gnus-ignored-headers
121 (concat "^" header ":"))
122 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
123 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
124 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
125 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
126 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
127 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
128 "X-Attribution" "X-Originating-IP" "Delivered-To"
129 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
130 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
131 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
132 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
133 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
134 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
135 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
136 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
137 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
138 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
139 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
140 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
141 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
142 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
143 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
144 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
145 "List-[A-Za-z]+" "X-Listprocessor-Version"
146 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
147 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
148 "X-Received" "Content-length" "X-precedence"
149 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
150 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
151 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
152 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
153 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
154 "X-Content-length" "X-Posting-Agent" "Original-Received"
155 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
156 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
157 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
158 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
159 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
160 "*All headers that start with this regexp will be hidden.
161 This variable can also be a list of regexps of headers to be ignored.
162 If `gnus-visible-headers' is non-nil, this variable will be ignored."
163 :type '(choice :custom-show nil
166 :group 'gnus-article-hiding)
168 (defcustom gnus-visible-headers
169 "^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:"
170 "*All headers that do not match this regexp will be hidden.
171 This variable can also be a list of regexp of headers to remain visible.
172 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
173 :type '(repeat :value-to-internal (lambda (widget value)
174 (custom-split-regexp-maybe value))
175 :match (lambda (widget value)
177 (widget-editable-list-match widget value)))
179 :group 'gnus-article-hiding)
181 (defcustom gnus-sorted-header-list
182 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
183 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
184 "*This variable is a list of regular expressions.
185 If it is non-nil, headers that match the regular expressions will
186 be placed first in the article buffer in the sequence specified by
188 :type '(repeat regexp)
189 :group 'gnus-article-hiding)
191 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
192 "Headers that are only to be displayed if they have interesting data.
193 Possible values in this list are:
195 'empty Headers with no content.
196 'newsgroups Newsgroup identical to Gnus group.
197 'to-address To identical to To-address.
198 'to-list To identical to To-list.
199 'cc-list CC identical to To-list.
200 'followup-to Followup-to identical to Newsgroups.
201 'reply-to Reply-to identical to From.
202 'date Date less than four days old.
203 'long-to To and/or Cc longer than 1024 characters.
204 'many-to Multiple To and/or Cc."
205 :type '(set (const :tag "Headers with no content." empty)
206 (const :tag "Newsgroups identical to Gnus group." newsgroups)
207 (const :tag "To identical to To-address." to-address)
208 (const :tag "To identical to To-list." to-list)
209 (const :tag "CC identical to To-list." cc-list)
210 (const :tag "Followup-to identical to Newsgroups." followup-to)
211 (const :tag "Reply-to identical to From." reply-to)
212 (const :tag "Date less than four days old." date)
213 (const :tag "To and/or Cc longer than 1024 characters." long-to)
214 (const :tag "Multiple To and/or Cc headers." many-to))
215 :group 'gnus-article-hiding)
217 (defcustom gnus-article-skip-boring nil
218 "Skip over text that is not worth reading.
219 By default, if you set this t, then Gnus will display citations and
220 signatures, but will never scroll down to show you a page consisting
221 only of boring text. Boring text is controlled by
222 `gnus-article-boring-faces'."
225 :group 'gnus-article-hiding)
227 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
228 "Regexp matching signature separator.
229 This can also be a list of regexps. In that case, it will be checked
230 from head to tail looking for a separator. Searches will be done from
231 the end of the buffer."
232 :type '(repeat string)
233 :group 'gnus-article-signature)
235 (defcustom gnus-signature-limit nil
236 "Provide a limit to what is considered a signature.
237 If it is a number, no signature may not be longer (in characters) than
238 that number. If it is a floating point number, no signature may be
239 longer (in lines) than that number. If it is a function, the function
240 will be called without any parameters, and if it returns nil, there is
241 no signature in the buffer. If it is a string, it will be used as a
242 regexp. If it matches, the text in question is not a signature.
244 This can also be a list of the above values."
245 :type '(choice (const nil)
248 (function :value fun)
249 (regexp :value ".*"))
250 :group 'gnus-article-signature)
252 (defcustom gnus-hidden-properties '(invisible t intangible t)
253 "Property list to use for hiding text."
255 :group 'gnus-article-hiding)
257 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
258 ;; frames in a session.
259 (defcustom gnus-article-x-face-command
260 (if (featurep 'xemacs)
261 (if (or (gnus-image-type-available-p 'xface)
262 (gnus-image-type-available-p 'pbm))
263 'gnus-display-x-face-in-from
264 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
265 (if (gnus-image-type-available-p 'pbm)
266 'gnus-display-x-face-in-from
267 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
269 "*String or function to be executed to display an X-Face header.
270 If it is a string, the command will be executed in a sub-shell
271 asynchronously. The compressed face will be piped to this command."
272 :type `(choice string
273 (function-item gnus-display-x-face-in-from)
277 :group 'gnus-article-washing)
279 (defcustom gnus-article-x-face-too-ugly nil
280 "Regexp matching posters whose face shouldn't be shown automatically."
281 :type '(choice regexp (const nil))
282 :group 'gnus-article-washing)
284 (defcustom gnus-article-banner-alist nil
285 "Banner alist for stripping.
287 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
289 :type '(repeat (cons symbol regexp))
290 :group 'gnus-article-washing)
292 (gnus-define-group-parameter
295 "Alist of regexps (to match group names) and banner."
296 :variable-group gnus-article-washing
298 '(choice :tag "Banner"
300 (const :tag "Remove signature" signature)
301 (symbol :tag "Item in `gnus-article-banner-alist'" none)
303 (const :tag "None" nil))
305 "If non-nil, specify how to remove `banners' from articles.
307 Symbol `signature' means to remove signatures delimited by
308 `gnus-signature-separator'. Any other symbol is used to look up a
309 regular expression to match the banner in `gnus-article-banner-alist'.
310 A string is used as a regular expression to match the banner
313 (defcustom gnus-article-address-banner-alist nil
314 "Alist of mail addresses and banners.
315 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
316 to match a mail address in the From: header, BANNER is one of a symbol
317 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
318 If ADDRESS matches author's mail address, it will remove things like
319 advertisements. For example:
321 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
325 (regexp :tag "Address")
326 (choice :tag "Banner" :value nil
327 (const :tag "Remove signature" signature)
328 (symbol :tag "Item in `gnus-article-banner-alist'" none)
330 (const :tag "None" nil))))
332 :group 'gnus-article-washing)
334 (defmacro gnus-emphasis-custom-with-format (&rest body)
336 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
337 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
340 (defun gnus-emphasis-custom-value-to-external (value)
341 (gnus-emphasis-custom-with-format
342 (if (consp (car value))
343 (list (format format (car (car value)) (cdr (car value)))
345 (if (nth 1 value) 2 3)
349 (defun gnus-emphasis-custom-value-to-internal (value)
350 (gnus-emphasis-custom-with-format
351 (let ((regexp (concat "\\`"
352 (format (regexp-quote format)
353 "\\([^()]+\\)" "\\([^()]+\\)")
356 (if (string-match regexp (setq pattern (car value)))
357 (list (cons (match-string 1 pattern) (match-string 2 pattern))
362 (defcustom gnus-emphasis-alist
364 '(("\\*" "\\*" bold nil 2)
367 ("_/" "/_" underline-italic)
368 ("_\\*" "\\*_" underline-bold)
369 ("\\*/" "/\\*" bold-italic)
370 ("_\\*/" "/\\*_" underline-bold-italic))))
372 (gnus-emphasis-custom-with-format
373 (mapcar (lambda (spec)
374 (list (format format (car spec) (cadr spec))
377 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
379 '(;; I've never seen anyone use this strikethru convention whereas I've
380 ;; several times seen it triggered by normal text. --Stef
381 ;; Miles suggests that this form is sometimes used but for italics,
382 ;; so maybe we should map it to `italic'.
383 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
384 ;; 2 3 gnus-emphasis-strikethru)
385 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
386 2 3 gnus-emphasis-underline))))
387 "*Alist that says how to fontify certain phrases.
388 Each item looks like this:
390 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
392 The first element is a regular expression to be matched. The second
393 is a number that says what regular expression grouping used to find
394 the entire emphasized word. The third is a number that says what
395 regexp grouping should be displayed and highlighted. The fourth
396 is the face used for highlighting."
400 :format "%[Customizing Style%]\n%v"
402 (group :tag "Default"
403 :value ("" 0 0 default)
406 (let ((value (widget-get
407 (cadr (widget-get (widget-get widget :parent)
410 (if (not (eq (nth 2 value) 'default))
414 (gnus-emphasis-custom-value-to-external value))))
415 (widget-group-value-create widget))
417 (integer :format "Match group: %v")
418 (integer :format "Emphasize group: %v")
421 :value (("_" . "_") nil default)
423 (regexp :format "Start regexp: %v")
424 (regexp :format "End regexp: %v"))
425 (boolean :format "Show start and end patterns: %[%v%]\n"
426 :on " On " :off " Off ")
428 :get (lambda (symbol)
429 (mapcar 'gnus-emphasis-custom-value-to-internal
430 (default-value symbol)))
431 :set (lambda (symbol value)
432 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
434 :group 'gnus-article-emphasis)
436 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
437 "A regexp to describe whitespace which should not be emphasized.
438 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
439 The former avoids underlining of leading and trailing whitespace,
440 and the latter avoids underlining any whitespace at all."
442 :group 'gnus-article-emphasis
445 (defface gnus-emphasis-bold '((t (:bold t)))
446 "Face used for displaying strong emphasized text (*word*)."
447 :group 'gnus-article-emphasis)
449 (defface gnus-emphasis-italic '((t (:italic t)))
450 "Face used for displaying italic emphasized text (/word/)."
451 :group 'gnus-article-emphasis)
453 (defface gnus-emphasis-underline '((t (:underline t)))
454 "Face used for displaying underlined emphasized text (_word_)."
455 :group 'gnus-article-emphasis)
457 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
458 "Face used for displaying underlined bold emphasized text (_*word*_)."
459 :group 'gnus-article-emphasis)
461 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
462 "Face used for displaying underlined italic emphasized text (_/word/_)."
463 :group 'gnus-article-emphasis)
465 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
466 "Face used for displaying bold italic emphasized text (/*word*/)."
467 :group 'gnus-article-emphasis)
469 (defface gnus-emphasis-underline-bold-italic
470 '((t (:bold t :italic t :underline t)))
471 "Face used for displaying underlined bold italic emphasized text.
472 Example: (_/*word*/_)."
473 :group 'gnus-article-emphasis)
475 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
476 '((t (:strikethru t)))
477 '((t (:strike-through t))))
478 "Face used for displaying strike-through text (-word-)."
479 :group 'gnus-article-emphasis)
481 (defface gnus-emphasis-highlight-words
482 '((t (:background "black" :foreground "yellow")))
483 "Face used for displaying highlighted words."
484 :group 'gnus-article-emphasis)
486 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
487 "Format for display of Date headers in article bodies.
488 See `format-time-string' for the possible values.
490 The variable can also be function, which should return a complete Date
491 header. The function is called with one argument, the time, which can
492 be fed to `format-time-string'."
493 :type '(choice string function)
494 :link '(custom-manual "(gnus)Article Date")
495 :group 'gnus-article-washing)
497 (defcustom gnus-save-all-headers t
498 "*If non-nil, don't remove any headers before saving."
499 :group 'gnus-article-saving
502 (defcustom gnus-prompt-before-saving 'always
503 "*This variable says how much prompting is to be done when saving articles.
504 If it is nil, no prompting will be done, and the articles will be
505 saved to the default files. If this variable is `always', each and
506 every article that is saved will be preceded by a prompt, even when
507 saving large batches of articles. If this variable is neither nil not
508 `always', there the user will be prompted once for a file name for
509 each invocation of the saving commands."
510 :group 'gnus-article-saving
511 :type '(choice (item always)
512 (item :tag "never" nil)
513 (sexp :tag "once" :format "%t\n" :value t)))
515 (defcustom gnus-saved-headers gnus-visible-headers
516 "Headers to keep if `gnus-save-all-headers' is nil.
517 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
518 If that variable is nil, however, all headers that match this regexp
519 will be kept while the rest will be deleted before saving."
520 :group 'gnus-article-saving
523 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
524 "A function to save articles in your favourite format.
525 The function must be interactively callable (in other words, it must
526 be an Emacs command).
528 Gnus provides the following functions:
530 * gnus-summary-save-in-rmail (Rmail format)
531 * gnus-summary-save-in-mail (Unix mail format)
532 * gnus-summary-save-in-folder (MH folder)
533 * gnus-summary-save-in-file (article format)
534 * gnus-summary-save-body-in-file (article body)
535 * gnus-summary-save-in-vm (use VM's folder format)
536 * gnus-summary-write-to-file (article format -- overwrite)."
537 :group 'gnus-article-saving
538 :type '(radio (function-item gnus-summary-save-in-rmail)
539 (function-item gnus-summary-save-in-mail)
540 (function-item gnus-summary-save-in-folder)
541 (function-item gnus-summary-save-in-file)
542 (function-item gnus-summary-save-body-in-file)
543 (function-item gnus-summary-save-in-vm)
544 (function-item gnus-summary-write-to-file)))
546 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
547 "A function generating a file name to save articles in Rmail format.
548 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
549 :group 'gnus-article-saving
552 (defcustom gnus-mail-save-name 'gnus-plain-save-name
553 "A function generating a file name to save articles in Unix mail format.
554 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
555 :group 'gnus-article-saving
558 (defcustom gnus-folder-save-name 'gnus-folder-save-name
559 "A function generating a file name to save articles in MH folder.
560 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
561 :group 'gnus-article-saving
564 (defcustom gnus-file-save-name 'gnus-numeric-save-name
565 "A function generating a file name to save articles in article format.
566 The function is called with NEWSGROUP, HEADERS, and optional
568 :group 'gnus-article-saving
571 (defcustom gnus-split-methods
572 '((gnus-article-archive-name)
573 (gnus-article-nndoc-name))
574 "*Variable used to suggest where articles are to be saved.
575 For instance, if you would like to save articles related to Gnus in
576 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
577 you could set this variable to something like:
579 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
580 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
582 This variable is an alist where the key is the match and the
583 value is a list of possible files to save in if the match is
586 If the match is a string, it is used as a regexp match on the
587 article. If the match is a symbol, that symbol will be funcalled
588 from the buffer of the article to be saved with the newsgroup as
589 the parameter. If it is a list, it will be evaled in the same
592 If this form or function returns a string, this string will be
593 used as a possible file name; and if it returns a non-nil list,
594 that list will be used as possible file names."
595 :group 'gnus-article-saving
596 :type '(repeat (choice (list :value (fun) function)
597 (cons :value ("" "") regexp (repeat string))
600 (defcustom gnus-page-delimiter "^\^L"
601 "*Regexp describing what to use as article page delimiters.
602 The default value is \"^\^L\", which is a form linefeed at the
603 beginning of a line."
605 :group 'gnus-article-various)
607 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
608 "*The format specification for the article mode line.
609 See `gnus-summary-mode-line-format' for a closer description.
611 The following additional specs are available:
613 %w The article washing status.
614 %m The number of MIME parts in the article."
616 :group 'gnus-article-various)
618 (defcustom gnus-article-mode-hook nil
619 "*A hook for Gnus article mode."
621 :group 'gnus-article-various)
623 (when (featurep 'xemacs)
624 ;; Extracted from gnus-xmas-define in order to preserve user settings
625 (when (fboundp 'turn-off-scroll-in-place)
626 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
627 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
628 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
630 (defcustom gnus-article-menu-hook nil
631 "*Hook run after the creation of the article mode menu."
633 :group 'gnus-article-various)
635 (defcustom gnus-article-prepare-hook nil
636 "*A hook called after an article has been prepared in the article buffer."
638 :group 'gnus-article-various)
640 (defcustom gnus-copy-article-ignored-headers nil
641 "List of headers to be removed when copying an article.
642 Each element is a regular expression."
643 :version "23.0" ;; No Gnus
644 :type '(repeat regexp)
645 :group 'gnus-article-various)
647 (make-obsolete-variable 'gnus-article-hide-pgp-hook
648 "This variable is obsolete in Gnus 5.10.")
650 (defcustom gnus-article-button-face 'bold
651 "Face used for highlighting buttons in the article buffer.
653 An article button is a piece of text that you can activate by pressing
654 `RET' or `mouse-2' above it."
656 :group 'gnus-article-buttons)
658 (defcustom gnus-article-mouse-face 'highlight
659 "Face used for mouse highlighting in the article buffer.
661 Article buttons will be displayed in this face when the cursor is
664 :group 'gnus-article-buttons)
666 (defcustom gnus-signature-face 'gnus-signature
667 "Face used for highlighting a signature in the article buffer.
668 Obsolete; use the face `gnus-signature' for customizations instead."
670 :group 'gnus-article-highlight
671 :group 'gnus-article-signature)
673 (defface gnus-signature
676 "Face used for highlighting a signature in the article buffer."
677 :group 'gnus-article-highlight
678 :group 'gnus-article-signature)
679 ;; backward-compatibility alias
680 (put 'gnus-signature-face 'face-alias 'gnus-signature)
682 (defface gnus-header-from
685 (:foreground "spring green"))
688 (:foreground "red3"))
691 "Face used for displaying from headers."
692 :group 'gnus-article-headers
693 :group 'gnus-article-highlight)
694 ;; backward-compatibility alias
695 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
697 (defface gnus-header-subject
700 (:foreground "SeaGreen3"))
703 (:foreground "red4"))
705 (:bold t :italic t)))
706 "Face used for displaying subject headers."
707 :group 'gnus-article-headers
708 :group 'gnus-article-highlight)
709 ;; backward-compatibility alias
710 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
712 (defface gnus-header-newsgroups
715 (:foreground "yellow" :italic t))
718 (:foreground "MidnightBlue" :italic t))
721 "Face used for displaying newsgroups headers.
722 In the default setup this face is only used for crossposted
724 :group 'gnus-article-headers
725 :group 'gnus-article-highlight)
726 ;; backward-compatibility alias
727 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
729 (defface gnus-header-name
732 (:foreground "SeaGreen"))
735 (:foreground "maroon"))
738 "Face used for displaying header names."
739 :group 'gnus-article-headers
740 :group 'gnus-article-highlight)
741 ;; backward-compatibility alias
742 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
744 (defface gnus-header-content
747 (:foreground "forest green" :italic t))
750 (:foreground "indianred4" :italic t))
752 (:italic t))) "Face used for displaying header content."
753 :group 'gnus-article-headers
754 :group 'gnus-article-highlight)
755 ;; backward-compatibility alias
756 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
758 (defcustom gnus-header-face-alist
759 '(("From" nil gnus-header-from)
760 ("Subject" nil gnus-header-subject)
761 ("Newsgroups:.*," nil gnus-header-newsgroups)
762 ("" gnus-header-name gnus-header-content))
763 "*Controls highlighting of article headers.
765 An alist of the form (HEADER NAME CONTENT).
767 HEADER is a regular expression which should match the name of a
768 header and NAME and CONTENT are either face names or nil.
770 The name of each header field will be displayed using the face
771 specified by the first element in the list where HEADER matches
772 the header name and NAME is non-nil. Similarly, the content will
773 be displayed by the first non-nil matching CONTENT face."
774 :group 'gnus-article-headers
775 :group 'gnus-article-highlight
776 :type '(repeat (list (regexp :tag "Header")
778 (item :tag "skip" nil)
779 (face :value default))
780 (choice :tag "Content"
781 (item :tag "skip" nil)
782 (face :value default)))))
784 (defcustom gnus-article-decode-hook
785 '(article-decode-charset article-decode-encoded-words
786 article-decode-group-name article-decode-idna-rhs)
787 "*Hook run to decode charsets in articles."
788 :group 'gnus-article-headers
791 (defcustom gnus-display-mime-function 'gnus-display-mime
792 "Function to display MIME articles."
793 :group 'gnus-article-mime
796 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
797 "Function used to decode headers.")
799 (defvar gnus-article-dumbquotes-map
819 "Table for MS-to-Latin1 translation.")
821 (defcustom gnus-ignored-mime-types nil
822 "List of MIME types that should be ignored by Gnus."
824 :group 'gnus-article-mime
825 :type '(repeat regexp))
827 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
828 "List of MIME types that should not be given buttons when rendered inline.
829 See also `gnus-buttonized-mime-types' which may override this variable.
830 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
832 :group 'gnus-article-mime
833 :type '(repeat regexp))
835 (defcustom gnus-buttonized-mime-types nil
836 "List of MIME types that should be given buttons when rendered inline.
837 If set, this variable overrides `gnus-unbuttonized-mime-types'.
838 To see e.g. security buttons you could set this to
839 `(\"multipart/signed\")'.
840 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
842 :group 'gnus-article-mime
843 :type '(repeat regexp))
845 (defcustom gnus-inhibit-mime-unbuttonizing nil
846 "If non-nil, all MIME parts get buttons.
847 When nil (the default value), then some MIME parts do not get buttons,
848 as described by the variables `gnus-buttonized-mime-types' and
849 `gnus-unbuttonized-mime-types'."
851 :group 'gnus-article-mime
854 (defcustom gnus-body-boundary-delimiter "_"
855 "String used to delimit header and body.
856 This variable is used by `gnus-article-treat-body-boundary' which can
857 be controlled by `gnus-treat-body-boundary'."
859 :group 'gnus-article-various
860 :type '(choice (item :tag "None" :value nil)
863 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
865 "Defines the location of the faces database.
866 For information on obtaining this database of pretty pictures, please
867 see http://www.cs.indiana.edu/picons/ftp/index.html"
869 :type '(repeat directory)
870 :link '(url-link :tag "download"
871 "http://www.cs.indiana.edu/picons/ftp/index.html")
872 :link '(custom-manual "(gnus)Picons")
875 (defun gnus-picons-installed-p ()
876 "Say whether picons are installed on your machine."
877 (let ((installed nil))
878 (dolist (database gnus-picon-databases)
879 (when (file-exists-p database)
883 (defcustom gnus-article-mime-part-function nil
884 "Function called with a MIME handle as the argument.
885 This is meant for people who want to do something automatic based
886 on parts -- for instance, adding Vcard info to a database."
887 :group 'gnus-article-mime
888 :type '(choice (const nil)
891 (defcustom gnus-mime-multipart-functions nil
892 "An alist of MIME types to functions to display them."
894 :group 'gnus-article-mime
895 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
897 (defcustom gnus-article-date-lapsed-new-header nil
898 "Whether the X-Sent and Date headers can coexist.
899 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
900 either replace the old \"Date:\" header (if this variable is nil), or
901 be added below it (otherwise)."
903 :group 'gnus-article-headers
906 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
907 "Function called with a MIME handle as the argument.
908 This is meant for people who want to view first matched part.
909 For `undisplayed-alternative' (default), the first undisplayed
910 part or alternative part is used. For `undisplayed', the first
911 undisplayed part is used. For a function, the first part which
912 the function return t is used. For nil, the first part is
915 :group 'gnus-article-mime
917 (item :tag "first" :value nil)
918 (item :tag "undisplayed" :value undisplayed)
919 (item :tag "undisplayed or alternative"
920 :value undisplayed-alternative)
923 (defcustom gnus-mime-action-alist
924 '(("save to file" . gnus-mime-save-part)
925 ("save and strip" . gnus-mime-save-part-and-strip)
926 ("delete part" . gnus-mime-delete-part)
927 ("display as text" . gnus-mime-inline-part)
928 ("view the part" . gnus-mime-view-part)
929 ("pipe to command" . gnus-mime-pipe-part)
930 ("toggle display" . gnus-article-press-button)
931 ("toggle display" . gnus-article-view-part-as-charset)
932 ("view as type" . gnus-mime-view-part-as-type)
933 ("view internally" . gnus-mime-view-part-internally)
934 ("view externally" . gnus-mime-view-part-externally))
935 "An alist of actions that run on the MIME attachment."
936 :group 'gnus-article-mime
937 :type '(repeat (cons (string :tag "name")
940 (defcustom gnus-auto-select-part 1
941 "Advance to next MIME part when deleting or stripping parts.
943 When 0, point will be placed on the same part as before. When
944 positive (negative), move point forward (backwards) this many
945 parts. When nil, redisplay article."
946 :version "23.0" ;; No Gnus
947 :group 'gnus-article-mime
948 :type '(choice (const nil :tag "Redisplay article.")
949 (const 1 :tag "Next part.")
950 (const 0 :tag "Current part.")
954 ;;; The treatment variables
957 (defvar gnus-part-display-hook nil
958 "Hook called on parts that are to receive treatment.")
960 (defvar gnus-article-treat-custom
961 '(choice (const :tag "Off" nil)
963 (const :tag "Header" head)
964 (const :tag "Last" last)
965 (integer :tag "Less")
966 (repeat :tag "Groups" regexp)
967 (sexp :tag "Predicate")))
969 (defvar gnus-article-treat-head-custom
970 '(choice (const :tag "Off" nil)
971 (const :tag "Header" head)))
973 (defvar gnus-article-treat-types '("text/plain")
976 (defvar gnus-inhibit-treatment nil
977 "Whether to inhibit treatment.")
979 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
980 "Highlight the signature.
981 Valid values are nil, t, `head', `last', an integer or a predicate.
982 See Info node `(gnus)Customizing Articles'."
983 :group 'gnus-article-treat
984 :link '(custom-manual "(gnus)Customizing Articles")
985 :type gnus-article-treat-custom)
986 (put 'gnus-treat-highlight-signature 'highlight t)
988 (defcustom gnus-treat-buttonize 100000
990 Valid values are nil, t, `head', `last', an integer or a predicate.
991 See Info node `(gnus)Customizing Articles'."
992 :group 'gnus-article-treat
993 :link '(custom-manual "(gnus)Customizing Articles")
994 :type gnus-article-treat-custom)
995 (put 'gnus-treat-buttonize 'highlight t)
997 (defcustom gnus-treat-buttonize-head 'head
998 "Add buttons to the head.
999 Valid values are nil, t, `head', `last', an integer or a predicate.
1000 See Info node `(gnus)Customizing Articles' for details."
1001 :group 'gnus-article-treat
1002 :link '(custom-manual "(gnus)Customizing Articles")
1003 :type gnus-article-treat-head-custom)
1004 (put 'gnus-treat-buttonize-head 'highlight t)
1006 (defcustom gnus-treat-emphasize
1007 (and (or window-system
1011 Valid values are nil, t, `head', `last', an integer or a predicate.
1012 See Info node `(gnus)Customizing Articles' for details."
1013 :group 'gnus-article-treat
1014 :link '(custom-manual "(gnus)Customizing Articles")
1015 :type gnus-article-treat-custom)
1016 (put 'gnus-treat-emphasize 'highlight t)
1018 (defcustom gnus-treat-strip-cr nil
1019 "Remove carriage returns.
1020 Valid values are nil, t, `head', `last', an integer or a predicate.
1021 See Info node `(gnus)Customizing Articles' for details."
1023 :group 'gnus-article-treat
1024 :link '(custom-manual "(gnus)Customizing Articles")
1025 :type gnus-article-treat-custom)
1027 (defcustom gnus-treat-unsplit-urls nil
1028 "Remove newlines from within URLs.
1029 Valid values are nil, t, `head', `last', an integer or a predicate.
1030 See Info node `(gnus)Customizing Articles' for details."
1032 :group 'gnus-article-treat
1033 :link '(custom-manual "(gnus)Customizing Articles")
1034 :type gnus-article-treat-custom)
1036 (defcustom gnus-treat-leading-whitespace nil
1037 "Remove leading whitespace in headers.
1038 Valid values are nil, t, `head', `last', an integer or a predicate.
1039 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-headers 'head
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-head-custom)
1053 (defcustom gnus-treat-hide-boring-headers nil
1054 "Hide boring headers.
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-head-custom)
1061 (defcustom gnus-treat-hide-signature nil
1062 "Hide the signature.
1063 Valid values are nil, t, `head', `last', an integer or a predicate.
1064 See Info node `(gnus)Customizing Articles' for details."
1065 :group 'gnus-article-treat
1066 :link '(custom-manual "(gnus)Customizing Articles")
1067 :type gnus-article-treat-custom)
1069 (defcustom gnus-treat-fill-article nil
1071 Valid values are nil, t, `head', `last', an integer or a predicate.
1072 See Info node `(gnus)Customizing Articles' for details."
1073 :group 'gnus-article-treat
1074 :link '(custom-manual "(gnus)Customizing Articles")
1075 :type gnus-article-treat-custom)
1077 (defcustom gnus-treat-hide-citation nil
1079 Valid values are nil, t, `head', `last', an integer or a predicate.
1080 See Info node `(gnus)Customizing Articles' for details."
1081 :group 'gnus-article-treat
1082 :link '(custom-manual "(gnus)Customizing Articles")
1083 :type gnus-article-treat-custom)
1085 (defcustom gnus-treat-hide-citation-maybe nil
1087 Valid values are nil, t, `head', `last', an integer or a predicate.
1088 See Info node `(gnus)Customizing Articles' for details."
1089 :group 'gnus-article-treat
1090 :link '(custom-manual "(gnus)Customizing Articles")
1091 :type gnus-article-treat-custom)
1093 (defcustom gnus-treat-strip-list-identifiers 'head
1094 "Strip list identifiers from `gnus-list-identifiers`.
1095 Valid values are nil, t, `head', `last', an integer or a predicate.
1096 See Info node `(gnus)Customizing Articles' for details."
1098 :group 'gnus-article-treat
1099 :link '(custom-manual "(gnus)Customizing Articles")
1100 :type gnus-article-treat-custom)
1102 (make-obsolete-variable 'gnus-treat-strip-pgp
1103 "This option is obsolete in Gnus 5.10.")
1105 (defcustom gnus-treat-strip-pem nil
1106 "Strip PEM signatures.
1107 Valid values are nil, t, `head', `last', an integer or a predicate.
1108 See Info node `(gnus)Customizing Articles' for details."
1109 :group 'gnus-article-treat
1110 :link '(custom-manual "(gnus)Customizing Articles")
1111 :type gnus-article-treat-custom)
1113 (defcustom gnus-treat-strip-banner t
1114 "Strip banners from articles.
1115 The banner to be stripped is specified in the `banner' group parameter.
1116 Valid values are nil, t, `head', `last', an integer or a predicate.
1117 See Info node `(gnus)Customizing Articles' for details."
1118 :group 'gnus-article-treat
1119 :link '(custom-manual "(gnus)Customizing Articles")
1120 :type gnus-article-treat-custom)
1122 (defcustom gnus-treat-highlight-headers 'head
1123 "Highlight the headers.
1124 Valid values are nil, t, `head', `last', an integer or a predicate.
1125 See Info node `(gnus)Customizing Articles' for details."
1126 :group 'gnus-article-treat
1127 :link '(custom-manual "(gnus)Customizing Articles")
1128 :type gnus-article-treat-head-custom)
1129 (put 'gnus-treat-highlight-headers 'highlight t)
1131 (defcustom gnus-treat-highlight-citation t
1132 "Highlight cited text.
1133 Valid values are nil, t, `head', `last', an integer or a predicate.
1134 See Info node `(gnus)Customizing Articles' for details."
1135 :group 'gnus-article-treat
1136 :link '(custom-manual "(gnus)Customizing Articles")
1137 :type gnus-article-treat-custom)
1138 (put 'gnus-treat-highlight-citation 'highlight t)
1140 (defcustom gnus-treat-date-ut nil
1141 "Display the Date in UT (GMT).
1142 Valid values are nil, t, `head', `last', an integer or a predicate.
1143 See Info node `(gnus)Customizing Articles' for details."
1144 :group 'gnus-article-treat
1145 :link '(custom-manual "(gnus)Customizing Articles")
1146 :type gnus-article-treat-head-custom)
1148 (defcustom gnus-treat-date-local nil
1149 "Display the Date in the local timezone.
1150 Valid values are nil, t, `head', `last', an integer or a predicate.
1151 See Info node `(gnus)Customizing Articles' for details."
1152 :group 'gnus-article-treat
1153 :link '(custom-manual "(gnus)Customizing Articles")
1154 :type gnus-article-treat-head-custom)
1156 (defcustom gnus-treat-date-english nil
1157 "Display the Date in a format that can be read aloud in English.
1158 Valid values are nil, t, `head', `last', an integer or a predicate.
1159 See Info node `(gnus)Customizing Articles' for details."
1161 :group 'gnus-article-treat
1162 :link '(custom-manual "(gnus)Customizing Articles")
1163 :type gnus-article-treat-head-custom)
1165 (defcustom gnus-treat-date-lapsed nil
1166 "Display the Date header in a way that says how much time has elapsed.
1167 Valid values are nil, t, `head', `last', an integer or a predicate.
1168 See Info node `(gnus)Customizing Articles' for details."
1169 :group 'gnus-article-treat
1170 :link '(custom-manual "(gnus)Customizing Articles")
1171 :type gnus-article-treat-head-custom)
1173 (defcustom gnus-treat-date-original nil
1174 "Display the date in the original timezone.
1175 Valid values are nil, t, `head', `last', an integer or a predicate.
1176 See Info node `(gnus)Customizing Articles' for details."
1177 :group 'gnus-article-treat
1178 :link '(custom-manual "(gnus)Customizing Articles")
1179 :type gnus-article-treat-head-custom)
1181 (defcustom gnus-treat-date-iso8601 nil
1182 "Display the date in the ISO8601 format.
1183 Valid values are nil, t, `head', `last', an integer or a predicate.
1184 See Info node `(gnus)Customizing Articles' for details."
1186 :group 'gnus-article-treat
1187 :link '(custom-manual "(gnus)Customizing Articles")
1188 :type gnus-article-treat-head-custom)
1190 (defcustom gnus-treat-date-user-defined nil
1191 "Display the date in a user-defined format.
1192 The format is defined by the `gnus-article-time-format' variable.
1193 Valid values are nil, t, `head', `last', an integer or a predicate.
1194 See Info node `(gnus)Customizing Articles' for details."
1195 :group 'gnus-article-treat
1196 :link '(custom-manual "(gnus)Customizing Articles")
1197 :type gnus-article-treat-head-custom)
1199 (defcustom gnus-treat-strip-headers-in-body t
1200 "Strip the X-No-Archive header line from the beginning of the body.
1201 Valid values are nil, t, `head', `last', an integer or a predicate.
1202 See Info node `(gnus)Customizing Articles' for details."
1204 :group 'gnus-article-treat
1205 :link '(custom-manual "(gnus)Customizing Articles")
1206 :type gnus-article-treat-custom)
1208 (defcustom gnus-treat-strip-trailing-blank-lines nil
1209 "Strip trailing blank lines.
1210 Valid values are nil, t, `head', `last', an integer or a predicate.
1211 See Info node `(gnus)Customizing Articles' for details."
1212 :group 'gnus-article-treat
1213 :link '(custom-manual "(gnus)Customizing Articles")
1214 :type gnus-article-treat-custom)
1216 (defcustom gnus-treat-strip-leading-blank-lines nil
1217 "Strip leading blank lines.
1218 Valid values are nil, t, `head', `last', an integer or a predicate.
1219 See Info node `(gnus)Customizing Articles' for details."
1220 :group 'gnus-article-treat
1221 :link '(custom-manual "(gnus)Customizing Articles")
1222 :type gnus-article-treat-custom)
1224 (defcustom gnus-treat-strip-multiple-blank-lines nil
1225 "Strip multiple blank lines.
1226 Valid values are nil, t, `head', `last', an integer or a predicate.
1227 See Info node `(gnus)Customizing Articles' for details."
1228 :group 'gnus-article-treat
1229 :link '(custom-manual "(gnus)Customizing Articles")
1230 :type gnus-article-treat-custom)
1232 (defcustom gnus-treat-unfold-headers 'head
1233 "Unfold folded header lines.
1234 Valid values are nil, t, `head', `last', an integer or a predicate.
1235 See Info node `(gnus)Customizing Articles' for details."
1237 :group 'gnus-article-treat
1238 :link '(custom-manual "(gnus)Customizing Articles")
1239 :type gnus-article-treat-custom)
1241 (defcustom gnus-treat-fold-headers nil
1243 Valid values are nil, t, `head', `last', an integer or a predicate.
1244 See Info node `(gnus)Customizing Articles' for details."
1246 :group 'gnus-article-treat
1247 :link '(custom-manual "(gnus)Customizing Articles")
1248 :type gnus-article-treat-custom)
1250 (defcustom gnus-treat-fold-newsgroups 'head
1251 "Fold the Newsgroups and Followup-To headers.
1252 Valid values are nil, t, `head', `last', an integer or a predicate.
1253 See Info node `(gnus)Customizing Articles' for details."
1255 :group 'gnus-article-treat
1256 :link '(custom-manual "(gnus)Customizing Articles")
1257 :type gnus-article-treat-custom)
1259 (defcustom gnus-treat-overstrike t
1260 "Treat overstrike highlighting.
1261 Valid values are nil, t, `head', `last', an integer or a predicate.
1262 See Info node `(gnus)Customizing Articles' for details."
1263 :group 'gnus-article-treat
1264 :link '(custom-manual "(gnus)Customizing Articles")
1265 :type gnus-article-treat-custom)
1266 (put 'gnus-treat-overstrike 'highlight t)
1268 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1269 "Treat ANSI SGR control sequences.
1270 Valid values are nil, t, `head', `last', an integer or a predicate.
1271 See Info node `(gnus)Customizing Articles' for details."
1272 :group 'gnus-article-treat
1273 :link '(custom-manual "(gnus)Customizing Articles")
1274 :type gnus-article-treat-custom)
1276 (make-obsolete-variable 'gnus-treat-display-xface
1277 'gnus-treat-display-x-face)
1279 (defcustom gnus-treat-display-x-face
1280 (and (not noninteractive)
1281 (or (and (fboundp 'image-type-available-p)
1282 (image-type-available-p 'xbm)
1283 (string-match "^0x" (shell-command-to-string "uncompface"))
1284 (executable-find "icontopbm"))
1285 (and (featurep 'xemacs)
1288 "Display X-Face headers.
1289 Valid values are nil, t, `head', `last', an integer or a predicate.
1290 See Info node `(gnus)Customizing Articles' and Info node
1291 `(gnus)X-Face' for details."
1292 :group 'gnus-article-treat
1294 :link '(custom-manual "(gnus)Customizing Articles")
1295 :link '(custom-manual "(gnus)X-Face")
1296 :type gnus-article-treat-head-custom
1297 :set (lambda (symbol value)
1300 (cond ((or (boundp symbol) (get symbol 'saved-value))
1302 ((boundp 'gnus-treat-display-xface)
1304 ** gnus-treat-display-xface is an obsolete variable;\
1305 use gnus-treat-display-x-face instead")
1306 (default-value 'gnus-treat-display-xface))
1307 ((get 'gnus-treat-display-xface 'saved-value)
1309 ** gnus-treat-display-xface is an obsolete variable;\
1310 use gnus-treat-display-x-face instead")
1311 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1314 (put 'gnus-treat-display-x-face 'highlight t)
1316 (defcustom gnus-treat-display-face
1317 (and (not noninteractive)
1318 (or (and (fboundp 'image-type-available-p)
1319 (image-type-available-p 'png))
1320 (and (featurep 'xemacs)
1323 "Display Face headers.
1324 Valid values are nil, t, `head', `last', an integer or a predicate.
1325 See Info node `(gnus)Customizing Articles' and Info node
1326 `(gnus)X-Face' for details."
1327 :group 'gnus-article-treat
1329 :link '(custom-manual "(gnus)Customizing Articles")
1330 :link '(custom-manual "(gnus)X-Face")
1331 :type gnus-article-treat-head-custom)
1332 (put 'gnus-treat-display-face 'highlight t)
1334 (defcustom gnus-treat-display-smileys
1335 (if (or (and (featurep 'xemacs)
1337 (and (fboundp 'image-type-available-p)
1338 (image-type-available-p 'pbm)))
1341 Valid values are nil, t, `head', `last', an integer or a predicate.
1342 See Info node `(gnus)Customizing Articles' and Info node
1343 `(gnus)Smileys' for details."
1344 :group 'gnus-article-treat
1346 :link '(custom-manual "(gnus)Customizing Articles")
1347 :link '(custom-manual "(gnus)Smileys")
1348 :type gnus-article-treat-custom)
1349 (put 'gnus-treat-display-smileys 'highlight t)
1351 (defcustom gnus-treat-from-picon
1352 (if (and (gnus-image-type-available-p 'xpm)
1353 (gnus-picons-installed-p))
1355 "Display picons in the From header.
1356 Valid values are nil, t, `head', `last', an integer or a predicate.
1357 See Info node `(gnus)Customizing Articles' and Info node
1358 `(gnus)Picons' for details."
1360 :group 'gnus-article-treat
1362 :link '(custom-manual "(gnus)Customizing Articles")
1363 :link '(custom-manual "(gnus)Picons")
1364 :type gnus-article-treat-head-custom)
1365 (put 'gnus-treat-from-picon 'highlight t)
1367 (defcustom gnus-treat-mail-picon
1368 (if (and (gnus-image-type-available-p 'xpm)
1369 (gnus-picons-installed-p))
1371 "Display picons in To and Cc headers.
1372 Valid values are nil, t, `head', `last', an integer or a predicate.
1373 See Info node `(gnus)Customizing Articles' and Info node
1374 `(gnus)Picons' for details."
1376 :group 'gnus-article-treat
1378 :link '(custom-manual "(gnus)Customizing Articles")
1379 :link '(custom-manual "(gnus)Picons")
1380 :type gnus-article-treat-head-custom)
1381 (put 'gnus-treat-mail-picon 'highlight t)
1383 (defcustom gnus-treat-newsgroups-picon
1384 (if (and (gnus-image-type-available-p 'xpm)
1385 (gnus-picons-installed-p))
1387 "Display picons in the Newsgroups and Followup-To headers.
1388 Valid values are nil, t, `head', `last', an integer or a predicate.
1389 See Info node `(gnus)Customizing Articles' and Info node
1390 `(gnus)Picons' for details."
1392 :group 'gnus-article-treat
1394 :link '(custom-manual "(gnus)Customizing Articles")
1395 :link '(custom-manual "(gnus)Picons")
1396 :type gnus-article-treat-head-custom)
1397 (put 'gnus-treat-newsgroups-picon 'highlight t)
1399 (defcustom gnus-treat-body-boundary
1400 (if (and (eq window-system 'x)
1401 (or gnus-treat-newsgroups-picon
1402 gnus-treat-mail-picon
1403 gnus-treat-from-picon))
1405 "Draw a boundary at the end of the headers.
1406 Valid values are nil and `head'.
1407 See Info node `(gnus)Customizing Articles' for details."
1409 :group 'gnus-article-treat
1410 :link '(custom-manual "(gnus)Customizing Articles")
1411 :type gnus-article-treat-head-custom)
1413 (defcustom gnus-treat-capitalize-sentences nil
1414 "Capitalize sentence-starting words.
1415 Valid values are nil, t, `head', `last', an integer or a predicate.
1416 See Info node `(gnus)Customizing Articles' for details."
1418 :group 'gnus-article-treat
1419 :link '(custom-manual "(gnus)Customizing Articles")
1420 :type gnus-article-treat-custom)
1422 (defcustom gnus-treat-wash-html nil
1424 Valid values are nil, t, `head', `last', an integer or a predicate.
1425 See Info node `(gnus)Customizing Articles' for details."
1427 :group 'gnus-article-treat
1428 :link '(custom-manual "(gnus)Customizing Articles")
1429 :type gnus-article-treat-custom)
1431 (defcustom gnus-treat-fill-long-lines nil
1433 Valid values are nil, t, `head', `last', an integer or a predicate.
1434 See Info node `(gnus)Customizing Articles' for details."
1435 :group 'gnus-article-treat
1436 :link '(custom-manual "(gnus)Customizing Articles")
1437 :type gnus-article-treat-custom)
1439 (defcustom gnus-treat-play-sounds nil
1441 Valid values are nil, t, `head', `last', an integer or a predicate.
1442 See Info node `(gnus)Customizing Articles' for details."
1444 :group 'gnus-article-treat
1445 :link '(custom-manual "(gnus)Customizing Articles")
1446 :type gnus-article-treat-custom)
1448 (defcustom gnus-treat-translate nil
1449 "Translate articles from one language to another.
1450 Valid values are nil, t, `head', `last', an integer or a predicate.
1451 See Info node `(gnus)Customizing Articles' for details."
1453 :group 'gnus-article-treat
1454 :link '(custom-manual "(gnus)Customizing Articles")
1455 :type gnus-article-treat-custom)
1457 (defcustom gnus-treat-x-pgp-sig nil
1459 To automatically treat X-PGP-Sig, set it to head.
1460 Valid values are nil, t, `head', `last', an integer or a predicate.
1461 See Info node `(gnus)Customizing Articles' for details."
1463 :group 'gnus-article-treat
1464 :group 'mime-security
1465 :link '(custom-manual "(gnus)Customizing Articles")
1466 :type gnus-article-treat-custom)
1468 (defvar gnus-article-encrypt-protocol-alist
1469 '(("PGP" . mml2015-self-encrypt)))
1471 ;; Set to nil if more than one protocol added to
1472 ;; gnus-article-encrypt-protocol-alist.
1473 (defcustom gnus-article-encrypt-protocol "PGP"
1474 "The protocol used for encrypt articles.
1475 It is a string, such as \"PGP\". If nil, ask user."
1478 :group 'mime-security)
1480 (defvar gnus-article-wash-function nil
1481 "Function used for converting HTML into text.")
1483 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1484 (mm-coding-system-p 'utf-8)
1485 (executable-find idna-program))
1486 "Whether IDNA decoding of headers is used when viewing messages.
1487 This requires GNU Libidn, and by default only enabled if it is found."
1489 :group 'gnus-article-headers
1492 (defcustom gnus-article-over-scroll nil
1493 "If non-nil, allow scrolling the article buffer even when there no more text."
1495 :group 'gnus-article
1498 ;;; Internal variables
1500 (defvar gnus-english-month-names
1501 '("January" "February" "March" "April" "May" "June" "July" "August"
1502 "September" "October" "November" "December"))
1504 (defvar gnus-button-regexp nil)
1505 (defvar gnus-button-marker-list nil)
1506 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1508 (defvar gnus-button-last nil)
1509 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1511 (defvar article-goto-body-goes-to-point-min-p nil)
1512 (defvar gnus-article-wash-types nil)
1513 (defvar gnus-article-emphasis-alist nil)
1514 (defvar gnus-article-image-alist nil)
1516 (defvar gnus-article-mime-handle-alist-1 nil)
1517 (defvar gnus-treatment-function-alist
1518 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1519 (gnus-treat-strip-banner gnus-article-strip-banner)
1520 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1521 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1522 (gnus-treat-buttonize gnus-article-add-buttons)
1523 (gnus-treat-fill-article gnus-article-fill-cited-article)
1524 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1525 (gnus-treat-strip-cr gnus-article-remove-cr)
1526 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1527 (gnus-treat-date-ut gnus-article-date-ut)
1528 (gnus-treat-date-local gnus-article-date-local)
1529 (gnus-treat-date-english gnus-article-date-english)
1530 (gnus-treat-date-original gnus-article-date-original)
1531 (gnus-treat-date-user-defined gnus-article-date-user)
1532 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1533 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1534 (gnus-treat-display-x-face gnus-article-display-x-face)
1535 (gnus-treat-display-face gnus-article-display-face)
1536 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1537 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1538 (gnus-treat-hide-signature gnus-article-hide-signature)
1539 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1540 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1541 (gnus-treat-strip-pem gnus-article-hide-pem)
1542 (gnus-treat-from-picon gnus-treat-from-picon)
1543 (gnus-treat-mail-picon gnus-treat-mail-picon)
1544 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1545 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1546 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1547 (gnus-treat-strip-trailing-blank-lines
1548 gnus-article-remove-trailing-blank-lines)
1549 (gnus-treat-strip-leading-blank-lines
1550 gnus-article-strip-leading-blank-lines)
1551 (gnus-treat-strip-multiple-blank-lines
1552 gnus-article-strip-multiple-blank-lines)
1553 (gnus-treat-overstrike gnus-article-treat-overstrike)
1554 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1555 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1556 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1557 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1558 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1559 (gnus-treat-display-smileys gnus-treat-smiley)
1560 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1561 (gnus-treat-wash-html gnus-article-wash-html)
1562 (gnus-treat-emphasize gnus-article-emphasize)
1563 (gnus-treat-hide-citation gnus-article-hide-citation)
1564 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1565 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1566 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1567 (gnus-treat-play-sounds gnus-earcon-display)))
1569 (defvar gnus-article-mime-handle-alist nil)
1570 (defvar article-lapsed-timer nil)
1571 (defvar gnus-article-current-summary nil)
1573 (defvar gnus-article-mode-syntax-table
1574 (let ((table (copy-syntax-table text-mode-syntax-table)))
1575 ;; This causes the citation match run O(2^n).
1576 ;; (modify-syntax-entry ?- "w" table)
1577 (modify-syntax-entry ?> ")<" table)
1578 (modify-syntax-entry ?< "(>" table)
1579 ;; make M-. in article buffers work for `foo' strings
1580 (modify-syntax-entry ?' " " table)
1581 (modify-syntax-entry ?` " " table)
1583 "Syntax table used in article mode buffers.
1584 Initialized from `text-mode-syntax-table.")
1586 (defvar gnus-save-article-buffer nil)
1588 (defvar gnus-article-mode-line-format-alist
1589 (nconc '((?w (gnus-article-wash-status) ?s)
1590 (?m (gnus-article-mime-part-status) ?s))
1591 gnus-summary-mode-line-format-alist))
1593 (defvar gnus-number-of-articles-to-be-saved nil)
1595 (defvar gnus-inhibit-hiding nil)
1597 (defvar gnus-article-edit-mode nil)
1599 ;;; Macros for dealing with the article buffer.
1601 (defmacro gnus-with-article-headers (&rest forms)
1603 (set-buffer gnus-article-buffer)
1605 (let ((inhibit-read-only t)
1606 (inhibit-point-motion-hooks t)
1607 (case-fold-search t))
1608 (article-narrow-to-head)
1611 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1612 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1614 (defmacro gnus-with-article-buffer (&rest forms)
1616 (set-buffer gnus-article-buffer)
1617 (let ((inhibit-read-only t))
1620 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1621 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1623 (defun gnus-article-goto-header (header)
1624 "Go to HEADER, which is a regular expression."
1625 (re-search-forward (concat "^\\(" header "\\):") nil t))
1627 (defsubst gnus-article-hide-text (b e props)
1628 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1629 (gnus-add-text-properties-when 'article-type nil b e props)
1630 (when (memq 'intangible props)
1632 (max (1- b) (point-min))
1633 b 'intangible (cddr (memq 'intangible props)))))
1635 (defsubst gnus-article-unhide-text (b e)
1636 "Remove hidden text properties from region between B and E."
1637 (remove-text-properties b e gnus-hidden-properties)
1638 (when (memq 'intangible gnus-hidden-properties)
1639 (put-text-property (max (1- b) (point-min))
1640 b 'intangible nil)))
1642 (defun gnus-article-hide-text-type (b e type)
1643 "Hide text of TYPE between B and E."
1644 (gnus-add-wash-type type)
1645 (gnus-article-hide-text
1646 b e (cons 'article-type (cons type gnus-hidden-properties))))
1648 (defun gnus-article-unhide-text-type (b e type)
1649 "Unhide text of TYPE between B and E."
1650 (gnus-delete-wash-type type)
1651 (remove-text-properties
1652 b e (cons 'article-type (cons type gnus-hidden-properties)))
1653 (when (memq 'intangible gnus-hidden-properties)
1654 (put-text-property (max (1- b) (point-min))
1655 b 'intangible nil)))
1657 (defun gnus-article-hide-text-of-type (type)
1658 "Hide text of TYPE in the current buffer."
1660 (let ((b (point-min))
1662 (while (setq b (text-property-any b e 'article-type type))
1663 (add-text-properties b (incf b) gnus-hidden-properties)))))
1665 (defun gnus-article-delete-text-of-type (type)
1666 "Delete text of TYPE in the current buffer."
1668 (let ((b (point-min)))
1669 (while (setq b (text-property-any b (point-max) 'article-type type))
1671 b (or (text-property-not-all b (point-max) 'article-type type)
1674 (defun gnus-article-delete-invisible-text ()
1675 "Delete all invisible text in the current buffer."
1677 (let ((b (point-min)))
1678 (while (setq b (text-property-any b (point-max) 'invisible t))
1680 b (or (text-property-not-all b (point-max) 'invisible t)
1683 (defun gnus-article-text-type-exists-p (type)
1684 "Say whether any text of type TYPE exists in the buffer."
1685 (text-property-any (point-min) (point-max) 'article-type type))
1687 (defsubst gnus-article-header-rank ()
1688 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1689 (let ((list gnus-sorted-header-list)
1692 (if (looking-at (car list))
1694 (setq list (cdr list))
1698 (defun article-hide-headers (&optional arg delete)
1699 "Hide unwanted headers and possibly sort them as well."
1701 ;; This function might be inhibited.
1702 (unless gnus-inhibit-hiding
1703 (let ((inhibit-read-only nil)
1704 (case-fold-search t)
1705 (max (1+ (length gnus-sorted-header-list)))
1706 (inhibit-point-motion-hooks t)
1707 (cur (current-buffer))
1708 ignored visible beg)
1710 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1711 ;; group parameters, so we should go to the summary buffer.
1714 (progn (set-buffer gnus-summary-buffer) t)
1716 (setq ignored (when (not gnus-visible-headers)
1717 (cond ((stringp gnus-ignored-headers)
1718 gnus-ignored-headers)
1719 ((listp gnus-ignored-headers)
1720 (mapconcat 'identity
1721 gnus-ignored-headers
1723 visible (cond ((stringp gnus-visible-headers)
1724 gnus-visible-headers)
1725 ((and gnus-visible-headers
1726 (listp gnus-visible-headers))
1727 (mapconcat 'identity
1728 gnus-visible-headers
1732 ;; First we narrow to just the headers.
1733 (article-narrow-to-head)
1734 ;; Hide any "From " lines at the beginning of (mail) articles.
1735 (while (looking-at "From ")
1738 (delete-region (point-min) (point)))
1739 ;; Then treat the rest of the header lines.
1740 ;; Then we use the two regular expressions
1741 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1742 ;; select which header lines is to remain visible in the
1744 (while (re-search-forward "^[^ \t:]*:" nil t)
1746 ;; Mark the rank of the header.
1748 (point) (1+ (point)) 'message-rank
1749 (if (or (and visible (looking-at visible))
1751 (not (looking-at ignored))))
1752 (gnus-article-header-rank)
1755 (message-sort-headers-1)
1756 (when (setq beg (text-property-any
1757 (point-min) (point-max) 'message-rank (+ 2 max)))
1758 ;; We delete the unwanted headers.
1759 (gnus-add-wash-type 'headers)
1760 (add-text-properties (point-min) (+ 5 (point-min))
1761 '(article-type headers dummy-invisible t))
1762 (delete-region beg (point-max))))))))
1764 (defun article-hide-boring-headers (&optional arg)
1765 "Toggle hiding of headers that aren't very interesting.
1766 If given a negative prefix, always show; if given a positive prefix,
1768 (interactive (gnus-article-hidden-arg))
1769 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1770 (not gnus-show-all-headers))
1773 (let ((inhibit-read-only t)
1774 (inhibit-point-motion-hooks t))
1775 (article-narrow-to-head)
1776 (dolist (elem gnus-boring-article-headers)
1777 (goto-char (point-min))
1779 ;; Hide empty headers.
1781 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1783 (gnus-article-hide-text-type
1787 (if (re-search-forward "^[^ \t]" nil t)
1791 ;; Hide boring Newsgroups header.
1792 ((eq elem 'newsgroups)
1793 (when (gnus-string-equal
1794 (gnus-fetch-field "newsgroups")
1795 (gnus-group-real-name
1796 (if (boundp 'gnus-newsgroup-name)
1799 (gnus-article-hide-header "newsgroups")))
1800 ((eq elem 'to-address)
1801 (let ((to (message-fetch-field "to"))
1803 (gnus-parameter-to-address
1804 (if (boundp 'gnus-newsgroup-name)
1805 gnus-newsgroup-name ""))))
1806 (when (and to to-address
1809 ;; only one address in To
1810 (nth 1 (mail-extract-address-components to))
1812 (gnus-article-hide-header "to"))))
1814 (let ((to (message-fetch-field "to"))
1816 (gnus-parameter-to-list
1817 (if (boundp 'gnus-newsgroup-name)
1818 gnus-newsgroup-name ""))))
1819 (when (and to to-list
1822 ;; only one address in To
1823 (nth 1 (mail-extract-address-components to))
1825 (gnus-article-hide-header "to"))))
1827 (let ((cc (message-fetch-field "cc"))
1829 (gnus-parameter-to-list
1830 (if (boundp 'gnus-newsgroup-name)
1831 gnus-newsgroup-name ""))))
1832 (when (and cc to-list
1835 ;; only one address in CC
1836 (nth 1 (mail-extract-address-components cc))
1838 (gnus-article-hide-header "cc"))))
1839 ((eq elem 'followup-to)
1840 (when (gnus-string-equal
1841 (message-fetch-field "followup-to")
1842 (message-fetch-field "newsgroups"))
1843 (gnus-article-hide-header "followup-to")))
1844 ((eq elem 'reply-to)
1845 (if (gnus-group-find-parameter
1846 gnus-newsgroup-name 'broken-reply-to)
1847 (gnus-article-hide-header "reply-to")
1848 (let ((from (message-fetch-field "from"))
1849 (reply-to (message-fetch-field "reply-to")))
1856 (lambda (x) (downcase (cadr x)))
1857 (mail-extract-address-components from t))
1860 (lambda (x) (downcase (cadr x)))
1861 (mail-extract-address-components reply-to t))
1863 (gnus-article-hide-header "reply-to")))))
1865 (let ((date (message-fetch-field "date")))
1867 (< (days-between (current-time-string) date)
1869 (gnus-article-hide-header "date"))))
1871 (let ((to (message-fetch-field "to"))
1872 (cc (message-fetch-field "cc")))
1873 (when (> (length to) 1024)
1874 (gnus-article-hide-header "to"))
1875 (when (> (length cc) 1024)
1876 (gnus-article-hide-header "cc"))))
1880 (goto-char (point-min))
1881 (while (re-search-forward "^to:" nil t)
1882 (setq to-count (1+ to-count)))
1883 (when (> to-count 1)
1884 (while (> to-count 0)
1885 (goto-char (point-min))
1887 (re-search-forward "^to:" nil nil to-count)
1889 (narrow-to-region (point) (point-max))
1890 (gnus-article-hide-header "to"))
1891 (setq to-count (1- to-count))))
1892 (goto-char (point-min))
1893 (while (re-search-forward "^cc:" nil t)
1894 (setq cc-count (1+ cc-count)))
1895 (when (> cc-count 1)
1896 (while (> cc-count 0)
1897 (goto-char (point-min))
1899 (re-search-forward "^cc:" nil nil cc-count)
1901 (narrow-to-region (point) (point-max))
1902 (gnus-article-hide-header "cc"))
1903 (setq cc-count (1- cc-count)))))))))))))
1905 (defun gnus-article-hide-header (header)
1907 (goto-char (point-min))
1908 (when (re-search-forward (concat "^" header ":") nil t)
1909 (gnus-article-hide-text-type
1913 (if (re-search-forward "^[^ \t]" nil t)
1918 (defvar gnus-article-normalized-header-length 40
1919 "Length of normalized headers.")
1921 (defun article-normalize-headers ()
1922 "Make all header lines 40 characters long."
1924 (let ((inhibit-read-only t)
1928 (article-narrow-to-head)
1931 ((< (setq column (- (point-at-eol) (point)))
1932 gnus-article-normalized-header-length)
1934 (insert (make-string
1935 (- gnus-article-normalized-header-length column)
1937 ((> column gnus-article-normalized-header-length)
1938 (gnus-put-text-property
1940 (forward-char gnus-article-normalized-header-length)
1947 (forward-line 1))))))
1949 (defun article-treat-dumbquotes ()
1950 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1951 Note that this function guesses whether a character is a sm*rtq**t* or
1952 not, so it should only be used interactively.
1954 Sm*rtq**t*s are M****s***'s unilateral extension to the
1955 iso-8859-1 character map in an attempt to provide more quoting
1956 characters. If you see something like \\222 or \\264 where
1957 you're expecting some kind of apostrophe or quotation mark, then
1960 (article-translate-strings gnus-article-dumbquotes-map))
1962 (defun article-translate-characters (from to)
1963 "Translate all characters in the body of the article according to FROM and TO.
1964 FROM is a string of characters to translate from; to is a string of
1965 characters to translate to."
1967 (when (article-goto-body)
1968 (let ((inhibit-read-only t)
1969 (x (make-string 225 ?x))
1971 (while (< (incf i) (length x))
1974 (while (< i (length from))
1975 (aset x (aref from i) (aref to i))
1977 (translate-region (point) (point-max) x)))))
1979 (defun article-translate-strings (map)
1980 "Translate all string in the body of the article according to MAP.
1981 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1983 (when (article-goto-body)
1984 (let ((inhibit-read-only t))
1987 (while (search-forward (car elem) nil t)
1988 (replace-match (cadr elem)))))))))
1990 (defun article-treat-overstrike ()
1991 "Translate overstrikes into bold text."
1994 (when (article-goto-body)
1995 (let ((inhibit-read-only t))
1996 (while (search-forward "\b" nil t)
1997 (let ((next (char-after))
1998 (previous (char-after (- (point) 2))))
1999 ;; We do the boldification/underlining by hiding the
2000 ;; overstrikes and putting the proper text property
2004 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2005 (put-text-property (point) (1+ (point)) 'face 'bold))
2007 (gnus-article-hide-text-type
2008 (1- (point)) (1+ (point)) 'overstrike)
2010 (- (point) 2) (1- (point)) 'face 'underline))
2012 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2014 (point) (1+ (point)) 'face 'underline)))))))))
2016 (defun article-treat-ansi-sequences ()
2017 "Translate ANSI SGR control sequences into overlays or extents."
2020 (when (article-goto-body)
2021 (let ((inhibit-read-only t))
2022 (ansi-color-apply-on-region (point) (point-max))))))
2024 (defun gnus-article-treat-unfold-headers ()
2025 "Unfold folded message headers.
2026 Only the headers that fit into the current window width will be
2029 (gnus-with-article-headers
2033 (mail-header-narrow-to-field)
2034 (let ((header (buffer-string)))
2037 (goto-char (point-min))
2038 (while (re-search-forward "\n[\t ]" nil t)
2039 (replace-match " " t t)))
2040 (setq length (- (point-max) (point-min) 1)))
2041 (when (< length (window-width))
2042 (while (re-search-forward "\n[\t ]" nil t)
2043 (replace-match " " t t)))
2044 (goto-char (point-max)))))))
2046 (defun gnus-article-treat-fold-headers ()
2047 "Fold message headers."
2049 (gnus-with-article-headers
2052 (mail-header-narrow-to-field)
2053 (mail-header-fold-field)
2054 (goto-char (point-max))))))
2056 (defun gnus-treat-smiley ()
2057 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2059 (gnus-with-article-buffer
2060 (if (memq 'smiley gnus-article-wash-types)
2061 (gnus-delete-images 'smiley)
2063 (let ((images (smiley-region (point) (point-max))))
2065 (gnus-add-wash-type 'smiley)
2066 (dolist (image images)
2067 (gnus-add-image 'smiley image)))))))
2069 (defun gnus-article-remove-images ()
2070 "Remove all images from the article buffer."
2072 (gnus-with-article-buffer
2073 (dolist (elem gnus-article-image-alist)
2074 (gnus-delete-images (car elem)))))
2076 (defun gnus-article-treat-fold-newsgroups ()
2077 "Unfold folded message headers.
2078 Only the headers that fit into the current window width will be
2081 (gnus-with-article-headers
2082 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2084 (mail-header-narrow-to-field)
2085 (while (re-search-forward ", *" nil t)
2086 (replace-match ", " t t))
2087 (mail-header-fold-field)
2088 (goto-char (point-max))))))
2090 (defun gnus-article-treat-body-boundary ()
2091 "Place a boundary line at the end of the headers."
2093 (when (and gnus-body-boundary-delimiter
2094 (> (length gnus-body-boundary-delimiter) 0))
2095 (gnus-with-article-headers
2096 (goto-char (point-max))
2097 (let ((start (point)))
2098 (insert "X-Boundary: ")
2099 (gnus-add-text-properties start (point) '(invisible t intangible t))
2101 (while (>= (1- (window-width)) (length str))
2102 (setq str (concat str gnus-body-boundary-delimiter)))
2103 (substring str 0 (1- (window-width))))
2105 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2107 (defun article-fill-long-lines ()
2108 "Fill lines that are wider than the window width."
2111 (let ((inhibit-read-only t)
2112 (width (window-width (get-buffer-window (current-buffer)))))
2115 (let ((adaptive-fill-mode nil)) ;Why? -sm
2118 (when (>= (current-column) (min fill-column width))
2119 (narrow-to-region (min (1+ (point)) (point-max))
2121 (let ((goback (point-marker)))
2122 (fill-paragraph nil)
2123 (goto-char (marker-position goback)))
2125 (forward-line 1)))))))
2127 (defun article-capitalize-sentences ()
2128 "Capitalize the first word in each sentence."
2131 (let ((inhibit-read-only t)
2132 (paragraph-start "^[\n\^L]"))
2136 (forward-sentence)))))
2138 (defun article-remove-cr ()
2139 "Remove trailing CRs and then translate remaining CRs into LFs."
2142 (let ((inhibit-read-only t))
2143 (goto-char (point-min))
2144 (while (re-search-forward "\r+$" nil t)
2145 (replace-match "" t t))
2146 (goto-char (point-min))
2147 (while (search-forward "\r" nil t)
2148 (replace-match "\n" t t)))))
2150 (defun article-remove-trailing-blank-lines ()
2151 "Remove all trailing blank lines from the article."
2154 (let ((inhibit-read-only t))
2155 (goto-char (point-max))
2159 (while (and (not (bobp))
2160 (looking-at "^[ \t]*$")
2161 (not (gnus-annotation-in-region-p
2162 (point) (point-at-eol))))
2168 (defvar gnus-face-properties-alist))
2170 (defun article-display-face ()
2171 "Display any Face headers in the header."
2173 (let ((wash-face-p buffer-read-only))
2174 (gnus-with-article-headers
2175 ;; When displaying parts, this function can be called several times on
2176 ;; the same article, without any intended toggle semantic (as typing `W
2177 ;; D d' would have). So face deletion must occur only when we come from
2178 ;; an interactive command, that is when the *Article* buffer is
2180 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2181 (gnus-delete-images 'face)
2182 (let (face faces from)
2183 (save-current-buffer
2184 (when (and wash-face-p
2185 (gnus-buffer-live-p gnus-original-article-buffer)
2186 (not (re-search-forward "^Face:[\t ]*" nil t)))
2187 (set-buffer gnus-original-article-buffer))
2189 (mail-narrow-to-head)
2190 (while (gnus-article-goto-header "Face")
2191 (push (mail-header-field-value) faces))))
2193 (goto-char (point-min))
2194 (let ((from (gnus-article-goto-header "from"))
2199 (insert "[no `from' set]\n"))
2201 (when (setq png (gnus-convert-face-to-png (pop faces)))
2203 (apply 'gnus-create-image png 'png t
2204 (cdr (assq 'png gnus-face-properties-alist))))
2206 (gnus-add-wash-type 'face)
2207 (gnus-add-image 'face image)
2208 (gnus-put-image image nil 'face))))))))))
2210 (defun article-display-x-face (&optional force)
2211 "Look for an X-Face header and display it if present."
2212 (interactive (list 'force))
2213 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2214 (gnus-with-article-headers
2215 ;; Delete the old process, if any.
2216 (when (process-status "article-x-face")
2217 (delete-process "article-x-face"))
2218 ;; See the comment in `article-display-face'.
2219 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2220 ;; We have already displayed X-Faces, so we remove them
2222 (gnus-delete-images 'xface)
2224 (let (x-faces from face)
2225 (save-current-buffer
2226 (when (and wash-face-p
2227 (gnus-buffer-live-p gnus-original-article-buffer)
2228 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2229 ;; If type `W f', use gnus-original-article-buffer,
2230 ;; otherwise use the current buffer because displaying
2231 ;; RFC822 parts calls this function too.
2232 (set-buffer gnus-original-article-buffer))
2234 (mail-narrow-to-head)
2235 (while (gnus-article-goto-header "X-Face")
2236 (push (mail-header-field-value) x-faces))
2237 (setq from (message-fetch-field "from"))))
2238 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2239 ;; single external face.
2240 (when (stringp gnus-article-x-face-command)
2241 (setq x-faces (list (car x-faces))))
2243 gnus-article-x-face-command
2245 ;; Check whether this face is censored.
2246 (not gnus-article-x-face-too-ugly)
2248 (not (string-match gnus-article-x-face-too-ugly
2250 (while (setq face (pop x-faces))
2251 ;; We display the face.
2252 (cond ((stringp gnus-article-x-face-command)
2253 ;; The command is a string, so we interpret the command
2254 ;; as a, well, command, and fork it off.
2255 (let ((process-connection-type nil))
2256 (gnus-set-process-query-on-exit-flag
2258 "article-x-face" nil shell-file-name
2259 shell-command-switch gnus-article-x-face-command)
2263 (process-send-region "article-x-face"
2264 (point-min) (point-max)))
2265 (process-send-eof "article-x-face")))
2266 ((functionp gnus-article-x-face-command)
2267 ;; The command is a lisp function, so we call it.
2268 (funcall gnus-article-x-face-command face))
2270 (error "%s is not a function"
2271 gnus-article-x-face-command))))))))))
2273 (defun article-decode-mime-words ()
2274 "Decode all MIME-encoded words in the article."
2276 (gnus-with-article-buffer
2277 (let ((inhibit-point-motion-hooks t)
2278 (mail-parse-charset gnus-newsgroup-charset)
2279 (mail-parse-ignored-charsets
2280 (with-current-buffer gnus-summary-buffer
2281 gnus-newsgroup-ignored-charsets)))
2282 (mail-decode-encoded-word-region (point-min) (point-max)))))
2284 (defun article-decode-charset (&optional prompt)
2285 "Decode charset-encoded text in the article.
2286 If PROMPT (the prefix), prompt for a coding system to use."
2288 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2289 (inhibit-read-only t)
2290 (mail-parse-charset gnus-newsgroup-charset)
2291 (mail-parse-ignored-charsets
2292 (save-excursion (condition-case nil
2293 (set-buffer gnus-summary-buffer)
2295 gnus-newsgroup-ignored-charsets))
2296 ct cte ctl charset format)
2299 (article-narrow-to-head)
2300 (setq ct (message-fetch-field "Content-Type" t)
2301 cte (message-fetch-field "Content-Transfer-Encoding" t)
2302 ctl (and ct (ignore-errors
2303 (mail-header-parse-content-type ct)))
2306 (mm-read-coding-system "Charset to decode: "))
2308 (mail-content-type-get ctl 'charset)))
2309 format (and ctl (mail-content-type-get ctl 'format)))
2311 (setq cte (mail-header-strip cte)))
2312 (if (and ctl (not (string-match "/" (car ctl))))
2314 (goto-char (point-max)))
2317 (narrow-to-region (point) (point-max))
2318 (when (and (eq mail-parse-charset 'gnus-decoded)
2319 (eq (mm-body-7-or-8) '8bit))
2320 ;; The text code could have been decoded.
2321 (setq charset mail-parse-charset))
2322 (when (and (or (not ctl)
2323 (equal (car ctl) "text/plain"))
2324 (not format)) ;; article with format will decode later.
2326 charset (and cte (intern (downcase
2327 (gnus-strip-whitespace cte))))
2330 (defun article-decode-encoded-words ()
2331 "Remove encoded-word encoding from headers."
2332 (let ((inhibit-point-motion-hooks t)
2333 (mail-parse-charset gnus-newsgroup-charset)
2334 (mail-parse-ignored-charsets
2335 (save-excursion (condition-case nil
2336 (set-buffer gnus-summary-buffer)
2338 gnus-newsgroup-ignored-charsets))
2339 (inhibit-read-only t))
2341 (article-narrow-to-head)
2342 (funcall gnus-decode-header-function (point-min) (point-max)))))
2344 (defun article-decode-group-name ()
2345 "Decode group names in `Newsgroups:'."
2346 (let ((inhibit-point-motion-hooks t)
2347 (inhibit-read-only t)
2348 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2349 (when (and (or gnus-group-name-charset-method-alist
2350 gnus-group-name-charset-group-alist)
2351 (gnus-buffer-live-p gnus-original-article-buffer))
2353 (article-narrow-to-head)
2354 (with-current-buffer gnus-original-article-buffer
2355 (goto-char (point-min)))
2356 (while (re-search-forward
2357 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2358 (replace-match (save-match-data
2359 (gnus-decode-newsgroups
2360 ;; XXX how to use data in article buffer?
2361 (with-current-buffer gnus-original-article-buffer
2363 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2366 gnus-newsgroup-name method))
2368 (goto-char (point-min))
2369 (with-current-buffer gnus-original-article-buffer
2370 (goto-char (point-min)))
2371 (while (re-search-forward
2372 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2373 (replace-match (save-match-data
2374 (gnus-decode-newsgroups
2375 ;; XXX how to use data in article buffer?
2376 (with-current-buffer gnus-original-article-buffer
2378 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2381 gnus-newsgroup-name method))
2384 (autoload 'idna-to-unicode "idna")
2386 (defun article-decode-idna-rhs ()
2387 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2390 (let ((inhibit-point-motion-hooks t)
2391 (inhibit-read-only t))
2392 (article-narrow-to-head)
2393 (goto-char (point-min))
2394 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2396 (when (save-match-data
2397 (and (setq ace (match-string 1))
2399 (and (re-search-backward "^[^ \t]" nil t)
2400 (looking-at "From\\|To\\|Cc")))
2401 (setq unicode (idna-to-unicode ace))))
2402 (unless (string= ace unicode)
2403 (replace-match unicode nil nil nil 1)))))))))
2405 (defun article-de-quoted-unreadable (&optional force read-charset)
2406 "Translate a quoted-printable-encoded article.
2407 If FORCE, decode the article whether it is marked as quoted-printable
2409 If READ-CHARSET, ask for a coding system."
2410 (interactive (list 'force current-prefix-arg))
2412 (let ((inhibit-read-only t) type charset)
2413 (if (gnus-buffer-live-p gnus-original-article-buffer)
2414 (with-current-buffer gnus-original-article-buffer
2416 (gnus-fetch-field "content-transfer-encoding"))
2417 (let* ((ct (gnus-fetch-field "content-type"))
2420 (mail-header-parse-content-type ct)))))
2421 (setq charset (and ctl
2422 (mail-content-type-get ctl 'charset)))
2423 (if (stringp charset)
2424 (setq charset (intern (downcase charset)))))))
2426 (setq charset (mm-read-coding-system "Charset: " charset)))
2428 (setq charset gnus-newsgroup-charset))
2430 (and type (let ((case-fold-search t))
2431 (string-match "quoted-printable" type))))
2433 (quoted-printable-decode-region
2434 (point) (point-max) (mm-charset-to-coding-system charset))))))
2436 (defun article-de-base64-unreadable (&optional force read-charset)
2437 "Translate a base64 article.
2438 If FORCE, decode the article whether it is marked as base64 not.
2439 If READ-CHARSET, ask for a coding system."
2440 (interactive (list 'force current-prefix-arg))
2442 (let ((inhibit-read-only t) type charset)
2443 (if (gnus-buffer-live-p gnus-original-article-buffer)
2444 (with-current-buffer gnus-original-article-buffer
2446 (gnus-fetch-field "content-transfer-encoding"))
2447 (let* ((ct (gnus-fetch-field "content-type"))
2450 (mail-header-parse-content-type ct)))))
2451 (setq charset (and ctl
2452 (mail-content-type-get ctl 'charset)))
2453 (if (stringp charset)
2454 (setq charset (intern (downcase charset)))))))
2456 (setq charset (mm-read-coding-system "Charset: " charset)))
2458 (setq charset gnus-newsgroup-charset))
2460 (and type (let ((case-fold-search t))
2461 (string-match "base64" type))))
2464 (narrow-to-region (point) (point-max))
2465 (base64-decode-region (point-min) (point-max))
2466 (mm-decode-coding-region
2467 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2472 (defun article-decode-HZ ()
2473 "Translate a HZ-encoded article."
2477 (let ((inhibit-read-only t))
2478 (rfc1843-decode-region (point-min) (point-max)))))
2480 (defun article-unsplit-urls ()
2481 "Remove the newlines that some other mailers insert into URLs."
2484 (let ((inhibit-read-only t))
2485 (goto-char (point-min))
2486 (while (re-search-forward
2487 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2488 (replace-match "\\1\\3" t)))
2489 (when (interactive-p)
2490 (gnus-treat-article nil))))
2493 (defun article-wash-html (&optional read-charset)
2494 "Format an HTML article.
2495 If READ-CHARSET, ask for a coding system."
2498 (let ((inhibit-read-only t)
2500 (when (gnus-buffer-live-p gnus-original-article-buffer)
2501 (with-current-buffer gnus-original-article-buffer
2502 (let* ((ct (gnus-fetch-field "content-type"))
2505 (mail-header-parse-content-type ct)))))
2506 (setq charset (and ctl
2507 (mail-content-type-get ctl 'charset)))
2508 (when (stringp charset)
2509 (setq charset (intern (downcase charset)))))))
2511 (setq charset (mm-read-coding-system "Charset: " charset)))
2513 (setq charset gnus-newsgroup-charset))
2515 (save-window-excursion
2517 (narrow-to-region (point) (point-max))
2518 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2519 (entry (assq func mm-text-html-washer-alist)))
2521 (setq func (cdr entry)))
2526 (apply (car func) (cdr func))))))))))
2528 (defun gnus-article-wash-html-with-w3 ()
2529 "Wash the current buffer with w3."
2531 (let ((w3-strict-width (window-width))
2532 (url-standalone-mode t)
2533 (url-gateway-unplugged t)
2534 (w3-honor-stylesheets nil))
2536 (w3-region (point-min) (point-max))
2539 (defun gnus-article-wash-html-with-w3m ()
2540 "Wash the current buffer with emacs-w3m."
2543 (narrow-to-region (point) (point-max))
2544 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2545 w3m-force-redisplay)
2546 (w3m-region (point-min) (point-max)))
2547 (when (and mm-inline-text-html-with-w3m-keymap
2548 (boundp 'w3m-minor-mode-map)
2550 (add-text-properties
2551 (point-min) (point-max)
2552 (list 'keymap w3m-minor-mode-map
2553 ;; Put the mark meaning this part was rendered by emacs-w3m.
2554 'mm-inline-text-html-with-w3m t)))))
2556 (defun article-hide-list-identifiers ()
2557 "Remove list identifies from the Subject header.
2558 The `gnus-list-identifiers' variable specifies what to do."
2560 (let ((inhibit-point-motion-hooks t)
2561 (regexp (if (consp gnus-list-identifiers)
2562 (mapconcat 'identity gnus-list-identifiers " *\\|")
2563 gnus-list-identifiers))
2564 (inhibit-read-only t))
2568 (article-narrow-to-head)
2569 (goto-char (point-min))
2570 (while (re-search-forward
2571 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2573 (delete-region (match-beginning 2) (match-end 0))
2574 (beginning-of-line))
2575 (when (re-search-forward
2576 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2577 (delete-region (match-beginning 1) (match-end 1))))))))
2579 (defun article-hide-pem (&optional arg)
2580 "Toggle hiding of any PEM headers and signatures in the current article.
2581 If given a negative prefix, always show; if given a positive prefix,
2583 (interactive (gnus-article-hidden-arg))
2584 (unless (gnus-article-check-hidden-text 'pem arg)
2586 (let ((inhibit-read-only t) end)
2587 (goto-char (point-min))
2588 ;; Hide the horrendously ugly "header".
2589 (when (and (search-forward
2590 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2592 (setq end (1+ (match-beginning 0))))
2593 (gnus-add-wash-type 'pem)
2594 (gnus-article-hide-text-type
2596 (if (search-forward "\n\n" nil t)
2600 ;; Hide the trailer as well
2601 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2603 (gnus-article-hide-text-type
2604 (match-beginning 0) (match-end 0) 'pem)))))))
2606 (defun article-strip-banner ()
2607 "Strip the banners specified by the `banner' group parameter and by
2608 `gnus-article-address-banner-alist'."
2612 (let ((inhibit-point-motion-hooks t))
2613 (when (gnus-parameter-banner gnus-newsgroup-name)
2614 (article-really-strip-banner
2615 (gnus-parameter-banner gnus-newsgroup-name)))
2616 (when gnus-article-address-banner-alist
2617 ;; It is necessary to encode from fields before checking,
2618 ;; because `mail-header-parse-addresses' does not work
2619 ;; (reliably) on decoded headers. And more, it is
2620 ;; impossible to use `gnus-fetch-original-field' here,
2621 ;; because `article-strip-banner' may be called in draft
2622 ;; buffers to preview them.
2623 (let ((from (save-restriction
2625 (article-narrow-to-head)
2626 (mail-fetch-field "from"))))
2629 (caar (mail-header-parse-addresses
2630 (mail-encode-encoded-word-string from)))))
2632 (dolist (pair gnus-article-address-banner-alist)
2633 (when (string-match (car pair) from)
2635 (article-really-strip-banner (cdr pair)))))))))))))
2637 (defun article-really-strip-banner (banner)
2638 "Strip the banner specified by the argument."
2641 (let ((inhibit-point-motion-hooks t)
2642 (gnus-signature-limit nil)
2643 (inhibit-read-only t))
2646 ((eq banner 'signature)
2647 (when (gnus-article-narrow-to-signature)
2650 (delete-region (point) (point-max))))
2652 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2653 (while (re-search-forward banner nil t)
2654 (delete-region (match-beginning 0) (match-end 0)))))
2656 (while (re-search-forward banner nil t)
2657 (delete-region (match-beginning 0) (match-end 0)))))))))
2659 (defun article-babel ()
2660 "Translate article using an online translation service."
2663 (gnus-with-article-buffer
2664 (when (article-goto-body)
2665 (let* ((start (point))
2667 (orig (buffer-substring start end))
2668 (trans (babel-as-string orig)))
2670 (narrow-to-region start end)
2671 (delete-region start end)
2674 (defun article-hide-signature (&optional arg)
2675 "Hide the signature in the current article.
2676 If given a negative prefix, always show; if given a positive prefix,
2678 (interactive (gnus-article-hidden-arg))
2679 (unless (gnus-article-check-hidden-text 'signature arg)
2682 (let ((inhibit-read-only t))
2683 (when (gnus-article-narrow-to-signature)
2684 (gnus-article-hide-text-type
2685 (point-min) (point-max) 'signature))))))
2686 (gnus-set-mode-line 'article))
2688 (defun article-strip-headers-in-body ()
2689 "Strip offensive headers from bodies."
2693 (let ((case-fold-search t))
2694 (when (looking-at "x-no-archive:")
2695 (gnus-delete-line)))))
2697 (defun article-strip-leading-blank-lines ()
2698 "Remove all blank lines from the beginning of the article."
2701 (let ((inhibit-point-motion-hooks t)
2702 (inhibit-read-only t))
2703 (when (article-goto-body)
2704 (while (and (not (eobp))
2705 (looking-at "[ \t]*$"))
2706 (gnus-delete-line))))))
2708 (defun article-narrow-to-head ()
2709 "Narrow the buffer to the head of the message.
2710 Point is left at the beginning of the narrowed-to region."
2712 (goto-char (point-min))
2713 (if (search-forward "\n\n" nil 1)
2716 (goto-char (point-min)))
2718 (defun article-goto-body ()
2719 "Place point at the start of the body."
2720 (goto-char (point-min))
2722 ;; This variable is only bound when dealing with separate
2724 (article-goto-body-goes-to-point-min-p
2726 ((search-forward "\n\n" nil t)
2729 (goto-char (point-max))
2732 (defun article-strip-multiple-blank-lines ()
2733 "Replace consecutive blank lines with one empty line."
2736 (let ((inhibit-point-motion-hooks t)
2737 (inhibit-read-only t))
2738 ;; First make all blank lines empty.
2740 (while (re-search-forward "^[ \t]+$" nil t)
2741 (unless (gnus-annotation-in-region-p
2742 (match-beginning 0) (match-end 0))
2743 (replace-match "" nil t)))
2744 ;; Then replace multiple empty lines with a single empty line.
2746 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2747 (unless (gnus-annotation-in-region-p
2748 (match-beginning 0) (match-end 0))
2749 (delete-region (match-beginning 1) (match-end 1)))))))
2751 (defun article-strip-leading-space ()
2752 "Remove all white space from the beginning of the lines in the article."
2755 (let ((inhibit-point-motion-hooks t)
2756 (inhibit-read-only t))
2758 (while (re-search-forward "^[ \t]+" nil t)
2759 (replace-match "" t t)))))
2761 (defun article-strip-trailing-space ()
2762 "Remove all white space from the end of the lines in the article."
2765 (let ((inhibit-point-motion-hooks t)
2766 (inhibit-read-only t))
2768 (while (re-search-forward "[ \t]+$" nil t)
2769 (replace-match "" t t)))))
2771 (defun article-strip-blank-lines ()
2772 "Strip leading, trailing and multiple blank lines."
2774 (article-strip-leading-blank-lines)
2775 (article-remove-trailing-blank-lines)
2776 (article-strip-multiple-blank-lines))
2778 (defun article-strip-all-blank-lines ()
2779 "Strip all blank lines."
2782 (let ((inhibit-point-motion-hooks t)
2783 (inhibit-read-only t))
2785 (while (re-search-forward "^[ \t]*\n" nil t)
2786 (replace-match "" t t)))))
2788 (defun gnus-article-narrow-to-signature ()
2789 "Narrow to the signature; return t if a signature is found, else nil."
2790 (let ((inhibit-point-motion-hooks t))
2791 (when (gnus-article-search-signature)
2793 ;; Check whether we have some limits to what we consider
2794 ;; to be a signature.
2795 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2796 (list gnus-signature-limit)))
2798 (while (setq limit (pop limits))
2799 (if (or (and (integerp limit)
2800 (< (- (point-max) (point)) limit))
2802 (< (count-lines (point) (point-max)) limit))
2803 (and (functionp limit)
2805 (and (stringp limit)
2806 (not (re-search-forward limit nil t))))
2807 () ; This limit did not succeed.
2811 (narrow-to-region (point) (point-max))
2814 (defun gnus-article-search-signature ()
2815 "Search the current buffer for the signature separator.
2816 Put point at the beginning of the signature separator."
2817 (let ((cur (point)))
2818 (goto-char (point-max))
2819 (if (if (stringp gnus-signature-separator)
2820 (re-search-backward gnus-signature-separator nil t)
2821 (let ((seps gnus-signature-separator))
2823 (not (re-search-backward (car seps) nil t)))
2830 (defun gnus-article-hidden-arg ()
2831 "Return the current prefix arg as a number, or 0 if no prefix."
2832 (list (if current-prefix-arg
2833 (prefix-numeric-value current-prefix-arg)
2836 (defun gnus-article-check-hidden-text (type arg)
2837 "Return nil if hiding is necessary.
2838 Arg can be nil or a number. nil and positive means hide, negative
2839 means show, 0 means toggle."
2842 (let ((hide (gnus-article-hidden-text-p type)))
2848 (gnus-article-show-hidden-text type)
2851 (if (eq hide 'hidden)
2853 (gnus-article-show-hidden-text type)
2857 (defun gnus-article-hidden-text-p (type)
2858 "Say whether the current buffer contains hidden text of type TYPE."
2859 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2861 (not (get-text-property pos 'invisible))
2862 (not (get-text-property pos 'dummy-invisible)))
2864 (text-property-any (1+ pos) (point-max) 'article-type type)))
2869 (defun gnus-article-show-hidden-text (type &optional dummy)
2870 "Show all hidden text of type TYPE.
2871 Originally it is hide instead of DUMMY."
2872 (let ((inhibit-read-only t)
2873 (inhibit-point-motion-hooks t))
2874 (gnus-remove-text-properties-when
2876 (point-min) (point-max)
2877 (cons 'article-type (cons type
2878 gnus-hidden-properties)))
2879 (gnus-delete-wash-type type)))
2881 (defconst article-time-units
2882 `((year . ,(* 365.25 24 60 60))
2883 (week . ,(* 7 24 60 60))
2884 (day . ,(* 24 60 60))
2888 "Mapping from time units to seconds.")
2890 (defun gnus-article-forward-header ()
2891 "Move point to the start of the next header.
2892 If the current header is a continuation header, this can be several
2897 (if (looking-at "[ \t]+[^ \t]")
2901 (defun article-date-ut (&optional type highlight)
2902 "Convert DATE date to universal time in the current article.
2903 If TYPE is `local', convert to local time; if it is `lapsed', output
2904 how much time has lapsed since DATE. For `lapsed', the value of
2905 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2906 should replace the \"Date:\" one, or should be added below it."
2907 (interactive (list 'ut t))
2908 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2909 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
2913 (article-lapsed-timer
2917 (case-fold-search t)
2918 (inhibit-read-only t)
2919 (inhibit-point-motion-hooks t)
2920 pos date bface eface)
2924 (goto-char (point-min))
2925 (while (or (setq date (get-text-property (setq pos (point))
2927 (when (setq pos (next-single-property-change
2928 (point) 'original-date))
2929 (setq date (get-text-property pos 'original-date))
2931 (narrow-to-region pos (or (text-property-any pos (point-max)
2934 (goto-char (point-min))
2935 (when (re-search-forward tdate-regexp nil t)
2936 (setq bface (get-text-property (point-at-bol) 'face)
2937 eface (get-text-property (1- (point-at-eol)) 'face)))
2938 (goto-char (point-min))
2940 ;; Delete any old Date headers.
2941 (while (re-search-forward date-regexp nil t)
2943 (delete-region (point-at-bol) (progn
2944 (gnus-article-forward-header)
2946 (delete-region (point-at-bol) (progn
2947 (gnus-article-forward-header)
2950 (setq pos (point))))
2951 (when (and (not pos)
2952 (re-search-forward tdate-regexp nil t))
2954 (gnus-goto-char pos)
2955 (insert (article-make-date-line date (or type 'ut)))
2961 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2962 (put-text-property (match-beginning 1) (1+ (match-end 1))
2964 (put-text-property (match-beginning 2) (match-end 2)
2966 (put-text-property (point-min) (1- (point-max)) 'original-date date)
2967 (goto-char (point-max))
2970 (defun article-make-date-line (date type)
2971 "Return a DATE line of TYPE."
2972 (unless (memq type '(local ut original user iso8601 lapsed english))
2973 (error "Unknown conversion type: %s" type))
2975 (let ((time (date-to-time date)))
2977 ;; Convert to the local timezone.
2979 (concat "Date: " (message-make-date time)))
2980 ;; Convert to Universal Time.
2985 (let* ((e (parse-time-string date))
2986 (tm (apply 'encode-time e))
2988 (ls (- (cadr tm) (car (current-time-zone time)))))
2989 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2990 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2994 ;; Get the original date from the article.
2995 ((eq type 'original)
2996 (concat "Date: " (if (string-match "\n+$" date)
2997 (substring date 0 (match-beginning 0))
2999 ;; Let the user define the format.
3001 (let ((format (or (condition-case nil
3002 (with-current-buffer gnus-summary-buffer
3003 gnus-article-time-format)
3005 gnus-article-time-format)))
3006 (if (functionp format)
3007 (funcall format time)
3008 (concat "Date: " (format-time-string format time)))))
3011 (let ((tz (car (current-time-zone time))))
3014 (format-time-string "%Y%m%dT%H%M%S" time)
3015 (format "%s%02d%02d"
3016 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3017 (/ (% (abs tz) 3600) 60)))))
3018 ;; Do an X-Sent lapsed format.
3020 ;; If the date is seriously mangled, the timezone functions are
3021 ;; liable to bug out, so we ignore all errors.
3022 (let* ((now (current-time))
3023 (real-time (subtract-time now time))
3024 (real-sec (and real-time
3025 (+ (* (float (car real-time)) 65536)
3027 (sec (and real-time (abs real-sec)))
3037 ;; This is a bit convoluted, but basically we go
3038 ;; through the time units for years, weeks, etc,
3039 ;; and divide things to see whether that results
3040 ;; in positive answers.
3043 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3044 ;; The (remaining) seconds are too few to
3045 ;; be divided into this time unit.
3047 ;; It's big enough, so we output it.
3048 (setq sec (- sec (* num (cdr unit))))
3050 (concat (if prev ", " "") (int-to-string
3052 " " (symbol-name (car unit))
3053 (if (> num 1) "s" ""))
3055 article-time-units "")
3056 ;; If dates are odd, then it might appear like the
3057 ;; article was sent in the future.
3060 " in the future"))))))
3061 ;; Display the date in proper English
3063 (let ((dtime (decode-time time)))
3066 (number-to-string (nth 3 dtime))
3067 (let ((digit (% (nth 3 dtime) 10)))
3069 ((memq (nth 3 dtime) '(11 12 13)) "th")
3075 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3077 (number-to-string (nth 5 dtime))
3079 (format "%02d" (nth 2 dtime))
3081 (format "%02d" (nth 1 dtime)))))))
3083 (format "Date: %s (from Gnus)" date))))
3085 (defun article-date-local (&optional highlight)
3086 "Convert the current article date to the local timezone."
3087 (interactive (list t))
3088 (article-date-ut 'local highlight))
3090 (defun article-date-english (&optional highlight)
3091 "Convert the current article date to something that is proper English."
3092 (interactive (list t))
3093 (article-date-ut 'english highlight))
3095 (defun article-date-original (&optional highlight)
3096 "Convert the current article date to what it was originally.
3097 This is only useful if you have used some other date conversion
3098 function and want to see what the date was before converting."
3099 (interactive (list t))
3100 (article-date-ut 'original highlight))
3102 (defun article-date-lapsed (&optional highlight)
3103 "Convert the current article date to time lapsed since it was sent."
3104 (interactive (list t))
3105 (article-date-ut 'lapsed highlight))
3107 (defun article-update-date-lapsed ()
3108 "Function to be run from a timer to update the lapsed time line."
3110 (let (deactivate-mark)
3115 (set-buffer (window-buffer w))
3116 (when (eq major-mode 'gnus-article-mode)
3117 (let ((mark (point-marker)))
3118 (goto-char (point-min))
3119 (when (re-search-forward "^X-Sent:" nil t)
3120 (article-date-lapsed t))
3121 (goto-char (marker-position mark))
3122 (move-marker mark nil))))
3125 (defun gnus-start-date-timer (&optional n)
3126 "Start a timer to update the X-Sent header in the article buffers.
3127 The numerical prefix says how frequently (in seconds) the function
3132 (gnus-stop-date-timer)
3133 (setq article-lapsed-timer
3134 (run-at-time 1 n 'article-update-date-lapsed)))
3136 (defun gnus-stop-date-timer ()
3137 "Stop the X-Sent timer."
3139 (when article-lapsed-timer
3140 (nnheader-cancel-timer article-lapsed-timer)
3141 (setq article-lapsed-timer nil)))
3143 (defun article-date-user (&optional highlight)
3144 "Convert the current article date to the user-defined format.
3145 This format is defined by the `gnus-article-time-format' variable."
3146 (interactive (list t))
3147 (article-date-ut 'user highlight))
3149 (defun article-date-iso8601 (&optional highlight)
3150 "Convert the current article date to ISO8601."
3151 (interactive (list t))
3152 (article-date-ut 'iso8601 highlight))
3154 (defmacro gnus-article-save-original-date (&rest forms)
3155 "Save the original date as a text property and evaluate FORMS."
3156 `(let* ((case-fold-search t)
3158 (goto-char (point-min))
3159 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3162 (date (when (and start
3163 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3165 (buffer-substring-no-properties start
3166 (match-beginning 0)))))
3167 (goto-char (point-max))
3168 (skip-chars-backward "\n")
3169 (put-text-property (point-min) (point) 'original-date date)
3171 (goto-char (point-max))
3172 (skip-chars-backward "\n")
3173 (put-text-property (point-min) (point) 'original-date date)))
3175 ;; (defun article-show-all ()
3176 ;; "Show all hidden text in the article buffer."
3179 ;; (let ((inhibit-read-only t))
3180 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3182 (defun article-remove-leading-whitespace ()
3183 "Remove excessive whitespace from all headers."
3187 (let ((inhibit-read-only t))
3188 (article-narrow-to-head)
3189 (goto-char (point-min))
3190 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3191 (delete-region (match-beginning 1) (match-end 1)))))))
3193 (defun article-emphasize (&optional arg)
3194 "Emphasize text according to `gnus-emphasis-alist'."
3195 (interactive (gnus-article-hidden-arg))
3196 (unless (gnus-article-check-hidden-text 'emphasis arg)
3200 (with-current-buffer gnus-summary-buffer
3201 gnus-article-emphasis-alist)
3203 gnus-emphasis-alist))
3204 (inhibit-read-only t)
3205 (props (append '(article-type emphasis)
3206 gnus-hidden-properties))
3207 regexp elem beg invisible visible face)
3210 (while (setq elem (pop alist))
3212 (setq regexp (car elem)
3213 invisible (nth 1 elem)
3214 visible (nth 2 elem)
3216 (while (re-search-forward regexp nil t)
3217 (when (and (match-beginning visible) (match-beginning invisible))
3218 (gnus-article-hide-text
3219 (match-beginning invisible) (match-end invisible) props)
3220 (gnus-article-unhide-text-type
3221 (match-beginning visible) (match-end visible) 'emphasis)
3222 (gnus-put-overlay-excluding-newlines
3223 (match-beginning visible) (match-end visible) 'face face)
3224 (gnus-add-wash-type 'emphasis)
3225 (goto-char (match-end invisible)))))))))
3227 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3228 "Setup newsgroup emphasis alist."
3229 (unless gnus-article-emphasis-alist
3230 (let ((name (and gnus-newsgroup-name
3231 (gnus-group-real-name gnus-newsgroup-name))))
3232 (make-local-variable 'gnus-article-emphasis-alist)
3233 (setq gnus-article-emphasis-alist
3235 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3236 (while (setq elem (pop alist))
3237 (when (and name (string-match (car elem) name))
3239 highlight (copy-sequence (cdr elem)))))
3241 (copy-sequence highlight-words)
3242 (if gnus-newsgroup-name
3243 (copy-sequence (gnus-group-find-parameter
3244 gnus-newsgroup-name 'highlight-words t)))
3245 gnus-emphasis-alist)))))
3248 (defvar gnus-summary-article-menu)
3249 (defvar gnus-summary-post-menu))
3251 ;;; Saving functions.
3253 (defun gnus-article-save (save-buffer file &optional num)
3254 "Save the currently selected article."
3255 (unless gnus-save-all-headers
3256 ;; Remove headers according to `gnus-saved-headers'.
3257 (let ((gnus-visible-headers
3258 (or gnus-saved-headers gnus-visible-headers))
3259 (gnus-article-buffer save-buffer))
3261 (set-buffer save-buffer)
3262 (article-hide-headers 1 t))))
3263 (save-window-excursion
3264 (if (not gnus-default-article-saver)
3265 (error "No default saver is defined")
3266 ;; !!! Magic! The saving functions all save
3267 ;; `gnus-save-article-buffer' (or so they think), but we
3268 ;; bind that variable to our save-buffer.
3269 (set-buffer gnus-article-buffer)
3270 (let* ((gnus-save-article-buffer save-buffer)
3273 ((not gnus-prompt-before-saving) 'default)
3274 ((eq gnus-prompt-before-saving 'always) nil)
3276 (gnus-number-of-articles-to-be-saved
3277 (when (eq gnus-prompt-before-saving t)
3279 (set-buffer gnus-article-current-summary)
3280 (funcall gnus-default-article-saver filename)))))
3282 (defun gnus-read-save-file-name (prompt &optional filename
3283 function group headers variable)
3285 (funcall function group headers (symbol-value variable)))
3290 ((eq filename 'default)
3296 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3299 (if (and gnus-number-of-articles-to-be-saved
3300 (> gnus-number-of-articles-to-be-saved 1))
3301 (format "these %d articles"
3302 gnus-number-of-articles-to-be-saved)
3305 ;; Let the split methods have their say.
3307 ;; No split name was found.
3310 (concat prompt " (default "
3311 (file-name-nondirectory default-name) ") ")
3312 (file-name-directory default-name)
3314 ;; A single group name is returned.
3315 ((stringp split-name)
3317 (funcall function split-name headers
3318 (symbol-value variable)))
3320 (concat prompt " (default "
3321 (file-name-nondirectory default-name) ") ")
3322 (file-name-directory default-name)
3324 ;; A single split name was found
3325 ((= 1 (length split-name))
3326 (let* ((name (expand-file-name
3328 gnus-article-save-directory))
3329 (dir (cond ((file-directory-p name)
3330 (file-name-as-directory name))
3331 ((file-exists-p name) name)
3332 (t gnus-article-save-directory))))
3334 (concat prompt " (default " name ") ")
3336 ;; A list of splits was found.
3338 (setq split-name (nreverse split-name))
3340 (let ((file-name-history
3341 (nconc split-name file-name-history)))
3345 (concat prompt " (`M-p' for defaults) ")
3346 gnus-article-save-directory
3348 gnus-article-save-directory)))
3349 (car (push result file-name-history)))))))
3350 ;; Create the directory.
3351 (gnus-make-directory (file-name-directory file))
3352 ;; If we have read a directory, we append the default file name.
3353 (when (file-directory-p file)
3354 (setq file (expand-file-name (file-name-nondirectory
3356 (file-name-as-directory file))))
3357 ;; Possibly translate some characters.
3358 (nnheader-translate-file-chars file))))))
3359 (gnus-make-directory (file-name-directory result))
3360 (set variable result)))
3362 (defun gnus-article-archive-name (group)
3363 "Return the first instance of an \"Archive-name\" in the current buffer."
3364 (let ((case-fold-search t))
3365 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3366 (nnheader-concat gnus-article-save-directory
3367 (match-string 1)))))
3369 (defun gnus-article-nndoc-name (group)
3370 "If GROUP is an nndoc group, return the name of the parent group."
3371 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3372 (gnus-group-get-parameter group 'save-article-group)))
3374 (defun gnus-summary-save-in-rmail (&optional filename)
3375 "Append this article to Rmail file.
3376 Optional argument FILENAME specifies file name.
3377 Directory to save to is default to `gnus-article-save-directory'."
3378 (setq filename (gnus-read-save-file-name
3379 "Save %s in rmail file:" filename
3380 gnus-rmail-save-name gnus-newsgroup-name
3381 gnus-current-headers 'gnus-newsgroup-last-rmail))
3382 (gnus-eval-in-buffer-window gnus-save-article-buffer
3386 (gnus-output-to-rmail filename))))
3389 (defun gnus-summary-save-in-mail (&optional filename)
3390 "Append this article to Unix mail file.
3391 Optional argument FILENAME specifies file name.
3392 Directory to save to is default to `gnus-article-save-directory'."
3393 (setq filename (gnus-read-save-file-name
3394 "Save %s in Unix mail file:" filename
3395 gnus-mail-save-name gnus-newsgroup-name
3396 gnus-current-headers 'gnus-newsgroup-last-mail))
3397 (gnus-eval-in-buffer-window gnus-save-article-buffer
3401 (if (and (file-readable-p filename)
3402 (file-regular-p filename)
3403 (mail-file-babyl-p filename))
3404 (rmail-output-to-rmail-file filename t)
3405 (gnus-output-to-mail filename)))))
3408 (defun gnus-summary-save-in-file (&optional filename overwrite)
3409 "Append this article to file.
3410 Optional argument FILENAME specifies file name.
3411 Directory to save to is default to `gnus-article-save-directory'."
3412 (setq filename (gnus-read-save-file-name
3413 "Save %s in file:" filename
3414 gnus-file-save-name gnus-newsgroup-name
3415 gnus-current-headers 'gnus-newsgroup-last-file))
3416 (gnus-eval-in-buffer-window gnus-save-article-buffer
3420 (when (and overwrite
3421 (file-exists-p filename))
3422 (delete-file filename))
3423 (gnus-output-to-file filename))))
3426 (defun gnus-summary-write-to-file (&optional filename)
3427 "Write this article to a file, overwriting it if the file exists.
3428 Optional argument FILENAME specifies file name.
3429 The directory to save in defaults to `gnus-article-save-directory'."
3430 (gnus-summary-save-in-file nil t))
3432 (defun gnus-summary-save-body-in-file (&optional filename)
3433 "Append this article body to a file.
3434 Optional argument FILENAME specifies file name.
3435 The directory to save in defaults to `gnus-article-save-directory'."
3436 (setq filename (gnus-read-save-file-name
3437 "Save %s body in file:" filename
3438 gnus-file-save-name gnus-newsgroup-name
3439 gnus-current-headers 'gnus-newsgroup-last-file))
3440 (gnus-eval-in-buffer-window gnus-save-article-buffer
3444 (when (article-goto-body)
3445 (narrow-to-region (point) (point-max)))
3446 (gnus-output-to-file filename))))
3449 (defun gnus-summary-save-in-pipe (&optional command)
3450 "Pipe this article to subprocess."
3452 (cond ((and (eq command 'default)
3453 gnus-last-shell-command)
3454 gnus-last-shell-command)
3459 "Shell command on %s: "
3460 (if (and gnus-number-of-articles-to-be-saved
3461 (> gnus-number-of-articles-to-be-saved 1))
3462 (format "these %d articles"
3463 gnus-number-of-articles-to-be-saved)
3465 gnus-last-shell-command))))
3466 (when (string-equal command "")
3467 (if gnus-last-shell-command
3468 (setq command gnus-last-shell-command)
3469 (error "A command is required")))
3470 (gnus-eval-in-buffer-window gnus-article-buffer
3473 (shell-command-on-region (point-min) (point-max) command nil)))
3474 (setq gnus-last-shell-command command))
3476 (defun gnus-summary-pipe-to-muttprint (&optional command)
3477 "Pipe this article to muttprint."
3478 (setq command (read-string
3479 "Print using command: " gnus-summary-muttprint-program
3480 nil gnus-summary-muttprint-program))
3481 (gnus-summary-save-in-pipe command))
3483 ;;; Article file names when saving.
3485 (defun gnus-capitalize-newsgroup (newsgroup)
3486 "Capitalize NEWSGROUP name."
3487 (when (not (zerop (length newsgroup)))
3488 (concat (char-to-string (upcase (aref newsgroup 0)))
3489 (substring newsgroup 1))))
3491 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3492 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3493 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3494 Otherwise, it is like ~/News/news/group/num."
3497 (concat (if (gnus-use-long-file-name 'not-save)
3498 (gnus-capitalize-newsgroup newsgroup)
3499 (gnus-newsgroup-directory-form newsgroup))
3500 "/" (int-to-string (mail-header-number headers)))
3501 gnus-article-save-directory)))
3503 (string-equal (file-name-directory default)
3504 (file-name-directory last-file))
3505 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3507 (or last-file default))))
3509 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3510 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3511 If variable `gnus-use-long-file-name' is non-nil, it is
3512 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3515 (concat (if (gnus-use-long-file-name 'not-save)
3517 (gnus-newsgroup-directory-form newsgroup))
3518 "/" (int-to-string (mail-header-number headers)))
3519 gnus-article-save-directory)))
3521 (string-equal (file-name-directory default)
3522 (file-name-directory last-file))
3523 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3525 (or last-file default))))
3527 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3528 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3529 If variable `gnus-use-long-file-name' is non-nil, it is
3530 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3533 (if (gnus-use-long-file-name 'not-save)
3536 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3538 gnus-article-save-directory)))
3540 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3541 "Generate file name from sender."
3542 (let ((from (mail-header-from headers)))
3544 (if (and from (string-match "\\([^ <]+\\)@" from))
3545 (match-string 1 from)
3547 gnus-article-save-directory)))
3549 (defun article-verify-x-pgp-sig ()
3552 (if (gnus-buffer-live-p gnus-original-article-buffer)
3553 (let ((sig (with-current-buffer gnus-original-article-buffer
3554 (gnus-fetch-field "X-PGP-Sig")))
3558 (mml2015-clear-verify-function))
3560 (insert-buffer-substring gnus-original-article-buffer)
3561 (setq items (split-string sig))
3562 (message-narrow-to-head)
3563 (let ((inhibit-point-motion-hooks t)
3564 (case-fold-search t))
3565 ;; Don't verify multiple headers.
3566 (setq headers (mapconcat (lambda (header)
3568 (mail-fetch-field header)
3570 (split-string (nth 1 items) ",") "")))
3571 (delete-region (point-min) (point-max))
3572 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3573 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3578 (if (looking-at "^-")
3581 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3582 (insert "Version: " (car items) "\n\n")
3583 (insert (mapconcat 'identity (cddr items) "\n"))
3584 (insert "\n-----END PGP SIGNATURE-----\n")
3585 (let ((mm-security-handle (list (format "multipart/signed"))))
3586 (mml2015-clean-buffer)
3587 (let ((coding-system-for-write (or gnus-newsgroup-charset
3589 (funcall (mml2015-clear-verify-function)))
3591 (or (mm-handle-multipart-ctl-parameter
3592 mm-security-handle 'gnus-details)
3593 (mm-handle-multipart-ctl-parameter
3594 mm-security-handle 'gnus-info)))))
3596 (let ((inhibit-read-only t) bface eface)
3598 (message-narrow-to-head)
3599 (goto-char (point-max))
3601 (setq bface (get-text-property (point-at-bol) 'face)
3602 eface (get-text-property (1- (point-at-eol)) 'face))
3603 (message-remove-header "X-Gnus-PGP-Verify")
3604 (if (re-search-forward "^X-PGP-Sig:" nil t)
3606 (goto-char (point-max)))
3607 (narrow-to-region (point) (point))
3608 (insert "X-Gnus-PGP-Verify: " info "\n")
3609 (goto-char (point-min))
3612 (if (not (looking-at "^[ \t]"))
3616 (goto-char (point-min))
3617 (when (looking-at "\\([^:]+\\): *")
3618 (put-text-property (match-beginning 1) (1+ (match-end 1))
3620 (put-text-property (match-end 0) (point-max)
3621 'face eface)))))))))
3623 (defun article-verify-cancel-lock ()
3624 "Verify Cancel-Lock header."
3626 (if (gnus-buffer-live-p gnus-original-article-buffer)
3627 (canlock-verify gnus-original-article-buffer)))
3634 (setq afunc (car func)
3637 gfunc (intern (format "gnus-%s" func))))
3639 (when (fboundp afunc)
3640 `(lambda (&optional interactive &rest args)
3641 ,(documentation afunc t)
3642 (interactive (list t))
3644 (set-buffer gnus-article-buffer)
3646 (call-interactively ',afunc)
3647 (apply ',afunc args))))))))
3648 '(article-hide-headers
3649 article-verify-x-pgp-sig
3650 article-verify-cancel-lock
3651 article-hide-boring-headers
3652 article-treat-overstrike
3653 article-treat-ansi-sequences
3654 article-fill-long-lines
3655 article-capitalize-sentences
3657 article-remove-leading-whitespace
3658 article-display-x-face
3659 article-display-face
3660 article-de-quoted-unreadable
3661 article-de-base64-unreadable
3664 article-unsplit-urls
3665 article-hide-list-identifiers
3666 article-strip-banner
3669 article-hide-signature
3670 article-strip-headers-in-body
3671 article-remove-trailing-blank-lines
3672 article-strip-leading-blank-lines
3673 article-strip-multiple-blank-lines
3674 article-strip-leading-space
3675 article-strip-trailing-space
3676 article-strip-blank-lines
3677 article-strip-all-blank-lines
3679 article-date-english
3680 article-date-iso8601
3681 article-date-original
3683 article-decode-mime-words
3684 article-decode-charset
3685 article-decode-encoded-words
3689 article-treat-dumbquotes
3690 article-normalize-headers
3691 ;; (article-show-all . gnus-article-show-all-headers)
3695 ;;; Gnus article mode
3698 (put 'gnus-article-mode 'mode-class 'special)
3700 (set-keymap-parent gnus-article-mode-map widget-keymap)
3702 (gnus-define-keys gnus-article-mode-map
3703 " " gnus-article-goto-next-page
3704 "\177" gnus-article-goto-prev-page
3705 [delete] gnus-article-goto-prev-page
3706 [backspace] gnus-article-goto-prev-page
3707 "\C-c^" gnus-article-refer-article
3708 "h" gnus-article-show-summary
3709 "s" gnus-article-show-summary
3710 "\C-c\C-m" gnus-article-mail
3711 "?" gnus-article-describe-briefly
3712 "e" gnus-summary-edit-article
3713 "<" beginning-of-buffer
3715 "\C-c\C-i" gnus-info-find-node
3717 "R" gnus-article-reply-with-original
3718 "F" gnus-article-followup-with-original
3719 "\C-hk" gnus-article-describe-key
3720 "\C-hc" gnus-article-describe-key-briefly
3722 "\C-d" gnus-article-read-summary-keys
3723 "\M-*" gnus-article-read-summary-keys
3724 "\M-#" gnus-article-read-summary-keys
3725 "\M-^" gnus-article-read-summary-keys
3726 "\M-g" gnus-article-read-summary-keys)
3728 (substitute-key-definition
3729 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3731 (defun gnus-article-make-menu-bar ()
3732 (unless (boundp 'gnus-article-commands-menu)
3733 (gnus-summary-make-menu-bar))
3734 (gnus-turn-off-edit-menu 'article)
3735 (unless (boundp 'gnus-article-article-menu)
3737 gnus-article-article-menu gnus-article-mode-map ""
3739 ["Scroll forwards" gnus-article-goto-next-page t]
3740 ["Scroll backwards" gnus-article-goto-prev-page t]
3741 ["Show summary" gnus-article-show-summary t]
3742 ["Fetch Message-ID at point" gnus-article-refer-article t]
3743 ["Mail to address at point" gnus-article-mail t]
3744 ["Send a bug report" gnus-bug t]))
3747 gnus-article-treatment-menu gnus-article-mode-map ""
3748 ;; Fixme: this should use :active (and maybe :visible).
3750 ["Hide headers" gnus-article-hide-headers t]
3751 ["Hide signature" gnus-article-hide-signature t]
3752 ["Hide citation" gnus-article-hide-citation t]
3753 ["Treat overstrike" gnus-article-treat-overstrike t]
3754 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3755 ["Remove carriage return" gnus-article-remove-cr t]
3756 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3757 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3758 ["Remove base64" gnus-article-de-base64-unreadable t]
3759 ["Treat html" gnus-article-wash-html t]
3760 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3761 ["Decode HZ" gnus-article-decode-HZ t]))
3763 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3765 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3767 (gnus-run-hooks 'gnus-article-menu-hook)))
3769 (defun gnus-article-mode ()
3770 "Major mode for displaying an article.
3772 All normal editing commands are switched off.
3774 The following commands are available in addition to all summary mode
3776 \\<gnus-article-mode-map>
3777 \\[gnus-article-next-page]\t Scroll the article one page forwards
3778 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3779 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3780 \\[gnus-article-show-summary]\t Display the summary buffer
3781 \\[gnus-article-mail]\t Send a reply to the address near point
3782 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3783 \\[gnus-info-find-node]\t Go to the Gnus info node"
3785 (kill-all-local-variables)
3786 (gnus-simplify-mode-line)
3787 (setq mode-name "Article")
3788 (setq major-mode 'gnus-article-mode)
3789 (make-local-variable 'minor-mode-alist)
3790 (use-local-map gnus-article-mode-map)
3791 (when (gnus-visual-p 'article-menu 'menu)
3792 (gnus-article-make-menu-bar)
3793 (when gnus-summary-tool-bar-map
3794 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3795 (gnus-update-format-specifications nil 'article-mode)
3796 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3797 (set (make-local-variable 'gnus-page-broken) nil)
3798 (make-local-variable 'gnus-button-marker-list)
3799 (make-local-variable 'gnus-article-current-summary)
3800 (make-local-variable 'gnus-article-mime-handles)
3801 (make-local-variable 'gnus-article-decoded-p)
3802 (make-local-variable 'gnus-article-mime-handle-alist)
3803 (make-local-variable 'gnus-article-wash-types)
3804 (make-local-variable 'gnus-article-image-alist)
3805 (make-local-variable 'gnus-article-charset)
3806 (make-local-variable 'gnus-article-ignored-charsets)
3807 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3808 (set (make-local-variable 'nobreak-char-display) nil)
3809 (gnus-set-default-directory)
3810 (buffer-disable-undo)
3811 (setq buffer-read-only t
3812 show-trailing-whitespace nil)
3813 (set-syntax-table gnus-article-mode-syntax-table)
3814 (mm-enable-multibyte)
3815 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3817 (defun gnus-article-setup-buffer ()
3818 "Initialize the article buffer."
3819 (let* ((name (if gnus-single-article-buffer "*Article*"
3820 (concat "*Article " gnus-newsgroup-name "*")))
3822 (progn (string-match "\\*Article" name)
3823 (concat " *Original Article"
3824 (substring name (match-end 0))))))
3825 (setq gnus-article-buffer name)
3826 (setq gnus-original-article-buffer original)
3827 (setq gnus-article-mime-handle-alist nil)
3828 ;; This might be a variable local to the summary buffer.
3829 (unless gnus-single-article-buffer
3831 (set-buffer gnus-summary-buffer)
3832 (setq gnus-article-buffer name)
3833 (setq gnus-original-article-buffer original)
3834 (gnus-set-global-variables)))
3835 (gnus-article-setup-highlight-words)
3836 ;; Init original article buffer.
3838 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3839 (mm-enable-multibyte)
3840 (setq major-mode 'gnus-original-article-mode)
3841 (make-local-variable 'gnus-original-article))
3842 (if (and (get-buffer name)
3843 (with-current-buffer name
3844 (if gnus-article-edit-mode
3845 (if (y-or-n-p "Article mode edit in progress; discard? ")
3847 (set-buffer-modified-p nil)
3848 (gnus-kill-buffer name)
3851 (error "Action aborted"))
3855 (set (make-local-variable 'gnus-article-edit-mode) nil)
3856 (when gnus-article-mime-handles
3857 (mm-destroy-parts gnus-article-mime-handles)
3858 (setq gnus-article-mime-handles nil))
3859 ;; Set it to nil in article-buffer!
3860 (setq gnus-article-mime-handle-alist nil)
3861 (buffer-disable-undo)
3862 (setq buffer-read-only t)
3863 ;; This list just keeps growing if we don't reset it.
3864 (setq gnus-button-marker-list nil)
3865 (unless (eq major-mode 'gnus-article-mode)
3866 (gnus-article-mode))
3869 (set-buffer (gnus-get-buffer-create name))
3871 (make-local-variable 'gnus-summary-buffer)
3872 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3873 (current-buffer)))))
3875 ;; Set article window start at LINE, where LINE is the number of lines
3876 ;; from the head of the article.
3877 (defun gnus-article-set-window-start (&optional line)
3879 (gnus-get-buffer-window gnus-article-buffer t)
3881 (set-buffer gnus-article-buffer)
3882 (goto-char (point-min))
3885 (gnus-message 6 "Moved to bookmark")
3886 (search-forward "\n\n" nil t)
3890 (defun gnus-article-prepare (article &optional all-headers header)
3891 "Prepare ARTICLE in article mode buffer.
3892 ARTICLE should either be an article number or a Message-ID.
3893 If ARTICLE is an id, HEADER should be the article headers.
3894 If ALL-HEADERS is non-nil, no headers are hidden."
3896 ;; Make sure we start in a summary buffer.
3897 (unless (eq major-mode 'gnus-summary-mode)
3898 (set-buffer gnus-summary-buffer))
3899 (setq gnus-summary-buffer (current-buffer))
3900 (let* ((gnus-article (if header (mail-header-number header) article))
3901 (summary-buffer (current-buffer))
3902 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3903 (group gnus-newsgroup-name)
3906 (gnus-article-setup-buffer)
3907 (set-buffer gnus-article-buffer)
3908 ;; Deactivate active regions.
3909 (when (and (boundp 'transient-mark-mode)
3910 transient-mark-mode)
3911 (setq mark-active nil))
3912 (if (not (setq result (let ((inhibit-read-only t))
3913 (gnus-request-article-this-buffer
3915 ;; There is no such article.
3917 (when (and (numberp article)
3918 (not (memq article gnus-newsgroup-sparse)))
3919 (setq gnus-article-current
3920 (cons gnus-newsgroup-name article))
3921 (set-buffer gnus-summary-buffer)
3922 (setq gnus-current-article article)
3923 (if (and (memq article gnus-newsgroup-undownloaded)
3924 (not (gnus-online (gnus-find-method-for-group
3925 gnus-newsgroup-name))))
3927 (gnus-summary-set-agent-mark article)
3928 (message "Message marked for downloading"))
3929 (gnus-summary-mark-article article gnus-canceled-mark)
3930 (unless (memq article gnus-newsgroup-sparse)
3931 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3932 (if (or (eq result 'pseudo)
3933 (eq result 'nneething))
3936 (set-buffer summary-buffer)
3937 (push article gnus-newsgroup-history)
3938 (setq gnus-last-article gnus-current-article
3939 gnus-current-article 0
3940 gnus-current-headers nil
3941 gnus-article-current nil)
3942 (if (eq result 'nneething)
3943 (gnus-configure-windows 'summary)
3944 (gnus-configure-windows 'article))
3945 (gnus-set-global-variables))
3946 (let ((gnus-article-mime-handle-alist-1
3947 gnus-article-mime-handle-alist))
3948 (gnus-set-mode-line 'article)))
3949 ;; The result from the `request' was an actual article -
3950 ;; or at least some text that is now displayed in the
3952 (when (and (numberp article)
3953 (not (eq article gnus-current-article)))
3954 ;; Seems like a new article has been selected.
3955 ;; `gnus-current-article' must be an article number.
3957 (set-buffer summary-buffer)
3958 (push article gnus-newsgroup-history)
3959 (setq gnus-last-article gnus-current-article
3960 gnus-current-article article
3961 gnus-current-headers
3962 (gnus-summary-article-header gnus-current-article)
3963 gnus-article-current
3964 (cons gnus-newsgroup-name gnus-current-article))
3965 (unless (vectorp gnus-current-headers)
3966 (setq gnus-current-headers nil))
3967 (gnus-summary-goto-subject gnus-current-article)
3968 (when (gnus-summary-show-thread)
3969 ;; If the summary buffer really was folded, the
3970 ;; previous goto may not actually have gone to
3971 ;; the right article, but the thread root instead.
3973 (gnus-summary-goto-subject gnus-current-article))
3974 (gnus-run-hooks 'gnus-mark-article-hook)
3975 (gnus-set-mode-line 'summary)
3976 (when (gnus-visual-p 'article-highlight 'highlight)
3977 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3978 ;; Set the global newsgroup variables here.
3979 (gnus-set-global-variables)
3980 (setq gnus-have-all-headers
3981 (or all-headers gnus-show-all-headers))))
3983 (gnus-configure-windows 'article))
3984 (when (or (numberp article)
3986 (gnus-article-prepare-display)
3988 (goto-char (point-min))
3989 (when gnus-break-pages
3990 (gnus-narrow-to-page)))
3991 (let ((gnus-article-mime-handle-alist-1
3992 gnus-article-mime-handle-alist))
3993 (gnus-set-mode-line 'article))
3997 (set-window-point (get-buffer-window (current-buffer)) (point))
3998 (gnus-configure-windows 'article)
4002 (defun gnus-article-prepare-display ()
4003 "Make the current buffer look like a nice article."
4004 ;; Hooks for getting information from the article.
4005 ;; This hook must be called before being narrowed.
4006 (let ((gnus-article-buffer (current-buffer))
4008 (inhibit-read-only t))
4009 (unless (eq major-mode 'gnus-article-mode)
4010 (gnus-article-mode))
4011 (setq buffer-read-only nil
4012 gnus-article-wash-types nil
4013 gnus-article-image-alist nil)
4014 (gnus-run-hooks 'gnus-tmp-internal-hook)
4015 (when gnus-display-mime-function
4016 (funcall gnus-display-mime-function))
4017 (gnus-run-hooks 'gnus-article-prepare-hook)))
4020 ;;; Gnus MIME viewing functions
4023 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4024 "Format of the MIME buttons.
4026 Valid specifiers include:
4028 %T MIME type, along with additional info
4029 %n The `name' parameter
4030 %d The description, if any
4031 %l The length of the encoded part
4032 %p The part identifier number
4033 %e Dots if the part isn't displayed
4035 General format specifiers can also be used. See Info node
4036 `(gnus)Formatting Variables'.")
4038 (defvar gnus-mime-button-line-format-alist
4039 '((?t gnus-tmp-type ?s)
4040 (?T gnus-tmp-type-long ?s)
4041 (?n gnus-tmp-name ?s)
4042 (?d gnus-tmp-description ?s)
4044 (?l gnus-tmp-length ?d)
4045 (?e gnus-tmp-dots ?s)))
4047 (defvar gnus-mime-button-commands
4048 '((gnus-article-press-button "\r" "Toggle Display")
4049 (gnus-mime-view-part "v" "View Interactively...")
4050 (gnus-mime-view-part-as-type "t" "View As Type...")
4051 (gnus-mime-view-part-as-charset "C" "View As charset...")
4052 (gnus-mime-save-part "o" "Save...")
4053 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4054 (gnus-mime-delete-part "d" "Delete part")
4055 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4056 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4057 (gnus-mime-view-part-internally "E" "View Internally")
4058 (gnus-mime-view-part-externally "e" "View Externally")
4059 (gnus-mime-print-part "p" "Print")
4060 (gnus-mime-pipe-part "|" "Pipe To Command...")
4061 (gnus-mime-action-on-part "." "Take action on the part...")))
4063 (defun gnus-article-mime-part-status ()
4064 (if gnus-article-mime-handle-alist-1
4065 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4067 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4070 (defvar gnus-mime-button-map
4071 (let ((map (make-sparse-keymap)))
4072 (define-key map gnus-mouse-2 'gnus-article-push-button)
4073 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4074 (dolist (c gnus-mime-button-commands)
4075 (define-key map (cadr c) (car c)))
4079 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4081 ,@(mapcar (lambda (c)
4082 (vector (caddr c) (car c) :enable t))
4083 gnus-mime-button-commands)))
4085 (defun gnus-mime-button-menu (event prefix)
4086 "Construct a context-sensitive menu of MIME commands."
4087 (interactive "e\nP")
4088 (save-window-excursion
4089 (let ((pos (event-start event)))
4090 (select-window (posn-window pos))
4091 (goto-char (posn-point pos))
4092 (gnus-article-check-buffer)
4093 (popup-menu gnus-mime-button-menu nil prefix))))
4095 (defun gnus-mime-view-all-parts (&optional handles)
4096 "View all the MIME parts."
4098 (with-current-buffer gnus-article-buffer
4099 (let ((handles (or handles gnus-article-mime-handles))
4100 (mail-parse-charset gnus-newsgroup-charset)
4101 (mail-parse-ignored-charsets
4102 (with-current-buffer gnus-summary-buffer
4103 gnus-newsgroup-ignored-charsets)))
4105 (mm-remove-parts handles)
4106 (goto-char (point-min))
4107 (or (search-forward "\n\n") (goto-char (point-max)))
4108 (let ((inhibit-read-only t))
4109 (delete-region (point) (point-max))
4110 (mm-display-parts handles))))))
4112 (defun gnus-article-jump-to-part (n)
4113 "Jump to MIME part N."
4115 (pop-to-buffer gnus-article-buffer)
4116 ;; FIXME: why is it necessary?
4118 (let ((parts (length gnus-article-mime-handle-alist)))
4121 (read-string ;; Emacs 21 doesn't have `read-number'.
4122 (format "Jump to part (2..%s): " parts)))))
4123 (unless (and (integerp n) (<= n parts) (>= n 1))
4126 (gnus-message 7 "Invalid part `%s', using %s instead."
4129 (gnus-message 9 "Jumping to part %s." n)
4130 (cond ((>= gnus-auto-select-part 1)
4131 (while (and (<= n parts)
4132 (not (gnus-article-goto-part n)))
4134 ((< gnus-auto-select-part 0)
4135 (while (and (>= n 1)
4136 (not (gnus-article-goto-part n)))
4139 (gnus-article-goto-part n)))))
4142 (defsubst gnus-article-edit-part (handles &optional current-id)
4143 "Edit an article in order to delete a mime part.
4144 This function is exclusively used by `gnus-mime-save-part-and-strip'
4145 and `gnus-mime-delete-part', and not provided at run-time normally."
4146 (gnus-article-edit-article
4148 (buffer-disable-undo)
4150 (let ((mail-parse-charset (or gnus-article-charset
4151 ',gnus-newsgroup-charset))
4152 (mail-parse-ignored-charsets
4153 (or gnus-article-ignored-charsets
4154 ',gnus-newsgroup-ignored-charsets))
4155 (mbl mml-buffer-list))
4156 (setq mml-buffer-list nil)
4157 (insert-buffer-substring gnus-original-article-buffer)
4158 (mime-to-mml ',handles)
4159 (setq gnus-article-mime-handles nil)
4160 (let ((mbl1 mml-buffer-list))
4161 (setq mml-buffer-list mbl)
4162 (set (make-local-variable 'mml-buffer-list) mbl1))
4163 (gnus-make-local-hook 'kill-buffer-hook)
4164 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4165 `(lambda (no-highlight)
4166 (let ((mail-parse-charset (or gnus-article-charset
4167 ',gnus-newsgroup-charset))
4168 (message-options message-options)
4169 (message-options-set-recipient)
4170 (mail-parse-ignored-charsets
4171 (or gnus-article-ignored-charsets
4172 ',gnus-newsgroup-ignored-charsets)))
4174 (mml-destroy-buffers)
4175 (remove-hook 'kill-buffer-hook
4176 'mml-destroy-buffers t)
4177 (kill-local-variable 'mml-buffer-list))
4178 (gnus-summary-edit-article-done
4179 ,(or (mail-header-references gnus-current-headers) "")
4180 ,(gnus-group-read-only-p)
4181 ,gnus-summary-buffer no-highlight))
4183 (gnus-article-edit-done)
4184 (gnus-summary-expand-window)
4185 (gnus-summary-show-article)
4186 (when (and current-id (integerp gnus-auto-select-part))
4187 (gnus-article-jump-to-part
4188 (+ current-id gnus-auto-select-part)))))
4190 (defun gnus-mime-save-part-and-strip ()
4191 "Save the MIME part under point then replace it with an external body."
4193 (gnus-article-check-buffer)
4194 (when (gnus-group-read-only-p)
4195 (error "The current group does not support deleting of parts"))
4196 (when (mm-complicated-handles gnus-article-mime-handles)
4198 The current article has a complicated MIME structure, giving up..."))
4199 (let* ((data (get-text-property (point) 'gnus-data))
4200 (id (get-text-property (point) 'gnus-part))
4202 (handles gnus-article-mime-handles))
4203 (setq file (and data (mm-save-part data "Delete MIME part and save to: ")))
4205 (with-current-buffer (mm-handle-buffer data)
4207 (insert "Content-Type: " (mm-handle-media-type data))
4208 (mml-insert-parameter-string (cdr (mm-handle-type data))
4211 (insert "Content-ID: " (message-make-message-id) "\n")
4212 (insert "Content-Transfer-Encoding: binary\n")
4215 (cdr (mm-make-handle nil
4216 `("message/external-body"
4217 (access-type . "LOCAL-FILE")
4219 ;; (set-buffer gnus-summary-buffer)
4220 (gnus-article-edit-part handles id))))
4222 (defun gnus-mime-delete-part ()
4223 "Delete the MIME part under point.
4224 Replace it with some information about the removed part."
4226 (gnus-article-check-buffer)
4227 (when (gnus-group-read-only-p)
4228 (error "The current group does not support deleting of parts"))
4229 (when (mm-complicated-handles gnus-article-mime-handles)
4231 The current article has a complicated MIME structure, giving up..."))
4232 (when (or gnus-expert-user
4233 (gnus-yes-or-no-p "\
4234 Deleting parts may malfunction or destroy the article; continue? "))
4235 (let* ((data (get-text-property (point) 'gnus-data))
4236 (id (get-text-property (point) 'gnus-part))
4237 (handles gnus-article-mime-handles)
4241 (mail-decode-encoded-word-string (or (mm-handle-description data)
4244 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4246 (type (mm-handle-media-type data)))
4248 (error "No MIME part under point"))
4249 (with-current-buffer (mm-handle-buffer data)
4250 (let ((bsize (format "%s" (buffer-size))))
4255 "| The following attachment has been deleted:\n"
4257 "| Type: " type "\n"
4258 "| Filename: " filename "\n"
4259 "| Size (encoded): " bsize " Byte\n"
4260 "| Description: " description "\n"
4263 (cdr (mm-make-handle
4264 nil `("text/plain") nil nil
4266 (format "Deleted attachment (%s bytes)" bsize))))))
4267 ;; (set-buffer gnus-summary-buffer)
4268 (gnus-article-edit-part handles id))))
4270 (defun gnus-mime-save-part ()
4271 "Save the MIME part under point."
4273 (gnus-article-check-buffer)
4274 (let ((data (get-text-property (point) 'gnus-data)))
4276 (mm-save-part data))))
4278 (defun gnus-mime-pipe-part ()
4279 "Pipe the MIME part under point to a process."
4281 (gnus-article-check-buffer)
4282 (let ((data (get-text-property (point) 'gnus-data)))
4284 (mm-pipe-part data))))
4286 (defun gnus-mime-view-part ()
4287 "Interactively choose a viewing method for the MIME part under point."
4289 (gnus-article-check-buffer)
4290 (let ((data (get-text-property (point) 'gnus-data)))
4292 (setq gnus-article-mime-handles
4294 gnus-article-mime-handles (setq data (copy-sequence data))))
4295 (mm-interactively-view-part data))))
4297 (defun gnus-mime-view-part-as-type-internal ()
4298 (gnus-article-check-buffer)
4299 (let* ((name (mail-content-type-get
4300 (mm-handle-type (get-text-property (point) 'gnus-data))
4302 (def-type (and name (mm-default-file-encoding name))))
4303 (and def-type (cons def-type 0))))
4305 (defun gnus-mime-view-part-as-type (&optional mime-type)
4306 "Choose a MIME media type, and view the part as such."
4309 (setq mime-type (completing-read
4310 "View as MIME type: "
4311 (mapcar #'list (mailcap-mime-types))
4313 (gnus-mime-view-part-as-type-internal))))
4314 (gnus-article-check-buffer)
4315 (let ((handle (get-text-property (point) 'gnus-data)))
4318 (mm-make-handle (mm-handle-buffer handle)
4319 (cons mime-type (cdr (mm-handle-type handle)))
4320 (mm-handle-encoding handle)
4321 (mm-handle-undisplayer handle)
4322 (mm-handle-disposition handle)
4323 (mm-handle-description handle)
4325 (mm-handle-id handle)))
4326 (setq gnus-article-mime-handles
4327 (mm-merge-handles gnus-article-mime-handles handle))
4328 (gnus-mm-display-part handle))))
4330 (defun gnus-mime-copy-part (&optional handle arg)
4331 "Put the MIME part under point into a new buffer.
4332 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4334 (interactive (list nil current-prefix-arg))
4335 (gnus-article-check-buffer)
4337 (setq handle (get-text-property (point) 'gnus-data)))
4339 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4341 (mail-content-type-get (mm-handle-disposition handle)
4343 contents dont-decode charset coding-system)
4344 (mm-with-unibyte-buffer
4345 (mm-insert-part handle)
4346 (setq contents (or (condition-case nil
4347 (mm-decompress-buffer filename nil 'sig)
4349 (setq dont-decode t)
4352 (setq filename (cond (filename (file-name-nondirectory filename))
4353 (dont-decode "*raw data*")
4358 (unless (setq charset (mail-content-type-get
4359 (mm-handle-type handle) 'charset))
4360 (unless (setq coding-system (mm-with-unibyte-buffer
4362 (mm-find-buffer-file-coding-system)))
4363 (setq charset gnus-newsgroup-charset))))
4365 (setq charset (or (cdr (assq arg
4366 gnus-summary-show-article-charset-alist))
4367 (mm-read-coding-system "Charset: ")))))
4368 (switch-to-buffer (generate-new-buffer filename))
4369 (if (or coding-system
4371 (setq coding-system (mm-charset-to-coding-system charset))
4372 (not (eq charset 'ascii))))
4374 (mm-enable-multibyte)
4375 (insert (mm-decode-coding-string contents coding-system))
4376 (setq buffer-file-coding-system
4377 (if (boundp 'last-coding-system-used)
4378 (symbol-value 'last-coding-system-used)
4380 (mm-disable-multibyte)
4382 (setq buffer-file-coding-system mm-binary-coding-system))
4383 ;; We do it this way to make `normal-mode' set the appropriate mode.
4386 (setq buffer-file-name (expand-file-name filename))
4388 (setq buffer-file-name nil))
4389 (goto-char (point-min)))))
4391 (defun gnus-mime-print-part (&optional handle filename)
4392 "Print the MIME part under point."
4393 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4394 (gnus-article-check-buffer)
4395 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4396 (contents (and handle (mm-get-part handle)))
4397 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4398 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4403 (mm-save-part-to-file handle file)
4404 (call-process shell-file-name nil
4405 (generate-new-buffer " *mm*")
4407 shell-command-switch
4409 printer file (mm-handle-type handle))))
4413 (gnus-print-buffer))
4414 (ps-despool filename)))))
4416 (defun gnus-mime-inline-part (&optional handle arg)
4417 "Insert the MIME part under point into the current buffer.
4418 Compressed files like .gz and .bz2 are decompressed."
4419 (interactive (list nil current-prefix-arg))
4420 (gnus-article-check-buffer)
4422 (setq handle (get-text-property (point) 'gnus-data)))
4425 (inhibit-read-only t)
4426 contents charset coding-system)
4427 (if (and (not arg) (mm-handle-undisplayer handle))
4428 (mm-remove-part handle)
4429 (mm-with-unibyte-buffer
4430 (mm-insert-part handle)
4432 (or (mm-decompress-buffer
4433 (or (mail-content-type-get (mm-handle-disposition handle)
4435 (mail-content-type-get (mm-handle-disposition handle)
4441 (unless (setq charset (mail-content-type-get
4442 (mm-handle-type handle) 'charset))
4443 (unless (setq coding-system
4444 (mm-with-unibyte-buffer
4446 (mm-find-buffer-file-coding-system)))
4447 (setq charset gnus-newsgroup-charset))))
4449 (if (mm-handle-undisplayer handle)
4450 (mm-remove-part handle))
4453 gnus-summary-show-article-charset-alist))
4454 (mm-read-coding-system "Charset: "))))
4456 (if (mm-handle-undisplayer handle)
4457 (mm-remove-part handle))))
4461 (if (or coding-system
4464 (mm-charset-to-coding-system charset))
4465 (not (eq coding-system 'ascii))))
4466 (mm-decode-coding-string contents coding-system)
4467 (mm-string-to-multibyte contents)))
4470 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4471 "Insert the MIME part under point into the current buffer using the
4473 (interactive (list nil current-prefix-arg))
4474 (gnus-article-check-buffer)
4475 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4478 (inhibit-read-only t))
4480 (if (mm-handle-undisplayer handle)
4481 (mm-remove-part handle))
4482 (let ((gnus-newsgroup-charset
4484 gnus-summary-show-article-charset-alist))
4485 (mm-read-coding-system "Charset: ")))
4486 (gnus-newsgroup-ignored-charsets 'gnus-all))
4487 (gnus-article-press-button)))))
4489 (defun gnus-mime-view-part-externally (&optional handle)
4490 "View the MIME part under point with an external viewer."
4492 (gnus-article-check-buffer)
4493 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4494 (mm-user-display-methods nil)
4495 (mm-inlined-types nil)
4496 (mail-parse-charset gnus-newsgroup-charset)
4497 (mail-parse-ignored-charsets
4498 (with-current-buffer gnus-summary-buffer
4499 gnus-newsgroup-ignored-charsets)))
4501 (if (mm-handle-undisplayer handle)
4502 (mm-remove-part handle)
4503 (mm-display-part handle)))))
4505 (defun gnus-mime-view-part-internally (&optional handle)
4506 "View the MIME part under point with an internal viewer.
4507 If no internal viewer is available, use an external viewer."
4509 (gnus-article-check-buffer)
4510 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4511 (mm-inlined-types '(".*"))
4512 (mm-inline-large-images t)
4513 (mail-parse-charset gnus-newsgroup-charset)
4514 (mail-parse-ignored-charsets
4515 (with-current-buffer gnus-summary-buffer
4516 gnus-newsgroup-ignored-charsets))
4517 (inhibit-read-only t))
4519 (if (mm-handle-undisplayer handle)
4520 (mm-remove-part handle)
4521 (mm-display-part handle)))))
4523 (defun gnus-mime-action-on-part (&optional action)
4524 "Do something with the MIME attachment at \(point\)."
4526 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4527 (gnus-article-check-buffer)
4528 (let ((action-pair (assoc action gnus-mime-action-alist)))
4530 (funcall (cdr action-pair)))))
4532 (defun gnus-article-part-wrapper (n function &optional no-handle)
4534 ;; Check whether the article is displayed.
4535 (unless (and (gnus-buffer-live-p gnus-article-buffer)
4536 (setq window (get-buffer-window gnus-article-buffer t))
4537 (frame-visible-p (setq frame (window-frame window))))
4538 (error "No article is displayed"))
4539 (with-current-buffer gnus-article-buffer
4540 ;; Check whether the article displays the right contents.
4541 (unless (with-current-buffer gnus-summary-buffer
4542 (eq gnus-current-article (gnus-summary-article-number)))
4543 (error "You should select the right article first"))
4544 ;; Check whether the specified part exists.
4545 (when (> n (length gnus-article-mime-handle-alist))
4546 (error "No such part")))
4549 ;; To select the window is needed so that the cursor
4550 ;; might be visible on the MIME button.
4551 (select-window (prog1
4553 (setq window (selected-window))
4554 ;; Article may be displayed in the other frame.
4555 (gnus-select-frame-set-input-focus
4558 (setq frame (selected-frame))))))
4559 (when (gnus-article-goto-part n)
4560 ;; We point the cursor and the arrow at the MIME button
4561 ;; when the `function' prompt the user for something.
4562 (let ((cursor-in-non-selected-windows t)
4563 (overlay-arrow-string "=>")
4564 (overlay-arrow-position (point-marker)))
4569 (cdr (assq n gnus-article-mime-handle-alist))))
4570 (set-marker overlay-arrow-position nil)
4571 (unless gnus-auto-select-part
4572 (gnus-select-frame-set-input-focus frame)
4573 (select-window window))))
4575 (if gnus-inhibit-mime-unbuttonizing
4576 ;; This is the default though the program shouldn't reach here.
4577 (error "No such part")
4578 ;; The part which doesn't have the MIME button is selected.
4579 ;; So, we display all the buttons and redo it.
4580 (let ((gnus-inhibit-mime-unbuttonizing t))
4581 (gnus-summary-show-article)
4582 (gnus-article-part-wrapper n function no-handle))))))
4584 (defun gnus-article-pipe-part (n)
4585 "Pipe MIME part N, which is the numerical prefix."
4587 (gnus-article-part-wrapper n 'mm-pipe-part))
4589 (defun gnus-article-save-part (n)
4590 "Save MIME part N, which is the numerical prefix."
4592 (gnus-article-part-wrapper n 'mm-save-part))
4594 (defun gnus-article-interactively-view-part (n)
4595 "View MIME part N interactively, which is the numerical prefix."
4597 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4599 (defun gnus-article-copy-part (n)
4600 "Copy MIME part N, which is the numerical prefix."
4602 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4604 (defun gnus-article-view-part-as-charset (n)
4605 "View MIME part N using a specified charset.
4606 N is the numerical prefix."
4608 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4610 (defun gnus-article-view-part-externally (n)
4611 "View MIME part N externally, which is the numerical prefix."
4613 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4615 (defun gnus-article-inline-part (n)
4616 "Inline MIME part N, which is the numerical prefix."
4618 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4620 (defun gnus-article-save-part-and-strip (n)
4621 "Save MIME part N and replace it with an external body.
4622 N is the numerical prefix."
4624 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
4626 (defun gnus-article-delete-part (n)
4627 "Delete MIME part N and add some information about the removed part.
4628 N is the numerical prefix."
4630 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
4632 (defun gnus-article-mime-match-handle-first (condition)
4635 (dolist (ihandle gnus-article-mime-handle-alist)
4637 ((functionp condition)
4638 (funcall condition (cdr ihandle)))
4639 ((eq condition 'undisplayed)
4640 (not (or (mm-handle-undisplayer (cdr ihandle))
4641 (equal (mm-handle-media-type (cdr ihandle))
4642 "multipart/alternative"))))
4643 ((eq condition 'undisplayed-alternative)
4644 (not (mm-handle-undisplayer (cdr ihandle))))
4646 (gnus-article-goto-part (car ihandle))
4647 (or (not n) (< (car ihandle) n)))
4648 (setq n (car ihandle))))
4652 (defun gnus-article-view-part (&optional n)
4653 "View MIME part N, which is the numerical prefix."
4655 (with-current-buffer gnus-article-buffer
4656 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4657 gnus-article-mime-match-handle-function)))
4658 (when (> n (length gnus-article-mime-handle-alist))
4659 (error "No such part"))
4660 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4661 (when (gnus-article-goto-part n)
4662 (if (equal (car handle) "multipart/alternative")
4663 (gnus-article-press-button)
4664 (when (eq (gnus-mm-display-part handle) 'internal)
4665 (gnus-set-window-start)))))))
4667 (defsubst gnus-article-mime-total-parts ()
4668 (if (bufferp (car gnus-article-mime-handles))
4670 (1- (length gnus-article-mime-handles))))
4672 (defun gnus-mm-display-part (handle)
4673 "Display HANDLE and fix MIME button."
4674 (let ((id (get-text-property (point) 'gnus-part))
4676 (inhibit-read-only t))
4679 (let ((window (selected-window))
4680 (mail-parse-charset gnus-newsgroup-charset)
4681 (mail-parse-ignored-charsets
4682 (if (gnus-buffer-live-p gnus-summary-buffer)
4683 (with-current-buffer gnus-summary-buffer
4684 gnus-newsgroup-ignored-charsets)
4688 (let ((win (gnus-get-buffer-window (current-buffer) t))
4691 (select-window win))
4694 (if (mm-handle-displayed-p handle)
4695 ;; This will remove the part.
4696 (mm-display-part handle)
4698 (narrow-to-region (point)
4699 (if (eobp) (point) (1+ (point))))
4700 (mm-display-part handle)
4701 ;; We narrow to the part itself and
4702 ;; then call the treatment functions.
4703 (goto-char (point-min))
4705 (narrow-to-region (point) (point-max))
4708 (gnus-article-mime-total-parts)
4709 (mm-handle-media-type handle)))))
4710 (if (window-live-p window)
4711 (select-window window)))))
4714 (gnus-insert-mime-button
4715 handle id (list (mm-handle-displayed-p handle)))
4716 (goto-char point))))
4718 (defun gnus-article-goto-part (n)
4719 "Go to MIME part N."
4720 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4722 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4723 (let ((gnus-tmp-name
4724 (or (mail-content-type-get (mm-handle-type handle) 'name)
4725 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4726 (mail-content-type-get (mm-handle-type handle) 'url)
4728 (gnus-tmp-type (mm-handle-media-type handle))
4729 (gnus-tmp-description
4730 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4733 (if (if displayed (car displayed)
4734 (mm-handle-displayed-p handle))
4736 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4738 gnus-tmp-type-long b e)
4739 (when (string-match ".*/" gnus-tmp-name)
4740 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4741 (setq gnus-tmp-type-long (concat gnus-tmp-type
4742 (and (not (equal gnus-tmp-name ""))
4743 (concat "; " gnus-tmp-name))))
4744 (unless (equal gnus-tmp-description "")
4745 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4750 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4751 `(keymap ,gnus-mime-button-map
4752 gnus-callback gnus-mm-display-part
4753 gnus-part ,gnus-tmp-id
4754 article-type annotation
4757 ;; Exclude a newline.
4760 (widget-convert-button
4763 :action 'gnus-widget-press-button
4764 :button-keymap gnus-mime-button-map
4766 (lambda (widget/window &optional overlay pos)
4767 ;; Needed to properly clear the message due to a bug in
4768 ;; wid-edit (XEmacs only).
4769 (if (boundp 'help-echo-owns-message)
4770 (setq help-echo-owns-message t))
4772 "%S: %s the MIME part; %S: more options"
4773 (aref gnus-mouse-2 0)
4774 ;; XEmacs will get a single widget arg; Emacs 21 will get
4775 ;; window, overlay, position.
4776 (if (mm-handle-displayed-p
4778 (with-current-buffer (gnus-overlay-buffer overlay)
4779 (widget-get (widget-at (gnus-overlay-start overlay))
4781 (widget-get widget/window :mime-handle)))
4783 (aref gnus-down-mouse-3 0))))))
4785 (defun gnus-widget-press-button (elems el)
4786 (goto-char (widget-get elems :from))
4787 (gnus-article-press-button))
4789 (defvar gnus-displaying-mime nil)
4791 (defun gnus-display-mime (&optional ihandles)
4792 "Display the MIME parts."
4794 (save-selected-window
4795 (let ((window (get-buffer-window gnus-article-buffer))
4798 (select-window window)
4799 ;; We have to do this since selecting the window
4800 ;; may change the point. So we set the window point.
4801 (set-window-point window point)))
4802 (let ((handles ihandles)
4803 (inhibit-read-only t)
4806 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
4807 (when gnus-article-emulate-mime
4808 (mm-uu-dissect-text-parts handles)))
4809 (gnus-article-emulate-mime
4810 (setq handles (mm-uu-dissect))))
4811 (when (and (not ihandles)
4812 (not gnus-displaying-mime))
4813 ;; Top-level call; we clean up.
4814 (when gnus-article-mime-handles
4815 (mm-destroy-parts gnus-article-mime-handles)
4816 (setq gnus-article-mime-handle-alist nil));; A trick.
4817 (setq gnus-article-mime-handles handles)
4818 ;; We allow users to glean info from the handles.
4819 (when gnus-article-mime-part-function
4820 (gnus-mime-part-function handles)))
4822 (or (not (stringp (car handles)))
4825 (when (and (not ihandles)
4826 (not gnus-displaying-mime))
4827 ;; Clean up for mime parts.
4829 (delete-region (point) (point-max)))
4830 (let ((gnus-displaying-mime t))
4831 (gnus-mime-display-part handles)))
4834 (narrow-to-region (point) (point-max))
4835 (gnus-treat-article nil 1 1)
4838 ;; Highlight the headers.
4842 (narrow-to-region (point-min) (point))
4843 (gnus-article-save-original-date
4844 (gnus-treat-article 'head)))))))))
4846 (defcustom gnus-mime-display-multipart-as-mixed nil
4847 "Display \"multipart\" parts as \"multipart/mixed\".
4849 If t, it overrides nil values of
4850 `gnus-mime-display-multipart-alternative-as-mixed' and
4851 `gnus-mime-display-multipart-related-as-mixed'."
4852 :group 'gnus-article-mime
4855 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4856 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4858 :group 'gnus-article-mime
4861 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4862 "Display \"multipart/related\" parts as \"multipart/mixed\".
4864 If displaying \"text/html\" is discouraged \(see
4865 `mm-discouraged-alternatives'\) images or other material inside a
4866 \"multipart/related\" part might be overlooked when this variable is nil."
4868 :group 'gnus-article-mime
4871 (defun gnus-mime-display-part (handle)
4873 ;; Maybe a broken MIME message.
4876 ((not (stringp (car handle)))
4877 (gnus-mime-display-single handle))
4878 ;; User-defined multipart
4879 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4880 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4882 ;; multipart/alternative
4883 ((and (equal (car handle) "multipart/alternative")
4884 (not (or gnus-mime-display-multipart-as-mixed
4885 gnus-mime-display-multipart-alternative-as-mixed)))
4886 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4887 (push (cons id handle) gnus-article-mime-handle-alist)
4888 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4889 ;; multipart/related
4890 ((and (equal (car handle) "multipart/related")
4891 (not (or gnus-mime-display-multipart-as-mixed
4892 gnus-mime-display-multipart-related-as-mixed)))
4893 ;;;!!!We should find the start part, but we just default
4894 ;;;!!!to the first part.
4895 ;;(gnus-mime-display-part (cadr handle))
4896 ;;;!!! Most multipart/related is an HTML message plus images.
4897 ;;;!!! Unfortunately we are unable to let W3 display those
4898 ;;;!!! included images, so we just display it as a mixed multipart.
4899 ;;(gnus-mime-display-mixed (cdr handle))
4900 ;;;!!! No, w3 can display everything just fine.
4901 (gnus-mime-display-part (cadr handle)))
4902 ((equal (car handle) "multipart/signed")
4903 (gnus-add-wash-type 'signed)
4904 (gnus-mime-display-security handle))
4905 ((equal (car handle) "multipart/encrypted")
4906 (gnus-add-wash-type 'encrypted)
4907 (gnus-mime-display-security handle))
4908 ;; Other multiparts are handled like multipart/mixed.
4910 (gnus-mime-display-mixed (cdr handle)))))
4912 (defun gnus-mime-part-function (handles)
4913 (if (stringp (car handles))
4914 (mapcar 'gnus-mime-part-function (cdr handles))
4915 (funcall gnus-article-mime-part-function handles)))
4917 (defun gnus-mime-display-mixed (handles)
4918 (mapcar 'gnus-mime-display-part handles))
4920 (defun gnus-mime-display-single (handle)
4921 (let ((type (mm-handle-media-type handle))
4922 (ignored gnus-ignored-mime-types)
4929 (when (string-match (pop ignored) type)
4930 (throw 'ignored nil)))
4931 (if (and (setq not-attachment
4932 (and (not (mm-inline-override-p handle))
4933 (or (not (mm-handle-disposition handle))
4934 (equal (car (mm-handle-disposition handle))
4936 (mm-attachment-override-p handle))))
4937 (mm-automatic-display-p handle)
4939 (mm-inlinable-p handle)
4940 (mm-inlined-p handle))
4941 (mm-automatic-external-display-p type)))
4943 (when (equal (mm-handle-media-supertype handle) "text")
4945 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4947 (push (cons id handle) gnus-article-mime-handle-alist)
4948 (when (or (not display)
4949 (not (gnus-unbuttonized-mime-type-p type)))
4950 (gnus-insert-mime-button
4951 handle id (list (or display (and not-attachment text))))
4952 (gnus-article-insert-newline)
4953 ;; Remember modify the number of forward lines.
4961 (let ((mail-parse-charset gnus-newsgroup-charset)
4962 (mail-parse-ignored-charsets
4963 (save-excursion (condition-case ()
4964 (set-buffer gnus-summary-buffer)
4966 gnus-newsgroup-ignored-charsets)))
4967 (mm-display-part handle t))
4968 (goto-char (point-max)))
4969 ((and text not-attachment)
4973 (gnus-article-insert-newline)
4974 (mm-insert-inline handle
4976 (mail-content-type-get
4977 (mm-handle-type handle) 'charset)))
4978 (if (eq charset 'gnus-decoded)
4979 (mm-get-part handle)
4980 (mm-decode-string (mm-get-part handle)
4982 (goto-char (point-max))))
4986 (narrow-to-region beg (point))
4989 (gnus-article-mime-total-parts)
4990 (mm-handle-media-type handle)))))))))
4992 (defun gnus-unbuttonized-mime-type-p (type)
4993 "Say whether TYPE is to be unbuttonized."
4994 (unless gnus-inhibit-mime-unbuttonizing
4996 (let ((types gnus-unbuttonized-mime-types))
4998 (when (string-match (pop types) type)
4999 (throw 'found t)))))
5001 (let ((types gnus-buttonized-mime-types))
5003 (when (string-match (pop types) type)
5004 (throw 'found t)))))))))
5006 (defun gnus-article-insert-newline ()
5007 "Insert a newline, but mark it as undeletable."
5008 (gnus-put-text-property
5009 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5011 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5012 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5015 handle (inhibit-read-only t) from props begend not-pref)
5016 (save-window-excursion
5019 (narrow-to-region (car ibegend)
5022 (goto-char (car ibegend))
5025 (delete-region (point-min) (point-max))
5026 (mm-remove-parts handles))
5027 (setq begend (list (point-marker)))
5029 (unless (setq not-pref (cadr (member preferred ihandles)))
5030 (setq not-pref (car ihandles)))
5033 (not (gnus-unbuttonized-mime-type-p
5034 "multipart/alternative")))
5035 (gnus-add-text-properties
5038 (insert (format "%d. " id))
5042 (unless ,(not ibegend)
5043 (setq gnus-article-mime-handle-alist
5044 ',gnus-article-mime-handle-alist))
5045 (gnus-mime-display-alternative
5046 ',ihandles ',not-pref ',begend ,id))
5047 keymap ,gnus-mime-button-map
5048 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5049 face ,gnus-article-button-face
5052 (widget-convert-button 'link from (point)
5053 :action 'gnus-widget-press-button
5054 :button-keymap gnus-widget-button-keymap)
5056 (while (setq handle (pop handles))
5057 (gnus-add-text-properties
5060 (insert (format "(%c) %-18s"
5061 (if (equal handle preferred) ?* ? )
5062 (mm-handle-media-type handle)))
5066 (unless ,(not ibegend)
5067 (setq gnus-article-mime-handle-alist
5068 ',gnus-article-mime-handle-alist))
5069 (gnus-mime-display-alternative
5070 ',ihandles ',handle ',begend ,id))
5071 keymap ,gnus-mime-button-map
5072 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5073 face ,gnus-article-button-face
5076 (widget-convert-button 'link from (point)
5077 :action 'gnus-widget-press-button
5078 :button-keymap gnus-widget-button-keymap)
5082 (if (stringp (car preferred))
5083 (gnus-display-mime preferred)
5084 (let ((mail-parse-charset gnus-newsgroup-charset)
5085 (mail-parse-ignored-charsets
5086 (with-current-buffer gnus-summary-buffer
5087 gnus-newsgroup-ignored-charsets)))
5088 (mm-display-part preferred)
5092 (narrow-to-region (car begend) (point-max))
5094 nil (length gnus-article-mime-handle-alist)
5095 (gnus-article-mime-total-parts)
5096 (mm-handle-media-type handle))))))
5097 (goto-char (point-max))
5098 (setcdr begend (point-marker)))))
5100 (goto-char point))))
5102 (defconst gnus-article-wash-status-strings
5103 (let ((alist '((cite "c" "Possible hidden citation text"
5104 " " "All citation text visible")
5105 (headers "h" "Hidden headers"
5106 " " "All headers visible.")
5107 (pgp "p" "Encrypted or signed message status hidden"
5108 " " "No hidden encryption nor digital signature status")
5109 (signature "s" "Signature has been hidden"
5110 " " "Signature is visible")
5111 (overstrike "o" "Overstrike (^H) characters applied"
5112 " " "No overstrike characters applied")
5113 (emphasis "e" "/*_Emphasis_*/ characters applied"
5114 " " "No /*_emphasis_*/ characters applied")))
5116 (dolist (entry alist result)
5117 (let ((key (nth 0 entry))
5118 (on (copy-sequence (nth 1 entry)))
5119 (on-help (nth 2 entry))
5120 (off (copy-sequence (nth 3 entry)))
5121 (off-help (nth 4 entry)))
5122 (put-text-property 0 1 'help-echo on-help on)
5123 (put-text-property 0 1 'help-echo off-help off)
5124 (push (list key on off) result))))
5125 "Alist of strings describing wash status in the mode line.
5126 Each entry has the form (KEY ON OF), where the KEY is a symbol
5127 representing the particular washing function, ON is the string to use
5128 in the article mode line when the washing function is active, and OFF
5129 is the string to use when it is inactive.")
5131 (defun gnus-article-wash-status-entry (key value)
5132 (let ((entry (assoc key gnus-article-wash-status-strings)))
5133 (if value (nth 1 entry) (nth 2 entry))))
5135 (defun gnus-article-wash-status ()
5136 "Return a string which display status of article washing."
5137 (with-current-buffer gnus-article-buffer
5138 (let ((cite (memq 'cite gnus-article-wash-types))
5139 (headers (memq 'headers gnus-article-wash-types))
5140 (boring (memq 'boring-headers gnus-article-wash-types))
5141 (pgp (memq 'pgp gnus-article-wash-types))
5142 (pem (memq 'pem gnus-article-wash-types))
5143 (signed (memq 'signed gnus-article-wash-types))
5144 (encrypted (memq 'encrypted gnus-article-wash-types))
5145 (signature (memq 'signature gnus-article-wash-types))
5146 (overstrike (memq 'overstrike gnus-article-wash-types))
5147 (emphasis (memq 'emphasis gnus-article-wash-types)))
5149 (gnus-article-wash-status-entry 'cite cite)
5150 (gnus-article-wash-status-entry 'headers (or headers boring))
5151 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5152 (gnus-article-wash-status-entry 'signature signature)
5153 (gnus-article-wash-status-entry 'overstrike overstrike)
5154 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5156 (defun gnus-add-wash-type (type)
5157 "Add a washing of TYPE to the current status."
5158 (add-to-list 'gnus-article-wash-types type))
5160 (defun gnus-delete-wash-type (type)
5161 "Add a washing of TYPE to the current status."
5162 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5164 (defun gnus-add-image (category image)
5165 "Add IMAGE of CATEGORY to the list of displayed images."
5166 (let ((entry (assq category gnus-article-image-alist)))
5168 (setq entry (list category))
5169 (push entry gnus-article-image-alist))
5170 (nconc entry (list image))))
5172 (defun gnus-delete-images (category)
5173 "Delete all images in CATEGORY."
5174 (let ((entry (assq category gnus-article-image-alist)))
5175 (dolist (image (cdr entry))
5176 (gnus-remove-image image category))
5177 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5178 (gnus-delete-wash-type category)))
5180 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5182 (defun gnus-article-maybe-hide-headers ()
5183 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5184 Provided for backwards compatibility."
5185 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5186 (not (with-current-buffer gnus-summary-buffer
5187 gnus-have-all-headers)))
5188 (not gnus-inhibit-hiding))
5189 (gnus-article-hide-headers)))
5193 (defun gnus-output-to-file (file-name)
5194 "Append the current article to a file named FILE-NAME."
5195 (let ((artbuf (current-buffer)))
5197 (insert-buffer-substring artbuf)
5198 ;; Append newline at end of the buffer as separator, and then
5200 (goto-char (point-max))
5202 (let ((file-name-coding-system nnmail-pathname-coding-system))
5203 (mm-append-to-file (point-min) (point-max) file-name))
5206 (defun gnus-narrow-to-page (&optional arg)
5207 "Narrow the article buffer to a page.
5208 If given a numerical ARG, move forward ARG pages."
5210 (setq arg (if arg (prefix-numeric-value arg) 0))
5212 (set-buffer gnus-article-buffer)
5213 (goto-char (point-min))
5215 ;; Remove any old next/prev buttons.
5216 (when (gnus-visual-p 'page-marker)
5217 (let ((inhibit-read-only t))
5218 (gnus-remove-text-with-property 'gnus-prev)
5219 (gnus-remove-text-with-property 'gnus-next)))
5222 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5224 (re-search-forward page-delimiter nil 'move arg)))
5225 (goto-char (match-end 0))
5227 (goto-char (point-min))
5228 (setq gnus-page-broken
5229 (and (re-search-forward page-delimiter nil t) t))))
5230 (when gnus-page-broken
5233 (if (re-search-forward page-delimiter nil 'move)
5236 (when (and (gnus-visual-p 'page-marker)
5237 (> (point-min) (save-restriction (widen) (point-min))))
5239 (goto-char (point-min))
5240 (gnus-insert-prev-page-button)))
5241 (when (and (gnus-visual-p 'page-marker)
5242 (< (point-max) (save-restriction (widen) (point-max))))
5244 (goto-char (point-max))
5245 (gnus-insert-next-page-button))))))
5247 ;; Article mode commands
5249 (defun gnus-article-goto-next-page ()
5250 "Show the next page of the article."
5252 (when (gnus-article-next-page)
5253 (goto-char (point-min))
5254 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5257 (defun gnus-article-goto-prev-page ()
5258 "Show the previous page of the article."
5261 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5262 (gnus-article-prev-page nil)))
5264 ;; This is cleaner but currently breaks `gnus-pick-mode':
5266 ;; (defun gnus-article-goto-next-page ()
5267 ;; "Show the next page of the article."
5269 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5270 ;; (gnus-summary-next-page)))
5272 ;; (defun gnus-article-goto-prev-page ()
5273 ;; "Show the next page of the article."
5275 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5276 ;; (gnus-summary-prev-page)))
5278 (defun gnus-article-next-page (&optional lines)
5279 "Show the next page of the current article.
5280 If end of article, return non-nil. Otherwise return nil.
5281 Argument LINES specifies lines to be scrolled up."
5283 (move-to-window-line -1)
5286 (and (pos-visible-in-window-p) ;Not continuation line.
5287 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5288 ;; Nothing in this page.
5289 (if (or (not gnus-page-broken)
5294 (eobp)))) ;Real end-of-buffer?
5296 (when gnus-article-over-scroll
5297 (gnus-article-next-page-1 lines))
5299 (gnus-narrow-to-page 1) ;Go to next page.
5301 ;; More in this page.
5302 (gnus-article-next-page-1 lines)
5305 (defmacro gnus-article-beginning-of-window ()
5306 "Move point to the beginning of the window.
5307 In Emacs, the point is placed at the line number which `scroll-margin'
5309 (if (featurep 'xemacs)
5310 '(move-to-window-line 0)
5311 '(move-to-window-line
5312 (min (max 0 scroll-margin)
5313 (max 1 (- (window-height)
5314 (if mode-line-format 1 0)
5315 (if header-line-format 1 0)))))))
5317 (defun gnus-article-next-page-1 (lines)
5318 (when (and (not (featurep 'xemacs))
5321 (numberp (symbol-value 'scroll-margin))
5322 (> (symbol-value 'scroll-margin) 0))
5323 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5324 ;; too many number of lines if `scroll-margin' is set as two or greater.
5325 (setq lines (min lines
5326 (max 0 (- (count-lines (window-start) (point-max))
5327 (symbol-value 'scroll-margin))))))
5329 (let ((scroll-in-place nil))
5332 ;; Long lines may cause an end-of-buffer error.
5333 (goto-char (point-max))))
5334 (gnus-article-beginning-of-window))
5336 (defun gnus-article-prev-page (&optional lines)
5337 "Show previous page of current article.
5338 Argument LINES specifies lines to be scrolled down."
5340 (move-to-window-line 0)
5341 (if (and gnus-page-broken
5343 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5345 (gnus-narrow-to-page -1) ;Go to previous page.
5346 (goto-char (point-max))
5350 (let ((scroll-in-place nil))
5351 (scroll-down lines))
5352 (beginning-of-buffer
5353 (goto-char (point-min))))
5354 (gnus-article-beginning-of-window))))
5356 (defun gnus-article-only-boring-p ()
5357 "Decide whether there is only boring text remaining in the article.
5358 Something \"interesting\" is a word of at least two letters that does
5359 not have a face in `gnus-article-boring-faces'."
5360 (when (and gnus-article-skip-boring
5361 (boundp 'gnus-article-boring-faces)
5362 (symbol-value 'gnus-article-boring-faces))
5365 (while (re-search-forward "\\b\\w\\w" nil t)
5367 (when (not (gnus-intersection
5368 (gnus-faces-at (point))
5369 (symbol-value 'gnus-article-boring-faces)))
5370 (throw 'only-boring nil)))
5371 (throw 'only-boring t)))))
5373 (defun gnus-article-refer-article ()
5374 "Read article specified by message-id around point."
5377 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5378 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5379 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5380 (let ((msg-id (concat "<" (match-string 0) ">")))
5381 (set-buffer gnus-summary-buffer)
5382 (gnus-summary-refer-article msg-id))
5383 (error "No references around point"))))
5385 (defun gnus-article-show-summary ()
5386 "Reconfigure windows to show summary buffer."
5388 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5389 (error "There is no summary buffer for this article buffer")
5390 (gnus-article-set-globals)
5391 (gnus-configure-windows 'article)
5392 (gnus-summary-goto-subject gnus-current-article)
5393 (gnus-summary-position-point)))
5395 (defun gnus-article-describe-briefly ()
5396 "Describe article mode commands briefly."
5398 (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")))
5400 (defun gnus-article-summary-command ()
5401 "Execute the last keystroke in the summary buffer."
5403 (let ((obuf (current-buffer))
5404 (owin (current-window-configuration))
5406 (switch-to-buffer gnus-article-current-summary 'norecord)
5407 (setq func (lookup-key (current-local-map) (this-command-keys)))
5408 (call-interactively func)
5410 (set-window-configuration owin)
5411 (set-window-point (get-buffer-window (current-buffer)) (point))))
5413 (defun gnus-article-summary-command-nosave ()
5414 "Execute the last keystroke in the summary buffer."
5417 (pop-to-buffer gnus-article-current-summary 'norecord)
5418 (setq func (lookup-key (current-local-map) (this-command-keys)))
5419 (call-interactively func)))
5421 (defun gnus-article-check-buffer ()
5422 "Beep if not in an article buffer."
5423 (unless (equal major-mode 'gnus-article-mode)
5424 (error "Command invoked outside of a Gnus article buffer")))
5426 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5427 "Read a summary buffer key sequence and execute it from the article buffer."
5429 (gnus-article-check-buffer)
5431 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5432 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5433 "=" "^" "\M-^" "|"))
5439 '("n" "Gn" "p" "Gp"))
5442 (set-buffer gnus-article-current-summary)
5443 (let (gnus-pick-mode)
5444 (push (or key last-command-event) unread-command-events)
5445 (setq keys (if (featurep 'xemacs)
5446 (events-to-keys (read-key-sequence nil))
5447 (read-key-sequence nil)))))
5451 (if (or (member keys nosaves)
5452 (member keys nosave-but-article)
5453 (member keys nosave-in-article))
5455 (save-window-excursion
5456 (pop-to-buffer gnus-article-current-summary 'norecord)
5457 ;; We disable the pick minor mode commands.
5458 (let (gnus-pick-mode)
5459 (setq func (lookup-key (current-local-map) keys))))
5463 (unless (member keys nosave-in-article)
5464 (set-buffer gnus-article-current-summary))
5465 (call-interactively func)
5466 (setq new-sum-point (point)))
5467 (when (member keys nosave-but-article)
5468 (pop-to-buffer gnus-article-buffer 'norecord)))
5469 ;; These commands should restore window configuration.
5470 (let ((obuf (current-buffer))
5471 (owin (current-window-configuration))
5473 win func in-buffer selected new-sum-start new-sum-hscroll)
5474 (cond (not-restore-window
5475 (pop-to-buffer gnus-article-current-summary 'norecord))
5476 ((setq win (get-buffer-window gnus-article-current-summary))
5477 (select-window win))
5479 (switch-to-buffer gnus-article-current-summary 'norecord)))
5480 (setq in-buffer (current-buffer))
5481 ;; We disable the pick minor mode commands.
5482 (if (and (setq func (let (gnus-pick-mode)
5483 (lookup-key (current-local-map) keys)))
5486 (call-interactively func)
5487 (when (eq win (selected-window))
5488 (setq new-sum-point (point)
5489 new-sum-start (window-start win)
5490 new-sum-hscroll (window-hscroll win)))
5491 (when (eq in-buffer (current-buffer))
5492 (setq selected (gnus-summary-select-article))
5494 (unless not-restore-window
5495 (set-window-configuration owin))
5496 (when (eq selected 'old)
5498 (set-window-start (get-buffer-window (current-buffer))
5500 (set-window-point (get-buffer-window (current-buffer))
5502 (when (and (not not-restore-window)
5504 (set-window-point win new-sum-point)
5505 (set-window-start win new-sum-start)
5506 (set-window-hscroll win new-sum-hscroll))))
5507 (set-window-configuration owin)
5510 (defun gnus-article-describe-key (key)
5511 "Display documentation of the function invoked by KEY. KEY is a string."
5512 (interactive "kDescribe key: ")
5513 (gnus-article-check-buffer)
5514 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5516 (set-buffer gnus-article-current-summary)
5517 (let (gnus-pick-mode)
5518 (if (featurep 'xemacs)
5520 (push (elt key 0) unread-command-events)
5521 (setq key (events-to-keys
5522 (read-key-sequence "Describe key: "))))
5523 (setq unread-command-events
5525 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5526 (string-to-list key)))
5527 (setq key (read-key-sequence "Describe key: "))))
5529 (describe-key key)))
5531 (defun gnus-article-describe-key-briefly (key &optional insert)
5532 "Display documentation of the function invoked by KEY. KEY is a string."
5533 (interactive "kDescribe key: \nP")
5534 (gnus-article-check-buffer)
5535 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5537 (set-buffer gnus-article-current-summary)
5538 (let (gnus-pick-mode)
5539 (if (featurep 'xemacs)
5541 (push (elt key 0) unread-command-events)
5542 (setq key (events-to-keys
5543 (read-key-sequence "Describe key: "))))
5544 (setq unread-command-events
5546 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5547 (string-to-list key)))
5548 (setq key (read-key-sequence "Describe key: "))))
5549 (describe-key-briefly key insert))
5550 (describe-key-briefly key insert)))
5552 (defun gnus-article-reply-with-original (&optional wide)
5553 "Start composing a reply mail to the current message.
5554 The text in the region will be yanked. If the region isn't active,
5555 the entire article will be yanked."
5557 (let ((article (cdr gnus-article-current))
5559 (if (not (gnus-region-active-p))
5560 (with-current-buffer gnus-summary-buffer
5561 (gnus-summary-reply (list (list article)) wide))
5562 (setq contents (buffer-substring (point) (mark t)))
5563 ;; Deactivate active regions.
5564 (when (and (boundp 'transient-mark-mode)
5565 transient-mark-mode)
5566 (setq mark-active nil))
5567 (with-current-buffer gnus-summary-buffer
5569 (list (list article contents)) wide)))))
5571 (defun gnus-article-followup-with-original ()
5572 "Compose a followup to the current article.
5573 The text in the region will be yanked. If the region isn't active,
5574 the entire article will be yanked."
5576 (let ((article (cdr gnus-article-current))
5578 (if (not (gnus-region-active-p))
5579 (with-current-buffer gnus-summary-buffer
5580 (gnus-summary-followup (list (list article))))
5581 (setq contents (buffer-substring (point) (mark t)))
5582 ;; Deactivate active regions.
5583 (when (and (boundp 'transient-mark-mode)
5584 transient-mark-mode)
5585 (setq mark-active nil))
5586 (with-current-buffer gnus-summary-buffer
5587 (gnus-summary-followup
5588 (list (list article contents)))))))
5590 (defun gnus-article-hide (&optional arg force)
5591 "Hide all the gruft in the current article.
5592 This means that signatures, cited text and (some) headers will be
5594 If given a prefix, show the hidden text instead."
5595 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5596 (gnus-article-hide-headers arg)
5597 (gnus-article-hide-list-identifiers arg)
5598 (gnus-article-hide-citation-maybe arg force)
5599 (gnus-article-hide-signature arg))
5601 (defun gnus-article-maybe-highlight ()
5602 "Do some article highlighting if article highlighting is requested."
5603 (when (gnus-visual-p 'article-highlight 'highlight)
5604 (gnus-article-highlight-some)))
5606 (defun gnus-check-group-server ()
5607 ;; Make sure the connection to the server is alive.
5608 (unless (gnus-server-opened
5609 (gnus-find-method-for-group gnus-newsgroup-name))
5610 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5611 (gnus-request-group gnus-newsgroup-name t)))
5614 (autoload 'nneething-get-file-name "nneething"))
5616 (defun gnus-request-article-this-buffer (article group)
5617 "Get an article and insert it into this buffer."
5618 (let (do-update-line sparse-header)
5622 (gnus-kill-all-overlays)
5623 (setq group (or group gnus-newsgroup-name))
5625 ;; Using `gnus-request-article' directly will insert the article into
5626 ;; `nntp-server-buffer' - so we'll save some time by not having to
5627 ;; copy it from the server buffer into the article buffer.
5629 ;; We only request an article by message-id when we do not have the
5630 ;; headers for it, so we'll have to get those.
5631 (when (stringp article)
5632 (gnus-read-header article))
5634 ;; If the article number is negative, that means that this article
5635 ;; doesn't belong in this newsgroup (possibly), so we find its
5636 ;; message-id and request it by id instead of number.
5637 (when (and (numberp article)
5639 (get-buffer gnus-summary-buffer)
5640 (gnus-buffer-exists-p gnus-summary-buffer))
5642 (set-buffer gnus-summary-buffer)
5643 (let ((header (gnus-summary-article-header article)))
5646 ((memq article gnus-newsgroup-sparse)
5647 ;; This is a sparse gap article.
5648 (setq do-update-line article)
5649 (setq article (mail-header-id header))
5650 (setq sparse-header (gnus-read-header article))
5651 (setq gnus-newsgroup-sparse
5652 (delq article gnus-newsgroup-sparse)))
5654 ;; It's a real article.
5655 (setq article (mail-header-id header)))
5657 ;; It is an extracted pseudo-article.
5658 (setq article 'pseudo)
5659 (gnus-request-pseudo-article header))))
5661 (let ((method (gnus-find-method-for-group
5662 gnus-newsgroup-name)))
5663 (when (and (eq (car method) 'nneething)
5665 (let ((dir (nneething-get-file-name
5666 (mail-header-id header))))
5667 (when (and (stringp dir)
5668 (file-directory-p dir))
5669 (setq article 'nneething)
5670 (gnus-group-enter-directory dir))))))))
5673 ;; Refuse to select canceled articles.
5674 ((and (numberp article)
5676 (get-buffer gnus-summary-buffer)
5677 (gnus-buffer-exists-p gnus-summary-buffer)
5678 (eq (cdr (with-current-buffer gnus-summary-buffer
5679 (assq article gnus-newsgroup-reads)))
5680 gnus-canceled-mark))
5682 ;; We first check `gnus-original-article-buffer'.
5683 ((and (get-buffer gnus-original-article-buffer)
5685 (with-current-buffer gnus-original-article-buffer
5686 (and (equal (car gnus-original-article) group)
5687 (eq (cdr gnus-original-article) article))))
5688 (insert-buffer-substring gnus-original-article-buffer)
5690 ;; Check the backlog.
5691 ((and gnus-keep-backlog
5692 (gnus-backlog-request-article group article (current-buffer)))
5694 ;; Check asynchronous pre-fetch.
5695 ((gnus-async-request-fetched-article group article (current-buffer))
5696 (gnus-async-prefetch-next group article gnus-summary-buffer)
5697 (when (and (numberp article) gnus-keep-backlog)
5698 (gnus-backlog-enter-article group article (current-buffer)))
5701 ((and gnus-use-cache
5703 (gnus-cache-request-article article group))
5705 ;; Check the agent cache.
5706 ((gnus-agent-request-article article group)
5708 ;; Get the article and put into the article buffer.
5709 ((or (stringp article)
5711 (let ((gnus-override-method gnus-override-method)
5712 (methods (and (stringp article)
5713 gnus-refer-article-method))
5714 (backend (car (gnus-find-method-for-group
5715 gnus-newsgroup-name)))
5717 (inhibit-read-only t))
5718 (if (or (not (listp methods))
5719 (and (symbolp (car methods))
5720 (assq (car methods) nnoo-definition-alist)))
5721 (setq methods (list methods)))
5722 (when (and (null gnus-override-method)
5724 (setq gnus-override-method (pop methods)))
5726 (when (eq gnus-override-method 'current)
5727 (setq gnus-override-method
5728 (with-current-buffer gnus-summary-buffer
5729 gnus-current-select-method)))
5731 (gnus-kill-all-overlays)
5732 (let ((gnus-newsgroup-name group))
5733 (gnus-check-group-server))
5735 ((gnus-request-article article group (current-buffer))
5736 (when (numberp article)
5737 (gnus-async-prefetch-next group article
5738 gnus-summary-buffer)
5739 (when gnus-keep-backlog
5740 (gnus-backlog-enter-article
5741 group article (current-buffer))))
5742 (setq result 'article))
5744 (setq gnus-override-method (pop methods)))
5745 ((not (string-match "^400 "
5746 (nnheader-get-report backend)))
5747 ;; If we get 400 server disconnect, reconnect and
5748 ;; retry; otherwise, assume the article has expired.
5749 (setq result 'done))))
5750 (and (eq result 'article) 'article)))
5754 ;; Associate this article with the current summary buffer.
5755 (setq gnus-article-current-summary gnus-summary-buffer)
5757 ;; Take the article from the original article buffer
5758 ;; and place it in the buffer it's supposed to be in.
5759 (when (and (get-buffer gnus-article-buffer)
5760 (equal (buffer-name (current-buffer))
5761 (buffer-name (get-buffer gnus-article-buffer))))
5763 (if (get-buffer gnus-original-article-buffer)
5764 (set-buffer gnus-original-article-buffer)
5765 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5766 (buffer-disable-undo)
5767 (setq major-mode 'gnus-original-article-mode)
5768 (setq buffer-read-only t))
5769 (let ((inhibit-read-only t))
5771 (insert-buffer-substring gnus-article-buffer))
5772 (setq gnus-original-article (cons group article)))
5775 (run-hooks 'gnus-article-decode-hook)
5776 ;; Mark article as decoded or not.
5777 (setq gnus-article-decoded-p gnus-article-decode-hook))
5779 ;; Update sparse articles.
5780 (when (and do-update-line
5781 (or (numberp article)
5783 (let ((buf (current-buffer)))
5784 (set-buffer gnus-summary-buffer)
5785 (gnus-summary-update-article do-update-line sparse-header)
5786 (gnus-summary-goto-subject do-update-line nil t)
5787 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5789 (set-buffer buf))))))
5795 (defcustom gnus-article-edit-mode-hook nil
5796 "Hook run in article edit mode buffers."
5797 :group 'gnus-article-various
5800 (defvar gnus-article-edit-done-function nil)
5802 (defvar gnus-article-edit-mode-map nil)
5804 ;; Should we be using derived.el for this?
5805 (unless gnus-article-edit-mode-map
5806 (setq gnus-article-edit-mode-map (make-keymap))
5807 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5809 (gnus-define-keys gnus-article-edit-mode-map
5810 "\C-c?" describe-mode
5811 "\C-c\C-c" gnus-article-edit-done
5812 "\C-c\C-k" gnus-article-edit-exit
5813 "\C-c\C-f\C-t" message-goto-to
5814 "\C-c\C-f\C-o" message-goto-from
5815 "\C-c\C-f\C-b" message-goto-bcc
5816 ;;"\C-c\C-f\C-w" message-goto-fcc
5817 "\C-c\C-f\C-c" message-goto-cc
5818 "\C-c\C-f\C-s" message-goto-subject
5819 "\C-c\C-f\C-r" message-goto-reply-to
5820 "\C-c\C-f\C-n" message-goto-newsgroups
5821 "\C-c\C-f\C-d" message-goto-distribution
5822 "\C-c\C-f\C-f" message-goto-followup-to
5823 "\C-c\C-f\C-m" message-goto-mail-followup-to
5824 "\C-c\C-f\C-k" message-goto-keywords
5825 "\C-c\C-f\C-u" message-goto-summary
5826 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5827 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5828 "\C-c\C-b" message-goto-body
5829 "\C-c\C-i" message-goto-signature
5831 "\C-c\C-t" message-insert-to
5832 "\C-c\C-n" message-insert-newsgroups
5833 "\C-c\C-o" message-sort-headers
5834 "\C-c\C-e" message-elide-region
5835 "\C-c\C-v" message-delete-not-region
5836 "\C-c\C-z" message-kill-to-signature
5837 "\M-\r" message-newline-and-reformat
5838 "\C-c\C-a" mml-attach-file
5839 "\C-a" message-beginning-of-line
5841 "\M-;" comment-region)
5843 (gnus-define-keys (gnus-article-edit-wash-map
5844 "\C-c\C-w" gnus-article-edit-mode-map)
5845 "f" gnus-article-edit-full-stops))
5848 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5850 ["Fetch To" message-insert-to t]
5851 ["Fetch Newsgroups" message-insert-newsgroups t]
5853 ["To" message-goto-to t]
5854 ["From" message-goto-from t]
5855 ["Subject" message-goto-subject t]
5856 ["Cc" message-goto-cc t]
5857 ["Reply-To" message-goto-reply-to t]
5858 ["Summary" message-goto-summary t]
5859 ["Keywords" message-goto-keywords t]
5860 ["Newsgroups" message-goto-newsgroups t]
5861 ["Followup-To" message-goto-followup-to t]
5862 ["Mail-Followup-To" message-goto-mail-followup-to t]
5863 ["Distribution" message-goto-distribution t]
5864 ["Body" message-goto-body t]
5865 ["Signature" message-goto-signature t]))
5867 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5868 "Major mode for editing articles.
5869 This is an extended text-mode.
5871 \\{gnus-article-edit-mode-map}"
5872 (make-local-variable 'gnus-article-edit-done-function)
5873 (make-local-variable 'gnus-prev-winconf)
5874 (set (make-local-variable 'font-lock-defaults)
5875 '(message-font-lock-keywords t))
5876 (set (make-local-variable 'mail-header-separator) "")
5877 (set (make-local-variable 'gnus-article-edit-mode) t)
5878 (easy-menu-add message-mode-field-menu message-mode-map)
5880 (setq buffer-read-only nil)
5881 (buffer-enable-undo)
5884 (defun gnus-article-edit (&optional force)
5885 "Edit the current article.
5886 This will have permanent effect only in mail groups.
5887 If FORCE is non-nil, allow editing of articles even in read-only
5890 (when (and (not force)
5891 (gnus-group-read-only-p))
5892 (error "The current newsgroup does not support article editing"))
5893 (gnus-article-date-original)
5894 (gnus-article-edit-article
5896 `(lambda (no-highlight)
5898 (gnus-summary-edit-article-done
5899 ,(or (mail-header-references gnus-current-headers) "")
5900 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5902 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
5903 "Start editing the contents of the current article buffer."
5904 (let ((winconf (current-window-configuration)))
5905 (set-buffer gnus-article-buffer)
5906 (let ((message-auto-save-directory
5907 ;; Don't associate the article buffer with a draft file.
5909 (gnus-article-edit-mode))
5910 (funcall start-func)
5911 (set-buffer-modified-p nil)
5912 (gnus-configure-windows 'edit-article)
5913 (setq gnus-article-edit-done-function exit-func)
5914 (setq gnus-prev-winconf winconf)
5916 (gnus-message 6 "C-c C-c to end edits"))))
5918 (defun gnus-article-edit-done (&optional arg)
5919 "Update the article edits and exit."
5921 (let ((func gnus-article-edit-done-function)
5922 (buf (current-buffer))
5923 (start (window-start))
5925 (winconf gnus-prev-winconf))
5926 (widen) ;; Widen it in case that users narrowed the buffer.
5929 ;; The cache and backlog have to be flushed somewhat.
5930 (when gnus-keep-backlog
5931 (gnus-backlog-remove-article
5932 (car gnus-article-current) (cdr gnus-article-current)))
5933 ;; Flush original article as well.
5935 (when (get-buffer gnus-original-article-buffer)
5936 (set-buffer gnus-original-article-buffer)
5937 (setq gnus-original-article nil)))
5938 (when gnus-use-cache
5939 (gnus-cache-update-article
5940 (car gnus-article-current) (cdr gnus-article-current)))
5941 ;; We remove all text props from the article buffer.
5942 (kill-all-local-variables)
5943 (set-text-properties (point-min) (point-max) nil)
5945 (set-window-configuration winconf)
5947 (set-window-start (get-buffer-window buf) start)
5948 (set-window-point (get-buffer-window buf) (point)))
5949 (gnus-summary-show-article))
5951 (defun gnus-article-edit-exit ()
5952 "Exit the article editing without updating."
5954 (when (or (not (buffer-modified-p))
5955 (yes-or-no-p "Article modified; kill anyway? "))
5956 (let ((curbuf (current-buffer))
5958 (window-start (window-start)))
5960 (if (gnus-buffer-live-p gnus-original-article-buffer)
5961 (insert-buffer-substring gnus-original-article-buffer))
5962 (let ((winconf gnus-prev-winconf))
5963 (kill-all-local-variables)
5965 (set-window-configuration winconf)
5966 ;; Tippy-toe some to make sure that point remains where it was.
5967 (save-current-buffer
5969 (set-window-start (get-buffer-window (current-buffer)) window-start)
5971 (gnus-summary-show-article)))
5973 (defun gnus-article-edit-full-stops ()
5974 "Interactively repair spacing at end of sentences."
5977 (goto-char (point-min))
5978 (search-forward-regexp "^$" nil t)
5979 (let ((case-fold-search nil))
5980 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5983 ;;; Article highlights
5986 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5988 ;;; Internal Variables:
5990 (defcustom gnus-button-url-regexp
5991 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5992 "\\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:]]\\)"
5993 "\\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\\)\\)")
5994 "Regular expression that matches URLs."
5995 :group 'gnus-article-buttons
5998 (defcustom gnus-button-valid-fqdn-regexp
5999 message-valid-fqdn-regexp
6000 "Regular expression that matches a valid FQDN."
6002 :group 'gnus-article-buttons
6005 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6006 (defcustom gnus-button-valid-localpart-regexp
6007 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*"
6008 "Regular expression that matches a localpart of mail addresses or MIDs."
6010 :group 'gnus-article-buttons
6013 (defcustom gnus-button-man-handler 'manual-entry
6014 "Function to use for displaying man pages.
6015 The function must take at least one argument with a string naming the
6018 :type '(choice (function-item :tag "Man" manual-entry)
6019 (function-item :tag "Woman" woman)
6020 (function :tag "Other"))
6021 :group 'gnus-article-buttons)
6023 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6024 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6025 If the default site is too slow, try to find a CTAN mirror, see
6026 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6027 the variable `gnus-button-handle-ctan'."
6029 :group 'gnus-article-buttons
6030 :link '(custom-manual "(gnus)Group Parameters")
6031 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6032 (const "http://tug.ctan.org/tex-archive/")
6033 (const "http://www.dante.de/CTAN/")
6034 (string :tag "Other")))
6036 (defcustom gnus-button-ctan-handler 'browse-url
6037 "Function to use for displaying CTAN links.
6038 The function must take one argument, the string naming the URL."
6040 :type '(choice (function-item :tag "Browse Url" browse-url)
6041 (function :tag "Other"))
6042 :group 'gnus-article-buttons)
6044 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6045 "Bogus strings removed from CTAN URLs."
6047 :group 'gnus-article-buttons
6048 :type '(choice (const "^/?tex-archive/\\|/")
6049 (regexp :tag "Other")))
6051 (defcustom gnus-button-ctan-directory-regexp
6053 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
6054 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
6055 "languages" "macros" "nonfree" "obsolete" "support" "systems"
6056 "tds" "tools" "usergrps" "web") t)
6057 "Regular expression for ctan directories.
6058 It should match all directories in the top level of `gnus-ctan-url'."
6060 :group 'gnus-article-buttons
6063 (defcustom gnus-button-mid-or-mail-regexp
6064 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
6065 gnus-button-valid-fqdn-regexp
6067 "Regular expression that matches a message ID or a mail address."
6069 :group 'gnus-article-buttons
6072 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6073 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6074 Strings like this can be either a message ID or a mail address. If it is one
6075 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6076 message ID or a mail address, respectively. If this variable is set to the
6077 symbol `ask', always query the user what do do. If it is a function, this
6078 function will be called with the string as it's only argument. The function
6079 must return `mid', `mail', `invalid' or `ask'."
6081 :group 'gnus-article-buttons
6082 :type '(choice (function-item :tag "Heuristic function"
6083 gnus-button-mid-or-mail-heuristic)
6088 (defcustom gnus-button-mid-or-mail-heuristic-alist
6089 '((-10.0 . ".+\\$.+@")
6092 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6093 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6094 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6095 (-1.0 . "^[^a-z]+@")
6097 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6098 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6099 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6100 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6103 (-1.0 . "^[0-9][0-9]")
6105 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6106 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6107 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6108 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6110 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6111 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6114 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6116 ;; compensation for TDMA dated mail addresses:
6117 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6119 (-20.0 . "\\.fsf@") ;; Gnus
6122 (-20.0 . "_-_") ;; Subject change in thread
6124 (-20.0 . "\\.ln@") ;; leafnode
6125 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6126 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6128 ;; (5.0 . "") ;; $local_part_len <= 7
6129 (10.0 . "^[^0-9]+@")
6130 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6131 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6134 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6136 (0.5 . "^[A-Z][a-z]")
6137 (0.5 . "^[A-Z][a-z][a-z]")
6138 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6139 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6140 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6142 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6143 address. The REGEXP is processed with `case-fold-search' set to nil."
6145 :group 'gnus-article-buttons
6146 :type '(repeat (cons (number :tag "Rate")
6147 (regexp :tag "Regexp"))))
6149 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6150 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6151 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6152 address, `ask' if unsure and `invalid' if the string is invalid."
6153 (let ((case-fold-search nil)
6154 (list gnus-button-mid-or-mail-heuristic-alist)
6155 (result 0) rate regexp lpartlen elem)
6157 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6158 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6159 ;; Certain special cases...
6162 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6163 "^[0-9]+\\.[0-9]+@compuserve\\|"
6164 "@public\\.gmane\\.org")
6166 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6167 (setq result 'mail))
6168 (when (string-match "@.*@\\| " mid-or-mail)
6169 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6170 (setq result 'invalid))
6171 ;; Nothing more to do, if result is not a number here...
6172 (when (numberp result)
6174 (setq elem (car list)
6178 (when (string-match regexp mid-or-mail)
6179 (setq result (+ result rate))
6181 9 "`%s' matched `%s', rate `%s', result `%s'."
6182 mid-or-mail regexp rate result)))
6183 (when (<= lpartlen 7)
6184 (setq result (+ result 5.0))
6185 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6186 mid-or-mail result))
6187 (when (>= lpartlen 12)
6188 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6190 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6191 ;; Long local part should contain realname if e-mail address,
6192 ;; too many digits: message-id.
6193 ;; $score -= 5.0 + 0.1 * $local_part_len;
6194 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6195 (setq result (+ result rate))
6197 9 "Many digits in `%s', rate `%s', result `%s'."
6198 mid-or-mail rate result))
6199 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6201 ;; Too few vowels [^aeiouy]{4,}.*\@
6202 (setq result (+ result -5.0))
6204 9 "Few vowels in `%s', rate `%s', result `%s'."
6205 mid-or-mail -5.0 result))
6207 (setq result (+ result 5.0))
6209 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6210 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6211 ;; Maybe we should make this a customizable alist: (condition . 'result)
6213 ((symbolp result) result)
6214 ;; Now convert number into proper results:
6215 ((< result -10.0) 'mid)
6216 ((> result 10.0) 'mail)
6219 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6220 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6221 (url-mid (concat "news" ":" mid-or-mail))
6222 (url-mailto (concat "mailto" ":" mid-or-mail)))
6223 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6224 (when (fboundp pref)
6226 ;; get rid of surrounding angles...
6228 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6229 (if (or (eq 'mid guessed) (eq 'mail guessed))
6233 (save-window-excursion
6234 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6237 (cond ((eq pref 'mid)
6238 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6239 (gnus-button-handle-news url-mid))
6241 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6242 (gnus-url-mailto url-mailto))
6243 (t (gnus-message 3 "Invalid string.")))))
6245 (defun gnus-button-handle-custom (url)
6246 "Follow a Custom URL."
6247 (customize-apropos (gnus-url-unhex-string url)))
6249 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6251 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6254 (defun gnus-button-handle-describe-function (url)
6255 "Call `describe-function' when pushing the corresponding URL button."
6258 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6260 (defun gnus-button-handle-describe-variable (url)
6261 "Call `describe-variable' when pushing the corresponding URL button."
6264 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6266 (defun gnus-button-handle-symbol (url)
6267 "Display help on variable or function.
6268 Calls `describe-variable' or `describe-function'."
6269 (let ((sym (intern url)))
6271 ((fboundp sym) (describe-function sym))
6272 ((boundp sym) (describe-variable sym))
6273 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6275 (defun gnus-button-handle-describe-key (url)
6276 "Call `describe-key' when pushing the corresponding URL button."
6278 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6279 (keys (ignore-errors (eval `(kbd ,key-string)))))
6282 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6284 (defun gnus-button-handle-apropos (url)
6285 "Call `apropos' when pushing the corresponding URL button."
6286 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6288 (defun gnus-button-handle-apropos-command (url)
6289 "Call `apropos' when pushing the corresponding URL button."
6291 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6293 (defun gnus-button-handle-apropos-variable (url)
6294 "Call `apropos' when pushing the corresponding URL button."
6296 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6297 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6299 (defun gnus-button-handle-apropos-documentation (url)
6300 "Call `apropos' when pushing the corresponding URL button."
6302 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6303 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6305 (defun gnus-button-handle-library (url)
6306 "Call `locate-library' when pushing the corresponding URL button."
6307 (gnus-message 9 "url=`%s'" url)
6308 (let* ((lib (locate-library url))
6309 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6311 (gnus-message 1 "Cannot locale library `%s'." url)
6312 (find-file-read-only file))))
6314 (defun gnus-button-handle-ctan (url)
6315 "Call `browse-url' when pushing a CTAN URL button."
6317 gnus-button-ctan-handler
6320 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6322 (defcustom gnus-button-tex-level 5
6323 "*Integer that says how many TeX-related buttons Gnus will show.
6324 The higher the number, the more buttons will appear and the more false
6325 positives are possible. Note that you can set this variable local to
6326 specific groups. Setting it higher in TeX groups is probably a good idea.
6327 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6328 how to set variables in specific groups."
6330 :group 'gnus-article-buttons
6331 :link '(custom-manual "(gnus)Group Parameters")
6334 (defcustom gnus-button-man-level 5
6335 "*Integer that says how many man-related buttons Gnus will show.
6336 The higher the number, the more buttons will appear and the more false
6337 positives are possible. Note that you can set this variable local to
6338 specific groups. Setting it higher in Unix groups is probably a good idea.
6339 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6340 how to set variables in specific groups."
6342 :group 'gnus-article-buttons
6343 :link '(custom-manual "(gnus)Group Parameters")
6346 (defcustom gnus-button-emacs-level 5
6347 "*Integer that says how many emacs-related buttons Gnus will show.
6348 The higher the number, the more buttons will appear and the more false
6349 positives are possible. Note that you can set this variable local to
6350 specific groups. Setting it higher in Emacs or Gnus related groups is
6351 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6352 `gnus-parameters' on how to set variables in specific groups."
6354 :group 'gnus-article-buttons
6355 :link '(custom-manual "(gnus)Group Parameters")
6358 (defcustom gnus-button-message-level 5
6359 "*Integer that says how many buttons for news or mail messages will appear.
6360 The higher the number, the more buttons will appear and the more false
6361 positives are possible."
6362 ;; mail addresses, MIDs, URLs for news, ...
6364 :group 'gnus-article-buttons
6367 (defcustom gnus-button-browse-level 5
6368 "*Integer that says how many buttons for browsing will appear.
6369 The higher the number, the more buttons will appear and the more false
6370 positives are possible."
6371 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6373 :group 'gnus-article-buttons
6376 (defcustom gnus-button-alist
6377 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6378 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6379 ((concat "\\b\\(nntp\\|news\\):\\("
6380 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6381 0 t gnus-button-handle-news 2)
6382 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6383 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6384 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6385 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6386 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6387 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6388 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6389 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6390 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6391 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6392 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6393 ;; RFC 2368 (The mailto URL scheme)
6394 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6395 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6396 ("\\bmailto:\\([^ \n\t]+\\)"
6397 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6399 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6400 gnus-button-ctan-directory-regexp
6401 "[^][>)!;:,'\n\t ]+\\)")
6402 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6403 ((concat "\\btex-archive/\\("
6404 gnus-button-ctan-directory-regexp
6405 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6406 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6409 gnus-button-ctan-directory-regexp
6410 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6411 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6412 ;; This is info (home-grown style) <info://foo/bar+baz>
6413 ("\\binfo://\\([^'\">\n\t ]+\\)"
6414 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6415 ;; Info GNOME style <info:foo#bar_baz>
6416 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6417 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6418 ;; Info KDE style <info:(foo)bar baz>
6419 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6420 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6421 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6422 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6423 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6424 ;; Info links like `C-h i d m CC Mode RET'
6425 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6427 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6428 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6429 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6430 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6431 ;; Emacs help commands
6432 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6433 ;; regexp doesn't match arguments containing ` '.
6434 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6435 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6436 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6437 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6438 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6439 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6440 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6441 ;; The following entries may lead to many false positives so don't enable
6442 ;; them by default (use a high button level).
6443 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6444 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6445 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6446 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6447 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6448 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6449 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6450 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6451 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6452 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6453 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6454 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6455 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6456 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6457 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6458 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6459 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6460 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6461 ;; Unlike the other regexps we really have to require quoting
6462 ;; here to determine where it ends.
6463 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6464 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6465 ("<URL: *\\([^<>]*\\)>"
6466 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6467 ;; RFC 2396 (2.4.3., delims) ...
6468 ("\"URL: *\\([^\"]*\\)\""
6469 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6470 ;; RFC 2396 (2.4.3., delims) ...
6471 ("\"URL: *\\([^\"]*\\)\""
6472 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6474 (gnus-button-url-regexp
6475 0 (>= gnus-button-browse-level 0) browse-url 0)
6477 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6478 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6479 gnus-button-handle-man 1)
6480 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6481 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6482 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6483 gnus-button-handle-man 1)
6484 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6485 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6486 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6487 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6488 ;; MID or mail: To avoid too many false positives we don't try to catch
6489 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6490 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6491 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6492 ;; so that non-ambiguous entries (see above) match first.
6493 (gnus-button-mid-or-mail-regexp
6494 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6495 "*Alist of regexps matching buttons in article bodies.
6497 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6498 REGEXP: is the string (case insensitive) matching text around the button (can
6499 also be Lisp expression evaluating to a string),
6500 BUTTON: is the number of the regexp grouping actually matching the button,
6501 FORM: is a Lisp expression which must eval to true for the button to
6503 CALLBACK: is the function to call when the user push this button, and each
6504 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6506 CALLBACK can also be a variable, in that case the value of that
6507 variable it the real callback function."
6508 :group 'gnus-article-buttons
6509 :type '(repeat (list (choice regexp variable sexp)
6510 (integer :tag "Button")
6512 (function :tag "Callback")
6515 (integer :tag "Regexp group")))))
6517 (defcustom gnus-header-button-alist
6518 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6519 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6520 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6521 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6522 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6523 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6524 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6525 0 (>= gnus-button-browse-level 0) browse-url 0)
6526 ("^Subject:" gnus-button-url-regexp
6527 0 (>= gnus-button-browse-level 0) browse-url 0)
6528 ("^[^:]+:" gnus-button-url-regexp
6529 0 (>= gnus-button-browse-level 0) browse-url 0)
6530 ("^OpenPGP:.*url=" gnus-button-url-regexp
6531 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6532 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6533 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6534 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6535 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6536 "*Alist of headers and regexps to match buttons in article heads.
6538 This alist is very similar to `gnus-button-alist', except that each
6539 alist has an additional HEADER element first in each entry:
6541 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6543 HEADER is a regexp to match a header. For a fuller explanation, see
6544 `gnus-button-alist'."
6545 :group 'gnus-article-buttons
6546 :group 'gnus-article-headers
6547 :type '(repeat (list (regexp :tag "Header")
6548 (choice regexp variable)
6549 (integer :tag "Button")
6551 (function :tag "Callback")
6554 (integer :tag "Regexp group")))))
6558 (defun gnus-article-push-button (event)
6559 "Check text under the mouse pointer for a callback function.
6560 If the text under the mouse pointer has a `gnus-callback' property,
6561 call it with the value of the `gnus-data' text property."
6563 (set-buffer (window-buffer (posn-window (event-start event))))
6564 (let* ((pos (posn-point (event-start event)))
6565 (data (get-text-property pos 'gnus-data))
6566 (fun (get-text-property pos 'gnus-callback)))
6569 (funcall fun data))))
6571 (defun gnus-article-press-button ()
6572 "Check text at point for a callback function.
6573 If the text at point has a `gnus-callback' property,
6574 call it with the value of the `gnus-data' text property."
6576 (let ((data (get-text-property (point) 'gnus-data))
6577 (fun (get-text-property (point) 'gnus-callback)))
6579 (funcall fun data))))
6581 (defun gnus-article-highlight (&optional force)
6582 "Highlight current article.
6583 This function calls `gnus-article-highlight-headers',
6584 `gnus-article-highlight-citation',
6585 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6586 do the highlighting. See the documentation for those functions."
6587 (interactive (list 'force))
6588 (gnus-article-highlight-headers)
6589 (gnus-article-highlight-citation force)
6590 (gnus-article-highlight-signature)
6591 (gnus-article-add-buttons force)
6592 (gnus-article-add-buttons-to-head))
6594 (defun gnus-article-highlight-some (&optional force)
6595 "Highlight current article.
6596 This function calls `gnus-article-highlight-headers',
6597 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6598 do the highlighting. See the documentation for those functions."
6599 (interactive (list 'force))
6600 (gnus-article-highlight-headers)
6601 (gnus-article-highlight-signature)
6602 (gnus-article-add-buttons))
6604 (defun gnus-article-highlight-headers ()
6605 "Highlight article headers as specified by `gnus-header-face-alist'."
6607 (gnus-with-article-headers
6608 (let (regexp header-face field-face from hpoints fpoints)
6609 (dolist (entry gnus-header-face-alist)
6610 (goto-char (point-min))
6611 (setq regexp (concat "^\\("
6612 (if (string-equal "" (nth 0 entry))
6616 header-face (nth 1 entry)
6617 field-face (nth 2 entry))
6618 (while (and (re-search-forward regexp nil t)
6622 (unless (search-forward ":" nil t)
6624 (when (and header-face
6625 (not (memq (point) hpoints)))
6626 (push (point) hpoints)
6627 (gnus-put-text-property from (point) 'face header-face))
6628 (when (and field-face
6629 (not (memq (setq from (point)) fpoints)))
6631 (if (re-search-forward "^[^ \t]" nil t)
6633 (goto-char (point-max)))
6634 (gnus-put-text-property from (point) 'face field-face)))))))
6636 (defun gnus-article-highlight-signature ()
6637 "Highlight the signature in an article.
6638 It does this by highlighting everything after
6639 `gnus-signature-separator' using the face `gnus-signature'."
6641 (gnus-with-article-buffer
6642 (let ((inhibit-point-motion-hooks t))
6644 (when (and gnus-signature-face
6645 (gnus-article-narrow-to-signature))
6646 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6647 'face gnus-signature-face)
6649 (gnus-article-search-signature)
6650 (let ((start (match-beginning 0))
6651 (end (set-marker (make-marker) (1+ (match-end 0)))))
6652 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6655 (defun gnus-button-in-region-p (b e prop)
6656 "Say whether PROP exists in the region."
6657 (text-property-not-all b e prop nil))
6659 (defun gnus-article-add-buttons (&optional force)
6660 "Find external references in the article and make buttons of them.
6661 \"External references\" are things like Message-IDs and URLs, as
6662 specified by `gnus-button-alist'."
6663 (interactive (list 'force))
6664 (gnus-with-article-buffer
6665 (let ((inhibit-point-motion-hooks t)
6666 (case-fold-search t)
6667 (alist gnus-button-alist)
6669 ;; Remove all old markers.
6670 (let (marker entry new-list)
6671 (while (setq marker (pop gnus-button-marker-list))
6672 (if (or (< marker (point-min)) (>= marker (point-max)))
6673 (push marker new-list)
6675 (when (setq entry (gnus-button-entry))
6676 (put-text-property (match-beginning (nth 1 entry))
6677 (match-end (nth 1 entry))
6678 'gnus-callback nil))
6679 (set-marker marker nil)))
6680 (setq gnus-button-marker-list new-list))
6681 ;; We skip the headers.
6684 (while (setq entry (pop alist))
6685 (setq regexp (eval (car entry)))
6687 (while (re-search-forward regexp nil t)
6688 (let* ((start (and entry (match-beginning (nth 1 entry))))
6689 (end (and entry (match-end (nth 1 entry))))
6690 (from (match-beginning 0)))
6691 (when (and (or (eq t (nth 2 entry))
6692 (eval (nth 2 entry)))
6693 (not (gnus-button-in-region-p
6694 start end 'gnus-callback)))
6695 ;; That optional form returned non-nil, so we add the
6697 (gnus-article-add-button
6698 start end 'gnus-button-push
6699 (car (push (set-marker (make-marker) from)
6700 gnus-button-marker-list))))))))))
6702 ;; Add buttons to the head of an article.
6703 (defun gnus-article-add-buttons-to-head ()
6704 "Add buttons to the head of the article."
6706 (gnus-with-article-headers
6708 (dolist (entry gnus-header-button-alist)
6709 ;; Each alist entry.
6710 (goto-char (point-min))
6711 (while (re-search-forward (car entry) nil t)
6712 ;; Each header matching the entry.
6713 (setq beg (match-beginning 0))
6714 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6715 (match-beginning 0))
6718 (while (re-search-forward (eval (nth 1 entry)) end t)
6719 ;; Each match within a header.
6720 (let* ((entry (cdr entry))
6721 (start (match-beginning (nth 1 entry)))
6722 (end (match-end (nth 1 entry)))
6723 (form (nth 2 entry)))
6724 (goto-char (match-end 0))
6726 (gnus-article-add-button
6727 start end (nth 3 entry)
6728 (buffer-substring (match-beginning (nth 4 entry))
6729 (match-end (nth 4 entry)))))))
6730 (goto-char end))))))
6732 ;;; External functions:
6734 (defun gnus-article-add-button (from to fun &optional data)
6735 "Create a button between FROM and TO with callback FUN and data DATA."
6736 (when gnus-article-button-face
6737 (gnus-overlay-put (gnus-make-overlay from to)
6738 'face gnus-article-button-face))
6739 (gnus-add-text-properties
6741 (nconc (and gnus-article-mouse-face
6742 (list gnus-mouse-face-prop gnus-article-mouse-face))
6743 (list 'gnus-callback fun)
6744 (and data (list 'gnus-data data))))
6745 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6746 :button-keymap gnus-widget-button-keymap))
6748 ;;; Internal functions:
6750 (defun gnus-article-set-globals ()
6751 (with-current-buffer gnus-summary-buffer
6752 (gnus-set-global-variables)))
6754 (defun gnus-signature-toggle (end)
6755 (gnus-with-article-buffer
6756 (let ((inhibit-point-motion-hooks t))
6757 (if (text-property-any end (point-max) 'article-type 'signature)
6759 (gnus-delete-wash-type 'signature)
6760 (gnus-remove-text-properties-when
6761 'article-type 'signature end (point-max)
6762 (cons 'article-type (cons 'signature
6763 gnus-hidden-properties))))
6764 (gnus-add-wash-type 'signature)
6765 (gnus-add-text-properties-when
6766 'article-type nil end (point-max)
6767 (cons 'article-type (cons 'signature
6768 gnus-hidden-properties)))))
6769 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6770 (gnus-set-mode-line 'article))))
6772 (defun gnus-button-entry ()
6773 ;; Return the first entry in `gnus-button-alist' matching this place.
6774 (let ((alist gnus-button-alist)
6777 (setq entry (pop alist))
6778 (if (looking-at (eval (car entry)))
6783 (defun gnus-button-push (marker)
6784 ;; Push button starting at MARKER.
6787 (let* ((entry (gnus-button-entry))
6788 (inhibit-point-motion-hooks t)
6790 (args (mapcar (lambda (group)
6791 (let ((string (match-string group)))
6792 (set-text-properties
6793 0 (length string) nil string)
6800 (fboundp (symbol-value fun)))
6801 (apply (symbol-value fun) args))
6803 (gnus-message 1 "You must define `%S' to use this button"
6804 (cons fun args)))))))
6806 (defun gnus-parse-news-url (url)
6807 (let (scheme server port group message-id articles)
6810 (goto-char (point-min))
6811 (when (looking-at "\\([A-Za-z]+\\):")
6812 (setq scheme (match-string 1))
6813 (goto-char (match-end 0)))
6814 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
6815 (setq server (match-string 1))
6816 (setq port (if (stringp (match-string 3))
6817 (string-to-number (match-string 3))
6819 (goto-char (match-end 0)))
6822 ((looking-at "\\(.*@.*\\)")
6823 (setq message-id (match-string 1)))
6824 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6825 (setq group (match-string 1)
6826 articles (split-string (match-string 2) "-")))
6827 ((looking-at "\\([^/]+\\)/?")
6828 (setq group (match-string 1)))
6830 (error "Unknown news URL syntax"))))
6831 (list scheme server port group message-id articles)))
6833 (defun gnus-button-handle-news (url)
6835 (destructuring-bind (scheme server port group message-id articles)
6836 (gnus-parse-news-url url)
6840 (set-buffer gnus-summary-buffer)
6842 (let ((gnus-refer-article-method
6843 (nconc (list (list 'nntp server))
6844 gnus-refer-article-method))
6845 (nntp-port-number (or port "nntp")))
6846 (gnus-message 7 "Fetching %s with %s"
6847 message-id gnus-refer-article-method)
6848 (gnus-summary-refer-article message-id))
6849 (gnus-summary-refer-article message-id))))
6851 (gnus-button-fetch-group url)))))
6853 (defun gnus-button-handle-man (url)
6855 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6856 (when (eq gnus-button-man-handler 'woman)
6857 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
6858 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6859 (funcall gnus-button-man-handler url))
6861 (defun gnus-button-handle-info-url (url)
6862 "Fetch an info URL."
6863 (setq url (mm-subst-char-in-string ?+ ?\ url))
6865 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6866 (gnus-info-find-node
6867 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6869 ")" (gnus-url-unhex-string (match-string 2 url)))))
6870 ((string-match "([^)\"]+)[^\"]+" url)
6872 (gnus-replace-in-string
6873 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6874 (gnus-info-find-node url))
6875 (t (error "Can't parse %s" url))))
6877 (defun gnus-button-handle-info-url-gnome (url)
6878 "Fetch GNOME style info URL."
6879 (setq url (mm-subst-char-in-string ?_ ?\ url))
6880 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6881 (gnus-info-find-node
6883 (gnus-url-unhex-string
6884 (match-string 1 url))
6886 (or (gnus-url-unhex-string
6887 (match-string 2 url))
6889 (error "Can't parse %s" url)))
6891 (defun gnus-button-handle-info-url-kde (url)
6892 "Fetch KDE style info URL."
6893 (gnus-info-find-node (gnus-url-unhex-string url)))
6895 (defun gnus-button-handle-info-keystrokes (url)
6896 "Call `info' when pushing the corresponding URL button."
6897 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6902 (defun gnus-button-openpgp (url)
6903 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
6905 (mm-url-insert-file-contents-external url)
6906 (pgg-snarf-keys-region (point-min) (point-max))
6907 (pgg-display-output-buffer nil nil nil)))
6909 (defun gnus-button-message-id (message-id)
6911 (with-current-buffer gnus-summary-buffer
6912 (gnus-summary-refer-article message-id)))
6914 (defun gnus-button-fetch-group (address)
6915 "Fetch GROUP specified by ADDRESS."
6916 (if (not (string-match "[:/]" address))
6917 ;; This is just a simple group url.
6918 (gnus-group-read-ephemeral-group address gnus-select-method)
6921 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6923 (error "Can't parse %s" address)
6924 (gnus-group-read-ephemeral-group
6925 (match-string 4 address)
6926 `(nntp ,(match-string 1 address)
6927 (nntp-address ,(match-string 1 address))
6928 (nntp-port-number ,(if (match-end 3)
6929 (match-string 3 address)
6932 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
6934 (defun gnus-url-parse-query-string (query &optional downcase)
6935 (let (retval pairs cur key val)
6936 (setq pairs (split-string query "&"))
6938 (setq cur (car pairs)
6940 (if (not (string-match "=" cur))
6942 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6943 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6945 (setq key (downcase key)))
6946 (setq cur (assoc key retval))
6948 (setcdr cur (cons val (cdr cur)))
6949 (setq retval (cons (list key val) retval)))))
6952 (defun gnus-url-mailto (url)
6953 ;; Send mail to someone
6954 (when (string-match "mailto:/*\\(.*\\)" url)
6955 (setq url (substring url (match-beginning 1) nil)))
6956 (let (to args subject func)
6957 (setq args (gnus-url-parse-query-string
6958 (if (string-match "^\\?" url)
6960 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6961 (concat "to=" (match-string 1 url) "&"
6962 (match-string 2 url))
6963 (concat "to=" url)))
6965 subject (cdr-safe (assoc "subject" args)))
6968 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6971 (message-position-on-field (caar args)))
6972 (insert (gnus-replace-in-string
6973 (mapconcat 'identity (reverse (cdar args)) ", ")
6975 (setq args (cdr args)))
6978 (message-goto-subject))))
6980 (defun gnus-button-embedded-url (address)
6981 "Activate ADDRESS with `browse-url'."
6982 (browse-url (gnus-strip-whitespace address)))
6984 ;;; Next/prev buttons in the article buffer.
6986 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6987 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6989 (defvar gnus-prev-page-map
6990 (let ((map (make-sparse-keymap)))
6991 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6992 (define-key map "\r" 'gnus-button-prev-page)
6995 (defvar gnus-next-page-map
6996 (let ((map (make-sparse-keymap)))
6997 (unless (>= emacs-major-version 21)
6998 ;; XEmacs doesn't care.
6999 (set-keymap-parent map gnus-article-mode-map))
7000 (define-key map gnus-mouse-2 'gnus-button-next-page)
7001 (define-key map "\r" 'gnus-button-next-page)
7004 (defun gnus-insert-prev-page-button ()
7006 (inhibit-read-only t))
7008 gnus-prev-page-line-format nil
7009 `(keymap ,gnus-prev-page-map
7011 gnus-callback gnus-article-button-prev-page
7012 article-type annotation))
7013 (widget-convert-button
7015 ;; Exclude a newline.
7018 :action 'gnus-button-prev-page
7019 :button-keymap gnus-prev-page-map)))
7021 (defun gnus-button-next-page (&optional args more-args)
7022 "Go to the next page."
7024 (let ((win (selected-window)))
7025 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7026 (gnus-article-next-page)
7027 (select-window win)))
7029 (defun gnus-button-prev-page (&optional args more-args)
7030 "Go to the prev page."
7032 (let ((win (selected-window)))
7033 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7034 (gnus-article-prev-page)
7035 (select-window win)))
7037 (defun gnus-insert-next-page-button ()
7039 (inhibit-read-only t))
7040 (gnus-eval-format gnus-next-page-line-format nil
7041 `(keymap ,gnus-next-page-map
7043 gnus-callback gnus-article-button-next-page
7044 article-type annotation))
7045 (widget-convert-button
7047 ;; Exclude a newline.
7050 :action 'gnus-button-next-page
7051 :button-keymap gnus-next-page-map)))
7053 (defun gnus-article-button-next-page (arg)
7054 "Go to the next page."
7056 (let ((win (selected-window)))
7057 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7058 (gnus-article-next-page)
7059 (select-window win)))
7061 (defun gnus-article-button-prev-page (arg)
7062 "Go to the prev page."
7064 (let ((win (selected-window)))
7065 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7066 (gnus-article-prev-page)
7067 (select-window win)))
7069 (defvar gnus-decode-header-methods
7070 '(mail-decode-encoded-word-region)
7071 "List of methods used to decode headers.
7073 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7074 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7075 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7076 whose names match REGEXP.
7079 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7080 mail-decode-encoded-word-region
7081 (\"chinese\" . rfc1843-decode-region))
7084 (defvar gnus-decode-header-methods-cache nil)
7086 (defun gnus-multi-decode-header (start end)
7087 "Apply the functions from `gnus-encoded-word-methods' that match."
7088 (unless (and gnus-decode-header-methods-cache
7089 (eq gnus-newsgroup-name
7090 (car gnus-decode-header-methods-cache)))
7091 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7094 (nconc gnus-decode-header-methods-cache (list x))
7095 (if (and gnus-newsgroup-name
7096 (string-match (car x) gnus-newsgroup-name))
7097 (nconc gnus-decode-header-methods-cache
7099 gnus-decode-header-methods))
7100 (let ((xlist gnus-decode-header-methods-cache))
7103 (narrow-to-region start end)
7105 (funcall (pop xlist) (point-min) (point-max))))))
7108 ;;; Treatment top-level handling.
7111 (defun gnus-treat-article (condition &optional part-number total-parts type)
7112 (let ((length (- (point-max) (point-min)))
7113 (alist gnus-treatment-function-alist)
7114 (article-goto-body-goes-to-point-min-p t)
7118 (let ((list gnus-article-treat-types))
7120 (when (string-match (pop list) type)
7121 (throw 'found t)))))))
7122 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7124 (gnus-run-hooks 'gnus-part-display-hook)
7125 (dolist (elem alist)
7128 (when (gnus-buffer-live-p gnus-summary-buffer)
7129 (set-buffer gnus-summary-buffer))
7130 (symbol-value (car elem))))
7131 (when (and (or (consp val)
7133 (gnus-treat-predicate val)
7134 (or (not (get (car elem) 'highlight))
7137 (funcall (cadr elem)))))))
7139 ;; Dynamic variables.
7141 (defvar part-number)
7142 (defvar total-parts)
7147 (defun gnus-treat-predicate (val)
7154 (stringp (car val)))
7155 (apply 'gnus-or (mapcar `(lambda (s)
7156 (string-match s ,(or gnus-newsgroup-name "")))
7159 (let ((pred (pop val)))
7162 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7164 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7166 (not (gnus-treat-predicate (car val))))
7168 (equal (car val) type))
7170 (error "%S is not a valid predicate" pred)))))
7176 (eq part-number total-parts))
7180 (error "%S is not a valid value" val))))
7182 (defun gnus-article-encrypt-body (protocol &optional n)
7183 "Encrypt the article body."
7186 (or gnus-article-encrypt-protocol
7187 (completing-read "Encrypt protocol: "
7188 gnus-article-encrypt-protocol-alist
7190 current-prefix-arg))
7191 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7193 (error "Can't find the encrypt protocol %s" protocol))
7194 (if (member gnus-newsgroup-name '("nndraft:delayed"
7197 (error "Can't encrypt the article in group %s"
7198 gnus-newsgroup-name))
7199 (gnus-summary-iterate n
7201 (set-buffer gnus-summary-buffer)
7202 (let ((mail-parse-charset gnus-newsgroup-charset)
7203 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7204 (summary-buffer gnus-summary-buffer)
7206 (gnus-set-global-variables)
7207 (when (gnus-group-read-only-p)
7208 (error "The current newsgroup does not support article encrypt"))
7209 (gnus-summary-show-article t)
7211 (or (mail-header-references gnus-current-headers) ""))
7212 (set-buffer gnus-article-buffer)
7213 (let* ((inhibit-read-only t)
7215 (mapcar (lambda (field)
7216 (and (save-restriction
7217 (message-narrow-to-head)
7218 (goto-char (point-min))
7219 (search-forward field nil t))
7221 (message-narrow-to-field)
7223 (delete-region (point-min) (point-max))
7225 '("Content-Type:" "Content-Transfer-Encoding:"
7226 "Content-Disposition:"))))
7227 (message-narrow-to-head)
7228 (message-remove-header "MIME-Version")
7229 (goto-char (point-max))
7230 (setq point (point))
7231 (insert (apply 'concat headers))
7233 (narrow-to-region point (point-max))
7234 (let ((message-options message-options))
7235 (message-options-set 'message-sender user-mail-address)
7236 (message-options-set 'message-recipients user-mail-address)
7237 (message-options-set 'message-sign-encrypt 'not)
7239 (goto-char (point-min))
7240 (insert "MIME-Version: 1.0\n")
7242 (gnus-summary-edit-article-done
7243 references nil summary-buffer t))
7244 (when gnus-keep-backlog
7245 (gnus-backlog-remove-article
7246 (car gnus-article-current) (cdr gnus-article-current)))
7248 (when (get-buffer gnus-original-article-buffer)
7249 (set-buffer gnus-original-article-buffer)
7250 (setq gnus-original-article nil)))
7251 (when gnus-use-cache
7252 (gnus-cache-update-article
7253 (car gnus-article-current) (cdr gnus-article-current))))))))
7255 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7256 "The following specs can be used:
7257 %t The security MIME type
7260 %D Details if button is pressed")
7262 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7263 "The following specs can be used:
7264 %t The security MIME type
7267 %D Details if button is pressed")
7269 (defvar gnus-mime-security-button-line-format-alist
7270 '((?t gnus-tmp-type ?s)
7271 (?i gnus-tmp-info ?s)
7272 (?d gnus-tmp-details ?s)
7273 (?D gnus-tmp-pressed-details ?s)))
7275 (defvar gnus-mime-security-button-map
7276 (let ((map (make-sparse-keymap)))
7277 (define-key map gnus-mouse-2 'gnus-article-push-button)
7278 (define-key map "\r" 'gnus-article-press-button)
7281 (defvar gnus-mime-security-details-buffer nil)
7283 (defvar gnus-mime-security-button-pressed nil)
7285 (defvar gnus-mime-security-show-details-inline t
7286 "If non-nil, show details in the article buffer.")
7288 (defun gnus-mime-security-verify-or-decrypt (handle)
7289 (mm-remove-parts (cdr handle))
7290 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7291 point (inhibit-read-only t))
7293 (goto-char (car region)))
7295 (narrow-to-region (point) (point))
7296 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7297 (let* ((mm-verify-option 'known)
7298 (mm-decrypt-option 'known)
7299 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7300 (unless (eq nparts (cdr handle))
7301 (mm-destroy-parts (cdr handle))
7302 (setcdr handle nparts))))
7303 (setq point (point))
7304 (gnus-mime-display-security handle)
7305 (goto-char (point-max)))
7307 (delete-region (point) (cdr region))
7308 (set-marker (car region) nil)
7309 (set-marker (cdr region) nil))
7312 (defun gnus-mime-security-show-details (handle)
7313 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7315 (gnus-message 5 "No details.")
7316 (if gnus-mime-security-show-details-inline
7317 (let ((gnus-mime-security-button-pressed
7318 (not (get-text-property (point) 'gnus-mime-details)))
7319 (gnus-mime-security-button-line-format
7320 (get-text-property (point) 'gnus-line-format))
7321 (inhibit-read-only t))
7323 (while (eq (get-text-property (point) 'gnus-line-format)
7324 gnus-mime-security-button-line-format)
7328 (narrow-to-region (point) (point))
7329 (gnus-insert-mime-security-button handle))
7330 (delete-region (point)
7331 (or (text-property-not-all
7334 gnus-mime-security-button-line-format)
7337 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7338 (with-current-buffer gnus-mime-security-details-buffer
7341 (setq gnus-mime-security-details-buffer
7342 (gnus-get-buffer-create "*MIME Security Details*")))
7343 (with-current-buffer gnus-mime-security-details-buffer
7345 (goto-char (point-min)))
7346 (pop-to-buffer gnus-mime-security-details-buffer)))))
7348 (defun gnus-mime-security-press-button (handle)
7350 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7351 (gnus-mime-security-show-details handle)
7352 (gnus-mime-security-verify-or-decrypt handle))))
7354 (defun gnus-insert-mime-security-button (handle &optional displayed)
7355 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7358 (or (nth 2 (assoc protocol mm-verify-function-alist))
7359 (nth 2 (assoc protocol mm-decrypt-function-alist))
7361 (if (equal (car handle) "multipart/signed")
7362 " Signed" " Encrypted")
7365 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7368 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7369 gnus-tmp-pressed-details
7371 (setq gnus-tmp-details
7372 (if gnus-tmp-details
7373 (concat "\n" gnus-tmp-details)
7375 (setq gnus-tmp-pressed-details
7376 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7381 gnus-mime-security-button-line-format
7382 gnus-mime-security-button-line-format-alist
7383 `(keymap ,gnus-mime-security-button-map
7384 gnus-callback gnus-mime-security-press-button
7385 gnus-line-format ,gnus-mime-security-button-line-format
7386 gnus-mime-details ,gnus-mime-security-button-pressed
7387 article-type annotation
7390 ;; Exclude a newline.
7393 (widget-convert-button
7396 :action 'gnus-widget-press-button
7397 :button-keymap gnus-mime-security-button-map
7399 (lambda (widget/window &optional overlay pos)
7400 ;; Needed to properly clear the message due to a bug in
7401 ;; wid-edit (XEmacs only).
7402 (when (boundp 'help-echo-owns-message)
7403 (setq help-echo-owns-message t))
7406 (aref gnus-mouse-2 0))))))
7408 (defun gnus-mime-display-security (handle)
7410 (narrow-to-region (point) (point))
7411 (unless (gnus-unbuttonized-mime-type-p (car handle))
7412 (gnus-insert-mime-security-button handle))
7413 (gnus-mime-display-part (cadr handle))
7416 (unless (gnus-unbuttonized-mime-type-p (car handle))
7417 (let ((gnus-mime-security-button-line-format
7418 gnus-mime-security-button-end-line-format))
7419 (gnus-insert-mime-security-button handle)))
7420 (mm-set-handle-multipart-parameter
7422 (cons (set-marker (make-marker) (point-min))
7423 (set-marker (make-marker) (point-max))))))
7429 (run-hooks 'gnus-art-load-hook)
7431 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7432 ;;; gnus-art.el ends here