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))
46 (autoload 'gnus-msg-mail "gnus-msg" nil t)
47 (autoload 'gnus-button-mailto "gnus-msg")
48 (autoload 'gnus-button-reply "gnus-msg" nil t)
50 (defgroup gnus-article nil
52 :link '(custom-manual "(gnus)Article Buffer")
55 (defgroup gnus-article-treat nil
56 "Treating article parts."
57 :link '(custom-manual "(gnus)Article Hiding")
60 (defgroup gnus-article-hiding nil
61 "Hiding article parts."
62 :link '(custom-manual "(gnus)Article Hiding")
65 (defgroup gnus-article-highlight nil
66 "Article highlighting."
67 :link '(custom-manual "(gnus)Article Highlighting")
71 (defgroup gnus-article-signature nil
73 :link '(custom-manual "(gnus)Article Signature")
76 (defgroup gnus-article-headers nil
78 :link '(custom-manual "(gnus)Hiding Headers")
81 (defgroup gnus-article-washing nil
82 "Special commands on articles."
83 :link '(custom-manual "(gnus)Article Washing")
86 (defgroup gnus-article-emphasis nil
87 "Fontisizing articles."
88 :link '(custom-manual "(gnus)Article Fontisizing")
91 (defgroup gnus-article-saving nil
93 :link '(custom-manual "(gnus)Saving Articles")
96 (defgroup gnus-article-mime nil
97 "Worshiping the MIME wonder."
98 :link '(custom-manual "(gnus)Using MIME")
101 (defgroup gnus-article-buttons nil
102 "Pushable buttons in the article buffer."
103 :link '(custom-manual "(gnus)Article Buttons")
104 :group 'gnus-article)
106 (defgroup gnus-article-various nil
107 "Other article options."
108 :link '(custom-manual "(gnus)Misc Article")
109 :group 'gnus-article)
111 (defcustom gnus-ignored-headers
114 (concat "^" header ":"))
115 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
116 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
117 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
118 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
119 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
120 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
121 "X-Attribution" "X-Originating-IP" "Delivered-To"
122 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
123 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
124 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
125 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
126 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
127 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
128 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
129 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
130 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
131 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
132 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
133 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
134 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
135 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
136 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
137 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
138 "List-[A-Za-z]+" "X-Listprocessor-Version"
139 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
140 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
141 "X-Received" "Content-length" "X-precedence"
142 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
143 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
144 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
145 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
146 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
147 "X-Content-length" "X-Posting-Agent" "Original-Received"
148 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
149 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
150 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
151 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
152 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
153 "*All headers that start with this regexp will be hidden.
154 This variable can also be a list of regexps of headers to be ignored.
155 If `gnus-visible-headers' is non-nil, this variable will be ignored."
156 :type '(choice :custom-show nil
159 :group 'gnus-article-hiding)
161 (defcustom gnus-visible-headers
162 "^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:"
163 "*All headers that do not match this regexp will be hidden.
164 This variable can also be a list of regexp of headers to remain visible.
165 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
166 :type '(repeat :value-to-internal (lambda (widget value)
167 (custom-split-regexp-maybe value))
168 :match (lambda (widget value)
170 (widget-editable-list-match widget value)))
172 :group 'gnus-article-hiding)
174 (defcustom gnus-sorted-header-list
175 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
176 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
177 "*This variable is a list of regular expressions.
178 If it is non-nil, headers that match the regular expressions will
179 be placed first in the article buffer in the sequence specified by
181 :type '(repeat regexp)
182 :group 'gnus-article-hiding)
184 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
185 "Headers that are only to be displayed if they have interesting data.
186 Possible values in this list are:
188 'empty Headers with no content.
189 'newsgroups Newsgroup identical to Gnus group.
190 'to-address To identical to To-address.
191 'to-list To identical to To-list.
192 'cc-list CC identical to To-list.
193 'followup-to Followup-to identical to Newsgroups.
194 'reply-to Reply-to identical to From.
195 'date Date less than four days old.
196 'long-to To and/or Cc longer than 1024 characters.
197 'many-to Multiple To and/or Cc."
198 :type '(set (const :tag "Headers with no content." empty)
199 (const :tag "Newsgroups identical to Gnus group." newsgroups)
200 (const :tag "To identical to To-address." to-address)
201 (const :tag "To identical to To-list." to-list)
202 (const :tag "CC identical to To-list." cc-list)
203 (const :tag "Followup-to identical to Newsgroups." followup-to)
204 (const :tag "Reply-to identical to From." reply-to)
205 (const :tag "Date less than four days old." date)
206 (const :tag "To and/or Cc longer than 1024 characters." long-to)
207 (const :tag "Multiple To and/or Cc headers." many-to))
208 :group 'gnus-article-hiding)
210 (defcustom gnus-article-skip-boring nil
211 "Skip over text that is not worth reading.
212 By default, if you set this t, then Gnus will display citations and
213 signatures, but will never scroll down to show you a page consisting
214 only of boring text. Boring text is controlled by
215 `gnus-article-boring-faces'."
218 :group 'gnus-article-hiding)
220 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
221 "Regexp matching signature separator.
222 This can also be a list of regexps. In that case, it will be checked
223 from head to tail looking for a separator. Searches will be done from
224 the end of the buffer."
225 :type '(repeat string)
226 :group 'gnus-article-signature)
228 (defcustom gnus-signature-limit nil
229 "Provide a limit to what is considered a signature.
230 If it is a number, no signature may not be longer (in characters) than
231 that number. If it is a floating point number, no signature may be
232 longer (in lines) than that number. If it is a function, the function
233 will be called without any parameters, and if it returns nil, there is
234 no signature in the buffer. If it is a string, it will be used as a
235 regexp. If it matches, the text in question is not a signature."
236 :type '(choice (integer :value 200)
238 (function :value fun)
239 (regexp :value ".*"))
240 :group 'gnus-article-signature)
242 (defcustom gnus-hidden-properties '(invisible t intangible t)
243 "Property list to use for hiding text."
245 :group 'gnus-article-hiding)
247 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
248 ;; frames in a session.
249 (defcustom gnus-article-x-face-command
250 (if (featurep 'xemacs)
251 (if (or (gnus-image-type-available-p 'xface)
252 (gnus-image-type-available-p 'pbm))
253 'gnus-display-x-face-in-from
254 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
255 (if (gnus-image-type-available-p 'pbm)
256 'gnus-display-x-face-in-from
257 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
259 "*String or function to be executed to display an X-Face header.
260 If it is a string, the command will be executed in a sub-shell
261 asynchronously. The compressed face will be piped to this command."
262 :type `(choice string
263 (function-item gnus-display-x-face-in-from)
267 :group 'gnus-article-washing)
269 (defcustom gnus-article-x-face-too-ugly nil
270 "Regexp matching posters whose face shouldn't be shown automatically."
271 :type '(choice regexp (const nil))
272 :group 'gnus-article-washing)
274 (defcustom gnus-article-banner-alist nil
275 "Banner alist for stripping.
277 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
279 :type '(repeat (cons symbol regexp))
280 :group 'gnus-article-washing)
282 (gnus-define-group-parameter
285 "Alist of regexps (to match group names) and banner."
286 :variable-group gnus-article-washing
288 '(choice :tag "Banner"
290 (const :tag "Remove signature" signature)
291 (symbol :tag "Item in `gnus-article-banner-alist'" none)
293 (const :tag "None" nil))
295 "If non-nil, specify how to remove `banners' from articles.
297 Symbol `signature' means to remove signatures delimited by
298 `gnus-signature-separator'. Any other symbol is used to look up a
299 regular expression to match the banner in `gnus-article-banner-alist'.
300 A string is used as a regular expression to match the banner
303 (defcustom gnus-article-address-banner-alist nil
304 "Alist of mail addresses and banners.
305 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
306 to match a mail address in the From: header, BANNER is one of a symbol
307 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
308 If ADDRESS matches author's mail address, it will remove things like
309 advertisements. For example:
311 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
315 (regexp :tag "Address")
316 (choice :tag "Banner" :value nil
317 (const :tag "Remove signature" signature)
318 (symbol :tag "Item in `gnus-article-banner-alist'" none)
320 (const :tag "None" nil))))
322 :group 'gnus-article-washing)
324 (defmacro gnus-emphasis-custom-with-format (&rest body)
326 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
327 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
330 (defun gnus-emphasis-custom-value-to-external (value)
331 (gnus-emphasis-custom-with-format
332 (if (consp (car value))
333 (list (format format (car (car value)) (cdr (car value)))
335 (if (nth 1 value) 2 3)
339 (defun gnus-emphasis-custom-value-to-internal (value)
340 (gnus-emphasis-custom-with-format
341 (let ((regexp (concat "\\`"
342 (format (regexp-quote format)
343 "\\([^()]+\\)" "\\([^()]+\\)")
346 (if (string-match regexp (setq pattern (car value)))
347 (list (cons (match-string 1 pattern) (match-string 2 pattern))
352 (defcustom gnus-emphasis-alist
354 '(("\\*" "\\*" bold nil 2)
357 ("_/" "/_" underline-italic)
358 ("_\\*" "\\*_" underline-bold)
359 ("\\*/" "/\\*" bold-italic)
360 ("_\\*/" "/\\*_" underline-bold-italic))))
362 (gnus-emphasis-custom-with-format
363 (mapcar (lambda (spec)
364 (list (format format (car spec) (cadr spec))
367 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
369 '(("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
370 2 3 gnus-emphasis-strikethru)
371 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
372 2 3 gnus-emphasis-underline))))
373 "*Alist that says how to fontify certain phrases.
374 Each item looks like this:
376 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
378 The first element is a regular expression to be matched. The second
379 is a number that says what regular expression grouping used to find
380 the entire emphasized word. The third is a number that says what
381 regexp grouping should be displayed and highlighted. The fourth
382 is the face used for highlighting."
386 :format "%[Customizing Style%]\n%v"
388 (group :tag "Default"
389 :value ("" 0 0 default)
392 (let ((value (widget-get
393 (cadr (widget-get (widget-get widget :parent)
396 (if (not (eq (nth 2 value) 'default))
400 (gnus-emphasis-custom-value-to-external value))))
401 (widget-group-value-create widget))
403 (integer :format "Match group: %v")
404 (integer :format "Emphasize group: %v")
407 :value (("_" . "_") nil default)
409 (regexp :format "Start regexp: %v")
410 (regexp :format "End regexp: %v"))
411 (boolean :format "Show start and end patterns: %[%v%]\n"
412 :on " On " :off " Off ")
414 :get (lambda (symbol)
415 (mapcar 'gnus-emphasis-custom-value-to-internal
416 (default-value symbol)))
417 :set (lambda (symbol value)
418 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
420 :group 'gnus-article-emphasis)
422 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
423 "A regexp to describe whitespace which should not be emphasized.
424 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
425 The former avoids underlining of leading and trailing whitespace,
426 and the latter avoids underlining any whitespace at all."
428 :group 'gnus-article-emphasis
431 (defface gnus-emphasis-bold '((t (:bold t)))
432 "Face used for displaying strong emphasized text (*word*)."
433 :group 'gnus-article-emphasis)
435 (defface gnus-emphasis-italic '((t (:italic t)))
436 "Face used for displaying italic emphasized text (/word/)."
437 :group 'gnus-article-emphasis)
439 (defface gnus-emphasis-underline '((t (:underline t)))
440 "Face used for displaying underlined emphasized text (_word_)."
441 :group 'gnus-article-emphasis)
443 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
444 "Face used for displaying underlined bold emphasized text (_*word*_)."
445 :group 'gnus-article-emphasis)
447 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
448 "Face used for displaying underlined italic emphasized text (_/word/_)."
449 :group 'gnus-article-emphasis)
451 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
452 "Face used for displaying bold italic emphasized text (/*word*/)."
453 :group 'gnus-article-emphasis)
455 (defface gnus-emphasis-underline-bold-italic
456 '((t (:bold t :italic t :underline t)))
457 "Face used for displaying underlined bold italic emphasized text.
458 Example: (_/*word*/_)."
459 :group 'gnus-article-emphasis)
461 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
462 '((t (:strikethru t)))
463 '((t (:strike-through t))))
464 "Face used for displaying strike-through text (-word-)."
465 :group 'gnus-article-emphasis)
467 (defface gnus-emphasis-highlight-words
468 '((t (:background "black" :foreground "yellow")))
469 "Face used for displaying highlighted words."
470 :group 'gnus-article-emphasis)
472 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
473 "Format for display of Date headers in article bodies.
474 See `format-time-string' for the possible values.
476 The variable can also be function, which should return a complete Date
477 header. The function is called with one argument, the time, which can
478 be fed to `format-time-string'."
479 :type '(choice string symbol)
480 :link '(custom-manual "(gnus)Article Date")
481 :group 'gnus-article-washing)
484 (autoload 'mail-extract-address-components "mail-extr"))
486 (defcustom gnus-save-all-headers t
487 "*If non-nil, don't remove any headers before saving."
488 :group 'gnus-article-saving
491 (defcustom gnus-prompt-before-saving 'always
492 "*This variable says how much prompting is to be done when saving articles.
493 If it is nil, no prompting will be done, and the articles will be
494 saved to the default files. If this variable is `always', each and
495 every article that is saved will be preceded by a prompt, even when
496 saving large batches of articles. If this variable is neither nil not
497 `always', there the user will be prompted once for a file name for
498 each invocation of the saving commands."
499 :group 'gnus-article-saving
500 :type '(choice (item always)
501 (item :tag "never" nil)
502 (sexp :tag "once" :format "%t\n" :value t)))
504 (defcustom gnus-saved-headers gnus-visible-headers
505 "Headers to keep if `gnus-save-all-headers' is nil.
506 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
507 If that variable is nil, however, all headers that match this regexp
508 will be kept while the rest will be deleted before saving."
509 :group 'gnus-article-saving
512 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
513 "A function to save articles in your favourite format.
514 The function must be interactively callable (in other words, it must
515 be an Emacs command).
517 Gnus provides the following functions:
519 * gnus-summary-save-in-rmail (Rmail format)
520 * gnus-summary-save-in-mail (Unix mail format)
521 * gnus-summary-save-in-folder (MH folder)
522 * gnus-summary-save-in-file (article format)
523 * gnus-summary-save-body-in-file (article body)
524 * gnus-summary-save-in-vm (use VM's folder format)
525 * gnus-summary-write-to-file (article format -- overwrite)."
526 :group 'gnus-article-saving
527 :type '(radio (function-item gnus-summary-save-in-rmail)
528 (function-item gnus-summary-save-in-mail)
529 (function-item gnus-summary-save-in-folder)
530 (function-item gnus-summary-save-in-file)
531 (function-item gnus-summary-save-body-in-file)
532 (function-item gnus-summary-save-in-vm)
533 (function-item gnus-summary-write-to-file)))
535 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
536 "A function generating a file name to save articles in Rmail format.
537 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
538 :group 'gnus-article-saving
541 (defcustom gnus-mail-save-name 'gnus-plain-save-name
542 "A function generating a file name to save articles in Unix mail format.
543 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
544 :group 'gnus-article-saving
547 (defcustom gnus-folder-save-name 'gnus-folder-save-name
548 "A function generating a file name to save articles in MH folder.
549 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
550 :group 'gnus-article-saving
553 (defcustom gnus-file-save-name 'gnus-numeric-save-name
554 "A function generating a file name to save articles in article format.
555 The function is called with NEWSGROUP, HEADERS, and optional
557 :group 'gnus-article-saving
560 (defcustom gnus-split-methods
561 '((gnus-article-archive-name)
562 (gnus-article-nndoc-name))
563 "*Variable used to suggest where articles are to be saved.
564 For instance, if you would like to save articles related to Gnus in
565 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
566 you could set this variable to something like:
568 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
569 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
571 This variable is an alist where the where the key is the match and the
572 value is a list of possible files to save in if the match is non-nil.
574 If the match is a string, it is used as a regexp match on the
575 article. If the match is a symbol, that symbol will be funcalled
576 from the buffer of the article to be saved with the newsgroup as the
577 parameter. If it is a list, it will be evaled in the same buffer.
579 If this form or function returns a string, this string will be used as
580 a possible file name; and if it returns a non-nil list, that list will
581 be used as possible file names."
582 :group 'gnus-article-saving
583 :type '(repeat (choice (list :value (fun) function)
584 (cons :value ("" "") regexp (repeat string))
587 (defcustom gnus-page-delimiter "^\^L"
588 "*Regexp describing what to use as article page delimiters.
589 The default value is \"^\^L\", which is a form linefeed at the
590 beginning of a line."
592 :group 'gnus-article-various)
594 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
595 "*The format specification for the article mode line.
596 See `gnus-summary-mode-line-format' for a closer description.
598 The following additional specs are available:
600 %w The article washing status.
601 %m The number of MIME parts in the article."
603 :group 'gnus-article-various)
605 (defcustom gnus-article-mode-hook nil
606 "*A hook for Gnus article mode."
608 :group 'gnus-article-various)
610 (when (featurep 'xemacs)
611 ;; Extracted from gnus-xmas-define in order to preserve user settings
612 (when (fboundp 'turn-off-scroll-in-place)
613 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
614 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
615 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
617 (defcustom gnus-article-menu-hook nil
618 "*Hook run after the creation of the article mode menu."
620 :group 'gnus-article-various)
622 (defcustom gnus-article-prepare-hook nil
623 "*A hook called after an article has been prepared in the article buffer."
625 :group 'gnus-article-various)
627 (make-obsolete-variable 'gnus-article-hide-pgp-hook
628 "This variable is obsolete in Gnus 5.10.")
630 (defcustom gnus-article-button-face 'bold
631 "Face used for highlighting buttons in the article buffer.
633 An article button is a piece of text that you can activate by pressing
634 `RET' or `mouse-2' above it."
636 :group 'gnus-article-buttons)
638 (defcustom gnus-article-mouse-face 'highlight
639 "Face used for mouse highlighting in the article buffer.
641 Article buttons will be displayed in this face when the cursor is
644 :group 'gnus-article-buttons)
646 (defcustom gnus-signature-face 'gnus-signature-face
647 "Face used for highlighting a signature in the article buffer.
648 Obsolete; use the face `gnus-signature-face' for customizations instead."
650 :group 'gnus-article-highlight
651 :group 'gnus-article-signature)
653 (defface gnus-signature-face
656 "Face used for highlighting a signature in the article buffer."
657 :group 'gnus-article-highlight
658 :group 'gnus-article-signature)
660 (defface gnus-header-from-face
663 (:foreground "spring green"))
666 (:foreground "red3"))
669 "Face used for displaying from headers."
670 :group 'gnus-article-headers
671 :group 'gnus-article-highlight)
673 (defface gnus-header-subject-face
676 (:foreground "SeaGreen3"))
679 (:foreground "red4"))
681 (:bold t :italic t)))
682 "Face used for displaying subject headers."
683 :group 'gnus-article-headers
684 :group 'gnus-article-highlight)
686 (defface gnus-header-newsgroups-face
689 (:foreground "yellow" :italic t))
692 (:foreground "MidnightBlue" :italic t))
695 "Face used for displaying newsgroups headers.
696 In the default setup this face is only used for crossposted
698 :group 'gnus-article-headers
699 :group 'gnus-article-highlight)
701 (defface gnus-header-name-face
704 (:foreground "SeaGreen"))
707 (:foreground "maroon"))
710 "Face used for displaying header names."
711 :group 'gnus-article-headers
712 :group 'gnus-article-highlight)
714 (defface gnus-header-content-face
717 (:foreground "forest green" :italic t))
720 (:foreground "indianred4" :italic t))
722 (:italic t))) "Face used for displaying header content."
723 :group 'gnus-article-headers
724 :group 'gnus-article-highlight)
726 (defcustom gnus-header-face-alist
727 '(("From" nil gnus-header-from-face)
728 ("Subject" nil gnus-header-subject-face)
729 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
730 ("" gnus-header-name-face gnus-header-content-face))
731 "*Controls highlighting of article headers.
733 An alist of the form (HEADER NAME CONTENT).
735 HEADER is a regular expression which should match the name of a
736 header and NAME and CONTENT are either face names or nil.
738 The name of each header field will be displayed using the face
739 specified by the first element in the list where HEADER matches
740 the header name and NAME is non-nil. Similarly, the content will
741 be displayed by the first non-nil matching CONTENT face."
742 :group 'gnus-article-headers
743 :group 'gnus-article-highlight
744 :type '(repeat (list (regexp :tag "Header")
746 (item :tag "skip" nil)
747 (face :value default))
748 (choice :tag "Content"
749 (item :tag "skip" nil)
750 (face :value default)))))
752 (defcustom gnus-article-decode-hook
753 '(article-decode-charset article-decode-encoded-words
754 article-decode-group-name article-decode-idna-rhs)
755 "*Hook run to decode charsets in articles."
756 :group 'gnus-article-headers
759 (defcustom gnus-display-mime-function 'gnus-display-mime
760 "Function to display MIME articles."
761 :group 'gnus-article-mime
764 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
765 "Function used to decode headers.")
767 (defvar gnus-article-dumbquotes-map
787 "Table for MS-to-Latin1 translation.")
789 (defcustom gnus-ignored-mime-types nil
790 "List of MIME types that should be ignored by Gnus."
792 :group 'gnus-article-mime
793 :type '(repeat regexp))
795 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
796 "List of MIME types that should not be given buttons when rendered inline.
797 See also `gnus-buttonized-mime-types' which may override this variable.
798 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
800 :group 'gnus-article-mime
801 :type '(repeat regexp))
803 (defcustom gnus-buttonized-mime-types nil
804 "List of MIME types that should be given buttons when rendered inline.
805 If set, this variable overrides `gnus-unbuttonized-mime-types'.
806 To see e.g. security buttons you could set this to
807 `(\"multipart/signed\")'.
808 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
810 :group 'gnus-article-mime
811 :type '(repeat regexp))
813 (defcustom gnus-inhibit-mime-unbuttonizing nil
814 "If non-nil, all MIME parts get buttons.
815 When nil (the default value), then some MIME parts do not get buttons,
816 as described by the variables `gnus-buttonized-mime-types' and
817 `gnus-unbuttonized-mime-types'."
821 (defcustom gnus-body-boundary-delimiter "_"
822 "String used to delimit header and body.
823 This variable is used by `gnus-article-treat-body-boundary' which can
824 be controlled by `gnus-treat-body-boundary'."
826 :group 'gnus-article-various
827 :type '(choice (item :tag "None" :value nil)
830 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
831 "Defines the location of the faces database.
832 For information on obtaining this database of pretty pictures, please
833 see http://www.cs.indiana.edu/picons/ftp/index.html"
835 :type '(repeat directory)
836 :link '(url-link :tag "download"
837 "http://www.cs.indiana.edu/picons/ftp/index.html")
838 :link '(custom-manual "(gnus)Picons")
841 (defun gnus-picons-installed-p ()
842 "Say whether picons are installed on your machine."
843 (let ((installed nil))
844 (dolist (database gnus-picon-databases)
845 (when (file-exists-p database)
849 (defcustom gnus-article-mime-part-function nil
850 "Function called with a MIME handle as the argument.
851 This is meant for people who want to do something automatic based
852 on parts -- for instance, adding Vcard info to a database."
853 :group 'gnus-article-mime
856 (defcustom gnus-mime-multipart-functions nil
857 "An alist of MIME types to functions to display them."
859 :group 'gnus-article-mime
862 (defcustom gnus-article-date-lapsed-new-header nil
863 "Whether the X-Sent and Date headers can coexist.
864 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
865 either replace the old \"Date:\" header (if this variable is nil), or
866 be added below it (otherwise)."
868 :group 'gnus-article-headers
871 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
872 "Function called with a MIME handle as the argument.
873 This is meant for people who want to view first matched part.
874 For `undisplayed-alternative' (default), the first undisplayed
875 part or alternative part is used. For `undisplayed', the first
876 undisplayed part is used. For a function, the first part which
877 the function return t is used. For nil, the first part is
880 :group 'gnus-article-mime
882 (item :tag "first" :value nil)
883 (item :tag "undisplayed" :value undisplayed)
884 (item :tag "undisplayed or alternative"
885 :value undisplayed-alternative)
888 (defcustom gnus-mime-action-alist
889 '(("save to file" . gnus-mime-save-part)
890 ("save and strip" . gnus-mime-save-part-and-strip)
891 ("delete part" . gnus-mime-delete-part)
892 ("display as text" . gnus-mime-inline-part)
893 ("view the part" . gnus-mime-view-part)
894 ("pipe to command" . gnus-mime-pipe-part)
895 ("toggle display" . gnus-article-press-button)
896 ("toggle display" . gnus-article-view-part-as-charset)
897 ("view as type" . gnus-mime-view-part-as-type)
898 ("view internally" . gnus-mime-view-part-internally)
899 ("view externally" . gnus-mime-view-part-externally))
900 "An alist of actions that run on the MIME attachment."
901 :group 'gnus-article-mime
902 :type '(repeat (cons (string :tag "name")
906 ;;; The treatment variables
909 (defvar gnus-part-display-hook nil
910 "Hook called on parts that are to receive treatment.")
912 (defvar gnus-article-treat-custom
913 '(choice (const :tag "Off" nil)
915 (const :tag "Header" head)
916 (const :tag "Last" last)
917 (integer :tag "Less")
918 (repeat :tag "Groups" regexp)
919 (sexp :tag "Predicate")))
921 (defvar gnus-article-treat-head-custom
922 '(choice (const :tag "Off" nil)
923 (const :tag "Header" head)))
925 (defvar gnus-article-treat-types '("text/plain")
928 (defvar gnus-inhibit-treatment nil
929 "Whether to inhibit treatment.")
931 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
932 "Highlight the signature.
933 Valid values are nil, t, `head', `last', an integer or a predicate.
934 See Info node `(gnus)Customizing Articles'."
935 :group 'gnus-article-treat
936 :link '(custom-manual "(gnus)Customizing Articles")
937 :type gnus-article-treat-custom)
938 (put 'gnus-treat-highlight-signature 'highlight t)
940 (defcustom gnus-treat-buttonize 100000
942 Valid values are nil, t, `head', `last', an integer or a predicate.
943 See Info node `(gnus)Customizing Articles'."
944 :group 'gnus-article-treat
945 :link '(custom-manual "(gnus)Customizing Articles")
946 :type gnus-article-treat-custom)
947 (put 'gnus-treat-buttonize 'highlight t)
949 (defcustom gnus-treat-buttonize-head 'head
950 "Add buttons to the head.
951 Valid values are nil, t, `head', `last', an integer or a predicate.
952 See Info node `(gnus)Customizing Articles' for details."
953 :group 'gnus-article-treat
954 :link '(custom-manual "(gnus)Customizing Articles")
955 :type gnus-article-treat-head-custom)
956 (put 'gnus-treat-buttonize-head 'highlight t)
958 (defcustom gnus-treat-emphasize
959 (and (or window-system
961 (>= (string-to-number emacs-version) 21))
964 Valid values are nil, t, `head', `last', an integer or a predicate.
965 See Info node `(gnus)Customizing Articles' for details."
966 :group 'gnus-article-treat
967 :link '(custom-manual "(gnus)Customizing Articles")
968 :type gnus-article-treat-custom)
969 (put 'gnus-treat-emphasize 'highlight t)
971 (defcustom gnus-treat-strip-cr nil
972 "Remove carriage returns.
973 Valid values are nil, t, `head', `last', an integer or a predicate.
974 See Info node `(gnus)Customizing Articles' for details."
976 :group 'gnus-article-treat
977 :link '(custom-manual "(gnus)Customizing Articles")
978 :type gnus-article-treat-custom)
980 (defcustom gnus-treat-unsplit-urls nil
981 "Remove newlines from within URLs.
982 Valid values are nil, t, `head', `last', an integer or a predicate.
983 See Info node `(gnus)Customizing Articles' for details."
985 :group 'gnus-article-treat
986 :link '(custom-manual "(gnus)Customizing Articles")
987 :type gnus-article-treat-custom)
989 (defcustom gnus-treat-leading-whitespace nil
990 "Remove leading whitespace in headers.
991 Valid values are nil, t, `head', `last', an integer or a predicate.
992 See Info node `(gnus)Customizing Articles' for details."
994 :group 'gnus-article-treat
995 :link '(custom-manual "(gnus)Customizing Articles")
996 :type gnus-article-treat-custom)
998 (defcustom gnus-treat-hide-headers 'head
1000 Valid values are nil, t, `head', `last', an integer or a predicate.
1001 See Info node `(gnus)Customizing Articles' for details."
1002 :group 'gnus-article-treat
1003 :link '(custom-manual "(gnus)Customizing Articles")
1004 :type gnus-article-treat-head-custom)
1006 (defcustom gnus-treat-hide-boring-headers nil
1007 "Hide boring headers.
1008 Valid values are nil, t, `head', `last', an integer or a predicate.
1009 See Info node `(gnus)Customizing Articles' for details."
1010 :group 'gnus-article-treat
1011 :link '(custom-manual "(gnus)Customizing Articles")
1012 :type gnus-article-treat-head-custom)
1014 (defcustom gnus-treat-hide-signature nil
1015 "Hide the signature.
1016 Valid values are nil, t, `head', `last', an integer or a predicate.
1017 See Info node `(gnus)Customizing Articles' for details."
1018 :group 'gnus-article-treat
1019 :link '(custom-manual "(gnus)Customizing Articles")
1020 :type gnus-article-treat-custom)
1022 (defcustom gnus-treat-fill-article nil
1024 Valid values are nil, t, `head', `last', an integer or a predicate.
1025 See Info node `(gnus)Customizing Articles' for details."
1026 :group 'gnus-article-treat
1027 :link '(custom-manual "(gnus)Customizing Articles")
1028 :type gnus-article-treat-custom)
1030 (defcustom gnus-treat-hide-citation nil
1032 Valid values are nil, t, `head', `last', an integer or a predicate.
1033 See Info node `(gnus)Customizing Articles' for details."
1034 :group 'gnus-article-treat
1035 :link '(custom-manual "(gnus)Customizing Articles")
1036 :type gnus-article-treat-custom)
1038 (defcustom gnus-treat-hide-citation-maybe nil
1040 Valid values are nil, t, `head', `last', an integer or a predicate.
1041 See Info node `(gnus)Customizing Articles' for details."
1042 :group 'gnus-article-treat
1043 :link '(custom-manual "(gnus)Customizing Articles")
1044 :type gnus-article-treat-custom)
1046 (defcustom gnus-treat-strip-list-identifiers 'head
1047 "Strip list identifiers from `gnus-list-identifiers`.
1048 Valid values are nil, t, `head', `last', an integer or a predicate.
1049 See Info node `(gnus)Customizing Articles' for details."
1051 :group 'gnus-article-treat
1052 :link '(custom-manual "(gnus)Customizing Articles")
1053 :type gnus-article-treat-custom)
1055 (make-obsolete-variable 'gnus-treat-strip-pgp
1056 "This option is obsolete in Gnus 5.10.")
1058 (defcustom gnus-treat-strip-pem nil
1059 "Strip PEM signatures.
1060 Valid values are nil, t, `head', `last', an integer or a predicate.
1061 See Info node `(gnus)Customizing Articles' for details."
1062 :group 'gnus-article-treat
1063 :link '(custom-manual "(gnus)Customizing Articles")
1064 :type gnus-article-treat-custom)
1066 (defcustom gnus-treat-strip-banner t
1067 "Strip banners from articles.
1068 The banner to be stripped is specified in the `banner' group parameter.
1069 Valid values are nil, t, `head', `last', an integer or a predicate.
1070 See Info node `(gnus)Customizing Articles' for details."
1071 :group 'gnus-article-treat
1072 :link '(custom-manual "(gnus)Customizing Articles")
1073 :type gnus-article-treat-custom)
1075 (defcustom gnus-treat-highlight-headers 'head
1076 "Highlight the headers.
1077 Valid values are nil, t, `head', `last', an integer or a predicate.
1078 See Info node `(gnus)Customizing Articles' for details."
1079 :group 'gnus-article-treat
1080 :link '(custom-manual "(gnus)Customizing Articles")
1081 :type gnus-article-treat-head-custom)
1082 (put 'gnus-treat-highlight-headers 'highlight t)
1084 (defcustom gnus-treat-highlight-citation t
1085 "Highlight cited text.
1086 Valid values are nil, t, `head', `last', an integer or a predicate.
1087 See Info node `(gnus)Customizing Articles' for details."
1088 :group 'gnus-article-treat
1089 :link '(custom-manual "(gnus)Customizing Articles")
1090 :type gnus-article-treat-custom)
1091 (put 'gnus-treat-highlight-citation 'highlight t)
1093 (defcustom gnus-treat-date-ut nil
1094 "Display the Date in UT (GMT).
1095 Valid values are nil, t, `head', `last', an integer or a predicate.
1096 See Info node `(gnus)Customizing Articles' for details."
1097 :group 'gnus-article-treat
1098 :link '(custom-manual "(gnus)Customizing Articles")
1099 :type gnus-article-treat-head-custom)
1101 (defcustom gnus-treat-date-local nil
1102 "Display the Date in the local timezone.
1103 Valid values are nil, t, `head', `last', an integer or a predicate.
1104 See Info node `(gnus)Customizing Articles' for details."
1105 :group 'gnus-article-treat
1106 :link '(custom-manual "(gnus)Customizing Articles")
1107 :type gnus-article-treat-head-custom)
1109 (defcustom gnus-treat-date-english nil
1110 "Display the Date in a format that can be read aloud in English.
1111 Valid values are nil, t, `head', `last', an integer or a predicate.
1112 See Info node `(gnus)Customizing Articles' for details."
1114 :group 'gnus-article-treat
1115 :link '(custom-manual "(gnus)Customizing Articles")
1116 :type gnus-article-treat-head-custom)
1118 (defcustom gnus-treat-date-lapsed nil
1119 "Display the Date header in a way that says how much time has elapsed.
1120 Valid values are nil, t, `head', `last', an integer or a predicate.
1121 See Info node `(gnus)Customizing Articles' for details."
1122 :group 'gnus-article-treat
1123 :link '(custom-manual "(gnus)Customizing Articles")
1124 :type gnus-article-treat-head-custom)
1126 (defcustom gnus-treat-date-original nil
1127 "Display the date in the original timezone.
1128 Valid values are nil, t, `head', `last', an integer or a predicate.
1129 See Info node `(gnus)Customizing Articles' for details."
1130 :group 'gnus-article-treat
1131 :link '(custom-manual "(gnus)Customizing Articles")
1132 :type gnus-article-treat-head-custom)
1134 (defcustom gnus-treat-date-iso8601 nil
1135 "Display the date in the ISO8601 format.
1136 Valid values are nil, t, `head', `last', an integer or a predicate.
1137 See Info node `(gnus)Customizing Articles' for details."
1139 :group 'gnus-article-treat
1140 :link '(custom-manual "(gnus)Customizing Articles")
1141 :type gnus-article-treat-head-custom)
1143 (defcustom gnus-treat-date-user-defined nil
1144 "Display the date in a user-defined format.
1145 The format is defined by the `gnus-article-time-format' variable.
1146 Valid values are nil, t, `head', `last', an integer or a predicate.
1147 See Info node `(gnus)Customizing Articles' for details."
1148 :group 'gnus-article-treat
1149 :link '(custom-manual "(gnus)Customizing Articles")
1150 :type gnus-article-treat-head-custom)
1152 (defcustom gnus-treat-strip-headers-in-body t
1153 "Strip the X-No-Archive header line from the beginning of the body.
1154 Valid values are nil, t, `head', `last', an integer or a predicate.
1155 See Info node `(gnus)Customizing Articles' for details."
1157 :group 'gnus-article-treat
1158 :link '(custom-manual "(gnus)Customizing Articles")
1159 :type gnus-article-treat-custom)
1161 (defcustom gnus-treat-strip-trailing-blank-lines nil
1162 "Strip trailing blank lines.
1163 Valid values are nil, t, `head', `last', an integer or a predicate.
1164 See Info node `(gnus)Customizing Articles' for details."
1165 :group 'gnus-article-treat
1166 :link '(custom-manual "(gnus)Customizing Articles")
1167 :type gnus-article-treat-custom)
1169 (defcustom gnus-treat-strip-leading-blank-lines nil
1170 "Strip leading blank lines.
1171 Valid values are nil, t, `head', `last', an integer or a predicate.
1172 See Info node `(gnus)Customizing Articles' for details."
1173 :group 'gnus-article-treat
1174 :link '(custom-manual "(gnus)Customizing Articles")
1175 :type gnus-article-treat-custom)
1177 (defcustom gnus-treat-strip-multiple-blank-lines nil
1178 "Strip multiple blank lines.
1179 Valid values are nil, t, `head', `last', an integer or a predicate.
1180 See Info node `(gnus)Customizing Articles' for details."
1181 :group 'gnus-article-treat
1182 :link '(custom-manual "(gnus)Customizing Articles")
1183 :type gnus-article-treat-custom)
1185 (defcustom gnus-treat-unfold-headers 'head
1186 "Unfold folded header lines.
1187 Valid values are nil, t, `head', `last', an integer or a predicate.
1188 See Info node `(gnus)Customizing Articles' for details."
1190 :group 'gnus-article-treat
1191 :link '(custom-manual "(gnus)Customizing Articles")
1192 :type gnus-article-treat-custom)
1194 (defcustom gnus-treat-fold-headers nil
1196 Valid values are nil, t, `head', `last', an integer or a predicate.
1197 See Info node `(gnus)Customizing Articles' for details."
1199 :group 'gnus-article-treat
1200 :link '(custom-manual "(gnus)Customizing Articles")
1201 :type gnus-article-treat-custom)
1203 (defcustom gnus-treat-fold-newsgroups 'head
1204 "Fold the Newsgroups and Followup-To headers.
1205 Valid values are nil, t, `head', `last', an integer or a predicate.
1206 See Info node `(gnus)Customizing Articles' for details."
1208 :group 'gnus-article-treat
1209 :link '(custom-manual "(gnus)Customizing Articles")
1210 :type gnus-article-treat-custom)
1212 (defcustom gnus-treat-overstrike t
1213 "Treat overstrike highlighting.
1214 Valid values are nil, t, `head', `last', an integer or a predicate.
1215 See Info node `(gnus)Customizing Articles' for details."
1216 :group 'gnus-article-treat
1217 :link '(custom-manual "(gnus)Customizing Articles")
1218 :type gnus-article-treat-custom)
1219 (put 'gnus-treat-overstrike 'highlight t)
1221 (make-obsolete-variable 'gnus-treat-display-xface
1222 'gnus-treat-display-x-face)
1224 (defcustom gnus-treat-display-x-face
1225 (and (not noninteractive)
1226 (or (and (fboundp 'image-type-available-p)
1227 (image-type-available-p 'xbm)
1228 (string-match "^0x" (shell-command-to-string "uncompface"))
1229 (executable-find "icontopbm"))
1230 (and (featurep 'xemacs)
1233 "Display X-Face headers.
1234 Valid values are nil, t, `head', `last', an integer or a predicate.
1235 See Info node `(gnus)Customizing Articles' and Info node
1236 `(gnus)X-Face' for details."
1237 :group 'gnus-article-treat
1239 :link '(custom-manual "(gnus)Customizing Articles")
1240 :link '(custom-manual "(gnus)X-Face")
1241 :type gnus-article-treat-head-custom
1242 :set (lambda (symbol value)
1245 (cond ((or (boundp symbol) (get symbol 'saved-value))
1247 ((boundp 'gnus-treat-display-xface)
1249 ** gnus-treat-display-xface is an obsolete variable;\
1250 use gnus-treat-display-x-face instead")
1251 (default-value 'gnus-treat-display-xface))
1252 ((get 'gnus-treat-display-xface 'saved-value)
1254 ** gnus-treat-display-xface is an obsolete variable;\
1255 use gnus-treat-display-x-face instead")
1256 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1259 (put 'gnus-treat-display-x-face 'highlight t)
1261 (defcustom gnus-treat-display-face
1262 (and (not noninteractive)
1263 (or (and (fboundp 'image-type-available-p)
1264 (image-type-available-p 'png))
1265 (and (featurep 'xemacs)
1268 "Display Face headers.
1269 Valid values are nil, t, `head', `last', an integer or a predicate.
1270 See Info node `(gnus)Customizing Articles' and Info node
1271 `(gnus)X-Face' for details."
1272 :group 'gnus-article-treat
1274 :link '(custom-manual "(gnus)Customizing Articles")
1275 :link '(custom-manual "(gnus)X-Face")
1276 :type gnus-article-treat-head-custom)
1277 (put 'gnus-treat-display-face 'highlight t)
1279 (defcustom gnus-treat-display-smileys
1280 (if (or (and (featurep 'xemacs)
1282 (and (fboundp 'image-type-available-p)
1283 (image-type-available-p 'pbm)))
1286 Valid values are nil, t, `head', `last', an integer or a predicate.
1287 See Info node `(gnus)Customizing Articles' and Info node
1288 `(gnus)Smileys' for details."
1289 :group 'gnus-article-treat
1291 :link '(custom-manual "(gnus)Customizing Articles")
1292 :link '(custom-manual "(gnus)Smileys")
1293 :type gnus-article-treat-custom)
1294 (put 'gnus-treat-display-smileys 'highlight t)
1296 (defcustom gnus-treat-from-picon
1297 (if (and (gnus-image-type-available-p 'xpm)
1298 (gnus-picons-installed-p))
1300 "Display picons in the From header.
1301 Valid values are nil, t, `head', `last', an integer or a predicate.
1302 See Info node `(gnus)Customizing Articles' and Info node
1303 `(gnus)Picons' for details."
1305 :group 'gnus-article-treat
1307 :link '(custom-manual "(gnus)Customizing Articles")
1308 :link '(custom-manual "(gnus)Picons")
1309 :type gnus-article-treat-head-custom)
1310 (put 'gnus-treat-from-picon 'highlight t)
1312 (defcustom gnus-treat-mail-picon
1313 (if (and (gnus-image-type-available-p 'xpm)
1314 (gnus-picons-installed-p))
1316 "Display picons in To and Cc headers.
1317 Valid values are nil, t, `head', `last', an integer or a predicate.
1318 See Info node `(gnus)Customizing Articles' and Info node
1319 `(gnus)Picons' for details."
1321 :group 'gnus-article-treat
1323 :link '(custom-manual "(gnus)Customizing Articles")
1324 :link '(custom-manual "(gnus)Picons")
1325 :type gnus-article-treat-head-custom)
1326 (put 'gnus-treat-mail-picon 'highlight t)
1328 (defcustom gnus-treat-newsgroups-picon
1329 (if (and (gnus-image-type-available-p 'xpm)
1330 (gnus-picons-installed-p))
1332 "Display picons in the Newsgroups and Followup-To headers.
1333 Valid values are nil, t, `head', `last', an integer or a predicate.
1334 See Info node `(gnus)Customizing Articles' and Info node
1335 `(gnus)Picons' for details."
1337 :group 'gnus-article-treat
1339 :link '(custom-manual "(gnus)Customizing Articles")
1340 :link '(custom-manual "(gnus)Picons")
1341 :type gnus-article-treat-head-custom)
1342 (put 'gnus-treat-newsgroups-picon 'highlight t)
1344 (defcustom gnus-treat-body-boundary
1345 (if (or gnus-treat-newsgroups-picon
1346 gnus-treat-mail-picon
1347 gnus-treat-from-picon)
1349 "Draw a boundary at the end of the headers.
1350 Valid values are nil and `head'.
1351 See Info node `(gnus)Customizing Articles' for details."
1353 :group 'gnus-article-treat
1354 :link '(custom-manual "(gnus)Customizing Articles")
1355 :type gnus-article-treat-head-custom)
1357 (defcustom gnus-treat-capitalize-sentences nil
1358 "Capitalize sentence-starting words.
1359 Valid values are nil, t, `head', `last', an integer or a predicate.
1360 See Info node `(gnus)Customizing Articles' for details."
1362 :group 'gnus-article-treat
1363 :link '(custom-manual "(gnus)Customizing Articles")
1364 :type gnus-article-treat-custom)
1366 (defcustom gnus-treat-wash-html nil
1368 Valid values are nil, t, `head', `last', an integer or a predicate.
1369 See Info node `(gnus)Customizing Articles' for details."
1371 :group 'gnus-article-treat
1372 :link '(custom-manual "(gnus)Customizing Articles")
1373 :type gnus-article-treat-custom)
1375 (defcustom gnus-treat-fill-long-lines nil
1377 Valid values are nil, t, `head', `last', an integer or a predicate.
1378 See Info node `(gnus)Customizing Articles' for details."
1379 :group 'gnus-article-treat
1380 :link '(custom-manual "(gnus)Customizing Articles")
1381 :type gnus-article-treat-custom)
1383 (defcustom gnus-treat-play-sounds nil
1385 Valid values are nil, t, `head', `last', an integer or a predicate.
1386 See Info node `(gnus)Customizing Articles' for details."
1388 :group 'gnus-article-treat
1389 :link '(custom-manual "(gnus)Customizing Articles")
1390 :type gnus-article-treat-custom)
1392 (defcustom gnus-treat-translate nil
1393 "Translate articles from one language to another.
1394 Valid values are nil, t, `head', `last', an integer or a predicate.
1395 See Info node `(gnus)Customizing Articles' for details."
1397 :group 'gnus-article-treat
1398 :link '(custom-manual "(gnus)Customizing Articles")
1399 :type gnus-article-treat-custom)
1401 (defcustom gnus-treat-x-pgp-sig nil
1403 To automatically treat X-PGP-Sig, set it to head.
1404 Valid values are nil, t, `head', `last', an integer or a predicate.
1405 See Info node `(gnus)Customizing Articles' for details."
1407 :group 'gnus-article-treat
1408 :group 'mime-security
1409 :link '(custom-manual "(gnus)Customizing Articles")
1410 :type gnus-article-treat-custom)
1412 (defvar gnus-article-encrypt-protocol-alist
1413 '(("PGP" . mml2015-self-encrypt)))
1415 ;; Set to nil if more than one protocol added to
1416 ;; gnus-article-encrypt-protocol-alist.
1417 (defcustom gnus-article-encrypt-protocol "PGP"
1418 "The protocol used for encrypt articles.
1419 It is a string, such as \"PGP\". If nil, ask user."
1422 :group 'mime-security)
1424 (defvar gnus-article-wash-function nil
1425 "Function used for converting HTML into text.")
1427 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1428 (mm-coding-system-p 'utf-8)
1429 (executable-find idna-program))
1430 "Whether IDNA decoding of headers is used when viewing messages.
1431 This requires GNU Libidn, and by default only enabled if it is found."
1433 :group 'gnus-article-headers
1436 (defcustom gnus-article-over-scroll nil
1437 "If non-nil, allow scrolling the article buffer even when there no more text."
1439 :group 'gnus-article
1442 ;;; Internal variables
1444 (defvar gnus-english-month-names
1445 '("January" "February" "March" "April" "May" "June" "July" "August"
1446 "September" "October" "November" "December"))
1448 (defvar article-goto-body-goes-to-point-min-p nil)
1449 (defvar gnus-article-wash-types nil)
1450 (defvar gnus-article-emphasis-alist nil)
1451 (defvar gnus-article-image-alist nil)
1453 (defvar gnus-article-mime-handle-alist-1 nil)
1454 (defvar gnus-treatment-function-alist
1455 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1456 (gnus-treat-strip-banner gnus-article-strip-banner)
1457 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1458 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1459 (gnus-treat-buttonize gnus-article-add-buttons)
1460 (gnus-treat-fill-article gnus-article-fill-cited-article)
1461 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1462 (gnus-treat-strip-cr gnus-article-remove-cr)
1463 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1464 (gnus-treat-date-ut gnus-article-date-ut)
1465 (gnus-treat-date-local gnus-article-date-local)
1466 (gnus-treat-date-english gnus-article-date-english)
1467 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1468 (gnus-treat-date-original gnus-article-date-original)
1469 (gnus-treat-date-user-defined gnus-article-date-user)
1470 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1471 (gnus-treat-display-x-face gnus-article-display-x-face)
1472 (gnus-treat-display-face gnus-article-display-face)
1473 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1474 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1475 (gnus-treat-hide-signature gnus-article-hide-signature)
1476 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1477 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1478 (gnus-treat-strip-pem gnus-article-hide-pem)
1479 (gnus-treat-from-picon gnus-treat-from-picon)
1480 (gnus-treat-mail-picon gnus-treat-mail-picon)
1481 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1482 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1483 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1484 (gnus-treat-strip-trailing-blank-lines
1485 gnus-article-remove-trailing-blank-lines)
1486 (gnus-treat-strip-leading-blank-lines
1487 gnus-article-strip-leading-blank-lines)
1488 (gnus-treat-strip-multiple-blank-lines
1489 gnus-article-strip-multiple-blank-lines)
1490 (gnus-treat-overstrike gnus-article-treat-overstrike)
1491 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1492 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1493 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1494 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1495 (gnus-treat-display-smileys gnus-treat-smiley)
1496 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1497 (gnus-treat-wash-html gnus-article-wash-html)
1498 (gnus-treat-emphasize gnus-article-emphasize)
1499 (gnus-treat-hide-citation gnus-article-hide-citation)
1500 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1501 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1502 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1503 (gnus-treat-play-sounds gnus-earcon-display)))
1505 (defvar gnus-article-mime-handle-alist nil)
1506 (defvar article-lapsed-timer nil)
1507 (defvar gnus-article-current-summary nil)
1509 (defvar gnus-article-mode-syntax-table
1510 (let ((table (copy-syntax-table text-mode-syntax-table)))
1511 ;; This causes the citation match run O(2^n).
1512 ;; (modify-syntax-entry ?- "w" table)
1513 (modify-syntax-entry ?> ")<" table)
1514 (modify-syntax-entry ?< "(>" table)
1515 ;; make M-. in article buffers work for `foo' strings
1516 (modify-syntax-entry ?' " " table)
1517 (modify-syntax-entry ?` " " table)
1519 "Syntax table used in article mode buffers.
1520 Initialized from `text-mode-syntax-table.")
1522 (defvar gnus-save-article-buffer nil)
1524 (defvar gnus-article-mode-line-format-alist
1525 (nconc '((?w (gnus-article-wash-status) ?s)
1526 (?m (gnus-article-mime-part-status) ?s))
1527 gnus-summary-mode-line-format-alist))
1529 (defvar gnus-number-of-articles-to-be-saved nil)
1531 (defvar gnus-inhibit-hiding nil)
1533 (defvar gnus-article-edit-mode nil)
1535 ;;; Macros for dealing with the article buffer.
1537 (defmacro gnus-with-article-headers (&rest forms)
1539 (set-buffer gnus-article-buffer)
1541 (let ((inhibit-read-only t)
1542 (inhibit-point-motion-hooks t)
1543 (case-fold-search t))
1544 (article-narrow-to-head)
1547 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1548 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1550 (defmacro gnus-with-article-buffer (&rest forms)
1552 (set-buffer gnus-article-buffer)
1553 (let ((inhibit-read-only t))
1556 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1557 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1559 (defun gnus-article-goto-header (header)
1560 "Go to HEADER, which is a regular expression."
1561 (re-search-forward (concat "^\\(" header "\\):") nil t))
1563 (defsubst gnus-article-hide-text (b e props)
1564 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1565 (gnus-add-text-properties-when 'article-type nil b e props)
1566 (when (memq 'intangible props)
1568 (max (1- b) (point-min))
1569 b 'intangible (cddr (memq 'intangible props)))))
1571 (defsubst gnus-article-unhide-text (b e)
1572 "Remove hidden text properties from region between B and E."
1573 (remove-text-properties b e gnus-hidden-properties)
1574 (when (memq 'intangible gnus-hidden-properties)
1575 (put-text-property (max (1- b) (point-min))
1576 b 'intangible nil)))
1578 (defun gnus-article-hide-text-type (b e type)
1579 "Hide text of TYPE between B and E."
1580 (gnus-add-wash-type type)
1581 (gnus-article-hide-text
1582 b e (cons 'article-type (cons type gnus-hidden-properties))))
1584 (defun gnus-article-unhide-text-type (b e type)
1585 "Unhide text of TYPE between B and E."
1586 (gnus-delete-wash-type type)
1587 (remove-text-properties
1588 b e (cons 'article-type (cons type gnus-hidden-properties)))
1589 (when (memq 'intangible gnus-hidden-properties)
1590 (put-text-property (max (1- b) (point-min))
1591 b 'intangible nil)))
1593 (defun gnus-article-hide-text-of-type (type)
1594 "Hide text of TYPE in the current buffer."
1596 (let ((b (point-min))
1598 (while (setq b (text-property-any b e 'article-type type))
1599 (add-text-properties b (incf b) gnus-hidden-properties)))))
1601 (defun gnus-article-delete-text-of-type (type)
1602 "Delete text of TYPE in the current buffer."
1604 (let ((b (point-min)))
1605 (while (setq b (text-property-any b (point-max) 'article-type type))
1607 b (or (text-property-not-all b (point-max) 'article-type type)
1610 (defun gnus-article-delete-invisible-text ()
1611 "Delete all invisible text in the current buffer."
1613 (let ((b (point-min)))
1614 (while (setq b (text-property-any b (point-max) 'invisible t))
1616 b (or (text-property-not-all b (point-max) 'invisible t)
1619 (defun gnus-article-text-type-exists-p (type)
1620 "Say whether any text of type TYPE exists in the buffer."
1621 (text-property-any (point-min) (point-max) 'article-type type))
1623 (defsubst gnus-article-header-rank ()
1624 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1625 (let ((list gnus-sorted-header-list)
1628 (if (looking-at (car list))
1630 (setq list (cdr list))
1634 (defun article-hide-headers (&optional arg delete)
1635 "Hide unwanted headers and possibly sort them as well."
1637 ;; This function might be inhibited.
1638 (unless gnus-inhibit-hiding
1639 (let ((inhibit-read-only nil)
1640 (case-fold-search t)
1641 (max (1+ (length gnus-sorted-header-list)))
1642 (inhibit-point-motion-hooks t)
1643 (cur (current-buffer))
1644 ignored visible beg)
1646 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1647 ;; group parameters, so we should go to the summary buffer.
1650 (progn (set-buffer gnus-summary-buffer) t)
1652 (setq ignored (when (not gnus-visible-headers)
1653 (cond ((stringp gnus-ignored-headers)
1654 gnus-ignored-headers)
1655 ((listp gnus-ignored-headers)
1656 (mapconcat 'identity
1657 gnus-ignored-headers
1659 visible (cond ((stringp gnus-visible-headers)
1660 gnus-visible-headers)
1661 ((and gnus-visible-headers
1662 (listp gnus-visible-headers))
1663 (mapconcat 'identity
1664 gnus-visible-headers
1668 ;; First we narrow to just the headers.
1669 (article-narrow-to-head)
1670 ;; Hide any "From " lines at the beginning of (mail) articles.
1671 (while (looking-at "From ")
1674 (delete-region (point-min) (point)))
1675 ;; Then treat the rest of the header lines.
1676 ;; Then we use the two regular expressions
1677 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1678 ;; select which header lines is to remain visible in the
1680 (while (re-search-forward "^[^ \t:]*:" nil t)
1682 ;; Mark the rank of the header.
1684 (point) (1+ (point)) 'message-rank
1685 (if (or (and visible (looking-at visible))
1687 (not (looking-at ignored))))
1688 (gnus-article-header-rank)
1691 (message-sort-headers-1)
1692 (when (setq beg (text-property-any
1693 (point-min) (point-max) 'message-rank (+ 2 max)))
1694 ;; We delete the unwanted headers.
1695 (gnus-add-wash-type 'headers)
1696 (add-text-properties (point-min) (+ 5 (point-min))
1697 '(article-type headers dummy-invisible t))
1698 (delete-region beg (point-max))))))))
1700 (defun article-hide-boring-headers (&optional arg)
1701 "Toggle hiding of headers that aren't very interesting.
1702 If given a negative prefix, always show; if given a positive prefix,
1704 (interactive (gnus-article-hidden-arg))
1705 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1706 (not gnus-show-all-headers))
1709 (let ((inhibit-read-only t)
1710 (list gnus-boring-article-headers)
1711 (inhibit-point-motion-hooks t)
1713 (article-narrow-to-head)
1715 (setq elem (pop list))
1716 (goto-char (point-min))
1718 ;; Hide empty headers.
1720 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1722 (gnus-article-hide-text-type
1726 (if (re-search-forward "^[^ \t]" nil t)
1730 ;; Hide boring Newsgroups header.
1731 ((eq elem 'newsgroups)
1732 (when (gnus-string-equal
1733 (gnus-fetch-field "newsgroups")
1734 (gnus-group-real-name
1735 (if (boundp 'gnus-newsgroup-name)
1738 (gnus-article-hide-header "newsgroups")))
1739 ((eq elem 'to-address)
1740 (let ((to (message-fetch-field "to"))
1742 (gnus-parameter-to-address
1743 (if (boundp 'gnus-newsgroup-name)
1744 gnus-newsgroup-name ""))))
1745 (when (and to to-address
1748 ;; only one address in To
1749 (nth 1 (mail-extract-address-components to))
1751 (gnus-article-hide-header "to"))))
1753 (let ((to (message-fetch-field "to"))
1755 (gnus-parameter-to-list
1756 (if (boundp 'gnus-newsgroup-name)
1757 gnus-newsgroup-name ""))))
1758 (when (and to to-list
1761 ;; only one address in To
1762 (nth 1 (mail-extract-address-components to))
1764 (gnus-article-hide-header "to"))))
1766 (let ((cc (message-fetch-field "cc"))
1768 (gnus-parameter-to-list
1769 (if (boundp 'gnus-newsgroup-name)
1770 gnus-newsgroup-name ""))))
1771 (when (and cc to-list
1774 ;; only one address in CC
1775 (nth 1 (mail-extract-address-components cc))
1777 (gnus-article-hide-header "cc"))))
1778 ((eq elem 'followup-to)
1779 (when (gnus-string-equal
1780 (message-fetch-field "followup-to")
1781 (message-fetch-field "newsgroups"))
1782 (gnus-article-hide-header "followup-to")))
1783 ((eq elem 'reply-to)
1784 (if (gnus-group-find-parameter
1785 gnus-newsgroup-name 'broken-reply-to)
1786 (gnus-article-hide-header "reply-to")
1787 (let ((from (message-fetch-field "from"))
1788 (reply-to (message-fetch-field "reply-to")))
1795 (lambda (x) (downcase (cadr x)))
1796 (mail-extract-address-components from t))
1799 (lambda (x) (downcase (cadr x)))
1800 (mail-extract-address-components reply-to t))
1802 (gnus-article-hide-header "reply-to")))))
1804 (let ((date (message-fetch-field "date")))
1806 (< (days-between (current-time-string) date)
1808 (gnus-article-hide-header "date"))))
1810 (let ((to (message-fetch-field "to"))
1811 (cc (message-fetch-field "cc")))
1812 (when (> (length to) 1024)
1813 (gnus-article-hide-header "to"))
1814 (when (> (length cc) 1024)
1815 (gnus-article-hide-header "cc"))))
1819 (goto-char (point-min))
1820 (while (re-search-forward "^to:" nil t)
1821 (setq to-count (1+ to-count)))
1822 (when (> to-count 1)
1823 (while (> to-count 0)
1824 (goto-char (point-min))
1826 (re-search-forward "^to:" nil nil to-count)
1828 (narrow-to-region (point) (point-max))
1829 (gnus-article-hide-header "to"))
1830 (setq to-count (1- to-count))))
1831 (goto-char (point-min))
1832 (while (re-search-forward "^cc:" nil t)
1833 (setq cc-count (1+ cc-count)))
1834 (when (> cc-count 1)
1835 (while (> cc-count 0)
1836 (goto-char (point-min))
1838 (re-search-forward "^cc:" nil nil cc-count)
1840 (narrow-to-region (point) (point-max))
1841 (gnus-article-hide-header "cc"))
1842 (setq cc-count (1- cc-count)))))))))))))
1844 (defun gnus-article-hide-header (header)
1846 (goto-char (point-min))
1847 (when (re-search-forward (concat "^" header ":") nil t)
1848 (gnus-article-hide-text-type
1852 (if (re-search-forward "^[^ \t]" nil t)
1857 (defvar gnus-article-normalized-header-length 40
1858 "Length of normalized headers.")
1860 (defun article-normalize-headers ()
1861 "Make all header lines 40 characters long."
1863 (let ((inhibit-read-only t)
1867 (article-narrow-to-head)
1870 ((< (setq column (- (gnus-point-at-eol) (point)))
1871 gnus-article-normalized-header-length)
1873 (insert (make-string
1874 (- gnus-article-normalized-header-length column)
1876 ((> column gnus-article-normalized-header-length)
1877 (gnus-put-text-property
1879 (forward-char gnus-article-normalized-header-length)
1886 (forward-line 1))))))
1888 (defun article-treat-dumbquotes ()
1889 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1890 Note that this function guesses whether a character is a sm*rtq**t* or
1891 not, so it should only be used interactively.
1893 Sm*rtq**t*s are M****s***'s unilateral extension to the
1894 iso-8859-1 character map in an attempt to provide more quoting
1895 characters. If you see something like \\222 or \\264 where
1896 you're expecting some kind of apostrophe or quotation mark, then
1899 (article-translate-strings gnus-article-dumbquotes-map))
1901 (defun article-translate-characters (from to)
1902 "Translate all characters in the body of the article according to FROM and TO.
1903 FROM is a string of characters to translate from; to is a string of
1904 characters to translate to."
1906 (when (article-goto-body)
1907 (let ((inhibit-read-only t)
1908 (x (make-string 225 ?x))
1910 (while (< (incf i) (length x))
1913 (while (< i (length from))
1914 (aset x (aref from i) (aref to i))
1916 (translate-region (point) (point-max) x)))))
1918 (defun article-translate-strings (map)
1919 "Translate all string in the body of the article according to MAP.
1920 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1922 (when (article-goto-body)
1923 (let ((inhibit-read-only t)
1925 (while (setq elem (pop map))
1927 (while (search-forward (car elem) nil t)
1928 (replace-match (cadr elem)))))))))
1930 (defun article-treat-overstrike ()
1931 "Translate overstrikes into bold text."
1934 (when (article-goto-body)
1935 (let ((inhibit-read-only t))
1936 (while (search-forward "\b" nil t)
1937 (let ((next (char-after))
1938 (previous (char-after (- (point) 2))))
1939 ;; We do the boldification/underlining by hiding the
1940 ;; overstrikes and putting the proper text property
1944 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1945 (put-text-property (point) (1+ (point)) 'face 'bold))
1947 (gnus-article-hide-text-type
1948 (1- (point)) (1+ (point)) 'overstrike)
1950 (- (point) 2) (1- (point)) 'face 'underline))
1952 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1954 (point) (1+ (point)) 'face 'underline)))))))))
1956 (defun gnus-article-treat-unfold-headers ()
1957 "Unfold folded message headers.
1958 Only the headers that fit into the current window width will be
1961 (gnus-with-article-headers
1965 (mail-header-narrow-to-field)
1966 (let ((header (buffer-string)))
1969 (goto-char (point-min))
1970 (while (re-search-forward "\n[\t ]" nil t)
1971 (replace-match " " t t)))
1972 (setq length (- (point-max) (point-min) 1)))
1973 (when (< length (window-width))
1974 (while (re-search-forward "\n[\t ]" nil t)
1975 (replace-match " " t t)))
1976 (goto-char (point-max)))))))
1978 (defun gnus-article-treat-fold-headers ()
1979 "Fold message headers."
1981 (gnus-with-article-headers
1984 (mail-header-narrow-to-field)
1985 (mail-header-fold-field)
1986 (goto-char (point-max))))))
1988 (defun gnus-treat-smiley ()
1989 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1991 (gnus-with-article-buffer
1992 (if (memq 'smiley gnus-article-wash-types)
1993 (gnus-delete-images 'smiley)
1995 (let ((images (smiley-region (point) (point-max))))
1997 (gnus-add-wash-type 'smiley)
1998 (dolist (image images)
1999 (gnus-add-image 'smiley image)))))))
2001 (defun gnus-article-remove-images ()
2002 "Remove all images from the article buffer."
2004 (gnus-with-article-buffer
2005 (dolist (elem gnus-article-image-alist)
2006 (gnus-delete-images (car elem)))))
2008 (defun gnus-article-treat-fold-newsgroups ()
2009 "Unfold folded message headers.
2010 Only the headers that fit into the current window width will be
2013 (gnus-with-article-headers
2014 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2016 (mail-header-narrow-to-field)
2017 (while (re-search-forward ", *" nil t)
2018 (replace-match ", " t t))
2019 (mail-header-fold-field)
2020 (goto-char (point-max))))))
2022 (defun gnus-article-treat-body-boundary ()
2023 "Place a boundary line at the end of the headers."
2025 (when (and gnus-body-boundary-delimiter
2026 (> (length gnus-body-boundary-delimiter) 0))
2027 (gnus-with-article-headers
2028 (goto-char (point-max))
2029 (let ((start (point)))
2030 (insert "X-Boundary: ")
2031 (gnus-add-text-properties start (point) '(invisible t intangible t))
2033 (while (>= (1- (window-width)) (length str))
2034 (setq str (concat str gnus-body-boundary-delimiter)))
2035 (substring str 0 (1- (window-width))))
2037 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2039 (defun article-fill-long-lines ()
2040 "Fill lines that are wider than the window width."
2043 (let ((inhibit-read-only t)
2044 (width (window-width (get-buffer-window (current-buffer)))))
2047 (let ((adaptive-fill-mode nil)) ;Why? -sm
2050 (when (>= (current-column) (min fill-column width))
2051 (narrow-to-region (min (1+ (point)) (point-max))
2052 (gnus-point-at-bol))
2053 (let ((goback (point-marker)))
2054 (fill-paragraph nil)
2055 (goto-char (marker-position goback)))
2057 (forward-line 1)))))))
2059 (defun article-capitalize-sentences ()
2060 "Capitalize the first word in each sentence."
2063 (let ((inhibit-read-only t)
2064 (paragraph-start "^[\n\^L]"))
2068 (forward-sentence)))))
2070 (defun article-remove-cr ()
2071 "Remove trailing CRs and then translate remaining CRs into LFs."
2074 (let ((inhibit-read-only t))
2075 (goto-char (point-min))
2076 (while (re-search-forward "\r+$" nil t)
2077 (replace-match "" t t))
2078 (goto-char (point-min))
2079 (while (search-forward "\r" nil t)
2080 (replace-match "\n" t t)))))
2082 (defun article-remove-trailing-blank-lines ()
2083 "Remove all trailing blank lines from the article."
2086 (let ((inhibit-read-only t))
2087 (goto-char (point-max))
2091 (while (and (not (bobp))
2092 (looking-at "^[ \t]*$")
2093 (not (gnus-annotation-in-region-p
2094 (point) (gnus-point-at-eol))))
2099 (defun article-display-face ()
2100 "Display any Face headers in the header."
2102 (let ((wash-face-p buffer-read-only))
2103 (gnus-with-article-headers
2104 ;; When displaying parts, this function can be called several times on
2105 ;; the same article, without any intended toggle semantic (as typing `W
2106 ;; D d' would have). So face deletion must occur only when we come from
2107 ;; an interactive command, that is when the *Article* buffer is
2109 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2110 (gnus-delete-images 'face)
2113 (when (and wash-face-p
2115 (goto-char (point-min))
2116 (not (re-search-forward "^Face:[\t ]*" nil t)))
2117 (gnus-buffer-live-p gnus-original-article-buffer))
2118 (set-buffer gnus-original-article-buffer))
2120 (mail-narrow-to-head)
2121 (while (gnus-article-goto-header "Face")
2122 (push (mail-header-field-value) faces))))
2123 (while (setq face (pop faces))
2124 (let ((png (gnus-convert-face-to-png face))
2127 (setq image (gnus-create-image png 'png t))
2128 (gnus-article-goto-header "from")
2130 (insert "From: [no `from' set]\n")
2132 (gnus-add-wash-type 'face)
2133 (gnus-add-image 'face image)
2134 (gnus-put-image image nil 'face))))))
2137 (defun article-display-x-face (&optional force)
2138 "Look for an X-Face header and display it if present."
2139 (interactive (list 'force))
2140 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2141 (gnus-with-article-headers
2142 ;; Delete the old process, if any.
2143 (when (process-status "article-x-face")
2144 (delete-process "article-x-face"))
2145 ;; See the comment in `article-display-face'.
2146 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2147 ;; We have already displayed X-Faces, so we remove them
2149 (gnus-delete-images 'xface)
2151 (let (x-faces from face)
2153 (when (and wash-face-p
2155 (goto-char (point-min))
2156 (not (re-search-forward
2157 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2158 (gnus-buffer-live-p gnus-original-article-buffer))
2159 ;; If type `W f', use gnus-original-article-buffer,
2160 ;; otherwise use the current buffer because displaying
2161 ;; RFC822 parts calls this function too.
2162 (set-buffer gnus-original-article-buffer))
2164 (mail-narrow-to-head)
2165 (while (gnus-article-goto-header "X-Face")
2166 (push (mail-header-field-value) x-faces))
2167 (setq from (message-fetch-field "from"))))
2168 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2169 ;; single external face.
2170 (when (stringp gnus-article-x-face-command)
2171 (setq x-faces (list (car x-faces))))
2172 (while (and (setq face (pop x-faces))
2173 gnus-article-x-face-command
2175 ;; Check whether this face is censored.
2176 (not gnus-article-x-face-too-ugly)
2177 (and gnus-article-x-face-too-ugly from
2178 (not (string-match gnus-article-x-face-too-ugly
2180 ;; We display the face.
2181 (cond ((stringp gnus-article-x-face-command)
2182 ;; The command is a string, so we interpret the command
2183 ;; as a, well, command, and fork it off.
2184 (let ((process-connection-type nil))
2185 (process-kill-without-query
2187 "article-x-face" nil shell-file-name
2188 shell-command-switch gnus-article-x-face-command))
2191 (process-send-region "article-x-face"
2192 (point-min) (point-max)))
2193 (process-send-eof "article-x-face")))
2194 ((functionp gnus-article-x-face-command)
2195 ;; The command is a lisp function, so we call it.
2196 (funcall gnus-article-x-face-command face))
2198 (error "%s is not a function"
2199 gnus-article-x-face-command)))))))))
2201 (defun article-decode-mime-words ()
2202 "Decode all MIME-encoded words in the article."
2205 (set-buffer gnus-article-buffer)
2206 (let ((inhibit-point-motion-hooks t)
2207 (inhibit-read-only t)
2208 (mail-parse-charset gnus-newsgroup-charset)
2209 (mail-parse-ignored-charsets
2210 (save-excursion (set-buffer gnus-summary-buffer)
2211 gnus-newsgroup-ignored-charsets)))
2212 (mail-decode-encoded-word-region (point-min) (point-max)))))
2214 (defun article-decode-charset (&optional prompt)
2215 "Decode charset-encoded text in the article.
2216 If PROMPT (the prefix), prompt for a coding system to use."
2218 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2219 (inhibit-read-only t)
2220 (mail-parse-charset gnus-newsgroup-charset)
2221 (mail-parse-ignored-charsets
2222 (save-excursion (condition-case nil
2223 (set-buffer gnus-summary-buffer)
2225 gnus-newsgroup-ignored-charsets))
2226 ct cte ctl charset format)
2229 (article-narrow-to-head)
2230 (setq ct (message-fetch-field "Content-Type" t)
2231 cte (message-fetch-field "Content-Transfer-Encoding" t)
2232 ctl (and ct (ignore-errors
2233 (mail-header-parse-content-type ct)))
2236 (mm-read-coding-system "Charset to decode: "))
2238 (mail-content-type-get ctl 'charset)))
2239 format (and ctl (mail-content-type-get ctl 'format)))
2241 (setq cte (mail-header-strip cte)))
2242 (if (and ctl (not (string-match "/" (car ctl))))
2244 (goto-char (point-max)))
2247 (narrow-to-region (point) (point-max))
2248 (when (and (eq mail-parse-charset 'gnus-decoded)
2249 (eq (mm-body-7-or-8) '8bit))
2250 ;; The text code could have been decoded.
2251 (setq charset mail-parse-charset))
2252 (when (and (or (not ctl)
2253 (equal (car ctl) "text/plain"))
2254 (not format)) ;; article with format will decode later.
2256 charset (and cte (intern (downcase
2257 (gnus-strip-whitespace cte))))
2260 (defun article-decode-encoded-words ()
2261 "Remove encoded-word encoding from headers."
2262 (let ((inhibit-point-motion-hooks t)
2263 (mail-parse-charset gnus-newsgroup-charset)
2264 (mail-parse-ignored-charsets
2265 (save-excursion (condition-case nil
2266 (set-buffer gnus-summary-buffer)
2268 gnus-newsgroup-ignored-charsets))
2269 (inhibit-read-only t))
2271 (article-narrow-to-head)
2272 (funcall gnus-decode-header-function (point-min) (point-max)))))
2274 (defun article-decode-group-name ()
2275 "Decode group names in `Newsgroups:'."
2276 (let ((inhibit-point-motion-hooks t)
2277 (inhibit-read-only t)
2278 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2279 (when (and (or gnus-group-name-charset-method-alist
2280 gnus-group-name-charset-group-alist)
2281 (gnus-buffer-live-p gnus-original-article-buffer))
2283 (article-narrow-to-head)
2284 (with-current-buffer gnus-original-article-buffer
2285 (goto-char (point-min)))
2286 (while (re-search-forward
2287 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2288 (replace-match (save-match-data
2289 (gnus-decode-newsgroups
2290 ;; XXX how to use data in article buffer?
2291 (with-current-buffer gnus-original-article-buffer
2293 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2296 gnus-newsgroup-name method))
2298 (goto-char (point-min))
2299 (with-current-buffer gnus-original-article-buffer
2300 (goto-char (point-min)))
2301 (while (re-search-forward
2302 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2303 (replace-match (save-match-data
2304 (gnus-decode-newsgroups
2305 ;; XXX how to use data in article buffer?
2306 (with-current-buffer gnus-original-article-buffer
2308 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2311 gnus-newsgroup-name method))
2314 (autoload 'idna-to-unicode "idna")
2316 (defun article-decode-idna-rhs ()
2317 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2320 (let ((inhibit-point-motion-hooks t)
2321 (inhibit-read-only t))
2322 (article-narrow-to-head)
2323 (goto-char (point-min))
2324 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2326 (when (save-match-data
2327 (and (setq ace (match-string 1))
2329 (and (re-search-backward "^[^ \t]" nil t)
2330 (looking-at "From\\|To\\|Cc")))
2331 (setq unicode (idna-to-unicode ace))))
2332 (unless (string= ace unicode)
2333 (replace-match unicode nil nil nil 1)))))))))
2335 (defun article-de-quoted-unreadable (&optional force read-charset)
2336 "Translate a quoted-printable-encoded article.
2337 If FORCE, decode the article whether it is marked as quoted-printable
2339 If READ-CHARSET, ask for a coding system."
2340 (interactive (list 'force current-prefix-arg))
2342 (let ((inhibit-read-only t) type charset)
2343 (if (gnus-buffer-live-p gnus-original-article-buffer)
2344 (with-current-buffer gnus-original-article-buffer
2346 (gnus-fetch-field "content-transfer-encoding"))
2347 (let* ((ct (gnus-fetch-field "content-type"))
2350 (mail-header-parse-content-type ct)))))
2351 (setq charset (and ctl
2352 (mail-content-type-get ctl 'charset)))
2353 (if (stringp charset)
2354 (setq charset (intern (downcase charset)))))))
2356 (setq charset (mm-read-coding-system "Charset: " charset)))
2358 (setq charset gnus-newsgroup-charset))
2360 (and type (let ((case-fold-search t))
2361 (string-match "quoted-printable" type))))
2363 (quoted-printable-decode-region
2364 (point) (point-max) (mm-charset-to-coding-system charset))))))
2366 (defun article-de-base64-unreadable (&optional force read-charset)
2367 "Translate a base64 article.
2368 If FORCE, decode the article whether it is marked as base64 not.
2369 If READ-CHARSET, ask for a coding system."
2370 (interactive (list 'force current-prefix-arg))
2372 (let ((inhibit-read-only t) type charset)
2373 (if (gnus-buffer-live-p gnus-original-article-buffer)
2374 (with-current-buffer gnus-original-article-buffer
2376 (gnus-fetch-field "content-transfer-encoding"))
2377 (let* ((ct (gnus-fetch-field "content-type"))
2380 (mail-header-parse-content-type ct)))))
2381 (setq charset (and ctl
2382 (mail-content-type-get ctl 'charset)))
2383 (if (stringp charset)
2384 (setq charset (intern (downcase charset)))))))
2386 (setq charset (mm-read-coding-system "Charset: " charset)))
2388 (setq charset gnus-newsgroup-charset))
2390 (and type (let ((case-fold-search t))
2391 (string-match "base64" type))))
2394 (narrow-to-region (point) (point-max))
2395 (base64-decode-region (point-min) (point-max))
2396 (mm-decode-coding-region
2397 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2402 (defun article-decode-HZ ()
2403 "Translate a HZ-encoded article."
2407 (let ((inhibit-read-only t))
2408 (rfc1843-decode-region (point-min) (point-max)))))
2410 (defun article-unsplit-urls ()
2411 "Remove the newlines that some other mailers insert into URLs."
2414 (let ((inhibit-read-only t))
2415 (goto-char (point-min))
2416 (while (re-search-forward
2417 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2418 (replace-match "\\1\\3" t)))
2419 (when (interactive-p)
2420 (gnus-treat-article nil))))
2423 (defun article-wash-html (&optional read-charset)
2424 "Format an HTML article.
2425 If READ-CHARSET, ask for a coding system."
2428 (let ((inhibit-read-only t)
2430 (when (gnus-buffer-live-p gnus-original-article-buffer)
2431 (with-current-buffer gnus-original-article-buffer
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 (when (stringp charset)
2439 (setq charset (intern (downcase charset)))))))
2441 (setq charset (mm-read-coding-system "Charset: " charset)))
2443 (setq charset gnus-newsgroup-charset))
2445 (save-window-excursion
2447 (narrow-to-region (point) (point-max))
2448 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2449 (entry (assq func mm-text-html-washer-alist)))
2451 (setq func (cdr entry)))
2456 (apply (car func) (cdr func))))))))))
2458 (defun gnus-article-wash-html-with-w3 ()
2459 "Wash the current buffer with w3."
2461 (let ((w3-strict-width (window-width))
2462 (url-standalone-mode t)
2463 (url-gateway-unplugged t)
2464 (w3-honor-stylesheets nil))
2466 (w3-region (point-min) (point-max))
2469 (defun gnus-article-wash-html-with-w3m ()
2470 "Wash the current buffer with emacs-w3m."
2473 (narrow-to-region (point) (point-max))
2474 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2475 w3m-force-redisplay)
2476 (w3m-region (point-min) (point-max)))
2477 (when (and mm-inline-text-html-with-w3m-keymap
2478 (boundp 'w3m-minor-mode-map)
2480 (add-text-properties
2481 (point-min) (point-max)
2482 (list 'keymap w3m-minor-mode-map
2483 ;; Put the mark meaning this part was rendered by emacs-w3m.
2484 'mm-inline-text-html-with-w3m t)))))
2486 (defun article-hide-list-identifiers ()
2487 "Remove list identifies from the Subject header.
2488 The `gnus-list-identifiers' variable specifies what to do."
2490 (let ((inhibit-point-motion-hooks t)
2491 (regexp (if (consp gnus-list-identifiers)
2492 (mapconcat 'identity gnus-list-identifiers " *\\|")
2493 gnus-list-identifiers))
2494 (inhibit-read-only t))
2498 (article-narrow-to-head)
2499 (goto-char (point-min))
2500 (while (re-search-forward
2501 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2503 (delete-region (match-beginning 2) (match-end 0))
2504 (beginning-of-line))
2505 (when (re-search-forward
2506 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2507 (delete-region (match-beginning 1) (match-end 1))))))))
2509 (defun article-hide-pem (&optional arg)
2510 "Toggle hiding of any PEM headers and signatures in the current article.
2511 If given a negative prefix, always show; if given a positive prefix,
2513 (interactive (gnus-article-hidden-arg))
2514 (unless (gnus-article-check-hidden-text 'pem arg)
2516 (let ((inhibit-read-only t) end)
2517 (goto-char (point-min))
2518 ;; Hide the horrendously ugly "header".
2519 (when (and (search-forward
2520 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2522 (setq end (1+ (match-beginning 0))))
2523 (gnus-add-wash-type 'pem)
2524 (gnus-article-hide-text-type
2526 (if (search-forward "\n\n" nil t)
2530 ;; Hide the trailer as well
2531 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2533 (gnus-article-hide-text-type
2534 (match-beginning 0) (match-end 0) 'pem)))))))
2536 (defun article-strip-banner ()
2537 "Strip the banners specified by the `banner' group parameter and by
2538 `gnus-article-address-banner-alist'."
2542 (let ((inhibit-point-motion-hooks t))
2543 (when (gnus-parameter-banner gnus-newsgroup-name)
2544 (article-really-strip-banner
2545 (gnus-parameter-banner gnus-newsgroup-name)))
2546 (when gnus-article-address-banner-alist
2547 (article-really-strip-banner
2548 (let ((from (save-restriction
2550 (article-narrow-to-head)
2551 (mail-fetch-field "from"))))
2554 (caar (mail-header-parse-addresses from))))
2556 (dolist (pair gnus-article-address-banner-alist)
2557 (when (string-match (car pair) from)
2558 (throw 'found (cdr pair)))))))))))))
2560 (defun article-really-strip-banner (banner)
2561 "Strip the banner specified by the argument."
2564 (let ((inhibit-point-motion-hooks t)
2565 (gnus-signature-limit nil)
2566 (inhibit-read-only t))
2569 ((eq banner 'signature)
2570 (when (gnus-article-narrow-to-signature)
2573 (delete-region (point) (point-max))))
2575 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2576 (while (re-search-forward banner nil t)
2577 (delete-region (match-beginning 0) (match-end 0)))))
2579 (while (re-search-forward banner nil t)
2580 (delete-region (match-beginning 0) (match-end 0)))))))))
2582 (defun article-babel ()
2583 "Translate article using an online translation service."
2587 (set-buffer gnus-article-buffer)
2588 (when (article-goto-body)
2589 (let* ((inhibit-read-only t)
2592 (orig (buffer-substring start end))
2593 (trans (babel-as-string orig)))
2595 (narrow-to-region start end)
2596 (delete-region start end)
2599 (defun article-hide-signature (&optional arg)
2600 "Hide the signature in the current article.
2601 If given a negative prefix, always show; if given a positive prefix,
2603 (interactive (gnus-article-hidden-arg))
2604 (unless (gnus-article-check-hidden-text 'signature arg)
2607 (let ((inhibit-read-only t))
2608 (when (gnus-article-narrow-to-signature)
2609 (gnus-article-hide-text-type
2610 (point-min) (point-max) 'signature))))))
2611 (gnus-set-mode-line 'article))
2613 (defun article-strip-headers-in-body ()
2614 "Strip offensive headers from bodies."
2618 (let ((case-fold-search t))
2619 (when (looking-at "x-no-archive:")
2620 (gnus-delete-line)))))
2622 (defun article-strip-leading-blank-lines ()
2623 "Remove all blank lines from the beginning of the article."
2626 (let ((inhibit-point-motion-hooks t)
2627 (inhibit-read-only t))
2628 (when (article-goto-body)
2629 (while (and (not (eobp))
2630 (looking-at "[ \t]*$"))
2631 (gnus-delete-line))))))
2633 (defun article-narrow-to-head ()
2634 "Narrow the buffer to the head of the message.
2635 Point is left at the beginning of the narrowed-to region."
2637 (goto-char (point-min))
2638 (if (search-forward "\n\n" nil 1)
2641 (goto-char (point-min)))
2643 (defun article-goto-body ()
2644 "Place point at the start of the body."
2645 (goto-char (point-min))
2647 ;; This variable is only bound when dealing with separate
2649 (article-goto-body-goes-to-point-min-p
2651 ((search-forward "\n\n" nil t)
2654 (goto-char (point-max))
2657 (defun article-strip-multiple-blank-lines ()
2658 "Replace consecutive blank lines with one empty line."
2661 (let ((inhibit-point-motion-hooks t)
2662 (inhibit-read-only t))
2663 ;; First make all blank lines empty.
2665 (while (re-search-forward "^[ \t]+$" nil t)
2666 (unless (gnus-annotation-in-region-p
2667 (match-beginning 0) (match-end 0))
2668 (replace-match "" nil t)))
2669 ;; Then replace multiple empty lines with a single empty line.
2671 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2672 (unless (gnus-annotation-in-region-p
2673 (match-beginning 0) (match-end 0))
2674 (delete-region (match-beginning 1) (match-end 1)))))))
2676 (defun article-strip-leading-space ()
2677 "Remove all white space from the beginning of the lines in the article."
2680 (let ((inhibit-point-motion-hooks t)
2681 (inhibit-read-only t))
2683 (while (re-search-forward "^[ \t]+" nil t)
2684 (replace-match "" t t)))))
2686 (defun article-strip-trailing-space ()
2687 "Remove all white space from the end of the lines in the article."
2690 (let ((inhibit-point-motion-hooks t)
2691 (inhibit-read-only t))
2693 (while (re-search-forward "[ \t]+$" nil t)
2694 (replace-match "" t t)))))
2696 (defun article-strip-blank-lines ()
2697 "Strip leading, trailing and multiple blank lines."
2699 (article-strip-leading-blank-lines)
2700 (article-remove-trailing-blank-lines)
2701 (article-strip-multiple-blank-lines))
2703 (defun article-strip-all-blank-lines ()
2704 "Strip all blank lines."
2707 (let ((inhibit-point-motion-hooks t)
2708 (inhibit-read-only t))
2710 (while (re-search-forward "^[ \t]*\n" nil t)
2711 (replace-match "" t t)))))
2713 (defun gnus-article-narrow-to-signature ()
2714 "Narrow to the signature; return t if a signature is found, else nil."
2715 (let ((inhibit-point-motion-hooks t))
2716 (when (gnus-article-search-signature)
2718 ;; Check whether we have some limits to what we consider
2719 ;; to be a signature.
2720 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2721 (list gnus-signature-limit)))
2723 (while (setq limit (pop limits))
2724 (if (or (and (integerp limit)
2725 (< (- (point-max) (point)) limit))
2727 (< (count-lines (point) (point-max)) limit))
2728 (and (functionp limit)
2730 (and (stringp limit)
2731 (not (re-search-forward limit nil t))))
2732 () ; This limit did not succeed.
2736 (narrow-to-region (point) (point-max))
2739 (defun gnus-article-search-signature ()
2740 "Search the current buffer for the signature separator.
2741 Put point at the beginning of the signature separator."
2742 (let ((cur (point)))
2743 (goto-char (point-max))
2744 (if (if (stringp gnus-signature-separator)
2745 (re-search-backward gnus-signature-separator nil t)
2746 (let ((seps gnus-signature-separator))
2748 (not (re-search-backward (car seps) nil t)))
2755 (defun gnus-article-hidden-arg ()
2756 "Return the current prefix arg as a number, or 0 if no prefix."
2757 (list (if current-prefix-arg
2758 (prefix-numeric-value current-prefix-arg)
2761 (defun gnus-article-check-hidden-text (type arg)
2762 "Return nil if hiding is necessary.
2763 Arg can be nil or a number. nil and positive means hide, negative
2764 means show, 0 means toggle."
2767 (let ((hide (gnus-article-hidden-text-p type)))
2773 (gnus-article-show-hidden-text type)
2776 (if (eq hide 'hidden)
2778 (gnus-article-show-hidden-text type)
2782 (defun gnus-article-hidden-text-p (type)
2783 "Say whether the current buffer contains hidden text of type TYPE."
2784 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2786 (not (get-text-property pos 'invisible))
2787 (not (get-text-property pos 'dummy-invisible)))
2789 (text-property-any (1+ pos) (point-max) 'article-type type)))
2794 (defun gnus-article-show-hidden-text (type &optional dummy)
2795 "Show all hidden text of type TYPE.
2796 Originally it is hide instead of DUMMY."
2797 (let ((inhibit-read-only t)
2798 (inhibit-point-motion-hooks t))
2799 (gnus-remove-text-properties-when
2801 (point-min) (point-max)
2802 (cons 'article-type (cons type
2803 gnus-hidden-properties)))
2804 (gnus-delete-wash-type type)))
2806 (defconst article-time-units
2807 `((year . ,(* 365.25 24 60 60))
2808 (week . ,(* 7 24 60 60))
2809 (day . ,(* 24 60 60))
2813 "Mapping from time units to seconds.")
2815 (defun gnus-article-forward-header ()
2816 "Move point to the start of the next header.
2817 If the current header is a continuation header, this can be several
2822 (if (looking-at "[ \t]+[^ \t]")
2826 (defun article-date-ut (&optional type highlight header)
2827 "Convert DATE date to universal time in the current article.
2828 If TYPE is `local', convert to local time; if it is `lapsed', output
2829 how much time has lapsed since DATE. For `lapsed', the value of
2830 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2831 should replace the \"Date:\" one, or should be added below it."
2832 (interactive (list 'ut t))
2833 (let* ((header (or header
2834 (message-fetch-field "date")
2836 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2839 ((not gnus-article-date-lapsed-new-header)
2845 (date (if (vectorp header) (mail-header-date header)
2847 (inhibit-point-motion-hooks t)
2852 (article-narrow-to-head)
2853 (when (re-search-forward tdate-regexp nil t)
2854 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2855 date (or (get-text-property (gnus-point-at-bol)
2858 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2860 (when (and date (not (string= date "")))
2861 (goto-char (point-min))
2862 (let ((inhibit-read-only t))
2863 ;; Delete any old Date headers.
2864 (while (re-search-forward date-regexp nil t)
2866 (delete-region (progn (beginning-of-line) (point))
2867 (progn (gnus-article-forward-header)
2869 (delete-region (progn (beginning-of-line) (point))
2870 (progn (gnus-article-forward-header)
2873 (setq pos (point))))
2874 (when (and (not pos)
2875 (re-search-forward tdate-regexp nil t))
2879 (insert (article-make-date-line date (or type 'ut)))
2885 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2886 (put-text-property (match-beginning 1) (1+ (match-end 1))
2887 'original-date date)
2888 (put-text-property (match-beginning 1) (1+ (match-end 1))
2890 (put-text-property (match-beginning 2) (match-end 2)
2893 (defun article-make-date-line (date type)
2894 "Return a DATE line of TYPE."
2895 (unless (memq type '(local ut original user iso8601 lapsed english))
2896 (error "Unknown conversion type: %s" type))
2898 (let ((time (date-to-time date)))
2900 ;; Convert to the local timezone.
2902 (let ((tz (car (current-time-zone time))))
2903 (format "Date: %s %s%02d%02d" (current-time-string time)
2904 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2905 (/ (% (abs tz) 3600) 60))))
2906 ;; Convert to Universal Time.
2909 (current-time-string
2910 (let* ((e (parse-time-string date))
2911 (tm (apply 'encode-time e))
2913 (ls (- (cadr tm) (car (current-time-zone time)))))
2914 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2915 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2918 ;; Get the original date from the article.
2919 ((eq type 'original)
2920 (concat "Date: " (if (string-match "\n+$" date)
2921 (substring date 0 (match-beginning 0))
2923 ;; Let the user define the format.
2925 (let ((format (or (condition-case nil
2926 (with-current-buffer gnus-summary-buffer
2927 gnus-article-time-format)
2929 gnus-article-time-format)))
2930 (if (functionp format)
2931 (funcall format time)
2932 (concat "Date: " (format-time-string format time)))))
2935 (let ((tz (car (current-time-zone time))))
2938 (format-time-string "%Y%m%dT%H%M%S" time)
2939 (format "%s%02d%02d"
2940 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2941 (/ (% (abs tz) 3600) 60)))))
2942 ;; Do an X-Sent lapsed format.
2944 ;; If the date is seriously mangled, the timezone functions are
2945 ;; liable to bug out, so we ignore all errors.
2946 (let* ((now (current-time))
2947 (real-time (subtract-time now time))
2948 (real-sec (and real-time
2949 (+ (* (float (car real-time)) 65536)
2951 (sec (and real-time (abs real-sec)))
2961 ;; This is a bit convoluted, but basically we go
2962 ;; through the time units for years, weeks, etc,
2963 ;; and divide things to see whether that results
2964 ;; in positive answers.
2967 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2968 ;; The (remaining) seconds are too few to
2969 ;; be divided into this time unit.
2971 ;; It's big enough, so we output it.
2972 (setq sec (- sec (* num (cdr unit))))
2974 (concat (if prev ", " "") (int-to-string
2976 " " (symbol-name (car unit))
2977 (if (> num 1) "s" ""))
2979 article-time-units "")
2980 ;; If dates are odd, then it might appear like the
2981 ;; article was sent in the future.
2984 " in the future"))))))
2985 ;; Display the date in proper English
2987 (let ((dtime (decode-time time)))
2990 (number-to-string (nth 3 dtime))
2991 (let ((digit (% (nth 3 dtime) 10)))
2993 ((memq (nth 3 dtime) '(11 12 13)) "th")
2999 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3001 (number-to-string (nth 5 dtime))
3003 (format "%02d" (nth 2 dtime))
3005 (format "%02d" (nth 1 dtime)))))))
3007 (format "Date: %s (from Gnus)" date))))
3009 (defun article-date-local (&optional highlight)
3010 "Convert the current article date to the local timezone."
3011 (interactive (list t))
3012 (article-date-ut 'local highlight))
3014 (defun article-date-english (&optional highlight)
3015 "Convert the current article date to something that is proper English."
3016 (interactive (list t))
3017 (article-date-ut 'english highlight))
3019 (defun article-date-original (&optional highlight)
3020 "Convert the current article date to what it was originally.
3021 This is only useful if you have used some other date conversion
3022 function and want to see what the date was before converting."
3023 (interactive (list t))
3024 (article-date-ut 'original highlight))
3026 (defun article-date-lapsed (&optional highlight)
3027 "Convert the current article date to time lapsed since it was sent."
3028 (interactive (list t))
3029 (article-date-ut 'lapsed highlight))
3031 (defun article-update-date-lapsed ()
3032 "Function to be run from a timer to update the lapsed time line."
3033 (let (deactivate-mark)
3038 (set-buffer (window-buffer w))
3039 (when (eq major-mode 'gnus-article-mode)
3040 (let ((mark (point-marker)))
3041 (goto-char (point-min))
3042 (when (re-search-forward "^X-Sent:" nil t)
3043 (article-date-lapsed t))
3044 (goto-char (marker-position mark))
3045 (move-marker mark nil))))
3048 (defun gnus-start-date-timer (&optional n)
3049 "Start a timer to update the X-Sent header in the article buffers.
3050 The numerical prefix says how frequently (in seconds) the function
3055 (gnus-stop-date-timer)
3056 (setq article-lapsed-timer
3057 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
3059 (defun gnus-stop-date-timer ()
3060 "Stop the X-Sent timer."
3062 (when article-lapsed-timer
3063 (nnheader-cancel-timer article-lapsed-timer)
3064 (setq article-lapsed-timer nil)))
3066 (defun article-date-user (&optional highlight)
3067 "Convert the current article date to the user-defined format.
3068 This format is defined by the `gnus-article-time-format' variable."
3069 (interactive (list t))
3070 (article-date-ut 'user highlight))
3072 (defun article-date-iso8601 (&optional highlight)
3073 "Convert the current article date to ISO8601."
3074 (interactive (list t))
3075 (article-date-ut 'iso8601 highlight))
3077 ;; (defun article-show-all ()
3078 ;; "Show all hidden text in the article buffer."
3081 ;; (let ((inhibit-read-only t))
3082 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3084 (defun article-remove-leading-whitespace ()
3085 "Remove excessive whitespace from all headers."
3089 (let ((inhibit-read-only t))
3090 (article-narrow-to-head)
3091 (goto-char (point-min))
3092 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3093 (delete-region (match-beginning 1) (match-end 1)))))))
3095 (defun article-emphasize (&optional arg)
3096 "Emphasize text according to `gnus-emphasis-alist'."
3097 (interactive (gnus-article-hidden-arg))
3098 (unless (gnus-article-check-hidden-text 'emphasis arg)
3102 (with-current-buffer gnus-summary-buffer
3103 gnus-article-emphasis-alist)
3105 gnus-emphasis-alist))
3106 (inhibit-read-only t)
3107 (props (append '(article-type emphasis)
3108 gnus-hidden-properties))
3109 regexp elem beg invisible visible face)
3112 (while (setq elem (pop alist))
3114 (setq regexp (car elem)
3115 invisible (nth 1 elem)
3116 visible (nth 2 elem)
3118 (while (re-search-forward regexp nil t)
3119 (when (and (match-beginning visible) (match-beginning invisible))
3120 (gnus-article-hide-text
3121 (match-beginning invisible) (match-end invisible) props)
3122 (gnus-article-unhide-text-type
3123 (match-beginning visible) (match-end visible) 'emphasis)
3124 (gnus-put-overlay-excluding-newlines
3125 (match-beginning visible) (match-end visible) 'face face)
3126 (gnus-add-wash-type 'emphasis)
3127 (goto-char (match-end invisible)))))))))
3129 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3130 "Setup newsgroup emphasis alist."
3131 (unless gnus-article-emphasis-alist
3132 (let ((name (and gnus-newsgroup-name
3133 (gnus-group-real-name gnus-newsgroup-name))))
3134 (make-local-variable 'gnus-article-emphasis-alist)
3135 (setq gnus-article-emphasis-alist
3137 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3138 (while (setq elem (pop alist))
3139 (when (and name (string-match (car elem) name))
3141 highlight (copy-sequence (cdr elem)))))
3143 (copy-sequence highlight-words)
3144 (if gnus-newsgroup-name
3145 (copy-sequence (gnus-group-find-parameter
3146 gnus-newsgroup-name 'highlight-words t)))
3147 gnus-emphasis-alist)))))
3150 (defvar gnus-summary-article-menu)
3151 (defvar gnus-summary-post-menu))
3153 ;;; Saving functions.
3155 (defun gnus-article-save (save-buffer file &optional num)
3156 "Save the currently selected article."
3157 (unless gnus-save-all-headers
3158 ;; Remove headers according to `gnus-saved-headers'.
3159 (let ((gnus-visible-headers
3160 (or gnus-saved-headers gnus-visible-headers))
3161 (gnus-article-buffer save-buffer))
3163 (set-buffer save-buffer)
3164 (article-hide-headers 1 t))))
3165 (save-window-excursion
3166 (if (not gnus-default-article-saver)
3167 (error "No default saver is defined")
3168 ;; !!! Magic! The saving functions all save
3169 ;; `gnus-save-article-buffer' (or so they think), but we
3170 ;; bind that variable to our save-buffer.
3171 (set-buffer gnus-article-buffer)
3172 (let* ((gnus-save-article-buffer save-buffer)
3175 ((not gnus-prompt-before-saving) 'default)
3176 ((eq gnus-prompt-before-saving 'always) nil)
3178 (gnus-number-of-articles-to-be-saved
3179 (when (eq gnus-prompt-before-saving t)
3181 (set-buffer gnus-article-current-summary)
3182 (funcall gnus-default-article-saver filename)))))
3184 (defun gnus-read-save-file-name (prompt &optional filename
3185 function group headers variable)
3187 (funcall function group headers (symbol-value variable)))
3192 ((eq filename 'default)
3198 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3201 (if (and gnus-number-of-articles-to-be-saved
3202 (> gnus-number-of-articles-to-be-saved 1))
3203 (format "these %d articles"
3204 gnus-number-of-articles-to-be-saved)
3207 ;; Let the split methods have their say.
3209 ;; No split name was found.
3212 (concat prompt " (default "
3213 (file-name-nondirectory default-name) ") ")
3214 (file-name-directory default-name)
3216 ;; A single group name is returned.
3217 ((stringp split-name)
3219 (funcall function split-name headers
3220 (symbol-value variable)))
3222 (concat prompt " (default "
3223 (file-name-nondirectory default-name) ") ")
3224 (file-name-directory default-name)
3226 ;; A single split name was found
3227 ((= 1 (length split-name))
3228 (let* ((name (expand-file-name
3230 gnus-article-save-directory))
3231 (dir (cond ((file-directory-p name)
3232 (file-name-as-directory name))
3233 ((file-exists-p name) name)
3234 (t gnus-article-save-directory))))
3236 (concat prompt " (default " name ") ")
3238 ;; A list of splits was found.
3240 (setq split-name (nreverse split-name))
3242 (let ((file-name-history
3243 (nconc split-name file-name-history)))
3247 (concat prompt " (`M-p' for defaults) ")
3248 gnus-article-save-directory
3250 gnus-article-save-directory)))
3251 (car (push result file-name-history)))))))
3252 ;; Create the directory.
3253 (gnus-make-directory (file-name-directory file))
3254 ;; If we have read a directory, we append the default file name.
3255 (when (file-directory-p file)
3256 (setq file (expand-file-name (file-name-nondirectory
3258 (file-name-as-directory file))))
3259 ;; Possibly translate some characters.
3260 (nnheader-translate-file-chars file))))))
3261 (gnus-make-directory (file-name-directory result))
3262 (set variable result)))
3264 (defun gnus-article-archive-name (group)
3265 "Return the first instance of an \"Archive-name\" in the current buffer."
3266 (let ((case-fold-search t))
3267 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3268 (nnheader-concat gnus-article-save-directory
3269 (match-string 1)))))
3271 (defun gnus-article-nndoc-name (group)
3272 "If GROUP is an nndoc group, return the name of the parent group."
3273 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3274 (gnus-group-get-parameter group 'save-article-group)))
3276 (defun gnus-summary-save-in-rmail (&optional filename)
3277 "Append this article to Rmail file.
3278 Optional argument FILENAME specifies file name.
3279 Directory to save to is default to `gnus-article-save-directory'."
3280 (setq filename (gnus-read-save-file-name
3281 "Save %s in rmail file:" filename
3282 gnus-rmail-save-name gnus-newsgroup-name
3283 gnus-current-headers 'gnus-newsgroup-last-rmail))
3284 (gnus-eval-in-buffer-window gnus-save-article-buffer
3288 (gnus-output-to-rmail filename))))
3291 (defun gnus-summary-save-in-mail (&optional filename)
3292 "Append this article to Unix mail file.
3293 Optional argument FILENAME specifies file name.
3294 Directory to save to is default to `gnus-article-save-directory'."
3295 (setq filename (gnus-read-save-file-name
3296 "Save %s in Unix mail file:" filename
3297 gnus-mail-save-name gnus-newsgroup-name
3298 gnus-current-headers 'gnus-newsgroup-last-mail))
3299 (gnus-eval-in-buffer-window gnus-save-article-buffer
3303 (if (and (file-readable-p filename)
3304 (file-regular-p filename)
3305 (mail-file-babyl-p filename))
3306 (rmail-output-to-rmail-file filename t)
3307 (gnus-output-to-mail filename)))))
3310 (defun gnus-summary-save-in-file (&optional filename overwrite)
3311 "Append this article to file.
3312 Optional argument FILENAME specifies file name.
3313 Directory to save to is default to `gnus-article-save-directory'."
3314 (setq filename (gnus-read-save-file-name
3315 "Save %s in file:" filename
3316 gnus-file-save-name gnus-newsgroup-name
3317 gnus-current-headers 'gnus-newsgroup-last-file))
3318 (gnus-eval-in-buffer-window gnus-save-article-buffer
3322 (when (and overwrite
3323 (file-exists-p filename))
3324 (delete-file filename))
3325 (gnus-output-to-file filename))))
3328 (defun gnus-summary-write-to-file (&optional filename)
3329 "Write this article to a file, overwriting it if the file exists.
3330 Optional argument FILENAME specifies file name.
3331 The directory to save in defaults to `gnus-article-save-directory'."
3332 (gnus-summary-save-in-file nil t))
3334 (defun gnus-summary-save-body-in-file (&optional filename)
3335 "Append this article body to a file.
3336 Optional argument FILENAME specifies file name.
3337 The directory to save in defaults to `gnus-article-save-directory'."
3338 (setq filename (gnus-read-save-file-name
3339 "Save %s body in file:" filename
3340 gnus-file-save-name gnus-newsgroup-name
3341 gnus-current-headers 'gnus-newsgroup-last-file))
3342 (gnus-eval-in-buffer-window gnus-save-article-buffer
3346 (when (article-goto-body)
3347 (narrow-to-region (point) (point-max)))
3348 (gnus-output-to-file filename))))
3351 (defun gnus-summary-save-in-pipe (&optional command)
3352 "Pipe this article to subprocess."
3354 (cond ((and (eq command 'default)
3355 gnus-last-shell-command)
3356 gnus-last-shell-command)
3361 "Shell command on %s: "
3362 (if (and gnus-number-of-articles-to-be-saved
3363 (> gnus-number-of-articles-to-be-saved 1))
3364 (format "these %d articles"
3365 gnus-number-of-articles-to-be-saved)
3367 gnus-last-shell-command))))
3368 (when (string-equal command "")
3369 (if gnus-last-shell-command
3370 (setq command gnus-last-shell-command)
3371 (error "A command is required")))
3372 (gnus-eval-in-buffer-window gnus-article-buffer
3375 (shell-command-on-region (point-min) (point-max) command nil)))
3376 (setq gnus-last-shell-command command))
3378 (defmacro gnus-read-string (prompt &optional initial-contents history
3380 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3381 (if (and (featurep 'xemacs)
3382 (< emacs-minor-version 2))
3383 `(read-string ,prompt ,initial-contents ,history)
3384 `(read-string ,prompt ,initial-contents ,history ,default-value)))
3386 (defun gnus-summary-pipe-to-muttprint (&optional command)
3387 "Pipe this article to muttprint."
3388 (setq command (gnus-read-string
3389 "Print using command: " gnus-summary-muttprint-program
3390 nil gnus-summary-muttprint-program))
3391 (gnus-summary-save-in-pipe command))
3393 ;;; Article file names when saving.
3395 (defun gnus-capitalize-newsgroup (newsgroup)
3396 "Capitalize NEWSGROUP name."
3397 (when (not (zerop (length newsgroup)))
3398 (concat (char-to-string (upcase (aref newsgroup 0)))
3399 (substring newsgroup 1))))
3401 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3402 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3403 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3404 Otherwise, it is like ~/News/news/group/num."
3407 (concat (if (gnus-use-long-file-name 'not-save)
3408 (gnus-capitalize-newsgroup newsgroup)
3409 (gnus-newsgroup-directory-form newsgroup))
3410 "/" (int-to-string (mail-header-number headers)))
3411 gnus-article-save-directory)))
3413 (string-equal (file-name-directory default)
3414 (file-name-directory last-file))
3415 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3417 (or last-file default))))
3419 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3420 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3421 If variable `gnus-use-long-file-name' is non-nil, it is
3422 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3425 (concat (if (gnus-use-long-file-name 'not-save)
3427 (gnus-newsgroup-directory-form newsgroup))
3428 "/" (int-to-string (mail-header-number headers)))
3429 gnus-article-save-directory)))
3431 (string-equal (file-name-directory default)
3432 (file-name-directory last-file))
3433 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3435 (or last-file default))))
3437 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3438 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3439 If variable `gnus-use-long-file-name' is non-nil, it is
3440 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3443 (if (gnus-use-long-file-name 'not-save)
3446 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3448 gnus-article-save-directory)))
3450 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3451 "Generate file name from sender."
3452 (let ((from (mail-header-from headers)))
3454 (if (and from (string-match "\\([^ <]+\\)@" from))
3455 (match-string 1 from)
3457 gnus-article-save-directory)))
3459 (defun article-verify-x-pgp-sig ()
3462 (if (gnus-buffer-live-p gnus-original-article-buffer)
3463 (let ((sig (with-current-buffer gnus-original-article-buffer
3464 (gnus-fetch-field "X-PGP-Sig")))
3468 (mml2015-clear-verify-function))
3470 (insert-buffer-substring gnus-original-article-buffer)
3471 (setq items (split-string sig))
3472 (message-narrow-to-head)
3473 (let ((inhibit-point-motion-hooks t)
3474 (case-fold-search t))
3475 ;; Don't verify multiple headers.
3476 (setq headers (mapconcat (lambda (header)
3478 (mail-fetch-field header)
3480 (split-string (nth 1 items) ",") "")))
3481 (delete-region (point-min) (point-max))
3482 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3483 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3488 (if (looking-at "^-")
3491 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3492 (insert "Version: " (car items) "\n\n")
3493 (insert (mapconcat 'identity (cddr items) "\n"))
3494 (insert "\n-----END PGP SIGNATURE-----\n")
3495 (let ((mm-security-handle (list (format "multipart/signed"))))
3496 (mml2015-clean-buffer)
3497 (let ((coding-system-for-write (or gnus-newsgroup-charset
3499 (funcall (mml2015-clear-verify-function)))
3501 (or (mm-handle-multipart-ctl-parameter
3502 mm-security-handle 'gnus-details)
3503 (mm-handle-multipart-ctl-parameter
3504 mm-security-handle 'gnus-info)))))
3506 (let ((inhibit-read-only t) bface eface)
3508 (message-narrow-to-head)
3509 (goto-char (point-max))
3511 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3512 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3513 (message-remove-header "X-Gnus-PGP-Verify")
3514 (if (re-search-forward "^X-PGP-Sig:" nil t)
3516 (goto-char (point-max)))
3517 (narrow-to-region (point) (point))
3518 (insert "X-Gnus-PGP-Verify: " info "\n")
3519 (goto-char (point-min))
3522 (if (not (looking-at "^[ \t]"))
3526 (goto-char (point-min))
3527 (when (looking-at "\\([^:]+\\): *")
3528 (put-text-property (match-beginning 1) (1+ (match-end 1))
3530 (put-text-property (match-end 0) (point-max)
3531 'face eface)))))))))
3533 (defun article-verify-cancel-lock ()
3534 "Verify Cancel-Lock header."
3536 (if (gnus-buffer-live-p gnus-original-article-buffer)
3537 (canlock-verify gnus-original-article-buffer)))
3544 (setq afunc (car func)
3547 gfunc (intern (format "gnus-%s" func))))
3549 (when (fboundp afunc)
3550 `(lambda (&optional interactive &rest args)
3551 ,(documentation afunc t)
3552 (interactive (list t))
3554 (set-buffer gnus-article-buffer)
3556 (call-interactively ',afunc)
3557 (apply ',afunc args))))))))
3558 '(article-hide-headers
3559 article-verify-x-pgp-sig
3560 article-verify-cancel-lock
3561 article-hide-boring-headers
3562 article-treat-overstrike
3563 article-fill-long-lines
3564 article-capitalize-sentences
3566 article-remove-leading-whitespace
3567 article-display-x-face
3568 article-display-face
3569 article-de-quoted-unreadable
3570 article-de-base64-unreadable
3573 article-unsplit-urls
3574 article-hide-list-identifiers
3575 article-strip-banner
3578 article-hide-signature
3579 article-strip-headers-in-body
3580 article-remove-trailing-blank-lines
3581 article-strip-leading-blank-lines
3582 article-strip-multiple-blank-lines
3583 article-strip-leading-space
3584 article-strip-trailing-space
3585 article-strip-blank-lines
3586 article-strip-all-blank-lines
3588 article-date-english
3589 article-date-iso8601
3590 article-date-original
3592 article-decode-mime-words
3593 article-decode-charset
3594 article-decode-encoded-words
3598 article-treat-dumbquotes
3599 article-normalize-headers
3600 ;; (article-show-all . gnus-article-show-all-headers)
3604 ;;; Gnus article mode
3607 (put 'gnus-article-mode 'mode-class 'special)
3609 (set-keymap-parent gnus-article-mode-map widget-keymap)
3611 (gnus-define-keys gnus-article-mode-map
3612 " " gnus-article-goto-next-page
3613 "\177" gnus-article-goto-prev-page
3614 [delete] gnus-article-goto-prev-page
3615 [backspace] gnus-article-goto-prev-page
3616 "\C-c^" gnus-article-refer-article
3617 "h" gnus-article-show-summary
3618 "s" gnus-article-show-summary
3619 "\C-c\C-m" gnus-article-mail
3620 "?" gnus-article-describe-briefly
3621 "e" gnus-summary-edit-article
3622 "<" beginning-of-buffer
3624 "\C-c\C-i" gnus-info-find-node
3626 "R" gnus-article-reply-with-original
3627 "F" gnus-article-followup-with-original
3628 "\C-hk" gnus-article-describe-key
3629 "\C-hc" gnus-article-describe-key-briefly
3631 "\C-d" gnus-article-read-summary-keys
3632 "\M-*" gnus-article-read-summary-keys
3633 "\M-#" gnus-article-read-summary-keys
3634 "\M-^" gnus-article-read-summary-keys
3635 "\M-g" gnus-article-read-summary-keys)
3637 (substitute-key-definition
3638 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3640 (defun gnus-article-make-menu-bar ()
3641 (unless (boundp 'gnus-article-commands-menu)
3642 (gnus-summary-make-menu-bar))
3643 (gnus-turn-off-edit-menu 'article)
3644 (unless (boundp 'gnus-article-article-menu)
3646 gnus-article-article-menu gnus-article-mode-map ""
3648 ["Scroll forwards" gnus-article-goto-next-page t]
3649 ["Scroll backwards" gnus-article-goto-prev-page t]
3650 ["Show summary" gnus-article-show-summary t]
3651 ["Fetch Message-ID at point" gnus-article-refer-article t]
3652 ["Mail to address at point" gnus-article-mail t]
3653 ["Send a bug report" gnus-bug t]))
3656 gnus-article-treatment-menu gnus-article-mode-map ""
3657 ;; Fixme: this should use :active (and maybe :visible).
3659 ["Hide headers" gnus-article-hide-headers t]
3660 ["Hide signature" gnus-article-hide-signature t]
3661 ["Hide citation" gnus-article-hide-citation t]
3662 ["Treat overstrike" gnus-article-treat-overstrike t]
3663 ["Remove carriage return" gnus-article-remove-cr t]
3664 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3665 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3666 ["Remove base64" gnus-article-de-base64-unreadable t]
3667 ["Treat html" gnus-article-wash-html t]
3668 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3669 ["Decode HZ" gnus-article-decode-HZ t]))
3671 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3673 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3675 (gnus-run-hooks 'gnus-article-menu-hook)))
3677 (defun gnus-article-mode ()
3678 "Major mode for displaying an article.
3680 All normal editing commands are switched off.
3682 The following commands are available in addition to all summary mode
3684 \\<gnus-article-mode-map>
3685 \\[gnus-article-next-page]\t Scroll the article one page forwards
3686 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3687 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3688 \\[gnus-article-show-summary]\t Display the summary buffer
3689 \\[gnus-article-mail]\t Send a reply to the address near point
3690 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3691 \\[gnus-info-find-node]\t Go to the Gnus info node"
3693 (gnus-simplify-mode-line)
3694 (setq mode-name "Article")
3695 (setq major-mode 'gnus-article-mode)
3696 (make-local-variable 'minor-mode-alist)
3697 (use-local-map gnus-article-mode-map)
3698 (when (gnus-visual-p 'article-menu 'menu)
3699 (gnus-article-make-menu-bar)
3700 (when gnus-summary-tool-bar-map
3701 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3702 (gnus-update-format-specifications nil 'article-mode)
3703 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3704 (set (make-local-variable 'gnus-page-broken) nil)
3705 (make-local-variable 'gnus-button-marker-list)
3706 (make-local-variable 'gnus-article-current-summary)
3707 (make-local-variable 'gnus-article-mime-handles)
3708 (make-local-variable 'gnus-article-decoded-p)
3709 (make-local-variable 'gnus-article-mime-handle-alist)
3710 (make-local-variable 'gnus-article-wash-types)
3711 (make-local-variable 'gnus-article-image-alist)
3712 (make-local-variable 'gnus-article-charset)
3713 (make-local-variable 'gnus-article-ignored-charsets)
3714 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3715 (set (make-local-variable 'show-nonbreak-escape) nil)
3716 (gnus-set-default-directory)
3717 (buffer-disable-undo)
3718 (setq buffer-read-only t)
3719 (set-syntax-table gnus-article-mode-syntax-table)
3720 (mm-enable-multibyte)
3721 (gnus-run-hooks 'gnus-article-mode-hook))
3723 (defun gnus-article-setup-buffer ()
3724 "Initialize the article buffer."
3725 (let* ((name (if gnus-single-article-buffer "*Article*"
3726 (concat "*Article " gnus-newsgroup-name "*")))
3728 (progn (string-match "\\*Article" name)
3729 (concat " *Original Article"
3730 (substring name (match-end 0))))))
3731 (setq gnus-article-buffer name)
3732 (setq gnus-original-article-buffer original)
3733 (setq gnus-article-mime-handle-alist nil)
3734 ;; This might be a variable local to the summary buffer.
3735 (unless gnus-single-article-buffer
3737 (set-buffer gnus-summary-buffer)
3738 (setq gnus-article-buffer name)
3739 (setq gnus-original-article-buffer original)
3740 (gnus-set-global-variables)))
3741 (gnus-article-setup-highlight-words)
3742 ;; Init original article buffer.
3744 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3745 (mm-enable-multibyte)
3746 (setq major-mode 'gnus-original-article-mode)
3747 (make-local-variable 'gnus-original-article))
3748 (if (and (get-buffer name)
3749 (with-current-buffer name
3750 (if gnus-article-edit-mode
3751 (if (y-or-n-p "Article mode edit in progress; discard? ")
3753 (set-buffer-modified-p nil)
3754 (gnus-kill-buffer name)
3757 (error "Action aborted"))
3761 (set (make-local-variable 'gnus-article-edit-mode) nil)
3762 (when gnus-article-mime-handles
3763 (mm-destroy-parts gnus-article-mime-handles)
3764 (setq gnus-article-mime-handles nil))
3765 ;; Set it to nil in article-buffer!
3766 (setq gnus-article-mime-handle-alist nil)
3767 (buffer-disable-undo)
3768 (setq buffer-read-only t)
3769 ;; This list just keeps growing if we don't reset it.
3770 (setq gnus-button-marker-list nil)
3771 (unless (eq major-mode 'gnus-article-mode)
3772 (gnus-article-mode))
3775 (set-buffer (gnus-get-buffer-create name))
3777 (make-local-variable 'gnus-summary-buffer)
3778 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3779 (current-buffer)))))
3781 ;; Set article window start at LINE, where LINE is the number of lines
3782 ;; from the head of the article.
3783 (defun gnus-article-set-window-start (&optional line)
3785 (gnus-get-buffer-window gnus-article-buffer t)
3787 (set-buffer gnus-article-buffer)
3788 (goto-char (point-min))
3791 (gnus-message 6 "Moved to bookmark")
3792 (search-forward "\n\n" nil t)
3796 (defun gnus-article-prepare (article &optional all-headers header)
3797 "Prepare ARTICLE in article mode buffer.
3798 ARTICLE should either be an article number or a Message-ID.
3799 If ARTICLE is an id, HEADER should be the article headers.
3800 If ALL-HEADERS is non-nil, no headers are hidden."
3802 ;; Make sure we start in a summary buffer.
3803 (unless (eq major-mode 'gnus-summary-mode)
3804 (set-buffer gnus-summary-buffer))
3805 (setq gnus-summary-buffer (current-buffer))
3806 (let* ((gnus-article (if header (mail-header-number header) article))
3807 (summary-buffer (current-buffer))
3808 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3809 (group gnus-newsgroup-name)
3812 (gnus-article-setup-buffer)
3813 (set-buffer gnus-article-buffer)
3814 ;; Deactivate active regions.
3815 (when (and (boundp 'transient-mark-mode)
3816 transient-mark-mode)
3817 (setq mark-active nil))
3818 (if (not (setq result (let ((inhibit-read-only t))
3819 (gnus-request-article-this-buffer
3821 ;; There is no such article.
3823 (when (and (numberp article)
3824 (not (memq article gnus-newsgroup-sparse)))
3825 (setq gnus-article-current
3826 (cons gnus-newsgroup-name article))
3827 (set-buffer gnus-summary-buffer)
3828 (setq gnus-current-article article)
3829 (if (and (memq article gnus-newsgroup-undownloaded)
3830 (not (gnus-online (gnus-find-method-for-group
3831 gnus-newsgroup-name))))
3833 (gnus-summary-set-agent-mark article)
3834 (message "Message marked for downloading"))
3835 (gnus-summary-mark-article article gnus-canceled-mark)
3836 (unless (memq article gnus-newsgroup-sparse)
3837 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3838 (if (or (eq result 'pseudo)
3839 (eq result 'nneething))
3842 (set-buffer summary-buffer)
3843 (push article gnus-newsgroup-history)
3844 (setq gnus-last-article gnus-current-article
3845 gnus-current-article 0
3846 gnus-current-headers nil
3847 gnus-article-current nil)
3848 (if (eq result 'nneething)
3849 (gnus-configure-windows 'summary)
3850 (gnus-configure-windows 'article))
3851 (gnus-set-global-variables))
3852 (let ((gnus-article-mime-handle-alist-1
3853 gnus-article-mime-handle-alist))
3854 (gnus-set-mode-line 'article)))
3855 ;; The result from the `request' was an actual article -
3856 ;; or at least some text that is now displayed in the
3858 (when (and (numberp article)
3859 (not (eq article gnus-current-article)))
3860 ;; Seems like a new article has been selected.
3861 ;; `gnus-current-article' must be an article number.
3863 (set-buffer summary-buffer)
3864 (push article gnus-newsgroup-history)
3865 (setq gnus-last-article gnus-current-article
3866 gnus-current-article article
3867 gnus-current-headers
3868 (gnus-summary-article-header gnus-current-article)
3869 gnus-article-current
3870 (cons gnus-newsgroup-name gnus-current-article))
3871 (unless (vectorp gnus-current-headers)
3872 (setq gnus-current-headers nil))
3873 (gnus-summary-goto-subject gnus-current-article)
3874 (when (gnus-summary-show-thread)
3875 ;; If the summary buffer really was folded, the
3876 ;; previous goto may not actually have gone to
3877 ;; the right article, but the thread root instead.
3879 (gnus-summary-goto-subject gnus-current-article))
3880 (gnus-run-hooks 'gnus-mark-article-hook)
3881 (gnus-set-mode-line 'summary)
3882 (when (gnus-visual-p 'article-highlight 'highlight)
3883 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3884 ;; Set the global newsgroup variables here.
3885 (gnus-set-global-variables)
3886 (setq gnus-have-all-headers
3887 (or all-headers gnus-show-all-headers))))
3889 (gnus-configure-windows 'article))
3890 (when (or (numberp article)
3892 (gnus-article-prepare-display)
3894 (goto-char (point-min))
3895 (when gnus-break-pages
3896 (gnus-narrow-to-page)))
3897 (let ((gnus-article-mime-handle-alist-1
3898 gnus-article-mime-handle-alist))
3899 (gnus-set-mode-line 'article))
3903 (set-window-point (get-buffer-window (current-buffer)) (point))
3904 (gnus-configure-windows 'article)
3908 (defun gnus-article-prepare-display ()
3909 "Make the current buffer look like a nice article."
3910 ;; Hooks for getting information from the article.
3911 ;; This hook must be called before being narrowed.
3912 (let ((gnus-article-buffer (current-buffer))
3914 (inhibit-read-only t))
3915 (unless (eq major-mode 'gnus-article-mode)
3916 (gnus-article-mode))
3917 (setq buffer-read-only nil
3918 gnus-article-wash-types nil
3919 gnus-article-image-alist nil)
3920 (gnus-run-hooks 'gnus-tmp-internal-hook)
3921 (when gnus-display-mime-function
3922 (funcall gnus-display-mime-function))
3923 (gnus-run-hooks 'gnus-article-prepare-hook)))
3926 ;;; Gnus MIME viewing functions
3929 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3930 "Format of the MIME buttons.
3932 Valid specifiers include:
3934 %T MIME type, along with additional info
3935 %n The `name' parameter
3936 %d The description, if any
3937 %l The length of the encoded part
3938 %p The part identifier number
3939 %e Dots if the part isn't displayed
3941 General format specifiers can also be used. See Info node
3942 `(gnus)Formatting Variables'.")
3944 (defvar gnus-mime-button-line-format-alist
3945 '((?t gnus-tmp-type ?s)
3946 (?T gnus-tmp-type-long ?s)
3947 (?n gnus-tmp-name ?s)
3948 (?d gnus-tmp-description ?s)
3950 (?l gnus-tmp-length ?d)
3951 (?e gnus-tmp-dots ?s)))
3953 (defvar gnus-mime-button-commands
3954 '((gnus-article-press-button "\r" "Toggle Display")
3955 (gnus-mime-view-part "v" "View Interactively...")
3956 (gnus-mime-view-part-as-type "t" "View As Type...")
3957 (gnus-mime-view-part-as-charset "C" "View As charset...")
3958 (gnus-mime-save-part "o" "Save...")
3959 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3960 (gnus-mime-delete-part "d" "Delete part")
3961 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3962 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3963 (gnus-mime-view-part-internally "E" "View Internally")
3964 (gnus-mime-view-part-externally "e" "View Externally")
3965 (gnus-mime-print-part "p" "Print")
3966 (gnus-mime-pipe-part "|" "Pipe To Command...")
3967 (gnus-mime-action-on-part "." "Take action on the part...")))
3969 (defun gnus-article-mime-part-status ()
3970 (if gnus-article-mime-handle-alist-1
3971 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3973 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3976 (defvar gnus-mime-button-map
3977 (let ((map (make-sparse-keymap)))
3978 (unless (>= (string-to-number emacs-version) 21)
3979 ;; XEmacs doesn't care.
3980 (set-keymap-parent map gnus-article-mode-map))
3981 (define-key map gnus-mouse-2 'gnus-article-push-button)
3982 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3983 (dolist (c gnus-mime-button-commands)
3984 (define-key map (cadr c) (car c)))
3988 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
3990 ,@(mapcar (lambda (c)
3991 (vector (caddr c) (car c) :enable t))
3992 gnus-mime-button-commands)))
3995 (define-compiler-macro popup-menu (&whole form
3996 menu &optional position prefix)
3997 (if (and (fboundp 'popup-menu)
3998 (not (memq 'popup-menu (assoc "lmenu" load-history))))
4000 ;; Gnus is probably running under Emacs 20.
4001 `(let* ((menu (cdr ,menu))
4002 (response (x-popup-menu
4004 (cons "" (mapcar (lambda (c)
4005 (cons (caddr c) (car c)))
4008 (call-interactively (nth 3 (assq response menu))))))))
4010 (defun gnus-mime-button-menu (event prefix)
4011 "Construct a context-sensitive menu of MIME commands."
4012 (interactive "e\nP")
4013 (save-window-excursion
4014 (let ((pos (event-start event)))
4015 (select-window (posn-window pos))
4016 (goto-char (posn-point pos))
4017 (gnus-article-check-buffer)
4018 (popup-menu gnus-mime-button-menu nil prefix))))
4020 (defun gnus-mime-view-all-parts (&optional handles)
4021 "View all the MIME parts."
4023 (save-current-buffer
4024 (set-buffer gnus-article-buffer)
4025 (let ((handles (or handles gnus-article-mime-handles))
4026 (mail-parse-charset gnus-newsgroup-charset)
4027 (mail-parse-ignored-charsets
4028 (with-current-buffer gnus-summary-buffer
4029 gnus-newsgroup-ignored-charsets)))
4031 (mm-remove-parts handles)
4032 (goto-char (point-min))
4033 (or (search-forward "\n\n") (goto-char (point-max)))
4034 (let ((inhibit-read-only t))
4035 (delete-region (point) (point-max))
4036 (mm-display-parts handles))))))
4038 (defun gnus-mime-save-part-and-strip ()
4039 "Save the MIME part under point then replace it with an external body."
4041 (gnus-article-check-buffer)
4042 (when (gnus-group-read-only-p)
4043 (error "The current group does not support deleting of parts"))
4044 (when (mm-complicated-handles gnus-article-mime-handles)
4046 The current article has a complicated MIME structure, giving up..."))
4047 (when (gnus-yes-or-no-p "\
4048 Deleting parts may malfunction or destroy the article; continue? ")
4049 (let* ((data (get-text-property (point) 'gnus-data))
4051 (handles gnus-article-mime-handles))
4052 (setq file (and data (mm-save-part data)))
4054 (with-current-buffer (mm-handle-buffer data)
4056 (insert "Content-Type: " (mm-handle-media-type data))
4057 (mml-insert-parameter-string (cdr (mm-handle-type data))
4060 (insert "Content-ID: " (message-make-message-id) "\n")
4061 (insert "Content-Transfer-Encoding: binary\n")
4064 (cdr (mm-make-handle nil
4065 `("message/external-body"
4066 (access-type . "LOCAL-FILE")
4068 (set-buffer gnus-summary-buffer)
4069 (gnus-article-edit-article
4072 (let ((mail-parse-charset (or gnus-article-charset
4073 ',gnus-newsgroup-charset))
4074 (mail-parse-ignored-charsets
4075 (or gnus-article-ignored-charsets
4076 ',gnus-newsgroup-ignored-charsets))
4077 (mbl mml-buffer-list))
4078 (setq mml-buffer-list nil)
4079 (insert-buffer gnus-original-article-buffer)
4080 (mime-to-mml ',handles)
4081 (setq gnus-article-mime-handles nil)
4082 (let ((mbl1 mml-buffer-list))
4083 (setq mml-buffer-list mbl)
4084 (set (make-local-variable 'mml-buffer-list) mbl1))
4085 (gnus-make-local-hook 'kill-buffer-hook)
4086 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4087 `(lambda (no-highlight)
4088 (let ((mail-parse-charset (or gnus-article-charset
4089 ',gnus-newsgroup-charset))
4090 (message-options message-options)
4091 (message-options-set-recipient)
4092 (mail-parse-ignored-charsets
4093 (or gnus-article-ignored-charsets
4094 ',gnus-newsgroup-ignored-charsets)))
4096 (mml-destroy-buffers)
4097 (remove-hook 'kill-buffer-hook
4098 'mml-destroy-buffers t)
4099 (kill-local-variable 'mml-buffer-list))
4100 (gnus-summary-edit-article-done
4101 ,(or (mail-header-references gnus-current-headers) "")
4102 ,(gnus-group-read-only-p)
4103 ,gnus-summary-buffer no-highlight)))))))
4105 (defun gnus-mime-delete-part ()
4106 "Delete the MIME part under point.
4107 Replace it with some information about the removed part."
4109 (gnus-article-check-buffer)
4110 (when (gnus-group-read-only-p)
4111 (error "The current group does not support deleting of parts"))
4112 (when (mm-complicated-handles gnus-article-mime-handles)
4114 The current article has a complicated MIME structure, giving up..."))
4115 (when (gnus-yes-or-no-p "\
4116 Deleting parts may malfunction or destroy the article; continue? ")
4117 (let* ((data (get-text-property (point) 'gnus-data))
4118 (handles gnus-article-mime-handles)
4122 (mail-decode-encoded-word-string (or (mm-handle-description data)
4125 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4127 (type (mm-handle-media-type data)))
4129 (error "No MIME part under point"))
4130 (with-current-buffer (mm-handle-buffer data)
4131 (let ((bsize (format "%s" (buffer-size))))
4136 "| The following attachment has been deleted:\n"
4138 "| Type: " type "\n"
4139 "| Filename: " filename "\n"
4140 "| Size (encoded): " bsize " Byte\n"
4141 "| Description: " description "\n"
4144 (cdr (mm-make-handle
4145 nil `("text/plain") nil nil
4147 (format "Deleted attachment (%s bytes)" bsize))))))
4148 (set-buffer gnus-summary-buffer)
4149 ;; FIXME: maybe some of the following code (borrowed from
4150 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4151 (gnus-article-edit-article
4154 (let ((mail-parse-charset (or gnus-article-charset
4155 ',gnus-newsgroup-charset))
4156 (mail-parse-ignored-charsets
4157 (or gnus-article-ignored-charsets
4158 ',gnus-newsgroup-ignored-charsets))
4159 (mbl mml-buffer-list))
4160 (setq mml-buffer-list nil)
4161 (insert-buffer gnus-original-article-buffer)
4162 (mime-to-mml ',handles)
4163 (setq gnus-article-mime-handles nil)
4164 (let ((mbl1 mml-buffer-list))
4165 (setq mml-buffer-list mbl)
4166 (set (make-local-variable 'mml-buffer-list) mbl1))
4167 (gnus-make-local-hook 'kill-buffer-hook)
4168 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4169 `(lambda (no-highlight)
4170 (let ((mail-parse-charset (or gnus-article-charset
4171 ',gnus-newsgroup-charset))
4172 (message-options message-options)
4173 (message-options-set-recipient)
4174 (mail-parse-ignored-charsets
4175 (or gnus-article-ignored-charsets
4176 ',gnus-newsgroup-ignored-charsets)))
4178 (mml-destroy-buffers)
4179 (remove-hook 'kill-buffer-hook
4180 'mml-destroy-buffers t)
4181 (kill-local-variable 'mml-buffer-list))
4182 (gnus-summary-edit-article-done
4183 ,(or (mail-header-references gnus-current-headers) "")
4184 ,(gnus-group-read-only-p)
4185 ,gnus-summary-buffer no-highlight)))))
4186 ;; Not in `gnus-mime-save-part-and-strip':
4187 (gnus-article-edit-done)
4188 (gnus-summary-expand-window)
4189 (gnus-summary-show-article))
4191 (defun gnus-mime-save-part ()
4192 "Save the MIME part under point."
4194 (gnus-article-check-buffer)
4195 (let ((data (get-text-property (point) 'gnus-data)))
4197 (mm-save-part data))))
4199 (defun gnus-mime-pipe-part ()
4200 "Pipe the MIME part under point to a process."
4202 (gnus-article-check-buffer)
4203 (let ((data (get-text-property (point) 'gnus-data)))
4205 (mm-pipe-part data))))
4207 (defun gnus-mime-view-part ()
4208 "Interactively choose a viewing method for the MIME part under point."
4210 (gnus-article-check-buffer)
4211 (let ((data (get-text-property (point) 'gnus-data)))
4213 (setq gnus-article-mime-handles
4215 gnus-article-mime-handles (setq data (copy-sequence data))))
4216 (mm-interactively-view-part data))))
4218 (defun gnus-mime-view-part-as-type-internal ()
4219 (gnus-article-check-buffer)
4220 (let* ((name (mail-content-type-get
4221 (mm-handle-type (get-text-property (point) 'gnus-data))
4223 (def-type (and name (mm-default-file-encoding name))))
4224 (and def-type (cons def-type 0))))
4226 (defun gnus-mime-view-part-as-type (&optional mime-type)
4227 "Choose a MIME media type, and view the part as such."
4230 (setq mime-type (completing-read
4231 "View as MIME type: "
4232 (mapcar #'list (mailcap-mime-types))
4234 (gnus-mime-view-part-as-type-internal))))
4235 (gnus-article-check-buffer)
4236 (let ((handle (get-text-property (point) 'gnus-data)))
4239 (mm-make-handle (mm-handle-buffer handle)
4240 (cons mime-type (cdr (mm-handle-type handle)))
4241 (mm-handle-encoding handle)
4242 (mm-handle-undisplayer handle)
4243 (mm-handle-disposition handle)
4244 (mm-handle-description handle)
4246 (mm-handle-id handle)))
4247 (setq gnus-article-mime-handles
4248 (mm-merge-handles gnus-article-mime-handles handle))
4249 (gnus-mm-display-part handle))))
4252 (require 'jka-compr))
4254 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4255 ;; emacs can do that itself.
4257 (defun gnus-mime-jka-compr-maybe-uncompress ()
4258 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4259 The uncompress method used is derived from `buffer-file-name'."
4260 (when (and (fboundp 'jka-compr-installed-p)
4261 (jka-compr-installed-p))
4262 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4264 (let ((basename (file-name-nondirectory buffer-file-name))
4265 (args (jka-compr-info-uncompress-args info))
4266 (prog (jka-compr-info-uncompress-program info))
4267 (message (jka-compr-info-uncompress-message info))
4268 (err-file (jka-compr-make-temp-name)))
4270 (message "%s %s..." message basename))
4272 (unless (memq (apply 'call-process-region
4273 (point-min) (point-max)
4275 t (list t err-file) nil
4277 jka-compr-acceptable-retval-list)
4278 (jka-compr-error prog args basename message err-file))
4279 (jka-compr-delete-temp-file err-file)))))))
4281 (defun gnus-mime-copy-part (&optional handle)
4282 "Put the MIME part under point into a new buffer.
4283 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4286 (gnus-article-check-buffer)
4287 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4288 (contents (and handle (mm-get-part handle)))
4290 (file-name-nondirectory
4292 (mail-content-type-get (mm-handle-type handle) 'name)
4293 (mail-content-type-get (mm-handle-disposition handle)
4296 (buffer (and base (generate-new-buffer base))))
4298 (switch-to-buffer buffer)
4300 ;; We do it this way to make `normal-mode' set the appropriate mode.
4303 (setq buffer-file-name (expand-file-name base))
4304 (gnus-mime-jka-compr-maybe-uncompress)
4306 (setq buffer-file-name nil))
4307 (goto-char (point-min)))))
4309 (defun gnus-mime-print-part (&optional handle filename)
4310 "Print the MIME part under point."
4311 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4312 (gnus-article-check-buffer)
4313 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4314 (contents (and handle (mm-get-part handle)))
4315 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4316 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4321 (mm-save-part-to-file handle file)
4322 (call-process shell-file-name nil
4323 (generate-new-buffer " *mm*")
4325 shell-command-switch
4327 printer file (mm-handle-type handle))))
4331 (gnus-print-buffer))
4332 (ps-despool filename)))))
4334 (defun gnus-mime-inline-part (&optional handle arg)
4335 "Insert the MIME part under point into the current buffer."
4336 (interactive (list nil current-prefix-arg))
4337 (gnus-article-check-buffer)
4338 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4341 (inhibit-read-only t))
4343 (if (and (not arg) (mm-handle-undisplayer handle))
4344 (mm-remove-part handle)
4345 (setq contents (mm-get-part handle))
4348 (setq charset (or (mail-content-type-get
4349 (mm-handle-type handle) 'charset)
4350 gnus-newsgroup-charset)))
4352 (if (mm-handle-undisplayer handle)
4353 (mm-remove-part handle))
4356 gnus-summary-show-article-charset-alist))
4357 (mm-read-coding-system "Charset: "))))
4359 (if (mm-handle-undisplayer handle)
4360 (mm-remove-part handle))
4362 (if (fboundp 'string-to-multibyte)
4363 (string-to-multibyte contents)
4365 (lambda (ch) (mm-string-as-multibyte (char-to-string ch)))
4368 (mm-insert-inline handle
4370 (setq charset (mm-charset-to-coding-system
4372 (not (eq charset 'ascii)))
4373 (mm-decode-coding-string contents charset)
4377 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4378 "Insert the MIME part under point into the current buffer using the
4380 (interactive (list nil current-prefix-arg))
4381 (gnus-article-check-buffer)
4382 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4385 (inhibit-read-only t))
4387 (if (mm-handle-undisplayer handle)
4388 (mm-remove-part handle))
4389 (let ((gnus-newsgroup-charset
4391 gnus-summary-show-article-charset-alist))
4392 (mm-read-coding-system "Charset: ")))
4393 (gnus-newsgroup-ignored-charsets 'gnus-all))
4394 (gnus-article-press-button)))))
4396 (defun gnus-mime-view-part-externally (&optional handle)
4397 "View the MIME part under point with an external viewer."
4399 (gnus-article-check-buffer)
4400 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4401 (mm-user-display-methods nil)
4402 (mm-inlined-types nil)
4403 (mail-parse-charset gnus-newsgroup-charset)
4404 (mail-parse-ignored-charsets
4405 (save-excursion (set-buffer gnus-summary-buffer)
4406 gnus-newsgroup-ignored-charsets)))
4408 (if (mm-handle-undisplayer handle)
4409 (mm-remove-part handle)
4410 (mm-display-part handle)))))
4412 (defun gnus-mime-view-part-internally (&optional handle)
4413 "View the MIME part under point with an internal viewer.
4414 If no internal viewer is available, use an external viewer."
4416 (gnus-article-check-buffer)
4417 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4418 (mm-inlined-types '(".*"))
4419 (mm-inline-large-images t)
4420 (mail-parse-charset gnus-newsgroup-charset)
4421 (mail-parse-ignored-charsets
4422 (save-excursion (set-buffer gnus-summary-buffer)
4423 gnus-newsgroup-ignored-charsets))
4424 (inhibit-read-only t))
4426 (if (mm-handle-undisplayer handle)
4427 (mm-remove-part handle)
4428 (mm-display-part handle)))))
4430 (defun gnus-mime-action-on-part (&optional action)
4431 "Do something with the MIME attachment at \(point\)."
4433 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4434 (gnus-article-check-buffer)
4435 (let ((action-pair (assoc action gnus-mime-action-alist)))
4437 (funcall (cdr action-pair)))))
4439 (defun gnus-article-part-wrapper (n function)
4440 (save-current-buffer
4441 (set-buffer gnus-article-buffer)
4442 (when (> n (length gnus-article-mime-handle-alist))
4443 (error "No such part"))
4444 (gnus-article-goto-part n)
4445 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4446 (funcall function handle))))
4448 (defun gnus-article-pipe-part (n)
4449 "Pipe MIME part N, which is the numerical prefix."
4451 (gnus-article-part-wrapper n 'mm-pipe-part))
4453 (defun gnus-article-save-part (n)
4454 "Save MIME part N, which is the numerical prefix."
4456 (gnus-article-part-wrapper n 'mm-save-part))
4458 (defun gnus-article-interactively-view-part (n)
4459 "View MIME part N interactively, which is the numerical prefix."
4461 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4463 (defun gnus-article-copy-part (n)
4464 "Copy MIME part N, which is the numerical prefix."
4466 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4468 (defun gnus-article-view-part-as-charset (n)
4469 "View MIME part N using a specified charset.
4470 N is the numerical prefix."
4472 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4474 (defun gnus-article-view-part-externally (n)
4475 "View MIME part N externally, which is the numerical prefix."
4477 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4479 (defun gnus-article-inline-part (n)
4480 "Inline MIME part N, which is the numerical prefix."
4482 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4484 (defun gnus-article-mime-match-handle-first (condition)
4486 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4487 (while (setq ihandle (pop alist))
4489 ((functionp condition)
4490 (funcall condition (cdr ihandle)))
4491 ((eq condition 'undisplayed)
4492 (not (or (mm-handle-undisplayer (cdr ihandle))
4493 (equal (mm-handle-media-type (cdr ihandle))
4494 "multipart/alternative"))))
4495 ((eq condition 'undisplayed-alternative)
4496 (not (mm-handle-undisplayer (cdr ihandle))))
4498 (gnus-article-goto-part (car ihandle))
4499 (or (not n) (< (car ihandle) n)))
4500 (setq n (car ihandle))))
4504 (defun gnus-article-view-part (&optional n)
4505 "View MIME part N, which is the numerical prefix."
4507 (save-current-buffer
4508 (set-buffer gnus-article-buffer)
4509 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4510 gnus-article-mime-match-handle-function)))
4511 (when (> n (length gnus-article-mime-handle-alist))
4512 (error "No such part"))
4513 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4514 (when (gnus-article-goto-part n)
4515 (if (equal (car handle) "multipart/alternative")
4516 (gnus-article-press-button)
4517 (when (eq (gnus-mm-display-part handle) 'internal)
4518 (gnus-set-window-start)))))))
4520 (defsubst gnus-article-mime-total-parts ()
4521 (if (bufferp (car gnus-article-mime-handles))
4523 (1- (length gnus-article-mime-handles))))
4525 (defun gnus-mm-display-part (handle)
4526 "Display HANDLE and fix MIME button."
4527 (let ((id (get-text-property (point) 'gnus-part))
4529 (inhibit-read-only t))
4532 (let ((window (selected-window))
4533 (mail-parse-charset gnus-newsgroup-charset)
4534 (mail-parse-ignored-charsets
4535 (if (gnus-buffer-live-p gnus-summary-buffer)
4537 (set-buffer gnus-summary-buffer)
4538 gnus-newsgroup-ignored-charsets)
4542 (let ((win (gnus-get-buffer-window (current-buffer) t))
4545 (select-window win))
4548 (if (mm-handle-displayed-p handle)
4549 ;; This will remove the part.
4550 (mm-display-part handle)
4552 (narrow-to-region (point)
4553 (if (eobp) (point) (1+ (point))))
4554 (mm-display-part handle)
4555 ;; We narrow to the part itself and
4556 ;; then call the treatment functions.
4557 (goto-char (point-min))
4559 (narrow-to-region (point) (point-max))
4562 (gnus-article-mime-total-parts)
4563 (mm-handle-media-type handle)))))
4564 (if (window-live-p window)
4565 (select-window window)))))
4568 (gnus-insert-mime-button
4569 handle id (list (mm-handle-displayed-p handle)))
4570 (goto-char point))))
4572 (defun gnus-article-goto-part (n)
4573 "Go to MIME part N."
4574 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4576 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4577 (let ((gnus-tmp-name
4578 (or (mail-content-type-get (mm-handle-type handle) 'name)
4579 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4580 (mail-content-type-get (mm-handle-type handle) 'url)
4582 (gnus-tmp-type (mm-handle-media-type handle))
4583 (gnus-tmp-description
4584 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4587 (if (if displayed (car displayed)
4588 (mm-handle-displayed-p handle))
4590 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4592 gnus-tmp-type-long b e)
4593 (when (string-match ".*/" gnus-tmp-name)
4594 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4595 (setq gnus-tmp-type-long (concat gnus-tmp-type
4596 (and (not (equal gnus-tmp-name ""))
4597 (concat "; " gnus-tmp-name))))
4598 (unless (equal gnus-tmp-description "")
4599 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4604 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4605 `(,@(gnus-local-map-property gnus-mime-button-map)
4606 gnus-callback gnus-mm-display-part
4607 gnus-part ,gnus-tmp-id
4608 article-type annotation
4611 ;; Exclude a newline.
4614 (widget-convert-button
4617 :action 'gnus-widget-press-button
4618 :button-keymap gnus-mime-button-map
4620 (lambda (widget/window &optional overlay pos)
4621 ;; Needed to properly clear the message due to a bug in
4622 ;; wid-edit (XEmacs only).
4623 (if (boundp 'help-echo-owns-message)
4624 (setq help-echo-owns-message t))
4626 "%S: %s the MIME part; %S: more options"
4627 (aref gnus-mouse-2 0)
4628 ;; XEmacs will get a single widget arg; Emacs 21 will get
4629 ;; window, overlay, position.
4630 (if (mm-handle-displayed-p
4632 (with-current-buffer (gnus-overlay-buffer overlay)
4633 (widget-get (widget-at (gnus-overlay-start overlay))
4635 (widget-get widget/window :mime-handle)))
4637 (aref gnus-down-mouse-3 0))))))
4639 (defun gnus-widget-press-button (elems el)
4640 (goto-char (widget-get elems :from))
4641 (gnus-article-press-button))
4643 (defvar gnus-displaying-mime nil)
4645 (defun gnus-display-mime (&optional ihandles)
4646 "Display the MIME parts."
4648 (save-selected-window
4649 (let ((window (get-buffer-window gnus-article-buffer))
4652 (select-window window)
4653 ;; We have to do this since selecting the window
4654 ;; may change the point. So we set the window point.
4655 (set-window-point window point)))
4656 (let* ((handles (or ihandles
4657 (mm-dissect-buffer nil gnus-article-loose-mime)
4658 (and gnus-article-emulate-mime
4660 (inhibit-read-only t) handle name type b e display)
4661 (when (and (not ihandles)
4662 (not gnus-displaying-mime))
4663 ;; Top-level call; we clean up.
4664 (when gnus-article-mime-handles
4665 (mm-destroy-parts gnus-article-mime-handles)
4666 (setq gnus-article-mime-handle-alist nil));; A trick.
4667 (setq gnus-article-mime-handles handles)
4668 ;; We allow users to glean info from the handles.
4669 (when gnus-article-mime-part-function
4670 (gnus-mime-part-function handles)))
4672 (or (not (stringp (car handles)))
4675 (when (and (not ihandles)
4676 (not gnus-displaying-mime))
4677 ;; Clean up for mime parts.
4679 (delete-region (point) (point-max)))
4680 (let ((gnus-displaying-mime t))
4681 (gnus-mime-display-part handles)))
4684 (narrow-to-region (point) (point-max))
4685 (gnus-treat-article nil 1 1)
4688 ;; Highlight the headers.
4692 (narrow-to-region (point-min) (point))
4693 (gnus-treat-article 'head))))))))
4695 (defcustom gnus-mime-display-multipart-as-mixed nil
4696 "Display \"multipart\" parts as \"multipart/mixed\".
4698 If t, it overrides nil values of
4699 `gnus-mime-display-multipart-alternative-as-mixed' and
4700 `gnus-mime-display-multipart-related-as-mixed'."
4701 :group 'gnus-article-mime
4704 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4705 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4707 :group 'gnus-article-mime
4710 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4711 "Display \"multipart/related\" parts as \"multipart/mixed\".
4713 If displaying \"text/html\" is discouraged \(see
4714 `mm-discouraged-alternatives'\) images or other material inside a
4715 \"multipart/related\" part might be overlooked when this variable is nil."
4717 :group 'gnus-article-mime
4720 (defun gnus-mime-display-part (handle)
4723 ((not (stringp (car handle)))
4724 (gnus-mime-display-single handle))
4725 ;; User-defined multipart
4726 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4727 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4729 ;; multipart/alternative
4730 ((and (equal (car handle) "multipart/alternative")
4731 (not (or gnus-mime-display-multipart-as-mixed
4732 gnus-mime-display-multipart-alternative-as-mixed)))
4733 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4734 (push (cons id handle) gnus-article-mime-handle-alist)
4735 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4736 ;; multipart/related
4737 ((and (equal (car handle) "multipart/related")
4738 (not (or gnus-mime-display-multipart-as-mixed
4739 gnus-mime-display-multipart-related-as-mixed)))
4740 ;;;!!!We should find the start part, but we just default
4741 ;;;!!!to the first part.
4742 ;;(gnus-mime-display-part (cadr handle))
4743 ;;;!!! Most multipart/related is an HTML message plus images.
4744 ;;;!!! Unfortunately we are unable to let W3 display those
4745 ;;;!!! included images, so we just display it as a mixed multipart.
4746 ;;(gnus-mime-display-mixed (cdr handle))
4747 ;;;!!! No, w3 can display everything just fine.
4748 (gnus-mime-display-part (cadr handle)))
4749 ((equal (car handle) "multipart/signed")
4750 (gnus-add-wash-type 'signed)
4751 (gnus-mime-display-security handle))
4752 ((equal (car handle) "multipart/encrypted")
4753 (gnus-add-wash-type 'encrypted)
4754 (gnus-mime-display-security handle))
4755 ;; Other multiparts are handled like multipart/mixed.
4757 (gnus-mime-display-mixed (cdr handle)))))
4759 (defun gnus-mime-part-function (handles)
4760 (if (stringp (car handles))
4761 (mapcar 'gnus-mime-part-function (cdr handles))
4762 (funcall gnus-article-mime-part-function handles)))
4764 (defun gnus-mime-display-mixed (handles)
4765 (mapcar 'gnus-mime-display-part handles))
4767 (defun gnus-mime-display-single (handle)
4768 (let ((type (mm-handle-media-type handle))
4769 (ignored gnus-ignored-mime-types)
4776 (when (string-match (pop ignored) type)
4777 (throw 'ignored nil)))
4778 (if (and (setq not-attachment
4779 (and (not (mm-inline-override-p handle))
4780 (or (not (mm-handle-disposition handle))
4781 (equal (car (mm-handle-disposition handle))
4783 (mm-attachment-override-p handle))))
4784 (mm-automatic-display-p handle)
4786 (mm-inlinable-p handle)
4787 (mm-inlined-p handle))
4788 (mm-automatic-external-display-p type)))
4790 (when (equal (mm-handle-media-supertype handle) "text")
4792 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4794 (push (cons id handle) gnus-article-mime-handle-alist)
4795 (when (or (not display)
4796 (not (gnus-unbuttonized-mime-type-p type)))
4797 ;(gnus-article-insert-newline)
4798 (gnus-insert-mime-button
4799 handle id (list (or display (and not-attachment text))))
4800 (gnus-article-insert-newline)
4801 ;(gnus-article-insert-newline)
4802 ;; Remember modify the number of forward lines.
4810 (let ((mail-parse-charset gnus-newsgroup-charset)
4811 (mail-parse-ignored-charsets
4812 (save-excursion (condition-case ()
4813 (set-buffer gnus-summary-buffer)
4815 gnus-newsgroup-ignored-charsets)))
4816 (mm-display-part handle t))
4817 (goto-char (point-max)))
4818 ((and text not-attachment)
4822 (gnus-article-insert-newline)
4823 (mm-insert-inline handle (mm-get-part handle))
4824 (goto-char (point-max))))
4828 (narrow-to-region beg (point))
4831 (gnus-article-mime-total-parts)
4832 (mm-handle-media-type handle)))))))))
4834 (defun gnus-unbuttonized-mime-type-p (type)
4835 "Say whether TYPE is to be unbuttonized."
4836 (unless gnus-inhibit-mime-unbuttonizing
4838 (let ((types gnus-unbuttonized-mime-types))
4840 (when (string-match (pop types) type)
4841 (throw 'found t)))))
4843 (let ((types gnus-buttonized-mime-types))
4845 (when (string-match (pop types) type)
4846 (throw 'found t)))))))))
4848 (defun gnus-article-insert-newline ()
4849 "Insert a newline, but mark it as undeletable."
4850 (gnus-put-text-property
4851 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4853 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4854 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4857 handle (inhibit-read-only t) from props begend not-pref)
4858 (save-window-excursion
4861 (narrow-to-region (car ibegend)
4864 (goto-char (car ibegend))
4867 (delete-region (point-min) (point-max))
4868 (mm-remove-parts handles))
4869 (setq begend (list (point-marker)))
4871 (unless (setq not-pref (cadr (member preferred ihandles)))
4872 (setq not-pref (car ihandles)))
4875 (not (gnus-unbuttonized-mime-type-p
4876 "multipart/alternative")))
4877 (gnus-add-text-properties
4880 (insert (format "%d. " id))
4884 (unless ,(not ibegend)
4885 (setq gnus-article-mime-handle-alist
4886 ',gnus-article-mime-handle-alist))
4887 (gnus-mime-display-alternative
4888 ',ihandles ',not-pref ',begend ,id))
4889 ,@(gnus-local-map-property gnus-mime-button-map)
4890 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4891 face ,gnus-article-button-face
4894 (widget-convert-button 'link from (point)
4895 :action 'gnus-widget-press-button
4896 :button-keymap gnus-widget-button-keymap)
4898 (while (setq handle (pop handles))
4899 (gnus-add-text-properties
4902 (insert (format "(%c) %-18s"
4903 (if (equal handle preferred) ?* ? )
4904 (mm-handle-media-type handle)))
4908 (unless ,(not ibegend)
4909 (setq gnus-article-mime-handle-alist
4910 ',gnus-article-mime-handle-alist))
4911 (gnus-mime-display-alternative
4912 ',ihandles ',handle ',begend ,id))
4913 ,@(gnus-local-map-property gnus-mime-button-map)
4914 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4915 face ,gnus-article-button-face
4918 (widget-convert-button 'link from (point)
4919 :action 'gnus-widget-press-button
4920 :button-keymap gnus-widget-button-keymap)
4924 (if (stringp (car preferred))
4925 (gnus-display-mime preferred)
4926 (let ((mail-parse-charset gnus-newsgroup-charset)
4927 (mail-parse-ignored-charsets
4928 (save-excursion (set-buffer gnus-summary-buffer)
4929 gnus-newsgroup-ignored-charsets)))
4930 (mm-display-part preferred)
4934 (narrow-to-region (car begend) (point-max))
4936 nil (length gnus-article-mime-handle-alist)
4937 (gnus-article-mime-total-parts)
4938 (mm-handle-media-type handle))))))
4939 (goto-char (point-max))
4940 (setcdr begend (point-marker)))))
4942 (goto-char point))))
4944 (defconst gnus-article-wash-status-strings
4945 (let ((alist '((cite "c" "Possible hidden citation text"
4946 " " "All citation text visible")
4947 (headers "h" "Hidden headers"
4948 " " "All headers visible.")
4949 (pgp "p" "Encrypted or signed message status hidden"
4950 " " "No hidden encryption nor digital signature status")
4951 (signature "s" "Signature has been hidden"
4952 " " "Signature is visible")
4953 (overstrike "o" "Overstrike (^H) characters applied"
4954 " " "No overstrike characters applied")
4955 (emphasis "e" "/*_Emphasis_*/ characters applied"
4956 " " "No /*_emphasis_*/ characters applied")))
4958 (dolist (entry alist result)
4959 (let ((key (nth 0 entry))
4960 (on (copy-sequence (nth 1 entry)))
4961 (on-help (nth 2 entry))
4962 (off (copy-sequence (nth 3 entry)))
4963 (off-help (nth 4 entry)))
4964 (put-text-property 0 1 'help-echo on-help on)
4965 (put-text-property 0 1 'help-echo off-help off)
4966 (push (list key on off) result))))
4967 "Alist of strings describing wash status in the mode line.
4968 Each entry has the form (KEY ON OF), where the KEY is a symbol
4969 representing the particular washing function, ON is the string to use
4970 in the article mode line when the washing function is active, and OFF
4971 is the string to use when it is inactive.")
4973 (defun gnus-article-wash-status-entry (key value)
4974 (let ((entry (assoc key gnus-article-wash-status-strings)))
4975 (if value (nth 1 entry) (nth 2 entry))))
4977 (defun gnus-article-wash-status ()
4978 "Return a string which display status of article washing."
4980 (set-buffer gnus-article-buffer)
4981 (let ((cite (memq 'cite gnus-article-wash-types))
4982 (headers (memq 'headers gnus-article-wash-types))
4983 (boring (memq 'boring-headers gnus-article-wash-types))
4984 (pgp (memq 'pgp gnus-article-wash-types))
4985 (pem (memq 'pem gnus-article-wash-types))
4986 (signed (memq 'signed gnus-article-wash-types))
4987 (encrypted (memq 'encrypted gnus-article-wash-types))
4988 (signature (memq 'signature gnus-article-wash-types))
4989 (overstrike (memq 'overstrike gnus-article-wash-types))
4990 (emphasis (memq 'emphasis gnus-article-wash-types)))
4992 (gnus-article-wash-status-entry 'cite cite)
4993 (gnus-article-wash-status-entry 'headers (or headers boring))
4994 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4995 (gnus-article-wash-status-entry 'signature signature)
4996 (gnus-article-wash-status-entry 'overstrike overstrike)
4997 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4999 (defun gnus-add-wash-type (type)
5000 "Add a washing of TYPE to the current status."
5001 (add-to-list 'gnus-article-wash-types type))
5003 (defun gnus-delete-wash-type (type)
5004 "Add a washing of TYPE to the current status."
5005 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5007 (defun gnus-add-image (category image)
5008 "Add IMAGE of CATEGORY to the list of displayed images."
5009 (let ((entry (assq category gnus-article-image-alist)))
5011 (setq entry (list category))
5012 (push entry gnus-article-image-alist))
5013 (nconc entry (list image))))
5015 (defun gnus-delete-images (category)
5016 "Delete all images in CATEGORY."
5017 (let ((entry (assq category gnus-article-image-alist)))
5018 (dolist (image (cdr entry))
5019 (gnus-remove-image image category))
5020 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5021 (gnus-delete-wash-type category)))
5023 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5025 (defun gnus-article-maybe-hide-headers ()
5026 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5027 Provided for backwards compatibility."
5028 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5029 (not (save-excursion (set-buffer gnus-summary-buffer)
5030 gnus-have-all-headers)))
5031 (not gnus-inhibit-hiding))
5032 (gnus-article-hide-headers)))
5036 (defun gnus-output-to-file (file-name)
5037 "Append the current article to a file named FILE-NAME."
5038 (let ((artbuf (current-buffer)))
5040 (insert-buffer-substring artbuf)
5041 ;; Append newline at end of the buffer as separator, and then
5043 (goto-char (point-max))
5045 (let ((file-name-coding-system nnmail-pathname-coding-system))
5046 (mm-append-to-file (point-min) (point-max) file-name))
5049 (defun gnus-narrow-to-page (&optional arg)
5050 "Narrow the article buffer to a page.
5051 If given a numerical ARG, move forward ARG pages."
5053 (setq arg (if arg (prefix-numeric-value arg) 0))
5055 (set-buffer gnus-article-buffer)
5056 (goto-char (point-min))
5058 ;; Remove any old next/prev buttons.
5059 (when (gnus-visual-p 'page-marker)
5060 (let ((inhibit-read-only t))
5061 (gnus-remove-text-with-property 'gnus-prev)
5062 (gnus-remove-text-with-property 'gnus-next)))
5065 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5067 (re-search-forward page-delimiter nil 'move arg)))
5068 (goto-char (match-end 0))
5070 (goto-char (point-min))
5071 (setq gnus-page-broken
5072 (and (re-search-forward page-delimiter nil t) t))))
5073 (when gnus-page-broken
5076 (if (re-search-forward page-delimiter nil 'move)
5079 (when (and (gnus-visual-p 'page-marker)
5080 (> (point-min) (save-restriction (widen) (point-min))))
5082 (goto-char (point-min))
5083 (gnus-insert-prev-page-button)))
5084 (when (and (gnus-visual-p 'page-marker)
5085 (< (point-max) (save-restriction (widen) (point-max))))
5087 (goto-char (point-max))
5088 (gnus-insert-next-page-button))))))
5090 ;; Article mode commands
5092 (defun gnus-article-goto-next-page ()
5093 "Show the next page of the article."
5095 (when (gnus-article-next-page)
5096 (goto-char (point-min))
5097 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5100 (defun gnus-article-goto-prev-page ()
5101 "Show the previous page of the article."
5104 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5105 (gnus-article-prev-page nil)))
5107 ;; This is cleaner but currently breaks `gnus-pick-mode':
5109 ;; (defun gnus-article-goto-next-page ()
5110 ;; "Show the next page of the article."
5112 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5113 ;; (gnus-summary-next-page)))
5115 ;; (defun gnus-article-goto-prev-page ()
5116 ;; "Show the next page of the article."
5118 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5119 ;; (gnus-summary-prev-page)))
5121 (defun gnus-article-next-page (&optional lines)
5122 "Show the next page of the current article.
5123 If end of article, return non-nil. Otherwise return nil.
5124 Argument LINES specifies lines to be scrolled up."
5126 (move-to-window-line -1)
5129 (and (pos-visible-in-window-p) ;Not continuation line.
5130 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5131 ;; Nothing in this page.
5132 (if (or (not gnus-page-broken)
5137 (eobp)))) ;Real end-of-buffer?
5139 (when gnus-article-over-scroll
5140 (gnus-article-next-page-1 lines))
5142 (gnus-narrow-to-page 1) ;Go to next page.
5144 ;; More in this page.
5145 (gnus-article-next-page-1 lines)
5148 (defun gnus-article-next-page-1 (lines)
5149 (let ((scroll-in-place nil))
5153 ;; Long lines may cause an end-of-buffer error.
5154 (goto-char (point-max)))))
5155 (move-to-window-line 0))
5157 (defun gnus-article-prev-page (&optional lines)
5158 "Show previous page of current article.
5159 Argument LINES specifies lines to be scrolled down."
5161 (move-to-window-line 0)
5162 (if (and gnus-page-broken
5164 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5166 (gnus-narrow-to-page -1) ;Go to previous page.
5167 (goto-char (point-max))
5169 (let ((scroll-in-place nil))
5173 (beginning-of-buffer
5174 (goto-char (point-min))))
5175 (move-to-window-line 0)))))
5177 (defun gnus-article-only-boring-p ()
5178 "Decide whether there is only boring text remaining in the article.
5179 Something \"interesting\" is a word of at least two letters that does
5180 not have a face in `gnus-article-boring-faces'."
5181 (when (and gnus-article-skip-boring
5182 (boundp 'gnus-article-boring-faces)
5183 (symbol-value 'gnus-article-boring-faces))
5186 (while (re-search-forward "\\b\\w\\w" nil t)
5188 (when (not (gnus-intersection
5189 (gnus-faces-at (point))
5190 (symbol-value 'gnus-article-boring-faces)))
5191 (throw 'only-boring nil)))
5192 (throw 'only-boring t)))))
5194 (defun gnus-article-refer-article ()
5195 "Read article specified by message-id around point."
5198 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5199 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5200 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5201 (let ((msg-id (concat "<" (match-string 0) ">")))
5202 (set-buffer gnus-summary-buffer)
5203 (gnus-summary-refer-article msg-id))
5204 (error "No references around point"))))
5206 (defun gnus-article-show-summary ()
5207 "Reconfigure windows to show summary buffer."
5209 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5210 (error "There is no summary buffer for this article buffer")
5211 (gnus-article-set-globals)
5212 (gnus-configure-windows 'article)
5213 (gnus-summary-goto-subject gnus-current-article)
5214 (gnus-summary-position-point)))
5216 (defun gnus-article-describe-briefly ()
5217 "Describe article mode commands briefly."
5219 (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")))
5221 (defun gnus-article-summary-command ()
5222 "Execute the last keystroke in the summary buffer."
5224 (let ((obuf (current-buffer))
5225 (owin (current-window-configuration))
5227 (switch-to-buffer gnus-article-current-summary 'norecord)
5228 (setq func (lookup-key (current-local-map) (this-command-keys)))
5229 (call-interactively func)
5231 (set-window-configuration owin)
5232 (set-window-point (get-buffer-window (current-buffer)) (point))))
5234 (defun gnus-article-summary-command-nosave ()
5235 "Execute the last keystroke in the summary buffer."
5238 (pop-to-buffer gnus-article-current-summary 'norecord)
5239 (setq func (lookup-key (current-local-map) (this-command-keys)))
5240 (call-interactively func)))
5242 (defun gnus-article-check-buffer ()
5243 "Beep if not in an article buffer."
5244 (unless (equal major-mode 'gnus-article-mode)
5245 (error "Command invoked outside of a Gnus article buffer")))
5247 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5248 "Read a summary buffer key sequence and execute it from the article buffer."
5250 (gnus-article-check-buffer)
5252 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5253 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5254 "=" "^" "\M-^" "|"))
5260 '("n" "Gn" "p" "Gp"))
5263 (set-buffer gnus-article-current-summary)
5264 (let (gnus-pick-mode)
5265 (push (or key last-command-event) unread-command-events)
5266 (setq keys (if (featurep 'xemacs)
5267 (events-to-keys (read-key-sequence nil))
5268 (read-key-sequence nil)))))
5272 (if (or (member keys nosaves)
5273 (member keys nosave-but-article)
5274 (member keys nosave-in-article))
5276 (save-window-excursion
5277 (pop-to-buffer gnus-article-current-summary 'norecord)
5278 ;; We disable the pick minor mode commands.
5279 (let (gnus-pick-mode)
5280 (setq func (lookup-key (current-local-map) keys))))
5284 (unless (member keys nosave-in-article)
5285 (set-buffer gnus-article-current-summary))
5286 (call-interactively func)
5287 (setq new-sum-point (point)))
5288 (when (member keys nosave-but-article)
5289 (pop-to-buffer gnus-article-buffer 'norecord)))
5290 ;; These commands should restore window configuration.
5291 (let ((obuf (current-buffer))
5292 (owin (current-window-configuration))
5294 win func in-buffer selected new-sum-start new-sum-hscroll)
5295 (cond (not-restore-window
5296 (pop-to-buffer gnus-article-current-summary 'norecord))
5297 ((setq win (get-buffer-window gnus-article-current-summary))
5298 (select-window win))
5300 (switch-to-buffer gnus-article-current-summary 'norecord)))
5301 (setq in-buffer (current-buffer))
5302 ;; We disable the pick minor mode commands.
5303 (if (and (setq func (let (gnus-pick-mode)
5304 (lookup-key (current-local-map) keys)))
5307 (call-interactively func)
5308 (when (eq win (selected-window))
5309 (setq new-sum-point (point)
5310 new-sum-start (window-start win)
5311 new-sum-hscroll (window-hscroll win))
5312 (when (eq in-buffer (current-buffer))
5313 (setq selected (gnus-summary-select-article))
5315 (unless not-restore-window
5316 (set-window-configuration owin))
5317 (when (eq selected 'old)
5319 (set-window-start (get-buffer-window (current-buffer))
5321 (set-window-point (get-buffer-window (current-buffer))
5323 (when (and (not not-restore-window)
5325 (set-window-point win new-sum-point)
5326 (set-window-start win new-sum-start)
5327 (set-window-hscroll win new-sum-hscroll)))))
5328 (set-window-configuration owin)
5331 (defun gnus-article-describe-key (key)
5332 "Display documentation of the function invoked by KEY. KEY is a string."
5333 (interactive "kDescribe key: ")
5334 (gnus-article-check-buffer)
5335 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5337 (set-buffer gnus-article-current-summary)
5338 (let (gnus-pick-mode)
5339 (if (featurep 'xemacs)
5341 (push (elt key 0) unread-command-events)
5342 (setq key (events-to-keys
5343 (read-key-sequence "Describe key: "))))
5344 (setq unread-command-events
5346 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5347 (string-to-list key)))
5348 (setq key (read-key-sequence "Describe key: "))))
5350 (describe-key key)))
5352 (defun gnus-article-describe-key-briefly (key &optional insert)
5353 "Display documentation of the function invoked by KEY. KEY is a string."
5354 (interactive "kDescribe key: \nP")
5355 (gnus-article-check-buffer)
5356 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5358 (set-buffer gnus-article-current-summary)
5359 (let (gnus-pick-mode)
5360 (if (featurep 'xemacs)
5362 (push (elt key 0) unread-command-events)
5363 (setq key (events-to-keys
5364 (read-key-sequence "Describe key: "))))
5365 (setq unread-command-events
5367 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5368 (string-to-list key)))
5369 (setq key (read-key-sequence "Describe key: "))))
5370 (describe-key-briefly key insert))
5371 (describe-key-briefly key insert)))
5373 (defun gnus-article-reply-with-original (&optional wide)
5374 "Start composing a reply mail to the current message.
5375 The text in the region will be yanked. If the region isn't active,
5376 the entire article will be yanked."
5378 (let ((article (cdr gnus-article-current))
5380 (if (not (gnus-mark-active-p))
5381 (with-current-buffer gnus-summary-buffer
5382 (gnus-summary-reply (list (list article)) wide))
5383 (setq contents (buffer-substring (point) (mark t)))
5384 ;; Deactivate active regions.
5385 (when (and (boundp 'transient-mark-mode)
5386 transient-mark-mode)
5387 (setq mark-active nil))
5388 (with-current-buffer gnus-summary-buffer
5390 (list (list article contents)) wide)))))
5392 (defun gnus-article-followup-with-original ()
5393 "Compose a followup to the current article.
5394 The text in the region will be yanked. If the region isn't active,
5395 the entire article will be yanked."
5397 (let ((article (cdr gnus-article-current))
5399 (if (not (gnus-mark-active-p))
5400 (with-current-buffer gnus-summary-buffer
5401 (gnus-summary-followup (list (list article))))
5402 (setq contents (buffer-substring (point) (mark t)))
5403 ;; Deactivate active regions.
5404 (when (and (boundp 'transient-mark-mode)
5405 transient-mark-mode)
5406 (setq mark-active nil))
5407 (with-current-buffer gnus-summary-buffer
5408 (gnus-summary-followup
5409 (list (list article contents)))))))
5411 (defun gnus-article-hide (&optional arg force)
5412 "Hide all the gruft in the current article.
5413 This means that signatures, cited text and (some) headers will be
5415 If given a prefix, show the hidden text instead."
5416 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5417 (gnus-article-hide-headers arg)
5418 (gnus-article-hide-list-identifiers arg)
5419 (gnus-article-hide-citation-maybe arg force)
5420 (gnus-article-hide-signature arg))
5422 (defun gnus-article-maybe-highlight ()
5423 "Do some article highlighting if article highlighting is requested."
5424 (when (gnus-visual-p 'article-highlight 'highlight)
5425 (gnus-article-highlight-some)))
5427 (defun gnus-check-group-server ()
5428 ;; Make sure the connection to the server is alive.
5429 (unless (gnus-server-opened
5430 (gnus-find-method-for-group gnus-newsgroup-name))
5431 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5432 (gnus-request-group gnus-newsgroup-name t)))
5435 (autoload 'nneething-get-file-name "nneething"))
5437 (defun gnus-request-article-this-buffer (article group)
5438 "Get an article and insert it into this buffer."
5439 (let (do-update-line sparse-header)
5443 (gnus-kill-all-overlays)
5444 (setq group (or group gnus-newsgroup-name))
5446 ;; Using `gnus-request-article' directly will insert the article into
5447 ;; `nntp-server-buffer' - so we'll save some time by not having to
5448 ;; copy it from the server buffer into the article buffer.
5450 ;; We only request an article by message-id when we do not have the
5451 ;; headers for it, so we'll have to get those.
5452 (when (stringp article)
5453 (gnus-read-header article))
5455 ;; If the article number is negative, that means that this article
5456 ;; doesn't belong in this newsgroup (possibly), so we find its
5457 ;; message-id and request it by id instead of number.
5458 (when (and (numberp article)
5460 (get-buffer gnus-summary-buffer)
5461 (gnus-buffer-exists-p gnus-summary-buffer))
5463 (set-buffer gnus-summary-buffer)
5464 (let ((header (gnus-summary-article-header article)))
5467 ((memq article gnus-newsgroup-sparse)
5468 ;; This is a sparse gap article.
5469 (setq do-update-line article)
5470 (setq article (mail-header-id header))
5471 (setq sparse-header (gnus-read-header article))
5472 (setq gnus-newsgroup-sparse
5473 (delq article gnus-newsgroup-sparse)))
5475 ;; It's a real article.
5476 (setq article (mail-header-id header)))
5478 ;; It is an extracted pseudo-article.
5479 (setq article 'pseudo)
5480 (gnus-request-pseudo-article header))))
5482 (let ((method (gnus-find-method-for-group
5483 gnus-newsgroup-name)))
5484 (when (and (eq (car method) 'nneething)
5486 (let ((dir (nneething-get-file-name
5487 (mail-header-id header))))
5488 (when (and (stringp dir)
5489 (file-directory-p dir))
5490 (setq article 'nneething)
5491 (gnus-group-enter-directory dir))))))))
5494 ;; Refuse to select canceled articles.
5495 ((and (numberp article)
5497 (get-buffer gnus-summary-buffer)
5498 (gnus-buffer-exists-p gnus-summary-buffer)
5499 (eq (cdr (save-excursion
5500 (set-buffer gnus-summary-buffer)
5501 (assq article gnus-newsgroup-reads)))
5502 gnus-canceled-mark))
5504 ;; We first check `gnus-original-article-buffer'.
5505 ((and (get-buffer gnus-original-article-buffer)
5508 (set-buffer gnus-original-article-buffer)
5509 (and (equal (car gnus-original-article) group)
5510 (eq (cdr gnus-original-article) article))))
5511 (insert-buffer-substring gnus-original-article-buffer)
5513 ;; Check the backlog.
5514 ((and gnus-keep-backlog
5515 (gnus-backlog-request-article group article (current-buffer)))
5517 ;; Check asynchronous pre-fetch.
5518 ((gnus-async-request-fetched-article group article (current-buffer))
5519 (gnus-async-prefetch-next group article gnus-summary-buffer)
5520 (when (and (numberp article) gnus-keep-backlog)
5521 (gnus-backlog-enter-article group article (current-buffer)))
5524 ((and gnus-use-cache
5526 (gnus-cache-request-article article group))
5528 ;; Check the agent cache.
5529 ((gnus-agent-request-article article group)
5531 ;; Get the article and put into the article buffer.
5532 ((or (stringp article)
5534 (let ((gnus-override-method gnus-override-method)
5535 (methods (and (stringp article)
5536 gnus-refer-article-method))
5537 (backend (car (gnus-find-method-for-group
5538 gnus-newsgroup-name)))
5540 (inhibit-read-only t))
5541 (if (or (not (listp methods))
5542 (and (symbolp (car methods))
5543 (assq (car methods) nnoo-definition-alist)))
5544 (setq methods (list methods)))
5545 (when (and (null gnus-override-method)
5547 (setq gnus-override-method (pop methods)))
5549 (when (eq gnus-override-method 'current)
5550 (setq gnus-override-method
5551 (with-current-buffer gnus-summary-buffer
5552 gnus-current-select-method)))
5554 (gnus-kill-all-overlays)
5555 (let ((gnus-newsgroup-name group))
5556 (gnus-check-group-server))
5558 ((gnus-request-article article group (current-buffer))
5559 (when (numberp article)
5560 (gnus-async-prefetch-next group article
5561 gnus-summary-buffer)
5562 (when gnus-keep-backlog
5563 (gnus-backlog-enter-article
5564 group article (current-buffer))))
5565 (setq result 'article))
5567 (setq gnus-override-method (pop methods)))
5568 ((not (string-match "^400 "
5569 (nnheader-get-report backend)))
5570 ;; If we get 400 server disconnect, reconnect and
5571 ;; retry; otherwise, assume the article has expired.
5572 (setq result 'done))))
5573 (and (eq result 'article) 'article)))
5577 ;; Associate this article with the current summary buffer.
5578 (setq gnus-article-current-summary gnus-summary-buffer)
5580 ;; Take the article from the original article buffer
5581 ;; and place it in the buffer it's supposed to be in.
5582 (when (and (get-buffer gnus-article-buffer)
5583 (equal (buffer-name (current-buffer))
5584 (buffer-name (get-buffer gnus-article-buffer))))
5586 (if (get-buffer gnus-original-article-buffer)
5587 (set-buffer gnus-original-article-buffer)
5588 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5589 (buffer-disable-undo)
5590 (setq major-mode 'gnus-original-article-mode)
5591 (setq buffer-read-only t))
5592 (let ((inhibit-read-only t))
5594 (insert-buffer-substring gnus-article-buffer))
5595 (setq gnus-original-article (cons group article)))
5598 (run-hooks 'gnus-article-decode-hook)
5599 ;; Mark article as decoded or not.
5600 (setq gnus-article-decoded-p gnus-article-decode-hook))
5602 ;; Update sparse articles.
5603 (when (and do-update-line
5604 (or (numberp article)
5606 (let ((buf (current-buffer)))
5607 (set-buffer gnus-summary-buffer)
5608 (gnus-summary-update-article do-update-line sparse-header)
5609 (gnus-summary-goto-subject do-update-line nil t)
5610 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5612 (set-buffer buf))))))
5618 (defcustom gnus-article-edit-mode-hook nil
5619 "Hook run in article edit mode buffers."
5620 :group 'gnus-article-various
5623 (defvar gnus-article-edit-done-function nil)
5625 (defvar gnus-article-edit-mode-map nil)
5626 (defvar gnus-article-edit-mode nil)
5628 ;; Should we be using derived.el for this?
5629 (unless gnus-article-edit-mode-map
5630 (setq gnus-article-edit-mode-map (make-keymap))
5631 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5633 (gnus-define-keys gnus-article-edit-mode-map
5634 "\C-c?" describe-mode
5635 "\C-c\C-c" gnus-article-edit-done
5636 "\C-c\C-k" gnus-article-edit-exit
5637 "\C-c\C-f\C-t" message-goto-to
5638 "\C-c\C-f\C-o" message-goto-from
5639 "\C-c\C-f\C-b" message-goto-bcc
5640 ;;"\C-c\C-f\C-w" message-goto-fcc
5641 "\C-c\C-f\C-c" message-goto-cc
5642 "\C-c\C-f\C-s" message-goto-subject
5643 "\C-c\C-f\C-r" message-goto-reply-to
5644 "\C-c\C-f\C-n" message-goto-newsgroups
5645 "\C-c\C-f\C-d" message-goto-distribution
5646 "\C-c\C-f\C-f" message-goto-followup-to
5647 "\C-c\C-f\C-m" message-goto-mail-followup-to
5648 "\C-c\C-f\C-k" message-goto-keywords
5649 "\C-c\C-f\C-u" message-goto-summary
5650 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5651 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5652 "\C-c\C-b" message-goto-body
5653 "\C-c\C-i" message-goto-signature
5655 "\C-c\C-t" message-insert-to
5656 "\C-c\C-n" message-insert-newsgroups
5657 "\C-c\C-o" message-sort-headers
5658 "\C-c\C-e" message-elide-region
5659 "\C-c\C-v" message-delete-not-region
5660 "\C-c\C-z" message-kill-to-signature
5661 "\M-\r" message-newline-and-reformat
5662 "\C-c\C-a" mml-attach-file
5663 "\C-a" message-beginning-of-line
5665 "\M-;" comment-region)
5667 (gnus-define-keys (gnus-article-edit-wash-map
5668 "\C-c\C-w" gnus-article-edit-mode-map)
5669 "f" gnus-article-edit-full-stops))
5672 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5674 ["Fetch To" message-insert-to t]
5675 ["Fetch Newsgroups" message-insert-newsgroups t]
5677 ["To" message-goto-to t]
5678 ["From" message-goto-from t]
5679 ["Subject" message-goto-subject t]
5680 ["Cc" message-goto-cc t]
5681 ["Reply-To" message-goto-reply-to t]
5682 ["Summary" message-goto-summary t]
5683 ["Keywords" message-goto-keywords t]
5684 ["Newsgroups" message-goto-newsgroups t]
5685 ["Followup-To" message-goto-followup-to t]
5686 ["Mail-Followup-To" message-goto-mail-followup-to t]
5687 ["Distribution" message-goto-distribution t]
5688 ["Body" message-goto-body t]
5689 ["Signature" message-goto-signature t]))
5691 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5692 "Major mode for editing articles.
5693 This is an extended text-mode.
5695 \\{gnus-article-edit-mode-map}"
5696 (make-local-variable 'gnus-article-edit-done-function)
5697 (make-local-variable 'gnus-prev-winconf)
5698 (set (make-local-variable 'font-lock-defaults)
5699 '(message-font-lock-keywords t))
5700 (set (make-local-variable 'mail-header-separator) "")
5701 (set (make-local-variable 'gnus-article-edit-mode) t)
5702 (easy-menu-add message-mode-field-menu message-mode-map)
5704 (setq buffer-read-only nil)
5705 (buffer-enable-undo)
5708 (defun gnus-article-edit (&optional force)
5709 "Edit the current article.
5710 This will have permanent effect only in mail groups.
5711 If FORCE is non-nil, allow editing of articles even in read-only
5714 (when (and (not force)
5715 (gnus-group-read-only-p))
5716 (error "The current newsgroup does not support article editing"))
5717 (gnus-article-date-original)
5718 (gnus-article-edit-article
5720 `(lambda (no-highlight)
5722 (gnus-summary-edit-article-done
5723 ,(or (mail-header-references gnus-current-headers) "")
5724 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5726 (defun gnus-article-edit-article (start-func exit-func)
5727 "Start editing the contents of the current article buffer."
5728 (let ((winconf (current-window-configuration)))
5729 (set-buffer gnus-article-buffer)
5730 (let ((message-auto-save-directory
5731 ;; Don't associate the article buffer with a draft file.
5733 (gnus-article-edit-mode))
5734 (funcall start-func)
5735 (set-buffer-modified-p nil)
5736 (gnus-configure-windows 'edit-article)
5737 (setq gnus-article-edit-done-function exit-func)
5738 (setq gnus-prev-winconf winconf)
5739 (gnus-message 6 "C-c C-c to end edits")))
5741 (defun gnus-article-edit-done (&optional arg)
5742 "Update the article edits and exit."
5744 (let ((func gnus-article-edit-done-function)
5745 (buf (current-buffer))
5746 (start (window-start))
5748 (winconf gnus-prev-winconf))
5749 (widen) ;; Widen it in case that users narrowed the buffer.
5752 ;; The cache and backlog have to be flushed somewhat.
5753 (when gnus-keep-backlog
5754 (gnus-backlog-remove-article
5755 (car gnus-article-current) (cdr gnus-article-current)))
5756 ;; Flush original article as well.
5758 (when (get-buffer gnus-original-article-buffer)
5759 (set-buffer gnus-original-article-buffer)
5760 (setq gnus-original-article nil)))
5761 (when gnus-use-cache
5762 (gnus-cache-update-article
5763 (car gnus-article-current) (cdr gnus-article-current)))
5764 ;; We remove all text props from the article buffer.
5765 (kill-all-local-variables)
5766 (gnus-set-text-properties (point-min) (point-max) nil)
5768 (set-window-configuration winconf)
5770 (set-window-start (get-buffer-window buf) start)
5771 (set-window-point (get-buffer-window buf) (point)))
5772 (gnus-summary-show-article))
5774 (defun gnus-article-edit-exit ()
5775 "Exit the article editing without updating."
5777 (when (or (not (buffer-modified-p))
5778 (yes-or-no-p "Article modified; kill anyway? "))
5779 (let ((curbuf (current-buffer))
5781 (window-start (window-start)))
5783 (if (gnus-buffer-live-p gnus-original-article-buffer)
5784 (insert-buffer gnus-original-article-buffer))
5785 (let ((winconf gnus-prev-winconf))
5786 (kill-all-local-variables)
5788 (set-window-configuration winconf)
5789 ;; Tippy-toe some to make sure that point remains where it was.
5790 (save-current-buffer
5792 (set-window-start (get-buffer-window (current-buffer)) window-start)
5794 (gnus-summary-show-article)))
5796 (defun gnus-article-edit-full-stops ()
5797 "Interactively repair spacing at end of sentences."
5800 (goto-char (point-min))
5801 (search-forward-regexp "^$" nil t)
5802 (let ((case-fold-search nil))
5803 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5806 ;;; Article highlights
5809 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5811 ;;; Internal Variables:
5813 (defcustom gnus-button-url-regexp
5814 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5815 "\\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:]]\\)"
5816 "\\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\\)\\)")
5817 "Regular expression that matches URLs."
5818 :group 'gnus-article-buttons
5821 (defcustom gnus-button-valid-fqdn-regexp
5822 message-valid-fqdn-regexp
5823 "Regular expression that matches a valid FQDN."
5825 :group 'gnus-article-buttons
5828 (defcustom gnus-button-man-handler 'manual-entry
5829 "Function to use for displaying man pages.
5830 The function must take at least one argument with a string naming the
5833 :type '(choice (function-item :tag "Man" manual-entry)
5834 (function-item :tag "Woman" woman)
5835 (function :tag "Other"))
5836 :group 'gnus-article-buttons)
5838 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5839 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5840 If the default site is too slow, try to find a CTAN mirror, see
5841 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5842 the variable `gnus-button-handle-ctan'."
5844 :group 'gnus-article-buttons
5845 :link '(custom-manual "(gnus)Group Parameters")
5846 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5847 (const "http://tug.ctan.org/tex-archive/")
5848 (const "http://www.dante.de/CTAN/")
5849 (string :tag "Other")))
5851 (defcustom gnus-button-ctan-handler 'browse-url
5852 "Function to use for displaying CTAN links.
5853 The function must take one argument, the string naming the URL."
5855 :type '(choice (function-item :tag "Browse Url" browse-url)
5856 (function :tag "Other"))
5857 :group 'gnus-article-buttons)
5859 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5860 "Bogus strings removed from CTAN URLs."
5862 :group 'gnus-article-buttons
5863 :type '(choice (const "^/?tex-archive/\\|/")
5864 (regexp :tag "Other")))
5866 (defcustom gnus-button-ctan-directory-regexp
5868 "\\("; Cannot use `\(?: ... \)' (compatibility with Emacs 20).
5869 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5870 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5871 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5873 "Regular expression for ctan directories.
5874 It should match all directories in the top level of `gnus-ctan-url'."
5876 :group 'gnus-article-buttons
5879 (defcustom gnus-button-mid-or-mail-regexp
5880 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
5881 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5882 gnus-button-valid-fqdn-regexp
5884 "Regular expression that matches a message ID or a mail address."
5886 :group 'gnus-article-buttons
5889 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5890 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5891 Strings like this can be either a message ID or a mail address. If it is one
5892 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5893 message ID or a mail address, respectively. If this variable is set to the
5894 symbol `ask', always query the user what do do. If it is a function, this
5895 function will be called with the string as it's only argument. The function
5896 must return `mid', `mail', `invalid' or `ask'."
5898 :group 'gnus-article-buttons
5899 :type '(choice (function-item :tag "Heuristic function"
5900 gnus-button-mid-or-mail-heuristic)
5905 (defcustom gnus-button-mid-or-mail-heuristic-alist
5906 '((-10.0 . ".+\\$.+@")
5909 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5910 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5911 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5912 (-1.0 . "^[^a-z]+@")
5914 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5915 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5916 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5917 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5920 (-1.0 . "^[0-9][0-9]")
5922 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5923 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5924 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5925 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5927 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5928 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5931 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5933 ;; compensation for TDMA dated mail addresses:
5934 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5936 (-20.0 . "\\.fsf@") ;; Gnus
5939 (-20.0 . "_-_") ;; Subject change in thread
5941 (-20.0 . "\\.ln@") ;; leafnode
5942 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5943 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5945 ;; (5.0 . "") ;; $local_part_len <= 7
5946 (10.0 . "^[^0-9]+@")
5947 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5948 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5951 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5953 (0.5 . "^[A-Z][a-z]")
5954 (0.5 . "^[A-Z][a-z][a-z]")
5955 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5956 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5957 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5959 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5960 address. The REGEXP is processed with `case-fold-search' set to nil."
5962 :group 'gnus-article-buttons
5963 :type '(repeat (cons (number :tag "Rate")
5964 (regexp :tag "Regexp"))))
5966 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5967 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5968 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5969 address, `ask' if unsure and `invalid' if the string is invalid."
5970 (let ((case-fold-search nil)
5971 (list gnus-button-mid-or-mail-heuristic-alist)
5972 (result 0) rate regexp lpartlen elem)
5974 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5975 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5976 ;; Certain special cases...
5979 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
5980 "^[0-9]+\\.[0-9]+@compuserve\\|"
5981 "@public\\.gmane\\.org")
5983 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
5984 (setq result 'mail))
5985 (when (string-match "@.*@\\| " mid-or-mail)
5986 (gnus-message 8 "`%s' is invalid." mid-or-mail)
5987 (setq result 'invalid))
5988 ;; Nothing more to do, if result is not a number here...
5989 (when (numberp result)
5991 (setq elem (car list)
5995 (when (string-match regexp mid-or-mail)
5996 (setq result (+ result rate))
5998 9 "`%s' matched `%s', rate `%s', result `%s'."
5999 mid-or-mail regexp rate result)))
6000 (when (<= lpartlen 7)
6001 (setq result (+ result 5.0))
6002 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6003 mid-or-mail result))
6004 (when (>= lpartlen 12)
6005 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6007 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6008 ;; Long local part should contain realname if e-mail address,
6009 ;; too many digits: message-id.
6010 ;; $score -= 5.0 + 0.1 * $local_part_len;
6011 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6012 (setq result (+ result rate))
6014 9 "Many digits in `%s', rate `%s', result `%s'."
6015 mid-or-mail rate result))
6016 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6018 ;; Too few vowels [^aeiouy]{4,}.*\@
6019 (setq result (+ result -5.0))
6021 9 "Few vowels in `%s', rate `%s', result `%s'."
6022 mid-or-mail -5.0 result))
6024 (setq result (+ result 5.0))
6026 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6027 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6028 ;; Maybe we should make this a customizable alist: (condition . 'result)
6030 ((symbolp result) result)
6031 ;; Now convert number into proper results:
6032 ((< result -10.0) 'mid)
6033 ((> result 10.0) 'mail)
6036 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6037 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6038 (url-mid (concat "news" ":" mid-or-mail))
6039 (url-mailto (concat "mailto" ":" mid-or-mail)))
6040 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6041 (when (fboundp pref)
6043 ;; get rid of surrounding angles...
6045 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6046 (if (or (eq 'mid guessed) (eq 'mail guessed))
6050 (save-window-excursion
6051 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6054 (cond ((eq pref 'mid)
6055 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6056 (gnus-button-handle-news url-mid))
6058 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6059 (gnus-url-mailto url-mailto))
6060 (t (gnus-message 3 "Invalid string.")))))
6062 (defun gnus-button-handle-custom (url)
6063 "Follow a Custom URL."
6064 (customize-apropos (gnus-url-unhex-string url)))
6066 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6068 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6071 (defun gnus-button-handle-describe-function (url)
6072 "Call `describe-function' when pushing the corresponding URL button."
6075 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6077 (defun gnus-button-handle-describe-variable (url)
6078 "Call `describe-variable' when pushing the corresponding URL button."
6081 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6083 (defun gnus-button-handle-symbol (url)
6084 "Display help on variable or function.
6085 Calls `describe-variable' or `describe-function'."
6086 (let ((sym (intern url)))
6088 ((fboundp sym) (describe-function sym))
6089 ((boundp sym) (describe-variable sym))
6090 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6092 (defun gnus-button-handle-describe-key (url)
6093 "Call `describe-key' when pushing the corresponding URL button."
6095 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6096 (keys (ignore-errors (eval `(kbd ,key-string)))))
6099 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6101 (defun gnus-button-handle-apropos (url)
6102 "Call `apropos' when pushing the corresponding URL button."
6103 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6105 (defun gnus-button-handle-apropos-command (url)
6106 "Call `apropos' when pushing the corresponding URL button."
6108 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6110 (defun gnus-button-handle-apropos-variable (url)
6111 "Call `apropos' when pushing the corresponding URL button."
6113 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6114 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6116 (defun gnus-button-handle-apropos-documentation (url)
6117 "Call `apropos' when pushing the corresponding URL button."
6119 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6120 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6122 (defun gnus-button-handle-library (url)
6123 "Call `locate-library' when pushing the corresponding URL button."
6124 (gnus-message 9 "url=`%s'" url)
6125 (let* ((lib (locate-library url))
6126 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6128 (gnus-message 1 "Cannot locale library `%s'." url)
6129 (find-file-read-only file))))
6131 (defun gnus-button-handle-ctan (url)
6132 "Call `browse-url' when pushing a CTAN URL button."
6134 gnus-button-ctan-handler
6137 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6139 (defcustom gnus-button-tex-level 5
6140 "*Integer that says how many TeX-related buttons Gnus will show.
6141 The higher the number, the more buttons will appear and the more false
6142 positives are possible. Note that you can set this variable local to
6143 specific groups. Setting it higher in TeX groups is probably a good idea.
6144 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6145 how to set variables in specific groups."
6147 :group 'gnus-article-buttons
6148 :link '(custom-manual "(gnus)Group Parameters")
6151 (defcustom gnus-button-man-level 5
6152 "*Integer that says how many man-related buttons Gnus will show.
6153 The higher the number, the more buttons will appear and the more false
6154 positives are possible. Note that you can set this variable local to
6155 specific groups. Setting it higher in Unix groups is probably a good idea.
6156 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6157 how to set variables in specific groups."
6159 :group 'gnus-article-buttons
6160 :link '(custom-manual "(gnus)Group Parameters")
6163 (defcustom gnus-button-emacs-level 5
6164 "*Integer that says how many emacs-related buttons Gnus will show.
6165 The higher the number, the more buttons will appear and the more false
6166 positives are possible. Note that you can set this variable local to
6167 specific groups. Setting it higher in Emacs or Gnus related groups is
6168 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6169 `gnus-parameters' on how to set variables in specific groups."
6171 :group 'gnus-article-buttons
6172 :link '(custom-manual "(gnus)Group Parameters")
6175 (defcustom gnus-button-message-level 5
6176 "*Integer that says how many buttons for news or mail messages will appear.
6177 The higher the number, the more buttons will appear and the more false
6178 positives are possible."
6179 ;; mail addresses, MIDs, URLs for news, ...
6181 :group 'gnus-article-buttons
6184 (defcustom gnus-button-browse-level 5
6185 "*Integer that says how many buttons for browsing will appear.
6186 The higher the number, the more buttons will appear and the more false
6187 positives are possible."
6188 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6190 :group 'gnus-article-buttons
6193 (defcustom gnus-button-alist
6194 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6195 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6196 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6197 gnus-button-handle-news 2)
6198 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6199 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6200 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6201 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6202 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6203 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6204 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6205 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6206 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6207 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6208 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6209 ;; RFC 2368 (The mailto URL scheme)
6210 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6211 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6212 ("\\bmailto:\\([^ \n\t]+\\)"
6213 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6215 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6216 gnus-button-ctan-directory-regexp
6217 "[^][>)!;:,'\n\t ]+\\)")
6218 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6219 ((concat "\\btex-archive/\\("
6220 gnus-button-ctan-directory-regexp
6221 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6222 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6225 gnus-button-ctan-directory-regexp
6226 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6227 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6228 ;; This is info (home-grown style) <info://foo/bar+baz>
6229 ("\\binfo://\\([^'\">\n\t ]+\\)"
6230 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6231 ;; Info GNOME style <info:foo#bar_baz>
6232 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6233 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6234 ;; Info KDE style <info:(foo)bar baz>
6235 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6236 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6237 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6238 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6239 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6240 ;; Info links like `C-h i d m CC Mode RET'
6241 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6243 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6244 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6245 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6246 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6247 ;; Emacs help commands
6248 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6249 ;; regexp doesn't match arguments containing ` '.
6250 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6251 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6252 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6253 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6254 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6255 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6256 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6257 ;; The following entries may lead to many false positives so don't enable
6258 ;; them by default (use a high button level).
6259 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6260 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6261 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6262 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6263 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6264 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6265 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6266 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6267 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6268 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6269 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6270 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6271 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6272 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6273 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6274 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6275 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6276 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6277 ;; Unlike the other regexps we really have to require quoting
6278 ;; here to determine where it ends.
6279 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6280 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6281 ("<URL: *\\([^<>]*\\)>"
6282 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6283 ;; RFC 2396 (2.4.3., delims) ...
6284 ("\"URL: *\\([^\"]*\\)\""
6285 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6286 ;; RFC 2396 (2.4.3., delims) ...
6287 ("\"URL: *\\([^\"]*\\)\""
6288 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6290 (gnus-button-url-regexp
6291 0 (>= gnus-button-browse-level 0) browse-url 0)
6293 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6294 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6295 gnus-button-handle-man 1)
6296 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6297 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6298 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6299 gnus-button-handle-man 1)
6300 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6301 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6302 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6303 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6304 ;; MID or mail: To avoid too many false positives we don't try to catch
6305 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6306 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6307 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6308 ;; so that non-ambiguous entries (see above) match first.
6309 (gnus-button-mid-or-mail-regexp
6310 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6311 "*Alist of regexps matching buttons in article bodies.
6313 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6314 REGEXP: is the string (case insensitive) matching text around the button (can
6315 also be Lisp expression evaluating to a string),
6316 BUTTON: is the number of the regexp grouping actually matching the button,
6317 FORM: is a Lisp expression which must eval to true for the button to
6319 CALLBACK: is the function to call when the user push this button, and each
6320 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6322 CALLBACK can also be a variable, in that case the value of that
6323 variable it the real callback function."
6324 :group 'gnus-article-buttons
6325 :type '(repeat (list (choice regexp variable sexp)
6326 (integer :tag "Button")
6328 (function :tag "Callback")
6331 (integer :tag "Regexp group")))))
6333 (defcustom gnus-header-button-alist
6334 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6335 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6336 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6337 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6338 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6339 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6340 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6341 0 (>= gnus-button-browse-level 0) browse-url 0)
6342 ("^Subject:" gnus-button-url-regexp
6343 0 (>= gnus-button-browse-level 0) browse-url 0)
6344 ("^[^:]+:" gnus-button-url-regexp
6345 0 (>= gnus-button-browse-level 0) browse-url 0)
6346 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6347 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6348 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6349 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6350 "*Alist of headers and regexps to match buttons in article heads.
6352 This alist is very similar to `gnus-button-alist', except that each
6353 alist has an additional HEADER element first in each entry:
6355 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6357 HEADER is a regexp to match a header. For a fuller explanation, see
6358 `gnus-button-alist'."
6359 :group 'gnus-article-buttons
6360 :group 'gnus-article-headers
6361 :type '(repeat (list (regexp :tag "Header")
6362 (choice regexp variable)
6363 (integer :tag "Button")
6365 (function :tag "Callback")
6368 (integer :tag "Regexp group")))))
6370 (defvar gnus-button-regexp nil)
6371 (defvar gnus-button-marker-list nil)
6372 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6374 (defvar gnus-button-last nil)
6375 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6379 (defun gnus-article-push-button (event)
6380 "Check text under the mouse pointer for a callback function.
6381 If the text under the mouse pointer has a `gnus-callback' property,
6382 call it with the value of the `gnus-data' text property."
6384 (set-buffer (window-buffer (posn-window (event-start event))))
6385 (let* ((pos (posn-point (event-start event)))
6386 (data (get-text-property pos 'gnus-data))
6387 (fun (get-text-property pos 'gnus-callback)))
6390 (funcall fun data))))
6392 (defun gnus-article-press-button ()
6393 "Check text at point for a callback function.
6394 If the text at point has a `gnus-callback' property,
6395 call it with the value of the `gnus-data' text property."
6397 (let ((data (get-text-property (point) 'gnus-data))
6398 (fun (get-text-property (point) 'gnus-callback)))
6400 (funcall fun data))))
6402 (defun gnus-article-highlight (&optional force)
6403 "Highlight current article.
6404 This function calls `gnus-article-highlight-headers',
6405 `gnus-article-highlight-citation',
6406 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6407 do the highlighting. See the documentation for those functions."
6408 (interactive (list 'force))
6409 (gnus-article-highlight-headers)
6410 (gnus-article-highlight-citation force)
6411 (gnus-article-highlight-signature)
6412 (gnus-article-add-buttons force)
6413 (gnus-article-add-buttons-to-head))
6415 (defun gnus-article-highlight-some (&optional force)
6416 "Highlight current article.
6417 This function calls `gnus-article-highlight-headers',
6418 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6419 do the highlighting. See the documentation for those functions."
6420 (interactive (list 'force))
6421 (gnus-article-highlight-headers)
6422 (gnus-article-highlight-signature)
6423 (gnus-article-add-buttons))
6425 (defun gnus-article-highlight-headers ()
6426 "Highlight article headers as specified by `gnus-header-face-alist'."
6429 (set-buffer gnus-article-buffer)
6431 (let ((alist gnus-header-face-alist)
6432 (inhibit-read-only t)
6433 (case-fold-search t)
6434 (inhibit-point-motion-hooks t)
6435 entry regexp header-face field-face from hpoints fpoints)
6436 (article-narrow-to-head)
6437 (while (setq entry (pop alist))
6438 (goto-char (point-min))
6439 (setq regexp (concat "^\\("
6440 (if (string-equal "" (nth 0 entry))
6444 header-face (nth 1 entry)
6445 field-face (nth 2 entry))
6446 (while (and (re-search-forward regexp nil t)
6450 (unless (search-forward ":" nil t)
6452 (when (and header-face
6453 (not (memq (point) hpoints)))
6454 (push (point) hpoints)
6455 (gnus-put-text-property from (point) 'face header-face))
6456 (when (and field-face
6457 (not (memq (setq from (point)) fpoints)))
6459 (if (re-search-forward "^[^ \t]" nil t)
6461 (goto-char (point-max)))
6462 (gnus-put-text-property from (point) 'face field-face))))))))
6464 (defun gnus-article-highlight-signature ()
6465 "Highlight the signature in an article.
6466 It does this by highlighting everything after
6467 `gnus-signature-separator' using `gnus-signature-face'."
6470 (set-buffer gnus-article-buffer)
6471 (let ((inhibit-read-only t)
6472 (inhibit-point-motion-hooks t))
6474 (when (and gnus-signature-face
6475 (gnus-article-narrow-to-signature))
6476 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6477 'face gnus-signature-face)
6479 (gnus-article-search-signature)
6480 (let ((start (match-beginning 0))
6481 (end (set-marker (make-marker) (1+ (match-end 0)))))
6482 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6485 (defun gnus-button-in-region-p (b e prop)
6486 "Say whether PROP exists in the region."
6487 (text-property-not-all b e prop nil))
6489 (defun gnus-article-add-buttons (&optional force)
6490 "Find external references in the article and make buttons of them.
6491 \"External references\" are things like Message-IDs and URLs, as
6492 specified by `gnus-button-alist'."
6493 (interactive (list 'force))
6495 (set-buffer gnus-article-buffer)
6496 (let ((inhibit-read-only t)
6497 (inhibit-point-motion-hooks t)
6498 (case-fold-search t)
6499 (alist gnus-button-alist)
6501 ;; Remove all old markers.
6502 (let (marker entry new-list)
6503 (while (setq marker (pop gnus-button-marker-list))
6504 (if (or (< marker (point-min)) (>= marker (point-max)))
6505 (push marker new-list)
6507 (when (setq entry (gnus-button-entry))
6508 (put-text-property (match-beginning (nth 1 entry))
6509 (match-end (nth 1 entry))
6510 'gnus-callback nil))
6511 (set-marker marker nil)))
6512 (setq gnus-button-marker-list new-list))
6513 ;; We skip the headers.
6516 (while (setq entry (pop alist))
6517 (setq regexp (eval (car entry)))
6519 (while (re-search-forward regexp nil t)
6520 (let* ((start (and entry (match-beginning (nth 1 entry))))
6521 (end (and entry (match-end (nth 1 entry))))
6522 (from (match-beginning 0)))
6523 (when (and (or (eq t (nth 2 entry))
6524 (eval (nth 2 entry)))
6525 (not (gnus-button-in-region-p
6526 start end 'gnus-callback)))
6527 ;; That optional form returned non-nil, so we add the
6529 (gnus-article-add-button
6530 start end 'gnus-button-push
6531 (car (push (set-marker (make-marker) from)
6532 gnus-button-marker-list))))))))))
6534 ;; Add buttons to the head of an article.
6535 (defun gnus-article-add-buttons-to-head ()
6536 "Add buttons to the head of the article."
6539 (set-buffer gnus-article-buffer)
6541 (let ((inhibit-read-only t)
6542 (inhibit-point-motion-hooks t)
6543 (case-fold-search t)
6544 (alist gnus-header-button-alist)
6546 (article-narrow-to-head)
6548 ;; Each alist entry.
6549 (setq entry (car alist)
6551 (goto-char (point-min))
6552 (while (re-search-forward (car entry) nil t)
6553 ;; Each header matching the entry.
6554 (setq beg (match-beginning 0))
6555 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6556 (match-beginning 0))
6559 (while (re-search-forward (eval (nth 1 entry)) end t)
6560 ;; Each match within a header.
6561 (let* ((entry (cdr entry))
6562 (start (match-beginning (nth 1 entry)))
6563 (end (match-end (nth 1 entry)))
6564 (form (nth 2 entry)))
6565 (goto-char (match-end 0))
6567 (gnus-article-add-button
6568 start end (nth 3 entry)
6569 (buffer-substring (match-beginning (nth 4 entry))
6570 (match-end (nth 4 entry)))))))
6571 (goto-char end)))))))
6573 ;;; External functions:
6575 (defun gnus-article-add-button (from to fun &optional data)
6576 "Create a button between FROM and TO with callback FUN and data DATA."
6577 (when gnus-article-button-face
6578 (gnus-overlay-put (gnus-make-overlay from to)
6579 'face gnus-article-button-face))
6580 (gnus-add-text-properties
6582 (nconc (and gnus-article-mouse-face
6583 (list gnus-mouse-face-prop gnus-article-mouse-face))
6584 (list 'gnus-callback fun)
6585 (and data (list 'gnus-data data))))
6586 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6587 :button-keymap gnus-widget-button-keymap))
6589 ;;; Internal functions:
6591 (defun gnus-article-set-globals ()
6593 (set-buffer gnus-summary-buffer)
6594 (gnus-set-global-variables)))
6596 (defun gnus-signature-toggle (end)
6598 (set-buffer gnus-article-buffer)
6599 (let ((inhibit-read-only t)
6600 (inhibit-point-motion-hooks t))
6601 (if (text-property-any end (point-max) 'article-type 'signature)
6603 (gnus-delete-wash-type 'signature)
6604 (gnus-remove-text-properties-when
6605 'article-type 'signature end (point-max)
6606 (cons 'article-type (cons 'signature
6607 gnus-hidden-properties))))
6608 (gnus-add-wash-type 'signature)
6609 (gnus-add-text-properties-when
6610 'article-type nil end (point-max)
6611 (cons 'article-type (cons 'signature
6612 gnus-hidden-properties)))))
6613 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6614 (gnus-set-mode-line 'article))))
6616 (defun gnus-button-entry ()
6617 ;; Return the first entry in `gnus-button-alist' matching this place.
6618 (let ((alist gnus-button-alist)
6621 (setq entry (pop alist))
6622 (if (looking-at (eval (car entry)))
6627 (defun gnus-button-push (marker)
6628 ;; Push button starting at MARKER.
6631 (let* ((entry (gnus-button-entry))
6632 (inhibit-point-motion-hooks t)
6634 (args (mapcar (lambda (group)
6635 (let ((string (match-string group)))
6636 (gnus-set-text-properties
6637 0 (length string) nil string)
6644 (fboundp (symbol-value fun)))
6645 (apply (symbol-value fun) args))
6647 (gnus-message 1 "You must define `%S' to use this button"
6648 (cons fun args)))))))
6650 (defun gnus-parse-news-url (url)
6651 (let (scheme server port group message-id articles)
6654 (goto-char (point-min))
6655 (when (looking-at "\\([A-Za-z]+\\):")
6656 (setq scheme (match-string 1))
6657 (goto-char (match-end 0)))
6658 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
6659 (setq server (match-string 1))
6660 (setq port (if (stringp (match-string 3))
6661 (string-to-number (match-string 3))
6663 (goto-char (match-end 0)))
6666 ((looking-at "\\(.*@.*\\)")
6667 (setq message-id (match-string 1)))
6668 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6669 (setq group (match-string 1)
6670 articles (split-string (match-string 2) "-")))
6671 ((looking-at "\\([^/]+\\)/?")
6672 (setq group (match-string 1)))
6674 (error "Unknown news URL syntax"))))
6675 (list scheme server port group message-id articles)))
6677 (defun gnus-button-handle-news (url)
6679 (destructuring-bind (scheme server port group message-id articles)
6680 (gnus-parse-news-url url)
6684 (set-buffer gnus-summary-buffer)
6686 (let ((gnus-refer-article-method
6687 (nconc (list (list 'nntp server))
6688 gnus-refer-article-method))
6689 (nntp-port-number (or port "nntp")))
6690 (gnus-message 7 "Fetching %s with %s"
6691 message-id gnus-refer-article-method)
6692 (gnus-summary-refer-article message-id))
6693 (gnus-summary-refer-article message-id))))
6695 (gnus-button-fetch-group url)))))
6697 (defun gnus-button-handle-man (url)
6699 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6700 (when (eq gnus-button-man-handler 'woman)
6701 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
6702 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6703 (funcall gnus-button-man-handler url))
6705 (defun gnus-button-handle-info-url (url)
6706 "Fetch an info URL."
6707 (setq url (mm-subst-char-in-string ?+ ?\ url))
6709 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6710 (gnus-info-find-node
6711 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6713 ")" (gnus-url-unhex-string (match-string 2 url)))))
6714 ((string-match "([^)\"]+)[^\"]+" url)
6716 (gnus-replace-in-string
6717 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6718 (gnus-info-find-node url))
6719 (t (error "Can't parse %s" url))))
6721 (defun gnus-button-handle-info-url-gnome (url)
6722 "Fetch GNOME style info URL."
6723 (setq url (mm-subst-char-in-string ?_ ?\ url))
6724 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6725 (gnus-info-find-node
6727 (gnus-url-unhex-string
6728 (match-string 1 url))
6730 (or (gnus-url-unhex-string
6731 (match-string 2 url))
6733 (error "Can't parse %s" url)))
6735 (defun gnus-button-handle-info-url-kde (url)
6736 "Fetch KDE style info URL."
6737 (gnus-info-find-node (gnus-url-unhex-string url)))
6739 (defun gnus-button-handle-info-keystrokes (url)
6740 "Call `info' when pushing the corresponding URL button."
6741 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6746 (defun gnus-button-message-id (message-id)
6749 (set-buffer gnus-summary-buffer)
6750 (gnus-summary-refer-article message-id)))
6752 (defun gnus-button-fetch-group (address)
6753 "Fetch GROUP specified by ADDRESS."
6754 (if (not (string-match "[:/]" address))
6755 ;; This is just a simple group url.
6756 (gnus-group-read-ephemeral-group address gnus-select-method)
6759 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6761 (error "Can't parse %s" address)
6762 (gnus-group-read-ephemeral-group
6763 (match-string 4 address)
6764 `(nntp ,(match-string 1 address)
6765 (nntp-address ,(match-string 1 address))
6766 (nntp-port-number ,(if (match-end 3)
6767 (match-string 3 address)
6770 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6772 (defun gnus-url-parse-query-string (query &optional downcase)
6773 (let (retval pairs cur key val)
6774 (setq pairs (split-string query "&"))
6776 (setq cur (car pairs)
6778 (if (not (string-match "=" cur))
6780 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6781 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6783 (setq key (downcase key)))
6784 (setq cur (assoc key retval))
6786 (setcdr cur (cons val (cdr cur)))
6787 (setq retval (cons (list key val) retval)))))
6790 (defun gnus-url-mailto (url)
6791 ;; Send mail to someone
6792 (when (string-match "mailto:/*\\(.*\\)" url)
6793 (setq url (substring url (match-beginning 1) nil)))
6794 (let (to args subject func)
6795 (setq args (gnus-url-parse-query-string
6796 (if (string-match "^\\?" url)
6798 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6799 (concat "to=" (match-string 1 url) "&"
6800 (match-string 2 url))
6801 (concat "to=" url)))
6803 subject (cdr-safe (assoc "subject" args)))
6806 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6809 (message-position-on-field (caar args)))
6810 (insert (gnus-replace-in-string
6811 (mapconcat 'identity (reverse (cdar args)) ", ")
6813 (setq args (cdr args)))
6816 (message-goto-subject))))
6818 (defun gnus-button-embedded-url (address)
6819 "Activate ADDRESS with `browse-url'."
6820 (browse-url (gnus-strip-whitespace address)))
6822 ;;; Next/prev buttons in the article buffer.
6824 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6825 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6827 (defvar gnus-prev-page-map
6828 (let ((map (make-sparse-keymap)))
6829 (unless (>= emacs-major-version 21)
6830 ;; XEmacs doesn't care.
6831 (set-keymap-parent map gnus-article-mode-map))
6832 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6833 (define-key map "\r" 'gnus-button-prev-page)
6836 (defvar gnus-next-page-map
6837 (let ((map (make-sparse-keymap)))
6838 (unless (>= emacs-major-version 21)
6839 ;; XEmacs doesn't care.
6840 (set-keymap-parent map gnus-article-mode-map))
6841 (define-key map gnus-mouse-2 'gnus-button-next-page)
6842 (define-key map "\r" 'gnus-button-next-page)
6845 (defun gnus-insert-prev-page-button ()
6847 (inhibit-read-only t))
6849 gnus-prev-page-line-format nil
6850 `(,@(gnus-local-map-property gnus-prev-page-map)
6852 gnus-callback gnus-article-button-prev-page
6853 article-type annotation))
6854 (widget-convert-button
6856 ;; Exclude a newline.
6859 :action 'gnus-button-prev-page
6860 :button-keymap gnus-prev-page-map)))
6862 (defun gnus-button-next-page (&optional args more-args)
6863 "Go to the next page."
6865 (let ((win (selected-window)))
6866 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6867 (gnus-article-next-page)
6868 (select-window win)))
6870 (defun gnus-button-prev-page (&optional args more-args)
6871 "Go to the prev page."
6873 (let ((win (selected-window)))
6874 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6875 (gnus-article-prev-page)
6876 (select-window win)))
6878 (defun gnus-insert-next-page-button ()
6880 (inhibit-read-only t))
6881 (gnus-eval-format gnus-next-page-line-format nil
6882 `(,@(gnus-local-map-property gnus-next-page-map)
6884 gnus-callback gnus-article-button-next-page
6885 article-type annotation))
6886 (widget-convert-button
6888 ;; Exclude a newline.
6891 :action 'gnus-button-next-page
6892 :button-keymap gnus-next-page-map)))
6894 (defun gnus-article-button-next-page (arg)
6895 "Go to the next page."
6897 (let ((win (selected-window)))
6898 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6899 (gnus-article-next-page)
6900 (select-window win)))
6902 (defun gnus-article-button-prev-page (arg)
6903 "Go to the prev page."
6905 (let ((win (selected-window)))
6906 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6907 (gnus-article-prev-page)
6908 (select-window win)))
6910 (defvar gnus-decode-header-methods
6911 '(mail-decode-encoded-word-region)
6912 "List of methods used to decode headers.
6914 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6915 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
6916 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6917 whose names match REGEXP.
6920 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6921 mail-decode-encoded-word-region
6922 (\"chinese\" . rfc1843-decode-region))
6925 (defvar gnus-decode-header-methods-cache nil)
6927 (defun gnus-multi-decode-header (start end)
6928 "Apply the functions from `gnus-encoded-word-methods' that match."
6929 (unless (and gnus-decode-header-methods-cache
6930 (eq gnus-newsgroup-name
6931 (car gnus-decode-header-methods-cache)))
6932 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6935 (nconc gnus-decode-header-methods-cache (list x))
6936 (if (and gnus-newsgroup-name
6937 (string-match (car x) gnus-newsgroup-name))
6938 (nconc gnus-decode-header-methods-cache
6940 gnus-decode-header-methods))
6941 (let ((xlist gnus-decode-header-methods-cache))
6944 (narrow-to-region start end)
6946 (funcall (pop xlist) (point-min) (point-max))))))
6949 ;;; Treatment top-level handling.
6952 (defun gnus-treat-article (condition &optional part-number total-parts type)
6953 (let ((length (- (point-max) (point-min)))
6954 (alist gnus-treatment-function-alist)
6955 (article-goto-body-goes-to-point-min-p t)
6959 (let ((list gnus-article-treat-types))
6961 (when (string-match (pop list) type)
6962 (throw 'found t)))))))
6963 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6965 (gnus-run-hooks 'gnus-part-display-hook)
6966 (dolist (elem alist)
6969 (when (gnus-buffer-live-p gnus-summary-buffer)
6970 (set-buffer gnus-summary-buffer))
6971 (symbol-value (car elem))))
6972 (when (and (or (consp val)
6974 (gnus-treat-predicate val)
6975 (or (not (get (car elem) 'highlight))
6978 (funcall (cadr elem)))))))
6980 ;; Dynamic variables.
6982 (defvar part-number)
6983 (defvar total-parts)
6988 (defun gnus-treat-predicate (val)
6995 (stringp (car val)))
6996 (apply 'gnus-or (mapcar `(lambda (s)
6997 (string-match s ,(or gnus-newsgroup-name "")))
7000 (let ((pred (pop val)))
7003 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7005 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7007 (not (gnus-treat-predicate (car val))))
7009 (equal (car val) type))
7011 (error "%S is not a valid predicate" pred)))))
7017 (eq part-number total-parts))
7021 (error "%S is not a valid value" val))))
7023 (defun gnus-article-encrypt-body (protocol &optional n)
7024 "Encrypt the article body."
7027 (or gnus-article-encrypt-protocol
7028 (completing-read "Encrypt protocol: "
7029 gnus-article-encrypt-protocol-alist
7031 current-prefix-arg))
7032 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7034 (error (format "Can't find the encrypt protocol %s" protocol)))
7035 (if (member gnus-newsgroup-name '("nndraft:delayed"
7038 (error "Can't encrypt the article in group %s"
7039 gnus-newsgroup-name))
7040 (gnus-summary-iterate n
7042 (set-buffer gnus-summary-buffer)
7043 (let ((mail-parse-charset gnus-newsgroup-charset)
7044 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7045 (summary-buffer gnus-summary-buffer)
7047 (gnus-set-global-variables)
7048 (when (gnus-group-read-only-p)
7049 (error "The current newsgroup does not support article encrypt"))
7050 (gnus-summary-show-article t)
7052 (or (mail-header-references gnus-current-headers) ""))
7053 (set-buffer gnus-article-buffer)
7054 (let* ((inhibit-read-only t)
7056 (mapcar (lambda (field)
7057 (and (save-restriction
7058 (message-narrow-to-head)
7059 (goto-char (point-min))
7060 (search-forward field nil t))
7062 (message-narrow-to-field)
7064 (delete-region (point-min) (point-max))
7066 '("Content-Type:" "Content-Transfer-Encoding:"
7067 "Content-Disposition:"))))
7068 (message-narrow-to-head)
7069 (message-remove-header "MIME-Version")
7070 (goto-char (point-max))
7071 (setq point (point))
7072 (insert (apply 'concat headers))
7074 (narrow-to-region point (point-max))
7075 (let ((message-options message-options))
7076 (message-options-set 'message-sender user-mail-address)
7077 (message-options-set 'message-recipients user-mail-address)
7078 (message-options-set 'message-sign-encrypt 'not)
7080 (goto-char (point-min))
7081 (insert "MIME-Version: 1.0\n")
7083 (gnus-summary-edit-article-done
7084 references nil summary-buffer t))
7085 (when gnus-keep-backlog
7086 (gnus-backlog-remove-article
7087 (car gnus-article-current) (cdr gnus-article-current)))
7089 (when (get-buffer gnus-original-article-buffer)
7090 (set-buffer gnus-original-article-buffer)
7091 (setq gnus-original-article nil)))
7092 (when gnus-use-cache
7093 (gnus-cache-update-article
7094 (car gnus-article-current) (cdr gnus-article-current))))))))
7096 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7097 "The following specs can be used:
7098 %t The security MIME type
7101 %D Details if button is pressed")
7103 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7104 "The following specs can be used:
7105 %t The security MIME type
7108 %D Details if button is pressed")
7110 (defvar gnus-mime-security-button-line-format-alist
7111 '((?t gnus-tmp-type ?s)
7112 (?i gnus-tmp-info ?s)
7113 (?d gnus-tmp-details ?s)
7114 (?D gnus-tmp-pressed-details ?s)))
7116 (defvar gnus-mime-security-button-map
7117 (let ((map (make-sparse-keymap)))
7118 (unless (>= (string-to-number emacs-version) 21)
7119 (set-keymap-parent map gnus-article-mode-map))
7120 (define-key map gnus-mouse-2 'gnus-article-push-button)
7121 (define-key map "\r" 'gnus-article-press-button)
7124 (defvar gnus-mime-security-details-buffer nil)
7126 (defvar gnus-mime-security-button-pressed nil)
7128 (defvar gnus-mime-security-show-details-inline t
7129 "If non-nil, show details in the article buffer.")
7131 (defun gnus-mime-security-verify-or-decrypt (handle)
7132 (mm-remove-parts (cdr handle))
7133 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7134 point (inhibit-read-only t))
7136 (goto-char (car region)))
7138 (narrow-to-region (point) (point))
7139 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7140 (let* ((mm-verify-option 'known)
7141 (mm-decrypt-option 'known)
7142 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7143 (unless (eq nparts (cdr handle))
7144 (mm-destroy-parts (cdr handle))
7145 (setcdr handle nparts))))
7146 (setq point (point))
7147 (gnus-mime-display-security handle)
7148 (goto-char (point-max)))
7150 (delete-region (point) (cdr region))
7151 (set-marker (car region) nil)
7152 (set-marker (cdr region) nil))
7155 (defun gnus-mime-security-show-details (handle)
7156 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7158 (gnus-message 5 "No details.")
7159 (if gnus-mime-security-show-details-inline
7160 (let ((gnus-mime-security-button-pressed
7161 (not (get-text-property (point) 'gnus-mime-details)))
7162 (gnus-mime-security-button-line-format
7163 (get-text-property (point) 'gnus-line-format))
7164 (inhibit-read-only t))
7166 (while (eq (get-text-property (point) 'gnus-line-format)
7167 gnus-mime-security-button-line-format)
7171 (narrow-to-region (point) (point))
7172 (gnus-insert-mime-security-button handle))
7173 (delete-region (point)
7174 (or (text-property-not-all
7177 gnus-mime-security-button-line-format)
7180 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7181 (with-current-buffer gnus-mime-security-details-buffer
7184 (setq gnus-mime-security-details-buffer
7185 (gnus-get-buffer-create "*MIME Security Details*")))
7186 (with-current-buffer gnus-mime-security-details-buffer
7188 (goto-char (point-min)))
7189 (pop-to-buffer gnus-mime-security-details-buffer)))))
7191 (defun gnus-mime-security-press-button (handle)
7193 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7194 (gnus-mime-security-show-details handle)
7195 (gnus-mime-security-verify-or-decrypt handle))))
7197 (defun gnus-insert-mime-security-button (handle &optional displayed)
7198 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7201 (or (nth 2 (assoc protocol mm-verify-function-alist))
7202 (nth 2 (assoc protocol mm-decrypt-function-alist))
7204 (if (equal (car handle) "multipart/signed")
7205 " Signed" " Encrypted")
7208 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7211 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7212 gnus-tmp-pressed-details
7214 (setq gnus-tmp-details
7215 (if gnus-tmp-details
7216 (concat "\n" gnus-tmp-details)
7218 (setq gnus-tmp-pressed-details
7219 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7224 gnus-mime-security-button-line-format
7225 gnus-mime-security-button-line-format-alist
7226 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7227 gnus-callback gnus-mime-security-press-button
7228 gnus-line-format ,gnus-mime-security-button-line-format
7229 gnus-mime-details ,gnus-mime-security-button-pressed
7230 article-type annotation
7233 ;; Exclude a newline.
7236 (widget-convert-button
7239 :action 'gnus-widget-press-button
7240 :button-keymap gnus-mime-security-button-map
7242 (lambda (widget/window &optional overlay pos)
7243 ;; Needed to properly clear the message due to a bug in
7244 ;; wid-edit (XEmacs only).
7245 (when (boundp 'help-echo-owns-message)
7246 (setq help-echo-owns-message t))
7249 (aref gnus-mouse-2 0))))))
7251 (defun gnus-mime-display-security (handle)
7253 (narrow-to-region (point) (point))
7254 (unless (gnus-unbuttonized-mime-type-p (car handle))
7255 (gnus-insert-mime-security-button handle))
7256 (gnus-mime-display-mixed (cdr handle))
7259 (unless (gnus-unbuttonized-mime-type-p (car handle))
7260 (let ((gnus-mime-security-button-line-format
7261 gnus-mime-security-button-end-line-format))
7262 (gnus-insert-mime-security-button handle)))
7263 (mm-set-handle-multipart-parameter
7265 (cons (set-marker (make-marker) (point-min))
7266 (set-marker (make-marker) (point-max))))))
7272 (run-hooks 'gnus-art-load-hook)
7274 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7275 ;;; gnus-art.el ends here