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., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, 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-lapsed gnus-article-date-lapsed)
1514 (gnus-treat-date-original gnus-article-date-original)
1515 (gnus-treat-date-user-defined gnus-article-date-user)
1516 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
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)
2209 (when (and wash-face-p
2211 (goto-char (point-min))
2212 (not (re-search-forward
2213 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2214 (gnus-buffer-live-p gnus-original-article-buffer))
2215 ;; If type `W f', use gnus-original-article-buffer,
2216 ;; otherwise use the current buffer because displaying
2217 ;; RFC822 parts calls this function too.
2218 (set-buffer gnus-original-article-buffer))
2220 (mail-narrow-to-head)
2221 (while (gnus-article-goto-header "X-Face")
2222 (push (mail-header-field-value) x-faces))
2223 (setq from (message-fetch-field "from"))))
2224 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2225 ;; single external face.
2226 (when (stringp gnus-article-x-face-command)
2227 (setq x-faces (list (car x-faces))))
2228 (while (and (setq face (pop x-faces))
2229 gnus-article-x-face-command
2231 ;; Check whether this face is censored.
2232 (not gnus-article-x-face-too-ugly)
2233 (and gnus-article-x-face-too-ugly from
2234 (not (string-match gnus-article-x-face-too-ugly
2236 ;; We display the face.
2237 (cond ((stringp gnus-article-x-face-command)
2238 ;; The command is a string, so we interpret the command
2239 ;; as a, well, command, and fork it off.
2240 (let ((process-connection-type nil))
2241 (gnus-set-process-query-on-exit-flag
2243 "article-x-face" nil shell-file-name
2244 shell-command-switch gnus-article-x-face-command)
2248 (process-send-region "article-x-face"
2249 (point-min) (point-max)))
2250 (process-send-eof "article-x-face")))
2251 ((functionp gnus-article-x-face-command)
2252 ;; The command is a lisp function, so we call it.
2253 (funcall gnus-article-x-face-command face))
2255 (error "%s is not a function"
2256 gnus-article-x-face-command)))))))))
2258 (defun article-decode-mime-words ()
2259 "Decode all MIME-encoded words in the article."
2261 (gnus-with-article-buffer
2262 (let ((inhibit-point-motion-hooks t)
2263 (mail-parse-charset gnus-newsgroup-charset)
2264 (mail-parse-ignored-charsets
2265 (with-current-buffer gnus-summary-buffer
2266 gnus-newsgroup-ignored-charsets)))
2267 (mail-decode-encoded-word-region (point-min) (point-max)))))
2269 (defun article-decode-charset (&optional prompt)
2270 "Decode charset-encoded text in the article.
2271 If PROMPT (the prefix), prompt for a coding system to use."
2273 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2274 (inhibit-read-only t)
2275 (mail-parse-charset gnus-newsgroup-charset)
2276 (mail-parse-ignored-charsets
2277 (save-excursion (condition-case nil
2278 (set-buffer gnus-summary-buffer)
2280 gnus-newsgroup-ignored-charsets))
2281 ct cte ctl charset format)
2284 (article-narrow-to-head)
2285 (setq ct (message-fetch-field "Content-Type" t)
2286 cte (message-fetch-field "Content-Transfer-Encoding" t)
2287 ctl (and ct (ignore-errors
2288 (mail-header-parse-content-type ct)))
2291 (mm-read-coding-system "Charset to decode: "))
2293 (mail-content-type-get ctl 'charset)))
2294 format (and ctl (mail-content-type-get ctl 'format)))
2296 (setq cte (mail-header-strip cte)))
2297 (if (and ctl (not (string-match "/" (car ctl))))
2299 (goto-char (point-max)))
2302 (narrow-to-region (point) (point-max))
2303 (when (and (eq mail-parse-charset 'gnus-decoded)
2304 (eq (mm-body-7-or-8) '8bit))
2305 ;; The text code could have been decoded.
2306 (setq charset mail-parse-charset))
2307 (when (and (or (not ctl)
2308 (equal (car ctl) "text/plain"))
2309 (not format)) ;; article with format will decode later.
2311 charset (and cte (intern (downcase
2312 (gnus-strip-whitespace cte))))
2315 (defun article-decode-encoded-words ()
2316 "Remove encoded-word encoding from headers."
2317 (let ((inhibit-point-motion-hooks t)
2318 (mail-parse-charset gnus-newsgroup-charset)
2319 (mail-parse-ignored-charsets
2320 (save-excursion (condition-case nil
2321 (set-buffer gnus-summary-buffer)
2323 gnus-newsgroup-ignored-charsets))
2324 (inhibit-read-only t))
2326 (article-narrow-to-head)
2327 (funcall gnus-decode-header-function (point-min) (point-max)))))
2329 (defun article-decode-group-name ()
2330 "Decode group names in `Newsgroups:'."
2331 (let ((inhibit-point-motion-hooks t)
2332 (inhibit-read-only t)
2333 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2334 (when (and (or gnus-group-name-charset-method-alist
2335 gnus-group-name-charset-group-alist)
2336 (gnus-buffer-live-p gnus-original-article-buffer))
2338 (article-narrow-to-head)
2339 (with-current-buffer gnus-original-article-buffer
2340 (goto-char (point-min)))
2341 (while (re-search-forward
2342 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2343 (replace-match (save-match-data
2344 (gnus-decode-newsgroups
2345 ;; XXX how to use data in article buffer?
2346 (with-current-buffer gnus-original-article-buffer
2348 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2351 gnus-newsgroup-name method))
2353 (goto-char (point-min))
2354 (with-current-buffer gnus-original-article-buffer
2355 (goto-char (point-min)))
2356 (while (re-search-forward
2357 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2358 (replace-match (save-match-data
2359 (gnus-decode-newsgroups
2360 ;; XXX how to use data in article buffer?
2361 (with-current-buffer gnus-original-article-buffer
2363 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2366 gnus-newsgroup-name method))
2369 (autoload 'idna-to-unicode "idna")
2371 (defun article-decode-idna-rhs ()
2372 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2375 (let ((inhibit-point-motion-hooks t)
2376 (inhibit-read-only t))
2377 (article-narrow-to-head)
2378 (goto-char (point-min))
2379 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2381 (when (save-match-data
2382 (and (setq ace (match-string 1))
2384 (and (re-search-backward "^[^ \t]" nil t)
2385 (looking-at "From\\|To\\|Cc")))
2386 (setq unicode (idna-to-unicode ace))))
2387 (unless (string= ace unicode)
2388 (replace-match unicode nil nil nil 1)))))))))
2390 (defun article-de-quoted-unreadable (&optional force read-charset)
2391 "Translate a quoted-printable-encoded article.
2392 If FORCE, decode the article whether it is marked as quoted-printable
2394 If READ-CHARSET, ask for a coding system."
2395 (interactive (list 'force current-prefix-arg))
2397 (let ((inhibit-read-only t) type charset)
2398 (if (gnus-buffer-live-p gnus-original-article-buffer)
2399 (with-current-buffer gnus-original-article-buffer
2401 (gnus-fetch-field "content-transfer-encoding"))
2402 (let* ((ct (gnus-fetch-field "content-type"))
2405 (mail-header-parse-content-type ct)))))
2406 (setq charset (and ctl
2407 (mail-content-type-get ctl 'charset)))
2408 (if (stringp charset)
2409 (setq charset (intern (downcase charset)))))))
2411 (setq charset (mm-read-coding-system "Charset: " charset)))
2413 (setq charset gnus-newsgroup-charset))
2415 (and type (let ((case-fold-search t))
2416 (string-match "quoted-printable" type))))
2418 (quoted-printable-decode-region
2419 (point) (point-max) (mm-charset-to-coding-system charset))))))
2421 (defun article-de-base64-unreadable (&optional force read-charset)
2422 "Translate a base64 article.
2423 If FORCE, decode the article whether it is marked as base64 not.
2424 If READ-CHARSET, ask for a coding system."
2425 (interactive (list 'force current-prefix-arg))
2427 (let ((inhibit-read-only t) type charset)
2428 (if (gnus-buffer-live-p gnus-original-article-buffer)
2429 (with-current-buffer gnus-original-article-buffer
2431 (gnus-fetch-field "content-transfer-encoding"))
2432 (let* ((ct (gnus-fetch-field "content-type"))
2435 (mail-header-parse-content-type ct)))))
2436 (setq charset (and ctl
2437 (mail-content-type-get ctl 'charset)))
2438 (if (stringp charset)
2439 (setq charset (intern (downcase charset)))))))
2441 (setq charset (mm-read-coding-system "Charset: " charset)))
2443 (setq charset gnus-newsgroup-charset))
2445 (and type (let ((case-fold-search t))
2446 (string-match "base64" type))))
2449 (narrow-to-region (point) (point-max))
2450 (base64-decode-region (point-min) (point-max))
2451 (mm-decode-coding-region
2452 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2457 (defun article-decode-HZ ()
2458 "Translate a HZ-encoded article."
2462 (let ((inhibit-read-only t))
2463 (rfc1843-decode-region (point-min) (point-max)))))
2465 (defun article-unsplit-urls ()
2466 "Remove the newlines that some other mailers insert into URLs."
2469 (let ((inhibit-read-only t))
2470 (goto-char (point-min))
2471 (while (re-search-forward
2472 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2473 (replace-match "\\1\\3" t)))
2474 (when (interactive-p)
2475 (gnus-treat-article nil))))
2478 (defun article-wash-html (&optional read-charset)
2479 "Format an HTML article.
2480 If READ-CHARSET, ask for a coding system."
2483 (let ((inhibit-read-only t)
2485 (when (gnus-buffer-live-p gnus-original-article-buffer)
2486 (with-current-buffer gnus-original-article-buffer
2487 (let* ((ct (gnus-fetch-field "content-type"))
2490 (mail-header-parse-content-type ct)))))
2491 (setq charset (and ctl
2492 (mail-content-type-get ctl 'charset)))
2493 (when (stringp charset)
2494 (setq charset (intern (downcase charset)))))))
2496 (setq charset (mm-read-coding-system "Charset: " charset)))
2498 (setq charset gnus-newsgroup-charset))
2500 (save-window-excursion
2502 (narrow-to-region (point) (point-max))
2503 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2504 (entry (assq func mm-text-html-washer-alist)))
2506 (setq func (cdr entry)))
2511 (apply (car func) (cdr func))))))))))
2513 (defun gnus-article-wash-html-with-w3 ()
2514 "Wash the current buffer with w3."
2516 (let ((w3-strict-width (window-width))
2517 (url-standalone-mode t)
2518 (url-gateway-unplugged t)
2519 (w3-honor-stylesheets nil))
2521 (w3-region (point-min) (point-max))
2524 (defun gnus-article-wash-html-with-w3m ()
2525 "Wash the current buffer with emacs-w3m."
2528 (narrow-to-region (point) (point-max))
2529 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2530 w3m-force-redisplay)
2531 (w3m-region (point-min) (point-max)))
2532 (when (and mm-inline-text-html-with-w3m-keymap
2533 (boundp 'w3m-minor-mode-map)
2535 (add-text-properties
2536 (point-min) (point-max)
2537 (list 'keymap w3m-minor-mode-map
2538 ;; Put the mark meaning this part was rendered by emacs-w3m.
2539 'mm-inline-text-html-with-w3m t)))))
2541 (defun article-hide-list-identifiers ()
2542 "Remove list identifies from the Subject header.
2543 The `gnus-list-identifiers' variable specifies what to do."
2545 (let ((inhibit-point-motion-hooks t)
2546 (regexp (if (consp gnus-list-identifiers)
2547 (mapconcat 'identity gnus-list-identifiers " *\\|")
2548 gnus-list-identifiers))
2549 (inhibit-read-only t))
2553 (article-narrow-to-head)
2554 (goto-char (point-min))
2555 (while (re-search-forward
2556 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2558 (delete-region (match-beginning 2) (match-end 0))
2559 (beginning-of-line))
2560 (when (re-search-forward
2561 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2562 (delete-region (match-beginning 1) (match-end 1))))))))
2564 (defun article-hide-pem (&optional arg)
2565 "Toggle hiding of any PEM headers and signatures in the current article.
2566 If given a negative prefix, always show; if given a positive prefix,
2568 (interactive (gnus-article-hidden-arg))
2569 (unless (gnus-article-check-hidden-text 'pem arg)
2571 (let ((inhibit-read-only t) end)
2572 (goto-char (point-min))
2573 ;; Hide the horrendously ugly "header".
2574 (when (and (search-forward
2575 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2577 (setq end (1+ (match-beginning 0))))
2578 (gnus-add-wash-type 'pem)
2579 (gnus-article-hide-text-type
2581 (if (search-forward "\n\n" nil t)
2585 ;; Hide the trailer as well
2586 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2588 (gnus-article-hide-text-type
2589 (match-beginning 0) (match-end 0) 'pem)))))))
2591 (defun article-strip-banner ()
2592 "Strip the banners specified by the `banner' group parameter and by
2593 `gnus-article-address-banner-alist'."
2597 (let ((inhibit-point-motion-hooks t))
2598 (when (gnus-parameter-banner gnus-newsgroup-name)
2599 (article-really-strip-banner
2600 (gnus-parameter-banner gnus-newsgroup-name)))
2601 (when gnus-article-address-banner-alist
2602 ;; It is necessary to encode from fields before checking,
2603 ;; because `mail-header-parse-addresses' does not work
2604 ;; (reliably) on decoded headers. And more, it is
2605 ;; impossible to use `gnus-fetch-original-field' here,
2606 ;; because `article-strip-banner' may be called in draft
2607 ;; buffers to preview them.
2608 (let ((from (save-restriction
2610 (article-narrow-to-head)
2611 (mail-fetch-field "from"))))
2614 (caar (mail-header-parse-addresses
2615 (mail-encode-encoded-word-string from)))))
2617 (dolist (pair gnus-article-address-banner-alist)
2618 (when (string-match (car pair) from)
2620 (article-really-strip-banner (cdr pair)))))))))))))
2622 (defun article-really-strip-banner (banner)
2623 "Strip the banner specified by the argument."
2626 (let ((inhibit-point-motion-hooks t)
2627 (gnus-signature-limit nil)
2628 (inhibit-read-only t))
2631 ((eq banner 'signature)
2632 (when (gnus-article-narrow-to-signature)
2635 (delete-region (point) (point-max))))
2637 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2638 (while (re-search-forward banner nil t)
2639 (delete-region (match-beginning 0) (match-end 0)))))
2641 (while (re-search-forward banner nil t)
2642 (delete-region (match-beginning 0) (match-end 0)))))))))
2644 (defun article-babel ()
2645 "Translate article using an online translation service."
2648 (gnus-with-article-buffer
2649 (when (article-goto-body)
2650 (let* ((start (point))
2652 (orig (buffer-substring start end))
2653 (trans (babel-as-string orig)))
2655 (narrow-to-region start end)
2656 (delete-region start end)
2659 (defun article-hide-signature (&optional arg)
2660 "Hide the signature in the current article.
2661 If given a negative prefix, always show; if given a positive prefix,
2663 (interactive (gnus-article-hidden-arg))
2664 (unless (gnus-article-check-hidden-text 'signature arg)
2667 (let ((inhibit-read-only t))
2668 (when (gnus-article-narrow-to-signature)
2669 (gnus-article-hide-text-type
2670 (point-min) (point-max) 'signature))))))
2671 (gnus-set-mode-line 'article))
2673 (defun article-strip-headers-in-body ()
2674 "Strip offensive headers from bodies."
2678 (let ((case-fold-search t))
2679 (when (looking-at "x-no-archive:")
2680 (gnus-delete-line)))))
2682 (defun article-strip-leading-blank-lines ()
2683 "Remove all blank lines from the beginning of the article."
2686 (let ((inhibit-point-motion-hooks t)
2687 (inhibit-read-only t))
2688 (when (article-goto-body)
2689 (while (and (not (eobp))
2690 (looking-at "[ \t]*$"))
2691 (gnus-delete-line))))))
2693 (defun article-narrow-to-head ()
2694 "Narrow the buffer to the head of the message.
2695 Point is left at the beginning of the narrowed-to region."
2697 (goto-char (point-min))
2698 (if (search-forward "\n\n" nil 1)
2701 (goto-char (point-min)))
2703 (defun article-goto-body ()
2704 "Place point at the start of the body."
2705 (goto-char (point-min))
2707 ;; This variable is only bound when dealing with separate
2709 (article-goto-body-goes-to-point-min-p
2711 ((search-forward "\n\n" nil t)
2714 (goto-char (point-max))
2717 (defun article-strip-multiple-blank-lines ()
2718 "Replace consecutive blank lines with one empty line."
2721 (let ((inhibit-point-motion-hooks t)
2722 (inhibit-read-only t))
2723 ;; First make all blank lines empty.
2725 (while (re-search-forward "^[ \t]+$" nil t)
2726 (unless (gnus-annotation-in-region-p
2727 (match-beginning 0) (match-end 0))
2728 (replace-match "" nil t)))
2729 ;; Then replace multiple empty lines with a single empty line.
2731 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2732 (unless (gnus-annotation-in-region-p
2733 (match-beginning 0) (match-end 0))
2734 (delete-region (match-beginning 1) (match-end 1)))))))
2736 (defun article-strip-leading-space ()
2737 "Remove all white space from the beginning of the lines in the article."
2740 (let ((inhibit-point-motion-hooks t)
2741 (inhibit-read-only t))
2743 (while (re-search-forward "^[ \t]+" nil t)
2744 (replace-match "" t t)))))
2746 (defun article-strip-trailing-space ()
2747 "Remove all white space from the end of the lines in the article."
2750 (let ((inhibit-point-motion-hooks t)
2751 (inhibit-read-only t))
2753 (while (re-search-forward "[ \t]+$" nil t)
2754 (replace-match "" t t)))))
2756 (defun article-strip-blank-lines ()
2757 "Strip leading, trailing and multiple blank lines."
2759 (article-strip-leading-blank-lines)
2760 (article-remove-trailing-blank-lines)
2761 (article-strip-multiple-blank-lines))
2763 (defun article-strip-all-blank-lines ()
2764 "Strip all blank lines."
2767 (let ((inhibit-point-motion-hooks t)
2768 (inhibit-read-only t))
2770 (while (re-search-forward "^[ \t]*\n" nil t)
2771 (replace-match "" t t)))))
2773 (defun gnus-article-narrow-to-signature ()
2774 "Narrow to the signature; return t if a signature is found, else nil."
2775 (let ((inhibit-point-motion-hooks t))
2776 (when (gnus-article-search-signature)
2778 ;; Check whether we have some limits to what we consider
2779 ;; to be a signature.
2780 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2781 (list gnus-signature-limit)))
2783 (while (setq limit (pop limits))
2784 (if (or (and (integerp limit)
2785 (< (- (point-max) (point)) limit))
2787 (< (count-lines (point) (point-max)) limit))
2788 (and (functionp limit)
2790 (and (stringp limit)
2791 (not (re-search-forward limit nil t))))
2792 () ; This limit did not succeed.
2796 (narrow-to-region (point) (point-max))
2799 (defun gnus-article-search-signature ()
2800 "Search the current buffer for the signature separator.
2801 Put point at the beginning of the signature separator."
2802 (let ((cur (point)))
2803 (goto-char (point-max))
2804 (if (if (stringp gnus-signature-separator)
2805 (re-search-backward gnus-signature-separator nil t)
2806 (let ((seps gnus-signature-separator))
2808 (not (re-search-backward (car seps) nil t)))
2815 (defun gnus-article-hidden-arg ()
2816 "Return the current prefix arg as a number, or 0 if no prefix."
2817 (list (if current-prefix-arg
2818 (prefix-numeric-value current-prefix-arg)
2821 (defun gnus-article-check-hidden-text (type arg)
2822 "Return nil if hiding is necessary.
2823 Arg can be nil or a number. nil and positive means hide, negative
2824 means show, 0 means toggle."
2827 (let ((hide (gnus-article-hidden-text-p type)))
2833 (gnus-article-show-hidden-text type)
2836 (if (eq hide 'hidden)
2838 (gnus-article-show-hidden-text type)
2842 (defun gnus-article-hidden-text-p (type)
2843 "Say whether the current buffer contains hidden text of type TYPE."
2844 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2846 (not (get-text-property pos 'invisible))
2847 (not (get-text-property pos 'dummy-invisible)))
2849 (text-property-any (1+ pos) (point-max) 'article-type type)))
2854 (defun gnus-article-show-hidden-text (type &optional dummy)
2855 "Show all hidden text of type TYPE.
2856 Originally it is hide instead of DUMMY."
2857 (let ((inhibit-read-only t)
2858 (inhibit-point-motion-hooks t))
2859 (gnus-remove-text-properties-when
2861 (point-min) (point-max)
2862 (cons 'article-type (cons type
2863 gnus-hidden-properties)))
2864 (gnus-delete-wash-type type)))
2866 (defconst article-time-units
2867 `((year . ,(* 365.25 24 60 60))
2868 (week . ,(* 7 24 60 60))
2869 (day . ,(* 24 60 60))
2873 "Mapping from time units to seconds.")
2875 (defun gnus-article-forward-header ()
2876 "Move point to the start of the next header.
2877 If the current header is a continuation header, this can be several
2882 (if (looking-at "[ \t]+[^ \t]")
2886 (defun article-date-ut (&optional type highlight)
2887 "Convert DATE date to universal time in the current article.
2888 If TYPE is `local', convert to local time; if it is `lapsed', output
2889 how much time has lapsed since DATE. For `lapsed', the value of
2890 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2891 should replace the \"Date:\" one, or should be added below it."
2892 (interactive (list 'ut t))
2893 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2894 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
2898 (article-lapsed-timer
2902 (case-fold-search t)
2903 (inhibit-read-only t)
2904 (inhibit-point-motion-hooks t)
2905 pos date bface eface)
2909 (goto-char (point-min))
2910 (while (or (setq date (get-text-property (setq pos (point))
2912 (when (setq pos (next-single-property-change
2913 (point) 'original-date))
2914 (setq date (get-text-property pos 'original-date))
2916 (narrow-to-region pos (or (text-property-any pos (point-max)
2919 (goto-char (point-min))
2920 (when (re-search-forward tdate-regexp nil t)
2921 (setq bface (get-text-property (point-at-bol) 'face)
2922 eface (get-text-property (1- (point-at-eol)) 'face)))
2923 (goto-char (point-min))
2925 ;; Delete any old Date headers.
2926 (while (re-search-forward date-regexp nil t)
2928 (delete-region (point-at-bol) (progn
2929 (gnus-article-forward-header)
2931 (delete-region (point-at-bol) (progn
2932 (gnus-article-forward-header)
2935 (setq pos (point))))
2936 (when (and (not pos)
2937 (re-search-forward tdate-regexp nil t))
2939 (gnus-goto-char pos)
2940 (insert (article-make-date-line date (or type 'ut)))
2946 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2947 (put-text-property (match-beginning 1) (1+ (match-end 1))
2949 (put-text-property (match-beginning 2) (match-end 2)
2951 (put-text-property (point-min) (1- (point-max)) 'original-date date)
2952 (goto-char (point-max))
2955 (defun article-make-date-line (date type)
2956 "Return a DATE line of TYPE."
2957 (unless (memq type '(local ut original user iso8601 lapsed english))
2958 (error "Unknown conversion type: %s" type))
2960 (let ((time (date-to-time date)))
2962 ;; Convert to the local timezone.
2964 (concat "Date: " (message-make-date time)))
2965 ;; Convert to Universal Time.
2970 (let* ((e (parse-time-string date))
2971 (tm (apply 'encode-time e))
2973 (ls (- (cadr tm) (car (current-time-zone time)))))
2974 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2975 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2979 ;; Get the original date from the article.
2980 ((eq type 'original)
2981 (concat "Date: " (if (string-match "\n+$" date)
2982 (substring date 0 (match-beginning 0))
2984 ;; Let the user define the format.
2986 (let ((format (or (condition-case nil
2987 (with-current-buffer gnus-summary-buffer
2988 gnus-article-time-format)
2990 gnus-article-time-format)))
2991 (if (functionp format)
2992 (funcall format time)
2993 (concat "Date: " (format-time-string format time)))))
2996 (let ((tz (car (current-time-zone time))))
2999 (format-time-string "%Y%m%dT%H%M%S" time)
3000 (format "%s%02d%02d"
3001 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3002 (/ (% (abs tz) 3600) 60)))))
3003 ;; Do an X-Sent lapsed format.
3005 ;; If the date is seriously mangled, the timezone functions are
3006 ;; liable to bug out, so we ignore all errors.
3007 (let* ((now (current-time))
3008 (real-time (subtract-time now time))
3009 (real-sec (and real-time
3010 (+ (* (float (car real-time)) 65536)
3012 (sec (and real-time (abs real-sec)))
3022 ;; This is a bit convoluted, but basically we go
3023 ;; through the time units for years, weeks, etc,
3024 ;; and divide things to see whether that results
3025 ;; in positive answers.
3028 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3029 ;; The (remaining) seconds are too few to
3030 ;; be divided into this time unit.
3032 ;; It's big enough, so we output it.
3033 (setq sec (- sec (* num (cdr unit))))
3035 (concat (if prev ", " "") (int-to-string
3037 " " (symbol-name (car unit))
3038 (if (> num 1) "s" ""))
3040 article-time-units "")
3041 ;; If dates are odd, then it might appear like the
3042 ;; article was sent in the future.
3045 " in the future"))))))
3046 ;; Display the date in proper English
3048 (let ((dtime (decode-time time)))
3051 (number-to-string (nth 3 dtime))
3052 (let ((digit (% (nth 3 dtime) 10)))
3054 ((memq (nth 3 dtime) '(11 12 13)) "th")
3060 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3062 (number-to-string (nth 5 dtime))
3064 (format "%02d" (nth 2 dtime))
3066 (format "%02d" (nth 1 dtime)))))))
3068 (format "Date: %s (from Gnus)" date))))
3070 (defun article-date-local (&optional highlight)
3071 "Convert the current article date to the local timezone."
3072 (interactive (list t))
3073 (article-date-ut 'local highlight))
3075 (defun article-date-english (&optional highlight)
3076 "Convert the current article date to something that is proper English."
3077 (interactive (list t))
3078 (article-date-ut 'english highlight))
3080 (defun article-date-original (&optional highlight)
3081 "Convert the current article date to what it was originally.
3082 This is only useful if you have used some other date conversion
3083 function and want to see what the date was before converting."
3084 (interactive (list t))
3085 (article-date-ut 'original highlight))
3087 (defun article-date-lapsed (&optional highlight)
3088 "Convert the current article date to time lapsed since it was sent."
3089 (interactive (list t))
3090 (article-date-ut 'lapsed highlight))
3092 (defun article-update-date-lapsed ()
3093 "Function to be run from a timer to update the lapsed time line."
3095 (let (deactivate-mark)
3100 (set-buffer (window-buffer w))
3101 (when (eq major-mode 'gnus-article-mode)
3102 (let ((mark (point-marker)))
3103 (goto-char (point-min))
3104 (when (re-search-forward "^X-Sent:" nil t)
3105 (article-date-lapsed t))
3106 (goto-char (marker-position mark))
3107 (move-marker mark nil))))
3110 (defun gnus-start-date-timer (&optional n)
3111 "Start a timer to update the X-Sent header in the article buffers.
3112 The numerical prefix says how frequently (in seconds) the function
3117 (gnus-stop-date-timer)
3118 (setq article-lapsed-timer
3119 (run-at-time 1 n 'article-update-date-lapsed)))
3121 (defun gnus-stop-date-timer ()
3122 "Stop the X-Sent timer."
3124 (when article-lapsed-timer
3125 (nnheader-cancel-timer article-lapsed-timer)
3126 (setq article-lapsed-timer nil)))
3128 (defun article-date-user (&optional highlight)
3129 "Convert the current article date to the user-defined format.
3130 This format is defined by the `gnus-article-time-format' variable."
3131 (interactive (list t))
3132 (article-date-ut 'user highlight))
3134 (defun article-date-iso8601 (&optional highlight)
3135 "Convert the current article date to ISO8601."
3136 (interactive (list t))
3137 (article-date-ut 'iso8601 highlight))
3139 (defmacro gnus-article-save-original-date (&rest forms)
3140 "Save the original date as a text property and evaluate FORMS."
3141 `(let* ((case-fold-search t)
3143 (goto-char (point-min))
3144 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3147 (date (when (and start
3148 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3150 (buffer-substring-no-properties start
3151 (match-beginning 0)))))
3152 (goto-char (point-max))
3153 (skip-chars-backward "\n")
3154 (put-text-property (point-min) (point) 'original-date date)
3156 (goto-char (point-max))
3157 (skip-chars-backward "\n")
3158 (put-text-property (point-min) (point) 'original-date date)))
3160 ;; (defun article-show-all ()
3161 ;; "Show all hidden text in the article buffer."
3164 ;; (let ((inhibit-read-only t))
3165 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3167 (defun article-remove-leading-whitespace ()
3168 "Remove excessive whitespace from all headers."
3172 (let ((inhibit-read-only t))
3173 (article-narrow-to-head)
3174 (goto-char (point-min))
3175 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3176 (delete-region (match-beginning 1) (match-end 1)))))))
3178 (defun article-emphasize (&optional arg)
3179 "Emphasize text according to `gnus-emphasis-alist'."
3180 (interactive (gnus-article-hidden-arg))
3181 (unless (gnus-article-check-hidden-text 'emphasis arg)
3185 (with-current-buffer gnus-summary-buffer
3186 gnus-article-emphasis-alist)
3188 gnus-emphasis-alist))
3189 (inhibit-read-only t)
3190 (props (append '(article-type emphasis)
3191 gnus-hidden-properties))
3192 regexp elem beg invisible visible face)
3195 (while (setq elem (pop alist))
3197 (setq regexp (car elem)
3198 invisible (nth 1 elem)
3199 visible (nth 2 elem)
3201 (while (re-search-forward regexp nil t)
3202 (when (and (match-beginning visible) (match-beginning invisible))
3203 (gnus-article-hide-text
3204 (match-beginning invisible) (match-end invisible) props)
3205 (gnus-article-unhide-text-type
3206 (match-beginning visible) (match-end visible) 'emphasis)
3207 (gnus-put-overlay-excluding-newlines
3208 (match-beginning visible) (match-end visible) 'face face)
3209 (gnus-add-wash-type 'emphasis)
3210 (goto-char (match-end invisible)))))))))
3212 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3213 "Setup newsgroup emphasis alist."
3214 (unless gnus-article-emphasis-alist
3215 (let ((name (and gnus-newsgroup-name
3216 (gnus-group-real-name gnus-newsgroup-name))))
3217 (make-local-variable 'gnus-article-emphasis-alist)
3218 (setq gnus-article-emphasis-alist
3220 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3221 (while (setq elem (pop alist))
3222 (when (and name (string-match (car elem) name))
3224 highlight (copy-sequence (cdr elem)))))
3226 (copy-sequence highlight-words)
3227 (if gnus-newsgroup-name
3228 (copy-sequence (gnus-group-find-parameter
3229 gnus-newsgroup-name 'highlight-words t)))
3230 gnus-emphasis-alist)))))
3233 (defvar gnus-summary-article-menu)
3234 (defvar gnus-summary-post-menu))
3236 ;;; Saving functions.
3238 (defun gnus-article-save (save-buffer file &optional num)
3239 "Save the currently selected article."
3240 (unless gnus-save-all-headers
3241 ;; Remove headers according to `gnus-saved-headers'.
3242 (let ((gnus-visible-headers
3243 (or gnus-saved-headers gnus-visible-headers))
3244 (gnus-article-buffer save-buffer))
3246 (set-buffer save-buffer)
3247 (article-hide-headers 1 t))))
3248 (save-window-excursion
3249 (if (not gnus-default-article-saver)
3250 (error "No default saver is defined")
3251 ;; !!! Magic! The saving functions all save
3252 ;; `gnus-save-article-buffer' (or so they think), but we
3253 ;; bind that variable to our save-buffer.
3254 (set-buffer gnus-article-buffer)
3255 (let* ((gnus-save-article-buffer save-buffer)
3258 ((not gnus-prompt-before-saving) 'default)
3259 ((eq gnus-prompt-before-saving 'always) nil)
3261 (gnus-number-of-articles-to-be-saved
3262 (when (eq gnus-prompt-before-saving t)
3264 (set-buffer gnus-article-current-summary)
3265 (funcall gnus-default-article-saver filename)))))
3267 (defun gnus-read-save-file-name (prompt &optional filename
3268 function group headers variable)
3270 (funcall function group headers (symbol-value variable)))
3275 ((eq filename 'default)
3281 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3284 (if (and gnus-number-of-articles-to-be-saved
3285 (> gnus-number-of-articles-to-be-saved 1))
3286 (format "these %d articles"
3287 gnus-number-of-articles-to-be-saved)
3290 ;; Let the split methods have their say.
3292 ;; No split name was found.
3295 (concat prompt " (default "
3296 (file-name-nondirectory default-name) ") ")
3297 (file-name-directory default-name)
3299 ;; A single group name is returned.
3300 ((stringp split-name)
3302 (funcall function split-name headers
3303 (symbol-value variable)))
3305 (concat prompt " (default "
3306 (file-name-nondirectory default-name) ") ")
3307 (file-name-directory default-name)
3309 ;; A single split name was found
3310 ((= 1 (length split-name))
3311 (let* ((name (expand-file-name
3313 gnus-article-save-directory))
3314 (dir (cond ((file-directory-p name)
3315 (file-name-as-directory name))
3316 ((file-exists-p name) name)
3317 (t gnus-article-save-directory))))
3319 (concat prompt " (default " name ") ")
3321 ;; A list of splits was found.
3323 (setq split-name (nreverse split-name))
3325 (let ((file-name-history
3326 (nconc split-name file-name-history)))
3330 (concat prompt " (`M-p' for defaults) ")
3331 gnus-article-save-directory
3333 gnus-article-save-directory)))
3334 (car (push result file-name-history)))))))
3335 ;; Create the directory.
3336 (gnus-make-directory (file-name-directory file))
3337 ;; If we have read a directory, we append the default file name.
3338 (when (file-directory-p file)
3339 (setq file (expand-file-name (file-name-nondirectory
3341 (file-name-as-directory file))))
3342 ;; Possibly translate some characters.
3343 (nnheader-translate-file-chars file))))))
3344 (gnus-make-directory (file-name-directory result))
3345 (set variable result)))
3347 (defun gnus-article-archive-name (group)
3348 "Return the first instance of an \"Archive-name\" in the current buffer."
3349 (let ((case-fold-search t))
3350 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3351 (nnheader-concat gnus-article-save-directory
3352 (match-string 1)))))
3354 (defun gnus-article-nndoc-name (group)
3355 "If GROUP is an nndoc group, return the name of the parent group."
3356 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3357 (gnus-group-get-parameter group 'save-article-group)))
3359 (defun gnus-summary-save-in-rmail (&optional filename)
3360 "Append this article to Rmail file.
3361 Optional argument FILENAME specifies file name.
3362 Directory to save to is default to `gnus-article-save-directory'."
3363 (setq filename (gnus-read-save-file-name
3364 "Save %s in rmail file:" filename
3365 gnus-rmail-save-name gnus-newsgroup-name
3366 gnus-current-headers 'gnus-newsgroup-last-rmail))
3367 (gnus-eval-in-buffer-window gnus-save-article-buffer
3371 (gnus-output-to-rmail filename))))
3374 (defun gnus-summary-save-in-mail (&optional filename)
3375 "Append this article to Unix mail file.
3376 Optional argument FILENAME specifies file name.
3377 Directory to save to is default to `gnus-article-save-directory'."
3378 (setq filename (gnus-read-save-file-name
3379 "Save %s in Unix mail file:" filename
3380 gnus-mail-save-name gnus-newsgroup-name
3381 gnus-current-headers 'gnus-newsgroup-last-mail))
3382 (gnus-eval-in-buffer-window gnus-save-article-buffer
3386 (if (and (file-readable-p filename)
3387 (file-regular-p filename)
3388 (mail-file-babyl-p filename))
3389 (rmail-output-to-rmail-file filename t)
3390 (gnus-output-to-mail filename)))))
3393 (defun gnus-summary-save-in-file (&optional filename overwrite)
3394 "Append this article to file.
3395 Optional argument FILENAME specifies file name.
3396 Directory to save to is default to `gnus-article-save-directory'."
3397 (setq filename (gnus-read-save-file-name
3398 "Save %s in file:" filename
3399 gnus-file-save-name gnus-newsgroup-name
3400 gnus-current-headers 'gnus-newsgroup-last-file))
3401 (gnus-eval-in-buffer-window gnus-save-article-buffer
3405 (when (and overwrite
3406 (file-exists-p filename))
3407 (delete-file filename))
3408 (gnus-output-to-file filename))))
3411 (defun gnus-summary-write-to-file (&optional filename)
3412 "Write this article to a file, overwriting it if the file exists.
3413 Optional argument FILENAME specifies file name.
3414 The directory to save in defaults to `gnus-article-save-directory'."
3415 (gnus-summary-save-in-file nil t))
3417 (defun gnus-summary-save-body-in-file (&optional filename)
3418 "Append this article body to a file.
3419 Optional argument FILENAME specifies file name.
3420 The directory to save in defaults to `gnus-article-save-directory'."
3421 (setq filename (gnus-read-save-file-name
3422 "Save %s body in file:" filename
3423 gnus-file-save-name gnus-newsgroup-name
3424 gnus-current-headers 'gnus-newsgroup-last-file))
3425 (gnus-eval-in-buffer-window gnus-save-article-buffer
3429 (when (article-goto-body)
3430 (narrow-to-region (point) (point-max)))
3431 (gnus-output-to-file filename))))
3434 (defun gnus-summary-save-in-pipe (&optional command)
3435 "Pipe this article to subprocess."
3437 (cond ((and (eq command 'default)
3438 gnus-last-shell-command)
3439 gnus-last-shell-command)
3444 "Shell command on %s: "
3445 (if (and gnus-number-of-articles-to-be-saved
3446 (> gnus-number-of-articles-to-be-saved 1))
3447 (format "these %d articles"
3448 gnus-number-of-articles-to-be-saved)
3450 gnus-last-shell-command))))
3451 (when (string-equal command "")
3452 (if gnus-last-shell-command
3453 (setq command gnus-last-shell-command)
3454 (error "A command is required")))
3455 (gnus-eval-in-buffer-window gnus-article-buffer
3458 (shell-command-on-region (point-min) (point-max) command nil)))
3459 (setq gnus-last-shell-command command))
3461 (defun gnus-summary-pipe-to-muttprint (&optional command)
3462 "Pipe this article to muttprint."
3463 (setq command (read-string
3464 "Print using command: " gnus-summary-muttprint-program
3465 nil gnus-summary-muttprint-program))
3466 (gnus-summary-save-in-pipe command))
3468 ;;; Article file names when saving.
3470 (defun gnus-capitalize-newsgroup (newsgroup)
3471 "Capitalize NEWSGROUP name."
3472 (when (not (zerop (length newsgroup)))
3473 (concat (char-to-string (upcase (aref newsgroup 0)))
3474 (substring newsgroup 1))))
3476 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3477 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3478 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3479 Otherwise, it is like ~/News/news/group/num."
3482 (concat (if (gnus-use-long-file-name 'not-save)
3483 (gnus-capitalize-newsgroup newsgroup)
3484 (gnus-newsgroup-directory-form newsgroup))
3485 "/" (int-to-string (mail-header-number headers)))
3486 gnus-article-save-directory)))
3488 (string-equal (file-name-directory default)
3489 (file-name-directory last-file))
3490 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3492 (or last-file default))))
3494 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3495 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3496 If variable `gnus-use-long-file-name' is non-nil, it is
3497 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3500 (concat (if (gnus-use-long-file-name 'not-save)
3502 (gnus-newsgroup-directory-form newsgroup))
3503 "/" (int-to-string (mail-header-number headers)))
3504 gnus-article-save-directory)))
3506 (string-equal (file-name-directory default)
3507 (file-name-directory last-file))
3508 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3510 (or last-file default))))
3512 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3513 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3514 If variable `gnus-use-long-file-name' is non-nil, it is
3515 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3518 (if (gnus-use-long-file-name 'not-save)
3521 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3523 gnus-article-save-directory)))
3525 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3526 "Generate file name from sender."
3527 (let ((from (mail-header-from headers)))
3529 (if (and from (string-match "\\([^ <]+\\)@" from))
3530 (match-string 1 from)
3532 gnus-article-save-directory)))
3534 (defun article-verify-x-pgp-sig ()
3537 (if (gnus-buffer-live-p gnus-original-article-buffer)
3538 (let ((sig (with-current-buffer gnus-original-article-buffer
3539 (gnus-fetch-field "X-PGP-Sig")))
3543 (mml2015-clear-verify-function))
3545 (insert-buffer-substring gnus-original-article-buffer)
3546 (setq items (split-string sig))
3547 (message-narrow-to-head)
3548 (let ((inhibit-point-motion-hooks t)
3549 (case-fold-search t))
3550 ;; Don't verify multiple headers.
3551 (setq headers (mapconcat (lambda (header)
3553 (mail-fetch-field header)
3555 (split-string (nth 1 items) ",") "")))
3556 (delete-region (point-min) (point-max))
3557 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3558 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3563 (if (looking-at "^-")
3566 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3567 (insert "Version: " (car items) "\n\n")
3568 (insert (mapconcat 'identity (cddr items) "\n"))
3569 (insert "\n-----END PGP SIGNATURE-----\n")
3570 (let ((mm-security-handle (list (format "multipart/signed"))))
3571 (mml2015-clean-buffer)
3572 (let ((coding-system-for-write (or gnus-newsgroup-charset
3574 (funcall (mml2015-clear-verify-function)))
3576 (or (mm-handle-multipart-ctl-parameter
3577 mm-security-handle 'gnus-details)
3578 (mm-handle-multipart-ctl-parameter
3579 mm-security-handle 'gnus-info)))))
3581 (let ((inhibit-read-only t) bface eface)
3583 (message-narrow-to-head)
3584 (goto-char (point-max))
3586 (setq bface (get-text-property (point-at-bol) 'face)
3587 eface (get-text-property (1- (point-at-eol)) 'face))
3588 (message-remove-header "X-Gnus-PGP-Verify")
3589 (if (re-search-forward "^X-PGP-Sig:" nil t)
3591 (goto-char (point-max)))
3592 (narrow-to-region (point) (point))
3593 (insert "X-Gnus-PGP-Verify: " info "\n")
3594 (goto-char (point-min))
3597 (if (not (looking-at "^[ \t]"))
3601 (goto-char (point-min))
3602 (when (looking-at "\\([^:]+\\): *")
3603 (put-text-property (match-beginning 1) (1+ (match-end 1))
3605 (put-text-property (match-end 0) (point-max)
3606 'face eface)))))))))
3608 (defun article-verify-cancel-lock ()
3609 "Verify Cancel-Lock header."
3611 (if (gnus-buffer-live-p gnus-original-article-buffer)
3612 (canlock-verify gnus-original-article-buffer)))
3619 (setq afunc (car func)
3622 gfunc (intern (format "gnus-%s" func))))
3624 (when (fboundp afunc)
3625 `(lambda (&optional interactive &rest args)
3626 ,(documentation afunc t)
3627 (interactive (list t))
3629 (set-buffer gnus-article-buffer)
3631 (call-interactively ',afunc)
3632 (apply ',afunc args))))))))
3633 '(article-hide-headers
3634 article-verify-x-pgp-sig
3635 article-verify-cancel-lock
3636 article-hide-boring-headers
3637 article-treat-overstrike
3638 article-treat-ansi-sequences
3639 article-fill-long-lines
3640 article-capitalize-sentences
3642 article-remove-leading-whitespace
3643 article-display-x-face
3644 article-display-face
3645 article-de-quoted-unreadable
3646 article-de-base64-unreadable
3649 article-unsplit-urls
3650 article-hide-list-identifiers
3651 article-strip-banner
3654 article-hide-signature
3655 article-strip-headers-in-body
3656 article-remove-trailing-blank-lines
3657 article-strip-leading-blank-lines
3658 article-strip-multiple-blank-lines
3659 article-strip-leading-space
3660 article-strip-trailing-space
3661 article-strip-blank-lines
3662 article-strip-all-blank-lines
3664 article-date-english
3665 article-date-iso8601
3666 article-date-original
3668 article-decode-mime-words
3669 article-decode-charset
3670 article-decode-encoded-words
3674 article-treat-dumbquotes
3675 article-normalize-headers
3676 ;; (article-show-all . gnus-article-show-all-headers)
3680 ;;; Gnus article mode
3683 (put 'gnus-article-mode 'mode-class 'special)
3685 (set-keymap-parent gnus-article-mode-map widget-keymap)
3687 (gnus-define-keys gnus-article-mode-map
3688 " " gnus-article-goto-next-page
3689 "\177" gnus-article-goto-prev-page
3690 [delete] gnus-article-goto-prev-page
3691 [backspace] gnus-article-goto-prev-page
3692 "\C-c^" gnus-article-refer-article
3693 "h" gnus-article-show-summary
3694 "s" gnus-article-show-summary
3695 "\C-c\C-m" gnus-article-mail
3696 "?" gnus-article-describe-briefly
3697 "e" gnus-summary-edit-article
3698 "<" beginning-of-buffer
3700 "\C-c\C-i" gnus-info-find-node
3702 "R" gnus-article-reply-with-original
3703 "F" gnus-article-followup-with-original
3704 "\C-hk" gnus-article-describe-key
3705 "\C-hc" gnus-article-describe-key-briefly
3707 "\C-d" gnus-article-read-summary-keys
3708 "\M-*" gnus-article-read-summary-keys
3709 "\M-#" gnus-article-read-summary-keys
3710 "\M-^" gnus-article-read-summary-keys
3711 "\M-g" gnus-article-read-summary-keys)
3713 (substitute-key-definition
3714 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3716 (defun gnus-article-make-menu-bar ()
3717 (unless (boundp 'gnus-article-commands-menu)
3718 (gnus-summary-make-menu-bar))
3719 (gnus-turn-off-edit-menu 'article)
3720 (unless (boundp 'gnus-article-article-menu)
3722 gnus-article-article-menu gnus-article-mode-map ""
3724 ["Scroll forwards" gnus-article-goto-next-page t]
3725 ["Scroll backwards" gnus-article-goto-prev-page t]
3726 ["Show summary" gnus-article-show-summary t]
3727 ["Fetch Message-ID at point" gnus-article-refer-article t]
3728 ["Mail to address at point" gnus-article-mail t]
3729 ["Send a bug report" gnus-bug t]))
3732 gnus-article-treatment-menu gnus-article-mode-map ""
3733 ;; Fixme: this should use :active (and maybe :visible).
3735 ["Hide headers" gnus-article-hide-headers t]
3736 ["Hide signature" gnus-article-hide-signature t]
3737 ["Hide citation" gnus-article-hide-citation t]
3738 ["Treat overstrike" gnus-article-treat-overstrike t]
3739 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3740 ["Remove carriage return" gnus-article-remove-cr t]
3741 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3742 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3743 ["Remove base64" gnus-article-de-base64-unreadable t]
3744 ["Treat html" gnus-article-wash-html t]
3745 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3746 ["Decode HZ" gnus-article-decode-HZ t]))
3748 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3750 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3752 (gnus-run-hooks 'gnus-article-menu-hook)))
3754 (defun gnus-article-mode ()
3755 "Major mode for displaying an article.
3757 All normal editing commands are switched off.
3759 The following commands are available in addition to all summary mode
3761 \\<gnus-article-mode-map>
3762 \\[gnus-article-next-page]\t Scroll the article one page forwards
3763 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3764 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3765 \\[gnus-article-show-summary]\t Display the summary buffer
3766 \\[gnus-article-mail]\t Send a reply to the address near point
3767 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3768 \\[gnus-info-find-node]\t Go to the Gnus info node"
3770 (kill-all-local-variables)
3771 (gnus-simplify-mode-line)
3772 (setq mode-name "Article")
3773 (setq major-mode 'gnus-article-mode)
3774 (make-local-variable 'minor-mode-alist)
3775 (use-local-map gnus-article-mode-map)
3776 (when (gnus-visual-p 'article-menu 'menu)
3777 (gnus-article-make-menu-bar)
3778 (when gnus-summary-tool-bar-map
3779 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3780 (gnus-update-format-specifications nil 'article-mode)
3781 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3782 (set (make-local-variable 'gnus-page-broken) nil)
3783 (make-local-variable 'gnus-button-marker-list)
3784 (make-local-variable 'gnus-article-current-summary)
3785 (make-local-variable 'gnus-article-mime-handles)
3786 (make-local-variable 'gnus-article-decoded-p)
3787 (make-local-variable 'gnus-article-mime-handle-alist)
3788 (make-local-variable 'gnus-article-wash-types)
3789 (make-local-variable 'gnus-article-image-alist)
3790 (make-local-variable 'gnus-article-charset)
3791 (make-local-variable 'gnus-article-ignored-charsets)
3792 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3793 (set (make-local-variable 'nobreak-char-display) nil)
3794 (gnus-set-default-directory)
3795 (buffer-disable-undo)
3796 (setq buffer-read-only t
3797 show-trailing-whitespace nil)
3798 (set-syntax-table gnus-article-mode-syntax-table)
3799 (mm-enable-multibyte)
3800 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3802 (defun gnus-article-setup-buffer ()
3803 "Initialize the article buffer."
3804 (let* ((name (if gnus-single-article-buffer "*Article*"
3805 (concat "*Article " gnus-newsgroup-name "*")))
3807 (progn (string-match "\\*Article" name)
3808 (concat " *Original Article"
3809 (substring name (match-end 0))))))
3810 (setq gnus-article-buffer name)
3811 (setq gnus-original-article-buffer original)
3812 (setq gnus-article-mime-handle-alist nil)
3813 ;; This might be a variable local to the summary buffer.
3814 (unless gnus-single-article-buffer
3816 (set-buffer gnus-summary-buffer)
3817 (setq gnus-article-buffer name)
3818 (setq gnus-original-article-buffer original)
3819 (gnus-set-global-variables)))
3820 (gnus-article-setup-highlight-words)
3821 ;; Init original article buffer.
3823 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3824 (mm-enable-multibyte)
3825 (setq major-mode 'gnus-original-article-mode)
3826 (make-local-variable 'gnus-original-article))
3827 (if (and (get-buffer name)
3828 (with-current-buffer name
3829 (if gnus-article-edit-mode
3830 (if (y-or-n-p "Article mode edit in progress; discard? ")
3832 (set-buffer-modified-p nil)
3833 (gnus-kill-buffer name)
3836 (error "Action aborted"))
3840 (set (make-local-variable 'gnus-article-edit-mode) nil)
3841 (when gnus-article-mime-handles
3842 (mm-destroy-parts gnus-article-mime-handles)
3843 (setq gnus-article-mime-handles nil))
3844 ;; Set it to nil in article-buffer!
3845 (setq gnus-article-mime-handle-alist nil)
3846 (buffer-disable-undo)
3847 (setq buffer-read-only t)
3848 ;; This list just keeps growing if we don't reset it.
3849 (setq gnus-button-marker-list nil)
3850 (unless (eq major-mode 'gnus-article-mode)
3851 (gnus-article-mode))
3854 (set-buffer (gnus-get-buffer-create name))
3856 (make-local-variable 'gnus-summary-buffer)
3857 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3858 (current-buffer)))))
3860 ;; Set article window start at LINE, where LINE is the number of lines
3861 ;; from the head of the article.
3862 (defun gnus-article-set-window-start (&optional line)
3864 (gnus-get-buffer-window gnus-article-buffer t)
3866 (set-buffer gnus-article-buffer)
3867 (goto-char (point-min))
3870 (gnus-message 6 "Moved to bookmark")
3871 (search-forward "\n\n" nil t)
3875 (defun gnus-article-prepare (article &optional all-headers header)
3876 "Prepare ARTICLE in article mode buffer.
3877 ARTICLE should either be an article number or a Message-ID.
3878 If ARTICLE is an id, HEADER should be the article headers.
3879 If ALL-HEADERS is non-nil, no headers are hidden."
3881 ;; Make sure we start in a summary buffer.
3882 (unless (eq major-mode 'gnus-summary-mode)
3883 (set-buffer gnus-summary-buffer))
3884 (setq gnus-summary-buffer (current-buffer))
3885 (let* ((gnus-article (if header (mail-header-number header) article))
3886 (summary-buffer (current-buffer))
3887 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3888 (group gnus-newsgroup-name)
3891 (gnus-article-setup-buffer)
3892 (set-buffer gnus-article-buffer)
3893 ;; Deactivate active regions.
3894 (when (and (boundp 'transient-mark-mode)
3895 transient-mark-mode)
3896 (setq mark-active nil))
3897 (if (not (setq result (let ((inhibit-read-only t))
3898 (gnus-request-article-this-buffer
3900 ;; There is no such article.
3902 (when (and (numberp article)
3903 (not (memq article gnus-newsgroup-sparse)))
3904 (setq gnus-article-current
3905 (cons gnus-newsgroup-name article))
3906 (set-buffer gnus-summary-buffer)
3907 (setq gnus-current-article article)
3908 (if (and (memq article gnus-newsgroup-undownloaded)
3909 (not (gnus-online (gnus-find-method-for-group
3910 gnus-newsgroup-name))))
3912 (gnus-summary-set-agent-mark article)
3913 (message "Message marked for downloading"))
3914 (gnus-summary-mark-article article gnus-canceled-mark)
3915 (unless (memq article gnus-newsgroup-sparse)
3916 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3917 (if (or (eq result 'pseudo)
3918 (eq result 'nneething))
3921 (set-buffer summary-buffer)
3922 (push article gnus-newsgroup-history)
3923 (setq gnus-last-article gnus-current-article
3924 gnus-current-article 0
3925 gnus-current-headers nil
3926 gnus-article-current nil)
3927 (if (eq result 'nneething)
3928 (gnus-configure-windows 'summary)
3929 (gnus-configure-windows 'article))
3930 (gnus-set-global-variables))
3931 (let ((gnus-article-mime-handle-alist-1
3932 gnus-article-mime-handle-alist))
3933 (gnus-set-mode-line 'article)))
3934 ;; The result from the `request' was an actual article -
3935 ;; or at least some text that is now displayed in the
3937 (when (and (numberp article)
3938 (not (eq article gnus-current-article)))
3939 ;; Seems like a new article has been selected.
3940 ;; `gnus-current-article' must be an article number.
3942 (set-buffer summary-buffer)
3943 (push article gnus-newsgroup-history)
3944 (setq gnus-last-article gnus-current-article
3945 gnus-current-article article
3946 gnus-current-headers
3947 (gnus-summary-article-header gnus-current-article)
3948 gnus-article-current
3949 (cons gnus-newsgroup-name gnus-current-article))
3950 (unless (vectorp gnus-current-headers)
3951 (setq gnus-current-headers nil))
3952 (gnus-summary-goto-subject gnus-current-article)
3953 (when (gnus-summary-show-thread)
3954 ;; If the summary buffer really was folded, the
3955 ;; previous goto may not actually have gone to
3956 ;; the right article, but the thread root instead.
3958 (gnus-summary-goto-subject gnus-current-article))
3959 (gnus-run-hooks 'gnus-mark-article-hook)
3960 (gnus-set-mode-line 'summary)
3961 (when (gnus-visual-p 'article-highlight 'highlight)
3962 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3963 ;; Set the global newsgroup variables here.
3964 (gnus-set-global-variables)
3965 (setq gnus-have-all-headers
3966 (or all-headers gnus-show-all-headers))))
3968 (gnus-configure-windows 'article))
3969 (when (or (numberp article)
3971 (gnus-article-prepare-display)
3973 (goto-char (point-min))
3974 (when gnus-break-pages
3975 (gnus-narrow-to-page)))
3976 (let ((gnus-article-mime-handle-alist-1
3977 gnus-article-mime-handle-alist))
3978 (gnus-set-mode-line 'article))
3982 (set-window-point (get-buffer-window (current-buffer)) (point))
3983 (gnus-configure-windows 'article)
3987 (defun gnus-article-prepare-display ()
3988 "Make the current buffer look like a nice article."
3989 ;; Hooks for getting information from the article.
3990 ;; This hook must be called before being narrowed.
3991 (let ((gnus-article-buffer (current-buffer))
3993 (inhibit-read-only t))
3994 (unless (eq major-mode 'gnus-article-mode)
3995 (gnus-article-mode))
3996 (setq buffer-read-only nil
3997 gnus-article-wash-types nil
3998 gnus-article-image-alist nil)
3999 (gnus-run-hooks 'gnus-tmp-internal-hook)
4000 (when gnus-display-mime-function
4001 (funcall gnus-display-mime-function))
4002 (gnus-run-hooks 'gnus-article-prepare-hook)))
4005 ;;; Gnus MIME viewing functions
4008 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4009 "Format of the MIME buttons.
4011 Valid specifiers include:
4013 %T MIME type, along with additional info
4014 %n The `name' parameter
4015 %d The description, if any
4016 %l The length of the encoded part
4017 %p The part identifier number
4018 %e Dots if the part isn't displayed
4020 General format specifiers can also be used. See Info node
4021 `(gnus)Formatting Variables'.")
4023 (defvar gnus-mime-button-line-format-alist
4024 '((?t gnus-tmp-type ?s)
4025 (?T gnus-tmp-type-long ?s)
4026 (?n gnus-tmp-name ?s)
4027 (?d gnus-tmp-description ?s)
4029 (?l gnus-tmp-length ?d)
4030 (?e gnus-tmp-dots ?s)))
4032 (defvar gnus-mime-button-commands
4033 '((gnus-article-press-button "\r" "Toggle Display")
4034 (gnus-mime-view-part "v" "View Interactively...")
4035 (gnus-mime-view-part-as-type "t" "View As Type...")
4036 (gnus-mime-view-part-as-charset "C" "View As charset...")
4037 (gnus-mime-save-part "o" "Save...")
4038 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4039 (gnus-mime-delete-part "d" "Delete part")
4040 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4041 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4042 (gnus-mime-view-part-internally "E" "View Internally")
4043 (gnus-mime-view-part-externally "e" "View Externally")
4044 (gnus-mime-print-part "p" "Print")
4045 (gnus-mime-pipe-part "|" "Pipe To Command...")
4046 (gnus-mime-action-on-part "." "Take action on the part...")))
4048 (defun gnus-article-mime-part-status ()
4049 (if gnus-article-mime-handle-alist-1
4050 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4052 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4055 (defvar gnus-mime-button-map
4056 (let ((map (make-sparse-keymap)))
4057 (define-key map gnus-mouse-2 'gnus-article-push-button)
4058 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4059 (dolist (c gnus-mime-button-commands)
4060 (define-key map (cadr c) (car c)))
4064 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4066 ,@(mapcar (lambda (c)
4067 (vector (caddr c) (car c) :enable t))
4068 gnus-mime-button-commands)))
4070 (defun gnus-mime-button-menu (event prefix)
4071 "Construct a context-sensitive menu of MIME commands."
4072 (interactive "e\nP")
4073 (save-window-excursion
4074 (let ((pos (event-start event)))
4075 (select-window (posn-window pos))
4076 (goto-char (posn-point pos))
4077 (gnus-article-check-buffer)
4078 (popup-menu gnus-mime-button-menu nil prefix))))
4080 (defun gnus-mime-view-all-parts (&optional handles)
4081 "View all the MIME parts."
4083 (with-current-buffer gnus-article-buffer
4084 (let ((handles (or handles gnus-article-mime-handles))
4085 (mail-parse-charset gnus-newsgroup-charset)
4086 (mail-parse-ignored-charsets
4087 (with-current-buffer gnus-summary-buffer
4088 gnus-newsgroup-ignored-charsets)))
4090 (mm-remove-parts handles)
4091 (goto-char (point-min))
4092 (or (search-forward "\n\n") (goto-char (point-max)))
4093 (let ((inhibit-read-only t))
4094 (delete-region (point) (point-max))
4095 (mm-display-parts handles))))))
4098 (defsubst gnus-article-edit-part (handles)
4099 "Edit an article in order to delete a mime part.
4100 This function is exclusively used by `gnus-mime-save-part-and-strip'
4101 and `gnus-mime-delete-part', and not provided at run-time normally."
4102 (gnus-article-edit-article
4104 (buffer-disable-undo)
4106 (let ((mail-parse-charset (or gnus-article-charset
4107 ',gnus-newsgroup-charset))
4108 (mail-parse-ignored-charsets
4109 (or gnus-article-ignored-charsets
4110 ',gnus-newsgroup-ignored-charsets))
4111 (mbl mml-buffer-list))
4112 (setq mml-buffer-list nil)
4113 (insert-buffer gnus-original-article-buffer)
4114 (mime-to-mml ',handles)
4115 (setq gnus-article-mime-handles nil)
4116 (let ((mbl1 mml-buffer-list))
4117 (setq mml-buffer-list mbl)
4118 (set (make-local-variable 'mml-buffer-list) mbl1))
4119 (gnus-make-local-hook 'kill-buffer-hook)
4120 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4121 `(lambda (no-highlight)
4122 (let ((mail-parse-charset (or gnus-article-charset
4123 ',gnus-newsgroup-charset))
4124 (message-options message-options)
4125 (message-options-set-recipient)
4126 (mail-parse-ignored-charsets
4127 (or gnus-article-ignored-charsets
4128 ',gnus-newsgroup-ignored-charsets)))
4130 (mml-destroy-buffers)
4131 (remove-hook 'kill-buffer-hook
4132 'mml-destroy-buffers t)
4133 (kill-local-variable 'mml-buffer-list))
4134 (gnus-summary-edit-article-done
4135 ,(or (mail-header-references gnus-current-headers) "")
4136 ,(gnus-group-read-only-p)
4137 ,gnus-summary-buffer no-highlight)))
4138 (gnus-article-edit-done)
4139 (gnus-summary-expand-window)
4140 (gnus-summary-show-article)))
4142 (defun gnus-mime-save-part-and-strip ()
4143 "Save the MIME part under point then replace it with an external body."
4145 (gnus-article-check-buffer)
4146 (when (gnus-group-read-only-p)
4147 (error "The current group does not support deleting of parts"))
4148 (when (mm-complicated-handles gnus-article-mime-handles)
4150 The current article has a complicated MIME structure, giving up..."))
4151 (when (gnus-yes-or-no-p "\
4152 Deleting parts may malfunction or destroy the article; continue? ")
4153 (let* ((data (get-text-property (point) 'gnus-data))
4155 (handles gnus-article-mime-handles))
4156 (setq file (and data (mm-save-part data)))
4158 (with-current-buffer (mm-handle-buffer data)
4160 (insert "Content-Type: " (mm-handle-media-type data))
4161 (mml-insert-parameter-string (cdr (mm-handle-type data))
4164 (insert "Content-ID: " (message-make-message-id) "\n")
4165 (insert "Content-Transfer-Encoding: binary\n")
4168 (cdr (mm-make-handle nil
4169 `("message/external-body"
4170 (access-type . "LOCAL-FILE")
4172 (set-buffer gnus-summary-buffer)
4173 (gnus-article-edit-part handles)))))
4175 (defun gnus-mime-delete-part ()
4176 "Delete the MIME part under point.
4177 Replace it with some information about the removed part."
4179 (gnus-article-check-buffer)
4180 (when (gnus-group-read-only-p)
4181 (error "The current group does not support deleting of parts"))
4182 (when (mm-complicated-handles gnus-article-mime-handles)
4184 The current article has a complicated MIME structure, giving up..."))
4185 (when (gnus-yes-or-no-p "\
4186 Deleting parts may malfunction or destroy the article; continue? ")
4187 (let* ((data (get-text-property (point) 'gnus-data))
4188 (handles gnus-article-mime-handles)
4192 (mail-decode-encoded-word-string (or (mm-handle-description data)
4195 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4197 (type (mm-handle-media-type data)))
4199 (error "No MIME part under point"))
4200 (with-current-buffer (mm-handle-buffer data)
4201 (let ((bsize (format "%s" (buffer-size))))
4206 "| The following attachment has been deleted:\n"
4208 "| Type: " type "\n"
4209 "| Filename: " filename "\n"
4210 "| Size (encoded): " bsize " Byte\n"
4211 "| Description: " description "\n"
4214 (cdr (mm-make-handle
4215 nil `("text/plain") nil nil
4217 (format "Deleted attachment (%s bytes)" bsize))))))
4218 (set-buffer gnus-summary-buffer)
4219 (gnus-article-edit-part handles))))
4221 (defun gnus-mime-save-part ()
4222 "Save the MIME part under point."
4224 (gnus-article-check-buffer)
4225 (let ((data (get-text-property (point) 'gnus-data)))
4227 (mm-save-part data))))
4229 (defun gnus-mime-pipe-part ()
4230 "Pipe the MIME part under point to a process."
4232 (gnus-article-check-buffer)
4233 (let ((data (get-text-property (point) 'gnus-data)))
4235 (mm-pipe-part data))))
4237 (defun gnus-mime-view-part ()
4238 "Interactively choose a viewing method for the MIME part under point."
4240 (gnus-article-check-buffer)
4241 (let ((data (get-text-property (point) 'gnus-data)))
4243 (setq gnus-article-mime-handles
4245 gnus-article-mime-handles (setq data (copy-sequence data))))
4246 (mm-interactively-view-part data))))
4248 (defun gnus-mime-view-part-as-type-internal ()
4249 (gnus-article-check-buffer)
4250 (let* ((name (mail-content-type-get
4251 (mm-handle-type (get-text-property (point) 'gnus-data))
4253 (def-type (and name (mm-default-file-encoding name))))
4254 (and def-type (cons def-type 0))))
4256 (defun gnus-mime-view-part-as-type (&optional mime-type)
4257 "Choose a MIME media type, and view the part as such."
4260 (setq mime-type (completing-read
4261 "View as MIME type: "
4262 (mapcar #'list (mailcap-mime-types))
4264 (gnus-mime-view-part-as-type-internal))))
4265 (gnus-article-check-buffer)
4266 (let ((handle (get-text-property (point) 'gnus-data)))
4269 (mm-make-handle (mm-handle-buffer handle)
4270 (cons mime-type (cdr (mm-handle-type handle)))
4271 (mm-handle-encoding handle)
4272 (mm-handle-undisplayer handle)
4273 (mm-handle-disposition handle)
4274 (mm-handle-description handle)
4276 (mm-handle-id handle)))
4277 (setq gnus-article-mime-handles
4278 (mm-merge-handles gnus-article-mime-handles handle))
4279 (gnus-mm-display-part handle))))
4281 (defun gnus-mime-copy-part (&optional handle arg)
4282 "Put the MIME part under point into a new buffer.
4283 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4285 (interactive (list nil current-prefix-arg))
4286 (gnus-article-check-buffer)
4288 (setq handle (get-text-property (point) 'gnus-data)))
4290 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4292 (mail-content-type-get (mm-handle-disposition handle)
4294 contents dont-decode charset coding-system)
4295 (mm-with-unibyte-buffer
4296 (mm-insert-part handle)
4297 (setq contents (or (condition-case nil
4298 (mm-decompress-buffer filename nil 'sig)
4300 (setq dont-decode t)
4303 (setq filename (cond (filename (file-name-nondirectory filename))
4304 (dont-decode "*raw data*")
4309 (unless (setq charset (mail-content-type-get
4310 (mm-handle-type handle) 'charset))
4311 (unless (setq coding-system (mm-with-unibyte-buffer
4313 (mm-find-buffer-file-coding-system)))
4314 (setq charset gnus-newsgroup-charset))))
4316 (setq charset (or (cdr (assq arg
4317 gnus-summary-show-article-charset-alist))
4318 (mm-read-coding-system "Charset: ")))))
4319 (switch-to-buffer (generate-new-buffer filename))
4320 (if (or coding-system
4322 (setq coding-system (mm-charset-to-coding-system charset))
4323 (not (eq charset 'ascii))))
4325 (mm-enable-multibyte)
4326 (insert (mm-decode-coding-string contents coding-system))
4327 (setq buffer-file-coding-system
4328 (if (boundp 'last-coding-system-used)
4329 (symbol-value 'last-coding-system-used)
4331 (mm-disable-multibyte)
4333 (setq buffer-file-coding-system mm-binary-coding-system))
4334 ;; We do it this way to make `normal-mode' set the appropriate mode.
4337 (setq buffer-file-name (expand-file-name filename))
4339 (setq buffer-file-name nil))
4340 (goto-char (point-min)))))
4342 (defun gnus-mime-print-part (&optional handle filename)
4343 "Print the MIME part under point."
4344 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4345 (gnus-article-check-buffer)
4346 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4347 (contents (and handle (mm-get-part handle)))
4348 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4349 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4354 (mm-save-part-to-file handle file)
4355 (call-process shell-file-name nil
4356 (generate-new-buffer " *mm*")
4358 shell-command-switch
4360 printer file (mm-handle-type handle))))
4364 (gnus-print-buffer))
4365 (ps-despool filename)))))
4367 (defun gnus-mime-inline-part (&optional handle arg)
4368 "Insert the MIME part under point into the current buffer.
4369 Compressed files like .gz and .bz2 are decompressed."
4370 (interactive (list nil current-prefix-arg))
4371 (gnus-article-check-buffer)
4373 (setq handle (get-text-property (point) 'gnus-data)))
4376 (inhibit-read-only t)
4377 contents charset coding-system)
4378 (if (and (not arg) (mm-handle-undisplayer handle))
4379 (mm-remove-part handle)
4380 (mm-with-unibyte-buffer
4381 (mm-insert-part handle)
4383 (or (mm-decompress-buffer
4384 (or (mail-content-type-get (mm-handle-disposition handle)
4386 (mail-content-type-get (mm-handle-disposition handle)
4392 (unless (setq charset (mail-content-type-get
4393 (mm-handle-type handle) 'charset))
4394 (unless (setq coding-system
4395 (mm-with-unibyte-buffer
4397 (mm-find-buffer-file-coding-system)))
4398 (setq charset gnus-newsgroup-charset))))
4400 (if (mm-handle-undisplayer handle)
4401 (mm-remove-part handle))
4404 gnus-summary-show-article-charset-alist))
4405 (mm-read-coding-system "Charset: "))))
4407 (if (mm-handle-undisplayer handle)
4408 (mm-remove-part handle))))
4412 (if (or coding-system
4415 (mm-charset-to-coding-system charset))
4416 (not (eq coding-system 'ascii))))
4417 (mm-decode-coding-string contents coding-system)
4418 (mm-string-to-multibyte contents)))
4421 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4422 "Insert the MIME part under point into the current buffer using the
4424 (interactive (list nil current-prefix-arg))
4425 (gnus-article-check-buffer)
4426 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4429 (inhibit-read-only t))
4431 (if (mm-handle-undisplayer handle)
4432 (mm-remove-part handle))
4433 (let ((gnus-newsgroup-charset
4435 gnus-summary-show-article-charset-alist))
4436 (mm-read-coding-system "Charset: ")))
4437 (gnus-newsgroup-ignored-charsets 'gnus-all))
4438 (gnus-article-press-button)))))
4440 (defun gnus-mime-view-part-externally (&optional handle)
4441 "View the MIME part under point with an external viewer."
4443 (gnus-article-check-buffer)
4444 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4445 (mm-user-display-methods nil)
4446 (mm-inlined-types nil)
4447 (mail-parse-charset gnus-newsgroup-charset)
4448 (mail-parse-ignored-charsets
4449 (with-current-buffer gnus-summary-buffer
4450 gnus-newsgroup-ignored-charsets)))
4452 (if (mm-handle-undisplayer handle)
4453 (mm-remove-part handle)
4454 (mm-display-part handle)))))
4456 (defun gnus-mime-view-part-internally (&optional handle)
4457 "View the MIME part under point with an internal viewer.
4458 If no internal viewer is available, use an external viewer."
4460 (gnus-article-check-buffer)
4461 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4462 (mm-inlined-types '(".*"))
4463 (mm-inline-large-images t)
4464 (mail-parse-charset gnus-newsgroup-charset)
4465 (mail-parse-ignored-charsets
4466 (with-current-buffer gnus-summary-buffer
4467 gnus-newsgroup-ignored-charsets))
4468 (inhibit-read-only t))
4470 (if (mm-handle-undisplayer handle)
4471 (mm-remove-part handle)
4472 (mm-display-part handle)))))
4474 (defun gnus-mime-action-on-part (&optional action)
4475 "Do something with the MIME attachment at \(point\)."
4477 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4478 (gnus-article-check-buffer)
4479 (let ((action-pair (assoc action gnus-mime-action-alist)))
4481 (funcall (cdr action-pair)))))
4483 (defun gnus-article-part-wrapper (n function)
4484 (with-current-buffer gnus-article-buffer
4485 (when (> n (length gnus-article-mime-handle-alist))
4486 (error "No such part"))
4487 (gnus-article-goto-part n)
4488 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4489 (funcall function handle))))
4491 (defun gnus-article-pipe-part (n)
4492 "Pipe MIME part N, which is the numerical prefix."
4494 (gnus-article-part-wrapper n 'mm-pipe-part))
4496 (defun gnus-article-save-part (n)
4497 "Save MIME part N, which is the numerical prefix."
4499 (gnus-article-part-wrapper n 'mm-save-part))
4501 (defun gnus-article-interactively-view-part (n)
4502 "View MIME part N interactively, which is the numerical prefix."
4504 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4506 (defun gnus-article-copy-part (n)
4507 "Copy MIME part N, which is the numerical prefix."
4509 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4511 (defun gnus-article-view-part-as-charset (n)
4512 "View MIME part N using a specified charset.
4513 N is the numerical prefix."
4515 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4517 (defun gnus-article-view-part-externally (n)
4518 "View MIME part N externally, which is the numerical prefix."
4520 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4522 (defun gnus-article-inline-part (n)
4523 "Inline MIME part N, which is the numerical prefix."
4525 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4527 (defun gnus-article-mime-match-handle-first (condition)
4530 (dolist (ihandle gnus-article-mime-handle-alist)
4532 ((functionp condition)
4533 (funcall condition (cdr ihandle)))
4534 ((eq condition 'undisplayed)
4535 (not (or (mm-handle-undisplayer (cdr ihandle))
4536 (equal (mm-handle-media-type (cdr ihandle))
4537 "multipart/alternative"))))
4538 ((eq condition 'undisplayed-alternative)
4539 (not (mm-handle-undisplayer (cdr ihandle))))
4541 (gnus-article-goto-part (car ihandle))
4542 (or (not n) (< (car ihandle) n)))
4543 (setq n (car ihandle))))
4547 (defun gnus-article-view-part (&optional n)
4548 "View MIME part N, which is the numerical prefix."
4550 (with-current-buffer gnus-article-buffer
4551 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4552 gnus-article-mime-match-handle-function)))
4553 (when (> n (length gnus-article-mime-handle-alist))
4554 (error "No such part"))
4555 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4556 (when (gnus-article-goto-part n)
4557 (if (equal (car handle) "multipart/alternative")
4558 (gnus-article-press-button)
4559 (when (eq (gnus-mm-display-part handle) 'internal)
4560 (gnus-set-window-start)))))))
4562 (defsubst gnus-article-mime-total-parts ()
4563 (if (bufferp (car gnus-article-mime-handles))
4565 (1- (length gnus-article-mime-handles))))
4567 (defun gnus-mm-display-part (handle)
4568 "Display HANDLE and fix MIME button."
4569 (let ((id (get-text-property (point) 'gnus-part))
4571 (inhibit-read-only t))
4574 (let ((window (selected-window))
4575 (mail-parse-charset gnus-newsgroup-charset)
4576 (mail-parse-ignored-charsets
4577 (if (gnus-buffer-live-p gnus-summary-buffer)
4578 (with-current-buffer gnus-summary-buffer
4579 gnus-newsgroup-ignored-charsets)
4583 (let ((win (gnus-get-buffer-window (current-buffer) t))
4586 (select-window win))
4589 (if (mm-handle-displayed-p handle)
4590 ;; This will remove the part.
4591 (mm-display-part handle)
4593 (narrow-to-region (point)
4594 (if (eobp) (point) (1+ (point))))
4595 (mm-display-part handle)
4596 ;; We narrow to the part itself and
4597 ;; then call the treatment functions.
4598 (goto-char (point-min))
4600 (narrow-to-region (point) (point-max))
4603 (gnus-article-mime-total-parts)
4604 (mm-handle-media-type handle)))))
4605 (if (window-live-p window)
4606 (select-window window)))))
4609 (gnus-insert-mime-button
4610 handle id (list (mm-handle-displayed-p handle)))
4611 (goto-char point))))
4613 (defun gnus-article-goto-part (n)
4614 "Go to MIME part N."
4615 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4617 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4618 (let ((gnus-tmp-name
4619 (or (mail-content-type-get (mm-handle-type handle) 'name)
4620 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4621 (mail-content-type-get (mm-handle-type handle) 'url)
4623 (gnus-tmp-type (mm-handle-media-type handle))
4624 (gnus-tmp-description
4625 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4628 (if (if displayed (car displayed)
4629 (mm-handle-displayed-p handle))
4631 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4633 gnus-tmp-type-long b e)
4634 (when (string-match ".*/" gnus-tmp-name)
4635 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4636 (setq gnus-tmp-type-long (concat gnus-tmp-type
4637 (and (not (equal gnus-tmp-name ""))
4638 (concat "; " gnus-tmp-name))))
4639 (unless (equal gnus-tmp-description "")
4640 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4645 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4646 `(keymap ,gnus-mime-button-map
4647 gnus-callback gnus-mm-display-part
4648 gnus-part ,gnus-tmp-id
4649 article-type annotation
4652 ;; Exclude a newline.
4655 (widget-convert-button
4658 :action 'gnus-widget-press-button
4659 :button-keymap gnus-mime-button-map
4661 (lambda (widget/window &optional overlay pos)
4662 ;; Needed to properly clear the message due to a bug in
4663 ;; wid-edit (XEmacs only).
4664 (if (boundp 'help-echo-owns-message)
4665 (setq help-echo-owns-message t))
4667 "%S: %s the MIME part; %S: more options"
4668 (aref gnus-mouse-2 0)
4669 ;; XEmacs will get a single widget arg; Emacs 21 will get
4670 ;; window, overlay, position.
4671 (if (mm-handle-displayed-p
4673 (with-current-buffer (gnus-overlay-buffer overlay)
4674 (widget-get (widget-at (gnus-overlay-start overlay))
4676 (widget-get widget/window :mime-handle)))
4678 (aref gnus-down-mouse-3 0))))))
4680 (defun gnus-widget-press-button (elems el)
4681 (goto-char (widget-get elems :from))
4682 (gnus-article-press-button))
4684 (defvar gnus-displaying-mime nil)
4686 (defun gnus-display-mime (&optional ihandles)
4687 "Display the MIME parts."
4689 (save-selected-window
4690 (let ((window (get-buffer-window gnus-article-buffer))
4693 (select-window window)
4694 ;; We have to do this since selecting the window
4695 ;; may change the point. So we set the window point.
4696 (set-window-point window point)))
4697 (let ((handles ihandles)
4698 (inhibit-read-only t)
4701 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
4702 (when gnus-article-emulate-mime
4703 (mm-uu-dissect-text-parts handles)))
4704 (gnus-article-emulate-mime
4705 (setq handles (mm-uu-dissect))))
4706 (when (and (not ihandles)
4707 (not gnus-displaying-mime))
4708 ;; Top-level call; we clean up.
4709 (when gnus-article-mime-handles
4710 (mm-destroy-parts gnus-article-mime-handles)
4711 (setq gnus-article-mime-handle-alist nil));; A trick.
4712 (setq gnus-article-mime-handles handles)
4713 ;; We allow users to glean info from the handles.
4714 (when gnus-article-mime-part-function
4715 (gnus-mime-part-function handles)))
4717 (or (not (stringp (car handles)))
4720 (when (and (not ihandles)
4721 (not gnus-displaying-mime))
4722 ;; Clean up for mime parts.
4724 (delete-region (point) (point-max)))
4725 (let ((gnus-displaying-mime t))
4726 (gnus-mime-display-part handles)))
4729 (narrow-to-region (point) (point-max))
4730 (gnus-treat-article nil 1 1)
4733 ;; Highlight the headers.
4737 (narrow-to-region (point-min) (point))
4738 (gnus-article-save-original-date
4739 (gnus-treat-article 'head)))))))))
4741 (defcustom gnus-mime-display-multipart-as-mixed nil
4742 "Display \"multipart\" parts as \"multipart/mixed\".
4744 If t, it overrides nil values of
4745 `gnus-mime-display-multipart-alternative-as-mixed' and
4746 `gnus-mime-display-multipart-related-as-mixed'."
4747 :group 'gnus-article-mime
4750 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4751 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4753 :group 'gnus-article-mime
4756 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4757 "Display \"multipart/related\" parts as \"multipart/mixed\".
4759 If displaying \"text/html\" is discouraged \(see
4760 `mm-discouraged-alternatives'\) images or other material inside a
4761 \"multipart/related\" part might be overlooked when this variable is nil."
4763 :group 'gnus-article-mime
4766 (defun gnus-mime-display-part (handle)
4769 ((not (stringp (car handle)))
4770 (gnus-mime-display-single handle))
4771 ;; User-defined multipart
4772 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4773 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4775 ;; multipart/alternative
4776 ((and (equal (car handle) "multipart/alternative")
4777 (not (or gnus-mime-display-multipart-as-mixed
4778 gnus-mime-display-multipart-alternative-as-mixed)))
4779 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4780 (push (cons id handle) gnus-article-mime-handle-alist)
4781 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4782 ;; multipart/related
4783 ((and (equal (car handle) "multipart/related")
4784 (not (or gnus-mime-display-multipart-as-mixed
4785 gnus-mime-display-multipart-related-as-mixed)))
4786 ;;;!!!We should find the start part, but we just default
4787 ;;;!!!to the first part.
4788 ;;(gnus-mime-display-part (cadr handle))
4789 ;;;!!! Most multipart/related is an HTML message plus images.
4790 ;;;!!! Unfortunately we are unable to let W3 display those
4791 ;;;!!! included images, so we just display it as a mixed multipart.
4792 ;;(gnus-mime-display-mixed (cdr handle))
4793 ;;;!!! No, w3 can display everything just fine.
4794 (gnus-mime-display-part (cadr handle)))
4795 ((equal (car handle) "multipart/signed")
4796 (gnus-add-wash-type 'signed)
4797 (gnus-mime-display-security handle))
4798 ((equal (car handle) "multipart/encrypted")
4799 (gnus-add-wash-type 'encrypted)
4800 (gnus-mime-display-security handle))
4801 ;; Other multiparts are handled like multipart/mixed.
4803 (gnus-mime-display-mixed (cdr handle)))))
4805 (defun gnus-mime-part-function (handles)
4806 (if (stringp (car handles))
4807 (mapcar 'gnus-mime-part-function (cdr handles))
4808 (funcall gnus-article-mime-part-function handles)))
4810 (defun gnus-mime-display-mixed (handles)
4811 (mapcar 'gnus-mime-display-part handles))
4813 (defun gnus-mime-display-single (handle)
4814 (let ((type (mm-handle-media-type handle))
4815 (ignored gnus-ignored-mime-types)
4822 (when (string-match (pop ignored) type)
4823 (throw 'ignored nil)))
4824 (if (and (setq not-attachment
4825 (and (not (mm-inline-override-p handle))
4826 (or (not (mm-handle-disposition handle))
4827 (equal (car (mm-handle-disposition handle))
4829 (mm-attachment-override-p handle))))
4830 (mm-automatic-display-p handle)
4832 (mm-inlinable-p handle)
4833 (mm-inlined-p handle))
4834 (mm-automatic-external-display-p type)))
4836 (when (equal (mm-handle-media-supertype handle) "text")
4838 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4840 (push (cons id handle) gnus-article-mime-handle-alist)
4841 (when (or (not display)
4842 (not (gnus-unbuttonized-mime-type-p type)))
4843 (gnus-insert-mime-button
4844 handle id (list (or display (and not-attachment text))))
4845 (gnus-article-insert-newline)
4846 ;; Remember modify the number of forward lines.
4854 (let ((mail-parse-charset gnus-newsgroup-charset)
4855 (mail-parse-ignored-charsets
4856 (save-excursion (condition-case ()
4857 (set-buffer gnus-summary-buffer)
4859 gnus-newsgroup-ignored-charsets)))
4860 (mm-display-part handle t))
4861 (goto-char (point-max)))
4862 ((and text not-attachment)
4866 (gnus-article-insert-newline)
4867 (mm-display-inline handle)
4868 (goto-char (point-max))))
4872 (narrow-to-region beg (point))
4875 (gnus-article-mime-total-parts)
4876 (mm-handle-media-type handle)))))))))
4878 (defun gnus-unbuttonized-mime-type-p (type)
4879 "Say whether TYPE is to be unbuttonized."
4880 (unless gnus-inhibit-mime-unbuttonizing
4882 (let ((types gnus-unbuttonized-mime-types))
4884 (when (string-match (pop types) type)
4885 (throw 'found t)))))
4887 (let ((types gnus-buttonized-mime-types))
4889 (when (string-match (pop types) type)
4890 (throw 'found t)))))))))
4892 (defun gnus-article-insert-newline ()
4893 "Insert a newline, but mark it as undeletable."
4894 (gnus-put-text-property
4895 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4897 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4898 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4901 handle (inhibit-read-only t) from props begend not-pref)
4902 (save-window-excursion
4905 (narrow-to-region (car ibegend)
4908 (goto-char (car ibegend))
4911 (delete-region (point-min) (point-max))
4912 (mm-remove-parts handles))
4913 (setq begend (list (point-marker)))
4915 (unless (setq not-pref (cadr (member preferred ihandles)))
4916 (setq not-pref (car ihandles)))
4919 (not (gnus-unbuttonized-mime-type-p
4920 "multipart/alternative")))
4921 (gnus-add-text-properties
4924 (insert (format "%d. " id))
4928 (unless ,(not ibegend)
4929 (setq gnus-article-mime-handle-alist
4930 ',gnus-article-mime-handle-alist))
4931 (gnus-mime-display-alternative
4932 ',ihandles ',not-pref ',begend ,id))
4933 keymap ,gnus-mime-button-map
4934 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4935 face ,gnus-article-button-face
4938 (widget-convert-button 'link from (point)
4939 :action 'gnus-widget-press-button
4940 :button-keymap gnus-widget-button-keymap)
4942 (while (setq handle (pop handles))
4943 (gnus-add-text-properties
4946 (insert (format "(%c) %-18s"
4947 (if (equal handle preferred) ?* ? )
4948 (mm-handle-media-type handle)))
4952 (unless ,(not ibegend)
4953 (setq gnus-article-mime-handle-alist
4954 ',gnus-article-mime-handle-alist))
4955 (gnus-mime-display-alternative
4956 ',ihandles ',handle ',begend ,id))
4957 keymap ,gnus-mime-button-map
4958 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4959 face ,gnus-article-button-face
4962 (widget-convert-button 'link from (point)
4963 :action 'gnus-widget-press-button
4964 :button-keymap gnus-widget-button-keymap)
4968 (if (stringp (car preferred))
4969 (gnus-display-mime preferred)
4970 (let ((mail-parse-charset gnus-newsgroup-charset)
4971 (mail-parse-ignored-charsets
4972 (with-current-buffer gnus-summary-buffer
4973 gnus-newsgroup-ignored-charsets)))
4974 (mm-display-part preferred)
4978 (narrow-to-region (car begend) (point-max))
4980 nil (length gnus-article-mime-handle-alist)
4981 (gnus-article-mime-total-parts)
4982 (mm-handle-media-type handle))))))
4983 (goto-char (point-max))
4984 (setcdr begend (point-marker)))))
4986 (goto-char point))))
4988 (defconst gnus-article-wash-status-strings
4989 (let ((alist '((cite "c" "Possible hidden citation text"
4990 " " "All citation text visible")
4991 (headers "h" "Hidden headers"
4992 " " "All headers visible.")
4993 (pgp "p" "Encrypted or signed message status hidden"
4994 " " "No hidden encryption nor digital signature status")
4995 (signature "s" "Signature has been hidden"
4996 " " "Signature is visible")
4997 (overstrike "o" "Overstrike (^H) characters applied"
4998 " " "No overstrike characters applied")
4999 (emphasis "e" "/*_Emphasis_*/ characters applied"
5000 " " "No /*_emphasis_*/ characters applied")))
5002 (dolist (entry alist result)
5003 (let ((key (nth 0 entry))
5004 (on (copy-sequence (nth 1 entry)))
5005 (on-help (nth 2 entry))
5006 (off (copy-sequence (nth 3 entry)))
5007 (off-help (nth 4 entry)))
5008 (put-text-property 0 1 'help-echo on-help on)
5009 (put-text-property 0 1 'help-echo off-help off)
5010 (push (list key on off) result))))
5011 "Alist of strings describing wash status in the mode line.
5012 Each entry has the form (KEY ON OF), where the KEY is a symbol
5013 representing the particular washing function, ON is the string to use
5014 in the article mode line when the washing function is active, and OFF
5015 is the string to use when it is inactive.")
5017 (defun gnus-article-wash-status-entry (key value)
5018 (let ((entry (assoc key gnus-article-wash-status-strings)))
5019 (if value (nth 1 entry) (nth 2 entry))))
5021 (defun gnus-article-wash-status ()
5022 "Return a string which display status of article washing."
5023 (with-current-buffer gnus-article-buffer
5024 (let ((cite (memq 'cite gnus-article-wash-types))
5025 (headers (memq 'headers gnus-article-wash-types))
5026 (boring (memq 'boring-headers gnus-article-wash-types))
5027 (pgp (memq 'pgp gnus-article-wash-types))
5028 (pem (memq 'pem gnus-article-wash-types))
5029 (signed (memq 'signed gnus-article-wash-types))
5030 (encrypted (memq 'encrypted gnus-article-wash-types))
5031 (signature (memq 'signature gnus-article-wash-types))
5032 (overstrike (memq 'overstrike gnus-article-wash-types))
5033 (emphasis (memq 'emphasis gnus-article-wash-types)))
5035 (gnus-article-wash-status-entry 'cite cite)
5036 (gnus-article-wash-status-entry 'headers (or headers boring))
5037 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5038 (gnus-article-wash-status-entry 'signature signature)
5039 (gnus-article-wash-status-entry 'overstrike overstrike)
5040 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5042 (defun gnus-add-wash-type (type)
5043 "Add a washing of TYPE to the current status."
5044 (add-to-list 'gnus-article-wash-types type))
5046 (defun gnus-delete-wash-type (type)
5047 "Add a washing of TYPE to the current status."
5048 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5050 (defun gnus-add-image (category image)
5051 "Add IMAGE of CATEGORY to the list of displayed images."
5052 (let ((entry (assq category gnus-article-image-alist)))
5054 (setq entry (list category))
5055 (push entry gnus-article-image-alist))
5056 (nconc entry (list image))))
5058 (defun gnus-delete-images (category)
5059 "Delete all images in CATEGORY."
5060 (let ((entry (assq category gnus-article-image-alist)))
5061 (dolist (image (cdr entry))
5062 (gnus-remove-image image category))
5063 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5064 (gnus-delete-wash-type category)))
5066 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5068 (defun gnus-article-maybe-hide-headers ()
5069 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5070 Provided for backwards compatibility."
5071 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5072 (not (with-current-buffer gnus-summary-buffer
5073 gnus-have-all-headers)))
5074 (not gnus-inhibit-hiding))
5075 (gnus-article-hide-headers)))
5079 (defun gnus-output-to-file (file-name)
5080 "Append the current article to a file named FILE-NAME."
5081 (let ((artbuf (current-buffer)))
5083 (insert-buffer-substring artbuf)
5084 ;; Append newline at end of the buffer as separator, and then
5086 (goto-char (point-max))
5088 (let ((file-name-coding-system nnmail-pathname-coding-system))
5089 (mm-append-to-file (point-min) (point-max) file-name))
5092 (defun gnus-narrow-to-page (&optional arg)
5093 "Narrow the article buffer to a page.
5094 If given a numerical ARG, move forward ARG pages."
5096 (setq arg (if arg (prefix-numeric-value arg) 0))
5098 (set-buffer gnus-article-buffer)
5099 (goto-char (point-min))
5101 ;; Remove any old next/prev buttons.
5102 (when (gnus-visual-p 'page-marker)
5103 (let ((inhibit-read-only t))
5104 (gnus-remove-text-with-property 'gnus-prev)
5105 (gnus-remove-text-with-property 'gnus-next)))
5108 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5110 (re-search-forward page-delimiter nil 'move arg)))
5111 (goto-char (match-end 0))
5113 (goto-char (point-min))
5114 (setq gnus-page-broken
5115 (and (re-search-forward page-delimiter nil t) t))))
5116 (when gnus-page-broken
5119 (if (re-search-forward page-delimiter nil 'move)
5122 (when (and (gnus-visual-p 'page-marker)
5123 (> (point-min) (save-restriction (widen) (point-min))))
5125 (goto-char (point-min))
5126 (gnus-insert-prev-page-button)))
5127 (when (and (gnus-visual-p 'page-marker)
5128 (< (point-max) (save-restriction (widen) (point-max))))
5130 (goto-char (point-max))
5131 (gnus-insert-next-page-button))))))
5133 ;; Article mode commands
5135 (defun gnus-article-goto-next-page ()
5136 "Show the next page of the article."
5138 (when (gnus-article-next-page)
5139 (goto-char (point-min))
5140 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5143 (defun gnus-article-goto-prev-page ()
5144 "Show the previous page of the article."
5147 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5148 (gnus-article-prev-page nil)))
5150 ;; This is cleaner but currently breaks `gnus-pick-mode':
5152 ;; (defun gnus-article-goto-next-page ()
5153 ;; "Show the next page of the article."
5155 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5156 ;; (gnus-summary-next-page)))
5158 ;; (defun gnus-article-goto-prev-page ()
5159 ;; "Show the next page of the article."
5161 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5162 ;; (gnus-summary-prev-page)))
5164 (defun gnus-article-next-page (&optional lines)
5165 "Show the next page of the current article.
5166 If end of article, return non-nil. Otherwise return nil.
5167 Argument LINES specifies lines to be scrolled up."
5169 (move-to-window-line -1)
5172 (and (pos-visible-in-window-p) ;Not continuation line.
5173 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5174 ;; Nothing in this page.
5175 (if (or (not gnus-page-broken)
5180 (eobp)))) ;Real end-of-buffer?
5182 (when gnus-article-over-scroll
5183 (gnus-article-next-page-1 lines))
5185 (gnus-narrow-to-page 1) ;Go to next page.
5187 ;; More in this page.
5188 (gnus-article-next-page-1 lines)
5191 (defun gnus-article-next-page-1 (lines)
5192 (let ((scroll-in-place nil))
5196 ;; Long lines may cause an end-of-buffer error.
5197 (goto-char (point-max)))))
5198 (move-to-window-line 0))
5200 (defun gnus-article-prev-page (&optional lines)
5201 "Show previous page of current article.
5202 Argument LINES specifies lines to be scrolled down."
5204 (move-to-window-line 0)
5205 (if (and gnus-page-broken
5207 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5209 (gnus-narrow-to-page -1) ;Go to previous page.
5210 (goto-char (point-max))
5212 (let ((scroll-in-place nil))
5216 (beginning-of-buffer
5217 (goto-char (point-min))))
5218 (move-to-window-line 0)))))
5220 (defun gnus-article-only-boring-p ()
5221 "Decide whether there is only boring text remaining in the article.
5222 Something \"interesting\" is a word of at least two letters that does
5223 not have a face in `gnus-article-boring-faces'."
5224 (when (and gnus-article-skip-boring
5225 (boundp 'gnus-article-boring-faces)
5226 (symbol-value 'gnus-article-boring-faces))
5229 (while (re-search-forward "\\b\\w\\w" nil t)
5231 (when (not (gnus-intersection
5232 (gnus-faces-at (point))
5233 (symbol-value 'gnus-article-boring-faces)))
5234 (throw 'only-boring nil)))
5235 (throw 'only-boring t)))))
5237 (defun gnus-article-refer-article ()
5238 "Read article specified by message-id around point."
5241 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5242 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5243 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5244 (let ((msg-id (concat "<" (match-string 0) ">")))
5245 (set-buffer gnus-summary-buffer)
5246 (gnus-summary-refer-article msg-id))
5247 (error "No references around point"))))
5249 (defun gnus-article-show-summary ()
5250 "Reconfigure windows to show summary buffer."
5252 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5253 (error "There is no summary buffer for this article buffer")
5254 (gnus-article-set-globals)
5255 (gnus-configure-windows 'article)
5256 (gnus-summary-goto-subject gnus-current-article)
5257 (gnus-summary-position-point)))
5259 (defun gnus-article-describe-briefly ()
5260 "Describe article mode commands briefly."
5262 (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")))
5264 (defun gnus-article-summary-command ()
5265 "Execute the last keystroke in the summary buffer."
5267 (let ((obuf (current-buffer))
5268 (owin (current-window-configuration))
5270 (switch-to-buffer gnus-article-current-summary 'norecord)
5271 (setq func (lookup-key (current-local-map) (this-command-keys)))
5272 (call-interactively func)
5274 (set-window-configuration owin)
5275 (set-window-point (get-buffer-window (current-buffer)) (point))))
5277 (defun gnus-article-summary-command-nosave ()
5278 "Execute the last keystroke in the summary buffer."
5281 (pop-to-buffer gnus-article-current-summary 'norecord)
5282 (setq func (lookup-key (current-local-map) (this-command-keys)))
5283 (call-interactively func)))
5285 (defun gnus-article-check-buffer ()
5286 "Beep if not in an article buffer."
5287 (unless (equal major-mode 'gnus-article-mode)
5288 (error "Command invoked outside of a Gnus article buffer")))
5290 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5291 "Read a summary buffer key sequence and execute it from the article buffer."
5293 (gnus-article-check-buffer)
5295 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5296 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5297 "=" "^" "\M-^" "|"))
5303 '("n" "Gn" "p" "Gp"))
5306 (set-buffer gnus-article-current-summary)
5307 (let (gnus-pick-mode)
5308 (push (or key last-command-event) unread-command-events)
5309 (setq keys (if (featurep 'xemacs)
5310 (events-to-keys (read-key-sequence nil))
5311 (read-key-sequence nil)))))
5315 (if (or (member keys nosaves)
5316 (member keys nosave-but-article)
5317 (member keys nosave-in-article))
5319 (save-window-excursion
5320 (pop-to-buffer gnus-article-current-summary 'norecord)
5321 ;; We disable the pick minor mode commands.
5322 (let (gnus-pick-mode)
5323 (setq func (lookup-key (current-local-map) keys))))
5327 (unless (member keys nosave-in-article)
5328 (set-buffer gnus-article-current-summary))
5329 (call-interactively func)
5330 (setq new-sum-point (point)))
5331 (when (member keys nosave-but-article)
5332 (pop-to-buffer gnus-article-buffer 'norecord)))
5333 ;; These commands should restore window configuration.
5334 (let ((obuf (current-buffer))
5335 (owin (current-window-configuration))
5337 win func in-buffer selected new-sum-start new-sum-hscroll)
5338 (cond (not-restore-window
5339 (pop-to-buffer gnus-article-current-summary 'norecord))
5340 ((setq win (get-buffer-window gnus-article-current-summary))
5341 (select-window win))
5343 (switch-to-buffer gnus-article-current-summary 'norecord)))
5344 (setq in-buffer (current-buffer))
5345 ;; We disable the pick minor mode commands.
5346 (if (and (setq func (let (gnus-pick-mode)
5347 (lookup-key (current-local-map) keys)))
5350 (call-interactively func)
5351 (when (eq win (selected-window))
5352 (setq new-sum-point (point)
5353 new-sum-start (window-start win)
5354 new-sum-hscroll (window-hscroll win)))
5355 (when (eq in-buffer (current-buffer))
5356 (setq selected (gnus-summary-select-article))
5358 (unless not-restore-window
5359 (set-window-configuration owin))
5360 (when (eq selected 'old)
5362 (set-window-start (get-buffer-window (current-buffer))
5364 (set-window-point (get-buffer-window (current-buffer))
5366 (when (and (not not-restore-window)
5368 (set-window-point win new-sum-point)
5369 (set-window-start win new-sum-start)
5370 (set-window-hscroll win new-sum-hscroll))))
5371 (set-window-configuration owin)
5374 (defun gnus-article-describe-key (key)
5375 "Display documentation of the function invoked by KEY. KEY is a string."
5376 (interactive "kDescribe key: ")
5377 (gnus-article-check-buffer)
5378 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5380 (set-buffer gnus-article-current-summary)
5381 (let (gnus-pick-mode)
5382 (if (featurep 'xemacs)
5384 (push (elt key 0) unread-command-events)
5385 (setq key (events-to-keys
5386 (read-key-sequence "Describe key: "))))
5387 (setq unread-command-events
5389 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5390 (string-to-list key)))
5391 (setq key (read-key-sequence "Describe key: "))))
5393 (describe-key key)))
5395 (defun gnus-article-describe-key-briefly (key &optional insert)
5396 "Display documentation of the function invoked by KEY. KEY is a string."
5397 (interactive "kDescribe key: \nP")
5398 (gnus-article-check-buffer)
5399 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5401 (set-buffer gnus-article-current-summary)
5402 (let (gnus-pick-mode)
5403 (if (featurep 'xemacs)
5405 (push (elt key 0) unread-command-events)
5406 (setq key (events-to-keys
5407 (read-key-sequence "Describe key: "))))
5408 (setq unread-command-events
5410 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5411 (string-to-list key)))
5412 (setq key (read-key-sequence "Describe key: "))))
5413 (describe-key-briefly key insert))
5414 (describe-key-briefly key insert)))
5416 (defun gnus-article-reply-with-original (&optional wide)
5417 "Start composing a reply mail to the current message.
5418 The text in the region will be yanked. If the region isn't active,
5419 the entire article will be yanked."
5421 (let ((article (cdr gnus-article-current))
5423 (if (not (gnus-region-active-p))
5424 (with-current-buffer gnus-summary-buffer
5425 (gnus-summary-reply (list (list article)) wide))
5426 (setq contents (buffer-substring (point) (mark t)))
5427 ;; Deactivate active regions.
5428 (when (and (boundp 'transient-mark-mode)
5429 transient-mark-mode)
5430 (setq mark-active nil))
5431 (with-current-buffer gnus-summary-buffer
5433 (list (list article contents)) wide)))))
5435 (defun gnus-article-followup-with-original ()
5436 "Compose a followup to the current article.
5437 The text in the region will be yanked. If the region isn't active,
5438 the entire article will be yanked."
5440 (let ((article (cdr gnus-article-current))
5442 (if (not (gnus-region-active-p))
5443 (with-current-buffer gnus-summary-buffer
5444 (gnus-summary-followup (list (list article))))
5445 (setq contents (buffer-substring (point) (mark t)))
5446 ;; Deactivate active regions.
5447 (when (and (boundp 'transient-mark-mode)
5448 transient-mark-mode)
5449 (setq mark-active nil))
5450 (with-current-buffer gnus-summary-buffer
5451 (gnus-summary-followup
5452 (list (list article contents)))))))
5454 (defun gnus-article-hide (&optional arg force)
5455 "Hide all the gruft in the current article.
5456 This means that signatures, cited text and (some) headers will be
5458 If given a prefix, show the hidden text instead."
5459 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5460 (gnus-article-hide-headers arg)
5461 (gnus-article-hide-list-identifiers arg)
5462 (gnus-article-hide-citation-maybe arg force)
5463 (gnus-article-hide-signature arg))
5465 (defun gnus-article-maybe-highlight ()
5466 "Do some article highlighting if article highlighting is requested."
5467 (when (gnus-visual-p 'article-highlight 'highlight)
5468 (gnus-article-highlight-some)))
5470 (defun gnus-check-group-server ()
5471 ;; Make sure the connection to the server is alive.
5472 (unless (gnus-server-opened
5473 (gnus-find-method-for-group gnus-newsgroup-name))
5474 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5475 (gnus-request-group gnus-newsgroup-name t)))
5478 (autoload 'nneething-get-file-name "nneething"))
5480 (defun gnus-request-article-this-buffer (article group)
5481 "Get an article and insert it into this buffer."
5482 (let (do-update-line sparse-header)
5486 (gnus-kill-all-overlays)
5487 (setq group (or group gnus-newsgroup-name))
5489 ;; Using `gnus-request-article' directly will insert the article into
5490 ;; `nntp-server-buffer' - so we'll save some time by not having to
5491 ;; copy it from the server buffer into the article buffer.
5493 ;; We only request an article by message-id when we do not have the
5494 ;; headers for it, so we'll have to get those.
5495 (when (stringp article)
5496 (gnus-read-header article))
5498 ;; If the article number is negative, that means that this article
5499 ;; doesn't belong in this newsgroup (possibly), so we find its
5500 ;; message-id and request it by id instead of number.
5501 (when (and (numberp article)
5503 (get-buffer gnus-summary-buffer)
5504 (gnus-buffer-exists-p gnus-summary-buffer))
5506 (set-buffer gnus-summary-buffer)
5507 (let ((header (gnus-summary-article-header article)))
5510 ((memq article gnus-newsgroup-sparse)
5511 ;; This is a sparse gap article.
5512 (setq do-update-line article)
5513 (setq article (mail-header-id header))
5514 (setq sparse-header (gnus-read-header article))
5515 (setq gnus-newsgroup-sparse
5516 (delq article gnus-newsgroup-sparse)))
5518 ;; It's a real article.
5519 (setq article (mail-header-id header)))
5521 ;; It is an extracted pseudo-article.
5522 (setq article 'pseudo)
5523 (gnus-request-pseudo-article header))))
5525 (let ((method (gnus-find-method-for-group
5526 gnus-newsgroup-name)))
5527 (when (and (eq (car method) 'nneething)
5529 (let ((dir (nneething-get-file-name
5530 (mail-header-id header))))
5531 (when (and (stringp dir)
5532 (file-directory-p dir))
5533 (setq article 'nneething)
5534 (gnus-group-enter-directory dir))))))))
5537 ;; Refuse to select canceled articles.
5538 ((and (numberp article)
5540 (get-buffer gnus-summary-buffer)
5541 (gnus-buffer-exists-p gnus-summary-buffer)
5542 (eq (cdr (with-current-buffer gnus-summary-buffer
5543 (assq article gnus-newsgroup-reads)))
5544 gnus-canceled-mark))
5546 ;; We first check `gnus-original-article-buffer'.
5547 ((and (get-buffer gnus-original-article-buffer)
5549 (with-current-buffer gnus-original-article-buffer
5550 (and (equal (car gnus-original-article) group)
5551 (eq (cdr gnus-original-article) article))))
5552 (insert-buffer-substring gnus-original-article-buffer)
5554 ;; Check the backlog.
5555 ((and gnus-keep-backlog
5556 (gnus-backlog-request-article group article (current-buffer)))
5558 ;; Check asynchronous pre-fetch.
5559 ((gnus-async-request-fetched-article group article (current-buffer))
5560 (gnus-async-prefetch-next group article gnus-summary-buffer)
5561 (when (and (numberp article) gnus-keep-backlog)
5562 (gnus-backlog-enter-article group article (current-buffer)))
5565 ((and gnus-use-cache
5567 (gnus-cache-request-article article group))
5569 ;; Check the agent cache.
5570 ((gnus-agent-request-article article group)
5572 ;; Get the article and put into the article buffer.
5573 ((or (stringp article)
5575 (let ((gnus-override-method gnus-override-method)
5576 (methods (and (stringp article)
5577 gnus-refer-article-method))
5578 (backend (car (gnus-find-method-for-group
5579 gnus-newsgroup-name)))
5581 (inhibit-read-only t))
5582 (if (or (not (listp methods))
5583 (and (symbolp (car methods))
5584 (assq (car methods) nnoo-definition-alist)))
5585 (setq methods (list methods)))
5586 (when (and (null gnus-override-method)
5588 (setq gnus-override-method (pop methods)))
5590 (when (eq gnus-override-method 'current)
5591 (setq gnus-override-method
5592 (with-current-buffer gnus-summary-buffer
5593 gnus-current-select-method)))
5595 (gnus-kill-all-overlays)
5596 (let ((gnus-newsgroup-name group))
5597 (gnus-check-group-server))
5599 ((gnus-request-article article group (current-buffer))
5600 (when (numberp article)
5601 (gnus-async-prefetch-next group article
5602 gnus-summary-buffer)
5603 (when gnus-keep-backlog
5604 (gnus-backlog-enter-article
5605 group article (current-buffer))))
5606 (setq result 'article))
5608 (setq gnus-override-method (pop methods)))
5609 ((not (string-match "^400 "
5610 (nnheader-get-report backend)))
5611 ;; If we get 400 server disconnect, reconnect and
5612 ;; retry; otherwise, assume the article has expired.
5613 (setq result 'done))))
5614 (and (eq result 'article) 'article)))
5618 ;; Associate this article with the current summary buffer.
5619 (setq gnus-article-current-summary gnus-summary-buffer)
5621 ;; Take the article from the original article buffer
5622 ;; and place it in the buffer it's supposed to be in.
5623 (when (and (get-buffer gnus-article-buffer)
5624 (equal (buffer-name (current-buffer))
5625 (buffer-name (get-buffer gnus-article-buffer))))
5627 (if (get-buffer gnus-original-article-buffer)
5628 (set-buffer gnus-original-article-buffer)
5629 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5630 (buffer-disable-undo)
5631 (setq major-mode 'gnus-original-article-mode)
5632 (setq buffer-read-only t))
5633 (let ((inhibit-read-only t))
5635 (insert-buffer-substring gnus-article-buffer))
5636 (setq gnus-original-article (cons group article)))
5639 (run-hooks 'gnus-article-decode-hook)
5640 ;; Mark article as decoded or not.
5641 (setq gnus-article-decoded-p gnus-article-decode-hook))
5643 ;; Update sparse articles.
5644 (when (and do-update-line
5645 (or (numberp article)
5647 (let ((buf (current-buffer)))
5648 (set-buffer gnus-summary-buffer)
5649 (gnus-summary-update-article do-update-line sparse-header)
5650 (gnus-summary-goto-subject do-update-line nil t)
5651 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5653 (set-buffer buf))))))
5659 (defcustom gnus-article-edit-mode-hook nil
5660 "Hook run in article edit mode buffers."
5661 :group 'gnus-article-various
5664 (defvar gnus-article-edit-done-function nil)
5666 (defvar gnus-article-edit-mode-map nil)
5668 ;; Should we be using derived.el for this?
5669 (unless gnus-article-edit-mode-map
5670 (setq gnus-article-edit-mode-map (make-keymap))
5671 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5673 (gnus-define-keys gnus-article-edit-mode-map
5674 "\C-c?" describe-mode
5675 "\C-c\C-c" gnus-article-edit-done
5676 "\C-c\C-k" gnus-article-edit-exit
5677 "\C-c\C-f\C-t" message-goto-to
5678 "\C-c\C-f\C-o" message-goto-from
5679 "\C-c\C-f\C-b" message-goto-bcc
5680 ;;"\C-c\C-f\C-w" message-goto-fcc
5681 "\C-c\C-f\C-c" message-goto-cc
5682 "\C-c\C-f\C-s" message-goto-subject
5683 "\C-c\C-f\C-r" message-goto-reply-to
5684 "\C-c\C-f\C-n" message-goto-newsgroups
5685 "\C-c\C-f\C-d" message-goto-distribution
5686 "\C-c\C-f\C-f" message-goto-followup-to
5687 "\C-c\C-f\C-m" message-goto-mail-followup-to
5688 "\C-c\C-f\C-k" message-goto-keywords
5689 "\C-c\C-f\C-u" message-goto-summary
5690 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5691 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5692 "\C-c\C-b" message-goto-body
5693 "\C-c\C-i" message-goto-signature
5695 "\C-c\C-t" message-insert-to
5696 "\C-c\C-n" message-insert-newsgroups
5697 "\C-c\C-o" message-sort-headers
5698 "\C-c\C-e" message-elide-region
5699 "\C-c\C-v" message-delete-not-region
5700 "\C-c\C-z" message-kill-to-signature
5701 "\M-\r" message-newline-and-reformat
5702 "\C-c\C-a" mml-attach-file
5703 "\C-a" message-beginning-of-line
5705 "\M-;" comment-region)
5707 (gnus-define-keys (gnus-article-edit-wash-map
5708 "\C-c\C-w" gnus-article-edit-mode-map)
5709 "f" gnus-article-edit-full-stops))
5712 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5714 ["Fetch To" message-insert-to t]
5715 ["Fetch Newsgroups" message-insert-newsgroups t]
5717 ["To" message-goto-to t]
5718 ["From" message-goto-from t]
5719 ["Subject" message-goto-subject t]
5720 ["Cc" message-goto-cc t]
5721 ["Reply-To" message-goto-reply-to t]
5722 ["Summary" message-goto-summary t]
5723 ["Keywords" message-goto-keywords t]
5724 ["Newsgroups" message-goto-newsgroups t]
5725 ["Followup-To" message-goto-followup-to t]
5726 ["Mail-Followup-To" message-goto-mail-followup-to t]
5727 ["Distribution" message-goto-distribution t]
5728 ["Body" message-goto-body t]
5729 ["Signature" message-goto-signature t]))
5731 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5732 "Major mode for editing articles.
5733 This is an extended text-mode.
5735 \\{gnus-article-edit-mode-map}"
5736 (make-local-variable 'gnus-article-edit-done-function)
5737 (make-local-variable 'gnus-prev-winconf)
5738 (set (make-local-variable 'font-lock-defaults)
5739 '(message-font-lock-keywords t))
5740 (set (make-local-variable 'mail-header-separator) "")
5741 (set (make-local-variable 'gnus-article-edit-mode) t)
5742 (easy-menu-add message-mode-field-menu message-mode-map)
5744 (setq buffer-read-only nil)
5745 (buffer-enable-undo)
5748 (defun gnus-article-edit (&optional force)
5749 "Edit the current article.
5750 This will have permanent effect only in mail groups.
5751 If FORCE is non-nil, allow editing of articles even in read-only
5754 (when (and (not force)
5755 (gnus-group-read-only-p))
5756 (error "The current newsgroup does not support article editing"))
5757 (gnus-article-date-original)
5758 (gnus-article-edit-article
5760 `(lambda (no-highlight)
5762 (gnus-summary-edit-article-done
5763 ,(or (mail-header-references gnus-current-headers) "")
5764 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5766 (defun gnus-article-edit-article (start-func exit-func)
5767 "Start editing the contents of the current article buffer."
5768 (let ((winconf (current-window-configuration)))
5769 (set-buffer gnus-article-buffer)
5770 (let ((message-auto-save-directory
5771 ;; Don't associate the article buffer with a draft file.
5773 (gnus-article-edit-mode))
5774 (funcall start-func)
5775 (set-buffer-modified-p nil)
5776 (gnus-configure-windows 'edit-article)
5777 (setq gnus-article-edit-done-function exit-func)
5778 (setq gnus-prev-winconf winconf)
5779 (gnus-message 6 "C-c C-c to end edits")))
5781 (defun gnus-article-edit-done (&optional arg)
5782 "Update the article edits and exit."
5784 (let ((func gnus-article-edit-done-function)
5785 (buf (current-buffer))
5786 (start (window-start))
5788 (winconf gnus-prev-winconf))
5789 (widen) ;; Widen it in case that users narrowed the buffer.
5792 ;; The cache and backlog have to be flushed somewhat.
5793 (when gnus-keep-backlog
5794 (gnus-backlog-remove-article
5795 (car gnus-article-current) (cdr gnus-article-current)))
5796 ;; Flush original article as well.
5798 (when (get-buffer gnus-original-article-buffer)
5799 (set-buffer gnus-original-article-buffer)
5800 (setq gnus-original-article nil)))
5801 (when gnus-use-cache
5802 (gnus-cache-update-article
5803 (car gnus-article-current) (cdr gnus-article-current)))
5804 ;; We remove all text props from the article buffer.
5805 (kill-all-local-variables)
5806 (set-text-properties (point-min) (point-max) nil)
5808 (set-window-configuration winconf)
5810 (set-window-start (get-buffer-window buf) start)
5811 (set-window-point (get-buffer-window buf) (point)))
5812 (gnus-summary-show-article))
5814 (defun gnus-article-edit-exit ()
5815 "Exit the article editing without updating."
5817 (when (or (not (buffer-modified-p))
5818 (yes-or-no-p "Article modified; kill anyway? "))
5819 (let ((curbuf (current-buffer))
5821 (window-start (window-start)))
5823 (if (gnus-buffer-live-p gnus-original-article-buffer)
5824 (insert-buffer gnus-original-article-buffer))
5825 (let ((winconf gnus-prev-winconf))
5826 (kill-all-local-variables)
5828 (set-window-configuration winconf)
5829 ;; Tippy-toe some to make sure that point remains where it was.
5830 (save-current-buffer
5832 (set-window-start (get-buffer-window (current-buffer)) window-start)
5834 (gnus-summary-show-article)))
5836 (defun gnus-article-edit-full-stops ()
5837 "Interactively repair spacing at end of sentences."
5840 (goto-char (point-min))
5841 (search-forward-regexp "^$" nil t)
5842 (let ((case-fold-search nil))
5843 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5846 ;;; Article highlights
5849 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5851 ;;; Internal Variables:
5853 (defcustom gnus-button-url-regexp
5854 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5855 "\\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:]]\\)"
5856 "\\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\\)\\)")
5857 "Regular expression that matches URLs."
5858 :group 'gnus-article-buttons
5861 (defcustom gnus-button-valid-fqdn-regexp
5862 message-valid-fqdn-regexp
5863 "Regular expression that matches a valid FQDN."
5865 :group 'gnus-article-buttons
5868 (defcustom gnus-button-man-handler 'manual-entry
5869 "Function to use for displaying man pages.
5870 The function must take at least one argument with a string naming the
5873 :type '(choice (function-item :tag "Man" manual-entry)
5874 (function-item :tag "Woman" woman)
5875 (function :tag "Other"))
5876 :group 'gnus-article-buttons)
5878 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5879 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5880 If the default site is too slow, try to find a CTAN mirror, see
5881 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5882 the variable `gnus-button-handle-ctan'."
5884 :group 'gnus-article-buttons
5885 :link '(custom-manual "(gnus)Group Parameters")
5886 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5887 (const "http://tug.ctan.org/tex-archive/")
5888 (const "http://www.dante.de/CTAN/")
5889 (string :tag "Other")))
5891 (defcustom gnus-button-ctan-handler 'browse-url
5892 "Function to use for displaying CTAN links.
5893 The function must take one argument, the string naming the URL."
5895 :type '(choice (function-item :tag "Browse Url" browse-url)
5896 (function :tag "Other"))
5897 :group 'gnus-article-buttons)
5899 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5900 "Bogus strings removed from CTAN URLs."
5902 :group 'gnus-article-buttons
5903 :type '(choice (const "^/?tex-archive/\\|/")
5904 (regexp :tag "Other")))
5906 (defcustom gnus-button-ctan-directory-regexp
5909 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5910 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5911 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5913 "Regular expression for ctan directories.
5914 It should match all directories in the top level of `gnus-ctan-url'."
5916 :group 'gnus-article-buttons
5919 (defcustom gnus-button-mid-or-mail-regexp
5920 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
5921 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5922 gnus-button-valid-fqdn-regexp
5924 "Regular expression that matches a message ID or a mail address."
5926 :group 'gnus-article-buttons
5929 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5930 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5931 Strings like this can be either a message ID or a mail address. If it is one
5932 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5933 message ID or a mail address, respectively. If this variable is set to the
5934 symbol `ask', always query the user what do do. If it is a function, this
5935 function will be called with the string as it's only argument. The function
5936 must return `mid', `mail', `invalid' or `ask'."
5938 :group 'gnus-article-buttons
5939 :type '(choice (function-item :tag "Heuristic function"
5940 gnus-button-mid-or-mail-heuristic)
5945 (defcustom gnus-button-mid-or-mail-heuristic-alist
5946 '((-10.0 . ".+\\$.+@")
5949 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5950 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5951 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5952 (-1.0 . "^[^a-z]+@")
5954 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5955 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5956 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5957 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5960 (-1.0 . "^[0-9][0-9]")
5962 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5963 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5964 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5965 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5967 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5968 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5971 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5973 ;; compensation for TDMA dated mail addresses:
5974 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5976 (-20.0 . "\\.fsf@") ;; Gnus
5979 (-20.0 . "_-_") ;; Subject change in thread
5981 (-20.0 . "\\.ln@") ;; leafnode
5982 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5983 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5985 ;; (5.0 . "") ;; $local_part_len <= 7
5986 (10.0 . "^[^0-9]+@")
5987 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5988 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5991 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5993 (0.5 . "^[A-Z][a-z]")
5994 (0.5 . "^[A-Z][a-z][a-z]")
5995 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5996 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5997 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5999 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6000 address. The REGEXP is processed with `case-fold-search' set to nil."
6002 :group 'gnus-article-buttons
6003 :type '(repeat (cons (number :tag "Rate")
6004 (regexp :tag "Regexp"))))
6006 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6007 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6008 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6009 address, `ask' if unsure and `invalid' if the string is invalid."
6010 (let ((case-fold-search nil)
6011 (list gnus-button-mid-or-mail-heuristic-alist)
6012 (result 0) rate regexp lpartlen elem)
6014 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6015 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6016 ;; Certain special cases...
6019 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6020 "^[0-9]+\\.[0-9]+@compuserve\\|"
6021 "@public\\.gmane\\.org")
6023 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6024 (setq result 'mail))
6025 (when (string-match "@.*@\\| " mid-or-mail)
6026 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6027 (setq result 'invalid))
6028 ;; Nothing more to do, if result is not a number here...
6029 (when (numberp result)
6031 (setq elem (car list)
6035 (when (string-match regexp mid-or-mail)
6036 (setq result (+ result rate))
6038 9 "`%s' matched `%s', rate `%s', result `%s'."
6039 mid-or-mail regexp rate result)))
6040 (when (<= lpartlen 7)
6041 (setq result (+ result 5.0))
6042 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6043 mid-or-mail result))
6044 (when (>= lpartlen 12)
6045 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6047 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6048 ;; Long local part should contain realname if e-mail address,
6049 ;; too many digits: message-id.
6050 ;; $score -= 5.0 + 0.1 * $local_part_len;
6051 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6052 (setq result (+ result rate))
6054 9 "Many digits in `%s', rate `%s', result `%s'."
6055 mid-or-mail rate result))
6056 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6058 ;; Too few vowels [^aeiouy]{4,}.*\@
6059 (setq result (+ result -5.0))
6061 9 "Few vowels in `%s', rate `%s', result `%s'."
6062 mid-or-mail -5.0 result))
6064 (setq result (+ result 5.0))
6066 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6067 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6068 ;; Maybe we should make this a customizable alist: (condition . 'result)
6070 ((symbolp result) result)
6071 ;; Now convert number into proper results:
6072 ((< result -10.0) 'mid)
6073 ((> result 10.0) 'mail)
6076 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6077 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6078 (url-mid (concat "news" ":" mid-or-mail))
6079 (url-mailto (concat "mailto" ":" mid-or-mail)))
6080 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6081 (when (fboundp pref)
6083 ;; get rid of surrounding angles...
6085 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6086 (if (or (eq 'mid guessed) (eq 'mail guessed))
6090 (save-window-excursion
6091 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6094 (cond ((eq pref 'mid)
6095 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6096 (gnus-button-handle-news url-mid))
6098 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6099 (gnus-url-mailto url-mailto))
6100 (t (gnus-message 3 "Invalid string.")))))
6102 (defun gnus-button-handle-custom (url)
6103 "Follow a Custom URL."
6104 (customize-apropos (gnus-url-unhex-string url)))
6106 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6108 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6111 (defun gnus-button-handle-describe-function (url)
6112 "Call `describe-function' when pushing the corresponding URL button."
6115 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6117 (defun gnus-button-handle-describe-variable (url)
6118 "Call `describe-variable' when pushing the corresponding URL button."
6121 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6123 (defun gnus-button-handle-symbol (url)
6124 "Display help on variable or function.
6125 Calls `describe-variable' or `describe-function'."
6126 (let ((sym (intern url)))
6128 ((fboundp sym) (describe-function sym))
6129 ((boundp sym) (describe-variable sym))
6130 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6132 (defun gnus-button-handle-describe-key (url)
6133 "Call `describe-key' when pushing the corresponding URL button."
6135 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6136 (keys (ignore-errors (eval `(kbd ,key-string)))))
6139 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6141 (defun gnus-button-handle-apropos (url)
6142 "Call `apropos' when pushing the corresponding URL button."
6143 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6145 (defun gnus-button-handle-apropos-command (url)
6146 "Call `apropos' when pushing the corresponding URL button."
6148 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6150 (defun gnus-button-handle-apropos-variable (url)
6151 "Call `apropos' when pushing the corresponding URL button."
6153 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6154 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6156 (defun gnus-button-handle-apropos-documentation (url)
6157 "Call `apropos' when pushing the corresponding URL button."
6159 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6160 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6162 (defun gnus-button-handle-library (url)
6163 "Call `locate-library' when pushing the corresponding URL button."
6164 (gnus-message 9 "url=`%s'" url)
6165 (let* ((lib (locate-library url))
6166 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6168 (gnus-message 1 "Cannot locale library `%s'." url)
6169 (find-file-read-only file))))
6171 (defun gnus-button-handle-ctan (url)
6172 "Call `browse-url' when pushing a CTAN URL button."
6174 gnus-button-ctan-handler
6177 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6179 (defcustom gnus-button-tex-level 5
6180 "*Integer that says how many TeX-related buttons Gnus will show.
6181 The higher the number, the more buttons will appear and the more false
6182 positives are possible. Note that you can set this variable local to
6183 specific groups. Setting it higher in TeX groups is probably a good idea.
6184 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6185 how to set variables in specific groups."
6187 :group 'gnus-article-buttons
6188 :link '(custom-manual "(gnus)Group Parameters")
6191 (defcustom gnus-button-man-level 5
6192 "*Integer that says how many man-related buttons Gnus will show.
6193 The higher the number, the more buttons will appear and the more false
6194 positives are possible. Note that you can set this variable local to
6195 specific groups. Setting it higher in Unix groups is probably a good idea.
6196 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6197 how to set variables in specific groups."
6199 :group 'gnus-article-buttons
6200 :link '(custom-manual "(gnus)Group Parameters")
6203 (defcustom gnus-button-emacs-level 5
6204 "*Integer that says how many emacs-related buttons Gnus will show.
6205 The higher the number, the more buttons will appear and the more false
6206 positives are possible. Note that you can set this variable local to
6207 specific groups. Setting it higher in Emacs or Gnus related groups is
6208 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6209 `gnus-parameters' on how to set variables in specific groups."
6211 :group 'gnus-article-buttons
6212 :link '(custom-manual "(gnus)Group Parameters")
6215 (defcustom gnus-button-message-level 5
6216 "*Integer that says how many buttons for news or mail messages will appear.
6217 The higher the number, the more buttons will appear and the more false
6218 positives are possible."
6219 ;; mail addresses, MIDs, URLs for news, ...
6221 :group 'gnus-article-buttons
6224 (defcustom gnus-button-browse-level 5
6225 "*Integer that says how many buttons for browsing will appear.
6226 The higher the number, the more buttons will appear and the more false
6227 positives are possible."
6228 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6230 :group 'gnus-article-buttons
6233 (defcustom gnus-button-alist
6234 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6235 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6236 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6237 gnus-button-handle-news 2)
6238 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6239 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6240 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6241 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6242 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6243 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6244 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6245 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6246 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6247 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6248 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6249 ;; RFC 2368 (The mailto URL scheme)
6250 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6251 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6252 ("\\bmailto:\\([^ \n\t]+\\)"
6253 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6255 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6256 gnus-button-ctan-directory-regexp
6257 "[^][>)!;:,'\n\t ]+\\)")
6258 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6259 ((concat "\\btex-archive/\\("
6260 gnus-button-ctan-directory-regexp
6261 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6262 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6265 gnus-button-ctan-directory-regexp
6266 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6267 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6268 ;; This is info (home-grown style) <info://foo/bar+baz>
6269 ("\\binfo://\\([^'\">\n\t ]+\\)"
6270 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6271 ;; Info GNOME style <info:foo#bar_baz>
6272 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6273 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6274 ;; Info KDE style <info:(foo)bar baz>
6275 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6276 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6277 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6278 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6279 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6280 ;; Info links like `C-h i d m CC Mode RET'
6281 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6283 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6284 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6285 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6286 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6287 ;; Emacs help commands
6288 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6289 ;; regexp doesn't match arguments containing ` '.
6290 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6291 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6292 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6293 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6294 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6295 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6296 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6297 ;; The following entries may lead to many false positives so don't enable
6298 ;; them by default (use a high button level).
6299 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6300 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6301 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6302 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6303 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6304 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6305 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6306 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6307 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6308 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6309 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6310 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6311 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6312 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6313 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6314 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6315 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6316 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6317 ;; Unlike the other regexps we really have to require quoting
6318 ;; here to determine where it ends.
6319 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6320 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6321 ("<URL: *\\([^<>]*\\)>"
6322 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6323 ;; RFC 2396 (2.4.3., delims) ...
6324 ("\"URL: *\\([^\"]*\\)\""
6325 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6326 ;; RFC 2396 (2.4.3., delims) ...
6327 ("\"URL: *\\([^\"]*\\)\""
6328 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6330 (gnus-button-url-regexp
6331 0 (>= gnus-button-browse-level 0) browse-url 0)
6333 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6334 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6335 gnus-button-handle-man 1)
6336 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6337 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6338 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6339 gnus-button-handle-man 1)
6340 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6341 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6342 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6343 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6344 ;; MID or mail: To avoid too many false positives we don't try to catch
6345 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6346 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6347 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6348 ;; so that non-ambiguous entries (see above) match first.
6349 (gnus-button-mid-or-mail-regexp
6350 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6351 "*Alist of regexps matching buttons in article bodies.
6353 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6354 REGEXP: is the string (case insensitive) matching text around the button (can
6355 also be Lisp expression evaluating to a string),
6356 BUTTON: is the number of the regexp grouping actually matching the button,
6357 FORM: is a Lisp expression which must eval to true for the button to
6359 CALLBACK: is the function to call when the user push this button, and each
6360 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6362 CALLBACK can also be a variable, in that case the value of that
6363 variable it the real callback function."
6364 :group 'gnus-article-buttons
6365 :type '(repeat (list (choice regexp variable sexp)
6366 (integer :tag "Button")
6368 (function :tag "Callback")
6371 (integer :tag "Regexp group")))))
6373 (defcustom gnus-header-button-alist
6374 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6375 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6376 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6377 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6378 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6379 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6380 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6381 0 (>= gnus-button-browse-level 0) browse-url 0)
6382 ("^Subject:" gnus-button-url-regexp
6383 0 (>= gnus-button-browse-level 0) browse-url 0)
6384 ("^[^:]+:" gnus-button-url-regexp
6385 0 (>= gnus-button-browse-level 0) browse-url 0)
6386 ("^OpenPGP:.*url=" gnus-button-url-regexp
6387 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6388 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6389 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6390 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6391 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6392 "*Alist of headers and regexps to match buttons in article heads.
6394 This alist is very similar to `gnus-button-alist', except that each
6395 alist has an additional HEADER element first in each entry:
6397 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6399 HEADER is a regexp to match a header. For a fuller explanation, see
6400 `gnus-button-alist'."
6401 :group 'gnus-article-buttons
6402 :group 'gnus-article-headers
6403 :type '(repeat (list (regexp :tag "Header")
6404 (choice regexp variable)
6405 (integer :tag "Button")
6407 (function :tag "Callback")
6410 (integer :tag "Regexp group")))))
6414 (defun gnus-article-push-button (event)
6415 "Check text under the mouse pointer for a callback function.
6416 If the text under the mouse pointer has a `gnus-callback' property,
6417 call it with the value of the `gnus-data' text property."
6419 (set-buffer (window-buffer (posn-window (event-start event))))
6420 (let* ((pos (posn-point (event-start event)))
6421 (data (get-text-property pos 'gnus-data))
6422 (fun (get-text-property pos 'gnus-callback)))
6425 (funcall fun data))))
6427 (defun gnus-article-press-button ()
6428 "Check text at point for a callback function.
6429 If the text at point has a `gnus-callback' property,
6430 call it with the value of the `gnus-data' text property."
6432 (let ((data (get-text-property (point) 'gnus-data))
6433 (fun (get-text-property (point) 'gnus-callback)))
6435 (funcall fun data))))
6437 (defun gnus-article-highlight (&optional force)
6438 "Highlight current article.
6439 This function calls `gnus-article-highlight-headers',
6440 `gnus-article-highlight-citation',
6441 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6442 do the highlighting. See the documentation for those functions."
6443 (interactive (list 'force))
6444 (gnus-article-highlight-headers)
6445 (gnus-article-highlight-citation force)
6446 (gnus-article-highlight-signature)
6447 (gnus-article-add-buttons force)
6448 (gnus-article-add-buttons-to-head))
6450 (defun gnus-article-highlight-some (&optional force)
6451 "Highlight current article.
6452 This function calls `gnus-article-highlight-headers',
6453 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6454 do the highlighting. See the documentation for those functions."
6455 (interactive (list 'force))
6456 (gnus-article-highlight-headers)
6457 (gnus-article-highlight-signature)
6458 (gnus-article-add-buttons))
6460 (defun gnus-article-highlight-headers ()
6461 "Highlight article headers as specified by `gnus-header-face-alist'."
6463 (gnus-with-article-headers
6464 (let (regexp header-face field-face from hpoints fpoints)
6465 (dolist (entry gnus-header-face-alist)
6466 (goto-char (point-min))
6467 (setq regexp (concat "^\\("
6468 (if (string-equal "" (nth 0 entry))
6472 header-face (nth 1 entry)
6473 field-face (nth 2 entry))
6474 (while (and (re-search-forward regexp nil t)
6478 (unless (search-forward ":" nil t)
6480 (when (and header-face
6481 (not (memq (point) hpoints)))
6482 (push (point) hpoints)
6483 (gnus-put-text-property from (point) 'face header-face))
6484 (when (and field-face
6485 (not (memq (setq from (point)) fpoints)))
6487 (if (re-search-forward "^[^ \t]" nil t)
6489 (goto-char (point-max)))
6490 (gnus-put-text-property from (point) 'face field-face)))))))
6492 (defun gnus-article-highlight-signature ()
6493 "Highlight the signature in an article.
6494 It does this by highlighting everything after
6495 `gnus-signature-separator' using the face `gnus-signature'."
6497 (gnus-with-article-buffer
6498 (let ((inhibit-point-motion-hooks t))
6500 (when (and gnus-signature-face
6501 (gnus-article-narrow-to-signature))
6502 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6503 'face gnus-signature-face)
6505 (gnus-article-search-signature)
6506 (let ((start (match-beginning 0))
6507 (end (set-marker (make-marker) (1+ (match-end 0)))))
6508 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6511 (defun gnus-button-in-region-p (b e prop)
6512 "Say whether PROP exists in the region."
6513 (text-property-not-all b e prop nil))
6515 (defun gnus-article-add-buttons (&optional force)
6516 "Find external references in the article and make buttons of them.
6517 \"External references\" are things like Message-IDs and URLs, as
6518 specified by `gnus-button-alist'."
6519 (interactive (list 'force))
6520 (gnus-with-article-buffer
6521 (let ((inhibit-point-motion-hooks t)
6522 (case-fold-search t)
6523 (alist gnus-button-alist)
6525 ;; Remove all old markers.
6526 (let (marker entry new-list)
6527 (while (setq marker (pop gnus-button-marker-list))
6528 (if (or (< marker (point-min)) (>= marker (point-max)))
6529 (push marker new-list)
6531 (when (setq entry (gnus-button-entry))
6532 (put-text-property (match-beginning (nth 1 entry))
6533 (match-end (nth 1 entry))
6534 'gnus-callback nil))
6535 (set-marker marker nil)))
6536 (setq gnus-button-marker-list new-list))
6537 ;; We skip the headers.
6540 (while (setq entry (pop alist))
6541 (setq regexp (eval (car entry)))
6543 (while (re-search-forward regexp nil t)
6544 (let* ((start (and entry (match-beginning (nth 1 entry))))
6545 (end (and entry (match-end (nth 1 entry))))
6546 (from (match-beginning 0)))
6547 (when (and (or (eq t (nth 2 entry))
6548 (eval (nth 2 entry)))
6549 (not (gnus-button-in-region-p
6550 start end 'gnus-callback)))
6551 ;; That optional form returned non-nil, so we add the
6553 (gnus-article-add-button
6554 start end 'gnus-button-push
6555 (car (push (set-marker (make-marker) from)
6556 gnus-button-marker-list))))))))))
6558 ;; Add buttons to the head of an article.
6559 (defun gnus-article-add-buttons-to-head ()
6560 "Add buttons to the head of the article."
6562 (gnus-with-article-headers
6564 (dolist (entry gnus-header-button-alist)
6565 ;; Each alist entry.
6566 (goto-char (point-min))
6567 (while (re-search-forward (car entry) nil t)
6568 ;; Each header matching the entry.
6569 (setq beg (match-beginning 0))
6570 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6571 (match-beginning 0))
6574 (while (re-search-forward (eval (nth 1 entry)) end t)
6575 ;; Each match within a header.
6576 (let* ((entry (cdr entry))
6577 (start (match-beginning (nth 1 entry)))
6578 (end (match-end (nth 1 entry)))
6579 (form (nth 2 entry)))
6580 (goto-char (match-end 0))
6582 (gnus-article-add-button
6583 start end (nth 3 entry)
6584 (buffer-substring (match-beginning (nth 4 entry))
6585 (match-end (nth 4 entry)))))))
6586 (goto-char end))))))
6588 ;;; External functions:
6590 (defun gnus-article-add-button (from to fun &optional data)
6591 "Create a button between FROM and TO with callback FUN and data DATA."
6592 (when gnus-article-button-face
6593 (gnus-overlay-put (gnus-make-overlay from to)
6594 'face gnus-article-button-face))
6595 (gnus-add-text-properties
6597 (nconc (and gnus-article-mouse-face
6598 (list gnus-mouse-face-prop gnus-article-mouse-face))
6599 (list 'gnus-callback fun)
6600 (and data (list 'gnus-data data))))
6601 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6602 :button-keymap gnus-widget-button-keymap))
6604 ;;; Internal functions:
6606 (defun gnus-article-set-globals ()
6607 (with-current-buffer gnus-summary-buffer
6608 (gnus-set-global-variables)))
6610 (defun gnus-signature-toggle (end)
6611 (gnus-with-article-buffer
6612 (let ((inhibit-point-motion-hooks t))
6613 (if (text-property-any end (point-max) 'article-type 'signature)
6615 (gnus-delete-wash-type 'signature)
6616 (gnus-remove-text-properties-when
6617 'article-type 'signature end (point-max)
6618 (cons 'article-type (cons 'signature
6619 gnus-hidden-properties))))
6620 (gnus-add-wash-type 'signature)
6621 (gnus-add-text-properties-when
6622 'article-type nil end (point-max)
6623 (cons 'article-type (cons 'signature
6624 gnus-hidden-properties)))))
6625 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6626 (gnus-set-mode-line 'article))))
6628 (defun gnus-button-entry ()
6629 ;; Return the first entry in `gnus-button-alist' matching this place.
6630 (let ((alist gnus-button-alist)
6633 (setq entry (pop alist))
6634 (if (looking-at (eval (car entry)))
6639 (defun gnus-button-push (marker)
6640 ;; Push button starting at MARKER.
6643 (let* ((entry (gnus-button-entry))
6644 (inhibit-point-motion-hooks t)
6646 (args (mapcar (lambda (group)
6647 (let ((string (match-string group)))
6648 (set-text-properties
6649 0 (length string) nil string)
6656 (fboundp (symbol-value fun)))
6657 (apply (symbol-value fun) args))
6659 (gnus-message 1 "You must define `%S' to use this button"
6660 (cons fun args)))))))
6662 (defun gnus-parse-news-url (url)
6663 (let (scheme server port group message-id articles)
6666 (goto-char (point-min))
6667 (when (looking-at "\\([A-Za-z]+\\):")
6668 (setq scheme (match-string 1))
6669 (goto-char (match-end 0)))
6670 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
6671 (setq server (match-string 1))
6672 (setq port (if (stringp (match-string 3))
6673 (string-to-number (match-string 3))
6675 (goto-char (match-end 0)))
6678 ((looking-at "\\(.*@.*\\)")
6679 (setq message-id (match-string 1)))
6680 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6681 (setq group (match-string 1)
6682 articles (split-string (match-string 2) "-")))
6683 ((looking-at "\\([^/]+\\)/?")
6684 (setq group (match-string 1)))
6686 (error "Unknown news URL syntax"))))
6687 (list scheme server port group message-id articles)))
6689 (defun gnus-button-handle-news (url)
6691 (destructuring-bind (scheme server port group message-id articles)
6692 (gnus-parse-news-url url)
6696 (set-buffer gnus-summary-buffer)
6698 (let ((gnus-refer-article-method
6699 (nconc (list (list 'nntp server))
6700 gnus-refer-article-method))
6701 (nntp-port-number (or port "nntp")))
6702 (gnus-message 7 "Fetching %s with %s"
6703 message-id gnus-refer-article-method)
6704 (gnus-summary-refer-article message-id))
6705 (gnus-summary-refer-article message-id))))
6707 (gnus-button-fetch-group url)))))
6709 (defun gnus-button-handle-man (url)
6711 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6712 (when (eq gnus-button-man-handler 'woman)
6713 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
6714 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6715 (funcall gnus-button-man-handler url))
6717 (defun gnus-button-handle-info-url (url)
6718 "Fetch an info URL."
6719 (setq url (mm-subst-char-in-string ?+ ?\ url))
6721 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6722 (gnus-info-find-node
6723 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6725 ")" (gnus-url-unhex-string (match-string 2 url)))))
6726 ((string-match "([^)\"]+)[^\"]+" url)
6728 (gnus-replace-in-string
6729 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6730 (gnus-info-find-node url))
6731 (t (error "Can't parse %s" url))))
6733 (defun gnus-button-handle-info-url-gnome (url)
6734 "Fetch GNOME style info URL."
6735 (setq url (mm-subst-char-in-string ?_ ?\ url))
6736 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6737 (gnus-info-find-node
6739 (gnus-url-unhex-string
6740 (match-string 1 url))
6742 (or (gnus-url-unhex-string
6743 (match-string 2 url))
6745 (error "Can't parse %s" url)))
6747 (defun gnus-button-handle-info-url-kde (url)
6748 "Fetch KDE style info URL."
6749 (gnus-info-find-node (gnus-url-unhex-string url)))
6751 (defun gnus-button-handle-info-keystrokes (url)
6752 "Call `info' when pushing the corresponding URL button."
6753 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6758 (defun gnus-button-openpgp (url)
6759 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
6761 (mm-url-insert-file-contents-external url)
6762 (pgg-snarf-keys-region (point-min) (point-max))
6763 (pgg-display-output-buffer nil nil nil)))
6765 (defun gnus-button-message-id (message-id)
6767 (with-current-buffer gnus-summary-buffer
6768 (gnus-summary-refer-article message-id)))
6770 (defun gnus-button-fetch-group (address)
6771 "Fetch GROUP specified by ADDRESS."
6772 (if (not (string-match "[:/]" address))
6773 ;; This is just a simple group url.
6774 (gnus-group-read-ephemeral-group address gnus-select-method)
6777 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6779 (error "Can't parse %s" address)
6780 (gnus-group-read-ephemeral-group
6781 (match-string 4 address)
6782 `(nntp ,(match-string 1 address)
6783 (nntp-address ,(match-string 1 address))
6784 (nntp-port-number ,(if (match-end 3)
6785 (match-string 3 address)
6788 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
6790 (defun gnus-url-parse-query-string (query &optional downcase)
6791 (let (retval pairs cur key val)
6792 (setq pairs (split-string query "&"))
6794 (setq cur (car pairs)
6796 (if (not (string-match "=" cur))
6798 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6799 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6801 (setq key (downcase key)))
6802 (setq cur (assoc key retval))
6804 (setcdr cur (cons val (cdr cur)))
6805 (setq retval (cons (list key val) retval)))))
6808 (defun gnus-url-mailto (url)
6809 ;; Send mail to someone
6810 (when (string-match "mailto:/*\\(.*\\)" url)
6811 (setq url (substring url (match-beginning 1) nil)))
6812 (let (to args subject func)
6813 (setq args (gnus-url-parse-query-string
6814 (if (string-match "^\\?" url)
6816 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6817 (concat "to=" (match-string 1 url) "&"
6818 (match-string 2 url))
6819 (concat "to=" url)))
6821 subject (cdr-safe (assoc "subject" args)))
6824 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6827 (message-position-on-field (caar args)))
6828 (insert (gnus-replace-in-string
6829 (mapconcat 'identity (reverse (cdar args)) ", ")
6831 (setq args (cdr args)))
6834 (message-goto-subject))))
6836 (defun gnus-button-embedded-url (address)
6837 "Activate ADDRESS with `browse-url'."
6838 (browse-url (gnus-strip-whitespace address)))
6840 ;;; Next/prev buttons in the article buffer.
6842 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6843 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6845 (defvar gnus-prev-page-map
6846 (let ((map (make-sparse-keymap)))
6847 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6848 (define-key map "\r" 'gnus-button-prev-page)
6851 (defvar gnus-next-page-map
6852 (let ((map (make-sparse-keymap)))
6853 (unless (>= emacs-major-version 21)
6854 ;; XEmacs doesn't care.
6855 (set-keymap-parent map gnus-article-mode-map))
6856 (define-key map gnus-mouse-2 'gnus-button-next-page)
6857 (define-key map "\r" 'gnus-button-next-page)
6860 (defun gnus-insert-prev-page-button ()
6862 (inhibit-read-only t))
6864 gnus-prev-page-line-format nil
6865 `(keymap ,gnus-prev-page-map
6867 gnus-callback gnus-article-button-prev-page
6868 article-type annotation))
6869 (widget-convert-button
6871 ;; Exclude a newline.
6874 :action 'gnus-button-prev-page
6875 :button-keymap gnus-prev-page-map)))
6877 (defun gnus-button-next-page (&optional args more-args)
6878 "Go to the next page."
6880 (let ((win (selected-window)))
6881 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6882 (gnus-article-next-page)
6883 (select-window win)))
6885 (defun gnus-button-prev-page (&optional args more-args)
6886 "Go to the prev page."
6888 (let ((win (selected-window)))
6889 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6890 (gnus-article-prev-page)
6891 (select-window win)))
6893 (defun gnus-insert-next-page-button ()
6895 (inhibit-read-only t))
6896 (gnus-eval-format gnus-next-page-line-format nil
6897 `(keymap ,gnus-next-page-map
6899 gnus-callback gnus-article-button-next-page
6900 article-type annotation))
6901 (widget-convert-button
6903 ;; Exclude a newline.
6906 :action 'gnus-button-next-page
6907 :button-keymap gnus-next-page-map)))
6909 (defun gnus-article-button-next-page (arg)
6910 "Go to the next page."
6912 (let ((win (selected-window)))
6913 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6914 (gnus-article-next-page)
6915 (select-window win)))
6917 (defun gnus-article-button-prev-page (arg)
6918 "Go to the prev page."
6920 (let ((win (selected-window)))
6921 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6922 (gnus-article-prev-page)
6923 (select-window win)))
6925 (defvar gnus-decode-header-methods
6926 '(mail-decode-encoded-word-region)
6927 "List of methods used to decode headers.
6929 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6930 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
6931 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6932 whose names match REGEXP.
6935 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6936 mail-decode-encoded-word-region
6937 (\"chinese\" . rfc1843-decode-region))
6940 (defvar gnus-decode-header-methods-cache nil)
6942 (defun gnus-multi-decode-header (start end)
6943 "Apply the functions from `gnus-encoded-word-methods' that match."
6944 (unless (and gnus-decode-header-methods-cache
6945 (eq gnus-newsgroup-name
6946 (car gnus-decode-header-methods-cache)))
6947 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6950 (nconc gnus-decode-header-methods-cache (list x))
6951 (if (and gnus-newsgroup-name
6952 (string-match (car x) gnus-newsgroup-name))
6953 (nconc gnus-decode-header-methods-cache
6955 gnus-decode-header-methods))
6956 (let ((xlist gnus-decode-header-methods-cache))
6959 (narrow-to-region start end)
6961 (funcall (pop xlist) (point-min) (point-max))))))
6964 ;;; Treatment top-level handling.
6967 (defun gnus-treat-article (condition &optional part-number total-parts type)
6968 (let ((length (- (point-max) (point-min)))
6969 (alist gnus-treatment-function-alist)
6970 (article-goto-body-goes-to-point-min-p t)
6974 (let ((list gnus-article-treat-types))
6976 (when (string-match (pop list) type)
6977 (throw 'found t)))))))
6978 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6980 (gnus-run-hooks 'gnus-part-display-hook)
6981 (dolist (elem alist)
6984 (when (gnus-buffer-live-p gnus-summary-buffer)
6985 (set-buffer gnus-summary-buffer))
6986 (symbol-value (car elem))))
6987 (when (and (or (consp val)
6989 (gnus-treat-predicate val)
6990 (or (not (get (car elem) 'highlight))
6993 (funcall (cadr elem)))))))
6995 ;; Dynamic variables.
6997 (defvar part-number)
6998 (defvar total-parts)
7003 (defun gnus-treat-predicate (val)
7010 (stringp (car val)))
7011 (apply 'gnus-or (mapcar `(lambda (s)
7012 (string-match s ,(or gnus-newsgroup-name "")))
7015 (let ((pred (pop val)))
7018 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7020 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7022 (not (gnus-treat-predicate (car val))))
7024 (equal (car val) type))
7026 (error "%S is not a valid predicate" pred)))))
7032 (eq part-number total-parts))
7036 (error "%S is not a valid value" val))))
7038 (defun gnus-article-encrypt-body (protocol &optional n)
7039 "Encrypt the article body."
7042 (or gnus-article-encrypt-protocol
7043 (completing-read "Encrypt protocol: "
7044 gnus-article-encrypt-protocol-alist
7046 current-prefix-arg))
7047 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7049 (error "Can't find the encrypt protocol %s" protocol))
7050 (if (member gnus-newsgroup-name '("nndraft:delayed"
7053 (error "Can't encrypt the article in group %s"
7054 gnus-newsgroup-name))
7055 (gnus-summary-iterate n
7057 (set-buffer gnus-summary-buffer)
7058 (let ((mail-parse-charset gnus-newsgroup-charset)
7059 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7060 (summary-buffer gnus-summary-buffer)
7062 (gnus-set-global-variables)
7063 (when (gnus-group-read-only-p)
7064 (error "The current newsgroup does not support article encrypt"))
7065 (gnus-summary-show-article t)
7067 (or (mail-header-references gnus-current-headers) ""))
7068 (set-buffer gnus-article-buffer)
7069 (let* ((inhibit-read-only t)
7071 (mapcar (lambda (field)
7072 (and (save-restriction
7073 (message-narrow-to-head)
7074 (goto-char (point-min))
7075 (search-forward field nil t))
7077 (message-narrow-to-field)
7079 (delete-region (point-min) (point-max))
7081 '("Content-Type:" "Content-Transfer-Encoding:"
7082 "Content-Disposition:"))))
7083 (message-narrow-to-head)
7084 (message-remove-header "MIME-Version")
7085 (goto-char (point-max))
7086 (setq point (point))
7087 (insert (apply 'concat headers))
7089 (narrow-to-region point (point-max))
7090 (let ((message-options message-options))
7091 (message-options-set 'message-sender user-mail-address)
7092 (message-options-set 'message-recipients user-mail-address)
7093 (message-options-set 'message-sign-encrypt 'not)
7095 (goto-char (point-min))
7096 (insert "MIME-Version: 1.0\n")
7098 (gnus-summary-edit-article-done
7099 references nil summary-buffer t))
7100 (when gnus-keep-backlog
7101 (gnus-backlog-remove-article
7102 (car gnus-article-current) (cdr gnus-article-current)))
7104 (when (get-buffer gnus-original-article-buffer)
7105 (set-buffer gnus-original-article-buffer)
7106 (setq gnus-original-article nil)))
7107 (when gnus-use-cache
7108 (gnus-cache-update-article
7109 (car gnus-article-current) (cdr gnus-article-current))))))))
7111 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7112 "The following specs can be used:
7113 %t The security MIME type
7116 %D Details if button is pressed")
7118 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7119 "The following specs can be used:
7120 %t The security MIME type
7123 %D Details if button is pressed")
7125 (defvar gnus-mime-security-button-line-format-alist
7126 '((?t gnus-tmp-type ?s)
7127 (?i gnus-tmp-info ?s)
7128 (?d gnus-tmp-details ?s)
7129 (?D gnus-tmp-pressed-details ?s)))
7131 (defvar gnus-mime-security-button-map
7132 (let ((map (make-sparse-keymap)))
7133 (define-key map gnus-mouse-2 'gnus-article-push-button)
7134 (define-key map "\r" 'gnus-article-press-button)
7137 (defvar gnus-mime-security-details-buffer nil)
7139 (defvar gnus-mime-security-button-pressed nil)
7141 (defvar gnus-mime-security-show-details-inline t
7142 "If non-nil, show details in the article buffer.")
7144 (defun gnus-mime-security-verify-or-decrypt (handle)
7145 (mm-remove-parts (cdr handle))
7146 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7147 point (inhibit-read-only t))
7149 (goto-char (car region)))
7151 (narrow-to-region (point) (point))
7152 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7153 (let* ((mm-verify-option 'known)
7154 (mm-decrypt-option 'known)
7155 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7156 (unless (eq nparts (cdr handle))
7157 (mm-destroy-parts (cdr handle))
7158 (setcdr handle nparts))))
7159 (setq point (point))
7160 (gnus-mime-display-security handle)
7161 (goto-char (point-max)))
7163 (delete-region (point) (cdr region))
7164 (set-marker (car region) nil)
7165 (set-marker (cdr region) nil))
7168 (defun gnus-mime-security-show-details (handle)
7169 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7171 (gnus-message 5 "No details.")
7172 (if gnus-mime-security-show-details-inline
7173 (let ((gnus-mime-security-button-pressed
7174 (not (get-text-property (point) 'gnus-mime-details)))
7175 (gnus-mime-security-button-line-format
7176 (get-text-property (point) 'gnus-line-format))
7177 (inhibit-read-only t))
7179 (while (eq (get-text-property (point) 'gnus-line-format)
7180 gnus-mime-security-button-line-format)
7184 (narrow-to-region (point) (point))
7185 (gnus-insert-mime-security-button handle))
7186 (delete-region (point)
7187 (or (text-property-not-all
7190 gnus-mime-security-button-line-format)
7193 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7194 (with-current-buffer gnus-mime-security-details-buffer
7197 (setq gnus-mime-security-details-buffer
7198 (gnus-get-buffer-create "*MIME Security Details*")))
7199 (with-current-buffer gnus-mime-security-details-buffer
7201 (goto-char (point-min)))
7202 (pop-to-buffer gnus-mime-security-details-buffer)))))
7204 (defun gnus-mime-security-press-button (handle)
7206 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7207 (gnus-mime-security-show-details handle)
7208 (gnus-mime-security-verify-or-decrypt handle))))
7210 (defun gnus-insert-mime-security-button (handle &optional displayed)
7211 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7214 (or (nth 2 (assoc protocol mm-verify-function-alist))
7215 (nth 2 (assoc protocol mm-decrypt-function-alist))
7217 (if (equal (car handle) "multipart/signed")
7218 " Signed" " Encrypted")
7221 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7224 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7225 gnus-tmp-pressed-details
7227 (setq gnus-tmp-details
7228 (if gnus-tmp-details
7229 (concat "\n" gnus-tmp-details)
7231 (setq gnus-tmp-pressed-details
7232 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7237 gnus-mime-security-button-line-format
7238 gnus-mime-security-button-line-format-alist
7239 `(keymap ,gnus-mime-security-button-map
7240 gnus-callback gnus-mime-security-press-button
7241 gnus-line-format ,gnus-mime-security-button-line-format
7242 gnus-mime-details ,gnus-mime-security-button-pressed
7243 article-type annotation
7246 ;; Exclude a newline.
7249 (widget-convert-button
7252 :action 'gnus-widget-press-button
7253 :button-keymap gnus-mime-security-button-map
7255 (lambda (widget/window &optional overlay pos)
7256 ;; Needed to properly clear the message due to a bug in
7257 ;; wid-edit (XEmacs only).
7258 (when (boundp 'help-echo-owns-message)
7259 (setq help-echo-owns-message t))
7262 (aref gnus-mouse-2 0))))))
7264 (defun gnus-mime-display-security (handle)
7266 (narrow-to-region (point) (point))
7267 (unless (gnus-unbuttonized-mime-type-p (car handle))
7268 (gnus-insert-mime-security-button handle))
7269 (gnus-mime-display-mixed (cdr handle))
7272 (unless (gnus-unbuttonized-mime-type-p (car handle))
7273 (let ((gnus-mime-security-button-line-format
7274 gnus-mime-security-button-end-line-format))
7275 (gnus-insert-mime-security-button handle)))
7276 (mm-set-handle-multipart-parameter
7278 (cons (set-marker (make-marker) (point-min))
7279 (set-marker (make-marker) (point-max))))))
7285 (run-hooks 'gnus-art-load-hook)
7287 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7288 ;;; gnus-art.el ends here