1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
31 (defvar tool-bar-map))
34 ;; Avoid the "Recursive load suspected" error in Emacs 21.1.
36 (let ((recursive-load-depth-limit 100))
49 (autoload 'gnus-msg-mail "gnus-msg" nil t)
50 (autoload 'gnus-button-mailto "gnus-msg")
51 (autoload 'gnus-button-reply "gnus-msg" nil t)
52 (autoload 'parse-time-string "parse-time" nil nil)
53 (autoload 'ansi-color-apply-on-region "ansi-color")
55 (defgroup gnus-article nil
57 :link '(custom-manual "(gnus)Article Buffer")
60 (defgroup gnus-article-treat nil
61 "Treating article parts."
62 :link '(custom-manual "(gnus)Article Hiding")
65 (defgroup gnus-article-hiding nil
66 "Hiding article parts."
67 :link '(custom-manual "(gnus)Article Hiding")
70 (defgroup gnus-article-highlight nil
71 "Article highlighting."
72 :link '(custom-manual "(gnus)Article Highlighting")
76 (defgroup gnus-article-signature nil
78 :link '(custom-manual "(gnus)Article Signature")
81 (defgroup gnus-article-headers nil
83 :link '(custom-manual "(gnus)Hiding Headers")
86 (defgroup gnus-article-washing nil
87 "Special commands on articles."
88 :link '(custom-manual "(gnus)Article Washing")
91 (defgroup gnus-article-emphasis nil
92 "Fontisizing articles."
93 :link '(custom-manual "(gnus)Article Fontisizing")
96 (defgroup gnus-article-saving nil
98 :link '(custom-manual "(gnus)Saving Articles")
101 (defgroup gnus-article-mime nil
102 "Worshiping the MIME wonder."
103 :link '(custom-manual "(gnus)Using MIME")
104 :group 'gnus-article)
106 (defgroup gnus-article-buttons nil
107 "Pushable buttons in the article buffer."
108 :link '(custom-manual "(gnus)Article Buttons")
109 :group 'gnus-article)
111 (defgroup gnus-article-various nil
112 "Other article options."
113 :link '(custom-manual "(gnus)Misc Article")
114 :group 'gnus-article)
116 (defcustom gnus-ignored-headers
119 (concat "^" header ":"))
120 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
121 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
122 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
123 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
124 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
125 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
126 "X-Attribution" "X-Originating-IP" "Delivered-To"
127 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
128 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
129 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
130 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
131 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
132 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
133 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
134 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
135 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
136 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
137 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
138 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
139 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
140 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
141 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
142 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
143 "List-[A-Za-z]+" "X-Listprocessor-Version"
144 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
145 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
146 "X-Received" "Content-length" "X-precedence"
147 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
148 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
149 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
150 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
151 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
152 "X-Content-length" "X-Posting-Agent" "Original-Received"
153 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
154 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
155 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
156 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
157 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
158 "*All headers that start with this regexp will be hidden.
159 This variable can also be a list of regexps of headers to be ignored.
160 If `gnus-visible-headers' is non-nil, this variable will be ignored."
161 :type '(choice :custom-show nil
164 :group 'gnus-article-hiding)
166 (defcustom gnus-visible-headers
167 "^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:"
168 "*All headers that do not match this regexp will be hidden.
169 This variable can also be a list of regexp of headers to remain visible.
170 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
171 :type '(repeat :value-to-internal (lambda (widget value)
172 (custom-split-regexp-maybe value))
173 :match (lambda (widget value)
175 (widget-editable-list-match widget value)))
177 :group 'gnus-article-hiding)
179 (defcustom gnus-sorted-header-list
180 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
181 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
182 "*This variable is a list of regular expressions.
183 If it is non-nil, headers that match the regular expressions will
184 be placed first in the article buffer in the sequence specified by
186 :type '(repeat regexp)
187 :group 'gnus-article-hiding)
189 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
190 "Headers that are only to be displayed if they have interesting data.
191 Possible values in this list are:
193 'empty Headers with no content.
194 'newsgroups Newsgroup identical to Gnus group.
195 'to-address To identical to To-address.
196 'to-list To identical to To-list.
197 'cc-list CC identical to To-list.
198 'followup-to Followup-to identical to Newsgroups.
199 'reply-to Reply-to identical to From.
200 'date Date less than four days old.
201 'long-to To and/or Cc longer than 1024 characters.
202 'many-to Multiple To and/or Cc."
203 :type '(set (const :tag "Headers with no content." empty)
204 (const :tag "Newsgroups identical to Gnus group." newsgroups)
205 (const :tag "To identical to To-address." to-address)
206 (const :tag "To identical to To-list." to-list)
207 (const :tag "CC identical to To-list." cc-list)
208 (const :tag "Followup-to identical to Newsgroups." followup-to)
209 (const :tag "Reply-to identical to From." reply-to)
210 (const :tag "Date less than four days old." date)
211 (const :tag "To and/or Cc longer than 1024 characters." long-to)
212 (const :tag "Multiple To and/or Cc headers." many-to))
213 :group 'gnus-article-hiding)
215 (defcustom gnus-article-skip-boring nil
216 "Skip over text that is not worth reading.
217 By default, if you set this t, then Gnus will display citations and
218 signatures, but will never scroll down to show you a page consisting
219 only of boring text. Boring text is controlled by
220 `gnus-article-boring-faces'."
223 :group 'gnus-article-hiding)
225 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
226 "Regexp matching signature separator.
227 This can also be a list of regexps. In that case, it will be checked
228 from head to tail looking for a separator. Searches will be done from
229 the end of the buffer."
230 :type '(repeat string)
231 :group 'gnus-article-signature)
233 (defcustom gnus-signature-limit nil
234 "Provide a limit to what is considered a signature.
235 If it is a number, no signature may not be longer (in characters) than
236 that number. If it is a floating point number, no signature may be
237 longer (in lines) than that number. If it is a function, the function
238 will be called without any parameters, and if it returns nil, there is
239 no signature in the buffer. If it is a string, it will be used as a
240 regexp. If it matches, the text in question is not a signature.
242 This can also be a list of the above values."
243 :type '(choice (integer :value 200)
245 (function :value fun)
246 (regexp :value ".*"))
247 :group 'gnus-article-signature)
249 (defcustom gnus-hidden-properties '(invisible t intangible t)
250 "Property list to use for hiding text."
252 :group 'gnus-article-hiding)
254 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
255 ;; frames in a session.
256 (defcustom gnus-article-x-face-command
257 (if (featurep 'xemacs)
258 (if (or (gnus-image-type-available-p 'xface)
259 (gnus-image-type-available-p 'pbm))
260 'gnus-display-x-face-in-from
261 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
262 (if (gnus-image-type-available-p 'pbm)
263 'gnus-display-x-face-in-from
264 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
266 "*String or function to be executed to display an X-Face header.
267 If it is a string, the command will be executed in a sub-shell
268 asynchronously. The compressed face will be piped to this command."
269 :type `(choice string
270 (function-item gnus-display-x-face-in-from)
274 :group 'gnus-article-washing)
276 (defcustom gnus-article-x-face-too-ugly nil
277 "Regexp matching posters whose face shouldn't be shown automatically."
278 :type '(choice regexp (const nil))
279 :group 'gnus-article-washing)
281 (defcustom gnus-article-banner-alist nil
282 "Banner alist for stripping.
284 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
286 :type '(repeat (cons symbol regexp))
287 :group 'gnus-article-washing)
289 (gnus-define-group-parameter
292 "Alist of regexps (to match group names) and banner."
293 :variable-group gnus-article-washing
295 '(choice :tag "Banner"
297 (const :tag "Remove signature" signature)
298 (symbol :tag "Item in `gnus-article-banner-alist'" none)
300 (const :tag "None" nil))
302 "If non-nil, specify how to remove `banners' from articles.
304 Symbol `signature' means to remove signatures delimited by
305 `gnus-signature-separator'. Any other symbol is used to look up a
306 regular expression to match the banner in `gnus-article-banner-alist'.
307 A string is used as a regular expression to match the banner
310 (defcustom gnus-article-address-banner-alist nil
311 "Alist of mail addresses and banners.
312 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
313 to match a mail address in the From: header, BANNER is one of a symbol
314 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
315 If ADDRESS matches author's mail address, it will remove things like
316 advertisements. For example:
318 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
322 (regexp :tag "Address")
323 (choice :tag "Banner" :value nil
324 (const :tag "Remove signature" signature)
325 (symbol :tag "Item in `gnus-article-banner-alist'" none)
327 (const :tag "None" nil))))
329 :group 'gnus-article-washing)
331 (defmacro gnus-emphasis-custom-with-format (&rest body)
333 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
334 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
337 (defun gnus-emphasis-custom-value-to-external (value)
338 (gnus-emphasis-custom-with-format
339 (if (consp (car value))
340 (list (format format (car (car value)) (cdr (car value)))
342 (if (nth 1 value) 2 3)
346 (defun gnus-emphasis-custom-value-to-internal (value)
347 (gnus-emphasis-custom-with-format
348 (let ((regexp (concat "\\`"
349 (format (regexp-quote format)
350 "\\([^()]+\\)" "\\([^()]+\\)")
353 (if (string-match regexp (setq pattern (car value)))
354 (list (cons (match-string 1 pattern) (match-string 2 pattern))
359 (defcustom gnus-emphasis-alist
361 '(("\\*" "\\*" bold nil 2)
364 ("_/" "/_" underline-italic)
365 ("_\\*" "\\*_" underline-bold)
366 ("\\*/" "/\\*" bold-italic)
367 ("_\\*/" "/\\*_" underline-bold-italic))))
369 (gnus-emphasis-custom-with-format
370 (mapcar (lambda (spec)
371 (list (format format (car spec) (cadr spec))
374 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
376 '(;; I've never seen anyone use this strikethru convention whereas I've
377 ;; several times seen it triggered by normal text. --Stef
378 ;; Miles suggests that this form is sometimes used but for italics,
379 ;; so maybe we should map it to `italic'.
380 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
381 ;; 2 3 gnus-emphasis-strikethru)
382 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
383 2 3 gnus-emphasis-underline))))
384 "*Alist that says how to fontify certain phrases.
385 Each item looks like this:
387 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
389 The first element is a regular expression to be matched. The second
390 is a number that says what regular expression grouping used to find
391 the entire emphasized word. The third is a number that says what
392 regexp grouping should be displayed and highlighted. The fourth
393 is the face used for highlighting."
397 :format "%[Customizing Style%]\n%v"
399 (group :tag "Default"
400 :value ("" 0 0 default)
403 (let ((value (widget-get
404 (cadr (widget-get (widget-get widget :parent)
407 (if (not (eq (nth 2 value) 'default))
411 (gnus-emphasis-custom-value-to-external value))))
412 (widget-group-value-create widget))
414 (integer :format "Match group: %v")
415 (integer :format "Emphasize group: %v")
418 :value (("_" . "_") nil default)
420 (regexp :format "Start regexp: %v")
421 (regexp :format "End regexp: %v"))
422 (boolean :format "Show start and end patterns: %[%v%]\n"
423 :on " On " :off " Off ")
425 :get (lambda (symbol)
426 (mapcar 'gnus-emphasis-custom-value-to-internal
427 (default-value symbol)))
428 :set (lambda (symbol value)
429 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
431 :group 'gnus-article-emphasis)
433 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
434 "A regexp to describe whitespace which should not be emphasized.
435 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
436 The former avoids underlining of leading and trailing whitespace,
437 and the latter avoids underlining any whitespace at all."
439 :group 'gnus-article-emphasis
442 (defface gnus-emphasis-bold '((t (:bold t)))
443 "Face used for displaying strong emphasized text (*word*)."
444 :group 'gnus-article-emphasis)
446 (defface gnus-emphasis-italic '((t (:italic t)))
447 "Face used for displaying italic emphasized text (/word/)."
448 :group 'gnus-article-emphasis)
450 (defface gnus-emphasis-underline '((t (:underline t)))
451 "Face used for displaying underlined emphasized text (_word_)."
452 :group 'gnus-article-emphasis)
454 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
455 "Face used for displaying underlined bold emphasized text (_*word*_)."
456 :group 'gnus-article-emphasis)
458 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
459 "Face used for displaying underlined italic emphasized text (_/word/_)."
460 :group 'gnus-article-emphasis)
462 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
463 "Face used for displaying bold italic emphasized text (/*word*/)."
464 :group 'gnus-article-emphasis)
466 (defface gnus-emphasis-underline-bold-italic
467 '((t (:bold t :italic t :underline t)))
468 "Face used for displaying underlined bold italic emphasized text.
469 Example: (_/*word*/_)."
470 :group 'gnus-article-emphasis)
472 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
473 '((t (:strikethru t)))
474 '((t (:strike-through t))))
475 "Face used for displaying strike-through text (-word-)."
476 :group 'gnus-article-emphasis)
478 (defface gnus-emphasis-highlight-words
479 '((t (:background "black" :foreground "yellow")))
480 "Face used for displaying highlighted words."
481 :group 'gnus-article-emphasis)
483 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
484 "Format for display of Date headers in article bodies.
485 See `format-time-string' for the possible values.
487 The variable can also be function, which should return a complete Date
488 header. The function is called with one argument, the time, which can
489 be fed to `format-time-string'."
490 :type '(choice string function)
491 :link '(custom-manual "(gnus)Article Date")
492 :group 'gnus-article-washing)
494 (defcustom gnus-save-all-headers t
495 "*If non-nil, don't remove any headers before saving."
496 :group 'gnus-article-saving
499 (defcustom gnus-prompt-before-saving 'always
500 "*This variable says how much prompting is to be done when saving articles.
501 If it is nil, no prompting will be done, and the articles will be
502 saved to the default files. If this variable is `always', each and
503 every article that is saved will be preceded by a prompt, even when
504 saving large batches of articles. If this variable is neither nil not
505 `always', there the user will be prompted once for a file name for
506 each invocation of the saving commands."
507 :group 'gnus-article-saving
508 :type '(choice (item always)
509 (item :tag "never" nil)
510 (sexp :tag "once" :format "%t\n" :value t)))
512 (defcustom gnus-saved-headers gnus-visible-headers
513 "Headers to keep if `gnus-save-all-headers' is nil.
514 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
515 If that variable is nil, however, all headers that match this regexp
516 will be kept while the rest will be deleted before saving."
517 :group 'gnus-article-saving
520 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
521 "A function to save articles in your favourite format.
522 The function must be interactively callable (in other words, it must
523 be an Emacs command).
525 Gnus provides the following functions:
527 * gnus-summary-save-in-rmail (Rmail format)
528 * gnus-summary-save-in-mail (Unix mail format)
529 * gnus-summary-save-in-folder (MH folder)
530 * gnus-summary-save-in-file (article format)
531 * gnus-summary-save-body-in-file (article body)
532 * gnus-summary-save-in-vm (use VM's folder format)
533 * gnus-summary-write-to-file (article format -- overwrite)."
534 :group 'gnus-article-saving
535 :type '(radio (function-item gnus-summary-save-in-rmail)
536 (function-item gnus-summary-save-in-mail)
537 (function-item gnus-summary-save-in-folder)
538 (function-item gnus-summary-save-in-file)
539 (function-item gnus-summary-save-body-in-file)
540 (function-item gnus-summary-save-in-vm)
541 (function-item gnus-summary-write-to-file)))
543 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
544 "A function generating a file name to save articles in Rmail format.
545 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
546 :group 'gnus-article-saving
549 (defcustom gnus-mail-save-name 'gnus-plain-save-name
550 "A function generating a file name to save articles in Unix mail format.
551 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
552 :group 'gnus-article-saving
555 (defcustom gnus-folder-save-name 'gnus-folder-save-name
556 "A function generating a file name to save articles in MH folder.
557 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
558 :group 'gnus-article-saving
561 (defcustom gnus-file-save-name 'gnus-numeric-save-name
562 "A function generating a file name to save articles in article format.
563 The function is called with NEWSGROUP, HEADERS, and optional
565 :group 'gnus-article-saving
568 (defcustom gnus-split-methods
569 '((gnus-article-archive-name)
570 (gnus-article-nndoc-name))
571 "*Variable used to suggest where articles are to be saved.
572 For instance, if you would like to save articles related to Gnus in
573 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
574 you could set this variable to something like:
576 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
577 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
579 This variable is an alist where the key is the match and the
580 value is a list of possible files to save in if the match is
583 If the match is a string, it is used as a regexp match on the
584 article. If the match is a symbol, that symbol will be funcalled
585 from the buffer of the article to be saved with the newsgroup as
586 the parameter. If it is a list, it will be evaled in the same
589 If this form or function returns a string, this string will be
590 used as a possible file name; and if it returns a non-nil list,
591 that list will be used as possible file names."
592 :group 'gnus-article-saving
593 :type '(repeat (choice (list :value (fun) function)
594 (cons :value ("" "") regexp (repeat string))
597 (defcustom gnus-page-delimiter "^\^L"
598 "*Regexp describing what to use as article page delimiters.
599 The default value is \"^\^L\", which is a form linefeed at the
600 beginning of a line."
602 :group 'gnus-article-various)
604 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
605 "*The format specification for the article mode line.
606 See `gnus-summary-mode-line-format' for a closer description.
608 The following additional specs are available:
610 %w The article washing status.
611 %m The number of MIME parts in the article."
613 :group 'gnus-article-various)
615 (defcustom gnus-article-mode-hook nil
616 "*A hook for Gnus article mode."
618 :group 'gnus-article-various)
620 (when (featurep 'xemacs)
621 ;; Extracted from gnus-xmas-define in order to preserve user settings
622 (when (fboundp 'turn-off-scroll-in-place)
623 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
624 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
625 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
627 (defcustom gnus-article-menu-hook nil
628 "*Hook run after the creation of the article mode menu."
630 :group 'gnus-article-various)
632 (defcustom gnus-article-prepare-hook nil
633 "*A hook called after an article has been prepared in the article buffer."
635 :group 'gnus-article-various)
637 (defcustom gnus-copy-article-ignored-headers nil
638 "List of headers to be removed when copying an article.
639 Each element is a regular expression."
640 :version "23.0" ;; No Gnus
641 :type '(repeat regexp)
642 :group 'gnus-article-various)
644 (make-obsolete-variable 'gnus-article-hide-pgp-hook
645 "This variable is obsolete in Gnus 5.10.")
647 (defcustom gnus-article-button-face 'bold
648 "Face used for highlighting buttons in the article buffer.
650 An article button is a piece of text that you can activate by pressing
651 `RET' or `mouse-2' above it."
653 :group 'gnus-article-buttons)
655 (defcustom gnus-article-mouse-face 'highlight
656 "Face used for mouse highlighting in the article buffer.
658 Article buttons will be displayed in this face when the cursor is
661 :group 'gnus-article-buttons)
663 (defcustom gnus-signature-face 'gnus-signature
664 "Face used for highlighting a signature in the article buffer.
665 Obsolete; use the face `gnus-signature' for customizations instead."
667 :group 'gnus-article-highlight
668 :group 'gnus-article-signature)
670 (defface gnus-signature
673 "Face used for highlighting a signature in the article buffer."
674 :group 'gnus-article-highlight
675 :group 'gnus-article-signature)
676 ;; backward-compatibility alias
677 (put 'gnus-signature-face 'face-alias 'gnus-signature)
679 (defface gnus-header-from
682 (:foreground "spring green"))
685 (:foreground "red3"))
688 "Face used for displaying from headers."
689 :group 'gnus-article-headers
690 :group 'gnus-article-highlight)
691 ;; backward-compatibility alias
692 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
694 (defface gnus-header-subject
697 (:foreground "SeaGreen3"))
700 (:foreground "red4"))
702 (:bold t :italic t)))
703 "Face used for displaying subject headers."
704 :group 'gnus-article-headers
705 :group 'gnus-article-highlight)
706 ;; backward-compatibility alias
707 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
709 (defface gnus-header-newsgroups
712 (:foreground "yellow" :italic t))
715 (:foreground "MidnightBlue" :italic t))
718 "Face used for displaying newsgroups headers.
719 In the default setup this face is only used for crossposted
721 :group 'gnus-article-headers
722 :group 'gnus-article-highlight)
723 ;; backward-compatibility alias
724 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
726 (defface gnus-header-name
729 (:foreground "SeaGreen"))
732 (:foreground "maroon"))
735 "Face used for displaying header names."
736 :group 'gnus-article-headers
737 :group 'gnus-article-highlight)
738 ;; backward-compatibility alias
739 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
741 (defface gnus-header-content
744 (:foreground "forest green" :italic t))
747 (:foreground "indianred4" :italic t))
749 (:italic t))) "Face used for displaying header content."
750 :group 'gnus-article-headers
751 :group 'gnus-article-highlight)
752 ;; backward-compatibility alias
753 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
755 (defcustom gnus-header-face-alist
756 '(("From" nil gnus-header-from)
757 ("Subject" nil gnus-header-subject)
758 ("Newsgroups:.*," nil gnus-header-newsgroups)
759 ("" gnus-header-name gnus-header-content))
760 "*Controls highlighting of article headers.
762 An alist of the form (HEADER NAME CONTENT).
764 HEADER is a regular expression which should match the name of a
765 header and NAME and CONTENT are either face names or nil.
767 The name of each header field will be displayed using the face
768 specified by the first element in the list where HEADER matches
769 the header name and NAME is non-nil. Similarly, the content will
770 be displayed by the first non-nil matching CONTENT face."
771 :group 'gnus-article-headers
772 :group 'gnus-article-highlight
773 :type '(repeat (list (regexp :tag "Header")
775 (item :tag "skip" nil)
776 (face :value default))
777 (choice :tag "Content"
778 (item :tag "skip" nil)
779 (face :value default)))))
781 (defcustom gnus-article-decode-hook
782 '(article-decode-charset article-decode-encoded-words
783 article-decode-group-name article-decode-idna-rhs)
784 "*Hook run to decode charsets in articles."
785 :group 'gnus-article-headers
788 (defcustom gnus-display-mime-function 'gnus-display-mime
789 "Function to display MIME articles."
790 :group 'gnus-article-mime
793 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
794 "Function used to decode headers.")
796 (defvar gnus-article-dumbquotes-map
816 "Table for MS-to-Latin1 translation.")
818 (defcustom gnus-ignored-mime-types nil
819 "List of MIME types that should be ignored by Gnus."
821 :group 'gnus-article-mime
822 :type '(repeat regexp))
824 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
825 "List of MIME types that should not be given buttons when rendered inline.
826 See also `gnus-buttonized-mime-types' which may override this variable.
827 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
829 :group 'gnus-article-mime
830 :type '(repeat regexp))
832 (defcustom gnus-buttonized-mime-types nil
833 "List of MIME types that should be given buttons when rendered inline.
834 If set, this variable overrides `gnus-unbuttonized-mime-types'.
835 To see e.g. security buttons you could set this to
836 `(\"multipart/signed\")'.
837 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
839 :group 'gnus-article-mime
840 :type '(repeat regexp))
842 (defcustom gnus-inhibit-mime-unbuttonizing nil
843 "If non-nil, all MIME parts get buttons.
844 When nil (the default value), then some MIME parts do not get buttons,
845 as described by the variables `gnus-buttonized-mime-types' and
846 `gnus-unbuttonized-mime-types'."
848 :group 'gnus-article-mime
851 (defcustom gnus-body-boundary-delimiter "_"
852 "String used to delimit header and body.
853 This variable is used by `gnus-article-treat-body-boundary' which can
854 be controlled by `gnus-treat-body-boundary'."
856 :group 'gnus-article-various
857 :type '(choice (item :tag "None" :value nil)
860 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
862 "Defines the location of the faces database.
863 For information on obtaining this database of pretty pictures, please
864 see http://www.cs.indiana.edu/picons/ftp/index.html"
866 :type '(repeat directory)
867 :link '(url-link :tag "download"
868 "http://www.cs.indiana.edu/picons/ftp/index.html")
869 :link '(custom-manual "(gnus)Picons")
872 (defun gnus-picons-installed-p ()
873 "Say whether picons are installed on your machine."
874 (let ((installed nil))
875 (dolist (database gnus-picon-databases)
876 (when (file-exists-p database)
880 (defcustom gnus-article-mime-part-function nil
881 "Function called with a MIME handle as the argument.
882 This is meant for people who want to do something automatic based
883 on parts -- for instance, adding Vcard info to a database."
884 :group 'gnus-article-mime
887 (defcustom gnus-mime-multipart-functions nil
888 "An alist of MIME types to functions to display them."
890 :group 'gnus-article-mime
891 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
893 (defcustom gnus-article-date-lapsed-new-header nil
894 "Whether the X-Sent and Date headers can coexist.
895 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
896 either replace the old \"Date:\" header (if this variable is nil), or
897 be added below it (otherwise)."
899 :group 'gnus-article-headers
902 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
903 "Function called with a MIME handle as the argument.
904 This is meant for people who want to view first matched part.
905 For `undisplayed-alternative' (default), the first undisplayed
906 part or alternative part is used. For `undisplayed', the first
907 undisplayed part is used. For a function, the first part which
908 the function return t is used. For nil, the first part is
911 :group 'gnus-article-mime
913 (item :tag "first" :value nil)
914 (item :tag "undisplayed" :value undisplayed)
915 (item :tag "undisplayed or alternative"
916 :value undisplayed-alternative)
919 (defcustom gnus-mime-action-alist
920 '(("save to file" . gnus-mime-save-part)
921 ("save and strip" . gnus-mime-save-part-and-strip)
922 ("delete part" . gnus-mime-delete-part)
923 ("display as text" . gnus-mime-inline-part)
924 ("view the part" . gnus-mime-view-part)
925 ("pipe to command" . gnus-mime-pipe-part)
926 ("toggle display" . gnus-article-press-button)
927 ("toggle display" . gnus-article-view-part-as-charset)
928 ("view as type" . gnus-mime-view-part-as-type)
929 ("view internally" . gnus-mime-view-part-internally)
930 ("view externally" . gnus-mime-view-part-externally))
931 "An alist of actions that run on the MIME attachment."
932 :group 'gnus-article-mime
933 :type '(repeat (cons (string :tag "name")
937 ;;; The treatment variables
940 (defvar gnus-part-display-hook nil
941 "Hook called on parts that are to receive treatment.")
943 (defvar gnus-article-treat-custom
944 '(choice (const :tag "Off" nil)
946 (const :tag "Header" head)
947 (const :tag "Last" last)
948 (integer :tag "Less")
949 (repeat :tag "Groups" regexp)
950 (sexp :tag "Predicate")))
952 (defvar gnus-article-treat-head-custom
953 '(choice (const :tag "Off" nil)
954 (const :tag "Header" head)))
956 (defvar gnus-article-treat-types '("text/plain")
959 (defvar gnus-inhibit-treatment nil
960 "Whether to inhibit treatment.")
962 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
963 "Highlight the signature.
964 Valid values are nil, t, `head', `last', an integer or a predicate.
965 See Info node `(gnus)Customizing Articles'."
966 :group 'gnus-article-treat
967 :link '(custom-manual "(gnus)Customizing Articles")
968 :type gnus-article-treat-custom)
969 (put 'gnus-treat-highlight-signature 'highlight t)
971 (defcustom gnus-treat-buttonize 100000
973 Valid values are nil, t, `head', `last', an integer or a predicate.
974 See Info node `(gnus)Customizing Articles'."
975 :group 'gnus-article-treat
976 :link '(custom-manual "(gnus)Customizing Articles")
977 :type gnus-article-treat-custom)
978 (put 'gnus-treat-buttonize 'highlight t)
980 (defcustom gnus-treat-buttonize-head 'head
981 "Add buttons to the head.
982 Valid values are nil, t, `head', `last', an integer or a predicate.
983 See Info node `(gnus)Customizing Articles' for details."
984 :group 'gnus-article-treat
985 :link '(custom-manual "(gnus)Customizing Articles")
986 :type gnus-article-treat-head-custom)
987 (put 'gnus-treat-buttonize-head 'highlight t)
989 (defcustom gnus-treat-emphasize
990 (and (or window-system
994 Valid values are nil, t, `head', `last', an integer or a predicate.
995 See Info node `(gnus)Customizing Articles' for details."
996 :group 'gnus-article-treat
997 :link '(custom-manual "(gnus)Customizing Articles")
998 :type gnus-article-treat-custom)
999 (put 'gnus-treat-emphasize 'highlight t)
1001 (defcustom gnus-treat-strip-cr nil
1002 "Remove carriage returns.
1003 Valid values are nil, t, `head', `last', an integer or a predicate.
1004 See Info node `(gnus)Customizing Articles' for details."
1006 :group 'gnus-article-treat
1007 :link '(custom-manual "(gnus)Customizing Articles")
1008 :type gnus-article-treat-custom)
1010 (defcustom gnus-treat-unsplit-urls nil
1011 "Remove newlines from within URLs.
1012 Valid values are nil, t, `head', `last', an integer or a predicate.
1013 See Info node `(gnus)Customizing Articles' for details."
1015 :group 'gnus-article-treat
1016 :link '(custom-manual "(gnus)Customizing Articles")
1017 :type gnus-article-treat-custom)
1019 (defcustom gnus-treat-leading-whitespace nil
1020 "Remove leading whitespace in headers.
1021 Valid values are nil, t, `head', `last', an integer or a predicate.
1022 See Info node `(gnus)Customizing Articles' for details."
1024 :group 'gnus-article-treat
1025 :link '(custom-manual "(gnus)Customizing Articles")
1026 :type gnus-article-treat-custom)
1028 (defcustom gnus-treat-hide-headers 'head
1030 Valid values are nil, t, `head', `last', an integer or a predicate.
1031 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-head-custom)
1036 (defcustom gnus-treat-hide-boring-headers nil
1037 "Hide boring headers.
1038 Valid values are nil, t, `head', `last', an integer or a predicate.
1039 See Info node `(gnus)Customizing Articles' for details."
1040 :group 'gnus-article-treat
1041 :link '(custom-manual "(gnus)Customizing Articles")
1042 :type gnus-article-treat-head-custom)
1044 (defcustom gnus-treat-hide-signature nil
1045 "Hide the signature.
1046 Valid values are nil, t, `head', `last', an integer or a predicate.
1047 See Info node `(gnus)Customizing Articles' for details."
1048 :group 'gnus-article-treat
1049 :link '(custom-manual "(gnus)Customizing Articles")
1050 :type gnus-article-treat-custom)
1052 (defcustom gnus-treat-fill-article nil
1054 Valid values are nil, t, `head', `last', an integer or a predicate.
1055 See Info node `(gnus)Customizing Articles' for details."
1056 :group 'gnus-article-treat
1057 :link '(custom-manual "(gnus)Customizing Articles")
1058 :type gnus-article-treat-custom)
1060 (defcustom gnus-treat-hide-citation nil
1062 Valid values are nil, t, `head', `last', an integer or a predicate.
1063 See Info node `(gnus)Customizing Articles' for details."
1064 :group 'gnus-article-treat
1065 :link '(custom-manual "(gnus)Customizing Articles")
1066 :type gnus-article-treat-custom)
1068 (defcustom gnus-treat-hide-citation-maybe nil
1070 Valid values are nil, t, `head', `last', an integer or a predicate.
1071 See Info node `(gnus)Customizing Articles' for details."
1072 :group 'gnus-article-treat
1073 :link '(custom-manual "(gnus)Customizing Articles")
1074 :type gnus-article-treat-custom)
1076 (defcustom gnus-treat-strip-list-identifiers 'head
1077 "Strip list identifiers from `gnus-list-identifiers`.
1078 Valid values are nil, t, `head', `last', an integer or a predicate.
1079 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 (make-obsolete-variable 'gnus-treat-strip-pgp
1086 "This option is obsolete in Gnus 5.10.")
1088 (defcustom gnus-treat-strip-pem nil
1089 "Strip PEM signatures.
1090 Valid values are nil, t, `head', `last', an integer or a predicate.
1091 See Info node `(gnus)Customizing Articles' for details."
1092 :group 'gnus-article-treat
1093 :link '(custom-manual "(gnus)Customizing Articles")
1094 :type gnus-article-treat-custom)
1096 (defcustom gnus-treat-strip-banner t
1097 "Strip banners from articles.
1098 The banner to be stripped is specified in the `banner' group parameter.
1099 Valid values are nil, t, `head', `last', an integer or a predicate.
1100 See Info node `(gnus)Customizing Articles' for details."
1101 :group 'gnus-article-treat
1102 :link '(custom-manual "(gnus)Customizing Articles")
1103 :type gnus-article-treat-custom)
1105 (defcustom gnus-treat-highlight-headers 'head
1106 "Highlight the headers.
1107 Valid values are nil, t, `head', `last', an integer or a predicate.
1108 See Info node `(gnus)Customizing Articles' for details."
1109 :group 'gnus-article-treat
1110 :link '(custom-manual "(gnus)Customizing Articles")
1111 :type gnus-article-treat-head-custom)
1112 (put 'gnus-treat-highlight-headers 'highlight t)
1114 (defcustom gnus-treat-highlight-citation t
1115 "Highlight cited text.
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)
1121 (put 'gnus-treat-highlight-citation 'highlight t)
1123 (defcustom gnus-treat-date-ut nil
1124 "Display the Date in UT (GMT).
1125 Valid values are nil, t, `head', `last', an integer or a predicate.
1126 See Info node `(gnus)Customizing Articles' for details."
1127 :group 'gnus-article-treat
1128 :link '(custom-manual "(gnus)Customizing Articles")
1129 :type gnus-article-treat-head-custom)
1131 (defcustom gnus-treat-date-local nil
1132 "Display the Date in the local timezone.
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-head-custom)
1139 (defcustom gnus-treat-date-english nil
1140 "Display the Date in a format that can be read aloud in English.
1141 Valid values are nil, t, `head', `last', an integer or a predicate.
1142 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-lapsed nil
1149 "Display the Date header in a way that says how much time has elapsed.
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-original nil
1157 "Display the date in the original timezone.
1158 Valid values are nil, t, `head', `last', an integer or a predicate.
1159 See Info node `(gnus)Customizing Articles' for details."
1160 :group 'gnus-article-treat
1161 :link '(custom-manual "(gnus)Customizing Articles")
1162 :type gnus-article-treat-head-custom)
1164 (defcustom gnus-treat-date-iso8601 nil
1165 "Display the date in the ISO8601 format.
1166 Valid values are nil, t, `head', `last', an integer or a predicate.
1167 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-user-defined nil
1174 "Display the date in a user-defined format.
1175 The format is defined by the `gnus-article-time-format' variable.
1176 Valid values are nil, t, `head', `last', an integer or a predicate.
1177 See Info node `(gnus)Customizing Articles' for details."
1178 :group 'gnus-article-treat
1179 :link '(custom-manual "(gnus)Customizing Articles")
1180 :type gnus-article-treat-head-custom)
1182 (defcustom gnus-treat-strip-headers-in-body t
1183 "Strip the X-No-Archive header line from the beginning of the body.
1184 Valid values are nil, t, `head', `last', an integer or a predicate.
1185 See Info node `(gnus)Customizing Articles' for details."
1187 :group 'gnus-article-treat
1188 :link '(custom-manual "(gnus)Customizing Articles")
1189 :type gnus-article-treat-custom)
1191 (defcustom gnus-treat-strip-trailing-blank-lines nil
1192 "Strip trailing blank lines.
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-custom)
1199 (defcustom gnus-treat-strip-leading-blank-lines nil
1200 "Strip leading blank lines.
1201 Valid values are nil, t, `head', `last', an integer or a predicate.
1202 See Info node `(gnus)Customizing Articles' for details."
1203 :group 'gnus-article-treat
1204 :link '(custom-manual "(gnus)Customizing Articles")
1205 :type gnus-article-treat-custom)
1207 (defcustom gnus-treat-strip-multiple-blank-lines nil
1208 "Strip multiple blank lines.
1209 Valid values are nil, t, `head', `last', an integer or a predicate.
1210 See Info node `(gnus)Customizing Articles' for details."
1211 :group 'gnus-article-treat
1212 :link '(custom-manual "(gnus)Customizing Articles")
1213 :type gnus-article-treat-custom)
1215 (defcustom gnus-treat-unfold-headers 'head
1216 "Unfold folded header lines.
1217 Valid values are nil, t, `head', `last', an integer or a predicate.
1218 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-fold-headers nil
1226 Valid values are nil, t, `head', `last', an integer or a predicate.
1227 See Info node `(gnus)Customizing Articles' for details."
1229 :group 'gnus-article-treat
1230 :link '(custom-manual "(gnus)Customizing Articles")
1231 :type gnus-article-treat-custom)
1233 (defcustom gnus-treat-fold-newsgroups 'head
1234 "Fold the Newsgroups and Followup-To headers.
1235 Valid values are nil, t, `head', `last', an integer or a predicate.
1236 See Info node `(gnus)Customizing Articles' for details."
1238 :group 'gnus-article-treat
1239 :link '(custom-manual "(gnus)Customizing Articles")
1240 :type gnus-article-treat-custom)
1242 (defcustom gnus-treat-overstrike t
1243 "Treat overstrike highlighting.
1244 Valid values are nil, t, `head', `last', an integer or a predicate.
1245 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)
1249 (put 'gnus-treat-overstrike 'highlight t)
1251 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1252 "Treat ANSI SGR control sequences.
1253 Valid values are nil, t, `head', `last', an integer or a predicate.
1254 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 (make-obsolete-variable 'gnus-treat-display-xface
1260 'gnus-treat-display-x-face)
1262 (defcustom gnus-treat-display-x-face
1263 (and (not noninteractive)
1264 (or (and (fboundp 'image-type-available-p)
1265 (image-type-available-p 'xbm)
1266 (string-match "^0x" (shell-command-to-string "uncompface"))
1267 (executable-find "icontopbm"))
1268 (and (featurep 'xemacs)
1271 "Display X-Face headers.
1272 Valid values are nil, t, `head', `last', an integer or a predicate.
1273 See Info node `(gnus)Customizing Articles' and Info node
1274 `(gnus)X-Face' for details."
1275 :group 'gnus-article-treat
1277 :link '(custom-manual "(gnus)Customizing Articles")
1278 :link '(custom-manual "(gnus)X-Face")
1279 :type gnus-article-treat-head-custom
1280 :set (lambda (symbol value)
1283 (cond ((or (boundp symbol) (get symbol 'saved-value))
1285 ((boundp 'gnus-treat-display-xface)
1287 ** gnus-treat-display-xface is an obsolete variable;\
1288 use gnus-treat-display-x-face instead")
1289 (default-value 'gnus-treat-display-xface))
1290 ((get 'gnus-treat-display-xface 'saved-value)
1292 ** gnus-treat-display-xface is an obsolete variable;\
1293 use gnus-treat-display-x-face instead")
1294 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1297 (put 'gnus-treat-display-x-face 'highlight t)
1299 (defcustom gnus-treat-display-face
1300 (and (not noninteractive)
1301 (or (and (fboundp 'image-type-available-p)
1302 (image-type-available-p 'png))
1303 (and (featurep 'xemacs)
1306 "Display Face headers.
1307 Valid values are nil, t, `head', `last', an integer or a predicate.
1308 See Info node `(gnus)Customizing Articles' and Info node
1309 `(gnus)X-Face' for details."
1310 :group 'gnus-article-treat
1312 :link '(custom-manual "(gnus)Customizing Articles")
1313 :link '(custom-manual "(gnus)X-Face")
1314 :type gnus-article-treat-head-custom)
1315 (put 'gnus-treat-display-face 'highlight t)
1317 (defcustom gnus-treat-display-smileys
1318 (if (or (and (featurep 'xemacs)
1320 (and (fboundp 'image-type-available-p)
1321 (image-type-available-p 'pbm)))
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)Smileys' for details."
1327 :group 'gnus-article-treat
1329 :link '(custom-manual "(gnus)Customizing Articles")
1330 :link '(custom-manual "(gnus)Smileys")
1331 :type gnus-article-treat-custom)
1332 (put 'gnus-treat-display-smileys 'highlight t)
1334 (defcustom gnus-treat-from-picon
1335 (if (and (gnus-image-type-available-p 'xpm)
1336 (gnus-picons-installed-p))
1338 "Display picons in the From header.
1339 Valid values are nil, t, `head', `last', an integer or a predicate.
1340 See Info node `(gnus)Customizing Articles' and Info node
1341 `(gnus)Picons' for details."
1343 :group 'gnus-article-treat
1345 :link '(custom-manual "(gnus)Customizing Articles")
1346 :link '(custom-manual "(gnus)Picons")
1347 :type gnus-article-treat-head-custom)
1348 (put 'gnus-treat-from-picon 'highlight t)
1350 (defcustom gnus-treat-mail-picon
1351 (if (and (gnus-image-type-available-p 'xpm)
1352 (gnus-picons-installed-p))
1354 "Display picons in To and Cc headers.
1355 Valid values are nil, t, `head', `last', an integer or a predicate.
1356 See Info node `(gnus)Customizing Articles' and Info node
1357 `(gnus)Picons' for details."
1359 :group 'gnus-article-treat
1361 :link '(custom-manual "(gnus)Customizing Articles")
1362 :link '(custom-manual "(gnus)Picons")
1363 :type gnus-article-treat-head-custom)
1364 (put 'gnus-treat-mail-picon 'highlight t)
1366 (defcustom gnus-treat-newsgroups-picon
1367 (if (and (gnus-image-type-available-p 'xpm)
1368 (gnus-picons-installed-p))
1370 "Display picons in the Newsgroups and Followup-To headers.
1371 Valid values are nil, t, `head', `last', an integer or a predicate.
1372 See Info node `(gnus)Customizing Articles' and Info node
1373 `(gnus)Picons' for details."
1375 :group 'gnus-article-treat
1377 :link '(custom-manual "(gnus)Customizing Articles")
1378 :link '(custom-manual "(gnus)Picons")
1379 :type gnus-article-treat-head-custom)
1380 (put 'gnus-treat-newsgroups-picon 'highlight t)
1382 (defcustom gnus-treat-body-boundary
1383 (if (and (eq window-system 'x)
1384 (or gnus-treat-newsgroups-picon
1385 gnus-treat-mail-picon
1386 gnus-treat-from-picon))
1388 "Draw a boundary at the end of the headers.
1389 Valid values are nil and `head'.
1390 See Info node `(gnus)Customizing Articles' for details."
1392 :group 'gnus-article-treat
1393 :link '(custom-manual "(gnus)Customizing Articles")
1394 :type gnus-article-treat-head-custom)
1396 (defcustom gnus-treat-capitalize-sentences nil
1397 "Capitalize sentence-starting words.
1398 Valid values are nil, t, `head', `last', an integer or a predicate.
1399 See Info node `(gnus)Customizing Articles' for details."
1401 :group 'gnus-article-treat
1402 :link '(custom-manual "(gnus)Customizing Articles")
1403 :type gnus-article-treat-custom)
1405 (defcustom gnus-treat-wash-html nil
1407 Valid values are nil, t, `head', `last', an integer or a predicate.
1408 See Info node `(gnus)Customizing Articles' for details."
1410 :group 'gnus-article-treat
1411 :link '(custom-manual "(gnus)Customizing Articles")
1412 :type gnus-article-treat-custom)
1414 (defcustom gnus-treat-fill-long-lines nil
1416 Valid values are nil, t, `head', `last', an integer or a predicate.
1417 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-play-sounds 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-translate nil
1432 "Translate articles from one language to another.
1433 Valid values are nil, t, `head', `last', an integer or a predicate.
1434 See Info node `(gnus)Customizing Articles' for details."
1436 :group 'gnus-article-treat
1437 :link '(custom-manual "(gnus)Customizing Articles")
1438 :type gnus-article-treat-custom)
1440 (defcustom gnus-treat-x-pgp-sig nil
1442 To automatically treat X-PGP-Sig, set it to head.
1443 Valid values are nil, t, `head', `last', an integer or a predicate.
1444 See Info node `(gnus)Customizing Articles' for details."
1446 :group 'gnus-article-treat
1447 :group 'mime-security
1448 :link '(custom-manual "(gnus)Customizing Articles")
1449 :type gnus-article-treat-custom)
1451 (defvar gnus-article-encrypt-protocol-alist
1452 '(("PGP" . mml2015-self-encrypt)))
1454 ;; Set to nil if more than one protocol added to
1455 ;; gnus-article-encrypt-protocol-alist.
1456 (defcustom gnus-article-encrypt-protocol "PGP"
1457 "The protocol used for encrypt articles.
1458 It is a string, such as \"PGP\". If nil, ask user."
1461 :group 'mime-security)
1463 (defvar gnus-article-wash-function nil
1464 "Function used for converting HTML into text.")
1466 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1467 (mm-coding-system-p 'utf-8)
1468 (executable-find idna-program))
1469 "Whether IDNA decoding of headers is used when viewing messages.
1470 This requires GNU Libidn, and by default only enabled if it is found."
1472 :group 'gnus-article-headers
1475 (defcustom gnus-article-over-scroll nil
1476 "If non-nil, allow scrolling the article buffer even when there no more text."
1478 :group 'gnus-article
1481 ;;; Internal variables
1483 (defvar gnus-english-month-names
1484 '("January" "February" "March" "April" "May" "June" "July" "August"
1485 "September" "October" "November" "December"))
1487 (defvar gnus-button-regexp nil)
1488 (defvar gnus-button-marker-list nil)
1489 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1491 (defvar gnus-button-last nil)
1492 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1494 (defvar article-goto-body-goes-to-point-min-p nil)
1495 (defvar gnus-article-wash-types nil)
1496 (defvar gnus-article-emphasis-alist nil)
1497 (defvar gnus-article-image-alist nil)
1499 (defvar gnus-article-mime-handle-alist-1 nil)
1500 (defvar gnus-treatment-function-alist
1501 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1502 (gnus-treat-strip-banner gnus-article-strip-banner)
1503 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1504 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1505 (gnus-treat-buttonize gnus-article-add-buttons)
1506 (gnus-treat-fill-article gnus-article-fill-cited-article)
1507 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1508 (gnus-treat-strip-cr gnus-article-remove-cr)
1509 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1510 (gnus-treat-date-ut gnus-article-date-ut)
1511 (gnus-treat-date-local gnus-article-date-local)
1512 (gnus-treat-date-english gnus-article-date-english)
1513 (gnus-treat-date-original gnus-article-date-original)
1514 (gnus-treat-date-user-defined gnus-article-date-user)
1515 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1516 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1517 (gnus-treat-display-x-face gnus-article-display-x-face)
1518 (gnus-treat-display-face gnus-article-display-face)
1519 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1520 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1521 (gnus-treat-hide-signature gnus-article-hide-signature)
1522 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1523 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1524 (gnus-treat-strip-pem gnus-article-hide-pem)
1525 (gnus-treat-from-picon gnus-treat-from-picon)
1526 (gnus-treat-mail-picon gnus-treat-mail-picon)
1527 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1528 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1529 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1530 (gnus-treat-strip-trailing-blank-lines
1531 gnus-article-remove-trailing-blank-lines)
1532 (gnus-treat-strip-leading-blank-lines
1533 gnus-article-strip-leading-blank-lines)
1534 (gnus-treat-strip-multiple-blank-lines
1535 gnus-article-strip-multiple-blank-lines)
1536 (gnus-treat-overstrike gnus-article-treat-overstrike)
1537 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1538 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1539 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1540 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1541 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1542 (gnus-treat-display-smileys gnus-treat-smiley)
1543 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1544 (gnus-treat-wash-html gnus-article-wash-html)
1545 (gnus-treat-emphasize gnus-article-emphasize)
1546 (gnus-treat-hide-citation gnus-article-hide-citation)
1547 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1548 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1549 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1550 (gnus-treat-play-sounds gnus-earcon-display)))
1552 (defvar gnus-article-mime-handle-alist nil)
1553 (defvar article-lapsed-timer nil)
1554 (defvar gnus-article-current-summary nil)
1556 (defvar gnus-article-mode-syntax-table
1557 (let ((table (copy-syntax-table text-mode-syntax-table)))
1558 ;; This causes the citation match run O(2^n).
1559 ;; (modify-syntax-entry ?- "w" table)
1560 (modify-syntax-entry ?> ")<" table)
1561 (modify-syntax-entry ?< "(>" table)
1562 ;; make M-. in article buffers work for `foo' strings
1563 (modify-syntax-entry ?' " " table)
1564 (modify-syntax-entry ?` " " table)
1566 "Syntax table used in article mode buffers.
1567 Initialized from `text-mode-syntax-table.")
1569 (defvar gnus-save-article-buffer nil)
1571 (defvar gnus-article-mode-line-format-alist
1572 (nconc '((?w (gnus-article-wash-status) ?s)
1573 (?m (gnus-article-mime-part-status) ?s))
1574 gnus-summary-mode-line-format-alist))
1576 (defvar gnus-number-of-articles-to-be-saved nil)
1578 (defvar gnus-inhibit-hiding nil)
1580 (defvar gnus-article-edit-mode nil)
1582 ;;; Macros for dealing with the article buffer.
1584 (defmacro gnus-with-article-headers (&rest forms)
1586 (set-buffer gnus-article-buffer)
1588 (let ((inhibit-read-only t)
1589 (inhibit-point-motion-hooks t)
1590 (case-fold-search t))
1591 (article-narrow-to-head)
1594 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1595 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1597 (defmacro gnus-with-article-buffer (&rest forms)
1599 (set-buffer gnus-article-buffer)
1600 (let ((inhibit-read-only t))
1603 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1604 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1606 (defun gnus-article-goto-header (header)
1607 "Go to HEADER, which is a regular expression."
1608 (re-search-forward (concat "^\\(" header "\\):") nil t))
1610 (defsubst gnus-article-hide-text (b e props)
1611 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1612 (gnus-add-text-properties-when 'article-type nil b e props)
1613 (when (memq 'intangible props)
1615 (max (1- b) (point-min))
1616 b 'intangible (cddr (memq 'intangible props)))))
1618 (defsubst gnus-article-unhide-text (b e)
1619 "Remove hidden text properties from region between B and E."
1620 (remove-text-properties b e gnus-hidden-properties)
1621 (when (memq 'intangible gnus-hidden-properties)
1622 (put-text-property (max (1- b) (point-min))
1623 b 'intangible nil)))
1625 (defun gnus-article-hide-text-type (b e type)
1626 "Hide text of TYPE between B and E."
1627 (gnus-add-wash-type type)
1628 (gnus-article-hide-text
1629 b e (cons 'article-type (cons type gnus-hidden-properties))))
1631 (defun gnus-article-unhide-text-type (b e type)
1632 "Unhide text of TYPE between B and E."
1633 (gnus-delete-wash-type type)
1634 (remove-text-properties
1635 b e (cons 'article-type (cons type gnus-hidden-properties)))
1636 (when (memq 'intangible gnus-hidden-properties)
1637 (put-text-property (max (1- b) (point-min))
1638 b 'intangible nil)))
1640 (defun gnus-article-hide-text-of-type (type)
1641 "Hide text of TYPE in the current buffer."
1643 (let ((b (point-min))
1645 (while (setq b (text-property-any b e 'article-type type))
1646 (add-text-properties b (incf b) gnus-hidden-properties)))))
1648 (defun gnus-article-delete-text-of-type (type)
1649 "Delete text of TYPE in the current buffer."
1651 (let ((b (point-min)))
1652 (while (setq b (text-property-any b (point-max) 'article-type type))
1654 b (or (text-property-not-all b (point-max) 'article-type type)
1657 (defun gnus-article-delete-invisible-text ()
1658 "Delete all invisible text in the current buffer."
1660 (let ((b (point-min)))
1661 (while (setq b (text-property-any b (point-max) 'invisible t))
1663 b (or (text-property-not-all b (point-max) 'invisible t)
1666 (defun gnus-article-text-type-exists-p (type)
1667 "Say whether any text of type TYPE exists in the buffer."
1668 (text-property-any (point-min) (point-max) 'article-type type))
1670 (defsubst gnus-article-header-rank ()
1671 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1672 (let ((list gnus-sorted-header-list)
1675 (if (looking-at (car list))
1677 (setq list (cdr list))
1681 (defun article-hide-headers (&optional arg delete)
1682 "Hide unwanted headers and possibly sort them as well."
1684 ;; This function might be inhibited.
1685 (unless gnus-inhibit-hiding
1686 (let ((inhibit-read-only nil)
1687 (case-fold-search t)
1688 (max (1+ (length gnus-sorted-header-list)))
1689 (inhibit-point-motion-hooks t)
1690 (cur (current-buffer))
1691 ignored visible beg)
1693 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1694 ;; group parameters, so we should go to the summary buffer.
1697 (progn (set-buffer gnus-summary-buffer) t)
1699 (setq ignored (when (not gnus-visible-headers)
1700 (cond ((stringp gnus-ignored-headers)
1701 gnus-ignored-headers)
1702 ((listp gnus-ignored-headers)
1703 (mapconcat 'identity
1704 gnus-ignored-headers
1706 visible (cond ((stringp gnus-visible-headers)
1707 gnus-visible-headers)
1708 ((and gnus-visible-headers
1709 (listp gnus-visible-headers))
1710 (mapconcat 'identity
1711 gnus-visible-headers
1715 ;; First we narrow to just the headers.
1716 (article-narrow-to-head)
1717 ;; Hide any "From " lines at the beginning of (mail) articles.
1718 (while (looking-at "From ")
1721 (delete-region (point-min) (point)))
1722 ;; Then treat the rest of the header lines.
1723 ;; Then we use the two regular expressions
1724 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1725 ;; select which header lines is to remain visible in the
1727 (while (re-search-forward "^[^ \t:]*:" nil t)
1729 ;; Mark the rank of the header.
1731 (point) (1+ (point)) 'message-rank
1732 (if (or (and visible (looking-at visible))
1734 (not (looking-at ignored))))
1735 (gnus-article-header-rank)
1738 (message-sort-headers-1)
1739 (when (setq beg (text-property-any
1740 (point-min) (point-max) 'message-rank (+ 2 max)))
1741 ;; We delete the unwanted headers.
1742 (gnus-add-wash-type 'headers)
1743 (add-text-properties (point-min) (+ 5 (point-min))
1744 '(article-type headers dummy-invisible t))
1745 (delete-region beg (point-max))))))))
1747 (defun article-hide-boring-headers (&optional arg)
1748 "Toggle hiding of headers that aren't very interesting.
1749 If given a negative prefix, always show; if given a positive prefix,
1751 (interactive (gnus-article-hidden-arg))
1752 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1753 (not gnus-show-all-headers))
1756 (let ((inhibit-read-only t)
1757 (inhibit-point-motion-hooks t))
1758 (article-narrow-to-head)
1759 (dolist (elem gnus-boring-article-headers)
1760 (goto-char (point-min))
1762 ;; Hide empty headers.
1764 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1766 (gnus-article-hide-text-type
1770 (if (re-search-forward "^[^ \t]" nil t)
1774 ;; Hide boring Newsgroups header.
1775 ((eq elem 'newsgroups)
1776 (when (gnus-string-equal
1777 (gnus-fetch-field "newsgroups")
1778 (gnus-group-real-name
1779 (if (boundp 'gnus-newsgroup-name)
1782 (gnus-article-hide-header "newsgroups")))
1783 ((eq elem 'to-address)
1784 (let ((to (message-fetch-field "to"))
1786 (gnus-parameter-to-address
1787 (if (boundp 'gnus-newsgroup-name)
1788 gnus-newsgroup-name ""))))
1789 (when (and to to-address
1792 ;; only one address in To
1793 (nth 1 (mail-extract-address-components to))
1795 (gnus-article-hide-header "to"))))
1797 (let ((to (message-fetch-field "to"))
1799 (gnus-parameter-to-list
1800 (if (boundp 'gnus-newsgroup-name)
1801 gnus-newsgroup-name ""))))
1802 (when (and to to-list
1805 ;; only one address in To
1806 (nth 1 (mail-extract-address-components to))
1808 (gnus-article-hide-header "to"))))
1810 (let ((cc (message-fetch-field "cc"))
1812 (gnus-parameter-to-list
1813 (if (boundp 'gnus-newsgroup-name)
1814 gnus-newsgroup-name ""))))
1815 (when (and cc to-list
1818 ;; only one address in CC
1819 (nth 1 (mail-extract-address-components cc))
1821 (gnus-article-hide-header "cc"))))
1822 ((eq elem 'followup-to)
1823 (when (gnus-string-equal
1824 (message-fetch-field "followup-to")
1825 (message-fetch-field "newsgroups"))
1826 (gnus-article-hide-header "followup-to")))
1827 ((eq elem 'reply-to)
1828 (if (gnus-group-find-parameter
1829 gnus-newsgroup-name 'broken-reply-to)
1830 (gnus-article-hide-header "reply-to")
1831 (let ((from (message-fetch-field "from"))
1832 (reply-to (message-fetch-field "reply-to")))
1839 (lambda (x) (downcase (cadr x)))
1840 (mail-extract-address-components from t))
1843 (lambda (x) (downcase (cadr x)))
1844 (mail-extract-address-components reply-to t))
1846 (gnus-article-hide-header "reply-to")))))
1848 (let ((date (message-fetch-field "date")))
1850 (< (days-between (current-time-string) date)
1852 (gnus-article-hide-header "date"))))
1854 (let ((to (message-fetch-field "to"))
1855 (cc (message-fetch-field "cc")))
1856 (when (> (length to) 1024)
1857 (gnus-article-hide-header "to"))
1858 (when (> (length cc) 1024)
1859 (gnus-article-hide-header "cc"))))
1863 (goto-char (point-min))
1864 (while (re-search-forward "^to:" nil t)
1865 (setq to-count (1+ to-count)))
1866 (when (> to-count 1)
1867 (while (> to-count 0)
1868 (goto-char (point-min))
1870 (re-search-forward "^to:" nil nil to-count)
1872 (narrow-to-region (point) (point-max))
1873 (gnus-article-hide-header "to"))
1874 (setq to-count (1- to-count))))
1875 (goto-char (point-min))
1876 (while (re-search-forward "^cc:" nil t)
1877 (setq cc-count (1+ cc-count)))
1878 (when (> cc-count 1)
1879 (while (> cc-count 0)
1880 (goto-char (point-min))
1882 (re-search-forward "^cc:" nil nil cc-count)
1884 (narrow-to-region (point) (point-max))
1885 (gnus-article-hide-header "cc"))
1886 (setq cc-count (1- cc-count)))))))))))))
1888 (defun gnus-article-hide-header (header)
1890 (goto-char (point-min))
1891 (when (re-search-forward (concat "^" header ":") nil t)
1892 (gnus-article-hide-text-type
1896 (if (re-search-forward "^[^ \t]" nil t)
1901 (defvar gnus-article-normalized-header-length 40
1902 "Length of normalized headers.")
1904 (defun article-normalize-headers ()
1905 "Make all header lines 40 characters long."
1907 (let ((inhibit-read-only t)
1911 (article-narrow-to-head)
1914 ((< (setq column (- (point-at-eol) (point)))
1915 gnus-article-normalized-header-length)
1917 (insert (make-string
1918 (- gnus-article-normalized-header-length column)
1920 ((> column gnus-article-normalized-header-length)
1921 (gnus-put-text-property
1923 (forward-char gnus-article-normalized-header-length)
1930 (forward-line 1))))))
1932 (defun article-treat-dumbquotes ()
1933 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1934 Note that this function guesses whether a character is a sm*rtq**t* or
1935 not, so it should only be used interactively.
1937 Sm*rtq**t*s are M****s***'s unilateral extension to the
1938 iso-8859-1 character map in an attempt to provide more quoting
1939 characters. If you see something like \\222 or \\264 where
1940 you're expecting some kind of apostrophe or quotation mark, then
1943 (article-translate-strings gnus-article-dumbquotes-map))
1945 (defun article-translate-characters (from to)
1946 "Translate all characters in the body of the article according to FROM and TO.
1947 FROM is a string of characters to translate from; to is a string of
1948 characters to translate to."
1950 (when (article-goto-body)
1951 (let ((inhibit-read-only t)
1952 (x (make-string 225 ?x))
1954 (while (< (incf i) (length x))
1957 (while (< i (length from))
1958 (aset x (aref from i) (aref to i))
1960 (translate-region (point) (point-max) x)))))
1962 (defun article-translate-strings (map)
1963 "Translate all string in the body of the article according to MAP.
1964 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1966 (when (article-goto-body)
1967 (let ((inhibit-read-only t))
1970 (while (search-forward (car elem) nil t)
1971 (replace-match (cadr elem)))))))))
1973 (defun article-treat-overstrike ()
1974 "Translate overstrikes into bold text."
1977 (when (article-goto-body)
1978 (let ((inhibit-read-only t))
1979 (while (search-forward "\b" nil t)
1980 (let ((next (char-after))
1981 (previous (char-after (- (point) 2))))
1982 ;; We do the boldification/underlining by hiding the
1983 ;; overstrikes and putting the proper text property
1987 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1988 (put-text-property (point) (1+ (point)) 'face 'bold))
1990 (gnus-article-hide-text-type
1991 (1- (point)) (1+ (point)) 'overstrike)
1993 (- (point) 2) (1- (point)) 'face 'underline))
1995 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1997 (point) (1+ (point)) 'face 'underline)))))))))
1999 (defun article-treat-ansi-sequences ()
2000 "Translate ANSI SGR control sequences into overlays or extents."
2003 (when (article-goto-body)
2004 (let ((inhibit-read-only t))
2005 (ansi-color-apply-on-region (point) (point-max))))))
2007 (defun gnus-article-treat-unfold-headers ()
2008 "Unfold folded message headers.
2009 Only the headers that fit into the current window width will be
2012 (gnus-with-article-headers
2016 (mail-header-narrow-to-field)
2017 (let ((header (buffer-string)))
2020 (goto-char (point-min))
2021 (while (re-search-forward "\n[\t ]" nil t)
2022 (replace-match " " t t)))
2023 (setq length (- (point-max) (point-min) 1)))
2024 (when (< length (window-width))
2025 (while (re-search-forward "\n[\t ]" nil t)
2026 (replace-match " " t t)))
2027 (goto-char (point-max)))))))
2029 (defun gnus-article-treat-fold-headers ()
2030 "Fold message headers."
2032 (gnus-with-article-headers
2035 (mail-header-narrow-to-field)
2036 (mail-header-fold-field)
2037 (goto-char (point-max))))))
2039 (defun gnus-treat-smiley ()
2040 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2042 (gnus-with-article-buffer
2043 (if (memq 'smiley gnus-article-wash-types)
2044 (gnus-delete-images 'smiley)
2046 (let ((images (smiley-region (point) (point-max))))
2048 (gnus-add-wash-type 'smiley)
2049 (dolist (image images)
2050 (gnus-add-image 'smiley image)))))))
2052 (defun gnus-article-remove-images ()
2053 "Remove all images from the article buffer."
2055 (gnus-with-article-buffer
2056 (dolist (elem gnus-article-image-alist)
2057 (gnus-delete-images (car elem)))))
2059 (defun gnus-article-treat-fold-newsgroups ()
2060 "Unfold folded message headers.
2061 Only the headers that fit into the current window width will be
2064 (gnus-with-article-headers
2065 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2067 (mail-header-narrow-to-field)
2068 (while (re-search-forward ", *" nil t)
2069 (replace-match ", " t t))
2070 (mail-header-fold-field)
2071 (goto-char (point-max))))))
2073 (defun gnus-article-treat-body-boundary ()
2074 "Place a boundary line at the end of the headers."
2076 (when (and gnus-body-boundary-delimiter
2077 (> (length gnus-body-boundary-delimiter) 0))
2078 (gnus-with-article-headers
2079 (goto-char (point-max))
2080 (let ((start (point)))
2081 (insert "X-Boundary: ")
2082 (gnus-add-text-properties start (point) '(invisible t intangible t))
2084 (while (>= (1- (window-width)) (length str))
2085 (setq str (concat str gnus-body-boundary-delimiter)))
2086 (substring str 0 (1- (window-width))))
2088 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2090 (defun article-fill-long-lines ()
2091 "Fill lines that are wider than the window width."
2094 (let ((inhibit-read-only t)
2095 (width (window-width (get-buffer-window (current-buffer)))))
2098 (let ((adaptive-fill-mode nil)) ;Why? -sm
2101 (when (>= (current-column) (min fill-column width))
2102 (narrow-to-region (min (1+ (point)) (point-max))
2104 (let ((goback (point-marker)))
2105 (fill-paragraph nil)
2106 (goto-char (marker-position goback)))
2108 (forward-line 1)))))))
2110 (defun article-capitalize-sentences ()
2111 "Capitalize the first word in each sentence."
2114 (let ((inhibit-read-only t)
2115 (paragraph-start "^[\n\^L]"))
2119 (forward-sentence)))))
2121 (defun article-remove-cr ()
2122 "Remove trailing CRs and then translate remaining CRs into LFs."
2125 (let ((inhibit-read-only t))
2126 (goto-char (point-min))
2127 (while (re-search-forward "\r+$" nil t)
2128 (replace-match "" t t))
2129 (goto-char (point-min))
2130 (while (search-forward "\r" nil t)
2131 (replace-match "\n" t t)))))
2133 (defun article-remove-trailing-blank-lines ()
2134 "Remove all trailing blank lines from the article."
2137 (let ((inhibit-read-only t))
2138 (goto-char (point-max))
2142 (while (and (not (bobp))
2143 (looking-at "^[ \t]*$")
2144 (not (gnus-annotation-in-region-p
2145 (point) (point-at-eol))))
2151 (defvar gnus-face-properties-alist))
2153 (defun article-display-face ()
2154 "Display any Face headers in the header."
2156 (let ((wash-face-p buffer-read-only))
2157 (gnus-with-article-headers
2158 ;; When displaying parts, this function can be called several times on
2159 ;; the same article, without any intended toggle semantic (as typing `W
2160 ;; D d' would have). So face deletion must occur only when we come from
2161 ;; an interactive command, that is when the *Article* buffer is
2163 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2164 (gnus-delete-images 'face)
2165 (let (face faces from)
2166 (save-current-buffer
2167 (when (and wash-face-p
2168 (gnus-buffer-live-p gnus-original-article-buffer)
2169 (not (re-search-forward "^Face:[\t ]*" nil t)))
2170 (set-buffer gnus-original-article-buffer))
2172 (mail-narrow-to-head)
2173 (while (gnus-article-goto-header "Face")
2174 (push (mail-header-field-value) faces))))
2176 (goto-char (point-min))
2177 (let ((from (gnus-article-goto-header "from"))
2182 (insert "[no `from' set]\n"))
2184 (when (setq png (gnus-convert-face-to-png (pop faces)))
2186 (apply 'gnus-create-image png 'png t
2187 (cdr (assq 'png gnus-face-properties-alist))))
2189 (gnus-add-wash-type 'face)
2190 (gnus-add-image 'face image)
2191 (gnus-put-image image nil 'face))))))))))
2193 (defun article-display-x-face (&optional force)
2194 "Look for an X-Face header and display it if present."
2195 (interactive (list 'force))
2196 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2197 (gnus-with-article-headers
2198 ;; Delete the old process, if any.
2199 (when (process-status "article-x-face")
2200 (delete-process "article-x-face"))
2201 ;; See the comment in `article-display-face'.
2202 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2203 ;; We have already displayed X-Faces, so we remove them
2205 (gnus-delete-images 'xface)
2207 (let (x-faces from face)
2208 (save-current-buffer
2209 (when (and wash-face-p
2210 (gnus-buffer-live-p gnus-original-article-buffer)
2211 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2212 ;; If type `W f', use gnus-original-article-buffer,
2213 ;; otherwise use the current buffer because displaying
2214 ;; RFC822 parts calls this function too.
2215 (set-buffer gnus-original-article-buffer))
2217 (mail-narrow-to-head)
2218 (while (gnus-article-goto-header "X-Face")
2219 (push (mail-header-field-value) x-faces))
2220 (setq from (message-fetch-field "from"))))
2221 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2222 ;; single external face.
2223 (when (stringp gnus-article-x-face-command)
2224 (setq x-faces (list (car x-faces))))
2226 gnus-article-x-face-command
2228 ;; Check whether this face is censored.
2229 (not gnus-article-x-face-too-ugly)
2231 (not (string-match gnus-article-x-face-too-ugly
2233 (while (setq face (pop x-faces))
2234 ;; We display the face.
2235 (cond ((stringp gnus-article-x-face-command)
2236 ;; The command is a string, so we interpret the command
2237 ;; as a, well, command, and fork it off.
2238 (let ((process-connection-type nil))
2239 (gnus-set-process-query-on-exit-flag
2241 "article-x-face" nil shell-file-name
2242 shell-command-switch gnus-article-x-face-command)
2246 (process-send-region "article-x-face"
2247 (point-min) (point-max)))
2248 (process-send-eof "article-x-face")))
2249 ((functionp gnus-article-x-face-command)
2250 ;; The command is a lisp function, so we call it.
2251 (funcall gnus-article-x-face-command face))
2253 (error "%s is not a function"
2254 gnus-article-x-face-command))))))))))
2256 (defun article-decode-mime-words ()
2257 "Decode all MIME-encoded words in the article."
2259 (gnus-with-article-buffer
2260 (let ((inhibit-point-motion-hooks t)
2261 (mail-parse-charset gnus-newsgroup-charset)
2262 (mail-parse-ignored-charsets
2263 (with-current-buffer gnus-summary-buffer
2264 gnus-newsgroup-ignored-charsets)))
2265 (mail-decode-encoded-word-region (point-min) (point-max)))))
2267 (defun article-decode-charset (&optional prompt)
2268 "Decode charset-encoded text in the article.
2269 If PROMPT (the prefix), prompt for a coding system to use."
2271 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2272 (inhibit-read-only t)
2273 (mail-parse-charset gnus-newsgroup-charset)
2274 (mail-parse-ignored-charsets
2275 (save-excursion (condition-case nil
2276 (set-buffer gnus-summary-buffer)
2278 gnus-newsgroup-ignored-charsets))
2279 ct cte ctl charset format)
2282 (article-narrow-to-head)
2283 (setq ct (message-fetch-field "Content-Type" t)
2284 cte (message-fetch-field "Content-Transfer-Encoding" t)
2285 ctl (and ct (ignore-errors
2286 (mail-header-parse-content-type ct)))
2289 (mm-read-coding-system "Charset to decode: "))
2291 (mail-content-type-get ctl 'charset)))
2292 format (and ctl (mail-content-type-get ctl 'format)))
2294 (setq cte (mail-header-strip cte)))
2295 (if (and ctl (not (string-match "/" (car ctl))))
2297 (goto-char (point-max)))
2300 (narrow-to-region (point) (point-max))
2301 (when (and (eq mail-parse-charset 'gnus-decoded)
2302 (eq (mm-body-7-or-8) '8bit))
2303 ;; The text code could have been decoded.
2304 (setq charset mail-parse-charset))
2305 (when (and (or (not ctl)
2306 (equal (car ctl) "text/plain"))
2307 (not format)) ;; article with format will decode later.
2309 charset (and cte (intern (downcase
2310 (gnus-strip-whitespace cte))))
2313 (defun article-decode-encoded-words ()
2314 "Remove encoded-word encoding from headers."
2315 (let ((inhibit-point-motion-hooks t)
2316 (mail-parse-charset gnus-newsgroup-charset)
2317 (mail-parse-ignored-charsets
2318 (save-excursion (condition-case nil
2319 (set-buffer gnus-summary-buffer)
2321 gnus-newsgroup-ignored-charsets))
2322 (inhibit-read-only t))
2324 (article-narrow-to-head)
2325 (funcall gnus-decode-header-function (point-min) (point-max)))))
2327 (defun article-decode-group-name ()
2328 "Decode group names in `Newsgroups:'."
2329 (let ((inhibit-point-motion-hooks t)
2330 (inhibit-read-only t)
2331 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2332 (when (and (or gnus-group-name-charset-method-alist
2333 gnus-group-name-charset-group-alist)
2334 (gnus-buffer-live-p gnus-original-article-buffer))
2336 (article-narrow-to-head)
2337 (with-current-buffer gnus-original-article-buffer
2338 (goto-char (point-min)))
2339 (while (re-search-forward
2340 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2341 (replace-match (save-match-data
2342 (gnus-decode-newsgroups
2343 ;; XXX how to use data in article buffer?
2344 (with-current-buffer gnus-original-article-buffer
2346 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2349 gnus-newsgroup-name method))
2351 (goto-char (point-min))
2352 (with-current-buffer gnus-original-article-buffer
2353 (goto-char (point-min)))
2354 (while (re-search-forward
2355 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2356 (replace-match (save-match-data
2357 (gnus-decode-newsgroups
2358 ;; XXX how to use data in article buffer?
2359 (with-current-buffer gnus-original-article-buffer
2361 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2364 gnus-newsgroup-name method))
2367 (autoload 'idna-to-unicode "idna")
2369 (defun article-decode-idna-rhs ()
2370 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2373 (let ((inhibit-point-motion-hooks t)
2374 (inhibit-read-only t))
2375 (article-narrow-to-head)
2376 (goto-char (point-min))
2377 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2379 (when (save-match-data
2380 (and (setq ace (match-string 1))
2382 (and (re-search-backward "^[^ \t]" nil t)
2383 (looking-at "From\\|To\\|Cc")))
2384 (setq unicode (idna-to-unicode ace))))
2385 (unless (string= ace unicode)
2386 (replace-match unicode nil nil nil 1)))))))))
2388 (defun article-de-quoted-unreadable (&optional force read-charset)
2389 "Translate a quoted-printable-encoded article.
2390 If FORCE, decode the article whether it is marked as quoted-printable
2392 If READ-CHARSET, ask for a coding system."
2393 (interactive (list 'force current-prefix-arg))
2395 (let ((inhibit-read-only t) type charset)
2396 (if (gnus-buffer-live-p gnus-original-article-buffer)
2397 (with-current-buffer gnus-original-article-buffer
2399 (gnus-fetch-field "content-transfer-encoding"))
2400 (let* ((ct (gnus-fetch-field "content-type"))
2403 (mail-header-parse-content-type ct)))))
2404 (setq charset (and ctl
2405 (mail-content-type-get ctl 'charset)))
2406 (if (stringp charset)
2407 (setq charset (intern (downcase charset)))))))
2409 (setq charset (mm-read-coding-system "Charset: " charset)))
2411 (setq charset gnus-newsgroup-charset))
2413 (and type (let ((case-fold-search t))
2414 (string-match "quoted-printable" type))))
2416 (quoted-printable-decode-region
2417 (point) (point-max) (mm-charset-to-coding-system charset))))))
2419 (defun article-de-base64-unreadable (&optional force read-charset)
2420 "Translate a base64 article.
2421 If FORCE, decode the article whether it is marked as base64 not.
2422 If READ-CHARSET, ask for a coding system."
2423 (interactive (list 'force current-prefix-arg))
2425 (let ((inhibit-read-only t) type charset)
2426 (if (gnus-buffer-live-p gnus-original-article-buffer)
2427 (with-current-buffer gnus-original-article-buffer
2429 (gnus-fetch-field "content-transfer-encoding"))
2430 (let* ((ct (gnus-fetch-field "content-type"))
2433 (mail-header-parse-content-type ct)))))
2434 (setq charset (and ctl
2435 (mail-content-type-get ctl 'charset)))
2436 (if (stringp charset)
2437 (setq charset (intern (downcase charset)))))))
2439 (setq charset (mm-read-coding-system "Charset: " charset)))
2441 (setq charset gnus-newsgroup-charset))
2443 (and type (let ((case-fold-search t))
2444 (string-match "base64" type))))
2447 (narrow-to-region (point) (point-max))
2448 (base64-decode-region (point-min) (point-max))
2449 (mm-decode-coding-region
2450 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2455 (defun article-decode-HZ ()
2456 "Translate a HZ-encoded article."
2460 (let ((inhibit-read-only t))
2461 (rfc1843-decode-region (point-min) (point-max)))))
2463 (defun article-unsplit-urls ()
2464 "Remove the newlines that some other mailers insert into URLs."
2467 (let ((inhibit-read-only t))
2468 (goto-char (point-min))
2469 (while (re-search-forward
2470 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2471 (replace-match "\\1\\3" t)))
2472 (when (interactive-p)
2473 (gnus-treat-article nil))))
2476 (defun article-wash-html (&optional read-charset)
2477 "Format an HTML article.
2478 If READ-CHARSET, ask for a coding system."
2481 (let ((inhibit-read-only t)
2483 (when (gnus-buffer-live-p gnus-original-article-buffer)
2484 (with-current-buffer gnus-original-article-buffer
2485 (let* ((ct (gnus-fetch-field "content-type"))
2488 (mail-header-parse-content-type ct)))))
2489 (setq charset (and ctl
2490 (mail-content-type-get ctl 'charset)))
2491 (when (stringp charset)
2492 (setq charset (intern (downcase charset)))))))
2494 (setq charset (mm-read-coding-system "Charset: " charset)))
2496 (setq charset gnus-newsgroup-charset))
2498 (save-window-excursion
2500 (narrow-to-region (point) (point-max))
2501 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2502 (entry (assq func mm-text-html-washer-alist)))
2504 (setq func (cdr entry)))
2509 (apply (car func) (cdr func))))))))))
2511 (defun gnus-article-wash-html-with-w3 ()
2512 "Wash the current buffer with w3."
2514 (let ((w3-strict-width (window-width))
2515 (url-standalone-mode t)
2516 (url-gateway-unplugged t)
2517 (w3-honor-stylesheets nil))
2519 (w3-region (point-min) (point-max))
2522 (defun gnus-article-wash-html-with-w3m ()
2523 "Wash the current buffer with emacs-w3m."
2526 (narrow-to-region (point) (point-max))
2527 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2528 w3m-force-redisplay)
2529 (w3m-region (point-min) (point-max)))
2530 (when (and mm-inline-text-html-with-w3m-keymap
2531 (boundp 'w3m-minor-mode-map)
2533 (add-text-properties
2534 (point-min) (point-max)
2535 (list 'keymap w3m-minor-mode-map
2536 ;; Put the mark meaning this part was rendered by emacs-w3m.
2537 'mm-inline-text-html-with-w3m t)))))
2539 (defun article-hide-list-identifiers ()
2540 "Remove list identifies from the Subject header.
2541 The `gnus-list-identifiers' variable specifies what to do."
2543 (let ((inhibit-point-motion-hooks t)
2544 (regexp (if (consp gnus-list-identifiers)
2545 (mapconcat 'identity gnus-list-identifiers " *\\|")
2546 gnus-list-identifiers))
2547 (inhibit-read-only t))
2551 (article-narrow-to-head)
2552 (goto-char (point-min))
2553 (while (re-search-forward
2554 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2556 (delete-region (match-beginning 2) (match-end 0))
2557 (beginning-of-line))
2558 (when (re-search-forward
2559 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2560 (delete-region (match-beginning 1) (match-end 1))))))))
2562 (defun article-hide-pem (&optional arg)
2563 "Toggle hiding of any PEM headers and signatures in the current article.
2564 If given a negative prefix, always show; if given a positive prefix,
2566 (interactive (gnus-article-hidden-arg))
2567 (unless (gnus-article-check-hidden-text 'pem arg)
2569 (let ((inhibit-read-only t) end)
2570 (goto-char (point-min))
2571 ;; Hide the horrendously ugly "header".
2572 (when (and (search-forward
2573 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2575 (setq end (1+ (match-beginning 0))))
2576 (gnus-add-wash-type 'pem)
2577 (gnus-article-hide-text-type
2579 (if (search-forward "\n\n" nil t)
2583 ;; Hide the trailer as well
2584 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2586 (gnus-article-hide-text-type
2587 (match-beginning 0) (match-end 0) 'pem)))))))
2589 (defun article-strip-banner ()
2590 "Strip the banners specified by the `banner' group parameter and by
2591 `gnus-article-address-banner-alist'."
2595 (let ((inhibit-point-motion-hooks t))
2596 (when (gnus-parameter-banner gnus-newsgroup-name)
2597 (article-really-strip-banner
2598 (gnus-parameter-banner gnus-newsgroup-name)))
2599 (when gnus-article-address-banner-alist
2600 ;; It is necessary to encode from fields before checking,
2601 ;; because `mail-header-parse-addresses' does not work
2602 ;; (reliably) on decoded headers. And more, it is
2603 ;; impossible to use `gnus-fetch-original-field' here,
2604 ;; because `article-strip-banner' may be called in draft
2605 ;; buffers to preview them.
2606 (let ((from (save-restriction
2608 (article-narrow-to-head)
2609 (mail-fetch-field "from"))))
2612 (caar (mail-header-parse-addresses
2613 (mail-encode-encoded-word-string from)))))
2615 (dolist (pair gnus-article-address-banner-alist)
2616 (when (string-match (car pair) from)
2618 (article-really-strip-banner (cdr pair)))))))))))))
2620 (defun article-really-strip-banner (banner)
2621 "Strip the banner specified by the argument."
2624 (let ((inhibit-point-motion-hooks t)
2625 (gnus-signature-limit nil)
2626 (inhibit-read-only t))
2629 ((eq banner 'signature)
2630 (when (gnus-article-narrow-to-signature)
2633 (delete-region (point) (point-max))))
2635 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2636 (while (re-search-forward banner nil t)
2637 (delete-region (match-beginning 0) (match-end 0)))))
2639 (while (re-search-forward banner nil t)
2640 (delete-region (match-beginning 0) (match-end 0)))))))))
2642 (defun article-babel ()
2643 "Translate article using an online translation service."
2646 (gnus-with-article-buffer
2647 (when (article-goto-body)
2648 (let* ((start (point))
2650 (orig (buffer-substring start end))
2651 (trans (babel-as-string orig)))
2653 (narrow-to-region start end)
2654 (delete-region start end)
2657 (defun article-hide-signature (&optional arg)
2658 "Hide the signature in the current article.
2659 If given a negative prefix, always show; if given a positive prefix,
2661 (interactive (gnus-article-hidden-arg))
2662 (unless (gnus-article-check-hidden-text 'signature arg)
2665 (let ((inhibit-read-only t))
2666 (when (gnus-article-narrow-to-signature)
2667 (gnus-article-hide-text-type
2668 (point-min) (point-max) 'signature))))))
2669 (gnus-set-mode-line 'article))
2671 (defun article-strip-headers-in-body ()
2672 "Strip offensive headers from bodies."
2676 (let ((case-fold-search t))
2677 (when (looking-at "x-no-archive:")
2678 (gnus-delete-line)))))
2680 (defun article-strip-leading-blank-lines ()
2681 "Remove all blank lines from the beginning of the article."
2684 (let ((inhibit-point-motion-hooks t)
2685 (inhibit-read-only t))
2686 (when (article-goto-body)
2687 (while (and (not (eobp))
2688 (looking-at "[ \t]*$"))
2689 (gnus-delete-line))))))
2691 (defun article-narrow-to-head ()
2692 "Narrow the buffer to the head of the message.
2693 Point is left at the beginning of the narrowed-to region."
2695 (goto-char (point-min))
2696 (if (search-forward "\n\n" nil 1)
2699 (goto-char (point-min)))
2701 (defun article-goto-body ()
2702 "Place point at the start of the body."
2703 (goto-char (point-min))
2705 ;; This variable is only bound when dealing with separate
2707 (article-goto-body-goes-to-point-min-p
2709 ((search-forward "\n\n" nil t)
2712 (goto-char (point-max))
2715 (defun article-strip-multiple-blank-lines ()
2716 "Replace consecutive blank lines with one empty line."
2719 (let ((inhibit-point-motion-hooks t)
2720 (inhibit-read-only t))
2721 ;; First make all blank lines empty.
2723 (while (re-search-forward "^[ \t]+$" nil t)
2724 (unless (gnus-annotation-in-region-p
2725 (match-beginning 0) (match-end 0))
2726 (replace-match "" nil t)))
2727 ;; Then replace multiple empty lines with a single empty line.
2729 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2730 (unless (gnus-annotation-in-region-p
2731 (match-beginning 0) (match-end 0))
2732 (delete-region (match-beginning 1) (match-end 1)))))))
2734 (defun article-strip-leading-space ()
2735 "Remove all white space from the beginning of the lines in the article."
2738 (let ((inhibit-point-motion-hooks t)
2739 (inhibit-read-only t))
2741 (while (re-search-forward "^[ \t]+" nil t)
2742 (replace-match "" t t)))))
2744 (defun article-strip-trailing-space ()
2745 "Remove all white space from the end of the lines in the article."
2748 (let ((inhibit-point-motion-hooks t)
2749 (inhibit-read-only t))
2751 (while (re-search-forward "[ \t]+$" nil t)
2752 (replace-match "" t t)))))
2754 (defun article-strip-blank-lines ()
2755 "Strip leading, trailing and multiple blank lines."
2757 (article-strip-leading-blank-lines)
2758 (article-remove-trailing-blank-lines)
2759 (article-strip-multiple-blank-lines))
2761 (defun article-strip-all-blank-lines ()
2762 "Strip all blank lines."
2765 (let ((inhibit-point-motion-hooks t)
2766 (inhibit-read-only t))
2768 (while (re-search-forward "^[ \t]*\n" nil t)
2769 (replace-match "" t t)))))
2771 (defun gnus-article-narrow-to-signature ()
2772 "Narrow to the signature; return t if a signature is found, else nil."
2773 (let ((inhibit-point-motion-hooks t))
2774 (when (gnus-article-search-signature)
2776 ;; Check whether we have some limits to what we consider
2777 ;; to be a signature.
2778 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2779 (list gnus-signature-limit)))
2781 (while (setq limit (pop limits))
2782 (if (or (and (integerp limit)
2783 (< (- (point-max) (point)) limit))
2785 (< (count-lines (point) (point-max)) limit))
2786 (and (functionp limit)
2788 (and (stringp limit)
2789 (not (re-search-forward limit nil t))))
2790 () ; This limit did not succeed.
2794 (narrow-to-region (point) (point-max))
2797 (defun gnus-article-search-signature ()
2798 "Search the current buffer for the signature separator.
2799 Put point at the beginning of the signature separator."
2800 (let ((cur (point)))
2801 (goto-char (point-max))
2802 (if (if (stringp gnus-signature-separator)
2803 (re-search-backward gnus-signature-separator nil t)
2804 (let ((seps gnus-signature-separator))
2806 (not (re-search-backward (car seps) nil t)))
2813 (defun gnus-article-hidden-arg ()
2814 "Return the current prefix arg as a number, or 0 if no prefix."
2815 (list (if current-prefix-arg
2816 (prefix-numeric-value current-prefix-arg)
2819 (defun gnus-article-check-hidden-text (type arg)
2820 "Return nil if hiding is necessary.
2821 Arg can be nil or a number. nil and positive means hide, negative
2822 means show, 0 means toggle."
2825 (let ((hide (gnus-article-hidden-text-p type)))
2831 (gnus-article-show-hidden-text type)
2834 (if (eq hide 'hidden)
2836 (gnus-article-show-hidden-text type)
2840 (defun gnus-article-hidden-text-p (type)
2841 "Say whether the current buffer contains hidden text of type TYPE."
2842 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2844 (not (get-text-property pos 'invisible))
2845 (not (get-text-property pos 'dummy-invisible)))
2847 (text-property-any (1+ pos) (point-max) 'article-type type)))
2852 (defun gnus-article-show-hidden-text (type &optional dummy)
2853 "Show all hidden text of type TYPE.
2854 Originally it is hide instead of DUMMY."
2855 (let ((inhibit-read-only t)
2856 (inhibit-point-motion-hooks t))
2857 (gnus-remove-text-properties-when
2859 (point-min) (point-max)
2860 (cons 'article-type (cons type
2861 gnus-hidden-properties)))
2862 (gnus-delete-wash-type type)))
2864 (defconst article-time-units
2865 `((year . ,(* 365.25 24 60 60))
2866 (week . ,(* 7 24 60 60))
2867 (day . ,(* 24 60 60))
2871 "Mapping from time units to seconds.")
2873 (defun gnus-article-forward-header ()
2874 "Move point to the start of the next header.
2875 If the current header is a continuation header, this can be several
2880 (if (looking-at "[ \t]+[^ \t]")
2884 (defun article-date-ut (&optional type highlight)
2885 "Convert DATE date to universal time in the current article.
2886 If TYPE is `local', convert to local time; if it is `lapsed', output
2887 how much time has lapsed since DATE. For `lapsed', the value of
2888 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2889 should replace the \"Date:\" one, or should be added below it."
2890 (interactive (list 'ut t))
2891 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2892 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
2896 (article-lapsed-timer
2900 (case-fold-search t)
2901 (inhibit-read-only t)
2902 (inhibit-point-motion-hooks t)
2903 pos date bface eface)
2907 (goto-char (point-min))
2908 (while (or (setq date (get-text-property (setq pos (point))
2910 (when (setq pos (next-single-property-change
2911 (point) 'original-date))
2912 (setq date (get-text-property pos 'original-date))
2914 (narrow-to-region pos (or (text-property-any pos (point-max)
2917 (goto-char (point-min))
2918 (when (re-search-forward tdate-regexp nil t)
2919 (setq bface (get-text-property (point-at-bol) 'face)
2920 eface (get-text-property (1- (point-at-eol)) 'face)))
2921 (goto-char (point-min))
2923 ;; Delete any old Date headers.
2924 (while (re-search-forward date-regexp nil t)
2926 (delete-region (point-at-bol) (progn
2927 (gnus-article-forward-header)
2929 (delete-region (point-at-bol) (progn
2930 (gnus-article-forward-header)
2933 (setq pos (point))))
2934 (when (and (not pos)
2935 (re-search-forward tdate-regexp nil t))
2937 (gnus-goto-char pos)
2938 (insert (article-make-date-line date (or type 'ut)))
2944 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2945 (put-text-property (match-beginning 1) (1+ (match-end 1))
2947 (put-text-property (match-beginning 2) (match-end 2)
2949 (put-text-property (point-min) (1- (point-max)) 'original-date date)
2950 (goto-char (point-max))
2953 (defun article-make-date-line (date type)
2954 "Return a DATE line of TYPE."
2955 (unless (memq type '(local ut original user iso8601 lapsed english))
2956 (error "Unknown conversion type: %s" type))
2958 (let ((time (date-to-time date)))
2960 ;; Convert to the local timezone.
2962 (concat "Date: " (message-make-date time)))
2963 ;; Convert to Universal Time.
2968 (let* ((e (parse-time-string date))
2969 (tm (apply 'encode-time e))
2971 (ls (- (cadr tm) (car (current-time-zone time)))))
2972 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2973 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2977 ;; Get the original date from the article.
2978 ((eq type 'original)
2979 (concat "Date: " (if (string-match "\n+$" date)
2980 (substring date 0 (match-beginning 0))
2982 ;; Let the user define the format.
2984 (let ((format (or (condition-case nil
2985 (with-current-buffer gnus-summary-buffer
2986 gnus-article-time-format)
2988 gnus-article-time-format)))
2989 (if (functionp format)
2990 (funcall format time)
2991 (concat "Date: " (format-time-string format time)))))
2994 (let ((tz (car (current-time-zone time))))
2997 (format-time-string "%Y%m%dT%H%M%S" time)
2998 (format "%s%02d%02d"
2999 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3000 (/ (% (abs tz) 3600) 60)))))
3001 ;; Do an X-Sent lapsed format.
3003 ;; If the date is seriously mangled, the timezone functions are
3004 ;; liable to bug out, so we ignore all errors.
3005 (let* ((now (current-time))
3006 (real-time (subtract-time now time))
3007 (real-sec (and real-time
3008 (+ (* (float (car real-time)) 65536)
3010 (sec (and real-time (abs real-sec)))
3020 ;; This is a bit convoluted, but basically we go
3021 ;; through the time units for years, weeks, etc,
3022 ;; and divide things to see whether that results
3023 ;; in positive answers.
3026 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3027 ;; The (remaining) seconds are too few to
3028 ;; be divided into this time unit.
3030 ;; It's big enough, so we output it.
3031 (setq sec (- sec (* num (cdr unit))))
3033 (concat (if prev ", " "") (int-to-string
3035 " " (symbol-name (car unit))
3036 (if (> num 1) "s" ""))
3038 article-time-units "")
3039 ;; If dates are odd, then it might appear like the
3040 ;; article was sent in the future.
3043 " in the future"))))))
3044 ;; Display the date in proper English
3046 (let ((dtime (decode-time time)))
3049 (number-to-string (nth 3 dtime))
3050 (let ((digit (% (nth 3 dtime) 10)))
3052 ((memq (nth 3 dtime) '(11 12 13)) "th")
3058 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3060 (number-to-string (nth 5 dtime))
3062 (format "%02d" (nth 2 dtime))
3064 (format "%02d" (nth 1 dtime)))))))
3066 (format "Date: %s (from Gnus)" date))))
3068 (defun article-date-local (&optional highlight)
3069 "Convert the current article date to the local timezone."
3070 (interactive (list t))
3071 (article-date-ut 'local highlight))
3073 (defun article-date-english (&optional highlight)
3074 "Convert the current article date to something that is proper English."
3075 (interactive (list t))
3076 (article-date-ut 'english highlight))
3078 (defun article-date-original (&optional highlight)
3079 "Convert the current article date to what it was originally.
3080 This is only useful if you have used some other date conversion
3081 function and want to see what the date was before converting."
3082 (interactive (list t))
3083 (article-date-ut 'original highlight))
3085 (defun article-date-lapsed (&optional highlight)
3086 "Convert the current article date to time lapsed since it was sent."
3087 (interactive (list t))
3088 (article-date-ut 'lapsed highlight))
3090 (defun article-update-date-lapsed ()
3091 "Function to be run from a timer to update the lapsed time line."
3093 (let (deactivate-mark)
3098 (set-buffer (window-buffer w))
3099 (when (eq major-mode 'gnus-article-mode)
3100 (let ((mark (point-marker)))
3101 (goto-char (point-min))
3102 (when (re-search-forward "^X-Sent:" nil t)
3103 (article-date-lapsed t))
3104 (goto-char (marker-position mark))
3105 (move-marker mark nil))))
3108 (defun gnus-start-date-timer (&optional n)
3109 "Start a timer to update the X-Sent header in the article buffers.
3110 The numerical prefix says how frequently (in seconds) the function
3115 (gnus-stop-date-timer)
3116 (setq article-lapsed-timer
3117 (run-at-time 1 n 'article-update-date-lapsed)))
3119 (defun gnus-stop-date-timer ()
3120 "Stop the X-Sent timer."
3122 (when article-lapsed-timer
3123 (nnheader-cancel-timer article-lapsed-timer)
3124 (setq article-lapsed-timer nil)))
3126 (defun article-date-user (&optional highlight)
3127 "Convert the current article date to the user-defined format.
3128 This format is defined by the `gnus-article-time-format' variable."
3129 (interactive (list t))
3130 (article-date-ut 'user highlight))
3132 (defun article-date-iso8601 (&optional highlight)
3133 "Convert the current article date to ISO8601."
3134 (interactive (list t))
3135 (article-date-ut 'iso8601 highlight))
3137 (defmacro gnus-article-save-original-date (&rest forms)
3138 "Save the original date as a text property and evaluate FORMS."
3139 `(let* ((case-fold-search t)
3141 (goto-char (point-min))
3142 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3145 (date (when (and start
3146 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3148 (buffer-substring-no-properties start
3149 (match-beginning 0)))))
3150 (goto-char (point-max))
3151 (skip-chars-backward "\n")
3152 (put-text-property (point-min) (point) 'original-date date)
3154 (goto-char (point-max))
3155 (skip-chars-backward "\n")
3156 (put-text-property (point-min) (point) 'original-date date)))
3158 ;; (defun article-show-all ()
3159 ;; "Show all hidden text in the article buffer."
3162 ;; (let ((inhibit-read-only t))
3163 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3165 (defun article-remove-leading-whitespace ()
3166 "Remove excessive whitespace from all headers."
3170 (let ((inhibit-read-only t))
3171 (article-narrow-to-head)
3172 (goto-char (point-min))
3173 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3174 (delete-region (match-beginning 1) (match-end 1)))))))
3176 (defun article-emphasize (&optional arg)
3177 "Emphasize text according to `gnus-emphasis-alist'."
3178 (interactive (gnus-article-hidden-arg))
3179 (unless (gnus-article-check-hidden-text 'emphasis arg)
3183 (with-current-buffer gnus-summary-buffer
3184 gnus-article-emphasis-alist)
3186 gnus-emphasis-alist))
3187 (inhibit-read-only t)
3188 (props (append '(article-type emphasis)
3189 gnus-hidden-properties))
3190 regexp elem beg invisible visible face)
3193 (while (setq elem (pop alist))
3195 (setq regexp (car elem)
3196 invisible (nth 1 elem)
3197 visible (nth 2 elem)
3199 (while (re-search-forward regexp nil t)
3200 (when (and (match-beginning visible) (match-beginning invisible))
3201 (gnus-article-hide-text
3202 (match-beginning invisible) (match-end invisible) props)
3203 (gnus-article-unhide-text-type
3204 (match-beginning visible) (match-end visible) 'emphasis)
3205 (gnus-put-overlay-excluding-newlines
3206 (match-beginning visible) (match-end visible) 'face face)
3207 (gnus-add-wash-type 'emphasis)
3208 (goto-char (match-end invisible)))))))))
3210 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3211 "Setup newsgroup emphasis alist."
3212 (unless gnus-article-emphasis-alist
3213 (let ((name (and gnus-newsgroup-name
3214 (gnus-group-real-name gnus-newsgroup-name))))
3215 (make-local-variable 'gnus-article-emphasis-alist)
3216 (setq gnus-article-emphasis-alist
3218 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3219 (while (setq elem (pop alist))
3220 (when (and name (string-match (car elem) name))
3222 highlight (copy-sequence (cdr elem)))))
3224 (copy-sequence highlight-words)
3225 (if gnus-newsgroup-name
3226 (copy-sequence (gnus-group-find-parameter
3227 gnus-newsgroup-name 'highlight-words t)))
3228 gnus-emphasis-alist)))))
3231 (defvar gnus-summary-article-menu)
3232 (defvar gnus-summary-post-menu))
3234 ;;; Saving functions.
3236 (defun gnus-article-save (save-buffer file &optional num)
3237 "Save the currently selected article."
3238 (unless gnus-save-all-headers
3239 ;; Remove headers according to `gnus-saved-headers'.
3240 (let ((gnus-visible-headers
3241 (or gnus-saved-headers gnus-visible-headers))
3242 (gnus-article-buffer save-buffer))
3244 (set-buffer save-buffer)
3245 (article-hide-headers 1 t))))
3246 (save-window-excursion
3247 (if (not gnus-default-article-saver)
3248 (error "No default saver is defined")
3249 ;; !!! Magic! The saving functions all save
3250 ;; `gnus-save-article-buffer' (or so they think), but we
3251 ;; bind that variable to our save-buffer.
3252 (set-buffer gnus-article-buffer)
3253 (let* ((gnus-save-article-buffer save-buffer)
3256 ((not gnus-prompt-before-saving) 'default)
3257 ((eq gnus-prompt-before-saving 'always) nil)
3259 (gnus-number-of-articles-to-be-saved
3260 (when (eq gnus-prompt-before-saving t)
3262 (set-buffer gnus-article-current-summary)
3263 (funcall gnus-default-article-saver filename)))))
3265 (defun gnus-read-save-file-name (prompt &optional filename
3266 function group headers variable)
3268 (funcall function group headers (symbol-value variable)))
3273 ((eq filename 'default)
3279 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3282 (if (and gnus-number-of-articles-to-be-saved
3283 (> gnus-number-of-articles-to-be-saved 1))
3284 (format "these %d articles"
3285 gnus-number-of-articles-to-be-saved)
3288 ;; Let the split methods have their say.
3290 ;; No split name was found.
3293 (concat prompt " (default "
3294 (file-name-nondirectory default-name) ") ")
3295 (file-name-directory default-name)
3297 ;; A single group name is returned.
3298 ((stringp split-name)
3300 (funcall function split-name headers
3301 (symbol-value variable)))
3303 (concat prompt " (default "
3304 (file-name-nondirectory default-name) ") ")
3305 (file-name-directory default-name)
3307 ;; A single split name was found
3308 ((= 1 (length split-name))
3309 (let* ((name (expand-file-name
3311 gnus-article-save-directory))
3312 (dir (cond ((file-directory-p name)
3313 (file-name-as-directory name))
3314 ((file-exists-p name) name)
3315 (t gnus-article-save-directory))))
3317 (concat prompt " (default " name ") ")
3319 ;; A list of splits was found.
3321 (setq split-name (nreverse split-name))
3323 (let ((file-name-history
3324 (nconc split-name file-name-history)))
3328 (concat prompt " (`M-p' for defaults) ")
3329 gnus-article-save-directory
3331 gnus-article-save-directory)))
3332 (car (push result file-name-history)))))))
3333 ;; Create the directory.
3334 (gnus-make-directory (file-name-directory file))
3335 ;; If we have read a directory, we append the default file name.
3336 (when (file-directory-p file)
3337 (setq file (expand-file-name (file-name-nondirectory
3339 (file-name-as-directory file))))
3340 ;; Possibly translate some characters.
3341 (nnheader-translate-file-chars file))))))
3342 (gnus-make-directory (file-name-directory result))
3343 (set variable result)))
3345 (defun gnus-article-archive-name (group)
3346 "Return the first instance of an \"Archive-name\" in the current buffer."
3347 (let ((case-fold-search t))
3348 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3349 (nnheader-concat gnus-article-save-directory
3350 (match-string 1)))))
3352 (defun gnus-article-nndoc-name (group)
3353 "If GROUP is an nndoc group, return the name of the parent group."
3354 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3355 (gnus-group-get-parameter group 'save-article-group)))
3357 (defun gnus-summary-save-in-rmail (&optional filename)
3358 "Append this article to Rmail file.
3359 Optional argument FILENAME specifies file name.
3360 Directory to save to is default to `gnus-article-save-directory'."
3361 (setq filename (gnus-read-save-file-name
3362 "Save %s in rmail file:" filename
3363 gnus-rmail-save-name gnus-newsgroup-name
3364 gnus-current-headers 'gnus-newsgroup-last-rmail))
3365 (gnus-eval-in-buffer-window gnus-save-article-buffer
3369 (gnus-output-to-rmail filename))))
3372 (defun gnus-summary-save-in-mail (&optional filename)
3373 "Append this article to Unix mail file.
3374 Optional argument FILENAME specifies file name.
3375 Directory to save to is default to `gnus-article-save-directory'."
3376 (setq filename (gnus-read-save-file-name
3377 "Save %s in Unix mail file:" filename
3378 gnus-mail-save-name gnus-newsgroup-name
3379 gnus-current-headers 'gnus-newsgroup-last-mail))
3380 (gnus-eval-in-buffer-window gnus-save-article-buffer
3384 (if (and (file-readable-p filename)
3385 (file-regular-p filename)
3386 (mail-file-babyl-p filename))
3387 (rmail-output-to-rmail-file filename t)
3388 (gnus-output-to-mail filename)))))
3391 (defun gnus-summary-save-in-file (&optional filename overwrite)
3392 "Append this article to file.
3393 Optional argument FILENAME specifies file name.
3394 Directory to save to is default to `gnus-article-save-directory'."
3395 (setq filename (gnus-read-save-file-name
3396 "Save %s in file:" filename
3397 gnus-file-save-name gnus-newsgroup-name
3398 gnus-current-headers 'gnus-newsgroup-last-file))
3399 (gnus-eval-in-buffer-window gnus-save-article-buffer
3403 (when (and overwrite
3404 (file-exists-p filename))
3405 (delete-file filename))
3406 (gnus-output-to-file filename))))
3409 (defun gnus-summary-write-to-file (&optional filename)
3410 "Write this article to a file, overwriting it if the file exists.
3411 Optional argument FILENAME specifies file name.
3412 The directory to save in defaults to `gnus-article-save-directory'."
3413 (gnus-summary-save-in-file nil t))
3415 (defun gnus-summary-save-body-in-file (&optional filename)
3416 "Append this article body to a file.
3417 Optional argument FILENAME specifies file name.
3418 The directory to save in defaults to `gnus-article-save-directory'."
3419 (setq filename (gnus-read-save-file-name
3420 "Save %s body in file:" filename
3421 gnus-file-save-name gnus-newsgroup-name
3422 gnus-current-headers 'gnus-newsgroup-last-file))
3423 (gnus-eval-in-buffer-window gnus-save-article-buffer
3427 (when (article-goto-body)
3428 (narrow-to-region (point) (point-max)))
3429 (gnus-output-to-file filename))))
3432 (defun gnus-summary-save-in-pipe (&optional command)
3433 "Pipe this article to subprocess."
3435 (cond ((and (eq command 'default)
3436 gnus-last-shell-command)
3437 gnus-last-shell-command)
3442 "Shell command on %s: "
3443 (if (and gnus-number-of-articles-to-be-saved
3444 (> gnus-number-of-articles-to-be-saved 1))
3445 (format "these %d articles"
3446 gnus-number-of-articles-to-be-saved)
3448 gnus-last-shell-command))))
3449 (when (string-equal command "")
3450 (if gnus-last-shell-command
3451 (setq command gnus-last-shell-command)
3452 (error "A command is required")))
3453 (gnus-eval-in-buffer-window gnus-article-buffer
3456 (shell-command-on-region (point-min) (point-max) command nil)))
3457 (setq gnus-last-shell-command command))
3459 (defun gnus-summary-pipe-to-muttprint (&optional command)
3460 "Pipe this article to muttprint."
3461 (setq command (read-string
3462 "Print using command: " gnus-summary-muttprint-program
3463 nil gnus-summary-muttprint-program))
3464 (gnus-summary-save-in-pipe command))
3466 ;;; Article file names when saving.
3468 (defun gnus-capitalize-newsgroup (newsgroup)
3469 "Capitalize NEWSGROUP name."
3470 (when (not (zerop (length newsgroup)))
3471 (concat (char-to-string (upcase (aref newsgroup 0)))
3472 (substring newsgroup 1))))
3474 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3475 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3476 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3477 Otherwise, it is like ~/News/news/group/num."
3480 (concat (if (gnus-use-long-file-name 'not-save)
3481 (gnus-capitalize-newsgroup newsgroup)
3482 (gnus-newsgroup-directory-form newsgroup))
3483 "/" (int-to-string (mail-header-number headers)))
3484 gnus-article-save-directory)))
3486 (string-equal (file-name-directory default)
3487 (file-name-directory last-file))
3488 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3490 (or last-file default))))
3492 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3493 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3494 If variable `gnus-use-long-file-name' is non-nil, it is
3495 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3498 (concat (if (gnus-use-long-file-name 'not-save)
3500 (gnus-newsgroup-directory-form newsgroup))
3501 "/" (int-to-string (mail-header-number headers)))
3502 gnus-article-save-directory)))
3504 (string-equal (file-name-directory default)
3505 (file-name-directory last-file))
3506 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3508 (or last-file default))))
3510 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3511 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3512 If variable `gnus-use-long-file-name' is non-nil, it is
3513 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3516 (if (gnus-use-long-file-name 'not-save)
3519 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3521 gnus-article-save-directory)))
3523 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3524 "Generate file name from sender."
3525 (let ((from (mail-header-from headers)))
3527 (if (and from (string-match "\\([^ <]+\\)@" from))
3528 (match-string 1 from)
3530 gnus-article-save-directory)))
3532 (defun article-verify-x-pgp-sig ()
3535 (if (gnus-buffer-live-p gnus-original-article-buffer)
3536 (let ((sig (with-current-buffer gnus-original-article-buffer
3537 (gnus-fetch-field "X-PGP-Sig")))
3541 (mml2015-clear-verify-function))
3543 (insert-buffer-substring gnus-original-article-buffer)
3544 (setq items (split-string sig))
3545 (message-narrow-to-head)
3546 (let ((inhibit-point-motion-hooks t)
3547 (case-fold-search t))
3548 ;; Don't verify multiple headers.
3549 (setq headers (mapconcat (lambda (header)
3551 (mail-fetch-field header)
3553 (split-string (nth 1 items) ",") "")))
3554 (delete-region (point-min) (point-max))
3555 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3556 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3561 (if (looking-at "^-")
3564 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3565 (insert "Version: " (car items) "\n\n")
3566 (insert (mapconcat 'identity (cddr items) "\n"))
3567 (insert "\n-----END PGP SIGNATURE-----\n")
3568 (let ((mm-security-handle (list (format "multipart/signed"))))
3569 (mml2015-clean-buffer)
3570 (let ((coding-system-for-write (or gnus-newsgroup-charset
3572 (funcall (mml2015-clear-verify-function)))
3574 (or (mm-handle-multipart-ctl-parameter
3575 mm-security-handle 'gnus-details)
3576 (mm-handle-multipart-ctl-parameter
3577 mm-security-handle 'gnus-info)))))
3579 (let ((inhibit-read-only t) bface eface)
3581 (message-narrow-to-head)
3582 (goto-char (point-max))
3584 (setq bface (get-text-property (point-at-bol) 'face)
3585 eface (get-text-property (1- (point-at-eol)) 'face))
3586 (message-remove-header "X-Gnus-PGP-Verify")
3587 (if (re-search-forward "^X-PGP-Sig:" nil t)
3589 (goto-char (point-max)))
3590 (narrow-to-region (point) (point))
3591 (insert "X-Gnus-PGP-Verify: " info "\n")
3592 (goto-char (point-min))
3595 (if (not (looking-at "^[ \t]"))
3599 (goto-char (point-min))
3600 (when (looking-at "\\([^:]+\\): *")
3601 (put-text-property (match-beginning 1) (1+ (match-end 1))
3603 (put-text-property (match-end 0) (point-max)
3604 'face eface)))))))))
3606 (defun article-verify-cancel-lock ()
3607 "Verify Cancel-Lock header."
3609 (if (gnus-buffer-live-p gnus-original-article-buffer)
3610 (canlock-verify gnus-original-article-buffer)))
3617 (setq afunc (car func)
3620 gfunc (intern (format "gnus-%s" func))))
3622 (when (fboundp afunc)
3623 `(lambda (&optional interactive &rest args)
3624 ,(documentation afunc t)
3625 (interactive (list t))
3627 (set-buffer gnus-article-buffer)
3629 (call-interactively ',afunc)
3630 (apply ',afunc args))))))))
3631 '(article-hide-headers
3632 article-verify-x-pgp-sig
3633 article-verify-cancel-lock
3634 article-hide-boring-headers
3635 article-treat-overstrike
3636 article-treat-ansi-sequences
3637 article-fill-long-lines
3638 article-capitalize-sentences
3640 article-remove-leading-whitespace
3641 article-display-x-face
3642 article-display-face
3643 article-de-quoted-unreadable
3644 article-de-base64-unreadable
3647 article-unsplit-urls
3648 article-hide-list-identifiers
3649 article-strip-banner
3652 article-hide-signature
3653 article-strip-headers-in-body
3654 article-remove-trailing-blank-lines
3655 article-strip-leading-blank-lines
3656 article-strip-multiple-blank-lines
3657 article-strip-leading-space
3658 article-strip-trailing-space
3659 article-strip-blank-lines
3660 article-strip-all-blank-lines
3662 article-date-english
3663 article-date-iso8601
3664 article-date-original
3666 article-decode-mime-words
3667 article-decode-charset
3668 article-decode-encoded-words
3672 article-treat-dumbquotes
3673 article-normalize-headers
3674 ;; (article-show-all . gnus-article-show-all-headers)
3678 ;;; Gnus article mode
3681 (put 'gnus-article-mode 'mode-class 'special)
3683 (set-keymap-parent gnus-article-mode-map widget-keymap)
3685 (gnus-define-keys gnus-article-mode-map
3686 " " gnus-article-goto-next-page
3687 "\177" gnus-article-goto-prev-page
3688 [delete] gnus-article-goto-prev-page
3689 [backspace] gnus-article-goto-prev-page
3690 "\C-c^" gnus-article-refer-article
3691 "h" gnus-article-show-summary
3692 "s" gnus-article-show-summary
3693 "\C-c\C-m" gnus-article-mail
3694 "?" gnus-article-describe-briefly
3695 "e" gnus-summary-edit-article
3696 "<" beginning-of-buffer
3698 "\C-c\C-i" gnus-info-find-node
3700 "R" gnus-article-reply-with-original
3701 "F" gnus-article-followup-with-original
3702 "\C-hk" gnus-article-describe-key
3703 "\C-hc" gnus-article-describe-key-briefly
3705 "\C-d" gnus-article-read-summary-keys
3706 "\M-*" gnus-article-read-summary-keys
3707 "\M-#" gnus-article-read-summary-keys
3708 "\M-^" gnus-article-read-summary-keys
3709 "\M-g" gnus-article-read-summary-keys)
3711 (substitute-key-definition
3712 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3714 (defun gnus-article-make-menu-bar ()
3715 (unless (boundp 'gnus-article-commands-menu)
3716 (gnus-summary-make-menu-bar))
3717 (gnus-turn-off-edit-menu 'article)
3718 (unless (boundp 'gnus-article-article-menu)
3720 gnus-article-article-menu gnus-article-mode-map ""
3722 ["Scroll forwards" gnus-article-goto-next-page t]
3723 ["Scroll backwards" gnus-article-goto-prev-page t]
3724 ["Show summary" gnus-article-show-summary t]
3725 ["Fetch Message-ID at point" gnus-article-refer-article t]
3726 ["Mail to address at point" gnus-article-mail t]
3727 ["Send a bug report" gnus-bug t]))
3730 gnus-article-treatment-menu gnus-article-mode-map ""
3731 ;; Fixme: this should use :active (and maybe :visible).
3733 ["Hide headers" gnus-article-hide-headers t]
3734 ["Hide signature" gnus-article-hide-signature t]
3735 ["Hide citation" gnus-article-hide-citation t]
3736 ["Treat overstrike" gnus-article-treat-overstrike t]
3737 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3738 ["Remove carriage return" gnus-article-remove-cr t]
3739 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3740 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3741 ["Remove base64" gnus-article-de-base64-unreadable t]
3742 ["Treat html" gnus-article-wash-html t]
3743 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3744 ["Decode HZ" gnus-article-decode-HZ t]))
3746 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3748 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3750 (gnus-run-hooks 'gnus-article-menu-hook)))
3752 (defun gnus-article-mode ()
3753 "Major mode for displaying an article.
3755 All normal editing commands are switched off.
3757 The following commands are available in addition to all summary mode
3759 \\<gnus-article-mode-map>
3760 \\[gnus-article-next-page]\t Scroll the article one page forwards
3761 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3762 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3763 \\[gnus-article-show-summary]\t Display the summary buffer
3764 \\[gnus-article-mail]\t Send a reply to the address near point
3765 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3766 \\[gnus-info-find-node]\t Go to the Gnus info node"
3768 (kill-all-local-variables)
3769 (gnus-simplify-mode-line)
3770 (setq mode-name "Article")
3771 (setq major-mode 'gnus-article-mode)
3772 (make-local-variable 'minor-mode-alist)
3773 (use-local-map gnus-article-mode-map)
3774 (when (gnus-visual-p 'article-menu 'menu)
3775 (gnus-article-make-menu-bar)
3776 (when gnus-summary-tool-bar-map
3777 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3778 (gnus-update-format-specifications nil 'article-mode)
3779 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3780 (set (make-local-variable 'gnus-page-broken) nil)
3781 (make-local-variable 'gnus-button-marker-list)
3782 (make-local-variable 'gnus-article-current-summary)
3783 (make-local-variable 'gnus-article-mime-handles)
3784 (make-local-variable 'gnus-article-decoded-p)
3785 (make-local-variable 'gnus-article-mime-handle-alist)
3786 (make-local-variable 'gnus-article-wash-types)
3787 (make-local-variable 'gnus-article-image-alist)
3788 (make-local-variable 'gnus-article-charset)
3789 (make-local-variable 'gnus-article-ignored-charsets)
3790 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3791 (set (make-local-variable 'nobreak-char-display) nil)
3792 (gnus-set-default-directory)
3793 (buffer-disable-undo)
3794 (setq buffer-read-only t
3795 show-trailing-whitespace nil)
3796 (set-syntax-table gnus-article-mode-syntax-table)
3797 (mm-enable-multibyte)
3798 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3800 (defun gnus-article-setup-buffer ()
3801 "Initialize the article buffer."
3802 (let* ((name (if gnus-single-article-buffer "*Article*"
3803 (concat "*Article " gnus-newsgroup-name "*")))
3805 (progn (string-match "\\*Article" name)
3806 (concat " *Original Article"
3807 (substring name (match-end 0))))))
3808 (setq gnus-article-buffer name)
3809 (setq gnus-original-article-buffer original)
3810 (setq gnus-article-mime-handle-alist nil)
3811 ;; This might be a variable local to the summary buffer.
3812 (unless gnus-single-article-buffer
3814 (set-buffer gnus-summary-buffer)
3815 (setq gnus-article-buffer name)
3816 (setq gnus-original-article-buffer original)
3817 (gnus-set-global-variables)))
3818 (gnus-article-setup-highlight-words)
3819 ;; Init original article buffer.
3821 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3822 (mm-enable-multibyte)
3823 (setq major-mode 'gnus-original-article-mode)
3824 (make-local-variable 'gnus-original-article))
3825 (if (and (get-buffer name)
3826 (with-current-buffer name
3827 (if gnus-article-edit-mode
3828 (if (y-or-n-p "Article mode edit in progress; discard? ")
3830 (set-buffer-modified-p nil)
3831 (gnus-kill-buffer name)
3834 (error "Action aborted"))
3838 (set (make-local-variable 'gnus-article-edit-mode) nil)
3839 (when gnus-article-mime-handles
3840 (mm-destroy-parts gnus-article-mime-handles)
3841 (setq gnus-article-mime-handles nil))
3842 ;; Set it to nil in article-buffer!
3843 (setq gnus-article-mime-handle-alist nil)
3844 (buffer-disable-undo)
3845 (setq buffer-read-only t)
3846 ;; This list just keeps growing if we don't reset it.
3847 (setq gnus-button-marker-list nil)
3848 (unless (eq major-mode 'gnus-article-mode)
3849 (gnus-article-mode))
3852 (set-buffer (gnus-get-buffer-create name))
3854 (make-local-variable 'gnus-summary-buffer)
3855 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3856 (current-buffer)))))
3858 ;; Set article window start at LINE, where LINE is the number of lines
3859 ;; from the head of the article.
3860 (defun gnus-article-set-window-start (&optional line)
3862 (gnus-get-buffer-window gnus-article-buffer t)
3864 (set-buffer gnus-article-buffer)
3865 (goto-char (point-min))
3868 (gnus-message 6 "Moved to bookmark")
3869 (search-forward "\n\n" nil t)
3873 (defun gnus-article-prepare (article &optional all-headers header)
3874 "Prepare ARTICLE in article mode buffer.
3875 ARTICLE should either be an article number or a Message-ID.
3876 If ARTICLE is an id, HEADER should be the article headers.
3877 If ALL-HEADERS is non-nil, no headers are hidden."
3879 ;; Make sure we start in a summary buffer.
3880 (unless (eq major-mode 'gnus-summary-mode)
3881 (set-buffer gnus-summary-buffer))
3882 (setq gnus-summary-buffer (current-buffer))
3883 (let* ((gnus-article (if header (mail-header-number header) article))
3884 (summary-buffer (current-buffer))
3885 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3886 (group gnus-newsgroup-name)
3889 (gnus-article-setup-buffer)
3890 (set-buffer gnus-article-buffer)
3891 ;; Deactivate active regions.
3892 (when (and (boundp 'transient-mark-mode)
3893 transient-mark-mode)
3894 (setq mark-active nil))
3895 (if (not (setq result (let ((inhibit-read-only t))
3896 (gnus-request-article-this-buffer
3898 ;; There is no such article.
3900 (when (and (numberp article)
3901 (not (memq article gnus-newsgroup-sparse)))
3902 (setq gnus-article-current
3903 (cons gnus-newsgroup-name article))
3904 (set-buffer gnus-summary-buffer)
3905 (setq gnus-current-article article)
3906 (if (and (memq article gnus-newsgroup-undownloaded)
3907 (not (gnus-online (gnus-find-method-for-group
3908 gnus-newsgroup-name))))
3910 (gnus-summary-set-agent-mark article)
3911 (message "Message marked for downloading"))
3912 (gnus-summary-mark-article article gnus-canceled-mark)
3913 (unless (memq article gnus-newsgroup-sparse)
3914 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3915 (if (or (eq result 'pseudo)
3916 (eq result 'nneething))
3919 (set-buffer summary-buffer)
3920 (push article gnus-newsgroup-history)
3921 (setq gnus-last-article gnus-current-article
3922 gnus-current-article 0
3923 gnus-current-headers nil
3924 gnus-article-current nil)
3925 (if (eq result 'nneething)
3926 (gnus-configure-windows 'summary)
3927 (gnus-configure-windows 'article))
3928 (gnus-set-global-variables))
3929 (let ((gnus-article-mime-handle-alist-1
3930 gnus-article-mime-handle-alist))
3931 (gnus-set-mode-line 'article)))
3932 ;; The result from the `request' was an actual article -
3933 ;; or at least some text that is now displayed in the
3935 (when (and (numberp article)
3936 (not (eq article gnus-current-article)))
3937 ;; Seems like a new article has been selected.
3938 ;; `gnus-current-article' must be an article number.
3940 (set-buffer summary-buffer)
3941 (push article gnus-newsgroup-history)
3942 (setq gnus-last-article gnus-current-article
3943 gnus-current-article article
3944 gnus-current-headers
3945 (gnus-summary-article-header gnus-current-article)
3946 gnus-article-current
3947 (cons gnus-newsgroup-name gnus-current-article))
3948 (unless (vectorp gnus-current-headers)
3949 (setq gnus-current-headers nil))
3950 (gnus-summary-goto-subject gnus-current-article)
3951 (when (gnus-summary-show-thread)
3952 ;; If the summary buffer really was folded, the
3953 ;; previous goto may not actually have gone to
3954 ;; the right article, but the thread root instead.
3956 (gnus-summary-goto-subject gnus-current-article))
3957 (gnus-run-hooks 'gnus-mark-article-hook)
3958 (gnus-set-mode-line 'summary)
3959 (when (gnus-visual-p 'article-highlight 'highlight)
3960 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3961 ;; Set the global newsgroup variables here.
3962 (gnus-set-global-variables)
3963 (setq gnus-have-all-headers
3964 (or all-headers gnus-show-all-headers))))
3966 (gnus-configure-windows 'article))
3967 (when (or (numberp article)
3969 (gnus-article-prepare-display)
3971 (goto-char (point-min))
3972 (when gnus-break-pages
3973 (gnus-narrow-to-page)))
3974 (let ((gnus-article-mime-handle-alist-1
3975 gnus-article-mime-handle-alist))
3976 (gnus-set-mode-line 'article))
3980 (set-window-point (get-buffer-window (current-buffer)) (point))
3981 (gnus-configure-windows 'article)
3985 (defun gnus-article-prepare-display ()
3986 "Make the current buffer look like a nice article."
3987 ;; Hooks for getting information from the article.
3988 ;; This hook must be called before being narrowed.
3989 (let ((gnus-article-buffer (current-buffer))
3991 (inhibit-read-only t))
3992 (unless (eq major-mode 'gnus-article-mode)
3993 (gnus-article-mode))
3994 (setq buffer-read-only nil
3995 gnus-article-wash-types nil
3996 gnus-article-image-alist nil)
3997 (gnus-run-hooks 'gnus-tmp-internal-hook)
3998 (when gnus-display-mime-function
3999 (funcall gnus-display-mime-function))
4000 (gnus-run-hooks 'gnus-article-prepare-hook)))
4003 ;;; Gnus MIME viewing functions
4006 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4007 "Format of the MIME buttons.
4009 Valid specifiers include:
4011 %T MIME type, along with additional info
4012 %n The `name' parameter
4013 %d The description, if any
4014 %l The length of the encoded part
4015 %p The part identifier number
4016 %e Dots if the part isn't displayed
4018 General format specifiers can also be used. See Info node
4019 `(gnus)Formatting Variables'.")
4021 (defvar gnus-mime-button-line-format-alist
4022 '((?t gnus-tmp-type ?s)
4023 (?T gnus-tmp-type-long ?s)
4024 (?n gnus-tmp-name ?s)
4025 (?d gnus-tmp-description ?s)
4027 (?l gnus-tmp-length ?d)
4028 (?e gnus-tmp-dots ?s)))
4030 (defvar gnus-mime-button-commands
4031 '((gnus-article-press-button "\r" "Toggle Display")
4032 (gnus-mime-view-part "v" "View Interactively...")
4033 (gnus-mime-view-part-as-type "t" "View As Type...")
4034 (gnus-mime-view-part-as-charset "C" "View As charset...")
4035 (gnus-mime-save-part "o" "Save...")
4036 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4037 (gnus-mime-delete-part "d" "Delete part")
4038 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4039 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4040 (gnus-mime-view-part-internally "E" "View Internally")
4041 (gnus-mime-view-part-externally "e" "View Externally")
4042 (gnus-mime-print-part "p" "Print")
4043 (gnus-mime-pipe-part "|" "Pipe To Command...")
4044 (gnus-mime-action-on-part "." "Take action on the part...")))
4046 (defun gnus-article-mime-part-status ()
4047 (if gnus-article-mime-handle-alist-1
4048 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4050 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4053 (defvar gnus-mime-button-map
4054 (let ((map (make-sparse-keymap)))
4055 (define-key map gnus-mouse-2 'gnus-article-push-button)
4056 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4057 (dolist (c gnus-mime-button-commands)
4058 (define-key map (cadr c) (car c)))
4062 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4064 ,@(mapcar (lambda (c)
4065 (vector (caddr c) (car c) :enable t))
4066 gnus-mime-button-commands)))
4068 (defun gnus-mime-button-menu (event prefix)
4069 "Construct a context-sensitive menu of MIME commands."
4070 (interactive "e\nP")
4071 (save-window-excursion
4072 (let ((pos (event-start event)))
4073 (select-window (posn-window pos))
4074 (goto-char (posn-point pos))
4075 (gnus-article-check-buffer)
4076 (popup-menu gnus-mime-button-menu nil prefix))))
4078 (defun gnus-mime-view-all-parts (&optional handles)
4079 "View all the MIME parts."
4081 (with-current-buffer gnus-article-buffer
4082 (let ((handles (or handles gnus-article-mime-handles))
4083 (mail-parse-charset gnus-newsgroup-charset)
4084 (mail-parse-ignored-charsets
4085 (with-current-buffer gnus-summary-buffer
4086 gnus-newsgroup-ignored-charsets)))
4088 (mm-remove-parts handles)
4089 (goto-char (point-min))
4090 (or (search-forward "\n\n") (goto-char (point-max)))
4091 (let ((inhibit-read-only t))
4092 (delete-region (point) (point-max))
4093 (mm-display-parts handles))))))
4096 (defsubst gnus-article-edit-part (handles)
4097 "Edit an article in order to delete a mime part.
4098 This function is exclusively used by `gnus-mime-save-part-and-strip'
4099 and `gnus-mime-delete-part', and not provided at run-time normally."
4100 (gnus-article-edit-article
4102 (buffer-disable-undo)
4104 (let ((mail-parse-charset (or gnus-article-charset
4105 ',gnus-newsgroup-charset))
4106 (mail-parse-ignored-charsets
4107 (or gnus-article-ignored-charsets
4108 ',gnus-newsgroup-ignored-charsets))
4109 (mbl mml-buffer-list))
4110 (setq mml-buffer-list nil)
4111 (insert-buffer-substring gnus-original-article-buffer)
4112 (mime-to-mml ',handles)
4113 (setq gnus-article-mime-handles nil)
4114 (let ((mbl1 mml-buffer-list))
4115 (setq mml-buffer-list mbl)
4116 (set (make-local-variable 'mml-buffer-list) mbl1))
4117 (gnus-make-local-hook 'kill-buffer-hook)
4118 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4119 `(lambda (no-highlight)
4120 (let ((mail-parse-charset (or gnus-article-charset
4121 ',gnus-newsgroup-charset))
4122 (message-options message-options)
4123 (message-options-set-recipient)
4124 (mail-parse-ignored-charsets
4125 (or gnus-article-ignored-charsets
4126 ',gnus-newsgroup-ignored-charsets)))
4128 (mml-destroy-buffers)
4129 (remove-hook 'kill-buffer-hook
4130 'mml-destroy-buffers t)
4131 (kill-local-variable 'mml-buffer-list))
4132 (gnus-summary-edit-article-done
4133 ,(or (mail-header-references gnus-current-headers) "")
4134 ,(gnus-group-read-only-p)
4135 ,gnus-summary-buffer no-highlight)))
4136 (gnus-article-edit-done)
4137 (gnus-summary-expand-window)
4138 (gnus-summary-show-article)))
4140 (defun gnus-mime-save-part-and-strip ()
4141 "Save the MIME part under point then replace it with an external body."
4143 (gnus-article-check-buffer)
4144 (when (gnus-group-read-only-p)
4145 (error "The current group does not support deleting of parts"))
4146 (when (mm-complicated-handles gnus-article-mime-handles)
4148 The current article has a complicated MIME structure, giving up..."))
4149 (when (gnus-yes-or-no-p "\
4150 Deleting parts may malfunction or destroy the article; continue? ")
4151 (let* ((data (get-text-property (point) 'gnus-data))
4153 (handles gnus-article-mime-handles))
4154 (setq file (and data (mm-save-part data)))
4156 (with-current-buffer (mm-handle-buffer data)
4158 (insert "Content-Type: " (mm-handle-media-type data))
4159 (mml-insert-parameter-string (cdr (mm-handle-type data))
4162 (insert "Content-ID: " (message-make-message-id) "\n")
4163 (insert "Content-Transfer-Encoding: binary\n")
4166 (cdr (mm-make-handle nil
4167 `("message/external-body"
4168 (access-type . "LOCAL-FILE")
4170 (set-buffer gnus-summary-buffer)
4171 (gnus-article-edit-part handles)))))
4173 (defun gnus-mime-delete-part ()
4174 "Delete the MIME part under point.
4175 Replace it with some information about the removed part."
4177 (gnus-article-check-buffer)
4178 (when (gnus-group-read-only-p)
4179 (error "The current group does not support deleting of parts"))
4180 (when (mm-complicated-handles gnus-article-mime-handles)
4182 The current article has a complicated MIME structure, giving up..."))
4183 (when (gnus-yes-or-no-p "\
4184 Deleting parts may malfunction or destroy the article; continue? ")
4185 (let* ((data (get-text-property (point) 'gnus-data))
4186 (handles gnus-article-mime-handles)
4190 (mail-decode-encoded-word-string (or (mm-handle-description data)
4193 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4195 (type (mm-handle-media-type data)))
4197 (error "No MIME part under point"))
4198 (with-current-buffer (mm-handle-buffer data)
4199 (let ((bsize (format "%s" (buffer-size))))
4204 "| The following attachment has been deleted:\n"
4206 "| Type: " type "\n"
4207 "| Filename: " filename "\n"
4208 "| Size (encoded): " bsize " Byte\n"
4209 "| Description: " description "\n"
4212 (cdr (mm-make-handle
4213 nil `("text/plain") nil nil
4215 (format "Deleted attachment (%s bytes)" bsize))))))
4216 (set-buffer gnus-summary-buffer)
4217 (gnus-article-edit-part handles))))
4219 (defun gnus-mime-save-part ()
4220 "Save the MIME part under point."
4222 (gnus-article-check-buffer)
4223 (let ((data (get-text-property (point) 'gnus-data)))
4225 (mm-save-part data))))
4227 (defun gnus-mime-pipe-part ()
4228 "Pipe the MIME part under point to a process."
4230 (gnus-article-check-buffer)
4231 (let ((data (get-text-property (point) 'gnus-data)))
4233 (mm-pipe-part data))))
4235 (defun gnus-mime-view-part ()
4236 "Interactively choose a viewing method for the MIME part under point."
4238 (gnus-article-check-buffer)
4239 (let ((data (get-text-property (point) 'gnus-data)))
4241 (setq gnus-article-mime-handles
4243 gnus-article-mime-handles (setq data (copy-sequence data))))
4244 (mm-interactively-view-part data))))
4246 (defun gnus-mime-view-part-as-type-internal ()
4247 (gnus-article-check-buffer)
4248 (let* ((name (mail-content-type-get
4249 (mm-handle-type (get-text-property (point) 'gnus-data))
4251 (def-type (and name (mm-default-file-encoding name))))
4252 (and def-type (cons def-type 0))))
4254 (defun gnus-mime-view-part-as-type (&optional mime-type)
4255 "Choose a MIME media type, and view the part as such."
4258 (setq mime-type (completing-read
4259 "View as MIME type: "
4260 (mapcar #'list (mailcap-mime-types))
4262 (gnus-mime-view-part-as-type-internal))))
4263 (gnus-article-check-buffer)
4264 (let ((handle (get-text-property (point) 'gnus-data)))
4267 (mm-make-handle (mm-handle-buffer handle)
4268 (cons mime-type (cdr (mm-handle-type handle)))
4269 (mm-handle-encoding handle)
4270 (mm-handle-undisplayer handle)
4271 (mm-handle-disposition handle)
4272 (mm-handle-description handle)
4274 (mm-handle-id handle)))
4275 (setq gnus-article-mime-handles
4276 (mm-merge-handles gnus-article-mime-handles handle))
4277 (gnus-mm-display-part handle))))
4279 (defun gnus-mime-copy-part (&optional handle arg)
4280 "Put the MIME part under point into a new buffer.
4281 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4283 (interactive (list nil current-prefix-arg))
4284 (gnus-article-check-buffer)
4286 (setq handle (get-text-property (point) 'gnus-data)))
4288 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4290 (mail-content-type-get (mm-handle-disposition handle)
4292 contents dont-decode charset coding-system)
4293 (mm-with-unibyte-buffer
4294 (mm-insert-part handle)
4295 (setq contents (or (condition-case nil
4296 (mm-decompress-buffer filename nil 'sig)
4298 (setq dont-decode t)
4301 (setq filename (cond (filename (file-name-nondirectory filename))
4302 (dont-decode "*raw data*")
4307 (unless (setq charset (mail-content-type-get
4308 (mm-handle-type handle) 'charset))
4309 (unless (setq coding-system (mm-with-unibyte-buffer
4311 (mm-find-buffer-file-coding-system)))
4312 (setq charset gnus-newsgroup-charset))))
4314 (setq charset (or (cdr (assq arg
4315 gnus-summary-show-article-charset-alist))
4316 (mm-read-coding-system "Charset: ")))))
4317 (switch-to-buffer (generate-new-buffer filename))
4318 (if (or coding-system
4320 (setq coding-system (mm-charset-to-coding-system charset))
4321 (not (eq charset 'ascii))))
4323 (mm-enable-multibyte)
4324 (insert (mm-decode-coding-string contents coding-system))
4325 (setq buffer-file-coding-system
4326 (if (boundp 'last-coding-system-used)
4327 (symbol-value 'last-coding-system-used)
4329 (mm-disable-multibyte)
4331 (setq buffer-file-coding-system mm-binary-coding-system))
4332 ;; We do it this way to make `normal-mode' set the appropriate mode.
4335 (setq buffer-file-name (expand-file-name filename))
4337 (setq buffer-file-name nil))
4338 (goto-char (point-min)))))
4340 (defun gnus-mime-print-part (&optional handle filename)
4341 "Print the MIME part under point."
4342 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4343 (gnus-article-check-buffer)
4344 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4345 (contents (and handle (mm-get-part handle)))
4346 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4347 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4352 (mm-save-part-to-file handle file)
4353 (call-process shell-file-name nil
4354 (generate-new-buffer " *mm*")
4356 shell-command-switch
4358 printer file (mm-handle-type handle))))
4362 (gnus-print-buffer))
4363 (ps-despool filename)))))
4365 (defun gnus-mime-inline-part (&optional handle arg)
4366 "Insert the MIME part under point into the current buffer.
4367 Compressed files like .gz and .bz2 are decompressed."
4368 (interactive (list nil current-prefix-arg))
4369 (gnus-article-check-buffer)
4371 (setq handle (get-text-property (point) 'gnus-data)))
4374 (inhibit-read-only t)
4375 contents charset coding-system)
4376 (if (and (not arg) (mm-handle-undisplayer handle))
4377 (mm-remove-part handle)
4378 (mm-with-unibyte-buffer
4379 (mm-insert-part handle)
4381 (or (mm-decompress-buffer
4382 (or (mail-content-type-get (mm-handle-disposition handle)
4384 (mail-content-type-get (mm-handle-disposition handle)
4390 (unless (setq charset (mail-content-type-get
4391 (mm-handle-type handle) 'charset))
4392 (unless (setq coding-system
4393 (mm-with-unibyte-buffer
4395 (mm-find-buffer-file-coding-system)))
4396 (setq charset gnus-newsgroup-charset))))
4398 (if (mm-handle-undisplayer handle)
4399 (mm-remove-part handle))
4402 gnus-summary-show-article-charset-alist))
4403 (mm-read-coding-system "Charset: "))))
4405 (if (mm-handle-undisplayer handle)
4406 (mm-remove-part handle))))
4410 (if (or coding-system
4413 (mm-charset-to-coding-system charset))
4414 (not (eq coding-system 'ascii))))
4415 (mm-decode-coding-string contents coding-system)
4416 (mm-string-to-multibyte contents)))
4419 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4420 "Insert the MIME part under point into the current buffer using the
4422 (interactive (list nil current-prefix-arg))
4423 (gnus-article-check-buffer)
4424 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4427 (inhibit-read-only t))
4429 (if (mm-handle-undisplayer handle)
4430 (mm-remove-part handle))
4431 (let ((gnus-newsgroup-charset
4433 gnus-summary-show-article-charset-alist))
4434 (mm-read-coding-system "Charset: ")))
4435 (gnus-newsgroup-ignored-charsets 'gnus-all))
4436 (gnus-article-press-button)))))
4438 (defun gnus-mime-view-part-externally (&optional handle)
4439 "View the MIME part under point with an external viewer."
4441 (gnus-article-check-buffer)
4442 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4443 (mm-user-display-methods nil)
4444 (mm-inlined-types nil)
4445 (mail-parse-charset gnus-newsgroup-charset)
4446 (mail-parse-ignored-charsets
4447 (with-current-buffer gnus-summary-buffer
4448 gnus-newsgroup-ignored-charsets)))
4450 (if (mm-handle-undisplayer handle)
4451 (mm-remove-part handle)
4452 (mm-display-part handle)))))
4454 (defun gnus-mime-view-part-internally (&optional handle)
4455 "View the MIME part under point with an internal viewer.
4456 If no internal viewer is available, use an external viewer."
4458 (gnus-article-check-buffer)
4459 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4460 (mm-inlined-types '(".*"))
4461 (mm-inline-large-images t)
4462 (mail-parse-charset gnus-newsgroup-charset)
4463 (mail-parse-ignored-charsets
4464 (with-current-buffer gnus-summary-buffer
4465 gnus-newsgroup-ignored-charsets))
4466 (inhibit-read-only t))
4468 (if (mm-handle-undisplayer handle)
4469 (mm-remove-part handle)
4470 (mm-display-part handle)))))
4472 (defun gnus-mime-action-on-part (&optional action)
4473 "Do something with the MIME attachment at \(point\)."
4475 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4476 (gnus-article-check-buffer)
4477 (let ((action-pair (assoc action gnus-mime-action-alist)))
4479 (funcall (cdr action-pair)))))
4481 (defun gnus-article-part-wrapper (n function)
4482 (with-current-buffer gnus-article-buffer
4483 (when (> n (length gnus-article-mime-handle-alist))
4484 (error "No such part"))
4485 (gnus-article-goto-part n)
4486 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4487 (funcall function handle))))
4489 (defun gnus-article-pipe-part (n)
4490 "Pipe MIME part N, which is the numerical prefix."
4492 (gnus-article-part-wrapper n 'mm-pipe-part))
4494 (defun gnus-article-save-part (n)
4495 "Save MIME part N, which is the numerical prefix."
4497 (gnus-article-part-wrapper n 'mm-save-part))
4499 (defun gnus-article-interactively-view-part (n)
4500 "View MIME part N interactively, which is the numerical prefix."
4502 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4504 (defun gnus-article-copy-part (n)
4505 "Copy MIME part N, which is the numerical prefix."
4507 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4509 (defun gnus-article-view-part-as-charset (n)
4510 "View MIME part N using a specified charset.
4511 N is the numerical prefix."
4513 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4515 (defun gnus-article-view-part-externally (n)
4516 "View MIME part N externally, which is the numerical prefix."
4518 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4520 (defun gnus-article-inline-part (n)
4521 "Inline MIME part N, which is the numerical prefix."
4523 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4525 (defun gnus-article-mime-match-handle-first (condition)
4528 (dolist (ihandle gnus-article-mime-handle-alist)
4530 ((functionp condition)
4531 (funcall condition (cdr ihandle)))
4532 ((eq condition 'undisplayed)
4533 (not (or (mm-handle-undisplayer (cdr ihandle))
4534 (equal (mm-handle-media-type (cdr ihandle))
4535 "multipart/alternative"))))
4536 ((eq condition 'undisplayed-alternative)
4537 (not (mm-handle-undisplayer (cdr ihandle))))
4539 (gnus-article-goto-part (car ihandle))
4540 (or (not n) (< (car ihandle) n)))
4541 (setq n (car ihandle))))
4545 (defun gnus-article-view-part (&optional n)
4546 "View MIME part N, which is the numerical prefix."
4548 (with-current-buffer gnus-article-buffer
4549 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4550 gnus-article-mime-match-handle-function)))
4551 (when (> n (length gnus-article-mime-handle-alist))
4552 (error "No such part"))
4553 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4554 (when (gnus-article-goto-part n)
4555 (if (equal (car handle) "multipart/alternative")
4556 (gnus-article-press-button)
4557 (when (eq (gnus-mm-display-part handle) 'internal)
4558 (gnus-set-window-start)))))))
4560 (defsubst gnus-article-mime-total-parts ()
4561 (if (bufferp (car gnus-article-mime-handles))
4563 (1- (length gnus-article-mime-handles))))
4565 (defun gnus-mm-display-part (handle)
4566 "Display HANDLE and fix MIME button."
4567 (let ((id (get-text-property (point) 'gnus-part))
4569 (inhibit-read-only t))
4572 (let ((window (selected-window))
4573 (mail-parse-charset gnus-newsgroup-charset)
4574 (mail-parse-ignored-charsets
4575 (if (gnus-buffer-live-p gnus-summary-buffer)
4576 (with-current-buffer gnus-summary-buffer
4577 gnus-newsgroup-ignored-charsets)
4581 (let ((win (gnus-get-buffer-window (current-buffer) t))
4584 (select-window win))
4587 (if (mm-handle-displayed-p handle)
4588 ;; This will remove the part.
4589 (mm-display-part handle)
4591 (narrow-to-region (point)
4592 (if (eobp) (point) (1+ (point))))
4593 (mm-display-part handle)
4594 ;; We narrow to the part itself and
4595 ;; then call the treatment functions.
4596 (goto-char (point-min))
4598 (narrow-to-region (point) (point-max))
4601 (gnus-article-mime-total-parts)
4602 (mm-handle-media-type handle)))))
4603 (if (window-live-p window)
4604 (select-window window)))))
4607 (gnus-insert-mime-button
4608 handle id (list (mm-handle-displayed-p handle)))
4609 (goto-char point))))
4611 (defun gnus-article-goto-part (n)
4612 "Go to MIME part N."
4613 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4615 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4616 (let ((gnus-tmp-name
4617 (or (mail-content-type-get (mm-handle-type handle) 'name)
4618 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4619 (mail-content-type-get (mm-handle-type handle) 'url)
4621 (gnus-tmp-type (mm-handle-media-type handle))
4622 (gnus-tmp-description
4623 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4626 (if (if displayed (car displayed)
4627 (mm-handle-displayed-p handle))
4629 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4631 gnus-tmp-type-long b e)
4632 (when (string-match ".*/" gnus-tmp-name)
4633 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4634 (setq gnus-tmp-type-long (concat gnus-tmp-type
4635 (and (not (equal gnus-tmp-name ""))
4636 (concat "; " gnus-tmp-name))))
4637 (unless (equal gnus-tmp-description "")
4638 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4643 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4644 `(keymap ,gnus-mime-button-map
4645 gnus-callback gnus-mm-display-part
4646 gnus-part ,gnus-tmp-id
4647 article-type annotation
4650 ;; Exclude a newline.
4653 (widget-convert-button
4656 :action 'gnus-widget-press-button
4657 :button-keymap gnus-mime-button-map
4659 (lambda (widget/window &optional overlay pos)
4660 ;; Needed to properly clear the message due to a bug in
4661 ;; wid-edit (XEmacs only).
4662 (if (boundp 'help-echo-owns-message)
4663 (setq help-echo-owns-message t))
4665 "%S: %s the MIME part; %S: more options"
4666 (aref gnus-mouse-2 0)
4667 ;; XEmacs will get a single widget arg; Emacs 21 will get
4668 ;; window, overlay, position.
4669 (if (mm-handle-displayed-p
4671 (with-current-buffer (gnus-overlay-buffer overlay)
4672 (widget-get (widget-at (gnus-overlay-start overlay))
4674 (widget-get widget/window :mime-handle)))
4676 (aref gnus-down-mouse-3 0))))))
4678 (defun gnus-widget-press-button (elems el)
4679 (goto-char (widget-get elems :from))
4680 (gnus-article-press-button))
4682 (defvar gnus-displaying-mime nil)
4684 (defun gnus-display-mime (&optional ihandles)
4685 "Display the MIME parts."
4687 (save-selected-window
4688 (let ((window (get-buffer-window gnus-article-buffer))
4691 (select-window window)
4692 ;; We have to do this since selecting the window
4693 ;; may change the point. So we set the window point.
4694 (set-window-point window point)))
4695 (let ((handles ihandles)
4696 (inhibit-read-only t)
4699 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
4700 (when gnus-article-emulate-mime
4701 (mm-uu-dissect-text-parts handles)))
4702 (gnus-article-emulate-mime
4703 (setq handles (mm-uu-dissect))))
4704 (when (and (not ihandles)
4705 (not gnus-displaying-mime))
4706 ;; Top-level call; we clean up.
4707 (when gnus-article-mime-handles
4708 (mm-destroy-parts gnus-article-mime-handles)
4709 (setq gnus-article-mime-handle-alist nil));; A trick.
4710 (setq gnus-article-mime-handles handles)
4711 ;; We allow users to glean info from the handles.
4712 (when gnus-article-mime-part-function
4713 (gnus-mime-part-function handles)))
4715 (or (not (stringp (car handles)))
4718 (when (and (not ihandles)
4719 (not gnus-displaying-mime))
4720 ;; Clean up for mime parts.
4722 (delete-region (point) (point-max)))
4723 (let ((gnus-displaying-mime t))
4724 (gnus-mime-display-part handles)))
4727 (narrow-to-region (point) (point-max))
4728 (gnus-treat-article nil 1 1)
4731 ;; Highlight the headers.
4735 (narrow-to-region (point-min) (point))
4736 (gnus-article-save-original-date
4737 (gnus-treat-article 'head)))))))))
4739 (defcustom gnus-mime-display-multipart-as-mixed nil
4740 "Display \"multipart\" parts as \"multipart/mixed\".
4742 If t, it overrides nil values of
4743 `gnus-mime-display-multipart-alternative-as-mixed' and
4744 `gnus-mime-display-multipart-related-as-mixed'."
4745 :group 'gnus-article-mime
4748 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4749 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4751 :group 'gnus-article-mime
4754 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4755 "Display \"multipart/related\" parts as \"multipart/mixed\".
4757 If displaying \"text/html\" is discouraged \(see
4758 `mm-discouraged-alternatives'\) images or other material inside a
4759 \"multipart/related\" part might be overlooked when this variable is nil."
4761 :group 'gnus-article-mime
4764 (defun gnus-mime-display-part (handle)
4767 ((not (stringp (car handle)))
4768 (gnus-mime-display-single handle))
4769 ;; User-defined multipart
4770 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4771 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4773 ;; multipart/alternative
4774 ((and (equal (car handle) "multipart/alternative")
4775 (not (or gnus-mime-display-multipart-as-mixed
4776 gnus-mime-display-multipart-alternative-as-mixed)))
4777 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4778 (push (cons id handle) gnus-article-mime-handle-alist)
4779 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4780 ;; multipart/related
4781 ((and (equal (car handle) "multipart/related")
4782 (not (or gnus-mime-display-multipart-as-mixed
4783 gnus-mime-display-multipart-related-as-mixed)))
4784 ;;;!!!We should find the start part, but we just default
4785 ;;;!!!to the first part.
4786 ;;(gnus-mime-display-part (cadr handle))
4787 ;;;!!! Most multipart/related is an HTML message plus images.
4788 ;;;!!! Unfortunately we are unable to let W3 display those
4789 ;;;!!! included images, so we just display it as a mixed multipart.
4790 ;;(gnus-mime-display-mixed (cdr handle))
4791 ;;;!!! No, w3 can display everything just fine.
4792 (gnus-mime-display-part (cadr handle)))
4793 ((equal (car handle) "multipart/signed")
4794 (gnus-add-wash-type 'signed)
4795 (gnus-mime-display-security handle))
4796 ((equal (car handle) "multipart/encrypted")
4797 (gnus-add-wash-type 'encrypted)
4798 (gnus-mime-display-security handle))
4799 ;; Other multiparts are handled like multipart/mixed.
4801 (gnus-mime-display-mixed (cdr handle)))))
4803 (defun gnus-mime-part-function (handles)
4804 (if (stringp (car handles))
4805 (mapcar 'gnus-mime-part-function (cdr handles))
4806 (funcall gnus-article-mime-part-function handles)))
4808 (defun gnus-mime-display-mixed (handles)
4809 (mapcar 'gnus-mime-display-part handles))
4811 (defun gnus-mime-display-single (handle)
4812 (let ((type (mm-handle-media-type handle))
4813 (ignored gnus-ignored-mime-types)
4820 (when (string-match (pop ignored) type)
4821 (throw 'ignored nil)))
4822 (if (and (setq not-attachment
4823 (and (not (mm-inline-override-p handle))
4824 (or (not (mm-handle-disposition handle))
4825 (equal (car (mm-handle-disposition handle))
4827 (mm-attachment-override-p handle))))
4828 (mm-automatic-display-p handle)
4830 (mm-inlinable-p handle)
4831 (mm-inlined-p handle))
4832 (mm-automatic-external-display-p type)))
4834 (when (equal (mm-handle-media-supertype handle) "text")
4836 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4838 (push (cons id handle) gnus-article-mime-handle-alist)
4839 (when (or (not display)
4840 (not (gnus-unbuttonized-mime-type-p type)))
4841 (gnus-insert-mime-button
4842 handle id (list (or display (and not-attachment text))))
4843 (gnus-article-insert-newline)
4844 ;; Remember modify the number of forward lines.
4852 (let ((mail-parse-charset gnus-newsgroup-charset)
4853 (mail-parse-ignored-charsets
4854 (save-excursion (condition-case ()
4855 (set-buffer gnus-summary-buffer)
4857 gnus-newsgroup-ignored-charsets)))
4858 (mm-display-part handle t))
4859 (goto-char (point-max)))
4860 ((and text not-attachment)
4864 (gnus-article-insert-newline)
4865 (mm-display-inline handle)
4866 (goto-char (point-max))))
4870 (narrow-to-region beg (point))
4873 (gnus-article-mime-total-parts)
4874 (mm-handle-media-type handle)))))))))
4876 (defun gnus-unbuttonized-mime-type-p (type)
4877 "Say whether TYPE is to be unbuttonized."
4878 (unless gnus-inhibit-mime-unbuttonizing
4880 (let ((types gnus-unbuttonized-mime-types))
4882 (when (string-match (pop types) type)
4883 (throw 'found t)))))
4885 (let ((types gnus-buttonized-mime-types))
4887 (when (string-match (pop types) type)
4888 (throw 'found t)))))))))
4890 (defun gnus-article-insert-newline ()
4891 "Insert a newline, but mark it as undeletable."
4892 (gnus-put-text-property
4893 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4895 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4896 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4899 handle (inhibit-read-only t) from props begend not-pref)
4900 (save-window-excursion
4903 (narrow-to-region (car ibegend)
4906 (goto-char (car ibegend))
4909 (delete-region (point-min) (point-max))
4910 (mm-remove-parts handles))
4911 (setq begend (list (point-marker)))
4913 (unless (setq not-pref (cadr (member preferred ihandles)))
4914 (setq not-pref (car ihandles)))
4917 (not (gnus-unbuttonized-mime-type-p
4918 "multipart/alternative")))
4919 (gnus-add-text-properties
4922 (insert (format "%d. " id))
4926 (unless ,(not ibegend)
4927 (setq gnus-article-mime-handle-alist
4928 ',gnus-article-mime-handle-alist))
4929 (gnus-mime-display-alternative
4930 ',ihandles ',not-pref ',begend ,id))
4931 keymap ,gnus-mime-button-map
4932 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4933 face ,gnus-article-button-face
4936 (widget-convert-button 'link from (point)
4937 :action 'gnus-widget-press-button
4938 :button-keymap gnus-widget-button-keymap)
4940 (while (setq handle (pop handles))
4941 (gnus-add-text-properties
4944 (insert (format "(%c) %-18s"
4945 (if (equal handle preferred) ?* ? )
4946 (mm-handle-media-type handle)))
4950 (unless ,(not ibegend)
4951 (setq gnus-article-mime-handle-alist
4952 ',gnus-article-mime-handle-alist))
4953 (gnus-mime-display-alternative
4954 ',ihandles ',handle ',begend ,id))
4955 keymap ,gnus-mime-button-map
4956 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4957 face ,gnus-article-button-face
4960 (widget-convert-button 'link from (point)
4961 :action 'gnus-widget-press-button
4962 :button-keymap gnus-widget-button-keymap)
4966 (if (stringp (car preferred))
4967 (gnus-display-mime preferred)
4968 (let ((mail-parse-charset gnus-newsgroup-charset)
4969 (mail-parse-ignored-charsets
4970 (with-current-buffer gnus-summary-buffer
4971 gnus-newsgroup-ignored-charsets)))
4972 (mm-display-part preferred)
4976 (narrow-to-region (car begend) (point-max))
4978 nil (length gnus-article-mime-handle-alist)
4979 (gnus-article-mime-total-parts)
4980 (mm-handle-media-type handle))))))
4981 (goto-char (point-max))
4982 (setcdr begend (point-marker)))))
4984 (goto-char point))))
4986 (defconst gnus-article-wash-status-strings
4987 (let ((alist '((cite "c" "Possible hidden citation text"
4988 " " "All citation text visible")
4989 (headers "h" "Hidden headers"
4990 " " "All headers visible.")
4991 (pgp "p" "Encrypted or signed message status hidden"
4992 " " "No hidden encryption nor digital signature status")
4993 (signature "s" "Signature has been hidden"
4994 " " "Signature is visible")
4995 (overstrike "o" "Overstrike (^H) characters applied"
4996 " " "No overstrike characters applied")
4997 (emphasis "e" "/*_Emphasis_*/ characters applied"
4998 " " "No /*_emphasis_*/ characters applied")))
5000 (dolist (entry alist result)
5001 (let ((key (nth 0 entry))
5002 (on (copy-sequence (nth 1 entry)))
5003 (on-help (nth 2 entry))
5004 (off (copy-sequence (nth 3 entry)))
5005 (off-help (nth 4 entry)))
5006 (put-text-property 0 1 'help-echo on-help on)
5007 (put-text-property 0 1 'help-echo off-help off)
5008 (push (list key on off) result))))
5009 "Alist of strings describing wash status in the mode line.
5010 Each entry has the form (KEY ON OF), where the KEY is a symbol
5011 representing the particular washing function, ON is the string to use
5012 in the article mode line when the washing function is active, and OFF
5013 is the string to use when it is inactive.")
5015 (defun gnus-article-wash-status-entry (key value)
5016 (let ((entry (assoc key gnus-article-wash-status-strings)))
5017 (if value (nth 1 entry) (nth 2 entry))))
5019 (defun gnus-article-wash-status ()
5020 "Return a string which display status of article washing."
5021 (with-current-buffer gnus-article-buffer
5022 (let ((cite (memq 'cite gnus-article-wash-types))
5023 (headers (memq 'headers gnus-article-wash-types))
5024 (boring (memq 'boring-headers gnus-article-wash-types))
5025 (pgp (memq 'pgp gnus-article-wash-types))
5026 (pem (memq 'pem gnus-article-wash-types))
5027 (signed (memq 'signed gnus-article-wash-types))
5028 (encrypted (memq 'encrypted gnus-article-wash-types))
5029 (signature (memq 'signature gnus-article-wash-types))
5030 (overstrike (memq 'overstrike gnus-article-wash-types))
5031 (emphasis (memq 'emphasis gnus-article-wash-types)))
5033 (gnus-article-wash-status-entry 'cite cite)
5034 (gnus-article-wash-status-entry 'headers (or headers boring))
5035 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5036 (gnus-article-wash-status-entry 'signature signature)
5037 (gnus-article-wash-status-entry 'overstrike overstrike)
5038 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5040 (defun gnus-add-wash-type (type)
5041 "Add a washing of TYPE to the current status."
5042 (add-to-list 'gnus-article-wash-types type))
5044 (defun gnus-delete-wash-type (type)
5045 "Add a washing of TYPE to the current status."
5046 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5048 (defun gnus-add-image (category image)
5049 "Add IMAGE of CATEGORY to the list of displayed images."
5050 (let ((entry (assq category gnus-article-image-alist)))
5052 (setq entry (list category))
5053 (push entry gnus-article-image-alist))
5054 (nconc entry (list image))))
5056 (defun gnus-delete-images (category)
5057 "Delete all images in CATEGORY."
5058 (let ((entry (assq category gnus-article-image-alist)))
5059 (dolist (image (cdr entry))
5060 (gnus-remove-image image category))
5061 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5062 (gnus-delete-wash-type category)))
5064 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5066 (defun gnus-article-maybe-hide-headers ()
5067 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5068 Provided for backwards compatibility."
5069 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5070 (not (with-current-buffer gnus-summary-buffer
5071 gnus-have-all-headers)))
5072 (not gnus-inhibit-hiding))
5073 (gnus-article-hide-headers)))
5077 (defun gnus-output-to-file (file-name)
5078 "Append the current article to a file named FILE-NAME."
5079 (let ((artbuf (current-buffer)))
5081 (insert-buffer-substring artbuf)
5082 ;; Append newline at end of the buffer as separator, and then
5084 (goto-char (point-max))
5086 (let ((file-name-coding-system nnmail-pathname-coding-system))
5087 (mm-append-to-file (point-min) (point-max) file-name))
5090 (defun gnus-narrow-to-page (&optional arg)
5091 "Narrow the article buffer to a page.
5092 If given a numerical ARG, move forward ARG pages."
5094 (setq arg (if arg (prefix-numeric-value arg) 0))
5096 (set-buffer gnus-article-buffer)
5097 (goto-char (point-min))
5099 ;; Remove any old next/prev buttons.
5100 (when (gnus-visual-p 'page-marker)
5101 (let ((inhibit-read-only t))
5102 (gnus-remove-text-with-property 'gnus-prev)
5103 (gnus-remove-text-with-property 'gnus-next)))
5106 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5108 (re-search-forward page-delimiter nil 'move arg)))
5109 (goto-char (match-end 0))
5111 (goto-char (point-min))
5112 (setq gnus-page-broken
5113 (and (re-search-forward page-delimiter nil t) t))))
5114 (when gnus-page-broken
5117 (if (re-search-forward page-delimiter nil 'move)
5120 (when (and (gnus-visual-p 'page-marker)
5121 (> (point-min) (save-restriction (widen) (point-min))))
5123 (goto-char (point-min))
5124 (gnus-insert-prev-page-button)))
5125 (when (and (gnus-visual-p 'page-marker)
5126 (< (point-max) (save-restriction (widen) (point-max))))
5128 (goto-char (point-max))
5129 (gnus-insert-next-page-button))))))
5131 ;; Article mode commands
5133 (defun gnus-article-goto-next-page ()
5134 "Show the next page of the article."
5136 (when (gnus-article-next-page)
5137 (goto-char (point-min))
5138 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5141 (defun gnus-article-goto-prev-page ()
5142 "Show the previous page of the article."
5145 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5146 (gnus-article-prev-page nil)))
5148 ;; This is cleaner but currently breaks `gnus-pick-mode':
5150 ;; (defun gnus-article-goto-next-page ()
5151 ;; "Show the next page of the article."
5153 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5154 ;; (gnus-summary-next-page)))
5156 ;; (defun gnus-article-goto-prev-page ()
5157 ;; "Show the next page of the article."
5159 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5160 ;; (gnus-summary-prev-page)))
5162 (defun gnus-article-next-page (&optional lines)
5163 "Show the next page of the current article.
5164 If end of article, return non-nil. Otherwise return nil.
5165 Argument LINES specifies lines to be scrolled up."
5167 (move-to-window-line -1)
5170 (and (pos-visible-in-window-p) ;Not continuation line.
5171 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5172 ;; Nothing in this page.
5173 (if (or (not gnus-page-broken)
5178 (eobp)))) ;Real end-of-buffer?
5180 (when gnus-article-over-scroll
5181 (gnus-article-next-page-1 lines))
5183 (gnus-narrow-to-page 1) ;Go to next page.
5185 ;; More in this page.
5186 (gnus-article-next-page-1 lines)
5189 (defmacro gnus-article-beginning-of-window ()
5190 "Move point to the beginning of the window.
5191 In Emacs, the point is placed at the line number which `scroll-margin'
5193 (if (featurep 'xemacs)
5194 '(move-to-window-line 0)
5195 '(move-to-window-line
5196 (min (max 0 scroll-margin)
5197 (max 1 (- (window-height)
5198 (if mode-line-format 1 0)
5199 (if header-line-format 1 0)))))))
5201 (defun gnus-article-next-page-1 (lines)
5202 (when (and (not (featurep 'xemacs))
5205 (numberp (symbol-value 'scroll-margin))
5206 (> (symbol-value 'scroll-margin) 0))
5207 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5208 ;; too many number of lines if `scroll-margin' is set as two or greater.
5209 (setq lines (min lines
5210 (max 0 (- (count-lines (window-start) (point-max))
5211 (symbol-value 'scroll-margin))))))
5213 (let ((scroll-in-place nil))
5216 ;; Long lines may cause an end-of-buffer error.
5217 (goto-char (point-max))))
5218 (gnus-article-beginning-of-window))
5220 (defun gnus-article-prev-page (&optional lines)
5221 "Show previous page of current article.
5222 Argument LINES specifies lines to be scrolled down."
5224 (move-to-window-line 0)
5225 (if (and gnus-page-broken
5227 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5229 (gnus-narrow-to-page -1) ;Go to previous page.
5230 (goto-char (point-max))
5234 (let ((scroll-in-place nil))
5235 (scroll-down lines))
5236 (beginning-of-buffer
5237 (goto-char (point-min))))
5238 (gnus-article-beginning-of-window))))
5240 (defun gnus-article-only-boring-p ()
5241 "Decide whether there is only boring text remaining in the article.
5242 Something \"interesting\" is a word of at least two letters that does
5243 not have a face in `gnus-article-boring-faces'."
5244 (when (and gnus-article-skip-boring
5245 (boundp 'gnus-article-boring-faces)
5246 (symbol-value 'gnus-article-boring-faces))
5249 (while (re-search-forward "\\b\\w\\w" nil t)
5251 (when (not (gnus-intersection
5252 (gnus-faces-at (point))
5253 (symbol-value 'gnus-article-boring-faces)))
5254 (throw 'only-boring nil)))
5255 (throw 'only-boring t)))))
5257 (defun gnus-article-refer-article ()
5258 "Read article specified by message-id around point."
5261 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5262 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5263 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5264 (let ((msg-id (concat "<" (match-string 0) ">")))
5265 (set-buffer gnus-summary-buffer)
5266 (gnus-summary-refer-article msg-id))
5267 (error "No references around point"))))
5269 (defun gnus-article-show-summary ()
5270 "Reconfigure windows to show summary buffer."
5272 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5273 (error "There is no summary buffer for this article buffer")
5274 (gnus-article-set-globals)
5275 (gnus-configure-windows 'article)
5276 (gnus-summary-goto-subject gnus-current-article)
5277 (gnus-summary-position-point)))
5279 (defun gnus-article-describe-briefly ()
5280 "Describe article mode commands briefly."
5282 (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")))
5284 (defun gnus-article-summary-command ()
5285 "Execute the last keystroke in the summary buffer."
5287 (let ((obuf (current-buffer))
5288 (owin (current-window-configuration))
5290 (switch-to-buffer gnus-article-current-summary 'norecord)
5291 (setq func (lookup-key (current-local-map) (this-command-keys)))
5292 (call-interactively func)
5294 (set-window-configuration owin)
5295 (set-window-point (get-buffer-window (current-buffer)) (point))))
5297 (defun gnus-article-summary-command-nosave ()
5298 "Execute the last keystroke in the summary buffer."
5301 (pop-to-buffer gnus-article-current-summary 'norecord)
5302 (setq func (lookup-key (current-local-map) (this-command-keys)))
5303 (call-interactively func)))
5305 (defun gnus-article-check-buffer ()
5306 "Beep if not in an article buffer."
5307 (unless (equal major-mode 'gnus-article-mode)
5308 (error "Command invoked outside of a Gnus article buffer")))
5310 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5311 "Read a summary buffer key sequence and execute it from the article buffer."
5313 (gnus-article-check-buffer)
5315 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5316 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5317 "=" "^" "\M-^" "|"))
5323 '("n" "Gn" "p" "Gp"))
5326 (set-buffer gnus-article-current-summary)
5327 (let (gnus-pick-mode)
5328 (push (or key last-command-event) unread-command-events)
5329 (setq keys (if (featurep 'xemacs)
5330 (events-to-keys (read-key-sequence nil))
5331 (read-key-sequence nil)))))
5335 (if (or (member keys nosaves)
5336 (member keys nosave-but-article)
5337 (member keys nosave-in-article))
5339 (save-window-excursion
5340 (pop-to-buffer gnus-article-current-summary 'norecord)
5341 ;; We disable the pick minor mode commands.
5342 (let (gnus-pick-mode)
5343 (setq func (lookup-key (current-local-map) keys))))
5347 (unless (member keys nosave-in-article)
5348 (set-buffer gnus-article-current-summary))
5349 (call-interactively func)
5350 (setq new-sum-point (point)))
5351 (when (member keys nosave-but-article)
5352 (pop-to-buffer gnus-article-buffer 'norecord)))
5353 ;; These commands should restore window configuration.
5354 (let ((obuf (current-buffer))
5355 (owin (current-window-configuration))
5357 win func in-buffer selected new-sum-start new-sum-hscroll)
5358 (cond (not-restore-window
5359 (pop-to-buffer gnus-article-current-summary 'norecord))
5360 ((setq win (get-buffer-window gnus-article-current-summary))
5361 (select-window win))
5363 (switch-to-buffer gnus-article-current-summary 'norecord)))
5364 (setq in-buffer (current-buffer))
5365 ;; We disable the pick minor mode commands.
5366 (if (and (setq func (let (gnus-pick-mode)
5367 (lookup-key (current-local-map) keys)))
5370 (call-interactively func)
5371 (when (eq win (selected-window))
5372 (setq new-sum-point (point)
5373 new-sum-start (window-start win)
5374 new-sum-hscroll (window-hscroll win)))
5375 (when (eq in-buffer (current-buffer))
5376 (setq selected (gnus-summary-select-article))
5378 (unless not-restore-window
5379 (set-window-configuration owin))
5380 (when (eq selected 'old)
5382 (set-window-start (get-buffer-window (current-buffer))
5384 (set-window-point (get-buffer-window (current-buffer))
5386 (when (and (not not-restore-window)
5388 (set-window-point win new-sum-point)
5389 (set-window-start win new-sum-start)
5390 (set-window-hscroll win new-sum-hscroll))))
5391 (set-window-configuration owin)
5394 (defun gnus-article-describe-key (key)
5395 "Display documentation of the function invoked by KEY. KEY is a string."
5396 (interactive "kDescribe key: ")
5397 (gnus-article-check-buffer)
5398 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5400 (set-buffer gnus-article-current-summary)
5401 (let (gnus-pick-mode)
5402 (if (featurep 'xemacs)
5404 (push (elt key 0) unread-command-events)
5405 (setq key (events-to-keys
5406 (read-key-sequence "Describe key: "))))
5407 (setq unread-command-events
5409 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5410 (string-to-list key)))
5411 (setq key (read-key-sequence "Describe key: "))))
5413 (describe-key key)))
5415 (defun gnus-article-describe-key-briefly (key &optional insert)
5416 "Display documentation of the function invoked by KEY. KEY is a string."
5417 (interactive "kDescribe key: \nP")
5418 (gnus-article-check-buffer)
5419 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5421 (set-buffer gnus-article-current-summary)
5422 (let (gnus-pick-mode)
5423 (if (featurep 'xemacs)
5425 (push (elt key 0) unread-command-events)
5426 (setq key (events-to-keys
5427 (read-key-sequence "Describe key: "))))
5428 (setq unread-command-events
5430 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5431 (string-to-list key)))
5432 (setq key (read-key-sequence "Describe key: "))))
5433 (describe-key-briefly key insert))
5434 (describe-key-briefly key insert)))
5436 (defun gnus-article-reply-with-original (&optional wide)
5437 "Start composing a reply mail to the current message.
5438 The text in the region will be yanked. If the region isn't active,
5439 the entire article will be yanked."
5441 (let ((article (cdr gnus-article-current))
5443 (if (not (gnus-region-active-p))
5444 (with-current-buffer gnus-summary-buffer
5445 (gnus-summary-reply (list (list article)) wide))
5446 (setq contents (buffer-substring (point) (mark t)))
5447 ;; Deactivate active regions.
5448 (when (and (boundp 'transient-mark-mode)
5449 transient-mark-mode)
5450 (setq mark-active nil))
5451 (with-current-buffer gnus-summary-buffer
5453 (list (list article contents)) wide)))))
5455 (defun gnus-article-followup-with-original ()
5456 "Compose a followup to the current article.
5457 The text in the region will be yanked. If the region isn't active,
5458 the entire article will be yanked."
5460 (let ((article (cdr gnus-article-current))
5462 (if (not (gnus-region-active-p))
5463 (with-current-buffer gnus-summary-buffer
5464 (gnus-summary-followup (list (list article))))
5465 (setq contents (buffer-substring (point) (mark t)))
5466 ;; Deactivate active regions.
5467 (when (and (boundp 'transient-mark-mode)
5468 transient-mark-mode)
5469 (setq mark-active nil))
5470 (with-current-buffer gnus-summary-buffer
5471 (gnus-summary-followup
5472 (list (list article contents)))))))
5474 (defun gnus-article-hide (&optional arg force)
5475 "Hide all the gruft in the current article.
5476 This means that signatures, cited text and (some) headers will be
5478 If given a prefix, show the hidden text instead."
5479 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5480 (gnus-article-hide-headers arg)
5481 (gnus-article-hide-list-identifiers arg)
5482 (gnus-article-hide-citation-maybe arg force)
5483 (gnus-article-hide-signature arg))
5485 (defun gnus-article-maybe-highlight ()
5486 "Do some article highlighting if article highlighting is requested."
5487 (when (gnus-visual-p 'article-highlight 'highlight)
5488 (gnus-article-highlight-some)))
5490 (defun gnus-check-group-server ()
5491 ;; Make sure the connection to the server is alive.
5492 (unless (gnus-server-opened
5493 (gnus-find-method-for-group gnus-newsgroup-name))
5494 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5495 (gnus-request-group gnus-newsgroup-name t)))
5498 (autoload 'nneething-get-file-name "nneething"))
5500 (defun gnus-request-article-this-buffer (article group)
5501 "Get an article and insert it into this buffer."
5502 (let (do-update-line sparse-header)
5506 (gnus-kill-all-overlays)
5507 (setq group (or group gnus-newsgroup-name))
5509 ;; Using `gnus-request-article' directly will insert the article into
5510 ;; `nntp-server-buffer' - so we'll save some time by not having to
5511 ;; copy it from the server buffer into the article buffer.
5513 ;; We only request an article by message-id when we do not have the
5514 ;; headers for it, so we'll have to get those.
5515 (when (stringp article)
5516 (gnus-read-header article))
5518 ;; If the article number is negative, that means that this article
5519 ;; doesn't belong in this newsgroup (possibly), so we find its
5520 ;; message-id and request it by id instead of number.
5521 (when (and (numberp article)
5523 (get-buffer gnus-summary-buffer)
5524 (gnus-buffer-exists-p gnus-summary-buffer))
5526 (set-buffer gnus-summary-buffer)
5527 (let ((header (gnus-summary-article-header article)))
5530 ((memq article gnus-newsgroup-sparse)
5531 ;; This is a sparse gap article.
5532 (setq do-update-line article)
5533 (setq article (mail-header-id header))
5534 (setq sparse-header (gnus-read-header article))
5535 (setq gnus-newsgroup-sparse
5536 (delq article gnus-newsgroup-sparse)))
5538 ;; It's a real article.
5539 (setq article (mail-header-id header)))
5541 ;; It is an extracted pseudo-article.
5542 (setq article 'pseudo)
5543 (gnus-request-pseudo-article header))))
5545 (let ((method (gnus-find-method-for-group
5546 gnus-newsgroup-name)))
5547 (when (and (eq (car method) 'nneething)
5549 (let ((dir (nneething-get-file-name
5550 (mail-header-id header))))
5551 (when (and (stringp dir)
5552 (file-directory-p dir))
5553 (setq article 'nneething)
5554 (gnus-group-enter-directory dir))))))))
5557 ;; Refuse to select canceled articles.
5558 ((and (numberp article)
5560 (get-buffer gnus-summary-buffer)
5561 (gnus-buffer-exists-p gnus-summary-buffer)
5562 (eq (cdr (with-current-buffer gnus-summary-buffer
5563 (assq article gnus-newsgroup-reads)))
5564 gnus-canceled-mark))
5566 ;; We first check `gnus-original-article-buffer'.
5567 ((and (get-buffer gnus-original-article-buffer)
5569 (with-current-buffer gnus-original-article-buffer
5570 (and (equal (car gnus-original-article) group)
5571 (eq (cdr gnus-original-article) article))))
5572 (insert-buffer-substring gnus-original-article-buffer)
5574 ;; Check the backlog.
5575 ((and gnus-keep-backlog
5576 (gnus-backlog-request-article group article (current-buffer)))
5578 ;; Check asynchronous pre-fetch.
5579 ((gnus-async-request-fetched-article group article (current-buffer))
5580 (gnus-async-prefetch-next group article gnus-summary-buffer)
5581 (when (and (numberp article) gnus-keep-backlog)
5582 (gnus-backlog-enter-article group article (current-buffer)))
5585 ((and gnus-use-cache
5587 (gnus-cache-request-article article group))
5589 ;; Check the agent cache.
5590 ((gnus-agent-request-article article group)
5592 ;; Get the article and put into the article buffer.
5593 ((or (stringp article)
5595 (let ((gnus-override-method gnus-override-method)
5596 (methods (and (stringp article)
5597 gnus-refer-article-method))
5598 (backend (car (gnus-find-method-for-group
5599 gnus-newsgroup-name)))
5601 (inhibit-read-only t))
5602 (if (or (not (listp methods))
5603 (and (symbolp (car methods))
5604 (assq (car methods) nnoo-definition-alist)))
5605 (setq methods (list methods)))
5606 (when (and (null gnus-override-method)
5608 (setq gnus-override-method (pop methods)))
5610 (when (eq gnus-override-method 'current)
5611 (setq gnus-override-method
5612 (with-current-buffer gnus-summary-buffer
5613 gnus-current-select-method)))
5615 (gnus-kill-all-overlays)
5616 (let ((gnus-newsgroup-name group))
5617 (gnus-check-group-server))
5619 ((gnus-request-article article group (current-buffer))
5620 (when (numberp article)
5621 (gnus-async-prefetch-next group article
5622 gnus-summary-buffer)
5623 (when gnus-keep-backlog
5624 (gnus-backlog-enter-article
5625 group article (current-buffer))))
5626 (setq result 'article))
5628 (setq gnus-override-method (pop methods)))
5629 ((not (string-match "^400 "
5630 (nnheader-get-report backend)))
5631 ;; If we get 400 server disconnect, reconnect and
5632 ;; retry; otherwise, assume the article has expired.
5633 (setq result 'done))))
5634 (and (eq result 'article) 'article)))
5638 ;; Associate this article with the current summary buffer.
5639 (setq gnus-article-current-summary gnus-summary-buffer)
5641 ;; Take the article from the original article buffer
5642 ;; and place it in the buffer it's supposed to be in.
5643 (when (and (get-buffer gnus-article-buffer)
5644 (equal (buffer-name (current-buffer))
5645 (buffer-name (get-buffer gnus-article-buffer))))
5647 (if (get-buffer gnus-original-article-buffer)
5648 (set-buffer gnus-original-article-buffer)
5649 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5650 (buffer-disable-undo)
5651 (setq major-mode 'gnus-original-article-mode)
5652 (setq buffer-read-only t))
5653 (let ((inhibit-read-only t))
5655 (insert-buffer-substring gnus-article-buffer))
5656 (setq gnus-original-article (cons group article)))
5659 (run-hooks 'gnus-article-decode-hook)
5660 ;; Mark article as decoded or not.
5661 (setq gnus-article-decoded-p gnus-article-decode-hook))
5663 ;; Update sparse articles.
5664 (when (and do-update-line
5665 (or (numberp article)
5667 (let ((buf (current-buffer)))
5668 (set-buffer gnus-summary-buffer)
5669 (gnus-summary-update-article do-update-line sparse-header)
5670 (gnus-summary-goto-subject do-update-line nil t)
5671 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5673 (set-buffer buf))))))
5679 (defcustom gnus-article-edit-mode-hook nil
5680 "Hook run in article edit mode buffers."
5681 :group 'gnus-article-various
5684 (defvar gnus-article-edit-done-function nil)
5686 (defvar gnus-article-edit-mode-map nil)
5688 ;; Should we be using derived.el for this?
5689 (unless gnus-article-edit-mode-map
5690 (setq gnus-article-edit-mode-map (make-keymap))
5691 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5693 (gnus-define-keys gnus-article-edit-mode-map
5694 "\C-c?" describe-mode
5695 "\C-c\C-c" gnus-article-edit-done
5696 "\C-c\C-k" gnus-article-edit-exit
5697 "\C-c\C-f\C-t" message-goto-to
5698 "\C-c\C-f\C-o" message-goto-from
5699 "\C-c\C-f\C-b" message-goto-bcc
5700 ;;"\C-c\C-f\C-w" message-goto-fcc
5701 "\C-c\C-f\C-c" message-goto-cc
5702 "\C-c\C-f\C-s" message-goto-subject
5703 "\C-c\C-f\C-r" message-goto-reply-to
5704 "\C-c\C-f\C-n" message-goto-newsgroups
5705 "\C-c\C-f\C-d" message-goto-distribution
5706 "\C-c\C-f\C-f" message-goto-followup-to
5707 "\C-c\C-f\C-m" message-goto-mail-followup-to
5708 "\C-c\C-f\C-k" message-goto-keywords
5709 "\C-c\C-f\C-u" message-goto-summary
5710 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5711 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5712 "\C-c\C-b" message-goto-body
5713 "\C-c\C-i" message-goto-signature
5715 "\C-c\C-t" message-insert-to
5716 "\C-c\C-n" message-insert-newsgroups
5717 "\C-c\C-o" message-sort-headers
5718 "\C-c\C-e" message-elide-region
5719 "\C-c\C-v" message-delete-not-region
5720 "\C-c\C-z" message-kill-to-signature
5721 "\M-\r" message-newline-and-reformat
5722 "\C-c\C-a" mml-attach-file
5723 "\C-a" message-beginning-of-line
5725 "\M-;" comment-region)
5727 (gnus-define-keys (gnus-article-edit-wash-map
5728 "\C-c\C-w" gnus-article-edit-mode-map)
5729 "f" gnus-article-edit-full-stops))
5732 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5734 ["Fetch To" message-insert-to t]
5735 ["Fetch Newsgroups" message-insert-newsgroups t]
5737 ["To" message-goto-to t]
5738 ["From" message-goto-from t]
5739 ["Subject" message-goto-subject t]
5740 ["Cc" message-goto-cc t]
5741 ["Reply-To" message-goto-reply-to t]
5742 ["Summary" message-goto-summary t]
5743 ["Keywords" message-goto-keywords t]
5744 ["Newsgroups" message-goto-newsgroups t]
5745 ["Followup-To" message-goto-followup-to t]
5746 ["Mail-Followup-To" message-goto-mail-followup-to t]
5747 ["Distribution" message-goto-distribution t]
5748 ["Body" message-goto-body t]
5749 ["Signature" message-goto-signature t]))
5751 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5752 "Major mode for editing articles.
5753 This is an extended text-mode.
5755 \\{gnus-article-edit-mode-map}"
5756 (make-local-variable 'gnus-article-edit-done-function)
5757 (make-local-variable 'gnus-prev-winconf)
5758 (set (make-local-variable 'font-lock-defaults)
5759 '(message-font-lock-keywords t))
5760 (set (make-local-variable 'mail-header-separator) "")
5761 (set (make-local-variable 'gnus-article-edit-mode) t)
5762 (easy-menu-add message-mode-field-menu message-mode-map)
5764 (setq buffer-read-only nil)
5765 (buffer-enable-undo)
5768 (defun gnus-article-edit (&optional force)
5769 "Edit the current article.
5770 This will have permanent effect only in mail groups.
5771 If FORCE is non-nil, allow editing of articles even in read-only
5774 (when (and (not force)
5775 (gnus-group-read-only-p))
5776 (error "The current newsgroup does not support article editing"))
5777 (gnus-article-date-original)
5778 (gnus-article-edit-article
5780 `(lambda (no-highlight)
5782 (gnus-summary-edit-article-done
5783 ,(or (mail-header-references gnus-current-headers) "")
5784 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5786 (defun gnus-article-edit-article (start-func exit-func)
5787 "Start editing the contents of the current article buffer."
5788 (let ((winconf (current-window-configuration)))
5789 (set-buffer gnus-article-buffer)
5790 (let ((message-auto-save-directory
5791 ;; Don't associate the article buffer with a draft file.
5793 (gnus-article-edit-mode))
5794 (funcall start-func)
5795 (set-buffer-modified-p nil)
5796 (gnus-configure-windows 'edit-article)
5797 (setq gnus-article-edit-done-function exit-func)
5798 (setq gnus-prev-winconf winconf)
5799 (gnus-message 6 "C-c C-c to end edits")))
5801 (defun gnus-article-edit-done (&optional arg)
5802 "Update the article edits and exit."
5804 (let ((func gnus-article-edit-done-function)
5805 (buf (current-buffer))
5806 (start (window-start))
5808 (winconf gnus-prev-winconf))
5809 (widen) ;; Widen it in case that users narrowed the buffer.
5812 ;; The cache and backlog have to be flushed somewhat.
5813 (when gnus-keep-backlog
5814 (gnus-backlog-remove-article
5815 (car gnus-article-current) (cdr gnus-article-current)))
5816 ;; Flush original article as well.
5818 (when (get-buffer gnus-original-article-buffer)
5819 (set-buffer gnus-original-article-buffer)
5820 (setq gnus-original-article nil)))
5821 (when gnus-use-cache
5822 (gnus-cache-update-article
5823 (car gnus-article-current) (cdr gnus-article-current)))
5824 ;; We remove all text props from the article buffer.
5825 (kill-all-local-variables)
5826 (set-text-properties (point-min) (point-max) nil)
5828 (set-window-configuration winconf)
5830 (set-window-start (get-buffer-window buf) start)
5831 (set-window-point (get-buffer-window buf) (point)))
5832 (gnus-summary-show-article))
5834 (defun gnus-article-edit-exit ()
5835 "Exit the article editing without updating."
5837 (when (or (not (buffer-modified-p))
5838 (yes-or-no-p "Article modified; kill anyway? "))
5839 (let ((curbuf (current-buffer))
5841 (window-start (window-start)))
5843 (if (gnus-buffer-live-p gnus-original-article-buffer)
5844 (insert-buffer-substring gnus-original-article-buffer))
5845 (let ((winconf gnus-prev-winconf))
5846 (kill-all-local-variables)
5848 (set-window-configuration winconf)
5849 ;; Tippy-toe some to make sure that point remains where it was.
5850 (save-current-buffer
5852 (set-window-start (get-buffer-window (current-buffer)) window-start)
5854 (gnus-summary-show-article)))
5856 (defun gnus-article-edit-full-stops ()
5857 "Interactively repair spacing at end of sentences."
5860 (goto-char (point-min))
5861 (search-forward-regexp "^$" nil t)
5862 (let ((case-fold-search nil))
5863 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5866 ;;; Article highlights
5869 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5871 ;;; Internal Variables:
5873 (defcustom gnus-button-url-regexp
5874 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5875 "\\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:]]\\)"
5876 "\\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\\)\\)")
5877 "Regular expression that matches URLs."
5878 :group 'gnus-article-buttons
5881 (defcustom gnus-button-valid-fqdn-regexp
5882 message-valid-fqdn-regexp
5883 "Regular expression that matches a valid FQDN."
5885 :group 'gnus-article-buttons
5888 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5889 (defcustom gnus-button-valid-localpart-regexp
5890 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*"
5891 "Regular expression that matches a localpart of mail addresses or MIDs."
5893 :group 'gnus-article-buttons
5896 (defcustom gnus-button-man-handler 'manual-entry
5897 "Function to use for displaying man pages.
5898 The function must take at least one argument with a string naming the
5901 :type '(choice (function-item :tag "Man" manual-entry)
5902 (function-item :tag "Woman" woman)
5903 (function :tag "Other"))
5904 :group 'gnus-article-buttons)
5906 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5907 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5908 If the default site is too slow, try to find a CTAN mirror, see
5909 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5910 the variable `gnus-button-handle-ctan'."
5912 :group 'gnus-article-buttons
5913 :link '(custom-manual "(gnus)Group Parameters")
5914 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5915 (const "http://tug.ctan.org/tex-archive/")
5916 (const "http://www.dante.de/CTAN/")
5917 (string :tag "Other")))
5919 (defcustom gnus-button-ctan-handler 'browse-url
5920 "Function to use for displaying CTAN links.
5921 The function must take one argument, the string naming the URL."
5923 :type '(choice (function-item :tag "Browse Url" browse-url)
5924 (function :tag "Other"))
5925 :group 'gnus-article-buttons)
5927 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5928 "Bogus strings removed from CTAN URLs."
5930 :group 'gnus-article-buttons
5931 :type '(choice (const "^/?tex-archive/\\|/")
5932 (regexp :tag "Other")))
5934 (defcustom gnus-button-ctan-directory-regexp
5936 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
5937 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
5938 "languages" "macros" "nonfree" "obsolete" "support" "systems"
5939 "tds" "tools" "usergrps" "web") t)
5940 "Regular expression for ctan directories.
5941 It should match all directories in the top level of `gnus-ctan-url'."
5943 :group 'gnus-article-buttons
5946 (defcustom gnus-button-mid-or-mail-regexp
5947 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
5948 gnus-button-valid-fqdn-regexp
5950 "Regular expression that matches a message ID or a mail address."
5952 :group 'gnus-article-buttons
5955 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5956 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5957 Strings like this can be either a message ID or a mail address. If it is one
5958 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5959 message ID or a mail address, respectively. If this variable is set to the
5960 symbol `ask', always query the user what do do. If it is a function, this
5961 function will be called with the string as it's only argument. The function
5962 must return `mid', `mail', `invalid' or `ask'."
5964 :group 'gnus-article-buttons
5965 :type '(choice (function-item :tag "Heuristic function"
5966 gnus-button-mid-or-mail-heuristic)
5971 (defcustom gnus-button-mid-or-mail-heuristic-alist
5972 '((-10.0 . ".+\\$.+@")
5975 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5976 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5977 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5978 (-1.0 . "^[^a-z]+@")
5980 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5981 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5982 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5983 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5986 (-1.0 . "^[0-9][0-9]")
5988 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5989 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5990 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5991 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5993 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5994 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5997 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5999 ;; compensation for TDMA dated mail addresses:
6000 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6002 (-20.0 . "\\.fsf@") ;; Gnus
6005 (-20.0 . "_-_") ;; Subject change in thread
6007 (-20.0 . "\\.ln@") ;; leafnode
6008 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6009 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6011 ;; (5.0 . "") ;; $local_part_len <= 7
6012 (10.0 . "^[^0-9]+@")
6013 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6014 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6017 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6019 (0.5 . "^[A-Z][a-z]")
6020 (0.5 . "^[A-Z][a-z][a-z]")
6021 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6022 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6023 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6025 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6026 address. The REGEXP is processed with `case-fold-search' set to nil."
6028 :group 'gnus-article-buttons
6029 :type '(repeat (cons (number :tag "Rate")
6030 (regexp :tag "Regexp"))))
6032 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6033 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6034 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6035 address, `ask' if unsure and `invalid' if the string is invalid."
6036 (let ((case-fold-search nil)
6037 (list gnus-button-mid-or-mail-heuristic-alist)
6038 (result 0) rate regexp lpartlen elem)
6040 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6041 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6042 ;; Certain special cases...
6045 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6046 "^[0-9]+\\.[0-9]+@compuserve\\|"
6047 "@public\\.gmane\\.org")
6049 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6050 (setq result 'mail))
6051 (when (string-match "@.*@\\| " mid-or-mail)
6052 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6053 (setq result 'invalid))
6054 ;; Nothing more to do, if result is not a number here...
6055 (when (numberp result)
6057 (setq elem (car list)
6061 (when (string-match regexp mid-or-mail)
6062 (setq result (+ result rate))
6064 9 "`%s' matched `%s', rate `%s', result `%s'."
6065 mid-or-mail regexp rate result)))
6066 (when (<= lpartlen 7)
6067 (setq result (+ result 5.0))
6068 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6069 mid-or-mail result))
6070 (when (>= lpartlen 12)
6071 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6073 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6074 ;; Long local part should contain realname if e-mail address,
6075 ;; too many digits: message-id.
6076 ;; $score -= 5.0 + 0.1 * $local_part_len;
6077 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6078 (setq result (+ result rate))
6080 9 "Many digits in `%s', rate `%s', result `%s'."
6081 mid-or-mail rate result))
6082 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6084 ;; Too few vowels [^aeiouy]{4,}.*\@
6085 (setq result (+ result -5.0))
6087 9 "Few vowels in `%s', rate `%s', result `%s'."
6088 mid-or-mail -5.0 result))
6090 (setq result (+ result 5.0))
6092 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6093 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6094 ;; Maybe we should make this a customizable alist: (condition . 'result)
6096 ((symbolp result) result)
6097 ;; Now convert number into proper results:
6098 ((< result -10.0) 'mid)
6099 ((> result 10.0) 'mail)
6102 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6103 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6104 (url-mid (concat "news" ":" mid-or-mail))
6105 (url-mailto (concat "mailto" ":" mid-or-mail)))
6106 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6107 (when (fboundp pref)
6109 ;; get rid of surrounding angles...
6111 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6112 (if (or (eq 'mid guessed) (eq 'mail guessed))
6116 (save-window-excursion
6117 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6120 (cond ((eq pref 'mid)
6121 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6122 (gnus-button-handle-news url-mid))
6124 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6125 (gnus-url-mailto url-mailto))
6126 (t (gnus-message 3 "Invalid string.")))))
6128 (defun gnus-button-handle-custom (url)
6129 "Follow a Custom URL."
6130 (customize-apropos (gnus-url-unhex-string url)))
6132 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6134 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6137 (defun gnus-button-handle-describe-function (url)
6138 "Call `describe-function' when pushing the corresponding URL button."
6141 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6143 (defun gnus-button-handle-describe-variable (url)
6144 "Call `describe-variable' when pushing the corresponding URL button."
6147 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6149 (defun gnus-button-handle-symbol (url)
6150 "Display help on variable or function.
6151 Calls `describe-variable' or `describe-function'."
6152 (let ((sym (intern url)))
6154 ((fboundp sym) (describe-function sym))
6155 ((boundp sym) (describe-variable sym))
6156 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6158 (defun gnus-button-handle-describe-key (url)
6159 "Call `describe-key' when pushing the corresponding URL button."
6161 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6162 (keys (ignore-errors (eval `(kbd ,key-string)))))
6165 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6167 (defun gnus-button-handle-apropos (url)
6168 "Call `apropos' when pushing the corresponding URL button."
6169 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6171 (defun gnus-button-handle-apropos-command (url)
6172 "Call `apropos' when pushing the corresponding URL button."
6174 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6176 (defun gnus-button-handle-apropos-variable (url)
6177 "Call `apropos' when pushing the corresponding URL button."
6179 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6180 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6182 (defun gnus-button-handle-apropos-documentation (url)
6183 "Call `apropos' when pushing the corresponding URL button."
6185 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6186 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6188 (defun gnus-button-handle-library (url)
6189 "Call `locate-library' when pushing the corresponding URL button."
6190 (gnus-message 9 "url=`%s'" url)
6191 (let* ((lib (locate-library url))
6192 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6194 (gnus-message 1 "Cannot locale library `%s'." url)
6195 (find-file-read-only file))))
6197 (defun gnus-button-handle-ctan (url)
6198 "Call `browse-url' when pushing a CTAN URL button."
6200 gnus-button-ctan-handler
6203 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6205 (defcustom gnus-button-tex-level 5
6206 "*Integer that says how many TeX-related buttons Gnus will show.
6207 The higher the number, the more buttons will appear and the more false
6208 positives are possible. Note that you can set this variable local to
6209 specific groups. Setting it higher in TeX groups is probably a good idea.
6210 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6211 how to set variables in specific groups."
6213 :group 'gnus-article-buttons
6214 :link '(custom-manual "(gnus)Group Parameters")
6217 (defcustom gnus-button-man-level 5
6218 "*Integer that says how many man-related buttons Gnus will show.
6219 The higher the number, the more buttons will appear and the more false
6220 positives are possible. Note that you can set this variable local to
6221 specific groups. Setting it higher in Unix groups is probably a good idea.
6222 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6223 how to set variables in specific groups."
6225 :group 'gnus-article-buttons
6226 :link '(custom-manual "(gnus)Group Parameters")
6229 (defcustom gnus-button-emacs-level 5
6230 "*Integer that says how many emacs-related buttons Gnus will show.
6231 The higher the number, the more buttons will appear and the more false
6232 positives are possible. Note that you can set this variable local to
6233 specific groups. Setting it higher in Emacs or Gnus related groups is
6234 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6235 `gnus-parameters' on how to set variables in specific groups."
6237 :group 'gnus-article-buttons
6238 :link '(custom-manual "(gnus)Group Parameters")
6241 (defcustom gnus-button-message-level 5
6242 "*Integer that says how many buttons for news or mail messages will appear.
6243 The higher the number, the more buttons will appear and the more false
6244 positives are possible."
6245 ;; mail addresses, MIDs, URLs for news, ...
6247 :group 'gnus-article-buttons
6250 (defcustom gnus-button-browse-level 5
6251 "*Integer that says how many buttons for browsing will appear.
6252 The higher the number, the more buttons will appear and the more false
6253 positives are possible."
6254 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6256 :group 'gnus-article-buttons
6259 (defcustom gnus-button-alist
6260 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6261 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6262 ((concat "\\b\\(nntp\\|news\\):\\("
6263 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6264 0 t gnus-button-handle-news 2)
6265 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6266 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6267 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6268 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6269 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6270 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6271 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6272 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6273 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6274 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6275 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6276 ;; RFC 2368 (The mailto URL scheme)
6277 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6278 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6279 ("\\bmailto:\\([^ \n\t]+\\)"
6280 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6282 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6283 gnus-button-ctan-directory-regexp
6284 "[^][>)!;:,'\n\t ]+\\)")
6285 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6286 ((concat "\\btex-archive/\\("
6287 gnus-button-ctan-directory-regexp
6288 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6289 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6292 gnus-button-ctan-directory-regexp
6293 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6294 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6295 ;; This is info (home-grown style) <info://foo/bar+baz>
6296 ("\\binfo://\\([^'\">\n\t ]+\\)"
6297 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6298 ;; Info GNOME style <info:foo#bar_baz>
6299 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6300 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6301 ;; Info KDE style <info:(foo)bar baz>
6302 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6303 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6304 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6305 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6306 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6307 ;; Info links like `C-h i d m CC Mode RET'
6308 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6310 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6311 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6312 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6313 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6314 ;; Emacs help commands
6315 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6316 ;; regexp doesn't match arguments containing ` '.
6317 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6318 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6319 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6320 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6321 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6322 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6323 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6324 ;; The following entries may lead to many false positives so don't enable
6325 ;; them by default (use a high button level).
6326 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6327 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6328 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6329 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6330 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6331 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6332 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6333 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6334 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6335 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6336 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6337 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6338 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6339 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6340 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6341 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6342 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6343 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6344 ;; Unlike the other regexps we really have to require quoting
6345 ;; here to determine where it ends.
6346 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6347 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6348 ("<URL: *\\([^<>]*\\)>"
6349 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6350 ;; RFC 2396 (2.4.3., delims) ...
6351 ("\"URL: *\\([^\"]*\\)\""
6352 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6353 ;; RFC 2396 (2.4.3., delims) ...
6354 ("\"URL: *\\([^\"]*\\)\""
6355 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6357 (gnus-button-url-regexp
6358 0 (>= gnus-button-browse-level 0) browse-url 0)
6360 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6361 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6362 gnus-button-handle-man 1)
6363 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6364 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6365 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6366 gnus-button-handle-man 1)
6367 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6368 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6369 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6370 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6371 ;; MID or mail: To avoid too many false positives we don't try to catch
6372 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6373 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6374 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6375 ;; so that non-ambiguous entries (see above) match first.
6376 (gnus-button-mid-or-mail-regexp
6377 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6378 "*Alist of regexps matching buttons in article bodies.
6380 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6381 REGEXP: is the string (case insensitive) matching text around the button (can
6382 also be Lisp expression evaluating to a string),
6383 BUTTON: is the number of the regexp grouping actually matching the button,
6384 FORM: is a Lisp expression which must eval to true for the button to
6386 CALLBACK: is the function to call when the user push this button, and each
6387 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6389 CALLBACK can also be a variable, in that case the value of that
6390 variable it the real callback function."
6391 :group 'gnus-article-buttons
6392 :type '(repeat (list (choice regexp variable sexp)
6393 (integer :tag "Button")
6395 (function :tag "Callback")
6398 (integer :tag "Regexp group")))))
6400 (defcustom gnus-header-button-alist
6401 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6402 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6403 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6404 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6405 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6406 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6407 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6408 0 (>= gnus-button-browse-level 0) browse-url 0)
6409 ("^Subject:" gnus-button-url-regexp
6410 0 (>= gnus-button-browse-level 0) browse-url 0)
6411 ("^[^:]+:" gnus-button-url-regexp
6412 0 (>= gnus-button-browse-level 0) browse-url 0)
6413 ("^OpenPGP:.*url=" gnus-button-url-regexp
6414 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6415 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6416 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6417 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6418 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6419 "*Alist of headers and regexps to match buttons in article heads.
6421 This alist is very similar to `gnus-button-alist', except that each
6422 alist has an additional HEADER element first in each entry:
6424 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6426 HEADER is a regexp to match a header. For a fuller explanation, see
6427 `gnus-button-alist'."
6428 :group 'gnus-article-buttons
6429 :group 'gnus-article-headers
6430 :type '(repeat (list (regexp :tag "Header")
6431 (choice regexp variable)
6432 (integer :tag "Button")
6434 (function :tag "Callback")
6437 (integer :tag "Regexp group")))))
6441 (defun gnus-article-push-button (event)
6442 "Check text under the mouse pointer for a callback function.
6443 If the text under the mouse pointer has a `gnus-callback' property,
6444 call it with the value of the `gnus-data' text property."
6446 (set-buffer (window-buffer (posn-window (event-start event))))
6447 (let* ((pos (posn-point (event-start event)))
6448 (data (get-text-property pos 'gnus-data))
6449 (fun (get-text-property pos 'gnus-callback)))
6452 (funcall fun data))))
6454 (defun gnus-article-press-button ()
6455 "Check text at point for a callback function.
6456 If the text at point has a `gnus-callback' property,
6457 call it with the value of the `gnus-data' text property."
6459 (let ((data (get-text-property (point) 'gnus-data))
6460 (fun (get-text-property (point) 'gnus-callback)))
6462 (funcall fun data))))
6464 (defun gnus-article-highlight (&optional force)
6465 "Highlight current article.
6466 This function calls `gnus-article-highlight-headers',
6467 `gnus-article-highlight-citation',
6468 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6469 do the highlighting. See the documentation for those functions."
6470 (interactive (list 'force))
6471 (gnus-article-highlight-headers)
6472 (gnus-article-highlight-citation force)
6473 (gnus-article-highlight-signature)
6474 (gnus-article-add-buttons force)
6475 (gnus-article-add-buttons-to-head))
6477 (defun gnus-article-highlight-some (&optional force)
6478 "Highlight current article.
6479 This function calls `gnus-article-highlight-headers',
6480 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6481 do the highlighting. See the documentation for those functions."
6482 (interactive (list 'force))
6483 (gnus-article-highlight-headers)
6484 (gnus-article-highlight-signature)
6485 (gnus-article-add-buttons))
6487 (defun gnus-article-highlight-headers ()
6488 "Highlight article headers as specified by `gnus-header-face-alist'."
6490 (gnus-with-article-headers
6491 (let (regexp header-face field-face from hpoints fpoints)
6492 (dolist (entry gnus-header-face-alist)
6493 (goto-char (point-min))
6494 (setq regexp (concat "^\\("
6495 (if (string-equal "" (nth 0 entry))
6499 header-face (nth 1 entry)
6500 field-face (nth 2 entry))
6501 (while (and (re-search-forward regexp nil t)
6505 (unless (search-forward ":" nil t)
6507 (when (and header-face
6508 (not (memq (point) hpoints)))
6509 (push (point) hpoints)
6510 (gnus-put-text-property from (point) 'face header-face))
6511 (when (and field-face
6512 (not (memq (setq from (point)) fpoints)))
6514 (if (re-search-forward "^[^ \t]" nil t)
6516 (goto-char (point-max)))
6517 (gnus-put-text-property from (point) 'face field-face)))))))
6519 (defun gnus-article-highlight-signature ()
6520 "Highlight the signature in an article.
6521 It does this by highlighting everything after
6522 `gnus-signature-separator' using the face `gnus-signature'."
6524 (gnus-with-article-buffer
6525 (let ((inhibit-point-motion-hooks t))
6527 (when (and gnus-signature-face
6528 (gnus-article-narrow-to-signature))
6529 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6530 'face gnus-signature-face)
6532 (gnus-article-search-signature)
6533 (let ((start (match-beginning 0))
6534 (end (set-marker (make-marker) (1+ (match-end 0)))))
6535 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6538 (defun gnus-button-in-region-p (b e prop)
6539 "Say whether PROP exists in the region."
6540 (text-property-not-all b e prop nil))
6542 (defun gnus-article-add-buttons (&optional force)
6543 "Find external references in the article and make buttons of them.
6544 \"External references\" are things like Message-IDs and URLs, as
6545 specified by `gnus-button-alist'."
6546 (interactive (list 'force))
6547 (gnus-with-article-buffer
6548 (let ((inhibit-point-motion-hooks t)
6549 (case-fold-search t)
6550 (alist gnus-button-alist)
6552 ;; Remove all old markers.
6553 (let (marker entry new-list)
6554 (while (setq marker (pop gnus-button-marker-list))
6555 (if (or (< marker (point-min)) (>= marker (point-max)))
6556 (push marker new-list)
6558 (when (setq entry (gnus-button-entry))
6559 (put-text-property (match-beginning (nth 1 entry))
6560 (match-end (nth 1 entry))
6561 'gnus-callback nil))
6562 (set-marker marker nil)))
6563 (setq gnus-button-marker-list new-list))
6564 ;; We skip the headers.
6567 (while (setq entry (pop alist))
6568 (setq regexp (eval (car entry)))
6570 (while (re-search-forward regexp nil t)
6571 (let* ((start (and entry (match-beginning (nth 1 entry))))
6572 (end (and entry (match-end (nth 1 entry))))
6573 (from (match-beginning 0)))
6574 (when (and (or (eq t (nth 2 entry))
6575 (eval (nth 2 entry)))
6576 (not (gnus-button-in-region-p
6577 start end 'gnus-callback)))
6578 ;; That optional form returned non-nil, so we add the
6580 (gnus-article-add-button
6581 start end 'gnus-button-push
6582 (car (push (set-marker (make-marker) from)
6583 gnus-button-marker-list))))))))))
6585 ;; Add buttons to the head of an article.
6586 (defun gnus-article-add-buttons-to-head ()
6587 "Add buttons to the head of the article."
6589 (gnus-with-article-headers
6591 (dolist (entry gnus-header-button-alist)
6592 ;; Each alist entry.
6593 (goto-char (point-min))
6594 (while (re-search-forward (car entry) nil t)
6595 ;; Each header matching the entry.
6596 (setq beg (match-beginning 0))
6597 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6598 (match-beginning 0))
6601 (while (re-search-forward (eval (nth 1 entry)) end t)
6602 ;; Each match within a header.
6603 (let* ((entry (cdr entry))
6604 (start (match-beginning (nth 1 entry)))
6605 (end (match-end (nth 1 entry)))
6606 (form (nth 2 entry)))
6607 (goto-char (match-end 0))
6609 (gnus-article-add-button
6610 start end (nth 3 entry)
6611 (buffer-substring (match-beginning (nth 4 entry))
6612 (match-end (nth 4 entry)))))))
6613 (goto-char end))))))
6615 ;;; External functions:
6617 (defun gnus-article-add-button (from to fun &optional data)
6618 "Create a button between FROM and TO with callback FUN and data DATA."
6619 (when gnus-article-button-face
6620 (gnus-overlay-put (gnus-make-overlay from to)
6621 'face gnus-article-button-face))
6622 (gnus-add-text-properties
6624 (nconc (and gnus-article-mouse-face
6625 (list gnus-mouse-face-prop gnus-article-mouse-face))
6626 (list 'gnus-callback fun)
6627 (and data (list 'gnus-data data))))
6628 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6629 :button-keymap gnus-widget-button-keymap))
6631 ;;; Internal functions:
6633 (defun gnus-article-set-globals ()
6634 (with-current-buffer gnus-summary-buffer
6635 (gnus-set-global-variables)))
6637 (defun gnus-signature-toggle (end)
6638 (gnus-with-article-buffer
6639 (let ((inhibit-point-motion-hooks t))
6640 (if (text-property-any end (point-max) 'article-type 'signature)
6642 (gnus-delete-wash-type 'signature)
6643 (gnus-remove-text-properties-when
6644 'article-type 'signature end (point-max)
6645 (cons 'article-type (cons 'signature
6646 gnus-hidden-properties))))
6647 (gnus-add-wash-type 'signature)
6648 (gnus-add-text-properties-when
6649 'article-type nil end (point-max)
6650 (cons 'article-type (cons 'signature
6651 gnus-hidden-properties)))))
6652 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6653 (gnus-set-mode-line 'article))))
6655 (defun gnus-button-entry ()
6656 ;; Return the first entry in `gnus-button-alist' matching this place.
6657 (let ((alist gnus-button-alist)
6660 (setq entry (pop alist))
6661 (if (looking-at (eval (car entry)))
6666 (defun gnus-button-push (marker)
6667 ;; Push button starting at MARKER.
6670 (let* ((entry (gnus-button-entry))
6671 (inhibit-point-motion-hooks t)
6673 (args (mapcar (lambda (group)
6674 (let ((string (match-string group)))
6675 (set-text-properties
6676 0 (length string) nil string)
6683 (fboundp (symbol-value fun)))
6684 (apply (symbol-value fun) args))
6686 (gnus-message 1 "You must define `%S' to use this button"
6687 (cons fun args)))))))
6689 (defun gnus-parse-news-url (url)
6690 (let (scheme server port group message-id articles)
6693 (goto-char (point-min))
6694 (when (looking-at "\\([A-Za-z]+\\):")
6695 (setq scheme (match-string 1))
6696 (goto-char (match-end 0)))
6697 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
6698 (setq server (match-string 1))
6699 (setq port (if (stringp (match-string 3))
6700 (string-to-number (match-string 3))
6702 (goto-char (match-end 0)))
6705 ((looking-at "\\(.*@.*\\)")
6706 (setq message-id (match-string 1)))
6707 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6708 (setq group (match-string 1)
6709 articles (split-string (match-string 2) "-")))
6710 ((looking-at "\\([^/]+\\)/?")
6711 (setq group (match-string 1)))
6713 (error "Unknown news URL syntax"))))
6714 (list scheme server port group message-id articles)))
6716 (defun gnus-button-handle-news (url)
6718 (destructuring-bind (scheme server port group message-id articles)
6719 (gnus-parse-news-url url)
6723 (set-buffer gnus-summary-buffer)
6725 (let ((gnus-refer-article-method
6726 (nconc (list (list 'nntp server))
6727 gnus-refer-article-method))
6728 (nntp-port-number (or port "nntp")))
6729 (gnus-message 7 "Fetching %s with %s"
6730 message-id gnus-refer-article-method)
6731 (gnus-summary-refer-article message-id))
6732 (gnus-summary-refer-article message-id))))
6734 (gnus-button-fetch-group url)))))
6736 (defun gnus-button-handle-man (url)
6738 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6739 (when (eq gnus-button-man-handler 'woman)
6740 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
6741 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6742 (funcall gnus-button-man-handler url))
6744 (defun gnus-button-handle-info-url (url)
6745 "Fetch an info URL."
6746 (setq url (mm-subst-char-in-string ?+ ?\ url))
6748 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6749 (gnus-info-find-node
6750 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6752 ")" (gnus-url-unhex-string (match-string 2 url)))))
6753 ((string-match "([^)\"]+)[^\"]+" url)
6755 (gnus-replace-in-string
6756 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6757 (gnus-info-find-node url))
6758 (t (error "Can't parse %s" url))))
6760 (defun gnus-button-handle-info-url-gnome (url)
6761 "Fetch GNOME style info URL."
6762 (setq url (mm-subst-char-in-string ?_ ?\ url))
6763 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6764 (gnus-info-find-node
6766 (gnus-url-unhex-string
6767 (match-string 1 url))
6769 (or (gnus-url-unhex-string
6770 (match-string 2 url))
6772 (error "Can't parse %s" url)))
6774 (defun gnus-button-handle-info-url-kde (url)
6775 "Fetch KDE style info URL."
6776 (gnus-info-find-node (gnus-url-unhex-string url)))
6778 (defun gnus-button-handle-info-keystrokes (url)
6779 "Call `info' when pushing the corresponding URL button."
6780 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6785 (defun gnus-button-openpgp (url)
6786 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
6788 (mm-url-insert-file-contents-external url)
6789 (pgg-snarf-keys-region (point-min) (point-max))
6790 (pgg-display-output-buffer nil nil nil)))
6792 (defun gnus-button-message-id (message-id)
6794 (with-current-buffer gnus-summary-buffer
6795 (gnus-summary-refer-article message-id)))
6797 (defun gnus-button-fetch-group (address)
6798 "Fetch GROUP specified by ADDRESS."
6799 (if (not (string-match "[:/]" address))
6800 ;; This is just a simple group url.
6801 (gnus-group-read-ephemeral-group address gnus-select-method)
6804 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6806 (error "Can't parse %s" address)
6807 (gnus-group-read-ephemeral-group
6808 (match-string 4 address)
6809 `(nntp ,(match-string 1 address)
6810 (nntp-address ,(match-string 1 address))
6811 (nntp-port-number ,(if (match-end 3)
6812 (match-string 3 address)
6815 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
6817 (defun gnus-url-parse-query-string (query &optional downcase)
6818 (let (retval pairs cur key val)
6819 (setq pairs (split-string query "&"))
6821 (setq cur (car pairs)
6823 (if (not (string-match "=" cur))
6825 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6826 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6828 (setq key (downcase key)))
6829 (setq cur (assoc key retval))
6831 (setcdr cur (cons val (cdr cur)))
6832 (setq retval (cons (list key val) retval)))))
6835 (defun gnus-url-mailto (url)
6836 ;; Send mail to someone
6837 (when (string-match "mailto:/*\\(.*\\)" url)
6838 (setq url (substring url (match-beginning 1) nil)))
6839 (let (to args subject func)
6840 (setq args (gnus-url-parse-query-string
6841 (if (string-match "^\\?" url)
6843 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6844 (concat "to=" (match-string 1 url) "&"
6845 (match-string 2 url))
6846 (concat "to=" url)))
6848 subject (cdr-safe (assoc "subject" args)))
6851 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6854 (message-position-on-field (caar args)))
6855 (insert (gnus-replace-in-string
6856 (mapconcat 'identity (reverse (cdar args)) ", ")
6858 (setq args (cdr args)))
6861 (message-goto-subject))))
6863 (defun gnus-button-embedded-url (address)
6864 "Activate ADDRESS with `browse-url'."
6865 (browse-url (gnus-strip-whitespace address)))
6867 ;;; Next/prev buttons in the article buffer.
6869 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6870 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6872 (defvar gnus-prev-page-map
6873 (let ((map (make-sparse-keymap)))
6874 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6875 (define-key map "\r" 'gnus-button-prev-page)
6878 (defvar gnus-next-page-map
6879 (let ((map (make-sparse-keymap)))
6880 (unless (>= emacs-major-version 21)
6881 ;; XEmacs doesn't care.
6882 (set-keymap-parent map gnus-article-mode-map))
6883 (define-key map gnus-mouse-2 'gnus-button-next-page)
6884 (define-key map "\r" 'gnus-button-next-page)
6887 (defun gnus-insert-prev-page-button ()
6889 (inhibit-read-only t))
6891 gnus-prev-page-line-format nil
6892 `(keymap ,gnus-prev-page-map
6894 gnus-callback gnus-article-button-prev-page
6895 article-type annotation))
6896 (widget-convert-button
6898 ;; Exclude a newline.
6901 :action 'gnus-button-prev-page
6902 :button-keymap gnus-prev-page-map)))
6904 (defun gnus-button-next-page (&optional args more-args)
6905 "Go to the next page."
6907 (let ((win (selected-window)))
6908 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6909 (gnus-article-next-page)
6910 (select-window win)))
6912 (defun gnus-button-prev-page (&optional args more-args)
6913 "Go to the prev page."
6915 (let ((win (selected-window)))
6916 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6917 (gnus-article-prev-page)
6918 (select-window win)))
6920 (defun gnus-insert-next-page-button ()
6922 (inhibit-read-only t))
6923 (gnus-eval-format gnus-next-page-line-format nil
6924 `(keymap ,gnus-next-page-map
6926 gnus-callback gnus-article-button-next-page
6927 article-type annotation))
6928 (widget-convert-button
6930 ;; Exclude a newline.
6933 :action 'gnus-button-next-page
6934 :button-keymap gnus-next-page-map)))
6936 (defun gnus-article-button-next-page (arg)
6937 "Go to the next page."
6939 (let ((win (selected-window)))
6940 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6941 (gnus-article-next-page)
6942 (select-window win)))
6944 (defun gnus-article-button-prev-page (arg)
6945 "Go to the prev page."
6947 (let ((win (selected-window)))
6948 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6949 (gnus-article-prev-page)
6950 (select-window win)))
6952 (defvar gnus-decode-header-methods
6953 '(mail-decode-encoded-word-region)
6954 "List of methods used to decode headers.
6956 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6957 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
6958 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6959 whose names match REGEXP.
6962 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6963 mail-decode-encoded-word-region
6964 (\"chinese\" . rfc1843-decode-region))
6967 (defvar gnus-decode-header-methods-cache nil)
6969 (defun gnus-multi-decode-header (start end)
6970 "Apply the functions from `gnus-encoded-word-methods' that match."
6971 (unless (and gnus-decode-header-methods-cache
6972 (eq gnus-newsgroup-name
6973 (car gnus-decode-header-methods-cache)))
6974 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6977 (nconc gnus-decode-header-methods-cache (list x))
6978 (if (and gnus-newsgroup-name
6979 (string-match (car x) gnus-newsgroup-name))
6980 (nconc gnus-decode-header-methods-cache
6982 gnus-decode-header-methods))
6983 (let ((xlist gnus-decode-header-methods-cache))
6986 (narrow-to-region start end)
6988 (funcall (pop xlist) (point-min) (point-max))))))
6991 ;;; Treatment top-level handling.
6994 (defun gnus-treat-article (condition &optional part-number total-parts type)
6995 (let ((length (- (point-max) (point-min)))
6996 (alist gnus-treatment-function-alist)
6997 (article-goto-body-goes-to-point-min-p t)
7001 (let ((list gnus-article-treat-types))
7003 (when (string-match (pop list) type)
7004 (throw 'found t)))))))
7005 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7007 (gnus-run-hooks 'gnus-part-display-hook)
7008 (dolist (elem alist)
7011 (when (gnus-buffer-live-p gnus-summary-buffer)
7012 (set-buffer gnus-summary-buffer))
7013 (symbol-value (car elem))))
7014 (when (and (or (consp val)
7016 (gnus-treat-predicate val)
7017 (or (not (get (car elem) 'highlight))
7020 (funcall (cadr elem)))))))
7022 ;; Dynamic variables.
7024 (defvar part-number)
7025 (defvar total-parts)
7030 (defun gnus-treat-predicate (val)
7037 (stringp (car val)))
7038 (apply 'gnus-or (mapcar `(lambda (s)
7039 (string-match s ,(or gnus-newsgroup-name "")))
7042 (let ((pred (pop val)))
7045 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7047 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7049 (not (gnus-treat-predicate (car val))))
7051 (equal (car val) type))
7053 (error "%S is not a valid predicate" pred)))))
7059 (eq part-number total-parts))
7063 (error "%S is not a valid value" val))))
7065 (defun gnus-article-encrypt-body (protocol &optional n)
7066 "Encrypt the article body."
7069 (or gnus-article-encrypt-protocol
7070 (completing-read "Encrypt protocol: "
7071 gnus-article-encrypt-protocol-alist
7073 current-prefix-arg))
7074 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7076 (error "Can't find the encrypt protocol %s" protocol))
7077 (if (member gnus-newsgroup-name '("nndraft:delayed"
7080 (error "Can't encrypt the article in group %s"
7081 gnus-newsgroup-name))
7082 (gnus-summary-iterate n
7084 (set-buffer gnus-summary-buffer)
7085 (let ((mail-parse-charset gnus-newsgroup-charset)
7086 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7087 (summary-buffer gnus-summary-buffer)
7089 (gnus-set-global-variables)
7090 (when (gnus-group-read-only-p)
7091 (error "The current newsgroup does not support article encrypt"))
7092 (gnus-summary-show-article t)
7094 (or (mail-header-references gnus-current-headers) ""))
7095 (set-buffer gnus-article-buffer)
7096 (let* ((inhibit-read-only t)
7098 (mapcar (lambda (field)
7099 (and (save-restriction
7100 (message-narrow-to-head)
7101 (goto-char (point-min))
7102 (search-forward field nil t))
7104 (message-narrow-to-field)
7106 (delete-region (point-min) (point-max))
7108 '("Content-Type:" "Content-Transfer-Encoding:"
7109 "Content-Disposition:"))))
7110 (message-narrow-to-head)
7111 (message-remove-header "MIME-Version")
7112 (goto-char (point-max))
7113 (setq point (point))
7114 (insert (apply 'concat headers))
7116 (narrow-to-region point (point-max))
7117 (let ((message-options message-options))
7118 (message-options-set 'message-sender user-mail-address)
7119 (message-options-set 'message-recipients user-mail-address)
7120 (message-options-set 'message-sign-encrypt 'not)
7122 (goto-char (point-min))
7123 (insert "MIME-Version: 1.0\n")
7125 (gnus-summary-edit-article-done
7126 references nil summary-buffer t))
7127 (when gnus-keep-backlog
7128 (gnus-backlog-remove-article
7129 (car gnus-article-current) (cdr gnus-article-current)))
7131 (when (get-buffer gnus-original-article-buffer)
7132 (set-buffer gnus-original-article-buffer)
7133 (setq gnus-original-article nil)))
7134 (when gnus-use-cache
7135 (gnus-cache-update-article
7136 (car gnus-article-current) (cdr gnus-article-current))))))))
7138 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7139 "The following specs can be used:
7140 %t The security MIME type
7143 %D Details if button is pressed")
7145 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7146 "The following specs can be used:
7147 %t The security MIME type
7150 %D Details if button is pressed")
7152 (defvar gnus-mime-security-button-line-format-alist
7153 '((?t gnus-tmp-type ?s)
7154 (?i gnus-tmp-info ?s)
7155 (?d gnus-tmp-details ?s)
7156 (?D gnus-tmp-pressed-details ?s)))
7158 (defvar gnus-mime-security-button-map
7159 (let ((map (make-sparse-keymap)))
7160 (define-key map gnus-mouse-2 'gnus-article-push-button)
7161 (define-key map "\r" 'gnus-article-press-button)
7164 (defvar gnus-mime-security-details-buffer nil)
7166 (defvar gnus-mime-security-button-pressed nil)
7168 (defvar gnus-mime-security-show-details-inline t
7169 "If non-nil, show details in the article buffer.")
7171 (defun gnus-mime-security-verify-or-decrypt (handle)
7172 (mm-remove-parts (cdr handle))
7173 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7174 point (inhibit-read-only t))
7176 (goto-char (car region)))
7178 (narrow-to-region (point) (point))
7179 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7180 (let* ((mm-verify-option 'known)
7181 (mm-decrypt-option 'known)
7182 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7183 (unless (eq nparts (cdr handle))
7184 (mm-destroy-parts (cdr handle))
7185 (setcdr handle nparts))))
7186 (setq point (point))
7187 (gnus-mime-display-security handle)
7188 (goto-char (point-max)))
7190 (delete-region (point) (cdr region))
7191 (set-marker (car region) nil)
7192 (set-marker (cdr region) nil))
7195 (defun gnus-mime-security-show-details (handle)
7196 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7198 (gnus-message 5 "No details.")
7199 (if gnus-mime-security-show-details-inline
7200 (let ((gnus-mime-security-button-pressed
7201 (not (get-text-property (point) 'gnus-mime-details)))
7202 (gnus-mime-security-button-line-format
7203 (get-text-property (point) 'gnus-line-format))
7204 (inhibit-read-only t))
7206 (while (eq (get-text-property (point) 'gnus-line-format)
7207 gnus-mime-security-button-line-format)
7211 (narrow-to-region (point) (point))
7212 (gnus-insert-mime-security-button handle))
7213 (delete-region (point)
7214 (or (text-property-not-all
7217 gnus-mime-security-button-line-format)
7220 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7221 (with-current-buffer gnus-mime-security-details-buffer
7224 (setq gnus-mime-security-details-buffer
7225 (gnus-get-buffer-create "*MIME Security Details*")))
7226 (with-current-buffer gnus-mime-security-details-buffer
7228 (goto-char (point-min)))
7229 (pop-to-buffer gnus-mime-security-details-buffer)))))
7231 (defun gnus-mime-security-press-button (handle)
7233 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7234 (gnus-mime-security-show-details handle)
7235 (gnus-mime-security-verify-or-decrypt handle))))
7237 (defun gnus-insert-mime-security-button (handle &optional displayed)
7238 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7241 (or (nth 2 (assoc protocol mm-verify-function-alist))
7242 (nth 2 (assoc protocol mm-decrypt-function-alist))
7244 (if (equal (car handle) "multipart/signed")
7245 " Signed" " Encrypted")
7248 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7251 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7252 gnus-tmp-pressed-details
7254 (setq gnus-tmp-details
7255 (if gnus-tmp-details
7256 (concat "\n" gnus-tmp-details)
7258 (setq gnus-tmp-pressed-details
7259 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7264 gnus-mime-security-button-line-format
7265 gnus-mime-security-button-line-format-alist
7266 `(keymap ,gnus-mime-security-button-map
7267 gnus-callback gnus-mime-security-press-button
7268 gnus-line-format ,gnus-mime-security-button-line-format
7269 gnus-mime-details ,gnus-mime-security-button-pressed
7270 article-type annotation
7273 ;; Exclude a newline.
7276 (widget-convert-button
7279 :action 'gnus-widget-press-button
7280 :button-keymap gnus-mime-security-button-map
7282 (lambda (widget/window &optional overlay pos)
7283 ;; Needed to properly clear the message due to a bug in
7284 ;; wid-edit (XEmacs only).
7285 (when (boundp 'help-echo-owns-message)
7286 (setq help-echo-owns-message t))
7289 (aref gnus-mouse-2 0))))))
7291 (defun gnus-mime-display-security (handle)
7293 (narrow-to-region (point) (point))
7294 (unless (gnus-unbuttonized-mime-type-p (car handle))
7295 (gnus-insert-mime-security-button handle))
7296 (gnus-mime-display-mixed (cdr handle))
7299 (unless (gnus-unbuttonized-mime-type-p (car handle))
7300 (let ((gnus-mime-security-button-line-format
7301 gnus-mime-security-button-end-line-format))
7302 (gnus-insert-mime-security-button handle)))
7303 (mm-set-handle-multipart-parameter
7305 (cons (set-marker (make-marker) (point-min))
7306 (set-marker (make-marker) (point-max))))))
7312 (run-hooks 'gnus-art-load-hook)
7314 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7315 ;;; gnus-art.el ends here