1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
33 (defvar w3m-minor-mode-map))
36 ;; Avoid the "Recursive load suspected" error in Emacs 21.1.
38 (let ((recursive-load-depth-limit 100))
51 (autoload 'gnus-msg-mail "gnus-msg" nil t)
52 (autoload 'gnus-button-mailto "gnus-msg")
53 (autoload 'gnus-button-reply "gnus-msg" nil t)
54 (autoload 'parse-time-string "parse-time" nil nil)
55 (autoload 'ansi-color-apply-on-region "ansi-color")
57 (defgroup gnus-article nil
59 :link '(custom-manual "(gnus)Article Buffer")
62 (defgroup gnus-article-treat nil
63 "Treating article parts."
64 :link '(custom-manual "(gnus)Article Hiding")
67 (defgroup gnus-article-hiding nil
68 "Hiding article parts."
69 :link '(custom-manual "(gnus)Article Hiding")
72 (defgroup gnus-article-highlight nil
73 "Article highlighting."
74 :link '(custom-manual "(gnus)Article Highlighting")
78 (defgroup gnus-article-signature nil
80 :link '(custom-manual "(gnus)Article Signature")
83 (defgroup gnus-article-headers nil
85 :link '(custom-manual "(gnus)Hiding Headers")
88 (defgroup gnus-article-washing nil
89 "Special commands on articles."
90 :link '(custom-manual "(gnus)Article Washing")
93 (defgroup gnus-article-emphasis nil
94 "Fontisizing articles."
95 :link '(custom-manual "(gnus)Article Fontisizing")
98 (defgroup gnus-article-saving nil
100 :link '(custom-manual "(gnus)Saving Articles")
101 :group 'gnus-article)
103 (defgroup gnus-article-mime nil
104 "Worshiping the MIME wonder."
105 :link '(custom-manual "(gnus)Using MIME")
106 :group 'gnus-article)
108 (defgroup gnus-article-buttons nil
109 "Pushable buttons in the article buffer."
110 :link '(custom-manual "(gnus)Article Buttons")
111 :group 'gnus-article)
113 (defgroup gnus-article-various nil
114 "Other article options."
115 :link '(custom-manual "(gnus)Misc Article")
116 :group 'gnus-article)
118 (defcustom gnus-ignored-headers
121 (concat "^" header ":"))
122 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
123 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
124 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
125 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
126 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
127 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
128 "X-Attribution" "X-Originating-IP" "Delivered-To"
129 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
130 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
131 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
132 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
133 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
134 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
135 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
136 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
137 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
138 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
139 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
140 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
141 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
142 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
143 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
144 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
145 "List-[A-Za-z]+" "X-Listprocessor-Version"
146 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
147 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
148 "X-Received" "Content-length" "X-precedence"
149 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
150 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
151 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
152 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
153 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
154 "X-Content-length" "X-Posting-Agent" "Original-Received"
155 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
156 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
157 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
158 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
159 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
160 "*All headers that start with this regexp will be hidden.
161 This variable can also be a list of regexps of headers to be ignored.
162 If `gnus-visible-headers' is non-nil, this variable will be ignored."
163 :type '(choice :custom-show nil
166 :group 'gnus-article-hiding)
168 (defcustom gnus-visible-headers
169 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
170 "*All headers that do not match this regexp will be hidden.
171 This variable can also be a list of regexp of headers to remain visible.
172 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
173 :type '(repeat :value-to-internal (lambda (widget value)
174 (custom-split-regexp-maybe value))
175 :match (lambda (widget value)
177 (widget-editable-list-match widget value)))
179 :group 'gnus-article-hiding)
181 (defcustom gnus-sorted-header-list
182 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
183 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
184 "*This variable is a list of regular expressions.
185 If it is non-nil, headers that match the regular expressions will
186 be placed first in the article buffer in the sequence specified by
188 :type '(repeat regexp)
189 :group 'gnus-article-hiding)
191 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
192 "Headers that are only to be displayed if they have interesting data.
193 Possible values in this list are:
195 'empty Headers with no content.
196 'newsgroups Newsgroup identical to Gnus group.
197 'to-address To identical to To-address.
198 'to-list To identical to To-list.
199 'cc-list CC identical to To-list.
200 'followup-to Followup-to identical to Newsgroups.
201 'reply-to Reply-to identical to From.
202 'date Date less than four days old.
203 'long-to To and/or Cc longer than 1024 characters.
204 'many-to Multiple To and/or Cc."
205 :type '(set (const :tag "Headers with no content." empty)
206 (const :tag "Newsgroups identical to Gnus group." newsgroups)
207 (const :tag "To identical to To-address." to-address)
208 (const :tag "To identical to To-list." to-list)
209 (const :tag "CC identical to To-list." cc-list)
210 (const :tag "Followup-to identical to Newsgroups." followup-to)
211 (const :tag "Reply-to identical to From." reply-to)
212 (const :tag "Date less than four days old." date)
213 (const :tag "To and/or Cc longer than 1024 characters." long-to)
214 (const :tag "Multiple To and/or Cc headers." many-to))
215 :group 'gnus-article-hiding)
217 (defcustom gnus-article-skip-boring nil
218 "Skip over text that is not worth reading.
219 By default, if you set this t, then Gnus will display citations and
220 signatures, but will never scroll down to show you a page consisting
221 only of boring text. Boring text is controlled by
222 `gnus-article-boring-faces'."
225 :group 'gnus-article-hiding)
227 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
228 "Regexp matching signature separator.
229 This can also be a list of regexps. In that case, it will be checked
230 from head to tail looking for a separator. Searches will be done from
231 the end of the buffer."
232 :type '(choice :format "%{%t%}: %[Value Menu%]\n%v"
234 (repeat :tag "List of regexp" regexp))
235 :group 'gnus-article-signature)
237 (defcustom gnus-signature-limit nil
238 "Provide a limit to what is considered a signature.
239 If it is a number, no signature may not be longer (in characters) than
240 that number. If it is a floating point number, no signature may be
241 longer (in lines) than that number. If it is a function, the function
242 will be called without any parameters, and if it returns nil, there is
243 no signature in the buffer. If it is a string, it will be used as a
244 regexp. If it matches, the text in question is not a signature.
246 This can also be a list of the above values."
247 :type '(choice (const nil)
250 (function :value fun)
251 (regexp :value ".*"))
252 :group 'gnus-article-signature)
254 (defcustom gnus-hidden-properties '(invisible t intangible t)
255 "Property list to use for hiding text."
257 :group 'gnus-article-hiding)
259 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
260 ;; frames in a session.
261 (defcustom gnus-article-x-face-command
262 (if (featurep 'xemacs)
263 (if (or (gnus-image-type-available-p 'xface)
264 (gnus-image-type-available-p 'pbm))
265 'gnus-display-x-face-in-from
266 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
267 (if (gnus-image-type-available-p 'pbm)
268 'gnus-display-x-face-in-from
269 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
271 "*String or function to be executed to display an X-Face header.
272 If it is a string, the command will be executed in a sub-shell
273 asynchronously. The compressed face will be piped to this command."
274 :type `(choice string
275 (function-item gnus-display-x-face-in-from)
279 :group 'gnus-article-washing)
281 (defcustom gnus-article-x-face-too-ugly nil
282 "Regexp matching posters whose face shouldn't be shown automatically."
283 :type '(choice regexp (const nil))
284 :group 'gnus-article-washing)
286 (defcustom gnus-article-banner-alist nil
287 "Banner alist for stripping.
289 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
291 :type '(repeat (cons symbol regexp))
292 :group 'gnus-article-washing)
294 (gnus-define-group-parameter
297 "Alist of regexps (to match group names) and banner."
298 :variable-group gnus-article-washing
300 '(choice :tag "Banner"
302 (const :tag "Remove signature" signature)
303 (symbol :tag "Item in `gnus-article-banner-alist'" none)
305 (const :tag "None" nil))
307 "If non-nil, specify how to remove `banners' from articles.
309 Symbol `signature' means to remove signatures delimited by
310 `gnus-signature-separator'. Any other symbol is used to look up a
311 regular expression to match the banner in `gnus-article-banner-alist'.
312 A string is used as a regular expression to match the banner
315 (defcustom gnus-article-address-banner-alist nil
316 "Alist of mail addresses and banners.
317 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
318 to match a mail address in the From: header, BANNER is one of a symbol
319 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
320 If ADDRESS matches author's mail address, it will remove things like
321 advertisements. For example:
323 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
327 (regexp :tag "Address")
328 (choice :tag "Banner" :value nil
329 (const :tag "Remove signature" signature)
330 (symbol :tag "Item in `gnus-article-banner-alist'" none)
332 (const :tag "None" nil))))
334 :group 'gnus-article-washing)
336 (defmacro gnus-emphasis-custom-with-format (&rest body)
338 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
339 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
342 (defun gnus-emphasis-custom-value-to-external (value)
343 (gnus-emphasis-custom-with-format
344 (if (consp (car value))
345 (list (format format (car (car value)) (cdr (car value)))
347 (if (nth 1 value) 2 3)
351 (defun gnus-emphasis-custom-value-to-internal (value)
352 (gnus-emphasis-custom-with-format
353 (let ((regexp (concat "\\`"
354 (format (regexp-quote format)
355 "\\([^()]+\\)" "\\([^()]+\\)")
358 (if (string-match regexp (setq pattern (car value)))
359 (list (cons (match-string 1 pattern) (match-string 2 pattern))
364 (defcustom gnus-emphasis-alist
366 '(("\\*" "\\*" bold nil 2)
369 ("_/" "/_" underline-italic)
370 ("_\\*" "\\*_" underline-bold)
371 ("\\*/" "/\\*" bold-italic)
372 ("_\\*/" "/\\*_" underline-bold-italic))))
374 (gnus-emphasis-custom-with-format
375 (mapcar (lambda (spec)
376 (list (format format (car spec) (cadr spec))
379 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
381 '(;; I've never seen anyone use this strikethru convention whereas I've
382 ;; several times seen it triggered by normal text. --Stef
383 ;; Miles suggests that this form is sometimes used but for italics,
384 ;; so maybe we should map it to `italic'.
385 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
386 ;; 2 3 gnus-emphasis-strikethru)
387 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
388 2 3 gnus-emphasis-underline))))
389 "*Alist that says how to fontify certain phrases.
390 Each item looks like this:
392 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
394 The first element is a regular expression to be matched. The second
395 is a number that says what regular expression grouping used to find
396 the entire emphasized word. The third is a number that says what
397 regexp grouping should be displayed and highlighted. The fourth
398 is the face used for highlighting."
402 :format "%[Customizing Style%]\n%v"
404 (group :tag "Default"
405 :value ("" 0 0 default)
408 (let ((value (widget-get
409 (cadr (widget-get (widget-get widget :parent)
412 (if (not (eq (nth 2 value) 'default))
416 (gnus-emphasis-custom-value-to-external value))))
417 (widget-group-value-create widget))
419 (integer :format "Match group: %v")
420 (integer :format "Emphasize group: %v")
423 :value (("_" . "_") nil default)
425 (regexp :format "Start regexp: %v")
426 (regexp :format "End regexp: %v"))
427 (boolean :format "Show start and end patterns: %[%v%]\n"
428 :on " On " :off " Off ")
430 :get (lambda (symbol)
431 (mapcar 'gnus-emphasis-custom-value-to-internal
432 (default-value symbol)))
433 :set (lambda (symbol value)
434 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
436 :group 'gnus-article-emphasis)
438 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
439 "A regexp to describe whitespace which should not be emphasized.
440 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
441 The former avoids underlining of leading and trailing whitespace,
442 and the latter avoids underlining any whitespace at all."
444 :group 'gnus-article-emphasis
447 (defface gnus-emphasis-bold '((t (:bold t)))
448 "Face used for displaying strong emphasized text (*word*)."
449 :group 'gnus-article-emphasis)
451 (defface gnus-emphasis-italic '((t (:italic t)))
452 "Face used for displaying italic emphasized text (/word/)."
453 :group 'gnus-article-emphasis)
455 (defface gnus-emphasis-underline '((t (:underline t)))
456 "Face used for displaying underlined emphasized text (_word_)."
457 :group 'gnus-article-emphasis)
459 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
460 "Face used for displaying underlined bold emphasized text (_*word*_)."
461 :group 'gnus-article-emphasis)
463 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
464 "Face used for displaying underlined italic emphasized text (_/word/_)."
465 :group 'gnus-article-emphasis)
467 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
468 "Face used for displaying bold italic emphasized text (/*word*/)."
469 :group 'gnus-article-emphasis)
471 (defface gnus-emphasis-underline-bold-italic
472 '((t (:bold t :italic t :underline t)))
473 "Face used for displaying underlined bold italic emphasized text.
474 Example: (_/*word*/_)."
475 :group 'gnus-article-emphasis)
477 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
478 '((t (:strikethru t)))
479 '((t (:strike-through t))))
480 "Face used for displaying strike-through text (-word-)."
481 :group 'gnus-article-emphasis)
483 (defface gnus-emphasis-highlight-words
484 '((t (:background "black" :foreground "yellow")))
485 "Face used for displaying highlighted words."
486 :group 'gnus-article-emphasis)
488 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
489 "Format for display of Date headers in article bodies.
490 See `format-time-string' for the possible values.
492 The variable can also be function, which should return a complete Date
493 header. The function is called with one argument, the time, which can
494 be fed to `format-time-string'."
495 :type '(choice string function)
496 :link '(custom-manual "(gnus)Article Date")
497 :group 'gnus-article-washing)
499 (defcustom gnus-save-all-headers t
500 "*If non-nil, don't remove any headers before saving."
501 :group 'gnus-article-saving
504 (defcustom gnus-prompt-before-saving 'always
505 "*This variable says how much prompting is to be done when saving articles.
506 If it is nil, no prompting will be done, and the articles will be
507 saved to the default files. If this variable is `always', each and
508 every article that is saved will be preceded by a prompt, even when
509 saving large batches of articles. If this variable is neither nil not
510 `always', there the user will be prompted once for a file name for
511 each invocation of the saving commands."
512 :group 'gnus-article-saving
513 :type '(choice (item always)
514 (item :tag "never" nil)
515 (sexp :tag "once" :format "%t\n" :value t)))
517 (defcustom gnus-saved-headers gnus-visible-headers
518 "Headers to keep if `gnus-save-all-headers' is nil.
519 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
520 If that variable is nil, however, all headers that match this regexp
521 will be kept while the rest will be deleted before saving."
522 :group 'gnus-article-saving
525 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
526 "A function to save articles in your favourite format.
527 The function must be interactively callable (in other words, it must
528 be an Emacs command).
530 Gnus provides the following functions:
532 * gnus-summary-save-in-rmail (Rmail format)
533 * gnus-summary-save-in-mail (Unix mail format)
534 * gnus-summary-save-in-folder (MH folder)
535 * gnus-summary-save-in-file (article format)
536 * gnus-summary-save-body-in-file (article body)
537 * gnus-summary-save-in-vm (use VM's folder format)
538 * gnus-summary-write-to-file (article format -- overwrite)."
539 :group 'gnus-article-saving
540 :type '(radio (function-item gnus-summary-save-in-rmail)
541 (function-item gnus-summary-save-in-mail)
542 (function-item gnus-summary-save-in-folder)
543 (function-item gnus-summary-save-in-file)
544 (function-item gnus-summary-save-body-in-file)
545 (function-item gnus-summary-save-in-vm)
546 (function-item gnus-summary-write-to-file)))
548 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
549 "A function generating a file name to save articles in Rmail format.
550 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
551 :group 'gnus-article-saving
554 (defcustom gnus-mail-save-name 'gnus-plain-save-name
555 "A function generating a file name to save articles in Unix mail format.
556 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
557 :group 'gnus-article-saving
560 (defcustom gnus-folder-save-name 'gnus-folder-save-name
561 "A function generating a file name to save articles in MH folder.
562 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
563 :group 'gnus-article-saving
566 (defcustom gnus-file-save-name 'gnus-numeric-save-name
567 "A function generating a file name to save articles in article format.
568 The function is called with NEWSGROUP, HEADERS, and optional
570 :group 'gnus-article-saving
573 (defcustom gnus-split-methods
574 '((gnus-article-archive-name)
575 (gnus-article-nndoc-name))
576 "*Variable used to suggest where articles are to be saved.
577 For instance, if you would like to save articles related to Gnus in
578 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
579 you could set this variable to something like:
581 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
582 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
584 This variable is an alist where the key is the match and the
585 value is a list of possible files to save in if the match is
588 If the match is a string, it is used as a regexp match on the
589 article. If the match is a symbol, that symbol will be funcalled
590 from the buffer of the article to be saved with the newsgroup as
591 the parameter. If it is a list, it will be evaled in the same
594 If this form or function returns a string, this string will be
595 used as a possible file name; and if it returns a non-nil list,
596 that list will be used as possible file names."
597 :group 'gnus-article-saving
598 :type '(repeat (choice (list :value (fun) function)
599 (cons :value ("" "") regexp (repeat string))
602 (defcustom gnus-page-delimiter "^\^L"
603 "*Regexp describing what to use as article page delimiters.
604 The default value is \"^\^L\", which is a form linefeed at the
605 beginning of a line."
607 :group 'gnus-article-various)
609 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
610 "*The format specification for the article mode line.
611 See `gnus-summary-mode-line-format' for a closer description.
613 The following additional specs are available:
615 %w The article washing status.
616 %m The number of MIME parts in the article."
618 :group 'gnus-article-various)
620 (defcustom gnus-article-mode-hook nil
621 "*A hook for Gnus article mode."
623 :group 'gnus-article-various)
625 (when (featurep 'xemacs)
626 ;; Extracted from gnus-xmas-define in order to preserve user settings
627 (when (fboundp 'turn-off-scroll-in-place)
628 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
629 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
630 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
632 (defcustom gnus-article-menu-hook nil
633 "*Hook run after the creation of the article mode menu."
635 :group 'gnus-article-various)
637 (defcustom gnus-article-prepare-hook nil
638 "*A hook called after an article has been prepared in the article buffer."
640 :group 'gnus-article-various)
642 (defcustom gnus-copy-article-ignored-headers nil
643 "List of headers to be removed when copying an article.
644 Each element is a regular expression."
645 :version "23.0" ;; No Gnus
646 :type '(repeat regexp)
647 :group 'gnus-article-various)
649 (make-obsolete-variable 'gnus-article-hide-pgp-hook
650 "This variable is obsolete in Gnus 5.10.")
652 (defcustom gnus-article-button-face 'bold
653 "Face used for highlighting buttons in the article buffer.
655 An article button is a piece of text that you can activate by pressing
656 `RET' or `mouse-2' above it."
658 :group 'gnus-article-buttons)
660 (defcustom gnus-article-mouse-face 'highlight
661 "Face used for mouse highlighting in the article buffer.
663 Article buttons will be displayed in this face when the cursor is
666 :group 'gnus-article-buttons)
668 (defcustom gnus-signature-face 'gnus-signature
669 "Face used for highlighting a signature in the article buffer.
670 Obsolete; use the face `gnus-signature' for customizations instead."
672 :group 'gnus-article-highlight
673 :group 'gnus-article-signature)
675 (defface gnus-signature
678 "Face used for highlighting a signature in the article buffer."
679 :group 'gnus-article-highlight
680 :group 'gnus-article-signature)
681 ;; backward-compatibility alias
682 (put 'gnus-signature-face 'face-alias 'gnus-signature)
684 (defface gnus-header-from
687 (:foreground "spring green"))
690 (:foreground "red3"))
693 "Face used for displaying from headers."
694 :group 'gnus-article-headers
695 :group 'gnus-article-highlight)
696 ;; backward-compatibility alias
697 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
699 (defface gnus-header-subject
702 (:foreground "SeaGreen3"))
705 (:foreground "red4"))
707 (:bold t :italic t)))
708 "Face used for displaying subject headers."
709 :group 'gnus-article-headers
710 :group 'gnus-article-highlight)
711 ;; backward-compatibility alias
712 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
714 (defface gnus-header-newsgroups
717 (:foreground "yellow" :italic t))
720 (:foreground "MidnightBlue" :italic t))
723 "Face used for displaying newsgroups headers.
724 In the default setup this face is only used for crossposted
726 :group 'gnus-article-headers
727 :group 'gnus-article-highlight)
728 ;; backward-compatibility alias
729 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
731 (defface gnus-header-name
734 (:foreground "SeaGreen"))
737 (:foreground "maroon"))
740 "Face used for displaying header names."
741 :group 'gnus-article-headers
742 :group 'gnus-article-highlight)
743 ;; backward-compatibility alias
744 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
746 (defface gnus-header-content
749 (:foreground "forest green" :italic t))
752 (:foreground "indianred4" :italic t))
754 (:italic t))) "Face used for displaying header content."
755 :group 'gnus-article-headers
756 :group 'gnus-article-highlight)
757 ;; backward-compatibility alias
758 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
760 (defcustom gnus-header-face-alist
761 '(("From" nil gnus-header-from)
762 ("Subject" nil gnus-header-subject)
763 ("Newsgroups:.*," nil gnus-header-newsgroups)
764 ("" gnus-header-name gnus-header-content))
765 "*Controls highlighting of article headers.
767 An alist of the form (HEADER NAME CONTENT).
769 HEADER is a regular expression which should match the name of a
770 header and NAME and CONTENT are either face names or nil.
772 The name of each header field will be displayed using the face
773 specified by the first element in the list where HEADER matches
774 the header name and NAME is non-nil. Similarly, the content will
775 be displayed by the first non-nil matching CONTENT face."
776 :group 'gnus-article-headers
777 :group 'gnus-article-highlight
778 :type '(repeat (list (regexp :tag "Header")
780 (item :tag "skip" nil)
781 (face :value default))
782 (choice :tag "Content"
783 (item :tag "skip" nil)
784 (face :value default)))))
786 (defcustom gnus-article-decode-hook
787 '(article-decode-charset article-decode-encoded-words
788 article-decode-group-name article-decode-idna-rhs)
789 "*Hook run to decode charsets in articles."
790 :group 'gnus-article-headers
793 (defcustom gnus-display-mime-function 'gnus-display-mime
794 "Function to display MIME articles."
795 :group 'gnus-article-mime
798 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
799 "Function used to decode headers.")
801 (defvar gnus-article-dumbquotes-map
821 "Table for MS-to-Latin1 translation.")
823 (defcustom gnus-ignored-mime-types nil
824 "List of MIME types that should be ignored by Gnus."
826 :group 'gnus-article-mime
827 :type '(repeat regexp))
829 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
830 "List of MIME types that should not be given buttons when rendered inline.
831 See also `gnus-buttonized-mime-types' which may override this variable.
832 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
834 :group 'gnus-article-mime
835 :type '(repeat regexp))
837 (defcustom gnus-buttonized-mime-types nil
838 "List of MIME types that should be given buttons when rendered inline.
839 If set, this variable overrides `gnus-unbuttonized-mime-types'.
840 To see e.g. security buttons you could set this to
841 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
842 this list to display radio buttons that allow you to choose one of two
843 media types those mails include. See also `mm-discouraged-alternatives'.
844 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
846 :group 'gnus-article-mime
847 :type '(repeat regexp))
849 (defcustom gnus-inhibit-mime-unbuttonizing nil
850 "If non-nil, all MIME parts get buttons.
851 When nil (the default value), then some MIME parts do not get buttons,
852 as described by the variables `gnus-buttonized-mime-types' and
853 `gnus-unbuttonized-mime-types'."
855 :group 'gnus-article-mime
858 (defcustom gnus-body-boundary-delimiter "_"
859 "String used to delimit header and body.
860 This variable is used by `gnus-article-treat-body-boundary' which can
861 be controlled by `gnus-treat-body-boundary'."
863 :group 'gnus-article-various
864 :type '(choice (item :tag "None" :value nil)
867 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
869 "Defines the location of the faces database.
870 For information on obtaining this database of pretty pictures, please
871 see http://www.cs.indiana.edu/picons/ftp/index.html"
873 :type '(repeat directory)
874 :link '(url-link :tag "download"
875 "http://www.cs.indiana.edu/picons/ftp/index.html")
876 :link '(custom-manual "(gnus)Picons")
879 (defun gnus-picons-installed-p ()
880 "Say whether picons are installed on your machine."
881 (let ((installed nil))
882 (dolist (database gnus-picon-databases)
883 (when (file-exists-p database)
887 (defcustom gnus-article-mime-part-function nil
888 "Function called with a MIME handle as the argument.
889 This is meant for people who want to do something automatic based
890 on parts -- for instance, adding Vcard info to a database."
891 :group 'gnus-article-mime
892 :type '(choice (const nil)
895 (defcustom gnus-mime-multipart-functions nil
896 "An alist of MIME types to functions to display them."
898 :group 'gnus-article-mime
899 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
901 (defcustom gnus-article-date-lapsed-new-header nil
902 "Whether the X-Sent and Date headers can coexist.
903 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
904 either replace the old \"Date:\" header (if this variable is nil), or
905 be added below it (otherwise)."
907 :group 'gnus-article-headers
910 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
911 "Function called with a MIME handle as the argument.
912 This is meant for people who want to view first matched part.
913 For `undisplayed-alternative' (default), the first undisplayed
914 part or alternative part is used. For `undisplayed', the first
915 undisplayed part is used. For a function, the first part which
916 the function return t is used. For nil, the first part is
919 :group 'gnus-article-mime
921 (item :tag "first" :value nil)
922 (item :tag "undisplayed" :value undisplayed)
923 (item :tag "undisplayed or alternative"
924 :value undisplayed-alternative)
927 (defcustom gnus-mime-action-alist
928 '(("save to file" . gnus-mime-save-part)
929 ("save and strip" . gnus-mime-save-part-and-strip)
930 ("replace with file" . gnus-mime-replace-part)
931 ("delete part" . gnus-mime-delete-part)
932 ("display as text" . gnus-mime-inline-part)
933 ("view the part" . gnus-mime-view-part)
934 ("pipe to command" . gnus-mime-pipe-part)
935 ("toggle display" . gnus-article-press-button)
936 ("toggle display" . gnus-article-view-part-as-charset)
937 ("view as type" . gnus-mime-view-part-as-type)
938 ("view internally" . gnus-mime-view-part-internally)
939 ("view externally" . gnus-mime-view-part-externally))
940 "An alist of actions that run on the MIME attachment."
941 :group 'gnus-article-mime
942 :type '(repeat (cons (string :tag "name")
945 (defcustom gnus-auto-select-part 1
946 "Advance to next MIME part when deleting or stripping parts.
948 When 0, point will be placed on the same part as before. When
949 positive (negative), move point forward (backwards) this many
950 parts. When nil, redisplay article."
951 :version "23.0" ;; No Gnus
952 :group 'gnus-article-mime
953 :type '(choice (const nil :tag "Redisplay article.")
954 (const 1 :tag "Next part.")
955 (const 0 :tag "Current part.")
959 ;;; The treatment variables
962 (defvar gnus-part-display-hook nil
963 "Hook called on parts that are to receive treatment.")
965 (defvar gnus-article-treat-custom
966 '(choice (const :tag "Off" nil)
968 (const :tag "Header" head)
969 (const :tag "First" first)
970 (const :tag "Last" last)
971 (integer :tag "Less")
972 (repeat :tag "Groups" regexp)
973 (sexp :tag "Predicate")))
975 (defvar gnus-article-treat-head-custom
976 '(choice (const :tag "Off" nil)
977 (const :tag "Header" head)))
979 (defvar gnus-article-treat-types '("text/plain")
982 (defvar gnus-inhibit-treatment nil
983 "Whether to inhibit treatment.")
985 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
986 "Highlight the signature.
987 Valid values are nil, t, `head', `first', `last', an integer or a
988 predicate. See Info node `(gnus)Customizing Articles'."
989 :group 'gnus-article-treat
990 :link '(custom-manual "(gnus)Customizing Articles")
991 :type gnus-article-treat-custom)
992 (put 'gnus-treat-highlight-signature 'highlight t)
994 (defcustom gnus-treat-buttonize 100000
996 Valid values are nil, t, `head', `first', `last', an integer or a
997 predicate. See Info node `(gnus)Customizing Articles'."
998 :group 'gnus-article-treat
999 :link '(custom-manual "(gnus)Customizing Articles")
1000 :type gnus-article-treat-custom)
1001 (put 'gnus-treat-buttonize 'highlight t)
1003 (defcustom gnus-treat-buttonize-head 'head
1004 "Add buttons to the head.
1005 Valid values are nil, t, `head', `first', `last', an integer or a
1006 predicate. See Info node `(gnus)Customizing Articles'."
1007 :group 'gnus-article-treat
1008 :link '(custom-manual "(gnus)Customizing Articles")
1009 :type gnus-article-treat-head-custom)
1010 (put 'gnus-treat-buttonize-head 'highlight t)
1012 (defcustom gnus-treat-emphasize
1013 (and (or window-system
1017 Valid values are nil, t, `head', `first', `last', an integer or a
1018 predicate. See Info node `(gnus)Customizing Articles'."
1019 :group 'gnus-article-treat
1020 :link '(custom-manual "(gnus)Customizing Articles")
1021 :type gnus-article-treat-custom)
1022 (put 'gnus-treat-emphasize 'highlight t)
1024 (defcustom gnus-treat-strip-cr nil
1025 "Remove carriage returns.
1026 Valid values are nil, t, `head', `first', `last', an integer or a
1027 predicate. See Info node `(gnus)Customizing Articles'."
1029 :group 'gnus-article-treat
1030 :link '(custom-manual "(gnus)Customizing Articles")
1031 :type gnus-article-treat-custom)
1033 (defcustom gnus-treat-unsplit-urls nil
1034 "Remove newlines from within URLs.
1035 Valid values are nil, t, `head', `first', `last', an integer or a
1036 predicate. See Info node `(gnus)Customizing Articles'."
1038 :group 'gnus-article-treat
1039 :link '(custom-manual "(gnus)Customizing Articles")
1040 :type gnus-article-treat-custom)
1042 (defcustom gnus-treat-leading-whitespace nil
1043 "Remove leading whitespace in headers.
1044 Valid values are nil, t, `head', `first', `last', an integer or a
1045 predicate. See Info node `(gnus)Customizing Articles'."
1047 :group 'gnus-article-treat
1048 :link '(custom-manual "(gnus)Customizing Articles")
1049 :type gnus-article-treat-custom)
1051 (defcustom gnus-treat-hide-headers 'head
1053 Valid values are nil, t, `head', `first', `last', an integer or a
1054 predicate. See Info node `(gnus)Customizing Articles'."
1055 :group 'gnus-article-treat
1056 :link '(custom-manual "(gnus)Customizing Articles")
1057 :type gnus-article-treat-head-custom)
1059 (defcustom gnus-treat-hide-boring-headers nil
1060 "Hide boring headers.
1061 Valid values are nil, t, `head', `first', `last', an integer or a
1062 predicate. See Info node `(gnus)Customizing Articles'."
1063 :group 'gnus-article-treat
1064 :link '(custom-manual "(gnus)Customizing Articles")
1065 :type gnus-article-treat-head-custom)
1067 (defcustom gnus-treat-hide-signature nil
1068 "Hide the signature.
1069 Valid values are nil, t, `head', `first', `last', an integer or a
1070 predicate. See Info node `(gnus)Customizing Articles'."
1071 :group 'gnus-article-treat
1072 :link '(custom-manual "(gnus)Customizing Articles")
1073 :type gnus-article-treat-custom)
1075 (defcustom gnus-treat-fill-article nil
1077 Valid values are nil, t, `head', `first', `last', an integer or a
1078 predicate. See Info node `(gnus)Customizing Articles'."
1079 :group 'gnus-article-treat
1080 :link '(custom-manual "(gnus)Customizing Articles")
1081 :type gnus-article-treat-custom)
1083 (defcustom gnus-treat-hide-citation nil
1085 Valid values are nil, t, `head', `first', `last', an integer or a
1086 predicate. See Info node `(gnus)Customizing Articles'."
1087 :group 'gnus-article-treat
1088 :link '(custom-manual "(gnus)Customizing Articles")
1089 :type gnus-article-treat-custom)
1091 (defcustom gnus-treat-hide-citation-maybe nil
1093 Valid values are nil, t, `head', `first', `last', an integer or a
1094 predicate. See Info node `(gnus)Customizing Articles'."
1095 :group 'gnus-article-treat
1096 :link '(custom-manual "(gnus)Customizing Articles")
1097 :type gnus-article-treat-custom)
1099 (defcustom gnus-treat-strip-list-identifiers 'head
1100 "Strip list identifiers from `gnus-list-identifiers`.
1101 Valid values are nil, t, `head', `first', `last', an integer or a
1102 predicate. See Info node `(gnus)Customizing Articles'."
1104 :group 'gnus-article-treat
1105 :link '(custom-manual "(gnus)Customizing Articles")
1106 :type gnus-article-treat-custom)
1108 (make-obsolete-variable 'gnus-treat-strip-pgp
1109 "This option is obsolete in Gnus 5.10.")
1111 (defcustom gnus-treat-strip-pem nil
1112 "Strip PEM signatures.
1113 Valid values are nil, t, `head', `first', `last', an integer or a
1114 predicate. See Info node `(gnus)Customizing Articles'."
1115 :group 'gnus-article-treat
1116 :link '(custom-manual "(gnus)Customizing Articles")
1117 :type gnus-article-treat-custom)
1119 (defcustom gnus-treat-strip-banner t
1120 "Strip banners from articles.
1121 The banner to be stripped is specified in the `banner' group parameter.
1122 Valid values are nil, t, `head', `first', `last', an integer or a
1123 predicate. See Info node `(gnus)Customizing Articles'."
1124 :group 'gnus-article-treat
1125 :link '(custom-manual "(gnus)Customizing Articles")
1126 :type gnus-article-treat-custom)
1128 (defcustom gnus-treat-highlight-headers 'head
1129 "Highlight the headers.
1130 Valid values are nil, t, `head', `first', `last', an integer or a
1131 predicate. See Info node `(gnus)Customizing Articles'."
1132 :group 'gnus-article-treat
1133 :link '(custom-manual "(gnus)Customizing Articles")
1134 :type gnus-article-treat-head-custom)
1135 (put 'gnus-treat-highlight-headers 'highlight t)
1137 (defcustom gnus-treat-highlight-citation t
1138 "Highlight cited text.
1139 Valid values are nil, t, `head', `first', `last', an integer or a
1140 predicate. See Info node `(gnus)Customizing Articles'."
1141 :group 'gnus-article-treat
1142 :link '(custom-manual "(gnus)Customizing Articles")
1143 :type gnus-article-treat-custom)
1144 (put 'gnus-treat-highlight-citation 'highlight t)
1146 (defcustom gnus-treat-date-ut nil
1147 "Display the Date in UT (GMT).
1148 Valid values are nil, t, `head', `first', `last', an integer or a
1149 predicate. See Info node `(gnus)Customizing Articles'."
1150 :group 'gnus-article-treat
1151 :link '(custom-manual "(gnus)Customizing Articles")
1152 :type gnus-article-treat-head-custom)
1154 (defcustom gnus-treat-date-local nil
1155 "Display the Date in the local timezone.
1156 Valid values are nil, t, `head', `first', `last', an integer or a
1157 predicate. See Info node `(gnus)Customizing Articles'."
1158 :group 'gnus-article-treat
1159 :link '(custom-manual "(gnus)Customizing Articles")
1160 :type gnus-article-treat-head-custom)
1162 (defcustom gnus-treat-date-english nil
1163 "Display the Date in a format that can be read aloud in English.
1164 Valid values are nil, t, `head', `first', `last', an integer or a
1165 predicate. See Info node `(gnus)Customizing Articles'."
1167 :group 'gnus-article-treat
1168 :link '(custom-manual "(gnus)Customizing Articles")
1169 :type gnus-article-treat-head-custom)
1171 (defcustom gnus-treat-date-lapsed nil
1172 "Display the Date header in a way that says how much time has elapsed.
1173 Valid values are nil, t, `head', `first', `last', an integer or a
1174 predicate. See Info node `(gnus)Customizing Articles'."
1175 :group 'gnus-article-treat
1176 :link '(custom-manual "(gnus)Customizing Articles")
1177 :type gnus-article-treat-head-custom)
1179 (defcustom gnus-treat-date-original nil
1180 "Display the date in the original timezone.
1181 Valid values are nil, t, `head', `first', `last', an integer or a
1182 predicate. See Info node `(gnus)Customizing Articles'."
1183 :group 'gnus-article-treat
1184 :link '(custom-manual "(gnus)Customizing Articles")
1185 :type gnus-article-treat-head-custom)
1187 (defcustom gnus-treat-date-iso8601 nil
1188 "Display the date in the ISO8601 format.
1189 Valid values are nil, t, `head', `first', `last', an integer or a
1190 predicate. See Info node `(gnus)Customizing Articles'."
1192 :group 'gnus-article-treat
1193 :link '(custom-manual "(gnus)Customizing Articles")
1194 :type gnus-article-treat-head-custom)
1196 (defcustom gnus-treat-date-user-defined nil
1197 "Display the date in a user-defined format.
1198 The format is defined by the `gnus-article-time-format' variable.
1199 Valid values are nil, t, `head', `first', `last', an integer or a
1200 predicate. See Info node `(gnus)Customizing Articles'."
1201 :group 'gnus-article-treat
1202 :link '(custom-manual "(gnus)Customizing Articles")
1203 :type gnus-article-treat-head-custom)
1205 (defcustom gnus-treat-strip-headers-in-body t
1206 "Strip the X-No-Archive header line from the beginning of the body.
1207 Valid values are nil, t, `head', `first', `last', an integer or a
1208 predicate. See Info node `(gnus)Customizing Articles'."
1210 :group 'gnus-article-treat
1211 :link '(custom-manual "(gnus)Customizing Articles")
1212 :type gnus-article-treat-custom)
1214 (defcustom gnus-treat-strip-trailing-blank-lines nil
1215 "Strip trailing blank lines.
1216 Valid values are nil, t, `head', `first', `last', an integer or a
1217 predicate. See Info node `(gnus)Customizing Articles'.
1219 When set to t, it also strips trailing blanks in all MIME parts.
1220 Consider to use `last' instead."
1221 :group 'gnus-article-treat
1222 :link '(custom-manual "(gnus)Customizing Articles")
1223 :type gnus-article-treat-custom)
1225 (defcustom gnus-treat-strip-leading-blank-lines nil
1226 "Strip leading blank lines.
1227 Valid values are nil, t, `head', `first', `last', an integer or a
1228 predicate. See Info node `(gnus)Customizing Articles'.
1230 When set to t, it also strips trailing blanks in all MIME parts."
1231 :group 'gnus-article-treat
1232 :link '(custom-manual "(gnus)Customizing Articles")
1233 :type gnus-article-treat-custom)
1235 (defcustom gnus-treat-strip-multiple-blank-lines nil
1236 "Strip multiple blank lines.
1237 Valid values are nil, t, `head', `first', `last', an integer or a
1238 predicate. See Info node `(gnus)Customizing Articles'."
1239 :group 'gnus-article-treat
1240 :link '(custom-manual "(gnus)Customizing Articles")
1241 :type gnus-article-treat-custom)
1243 (defcustom gnus-treat-unfold-headers 'head
1244 "Unfold folded header lines.
1245 Valid values are nil, t, `head', `first', `last', an integer or a
1246 predicate. See Info node `(gnus)Customizing Articles'."
1248 :group 'gnus-article-treat
1249 :link '(custom-manual "(gnus)Customizing Articles")
1250 :type gnus-article-treat-custom)
1252 (defcustom gnus-treat-fold-headers nil
1254 Valid values are nil, t, `head', `first', `last', an integer or a
1255 predicate. See Info node `(gnus)Customizing Articles'."
1257 :group 'gnus-article-treat
1258 :link '(custom-manual "(gnus)Customizing Articles")
1259 :type gnus-article-treat-custom)
1261 (defcustom gnus-treat-fold-newsgroups 'head
1262 "Fold the Newsgroups and Followup-To headers.
1263 Valid values are nil, t, `head', `first', `last', an integer or a
1264 predicate. See Info node `(gnus)Customizing Articles'."
1266 :group 'gnus-article-treat
1267 :link '(custom-manual "(gnus)Customizing Articles")
1268 :type gnus-article-treat-custom)
1270 (defcustom gnus-treat-overstrike t
1271 "Treat overstrike highlighting.
1272 Valid values are nil, t, `head', `first', `last', an integer or a
1273 predicate. See Info node `(gnus)Customizing Articles'."
1274 :group 'gnus-article-treat
1275 :link '(custom-manual "(gnus)Customizing Articles")
1276 :type gnus-article-treat-custom)
1277 (put 'gnus-treat-overstrike 'highlight t)
1279 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1280 "Treat ANSI SGR control sequences.
1281 Valid values are nil, t, `head', `first', `last', an integer or a
1282 predicate. See Info node `(gnus)Customizing Articles'."
1283 :group 'gnus-article-treat
1284 :link '(custom-manual "(gnus)Customizing Articles")
1285 :type gnus-article-treat-custom)
1287 (make-obsolete-variable 'gnus-treat-display-xface
1288 'gnus-treat-display-x-face)
1290 (defcustom gnus-treat-display-x-face
1291 (and (not noninteractive)
1292 (or (and (fboundp 'image-type-available-p)
1293 (image-type-available-p 'xbm)
1294 (string-match "^0x" (shell-command-to-string "uncompface"))
1295 (executable-find "icontopbm"))
1296 (and (featurep 'xemacs)
1299 "Display X-Face headers.
1300 Valid values are nil, t, `head', `first', `last', an integer or a
1301 predicate. See Info node `(gnus)Customizing Articles' and Info
1302 node `(gnus)X-Face' for details."
1303 :group 'gnus-article-treat
1305 :link '(custom-manual "(gnus)Customizing Articles")
1306 :link '(custom-manual "(gnus)X-Face")
1307 :type gnus-article-treat-head-custom
1308 :set (lambda (symbol value)
1311 (cond ((or (boundp symbol) (get symbol 'saved-value))
1313 ((boundp 'gnus-treat-display-xface)
1315 ** gnus-treat-display-xface is an obsolete variable;\
1316 use gnus-treat-display-x-face instead")
1317 (default-value 'gnus-treat-display-xface))
1318 ((get 'gnus-treat-display-xface 'saved-value)
1320 ** gnus-treat-display-xface is an obsolete variable;\
1321 use gnus-treat-display-x-face instead")
1322 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1325 (put 'gnus-treat-display-x-face 'highlight t)
1327 (defcustom gnus-treat-display-face
1328 (and (not noninteractive)
1329 (or (and (fboundp 'image-type-available-p)
1330 (image-type-available-p 'png))
1331 (and (featurep 'xemacs)
1334 "Display Face headers.
1335 Valid values are nil, t, `head', `first', `last', an integer or a
1336 predicate. See Info node `(gnus)Customizing Articles' and Info
1337 node `(gnus)X-Face' for details."
1338 :group 'gnus-article-treat
1340 :link '(custom-manual "(gnus)Customizing Articles")
1341 :link '(custom-manual "(gnus)X-Face")
1342 :type gnus-article-treat-head-custom)
1343 (put 'gnus-treat-display-face 'highlight t)
1345 (defcustom gnus-treat-display-smileys
1346 (if (or (and (featurep 'xemacs)
1348 (and (fboundp 'image-type-available-p)
1349 (image-type-available-p 'pbm)))
1352 Valid values are nil, t, `head', `first', `last', an integer or a
1353 predicate. See Info node `(gnus)Customizing Articles' and Info
1354 node `(gnus)Smileys' for details."
1355 :group 'gnus-article-treat
1357 :link '(custom-manual "(gnus)Customizing Articles")
1358 :link '(custom-manual "(gnus)Smileys")
1359 :type gnus-article-treat-custom)
1360 (put 'gnus-treat-display-smileys 'highlight t)
1362 (defcustom gnus-treat-from-picon
1363 (if (and (gnus-image-type-available-p 'xpm)
1364 (gnus-picons-installed-p))
1366 "Display picons in the From header.
1367 Valid values are nil, t, `head', `first', `last', an integer or a
1368 predicate. See Info node `(gnus)Customizing Articles' and Info
1369 node `(gnus)Picons' for details."
1371 :group 'gnus-article-treat
1373 :link '(custom-manual "(gnus)Customizing Articles")
1374 :link '(custom-manual "(gnus)Picons")
1375 :type gnus-article-treat-head-custom)
1376 (put 'gnus-treat-from-picon 'highlight t)
1378 (defcustom gnus-treat-mail-picon
1379 (if (and (gnus-image-type-available-p 'xpm)
1380 (gnus-picons-installed-p))
1382 "Display picons in To and Cc headers.
1383 Valid values are nil, t, `head', `first', `last', an integer or a
1384 predicate. See Info node `(gnus)Customizing Articles' and Info
1385 node `(gnus)Picons' for details."
1387 :group 'gnus-article-treat
1389 :link '(custom-manual "(gnus)Customizing Articles")
1390 :link '(custom-manual "(gnus)Picons")
1391 :type gnus-article-treat-head-custom)
1392 (put 'gnus-treat-mail-picon 'highlight t)
1394 (defcustom gnus-treat-newsgroups-picon
1395 (if (and (gnus-image-type-available-p 'xpm)
1396 (gnus-picons-installed-p))
1398 "Display picons in the Newsgroups and Followup-To headers.
1399 Valid values are nil, t, `head', `first', `last', an integer or a
1400 predicate. See Info node `(gnus)Customizing Articles' and Info
1401 node `(gnus)Picons' for details."
1403 :group 'gnus-article-treat
1405 :link '(custom-manual "(gnus)Customizing Articles")
1406 :link '(custom-manual "(gnus)Picons")
1407 :type gnus-article-treat-head-custom)
1408 (put 'gnus-treat-newsgroups-picon 'highlight t)
1410 (defcustom gnus-treat-body-boundary
1411 (if (and (eq window-system 'x)
1412 (or gnus-treat-newsgroups-picon
1413 gnus-treat-mail-picon
1414 gnus-treat-from-picon))
1416 "Draw a boundary at the end of the headers.
1417 Valid values are nil and `head'.
1418 See Info node `(gnus)Customizing Articles' for details."
1420 :group 'gnus-article-treat
1421 :link '(custom-manual "(gnus)Customizing Articles")
1422 :type gnus-article-treat-head-custom)
1424 (defcustom gnus-treat-capitalize-sentences nil
1425 "Capitalize sentence-starting words.
1426 Valid values are nil, t, `head', `first', `last', an integer or a
1427 predicate. See Info node `(gnus)Customizing Articles'."
1429 :group 'gnus-article-treat
1430 :link '(custom-manual "(gnus)Customizing Articles")
1431 :type gnus-article-treat-custom)
1433 (defcustom gnus-treat-wash-html nil
1435 Valid values are nil, t, `head', `first', `last', an integer or a
1436 predicate. See Info node `(gnus)Customizing Articles'."
1438 :group 'gnus-article-treat
1439 :link '(custom-manual "(gnus)Customizing Articles")
1440 :type gnus-article-treat-custom)
1442 (defcustom gnus-treat-fill-long-lines nil
1444 Valid values are nil, t, `head', `first', `last', an integer or a
1445 predicate. See Info node `(gnus)Customizing Articles'."
1446 :group 'gnus-article-treat
1447 :link '(custom-manual "(gnus)Customizing Articles")
1448 :type gnus-article-treat-custom)
1450 (defcustom gnus-treat-play-sounds nil
1452 Valid values are nil, t, `head', `first', `last', an integer or a
1453 predicate. See Info node `(gnus)Customizing Articles'."
1455 :group 'gnus-article-treat
1456 :link '(custom-manual "(gnus)Customizing Articles")
1457 :type gnus-article-treat-custom)
1459 (defcustom gnus-treat-translate nil
1460 "Translate articles from one language to another.
1461 Valid values are nil, t, `head', `first', `last', an integer or a
1462 predicate. See Info node `(gnus)Customizing Articles'."
1464 :group 'gnus-article-treat
1465 :link '(custom-manual "(gnus)Customizing Articles")
1466 :type gnus-article-treat-custom)
1468 (defcustom gnus-treat-x-pgp-sig nil
1470 To automatically treat X-PGP-Sig, set it to head.
1471 Valid values are nil, t, `head', `first', `last', an integer or a
1472 predicate. See Info node `(gnus)Customizing Articles'."
1474 :group 'gnus-article-treat
1475 :group 'mime-security
1476 :link '(custom-manual "(gnus)Customizing Articles")
1477 :type gnus-article-treat-custom)
1479 (defvar gnus-article-encrypt-protocol-alist
1480 '(("PGP" . mml2015-self-encrypt)))
1482 ;; Set to nil if more than one protocol added to
1483 ;; gnus-article-encrypt-protocol-alist.
1484 (defcustom gnus-article-encrypt-protocol "PGP"
1485 "The protocol used for encrypt articles.
1486 It is a string, such as \"PGP\". If nil, ask user."
1489 :group 'mime-security)
1491 (defvar gnus-article-wash-function nil
1492 "Function used for converting HTML into text.")
1494 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1495 (mm-coding-system-p 'utf-8)
1496 (executable-find idna-program))
1497 "Whether IDNA decoding of headers is used when viewing messages.
1498 This requires GNU Libidn, and by default only enabled if it is found."
1500 :group 'gnus-article-headers
1503 (defcustom gnus-article-over-scroll nil
1504 "If non-nil, allow scrolling the article buffer even when there no more text."
1506 :group 'gnus-article
1509 ;;; Internal variables
1511 (defvar gnus-english-month-names
1512 '("January" "February" "March" "April" "May" "June" "July" "August"
1513 "September" "October" "November" "December"))
1515 (defvar gnus-button-regexp nil)
1516 (defvar gnus-button-marker-list nil)
1517 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1519 (defvar gnus-button-last nil)
1520 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1522 (defvar article-goto-body-goes-to-point-min-p nil)
1523 (defvar gnus-article-wash-types nil)
1524 (defvar gnus-article-emphasis-alist nil)
1525 (defvar gnus-article-image-alist nil)
1527 (defvar gnus-article-mime-handle-alist-1 nil)
1528 (defvar gnus-treatment-function-alist
1529 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1530 (gnus-treat-strip-banner gnus-article-strip-banner)
1531 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1532 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1533 (gnus-treat-buttonize gnus-article-add-buttons)
1534 (gnus-treat-fill-article gnus-article-fill-cited-article)
1535 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1536 (gnus-treat-strip-cr gnus-article-remove-cr)
1537 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1538 (gnus-treat-date-ut gnus-article-date-ut)
1539 (gnus-treat-date-local gnus-article-date-local)
1540 (gnus-treat-date-english gnus-article-date-english)
1541 (gnus-treat-date-original gnus-article-date-original)
1542 (gnus-treat-date-user-defined gnus-article-date-user)
1543 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1544 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1545 (gnus-treat-display-x-face gnus-article-display-x-face)
1546 (gnus-treat-display-face gnus-article-display-face)
1547 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1548 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1549 (gnus-treat-hide-signature gnus-article-hide-signature)
1550 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1551 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1552 (gnus-treat-strip-pem gnus-article-hide-pem)
1553 (gnus-treat-from-picon gnus-treat-from-picon)
1554 (gnus-treat-mail-picon gnus-treat-mail-picon)
1555 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1556 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1557 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1558 (gnus-treat-strip-trailing-blank-lines
1559 gnus-article-remove-trailing-blank-lines)
1560 (gnus-treat-strip-leading-blank-lines
1561 gnus-article-strip-leading-blank-lines)
1562 (gnus-treat-strip-multiple-blank-lines
1563 gnus-article-strip-multiple-blank-lines)
1564 (gnus-treat-overstrike gnus-article-treat-overstrike)
1565 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1566 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1567 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1568 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1569 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1570 (gnus-treat-display-smileys gnus-treat-smiley)
1571 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1572 (gnus-treat-wash-html gnus-article-wash-html)
1573 (gnus-treat-emphasize gnus-article-emphasize)
1574 (gnus-treat-hide-citation gnus-article-hide-citation)
1575 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1576 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1577 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1578 (gnus-treat-play-sounds gnus-earcon-display)))
1580 (defvar gnus-article-mime-handle-alist nil)
1581 (defvar article-lapsed-timer nil)
1582 (defvar gnus-article-current-summary nil)
1584 (defvar gnus-article-mode-syntax-table
1585 (let ((table (copy-syntax-table text-mode-syntax-table)))
1586 ;; This causes the citation match run O(2^n).
1587 ;; (modify-syntax-entry ?- "w" table)
1588 (modify-syntax-entry ?> ")<" table)
1589 (modify-syntax-entry ?< "(>" table)
1590 ;; make M-. in article buffers work for `foo' strings
1591 (modify-syntax-entry ?' " " table)
1592 (modify-syntax-entry ?` " " table)
1594 "Syntax table used in article mode buffers.
1595 Initialized from `text-mode-syntax-table.")
1597 (defvar gnus-save-article-buffer nil)
1599 (defvar gnus-article-mode-line-format-alist
1600 (nconc '((?w (gnus-article-wash-status) ?s)
1601 (?m (gnus-article-mime-part-status) ?s))
1602 gnus-summary-mode-line-format-alist))
1604 (defvar gnus-number-of-articles-to-be-saved nil)
1606 (defvar gnus-inhibit-hiding nil)
1608 (defvar gnus-article-edit-mode nil)
1610 ;;; Macros for dealing with the article buffer.
1612 (defmacro gnus-with-article-headers (&rest forms)
1614 (set-buffer gnus-article-buffer)
1616 (let ((inhibit-read-only t)
1617 (inhibit-point-motion-hooks t)
1618 (case-fold-search t))
1619 (article-narrow-to-head)
1622 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1623 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1625 (defmacro gnus-with-article-buffer (&rest forms)
1627 (set-buffer gnus-article-buffer)
1628 (let ((inhibit-read-only t))
1631 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1632 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1634 (defun gnus-article-goto-header (header)
1635 "Go to HEADER, which is a regular expression."
1636 (re-search-forward (concat "^\\(" header "\\):") nil t))
1638 (defsubst gnus-article-hide-text (b e props)
1639 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1640 (gnus-add-text-properties-when 'article-type nil b e props)
1641 (when (memq 'intangible props)
1643 (max (1- b) (point-min))
1644 b 'intangible (cddr (memq 'intangible props)))))
1646 (defsubst gnus-article-unhide-text (b e)
1647 "Remove hidden text properties from region between B and E."
1648 (remove-text-properties b e gnus-hidden-properties)
1649 (when (memq 'intangible gnus-hidden-properties)
1650 (put-text-property (max (1- b) (point-min))
1651 b 'intangible nil)))
1653 (defun gnus-article-hide-text-type (b e type)
1654 "Hide text of TYPE between B and E."
1655 (gnus-add-wash-type type)
1656 (gnus-article-hide-text
1657 b e (cons 'article-type (cons type gnus-hidden-properties))))
1659 (defun gnus-article-unhide-text-type (b e type)
1660 "Unhide text of TYPE between B and E."
1661 (gnus-delete-wash-type type)
1662 (remove-text-properties
1663 b e (cons 'article-type (cons type gnus-hidden-properties)))
1664 (when (memq 'intangible gnus-hidden-properties)
1665 (put-text-property (max (1- b) (point-min))
1666 b 'intangible nil)))
1668 (defun gnus-article-hide-text-of-type (type)
1669 "Hide text of TYPE in the current buffer."
1671 (let ((b (point-min))
1673 (while (setq b (text-property-any b e 'article-type type))
1674 (add-text-properties b (incf b) gnus-hidden-properties)))))
1676 (defun gnus-article-delete-text-of-type (type)
1677 "Delete text of TYPE in the current buffer."
1679 (let ((b (point-min)))
1680 (if (eq type 'multipart)
1681 ;; Remove MIME buttons associated with multipart/alternative parts.
1684 (while (if (get-text-property (point) 'gnus-part)
1686 (when (setq b (next-single-property-change (point)
1691 (skip-chars-forward "\n")
1692 (when (eq (get-text-property b 'article-type) 'multipart)
1693 (delete-region b (point)))))
1694 (while (setq b (text-property-any b (point-max) 'article-type type))
1696 b (or (text-property-not-all b (point-max) 'article-type type)
1699 (defun gnus-article-delete-invisible-text ()
1700 "Delete all invisible text in the current buffer."
1702 (let ((b (point-min)))
1703 (while (setq b (text-property-any b (point-max) 'invisible t))
1705 b (or (text-property-not-all b (point-max) 'invisible t)
1708 (defun gnus-article-text-type-exists-p (type)
1709 "Say whether any text of type TYPE exists in the buffer."
1710 (text-property-any (point-min) (point-max) 'article-type type))
1712 (defsubst gnus-article-header-rank ()
1713 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1714 (let ((list gnus-sorted-header-list)
1717 (if (looking-at (car list))
1719 (setq list (cdr list))
1723 (defun article-hide-headers (&optional arg delete)
1724 "Hide unwanted headers and possibly sort them as well."
1726 ;; This function might be inhibited.
1727 (unless gnus-inhibit-hiding
1728 (let ((inhibit-read-only nil)
1729 (case-fold-search t)
1730 (max (1+ (length gnus-sorted-header-list)))
1731 (inhibit-point-motion-hooks t)
1732 (cur (current-buffer))
1733 ignored visible beg)
1735 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1736 ;; group parameters, so we should go to the summary buffer.
1739 (progn (set-buffer gnus-summary-buffer) t)
1741 (setq ignored (when (not gnus-visible-headers)
1742 (cond ((stringp gnus-ignored-headers)
1743 gnus-ignored-headers)
1744 ((listp gnus-ignored-headers)
1745 (mapconcat 'identity
1746 gnus-ignored-headers
1748 visible (cond ((stringp gnus-visible-headers)
1749 gnus-visible-headers)
1750 ((and gnus-visible-headers
1751 (listp gnus-visible-headers))
1752 (mapconcat 'identity
1753 gnus-visible-headers
1757 ;; First we narrow to just the headers.
1758 (article-narrow-to-head)
1759 ;; Hide any "From " lines at the beginning of (mail) articles.
1760 (while (looking-at "From ")
1763 (delete-region (point-min) (point)))
1764 ;; Then treat the rest of the header lines.
1765 ;; Then we use the two regular expressions
1766 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1767 ;; select which header lines is to remain visible in the
1769 (while (re-search-forward "^[^ \t:]*:" nil t)
1771 ;; Mark the rank of the header.
1773 (point) (1+ (point)) 'message-rank
1774 (if (or (and visible (looking-at visible))
1776 (not (looking-at ignored))))
1777 (gnus-article-header-rank)
1780 (message-sort-headers-1)
1781 (when (setq beg (text-property-any
1782 (point-min) (point-max) 'message-rank (+ 2 max)))
1783 ;; We delete the unwanted headers.
1784 (gnus-add-wash-type 'headers)
1785 (add-text-properties (point-min) (+ 5 (point-min))
1786 '(article-type headers dummy-invisible t))
1787 (delete-region beg (point-max))))))))
1789 (defun article-hide-boring-headers (&optional arg)
1790 "Toggle hiding of headers that aren't very interesting.
1791 If given a negative prefix, always show; if given a positive prefix,
1793 (interactive (gnus-article-hidden-arg))
1794 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1795 (not gnus-show-all-headers))
1798 (let ((inhibit-read-only t)
1799 (inhibit-point-motion-hooks t))
1800 (article-narrow-to-head)
1801 (dolist (elem gnus-boring-article-headers)
1802 (goto-char (point-min))
1804 ;; Hide empty headers.
1806 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1808 (gnus-article-hide-text-type
1812 (if (re-search-forward "^[^ \t]" nil t)
1816 ;; Hide boring Newsgroups header.
1817 ((eq elem 'newsgroups)
1818 (when (gnus-string-equal
1819 (gnus-fetch-field "newsgroups")
1820 (gnus-group-real-name
1821 (if (boundp 'gnus-newsgroup-name)
1824 (gnus-article-hide-header "newsgroups")))
1825 ((eq elem 'to-address)
1826 (let ((to (message-fetch-field "to"))
1828 (gnus-parameter-to-address
1829 (if (boundp 'gnus-newsgroup-name)
1830 gnus-newsgroup-name ""))))
1831 (when (and to to-address
1834 ;; only one address in To
1835 (nth 1 (mail-extract-address-components to))
1837 (gnus-article-hide-header "to"))))
1839 (let ((to (message-fetch-field "to"))
1841 (gnus-parameter-to-list
1842 (if (boundp 'gnus-newsgroup-name)
1843 gnus-newsgroup-name ""))))
1844 (when (and to to-list
1847 ;; only one address in To
1848 (nth 1 (mail-extract-address-components to))
1850 (gnus-article-hide-header "to"))))
1852 (let ((cc (message-fetch-field "cc"))
1854 (gnus-parameter-to-list
1855 (if (boundp 'gnus-newsgroup-name)
1856 gnus-newsgroup-name ""))))
1857 (when (and cc to-list
1860 ;; only one address in CC
1861 (nth 1 (mail-extract-address-components cc))
1863 (gnus-article-hide-header "cc"))))
1864 ((eq elem 'followup-to)
1865 (when (gnus-string-equal
1866 (message-fetch-field "followup-to")
1867 (message-fetch-field "newsgroups"))
1868 (gnus-article-hide-header "followup-to")))
1869 ((eq elem 'reply-to)
1870 (if (gnus-group-find-parameter
1871 gnus-newsgroup-name 'broken-reply-to)
1872 (gnus-article-hide-header "reply-to")
1873 (let ((from (message-fetch-field "from"))
1874 (reply-to (message-fetch-field "reply-to")))
1881 (lambda (x) (downcase (cadr x)))
1882 (mail-extract-address-components from t))
1885 (lambda (x) (downcase (cadr x)))
1886 (mail-extract-address-components reply-to t))
1888 (gnus-article-hide-header "reply-to")))))
1890 (let ((date (message-fetch-field "date")))
1892 (< (days-between (current-time-string) date)
1894 (gnus-article-hide-header "date"))))
1896 (let ((to (message-fetch-field "to"))
1897 (cc (message-fetch-field "cc")))
1898 (when (> (length to) 1024)
1899 (gnus-article-hide-header "to"))
1900 (when (> (length cc) 1024)
1901 (gnus-article-hide-header "cc"))))
1905 (goto-char (point-min))
1906 (while (re-search-forward "^to:" nil t)
1907 (setq to-count (1+ to-count)))
1908 (when (> to-count 1)
1909 (while (> to-count 0)
1910 (goto-char (point-min))
1912 (re-search-forward "^to:" nil nil to-count)
1914 (narrow-to-region (point) (point-max))
1915 (gnus-article-hide-header "to"))
1916 (setq to-count (1- to-count))))
1917 (goto-char (point-min))
1918 (while (re-search-forward "^cc:" nil t)
1919 (setq cc-count (1+ cc-count)))
1920 (when (> cc-count 1)
1921 (while (> cc-count 0)
1922 (goto-char (point-min))
1924 (re-search-forward "^cc:" nil nil cc-count)
1926 (narrow-to-region (point) (point-max))
1927 (gnus-article-hide-header "cc"))
1928 (setq cc-count (1- cc-count)))))))))))))
1930 (defun gnus-article-hide-header (header)
1932 (goto-char (point-min))
1933 (when (re-search-forward (concat "^" header ":") nil t)
1934 (gnus-article-hide-text-type
1938 (if (re-search-forward "^[^ \t]" nil t)
1943 (defvar gnus-article-normalized-header-length 40
1944 "Length of normalized headers.")
1946 (defun article-normalize-headers ()
1947 "Make all header lines 40 characters long."
1949 (let ((inhibit-read-only t)
1953 (article-narrow-to-head)
1956 ((< (setq column (- (point-at-eol) (point)))
1957 gnus-article-normalized-header-length)
1959 (insert (make-string
1960 (- gnus-article-normalized-header-length column)
1962 ((> column gnus-article-normalized-header-length)
1963 (gnus-put-text-property
1965 (forward-char gnus-article-normalized-header-length)
1972 (forward-line 1))))))
1974 (defun article-treat-dumbquotes ()
1975 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1976 Note that this function guesses whether a character is a sm*rtq**t* or
1977 not, so it should only be used interactively.
1979 Sm*rtq**t*s are M****s***'s unilateral extension to the
1980 iso-8859-1 character map in an attempt to provide more quoting
1981 characters. If you see something like \\222 or \\264 where
1982 you're expecting some kind of apostrophe or quotation mark, then
1985 (article-translate-strings gnus-article-dumbquotes-map))
1987 (defun article-translate-characters (from to)
1988 "Translate all characters in the body of the article according to FROM and TO.
1989 FROM is a string of characters to translate from; to is a string of
1990 characters to translate to."
1992 (when (article-goto-body)
1993 (let ((inhibit-read-only t)
1994 (x (make-string 225 ?x))
1996 (while (< (incf i) (length x))
1999 (while (< i (length from))
2000 (aset x (aref from i) (aref to i))
2002 (translate-region (point) (point-max) x)))))
2004 (defun article-translate-strings (map)
2005 "Translate all string in the body of the article according to MAP.
2006 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2008 (when (article-goto-body)
2009 (let ((inhibit-read-only t))
2012 (while (search-forward (car elem) nil t)
2013 (replace-match (cadr elem)))))))))
2015 (defun article-treat-overstrike ()
2016 "Translate overstrikes into bold text."
2019 (when (article-goto-body)
2020 (let ((inhibit-read-only t))
2021 (while (search-forward "\b" nil t)
2022 (let ((next (char-after))
2023 (previous (char-after (- (point) 2))))
2024 ;; We do the boldification/underlining by hiding the
2025 ;; overstrikes and putting the proper text property
2029 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2030 (put-text-property (point) (1+ (point)) 'face 'bold))
2032 (gnus-article-hide-text-type
2033 (1- (point)) (1+ (point)) 'overstrike)
2035 (- (point) 2) (1- (point)) 'face 'underline))
2037 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2039 (point) (1+ (point)) 'face 'underline)))))))))
2041 (defun article-treat-ansi-sequences ()
2042 "Translate ANSI SGR control sequences into overlays or extents."
2045 (when (article-goto-body)
2046 (let ((inhibit-read-only t))
2047 (ansi-color-apply-on-region (point) (point-max))))))
2049 (defun gnus-article-treat-unfold-headers ()
2050 "Unfold folded message headers.
2051 Only the headers that fit into the current window width will be
2054 (gnus-with-article-headers
2058 (mail-header-narrow-to-field)
2059 (let ((header (buffer-string)))
2062 (goto-char (point-min))
2063 (while (re-search-forward "\n[\t ]" nil t)
2064 (replace-match " " t t)))
2065 (setq length (- (point-max) (point-min) 1)))
2066 (when (< length (window-width))
2067 (while (re-search-forward "\n[\t ]" nil t)
2068 (replace-match " " t t)))
2069 (goto-char (point-max)))))))
2071 (defun gnus-article-treat-fold-headers ()
2072 "Fold message headers."
2074 (gnus-with-article-headers
2077 (mail-header-narrow-to-field)
2078 (mail-header-fold-field)
2079 (goto-char (point-max))))))
2081 (defun gnus-treat-smiley ()
2082 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2084 (gnus-with-article-buffer
2085 (if (memq 'smiley gnus-article-wash-types)
2086 (gnus-delete-images 'smiley)
2088 (let ((images (smiley-region (point) (point-max))))
2090 (gnus-add-wash-type 'smiley)
2091 (dolist (image images)
2092 (gnus-add-image 'smiley image)))))))
2094 (defun gnus-article-remove-images ()
2095 "Remove all images from the article buffer."
2097 (gnus-with-article-buffer
2098 (dolist (elem gnus-article-image-alist)
2099 (gnus-delete-images (car elem)))))
2101 (defun gnus-article-treat-fold-newsgroups ()
2102 "Unfold folded message headers.
2103 Only the headers that fit into the current window width will be
2106 (gnus-with-article-headers
2107 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2109 (mail-header-narrow-to-field)
2110 (while (re-search-forward ", *" nil t)
2111 (replace-match ", " t t))
2112 (mail-header-fold-field)
2113 (goto-char (point-max))))))
2115 (defun gnus-article-treat-body-boundary ()
2116 "Place a boundary line at the end of the headers."
2118 (when (and gnus-body-boundary-delimiter
2119 (> (length gnus-body-boundary-delimiter) 0))
2120 (gnus-with-article-headers
2121 (goto-char (point-max))
2122 (let ((start (point)))
2123 (insert "X-Boundary: ")
2124 (gnus-add-text-properties start (point) '(invisible t intangible t))
2126 (while (>= (1- (window-width)) (length str))
2127 (setq str (concat str gnus-body-boundary-delimiter)))
2128 (substring str 0 (1- (window-width))))
2130 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2132 (defun article-fill-long-lines ()
2133 "Fill lines that are wider than the window width."
2136 (let ((inhibit-read-only t)
2137 (width (window-width (get-buffer-window (current-buffer)))))
2140 (let ((adaptive-fill-mode nil)) ;Why? -sm
2143 (when (>= (current-column) (min fill-column width))
2144 (narrow-to-region (min (1+ (point)) (point-max))
2146 (let ((goback (point-marker)))
2147 (fill-paragraph nil)
2148 (goto-char (marker-position goback)))
2150 (forward-line 1)))))))
2152 (defun article-capitalize-sentences ()
2153 "Capitalize the first word in each sentence."
2156 (let ((inhibit-read-only t)
2157 (paragraph-start "^[\n\^L]"))
2161 (forward-sentence)))))
2163 (defun article-remove-cr ()
2164 "Remove trailing CRs and then translate remaining CRs into LFs."
2167 (let ((inhibit-read-only t))
2168 (goto-char (point-min))
2169 (while (re-search-forward "\r+$" nil t)
2170 (replace-match "" t t))
2171 (goto-char (point-min))
2172 (while (search-forward "\r" nil t)
2173 (replace-match "\n" t t)))))
2175 (defun article-remove-trailing-blank-lines ()
2176 "Remove all trailing blank lines from the article."
2179 (let ((inhibit-read-only t))
2180 (goto-char (point-max))
2184 (while (and (not (bobp))
2185 (looking-at "^[ \t]*$")
2186 (not (gnus-annotation-in-region-p
2187 (point) (point-at-eol))))
2193 (defvar gnus-face-properties-alist))
2195 (defun article-display-face ()
2196 "Display any Face headers in the header."
2198 (let ((wash-face-p buffer-read-only))
2199 (gnus-with-article-headers
2200 ;; When displaying parts, this function can be called several times on
2201 ;; the same article, without any intended toggle semantic (as typing `W
2202 ;; D d' would have). So face deletion must occur only when we come from
2203 ;; an interactive command, that is when the *Article* buffer is
2205 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2206 (gnus-delete-images 'face)
2207 (let (face faces from)
2208 (save-current-buffer
2209 (when (and wash-face-p
2210 (gnus-buffer-live-p gnus-original-article-buffer)
2211 (not (re-search-forward "^Face:[\t ]*" nil t)))
2212 (set-buffer gnus-original-article-buffer))
2214 (mail-narrow-to-head)
2215 (while (gnus-article-goto-header "Face")
2216 (push (mail-header-field-value) faces))))
2218 (goto-char (point-min))
2219 (let ((from (gnus-article-goto-header "from"))
2224 (insert "[no `from' set]\n"))
2226 (when (setq png (gnus-convert-face-to-png (pop faces)))
2228 (apply 'gnus-create-image png 'png t
2229 (cdr (assq 'png gnus-face-properties-alist))))
2231 (gnus-add-wash-type 'face)
2232 (gnus-add-image 'face image)
2233 (gnus-put-image image nil 'face))))))))))
2235 (defun article-display-x-face (&optional force)
2236 "Look for an X-Face header and display it if present."
2237 (interactive (list 'force))
2238 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2239 (gnus-with-article-headers
2240 ;; Delete the old process, if any.
2241 (when (process-status "article-x-face")
2242 (delete-process "article-x-face"))
2243 ;; See the comment in `article-display-face'.
2244 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2245 ;; We have already displayed X-Faces, so we remove them
2247 (gnus-delete-images 'xface)
2249 (let (x-faces from face)
2250 (save-current-buffer
2251 (when (and wash-face-p
2252 (gnus-buffer-live-p gnus-original-article-buffer)
2253 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2254 ;; If type `W f', use gnus-original-article-buffer,
2255 ;; otherwise use the current buffer because displaying
2256 ;; RFC822 parts calls this function too.
2257 (set-buffer gnus-original-article-buffer))
2259 (mail-narrow-to-head)
2260 (while (gnus-article-goto-header "X-Face")
2261 (push (mail-header-field-value) x-faces))
2262 (setq from (message-fetch-field "from"))))
2263 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2264 ;; single external face.
2265 (when (stringp gnus-article-x-face-command)
2266 (setq x-faces (list (car x-faces))))
2268 gnus-article-x-face-command
2270 ;; Check whether this face is censored.
2271 (not gnus-article-x-face-too-ugly)
2273 (not (string-match gnus-article-x-face-too-ugly
2275 (while (setq face (pop x-faces))
2276 ;; We display the face.
2277 (cond ((stringp gnus-article-x-face-command)
2278 ;; The command is a string, so we interpret the command
2279 ;; as a, well, command, and fork it off.
2280 (let ((process-connection-type nil))
2281 (gnus-set-process-query-on-exit-flag
2283 "article-x-face" nil shell-file-name
2284 shell-command-switch gnus-article-x-face-command)
2288 (process-send-region "article-x-face"
2289 (point-min) (point-max)))
2290 (process-send-eof "article-x-face")))
2291 ((functionp gnus-article-x-face-command)
2292 ;; The command is a lisp function, so we call it.
2293 (funcall gnus-article-x-face-command face))
2295 (error "%s is not a function"
2296 gnus-article-x-face-command))))))))))
2298 (defun article-decode-mime-words ()
2299 "Decode all MIME-encoded words in the article."
2301 (gnus-with-article-buffer
2302 (let ((inhibit-point-motion-hooks t)
2303 (mail-parse-charset gnus-newsgroup-charset)
2304 (mail-parse-ignored-charsets
2305 (with-current-buffer gnus-summary-buffer
2306 gnus-newsgroup-ignored-charsets)))
2307 (mail-decode-encoded-word-region (point-min) (point-max)))))
2309 (defun article-decode-charset (&optional prompt)
2310 "Decode charset-encoded text in the article.
2311 If PROMPT (the prefix), prompt for a coding system to use."
2313 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2314 (inhibit-read-only t)
2315 (mail-parse-charset gnus-newsgroup-charset)
2316 (mail-parse-ignored-charsets
2317 (save-excursion (condition-case nil
2318 (set-buffer gnus-summary-buffer)
2320 gnus-newsgroup-ignored-charsets))
2321 ct cte ctl charset format)
2324 (article-narrow-to-head)
2325 (setq ct (message-fetch-field "Content-Type" t)
2326 cte (message-fetch-field "Content-Transfer-Encoding" t)
2327 ctl (and ct (ignore-errors
2328 (mail-header-parse-content-type ct)))
2331 (mm-read-coding-system "Charset to decode: "))
2333 (mail-content-type-get ctl 'charset)))
2334 format (and ctl (mail-content-type-get ctl 'format)))
2336 (setq cte (mail-header-strip cte)))
2337 (if (and ctl (not (string-match "/" (car ctl))))
2339 (goto-char (point-max)))
2342 (narrow-to-region (point) (point-max))
2343 (when (and (eq mail-parse-charset 'gnus-decoded)
2344 (eq (mm-body-7-or-8) '8bit))
2345 ;; The text code could have been decoded.
2346 (setq charset mail-parse-charset))
2347 (when (and (or (not ctl)
2348 (equal (car ctl) "text/plain"))
2349 (not format)) ;; article with format will decode later.
2351 charset (and cte (intern (downcase
2352 (gnus-strip-whitespace cte))))
2355 (defun article-decode-encoded-words ()
2356 "Remove encoded-word encoding from headers."
2357 (let ((inhibit-point-motion-hooks t)
2358 (mail-parse-charset gnus-newsgroup-charset)
2359 (mail-parse-ignored-charsets
2360 (save-excursion (condition-case nil
2361 (set-buffer gnus-summary-buffer)
2363 gnus-newsgroup-ignored-charsets))
2364 (inhibit-read-only t))
2366 (article-narrow-to-head)
2367 (funcall gnus-decode-header-function (point-min) (point-max)))))
2369 (defun article-decode-group-name ()
2370 "Decode group names in `Newsgroups:'."
2371 (let ((inhibit-point-motion-hooks t)
2372 (inhibit-read-only t)
2373 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2374 (when (and (or gnus-group-name-charset-method-alist
2375 gnus-group-name-charset-group-alist)
2376 (gnus-buffer-live-p gnus-original-article-buffer))
2378 (article-narrow-to-head)
2379 (with-current-buffer gnus-original-article-buffer
2380 (goto-char (point-min)))
2381 (while (re-search-forward
2382 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2383 (replace-match (save-match-data
2384 (gnus-decode-newsgroups
2385 ;; XXX how to use data in article buffer?
2386 (with-current-buffer gnus-original-article-buffer
2388 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2391 gnus-newsgroup-name method))
2393 (goto-char (point-min))
2394 (with-current-buffer gnus-original-article-buffer
2395 (goto-char (point-min)))
2396 (while (re-search-forward
2397 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2398 (replace-match (save-match-data
2399 (gnus-decode-newsgroups
2400 ;; XXX how to use data in article buffer?
2401 (with-current-buffer gnus-original-article-buffer
2403 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2406 gnus-newsgroup-name method))
2409 (autoload 'idna-to-unicode "idna")
2411 (defun article-decode-idna-rhs ()
2412 "Decode IDNA strings in RHS in various headers in current buffer.
2413 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2414 Mail-Reply-To: and Mail-Followup-To:."
2417 (let ((inhibit-point-motion-hooks t)
2418 (inhibit-read-only t))
2419 (article-narrow-to-head)
2420 (goto-char (point-min))
2421 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2423 (when (save-match-data
2424 (and (setq ace (match-string 1))
2426 (and (re-search-backward "^[^ \t]" nil t)
2427 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2428 (setq unicode (idna-to-unicode ace))))
2429 (unless (string= ace unicode)
2430 (replace-match unicode nil nil nil 1)))))))))
2432 (defun article-de-quoted-unreadable (&optional force read-charset)
2433 "Translate a quoted-printable-encoded article.
2434 If FORCE, decode the article whether it is marked as quoted-printable
2436 If READ-CHARSET, ask for a coding system."
2437 (interactive (list 'force current-prefix-arg))
2439 (let ((inhibit-read-only t) type charset)
2440 (if (gnus-buffer-live-p gnus-original-article-buffer)
2441 (with-current-buffer gnus-original-article-buffer
2443 (gnus-fetch-field "content-transfer-encoding"))
2444 (let* ((ct (gnus-fetch-field "content-type"))
2447 (mail-header-parse-content-type ct)))))
2448 (setq charset (and ctl
2449 (mail-content-type-get ctl 'charset)))
2450 (if (stringp charset)
2451 (setq charset (intern (downcase charset)))))))
2453 (setq charset (mm-read-coding-system "Charset: " charset)))
2455 (setq charset gnus-newsgroup-charset))
2457 (and type (let ((case-fold-search t))
2458 (string-match "quoted-printable" type))))
2460 (quoted-printable-decode-region
2461 (point) (point-max) (mm-charset-to-coding-system charset))))))
2463 (defun article-de-base64-unreadable (&optional force read-charset)
2464 "Translate a base64 article.
2465 If FORCE, decode the article whether it is marked as base64 not.
2466 If READ-CHARSET, ask for a coding system."
2467 (interactive (list 'force current-prefix-arg))
2469 (let ((inhibit-read-only t) type charset)
2470 (if (gnus-buffer-live-p gnus-original-article-buffer)
2471 (with-current-buffer gnus-original-article-buffer
2473 (gnus-fetch-field "content-transfer-encoding"))
2474 (let* ((ct (gnus-fetch-field "content-type"))
2477 (mail-header-parse-content-type ct)))))
2478 (setq charset (and ctl
2479 (mail-content-type-get ctl 'charset)))
2480 (if (stringp charset)
2481 (setq charset (intern (downcase charset)))))))
2483 (setq charset (mm-read-coding-system "Charset: " charset)))
2485 (setq charset gnus-newsgroup-charset))
2487 (and type (let ((case-fold-search t))
2488 (string-match "base64" type))))
2491 (narrow-to-region (point) (point-max))
2492 (base64-decode-region (point-min) (point-max))
2493 (mm-decode-coding-region
2494 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2499 (defun article-decode-HZ ()
2500 "Translate a HZ-encoded article."
2504 (let ((inhibit-read-only t))
2505 (rfc1843-decode-region (point-min) (point-max)))))
2507 (defun article-unsplit-urls ()
2508 "Remove the newlines that some other mailers insert into URLs."
2511 (let ((inhibit-read-only t))
2512 (goto-char (point-min))
2513 (while (re-search-forward
2514 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2515 (replace-match "\\1\\3" t)))
2516 (when (interactive-p)
2517 (gnus-treat-article nil))))
2520 (defun article-wash-html (&optional read-charset)
2521 "Format an HTML article.
2522 If READ-CHARSET, ask for a coding system."
2525 (let ((inhibit-read-only t)
2527 (when (gnus-buffer-live-p gnus-original-article-buffer)
2528 (with-current-buffer gnus-original-article-buffer
2529 (let* ((ct (gnus-fetch-field "content-type"))
2532 (mail-header-parse-content-type ct)))))
2533 (setq charset (and ctl
2534 (mail-content-type-get ctl 'charset)))
2535 (when (stringp charset)
2536 (setq charset (intern (downcase charset)))))))
2538 (setq charset (mm-read-coding-system "Charset: " charset)))
2540 (setq charset gnus-newsgroup-charset))
2542 (save-window-excursion
2544 (narrow-to-region (point) (point-max))
2545 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2546 (entry (assq func mm-text-html-washer-alist)))
2548 (setq func (cdr entry)))
2553 (apply (car func) (cdr func))))))))))
2555 (defun gnus-article-wash-html-with-w3 ()
2556 "Wash the current buffer with w3."
2558 (let ((w3-strict-width (window-width))
2559 (url-standalone-mode t)
2560 (url-gateway-unplugged t)
2561 (w3-honor-stylesheets nil))
2563 (w3-region (point-min) (point-max))
2566 (defun gnus-article-wash-html-with-w3m ()
2567 "Wash the current buffer with emacs-w3m."
2569 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2570 w3m-force-redisplay)
2571 (w3m-region (point-min) (point-max)))
2572 (when (and mm-inline-text-html-with-w3m-keymap
2573 (boundp 'w3m-minor-mode-map)
2575 (add-text-properties
2576 (point-min) (point-max)
2577 (list 'keymap w3m-minor-mode-map
2578 ;; Put the mark meaning this part was rendered by emacs-w3m.
2579 'mm-inline-text-html-with-w3m t))))
2581 (defun article-hide-list-identifiers ()
2582 "Remove list identifies from the Subject header.
2583 The `gnus-list-identifiers' variable specifies what to do."
2585 (let ((inhibit-point-motion-hooks t)
2586 (regexp (if (consp gnus-list-identifiers)
2587 (mapconcat 'identity gnus-list-identifiers " *\\|")
2588 gnus-list-identifiers))
2589 (inhibit-read-only t))
2593 (article-narrow-to-head)
2594 (goto-char (point-min))
2595 (while (re-search-forward
2596 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2598 (delete-region (match-beginning 2) (match-end 0))
2599 (beginning-of-line))
2600 (when (re-search-forward
2601 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2602 (delete-region (match-beginning 1) (match-end 1))))))))
2604 (defun article-hide-pem (&optional arg)
2605 "Toggle hiding of any PEM headers and signatures in the current article.
2606 If given a negative prefix, always show; if given a positive prefix,
2608 (interactive (gnus-article-hidden-arg))
2609 (unless (gnus-article-check-hidden-text 'pem arg)
2611 (let ((inhibit-read-only t) end)
2612 (goto-char (point-min))
2613 ;; Hide the horrendously ugly "header".
2614 (when (and (search-forward
2615 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2617 (setq end (1+ (match-beginning 0))))
2618 (gnus-add-wash-type 'pem)
2619 (gnus-article-hide-text-type
2621 (if (search-forward "\n\n" nil t)
2625 ;; Hide the trailer as well
2626 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2628 (gnus-article-hide-text-type
2629 (match-beginning 0) (match-end 0) 'pem)))))))
2631 (defun article-strip-banner ()
2632 "Strip the banners specified by the `banner' group parameter and by
2633 `gnus-article-address-banner-alist'."
2637 (let ((inhibit-point-motion-hooks t))
2638 (when (gnus-parameter-banner gnus-newsgroup-name)
2639 (article-really-strip-banner
2640 (gnus-parameter-banner gnus-newsgroup-name)))
2641 (when gnus-article-address-banner-alist
2642 ;; It is necessary to encode from fields before checking,
2643 ;; because `mail-header-parse-addresses' does not work
2644 ;; (reliably) on decoded headers. And more, it is
2645 ;; impossible to use `gnus-fetch-original-field' here,
2646 ;; because `article-strip-banner' may be called in draft
2647 ;; buffers to preview them.
2648 (let ((from (save-restriction
2650 (article-narrow-to-head)
2651 (mail-fetch-field "from"))))
2654 (caar (mail-header-parse-addresses
2655 (mail-encode-encoded-word-string from)))))
2657 (dolist (pair gnus-article-address-banner-alist)
2658 (when (string-match (car pair) from)
2660 (article-really-strip-banner (cdr pair)))))))))))))
2662 (defun article-really-strip-banner (banner)
2663 "Strip the banner specified by the argument."
2666 (let ((inhibit-point-motion-hooks t)
2667 (gnus-signature-limit nil)
2668 (inhibit-read-only t))
2671 ((eq banner 'signature)
2672 (when (gnus-article-narrow-to-signature)
2675 (delete-region (point) (point-max))))
2677 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2678 (while (re-search-forward banner nil t)
2679 (delete-region (match-beginning 0) (match-end 0)))))
2681 (while (re-search-forward banner nil t)
2682 (delete-region (match-beginning 0) (match-end 0)))))))))
2684 (defun article-babel ()
2685 "Translate article using an online translation service."
2688 (gnus-with-article-buffer
2689 (when (article-goto-body)
2690 (let* ((start (point))
2692 (orig (buffer-substring start end))
2693 (trans (babel-as-string orig)))
2695 (narrow-to-region start end)
2696 (delete-region start end)
2699 (defun article-hide-signature (&optional arg)
2700 "Hide the signature in the current article.
2701 If given a negative prefix, always show; if given a positive prefix,
2703 (interactive (gnus-article-hidden-arg))
2704 (unless (gnus-article-check-hidden-text 'signature arg)
2707 (let ((inhibit-read-only t))
2708 (when (gnus-article-narrow-to-signature)
2709 (gnus-article-hide-text-type
2710 (point-min) (point-max) 'signature))))))
2711 (gnus-set-mode-line 'article))
2713 (defun article-strip-headers-in-body ()
2714 "Strip offensive headers from bodies."
2718 (let ((case-fold-search t))
2719 (when (looking-at "x-no-archive:")
2720 (gnus-delete-line)))))
2722 (defun article-strip-leading-blank-lines ()
2723 "Remove all blank lines from the beginning of the article."
2726 (let ((inhibit-point-motion-hooks t)
2727 (inhibit-read-only t))
2728 (when (article-goto-body)
2729 (while (and (not (eobp))
2730 (looking-at "[ \t]*$"))
2731 (gnus-delete-line))))))
2733 (defun article-narrow-to-head ()
2734 "Narrow the buffer to the head of the message.
2735 Point is left at the beginning of the narrowed-to region."
2737 (goto-char (point-min))
2738 (if (search-forward "\n\n" nil 1)
2741 (goto-char (point-min)))
2743 (defun article-goto-body ()
2744 "Place point at the start of the body."
2745 (goto-char (point-min))
2747 ;; This variable is only bound when dealing with separate
2749 (article-goto-body-goes-to-point-min-p
2751 ((search-forward "\n\n" nil t)
2754 (goto-char (point-max))
2757 (defun article-strip-multiple-blank-lines ()
2758 "Replace consecutive blank lines with one empty line."
2761 (let ((inhibit-point-motion-hooks t)
2762 (inhibit-read-only t))
2763 ;; First make all blank lines empty.
2765 (while (re-search-forward "^[ \t]+$" nil t)
2766 (unless (gnus-annotation-in-region-p
2767 (match-beginning 0) (match-end 0))
2768 (replace-match "" nil t)))
2769 ;; Then replace multiple empty lines with a single empty line.
2771 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2772 (unless (gnus-annotation-in-region-p
2773 (match-beginning 0) (match-end 0))
2774 (delete-region (match-beginning 1) (match-end 1)))))))
2776 (defun article-strip-leading-space ()
2777 "Remove all white space from the beginning of the lines in the article."
2780 (let ((inhibit-point-motion-hooks t)
2781 (inhibit-read-only t))
2783 (while (re-search-forward "^[ \t]+" nil t)
2784 (replace-match "" t t)))))
2786 (defun article-strip-trailing-space ()
2787 "Remove all white space from the end of the lines in the article."
2790 (let ((inhibit-point-motion-hooks t)
2791 (inhibit-read-only t))
2793 (while (re-search-forward "[ \t]+$" nil t)
2794 (replace-match "" t t)))))
2796 (defun article-strip-blank-lines ()
2797 "Strip leading, trailing and multiple blank lines."
2799 (article-strip-leading-blank-lines)
2800 (article-remove-trailing-blank-lines)
2801 (article-strip-multiple-blank-lines))
2803 (defun article-strip-all-blank-lines ()
2804 "Strip all blank lines."
2807 (let ((inhibit-point-motion-hooks t)
2808 (inhibit-read-only t))
2810 (while (re-search-forward "^[ \t]*\n" nil t)
2811 (replace-match "" t t)))))
2813 (defun gnus-article-narrow-to-signature ()
2814 "Narrow to the signature; return t if a signature is found, else nil."
2815 (let ((inhibit-point-motion-hooks t))
2816 (when (gnus-article-search-signature)
2818 ;; Check whether we have some limits to what we consider
2819 ;; to be a signature.
2820 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2821 (list gnus-signature-limit)))
2823 (while (setq limit (pop limits))
2824 (if (or (and (integerp limit)
2825 (< (- (point-max) (point)) limit))
2827 (< (count-lines (point) (point-max)) limit))
2828 (and (functionp limit)
2830 (and (stringp limit)
2831 (not (re-search-forward limit nil t))))
2832 () ; This limit did not succeed.
2836 (narrow-to-region (point) (point-max))
2839 (defun gnus-article-search-signature ()
2840 "Search the current buffer for the signature separator.
2841 Put point at the beginning of the signature separator."
2842 (let ((cur (point)))
2843 (goto-char (point-max))
2844 (if (if (stringp gnus-signature-separator)
2845 (re-search-backward gnus-signature-separator nil t)
2846 (let ((seps gnus-signature-separator))
2848 (not (re-search-backward (car seps) nil t)))
2855 (defun gnus-article-hidden-arg ()
2856 "Return the current prefix arg as a number, or 0 if no prefix."
2857 (list (if current-prefix-arg
2858 (prefix-numeric-value current-prefix-arg)
2861 (defun gnus-article-check-hidden-text (type arg)
2862 "Return nil if hiding is necessary.
2863 Arg can be nil or a number. nil and positive means hide, negative
2864 means show, 0 means toggle."
2867 (let ((hide (gnus-article-hidden-text-p type)))
2873 (gnus-article-show-hidden-text type)
2876 (if (eq hide 'hidden)
2878 (gnus-article-show-hidden-text type)
2882 (defun gnus-article-hidden-text-p (type)
2883 "Say whether the current buffer contains hidden text of type TYPE."
2884 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2886 (not (get-text-property pos 'invisible))
2887 (not (get-text-property pos 'dummy-invisible)))
2889 (text-property-any (1+ pos) (point-max) 'article-type type)))
2894 (defun gnus-article-show-hidden-text (type &optional dummy)
2895 "Show all hidden text of type TYPE.
2896 Originally it is hide instead of DUMMY."
2897 (let ((inhibit-read-only t)
2898 (inhibit-point-motion-hooks t))
2899 (gnus-remove-text-properties-when
2901 (point-min) (point-max)
2902 (cons 'article-type (cons type
2903 gnus-hidden-properties)))
2904 (gnus-delete-wash-type type)))
2906 (defconst article-time-units
2907 `((year . ,(* 365.25 24 60 60))
2908 (week . ,(* 7 24 60 60))
2909 (day . ,(* 24 60 60))
2913 "Mapping from time units to seconds.")
2915 (defun gnus-article-forward-header ()
2916 "Move point to the start of the next header.
2917 If the current header is a continuation header, this can be several
2922 (if (looking-at "[ \t]+[^ \t]")
2926 (defun article-date-ut (&optional type highlight)
2927 "Convert DATE date to universal time in the current article.
2928 If TYPE is `local', convert to local time; if it is `lapsed', output
2929 how much time has lapsed since DATE. For `lapsed', the value of
2930 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2931 should replace the \"Date:\" one, or should be added below it."
2932 (interactive (list 'ut t))
2933 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2934 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
2938 (article-lapsed-timer
2942 (case-fold-search t)
2943 (inhibit-read-only t)
2944 (inhibit-point-motion-hooks t)
2945 pos date bface eface)
2949 (goto-char (point-min))
2950 (while (or (setq date (get-text-property (setq pos (point))
2952 (when (setq pos (next-single-property-change
2953 (point) 'original-date))
2954 (setq date (get-text-property pos 'original-date))
2956 (narrow-to-region pos (or (text-property-any pos (point-max)
2959 (goto-char (point-min))
2960 (when (re-search-forward tdate-regexp nil t)
2961 (setq bface (get-text-property (point-at-bol) 'face)
2962 eface (get-text-property (1- (point-at-eol)) 'face)))
2963 (goto-char (point-min))
2965 ;; Delete any old Date headers.
2966 (while (re-search-forward date-regexp nil t)
2968 (delete-region (point-at-bol) (progn
2969 (gnus-article-forward-header)
2971 (delete-region (point-at-bol) (progn
2972 (gnus-article-forward-header)
2975 (setq pos (point))))
2976 (when (and (not pos)
2977 (re-search-forward tdate-regexp nil t))
2979 (gnus-goto-char pos)
2980 (insert (article-make-date-line date (or type 'ut)))
2986 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2987 (put-text-property (match-beginning 1) (1+ (match-end 1))
2989 (put-text-property (match-beginning 2) (match-end 2)
2991 (put-text-property (point-min) (1- (point-max)) 'original-date date)
2992 (goto-char (point-max))
2995 (defun article-make-date-line (date type)
2996 "Return a DATE line of TYPE."
2997 (unless (memq type '(local ut original user iso8601 lapsed english))
2998 (error "Unknown conversion type: %s" type))
3000 (let ((time (date-to-time date)))
3002 ;; Convert to the local timezone.
3004 (concat "Date: " (message-make-date time)))
3005 ;; Convert to Universal Time.
3010 (let* ((e (parse-time-string date))
3011 (tm (apply 'encode-time e))
3013 (ls (- (cadr tm) (car (current-time-zone time)))))
3014 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3015 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3019 ;; Get the original date from the article.
3020 ((eq type 'original)
3021 (concat "Date: " (if (string-match "\n+$" date)
3022 (substring date 0 (match-beginning 0))
3024 ;; Let the user define the format.
3026 (let ((format (or (condition-case nil
3027 (with-current-buffer gnus-summary-buffer
3028 gnus-article-time-format)
3030 gnus-article-time-format)))
3031 (if (functionp format)
3032 (funcall format time)
3033 (concat "Date: " (format-time-string format time)))))
3036 (let ((tz (car (current-time-zone time))))
3039 (format-time-string "%Y%m%dT%H%M%S" time)
3040 (format "%s%02d%02d"
3041 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3042 (/ (% (abs tz) 3600) 60)))))
3043 ;; Do an X-Sent lapsed format.
3045 ;; If the date is seriously mangled, the timezone functions are
3046 ;; liable to bug out, so we ignore all errors.
3047 (let* ((now (current-time))
3048 (real-time (subtract-time now time))
3049 (real-sec (and real-time
3050 (+ (* (float (car real-time)) 65536)
3052 (sec (and real-time (abs real-sec)))
3062 ;; This is a bit convoluted, but basically we go
3063 ;; through the time units for years, weeks, etc,
3064 ;; and divide things to see whether that results
3065 ;; in positive answers.
3068 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3069 ;; The (remaining) seconds are too few to
3070 ;; be divided into this time unit.
3072 ;; It's big enough, so we output it.
3073 (setq sec (- sec (* num (cdr unit))))
3075 (concat (if prev ", " "") (int-to-string
3077 " " (symbol-name (car unit))
3078 (if (> num 1) "s" ""))
3080 article-time-units "")
3081 ;; If dates are odd, then it might appear like the
3082 ;; article was sent in the future.
3085 " in the future"))))))
3086 ;; Display the date in proper English
3088 (let ((dtime (decode-time time)))
3091 (number-to-string (nth 3 dtime))
3092 (let ((digit (% (nth 3 dtime) 10)))
3094 ((memq (nth 3 dtime) '(11 12 13)) "th")
3100 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3102 (number-to-string (nth 5 dtime))
3104 (format "%02d" (nth 2 dtime))
3106 (format "%02d" (nth 1 dtime)))))))
3108 (format "Date: %s (from Gnus)" date))))
3110 (defun article-date-local (&optional highlight)
3111 "Convert the current article date to the local timezone."
3112 (interactive (list t))
3113 (article-date-ut 'local highlight))
3115 (defun article-date-english (&optional highlight)
3116 "Convert the current article date to something that is proper English."
3117 (interactive (list t))
3118 (article-date-ut 'english highlight))
3120 (defun article-date-original (&optional highlight)
3121 "Convert the current article date to what it was originally.
3122 This is only useful if you have used some other date conversion
3123 function and want to see what the date was before converting."
3124 (interactive (list t))
3125 (article-date-ut 'original highlight))
3127 (defun article-date-lapsed (&optional highlight)
3128 "Convert the current article date to time lapsed since it was sent."
3129 (interactive (list t))
3130 (article-date-ut 'lapsed highlight))
3132 (defun article-update-date-lapsed ()
3133 "Function to be run from a timer to update the lapsed time line."
3135 (let (deactivate-mark)
3140 (set-buffer (window-buffer w))
3141 (when (eq major-mode 'gnus-article-mode)
3142 (let ((mark (point-marker)))
3143 (goto-char (point-min))
3144 (when (re-search-forward "^X-Sent:" nil t)
3145 (article-date-lapsed t))
3146 (goto-char (marker-position mark))
3147 (move-marker mark nil))))
3150 (defun gnus-start-date-timer (&optional n)
3151 "Start a timer to update the X-Sent header in the article buffers.
3152 The numerical prefix says how frequently (in seconds) the function
3157 (gnus-stop-date-timer)
3158 (setq article-lapsed-timer
3159 (run-at-time 1 n 'article-update-date-lapsed)))
3161 (defun gnus-stop-date-timer ()
3162 "Stop the X-Sent timer."
3164 (when article-lapsed-timer
3165 (nnheader-cancel-timer article-lapsed-timer)
3166 (setq article-lapsed-timer nil)))
3168 (defun article-date-user (&optional highlight)
3169 "Convert the current article date to the user-defined format.
3170 This format is defined by the `gnus-article-time-format' variable."
3171 (interactive (list t))
3172 (article-date-ut 'user highlight))
3174 (defun article-date-iso8601 (&optional highlight)
3175 "Convert the current article date to ISO8601."
3176 (interactive (list t))
3177 (article-date-ut 'iso8601 highlight))
3179 (defmacro gnus-article-save-original-date (&rest forms)
3180 "Save the original date as a text property and evaluate FORMS."
3181 `(let* ((case-fold-search t)
3183 (goto-char (point-min))
3184 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3187 (date (when (and start
3188 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3190 (buffer-substring-no-properties start
3191 (match-beginning 0)))))
3192 (goto-char (point-max))
3193 (skip-chars-backward "\n")
3194 (put-text-property (point-min) (point) 'original-date date)
3196 (goto-char (point-max))
3197 (skip-chars-backward "\n")
3198 (put-text-property (point-min) (point) 'original-date date)))
3200 ;; (defun article-show-all ()
3201 ;; "Show all hidden text in the article buffer."
3204 ;; (let ((inhibit-read-only t))
3205 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3207 (defun article-remove-leading-whitespace ()
3208 "Remove excessive whitespace from all headers."
3212 (let ((inhibit-read-only t))
3213 (article-narrow-to-head)
3214 (goto-char (point-min))
3215 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3216 (delete-region (match-beginning 1) (match-end 1)))))))
3218 (defun article-emphasize (&optional arg)
3219 "Emphasize text according to `gnus-emphasis-alist'."
3220 (interactive (gnus-article-hidden-arg))
3221 (unless (gnus-article-check-hidden-text 'emphasis arg)
3225 (with-current-buffer gnus-summary-buffer
3226 gnus-article-emphasis-alist)
3228 gnus-emphasis-alist))
3229 (inhibit-read-only t)
3230 (props (append '(article-type emphasis)
3231 gnus-hidden-properties))
3232 regexp elem beg invisible visible face)
3235 (while (setq elem (pop alist))
3237 (setq regexp (car elem)
3238 invisible (nth 1 elem)
3239 visible (nth 2 elem)
3241 (while (re-search-forward regexp nil t)
3242 (when (and (match-beginning visible) (match-beginning invisible))
3243 (gnus-article-hide-text
3244 (match-beginning invisible) (match-end invisible) props)
3245 (gnus-article-unhide-text-type
3246 (match-beginning visible) (match-end visible) 'emphasis)
3247 (gnus-put-overlay-excluding-newlines
3248 (match-beginning visible) (match-end visible) 'face face)
3249 (gnus-add-wash-type 'emphasis)
3250 (goto-char (match-end invisible)))))))))
3252 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3253 "Setup newsgroup emphasis alist."
3254 (unless gnus-article-emphasis-alist
3255 (let ((name (and gnus-newsgroup-name
3256 (gnus-group-real-name gnus-newsgroup-name))))
3257 (make-local-variable 'gnus-article-emphasis-alist)
3258 (setq gnus-article-emphasis-alist
3260 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3261 (while (setq elem (pop alist))
3262 (when (and name (string-match (car elem) name))
3264 highlight (copy-sequence (cdr elem)))))
3266 (copy-sequence highlight-words)
3267 (if gnus-newsgroup-name
3268 (copy-sequence (gnus-group-find-parameter
3269 gnus-newsgroup-name 'highlight-words t)))
3270 gnus-emphasis-alist)))))
3273 (defvar gnus-summary-article-menu)
3274 (defvar gnus-summary-post-menu))
3276 ;;; Saving functions.
3278 (defun gnus-article-save (save-buffer file &optional num)
3279 "Save the currently selected article."
3280 (unless gnus-save-all-headers
3281 ;; Remove headers according to `gnus-saved-headers'.
3282 (let ((gnus-visible-headers
3283 (or gnus-saved-headers gnus-visible-headers))
3284 (gnus-article-buffer save-buffer))
3286 (set-buffer save-buffer)
3287 (article-hide-headers 1 t))))
3288 (save-window-excursion
3289 (if (not gnus-default-article-saver)
3290 (error "No default saver is defined")
3291 ;; !!! Magic! The saving functions all save
3292 ;; `gnus-save-article-buffer' (or so they think), but we
3293 ;; bind that variable to our save-buffer.
3294 (set-buffer gnus-article-buffer)
3295 (let* ((gnus-save-article-buffer save-buffer)
3298 ((not gnus-prompt-before-saving) 'default)
3299 ((eq gnus-prompt-before-saving 'always) nil)
3301 (gnus-number-of-articles-to-be-saved
3302 (when (eq gnus-prompt-before-saving t)
3304 (set-buffer gnus-article-current-summary)
3305 (funcall gnus-default-article-saver filename)))))
3307 (defun gnus-read-save-file-name (prompt &optional filename
3308 function group headers variable)
3310 (funcall function group headers (symbol-value variable)))
3315 ((eq filename 'default)
3321 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3324 (if (and gnus-number-of-articles-to-be-saved
3325 (> gnus-number-of-articles-to-be-saved 1))
3326 (format "these %d articles"
3327 gnus-number-of-articles-to-be-saved)
3330 ;; Let the split methods have their say.
3332 ;; No split name was found.
3335 (concat prompt " (default "
3336 (file-name-nondirectory default-name) "): ")
3337 (file-name-directory default-name)
3339 ;; A single group name is returned.
3340 ((stringp split-name)
3342 (funcall function split-name headers
3343 (symbol-value variable)))
3345 (concat prompt " (default "
3346 (file-name-nondirectory default-name) "): ")
3347 (file-name-directory default-name)
3349 ;; A single split name was found
3350 ((= 1 (length split-name))
3351 (let* ((name (expand-file-name
3353 gnus-article-save-directory))
3354 (dir (cond ((file-directory-p name)
3355 (file-name-as-directory name))
3356 ((file-exists-p name) name)
3357 (t gnus-article-save-directory))))
3359 (concat prompt " (default " name "): ")
3361 ;; A list of splits was found.
3363 (setq split-name (nreverse split-name))
3365 (let ((file-name-history
3366 (nconc split-name file-name-history)))
3370 (concat prompt " (`M-p' for defaults): ")
3371 gnus-article-save-directory
3373 gnus-article-save-directory)))
3374 (car (push result file-name-history)))))))
3375 ;; Create the directory.
3376 (gnus-make-directory (file-name-directory file))
3377 ;; If we have read a directory, we append the default file name.
3378 (when (file-directory-p file)
3379 (setq file (expand-file-name (file-name-nondirectory
3381 (file-name-as-directory file))))
3382 ;; Possibly translate some characters.
3383 (nnheader-translate-file-chars file))))))
3384 (gnus-make-directory (file-name-directory result))
3385 (set variable result)))
3387 (defun gnus-article-archive-name (group)
3388 "Return the first instance of an \"Archive-name\" in the current buffer."
3389 (let ((case-fold-search t))
3390 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3391 (nnheader-concat gnus-article-save-directory
3392 (match-string 1)))))
3394 (defun gnus-article-nndoc-name (group)
3395 "If GROUP is an nndoc group, return the name of the parent group."
3396 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3397 (gnus-group-get-parameter group 'save-article-group)))
3399 (defun gnus-summary-save-in-rmail (&optional filename)
3400 "Append this article to Rmail file.
3401 Optional argument FILENAME specifies file name.
3402 Directory to save to is default to `gnus-article-save-directory'."
3403 (setq filename (gnus-read-save-file-name
3404 "Save %s in rmail file" filename
3405 gnus-rmail-save-name gnus-newsgroup-name
3406 gnus-current-headers 'gnus-newsgroup-last-rmail))
3407 (gnus-eval-in-buffer-window gnus-save-article-buffer
3411 (gnus-output-to-rmail filename))))
3414 (defun gnus-summary-save-in-mail (&optional filename)
3415 "Append this article to Unix mail file.
3416 Optional argument FILENAME specifies file name.
3417 Directory to save to is default to `gnus-article-save-directory'."
3418 (setq filename (gnus-read-save-file-name
3419 "Save %s in Unix mail file" filename
3420 gnus-mail-save-name gnus-newsgroup-name
3421 gnus-current-headers 'gnus-newsgroup-last-mail))
3422 (gnus-eval-in-buffer-window gnus-save-article-buffer
3426 (if (and (file-readable-p filename)
3427 (file-regular-p filename)
3428 (mail-file-babyl-p filename))
3429 (rmail-output-to-rmail-file filename t)
3430 (gnus-output-to-mail filename)))))
3433 (defun gnus-summary-save-in-file (&optional filename overwrite)
3434 "Append this article to file.
3435 Optional argument FILENAME specifies file name.
3436 Directory to save to is default to `gnus-article-save-directory'."
3437 (setq filename (gnus-read-save-file-name
3438 "Save %s in file" filename
3439 gnus-file-save-name gnus-newsgroup-name
3440 gnus-current-headers 'gnus-newsgroup-last-file))
3441 (gnus-eval-in-buffer-window gnus-save-article-buffer
3445 (when (and overwrite
3446 (file-exists-p filename))
3447 (delete-file filename))
3448 (gnus-output-to-file filename))))
3451 (defun gnus-summary-write-to-file (&optional filename)
3452 "Write this article to a file, overwriting it if the file exists.
3453 Optional argument FILENAME specifies file name.
3454 The directory to save in defaults to `gnus-article-save-directory'."
3455 (gnus-summary-save-in-file nil t))
3457 (defun gnus-summary-save-body-in-file (&optional filename)
3458 "Append this article body to a file.
3459 Optional argument FILENAME specifies file name.
3460 The directory to save in defaults to `gnus-article-save-directory'."
3461 (setq filename (gnus-read-save-file-name
3462 "Save %s body in file" filename
3463 gnus-file-save-name gnus-newsgroup-name
3464 gnus-current-headers 'gnus-newsgroup-last-file))
3465 (gnus-eval-in-buffer-window gnus-save-article-buffer
3469 (when (article-goto-body)
3470 (narrow-to-region (point) (point-max)))
3471 (gnus-output-to-file filename))))
3474 (defun gnus-summary-save-in-pipe (&optional command)
3475 "Pipe this article to subprocess."
3477 (cond ((and (eq command 'default)
3478 gnus-last-shell-command)
3479 gnus-last-shell-command)
3484 "Shell command on %s: "
3485 (if (and gnus-number-of-articles-to-be-saved
3486 (> gnus-number-of-articles-to-be-saved 1))
3487 (format "these %d articles"
3488 gnus-number-of-articles-to-be-saved)
3490 gnus-last-shell-command))))
3491 (when (string-equal command "")
3492 (if gnus-last-shell-command
3493 (setq command gnus-last-shell-command)
3494 (error "A command is required")))
3495 (gnus-eval-in-buffer-window gnus-article-buffer
3498 (shell-command-on-region (point-min) (point-max) command nil)))
3499 (setq gnus-last-shell-command command))
3501 (defun gnus-summary-pipe-to-muttprint (&optional command)
3502 "Pipe this article to muttprint."
3503 (setq command (read-string
3504 "Print using command: " gnus-summary-muttprint-program
3505 nil gnus-summary-muttprint-program))
3506 (gnus-summary-save-in-pipe command))
3508 ;;; Article file names when saving.
3510 (defun gnus-capitalize-newsgroup (newsgroup)
3511 "Capitalize NEWSGROUP name."
3512 (when (not (zerop (length newsgroup)))
3513 (concat (char-to-string (upcase (aref newsgroup 0)))
3514 (substring newsgroup 1))))
3516 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3517 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3518 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3519 Otherwise, it is like ~/News/news/group/num."
3522 (concat (if (gnus-use-long-file-name 'not-save)
3523 (gnus-capitalize-newsgroup newsgroup)
3524 (gnus-newsgroup-directory-form newsgroup))
3525 "/" (int-to-string (mail-header-number headers)))
3526 gnus-article-save-directory)))
3528 (string-equal (file-name-directory default)
3529 (file-name-directory last-file))
3530 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3532 (or last-file default))))
3534 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3535 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3536 If variable `gnus-use-long-file-name' is non-nil, it is
3537 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3540 (concat (if (gnus-use-long-file-name 'not-save)
3542 (gnus-newsgroup-directory-form newsgroup))
3543 "/" (int-to-string (mail-header-number headers)))
3544 gnus-article-save-directory)))
3546 (string-equal (file-name-directory default)
3547 (file-name-directory last-file))
3548 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3550 (or last-file default))))
3552 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3553 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3554 If variable `gnus-use-long-file-name' is non-nil, it is
3555 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3558 (if (gnus-use-long-file-name 'not-save)
3561 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3563 gnus-article-save-directory)))
3565 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3566 "Generate file name from sender."
3567 (let ((from (mail-header-from headers)))
3569 (if (and from (string-match "\\([^ <]+\\)@" from))
3570 (match-string 1 from)
3572 gnus-article-save-directory)))
3574 (defun article-verify-x-pgp-sig ()
3577 (if (gnus-buffer-live-p gnus-original-article-buffer)
3578 (let ((sig (with-current-buffer gnus-original-article-buffer
3579 (gnus-fetch-field "X-PGP-Sig")))
3583 (mml2015-clear-verify-function))
3585 (insert-buffer-substring gnus-original-article-buffer)
3586 (setq items (split-string sig))
3587 (message-narrow-to-head)
3588 (let ((inhibit-point-motion-hooks t)
3589 (case-fold-search t))
3590 ;; Don't verify multiple headers.
3591 (setq headers (mapconcat (lambda (header)
3593 (mail-fetch-field header)
3595 (split-string (nth 1 items) ",") "")))
3596 (delete-region (point-min) (point-max))
3597 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3598 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3603 (if (looking-at "^-")
3606 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3607 (insert "Version: " (car items) "\n\n")
3608 (insert (mapconcat 'identity (cddr items) "\n"))
3609 (insert "\n-----END PGP SIGNATURE-----\n")
3610 (let ((mm-security-handle (list (format "multipart/signed"))))
3611 (mml2015-clean-buffer)
3612 (let ((coding-system-for-write (or gnus-newsgroup-charset
3614 (funcall (mml2015-clear-verify-function)))
3616 (or (mm-handle-multipart-ctl-parameter
3617 mm-security-handle 'gnus-details)
3618 (mm-handle-multipart-ctl-parameter
3619 mm-security-handle 'gnus-info)))))
3621 (let ((inhibit-read-only t) bface eface)
3623 (message-narrow-to-head)
3624 (goto-char (point-max))
3626 (setq bface (get-text-property (point-at-bol) 'face)
3627 eface (get-text-property (1- (point-at-eol)) 'face))
3628 (message-remove-header "X-Gnus-PGP-Verify")
3629 (if (re-search-forward "^X-PGP-Sig:" nil t)
3631 (goto-char (point-max)))
3632 (narrow-to-region (point) (point))
3633 (insert "X-Gnus-PGP-Verify: " info "\n")
3634 (goto-char (point-min))
3637 (if (not (looking-at "^[ \t]"))
3641 (goto-char (point-min))
3642 (when (looking-at "\\([^:]+\\): *")
3643 (put-text-property (match-beginning 1) (1+ (match-end 1))
3645 (put-text-property (match-end 0) (point-max)
3646 'face eface)))))))))
3648 (defun article-verify-cancel-lock ()
3649 "Verify Cancel-Lock header."
3651 (if (gnus-buffer-live-p gnus-original-article-buffer)
3652 (canlock-verify gnus-original-article-buffer)))
3659 (setq afunc (car func)
3662 gfunc (intern (format "gnus-%s" func))))
3664 (when (fboundp afunc)
3665 `(lambda (&optional interactive &rest args)
3666 ,(documentation afunc t)
3667 (interactive (list t))
3669 (set-buffer gnus-article-buffer)
3671 (call-interactively ',afunc)
3672 (apply ',afunc args))))))))
3673 '(article-hide-headers
3674 article-verify-x-pgp-sig
3675 article-verify-cancel-lock
3676 article-hide-boring-headers
3677 article-treat-overstrike
3678 article-treat-ansi-sequences
3679 article-fill-long-lines
3680 article-capitalize-sentences
3682 article-remove-leading-whitespace
3683 article-display-x-face
3684 article-display-face
3685 article-de-quoted-unreadable
3686 article-de-base64-unreadable
3689 article-unsplit-urls
3690 article-hide-list-identifiers
3691 article-strip-banner
3694 article-hide-signature
3695 article-strip-headers-in-body
3696 article-remove-trailing-blank-lines
3697 article-strip-leading-blank-lines
3698 article-strip-multiple-blank-lines
3699 article-strip-leading-space
3700 article-strip-trailing-space
3701 article-strip-blank-lines
3702 article-strip-all-blank-lines
3704 article-date-english
3705 article-date-iso8601
3706 article-date-original
3708 article-decode-mime-words
3709 article-decode-charset
3710 article-decode-encoded-words
3714 article-treat-dumbquotes
3715 article-normalize-headers
3716 ;; (article-show-all . gnus-article-show-all-headers)
3720 ;;; Gnus article mode
3723 (put 'gnus-article-mode 'mode-class 'special)
3725 (set-keymap-parent gnus-article-mode-map widget-keymap)
3727 (gnus-define-keys gnus-article-mode-map
3728 " " gnus-article-goto-next-page
3729 "\177" gnus-article-goto-prev-page
3730 [delete] gnus-article-goto-prev-page
3731 [backspace] gnus-article-goto-prev-page
3732 "\C-c^" gnus-article-refer-article
3733 "h" gnus-article-show-summary
3734 "s" gnus-article-show-summary
3735 "\C-c\C-m" gnus-article-mail
3736 "?" gnus-article-describe-briefly
3737 "e" gnus-summary-edit-article
3738 "<" beginning-of-buffer
3740 "\C-c\C-i" gnus-info-find-node
3742 "R" gnus-article-reply-with-original
3743 "F" gnus-article-followup-with-original
3744 "\C-hk" gnus-article-describe-key
3745 "\C-hc" gnus-article-describe-key-briefly
3747 "\C-d" gnus-article-read-summary-keys
3748 "\M-*" gnus-article-read-summary-keys
3749 "\M-#" gnus-article-read-summary-keys
3750 "\M-^" gnus-article-read-summary-keys
3751 "\M-g" gnus-article-read-summary-keys)
3753 (substitute-key-definition
3754 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3756 (defun gnus-article-make-menu-bar ()
3757 (unless (boundp 'gnus-article-commands-menu)
3758 (gnus-summary-make-menu-bar))
3759 (gnus-turn-off-edit-menu 'article)
3760 (unless (boundp 'gnus-article-article-menu)
3762 gnus-article-article-menu gnus-article-mode-map ""
3764 ["Scroll forwards" gnus-article-goto-next-page t]
3765 ["Scroll backwards" gnus-article-goto-prev-page t]
3766 ["Show summary" gnus-article-show-summary t]
3767 ["Fetch Message-ID at point" gnus-article-refer-article t]
3768 ["Mail to address at point" gnus-article-mail t]
3769 ["Send a bug report" gnus-bug t]))
3772 gnus-article-treatment-menu gnus-article-mode-map ""
3773 ;; Fixme: this should use :active (and maybe :visible).
3775 ["Hide headers" gnus-article-hide-headers t]
3776 ["Hide signature" gnus-article-hide-signature t]
3777 ["Hide citation" gnus-article-hide-citation t]
3778 ["Treat overstrike" gnus-article-treat-overstrike t]
3779 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3780 ["Remove carriage return" gnus-article-remove-cr t]
3781 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3782 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3783 ["Remove base64" gnus-article-de-base64-unreadable t]
3784 ["Treat html" gnus-article-wash-html t]
3785 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3786 ["Decode HZ" gnus-article-decode-HZ t]))
3788 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3790 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3792 (gnus-run-hooks 'gnus-article-menu-hook)))
3794 (defun gnus-article-mode ()
3795 "Major mode for displaying an article.
3797 All normal editing commands are switched off.
3799 The following commands are available in addition to all summary mode
3801 \\<gnus-article-mode-map>
3802 \\[gnus-article-next-page]\t Scroll the article one page forwards
3803 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3804 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3805 \\[gnus-article-show-summary]\t Display the summary buffer
3806 \\[gnus-article-mail]\t Send a reply to the address near point
3807 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3808 \\[gnus-info-find-node]\t Go to the Gnus info node"
3810 (kill-all-local-variables)
3811 (gnus-simplify-mode-line)
3812 (setq mode-name "Article")
3813 (setq major-mode 'gnus-article-mode)
3814 (make-local-variable 'minor-mode-alist)
3815 (use-local-map gnus-article-mode-map)
3816 (when (gnus-visual-p 'article-menu 'menu)
3817 (gnus-article-make-menu-bar)
3818 (when gnus-summary-tool-bar-map
3819 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3820 (gnus-update-format-specifications nil 'article-mode)
3821 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3822 (set (make-local-variable 'gnus-page-broken) nil)
3823 (make-local-variable 'gnus-button-marker-list)
3824 (make-local-variable 'gnus-article-current-summary)
3825 (make-local-variable 'gnus-article-mime-handles)
3826 (make-local-variable 'gnus-article-decoded-p)
3827 (make-local-variable 'gnus-article-mime-handle-alist)
3828 (make-local-variable 'gnus-article-wash-types)
3829 (make-local-variable 'gnus-article-image-alist)
3830 (make-local-variable 'gnus-article-charset)
3831 (make-local-variable 'gnus-article-ignored-charsets)
3832 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3833 (set (make-local-variable 'nobreak-char-display) nil)
3834 (gnus-set-default-directory)
3835 (buffer-disable-undo)
3836 (setq buffer-read-only t
3837 show-trailing-whitespace nil)
3838 (set-syntax-table gnus-article-mode-syntax-table)
3839 (mm-enable-multibyte)
3840 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3842 (defun gnus-article-setup-buffer ()
3843 "Initialize the article buffer."
3844 (let* ((name (if gnus-single-article-buffer "*Article*"
3845 (concat "*Article " gnus-newsgroup-name "*")))
3847 (progn (string-match "\\*Article" name)
3848 (concat " *Original Article"
3849 (substring name (match-end 0))))))
3850 (setq gnus-article-buffer name)
3851 (setq gnus-original-article-buffer original)
3852 (setq gnus-article-mime-handle-alist nil)
3853 ;; This might be a variable local to the summary buffer.
3854 (unless gnus-single-article-buffer
3856 (set-buffer gnus-summary-buffer)
3857 (setq gnus-article-buffer name)
3858 (setq gnus-original-article-buffer original)
3859 (gnus-set-global-variables)))
3860 (gnus-article-setup-highlight-words)
3861 ;; Init original article buffer.
3863 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3864 (mm-enable-multibyte)
3865 (setq major-mode 'gnus-original-article-mode)
3866 (make-local-variable 'gnus-original-article))
3867 (if (and (get-buffer name)
3868 (with-current-buffer name
3869 (if gnus-article-edit-mode
3870 (if (y-or-n-p "Article mode edit in progress; discard? ")
3872 (set-buffer-modified-p nil)
3873 (gnus-kill-buffer name)
3876 (error "Action aborted"))
3880 (set (make-local-variable 'gnus-article-edit-mode) nil)
3881 (when gnus-article-mime-handles
3882 (mm-destroy-parts gnus-article-mime-handles)
3883 (setq gnus-article-mime-handles nil))
3884 ;; Set it to nil in article-buffer!
3885 (setq gnus-article-mime-handle-alist nil)
3886 (buffer-disable-undo)
3887 (setq buffer-read-only t)
3888 ;; This list just keeps growing if we don't reset it.
3889 (setq gnus-button-marker-list nil)
3890 (unless (eq major-mode 'gnus-article-mode)
3891 (gnus-article-mode))
3894 (set-buffer (gnus-get-buffer-create name))
3896 (make-local-variable 'gnus-summary-buffer)
3897 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3898 (current-buffer)))))
3900 ;; Set article window start at LINE, where LINE is the number of lines
3901 ;; from the head of the article.
3902 (defun gnus-article-set-window-start (&optional line)
3904 (gnus-get-buffer-window gnus-article-buffer t)
3906 (set-buffer gnus-article-buffer)
3907 (goto-char (point-min))
3910 (gnus-message 6 "Moved to bookmark")
3911 (search-forward "\n\n" nil t)
3915 (defun gnus-article-prepare (article &optional all-headers header)
3916 "Prepare ARTICLE in article mode buffer.
3917 ARTICLE should either be an article number or a Message-ID.
3918 If ARTICLE is an id, HEADER should be the article headers.
3919 If ALL-HEADERS is non-nil, no headers are hidden."
3921 ;; Make sure we start in a summary buffer.
3922 (unless (eq major-mode 'gnus-summary-mode)
3923 (set-buffer gnus-summary-buffer))
3924 (setq gnus-summary-buffer (current-buffer))
3925 (let* ((gnus-article (if header (mail-header-number header) article))
3926 (summary-buffer (current-buffer))
3927 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3928 (group gnus-newsgroup-name)
3931 (gnus-article-setup-buffer)
3932 (set-buffer gnus-article-buffer)
3933 ;; Deactivate active regions.
3934 (when (and (boundp 'transient-mark-mode)
3935 transient-mark-mode)
3936 (setq mark-active nil))
3937 (if (not (setq result (let ((inhibit-read-only t))
3938 (gnus-request-article-this-buffer
3940 ;; There is no such article.
3942 (when (and (numberp article)
3943 (not (memq article gnus-newsgroup-sparse)))
3944 (setq gnus-article-current
3945 (cons gnus-newsgroup-name article))
3946 (set-buffer gnus-summary-buffer)
3947 (setq gnus-current-article article)
3948 (if (and (memq article gnus-newsgroup-undownloaded)
3949 (not (gnus-online (gnus-find-method-for-group
3950 gnus-newsgroup-name))))
3952 (gnus-summary-set-agent-mark article)
3953 (message "Message marked for downloading"))
3954 (gnus-summary-mark-article article gnus-canceled-mark)
3955 (unless (memq article gnus-newsgroup-sparse)
3956 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3957 (if (or (eq result 'pseudo)
3958 (eq result 'nneething))
3961 (set-buffer summary-buffer)
3962 (push article gnus-newsgroup-history)
3963 (setq gnus-last-article gnus-current-article
3964 gnus-current-article 0
3965 gnus-current-headers nil
3966 gnus-article-current nil)
3967 (if (eq result 'nneething)
3968 (gnus-configure-windows 'summary)
3969 (gnus-configure-windows 'article))
3970 (gnus-set-global-variables))
3971 (let ((gnus-article-mime-handle-alist-1
3972 gnus-article-mime-handle-alist))
3973 (gnus-set-mode-line 'article)))
3974 ;; The result from the `request' was an actual article -
3975 ;; or at least some text that is now displayed in the
3977 (when (and (numberp article)
3978 (not (eq article gnus-current-article)))
3979 ;; Seems like a new article has been selected.
3980 ;; `gnus-current-article' must be an article number.
3982 (set-buffer summary-buffer)
3983 (push article gnus-newsgroup-history)
3984 (setq gnus-last-article gnus-current-article
3985 gnus-current-article article
3986 gnus-current-headers
3987 (gnus-summary-article-header gnus-current-article)
3988 gnus-article-current
3989 (cons gnus-newsgroup-name gnus-current-article))
3990 (unless (vectorp gnus-current-headers)
3991 (setq gnus-current-headers nil))
3992 (gnus-summary-goto-subject gnus-current-article)
3993 (when (gnus-summary-show-thread)
3994 ;; If the summary buffer really was folded, the
3995 ;; previous goto may not actually have gone to
3996 ;; the right article, but the thread root instead.
3998 (gnus-summary-goto-subject gnus-current-article))
3999 (gnus-run-hooks 'gnus-mark-article-hook)
4000 (gnus-set-mode-line 'summary)
4001 (when (gnus-visual-p 'article-highlight 'highlight)
4002 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4003 ;; Set the global newsgroup variables here.
4004 (gnus-set-global-variables)
4005 (setq gnus-have-all-headers
4006 (or all-headers gnus-show-all-headers))))
4008 (gnus-configure-windows 'article))
4009 (when (or (numberp article)
4011 (gnus-article-prepare-display)
4013 (goto-char (point-min))
4014 (when gnus-break-pages
4015 (gnus-narrow-to-page)))
4016 (let ((gnus-article-mime-handle-alist-1
4017 gnus-article-mime-handle-alist))
4018 (gnus-set-mode-line 'article))
4022 (set-window-point (get-buffer-window (current-buffer)) (point))
4023 (gnus-configure-windows 'article)
4027 (defun gnus-article-prepare-display ()
4028 "Make the current buffer look like a nice article."
4029 ;; Hooks for getting information from the article.
4030 ;; This hook must be called before being narrowed.
4031 (let ((gnus-article-buffer (current-buffer))
4033 (inhibit-read-only t))
4034 (unless (eq major-mode 'gnus-article-mode)
4035 (gnus-article-mode))
4036 (setq buffer-read-only nil
4037 gnus-article-wash-types nil
4038 gnus-article-image-alist nil)
4039 (gnus-run-hooks 'gnus-tmp-internal-hook)
4040 (when gnus-display-mime-function
4041 (funcall gnus-display-mime-function))
4042 (gnus-run-hooks 'gnus-article-prepare-hook)))
4045 ;;; Gnus MIME viewing functions
4048 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4049 "Format of the MIME buttons.
4051 Valid specifiers include:
4053 %T MIME type, along with additional info
4054 %n The `name' parameter
4055 %d The description, if any
4056 %l The length of the encoded part
4057 %p The part identifier number
4058 %e Dots if the part isn't displayed
4060 General format specifiers can also be used. See Info node
4061 `(gnus)Formatting Variables'.")
4063 (defvar gnus-mime-button-line-format-alist
4064 '((?t gnus-tmp-type ?s)
4065 (?T gnus-tmp-type-long ?s)
4066 (?n gnus-tmp-name ?s)
4067 (?d gnus-tmp-description ?s)
4069 (?l gnus-tmp-length ?d)
4070 (?e gnus-tmp-dots ?s)))
4072 (defvar gnus-mime-button-commands
4073 '((gnus-article-press-button "\r" "Toggle Display")
4074 (gnus-mime-view-part "v" "View Interactively...")
4075 (gnus-mime-view-part-as-type "t" "View As Type...")
4076 (gnus-mime-view-part-as-charset "C" "View As charset...")
4077 (gnus-mime-save-part "o" "Save...")
4078 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4079 (gnus-mime-replace-part "r" "Replace part")
4080 (gnus-mime-delete-part "d" "Delete part")
4081 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4082 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4083 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4084 (gnus-mime-view-part-externally "e" "View Externally")
4085 (gnus-mime-print-part "p" "Print")
4086 (gnus-mime-pipe-part "|" "Pipe To Command...")
4087 (gnus-mime-action-on-part "." "Take action on the part...")))
4089 (defun gnus-article-mime-part-status ()
4090 (if gnus-article-mime-handle-alist-1
4091 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4093 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4096 (defvar gnus-mime-button-map
4097 (let ((map (make-sparse-keymap)))
4098 (define-key map gnus-mouse-2 'gnus-article-push-button)
4099 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4100 (dolist (c gnus-mime-button-commands)
4101 (define-key map (cadr c) (car c)))
4105 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4107 ,@(mapcar (lambda (c)
4108 (vector (caddr c) (car c) :enable t))
4109 gnus-mime-button-commands)))
4111 (defun gnus-mime-button-menu (event prefix)
4112 "Construct a context-sensitive menu of MIME commands."
4113 (interactive "e\nP")
4114 (save-window-excursion
4115 (let ((pos (event-start event)))
4116 (select-window (posn-window pos))
4117 (goto-char (posn-point pos))
4118 (gnus-article-check-buffer)
4119 (popup-menu gnus-mime-button-menu nil prefix))))
4121 (defun gnus-mime-view-all-parts (&optional handles)
4122 "View all the MIME parts."
4124 (with-current-buffer gnus-article-buffer
4125 (let ((handles (or handles gnus-article-mime-handles))
4126 (mail-parse-charset gnus-newsgroup-charset)
4127 (mail-parse-ignored-charsets
4128 (with-current-buffer gnus-summary-buffer
4129 gnus-newsgroup-ignored-charsets)))
4131 (mm-remove-parts handles)
4132 (goto-char (point-min))
4133 (or (search-forward "\n\n") (goto-char (point-max)))
4134 (let ((inhibit-read-only t))
4135 (delete-region (point) (point-max))
4136 (mm-display-parts handles))))))
4138 (defun gnus-article-jump-to-part (n)
4139 "Jump to MIME part N."
4141 (pop-to-buffer gnus-article-buffer)
4142 ;; FIXME: why is it necessary?
4144 (let ((parts (length gnus-article-mime-handle-alist)))
4147 (read-string ;; Emacs 21 doesn't have `read-number'.
4148 (format "Jump to part (2..%s): " parts)))))
4149 (unless (and (integerp n) (<= n parts) (>= n 1))
4152 (gnus-message 7 "Invalid part `%s', using %s instead."
4155 (gnus-message 9 "Jumping to part %s." n)
4156 (cond ((>= gnus-auto-select-part 1)
4157 (while (and (<= n parts)
4158 (not (gnus-article-goto-part n)))
4160 ((< gnus-auto-select-part 0)
4161 (while (and (>= n 1)
4162 (not (gnus-article-goto-part n)))
4165 (gnus-article-goto-part n)))))
4168 (defsubst gnus-article-edit-part (handles &optional current-id)
4169 "Edit an article in order to delete a mime part.
4170 This function is exclusively used by `gnus-mime-save-part-and-strip'
4171 and `gnus-mime-delete-part', and not provided at run-time normally."
4172 (gnus-article-edit-article
4174 (buffer-disable-undo)
4176 (let ((mail-parse-charset (or gnus-article-charset
4177 ',gnus-newsgroup-charset))
4178 (mail-parse-ignored-charsets
4179 (or gnus-article-ignored-charsets
4180 ',gnus-newsgroup-ignored-charsets))
4181 (mbl mml-buffer-list))
4182 (setq mml-buffer-list nil)
4183 (insert-buffer-substring gnus-original-article-buffer)
4184 (mime-to-mml ',handles)
4185 (setq gnus-article-mime-handles nil)
4186 (let ((mbl1 mml-buffer-list))
4187 (setq mml-buffer-list mbl)
4188 (set (make-local-variable 'mml-buffer-list) mbl1))
4189 (gnus-make-local-hook 'kill-buffer-hook)
4190 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4191 `(lambda (no-highlight)
4192 (let ((mail-parse-charset (or gnus-article-charset
4193 ',gnus-newsgroup-charset))
4194 (message-options message-options)
4195 (message-options-set-recipient)
4196 (mail-parse-ignored-charsets
4197 (or gnus-article-ignored-charsets
4198 ',gnus-newsgroup-ignored-charsets)))
4200 (mml-destroy-buffers)
4201 (remove-hook 'kill-buffer-hook
4202 'mml-destroy-buffers t)
4203 (kill-local-variable 'mml-buffer-list))
4204 (gnus-summary-edit-article-done
4205 ,(or (mail-header-references gnus-current-headers) "")
4206 ,(gnus-group-read-only-p)
4207 ,gnus-summary-buffer no-highlight))
4209 (gnus-article-edit-done)
4210 (gnus-summary-expand-window)
4211 (gnus-summary-show-article)
4212 (when (and current-id (integerp gnus-auto-select-part))
4213 (gnus-article-jump-to-part
4214 (+ current-id gnus-auto-select-part)))))
4216 (defun gnus-mime-replace-part (file)
4217 "Replace MIME part under point with an external body."
4218 ;; Useful if file has already been saved to disk
4222 (read-file-name "Replace MIME part with file: "
4223 (or mm-default-directory default-directory)
4225 (gnus-mime-save-part-and-strip file))
4227 (defun gnus-mime-save-part-and-strip (&optional file)
4228 "Save the MIME part under point then replace it with an external body.
4229 If FILE is given, use it for the external part."
4231 (gnus-article-check-buffer)
4232 (when (gnus-group-read-only-p)
4233 (error "The current group does not support deleting of parts"))
4234 (when (mm-complicated-handles gnus-article-mime-handles)
4236 The current article has a complicated MIME structure, giving up..."))
4237 (let* ((data (get-text-property (point) 'gnus-data))
4238 (id (get-text-property (point) 'gnus-part))
4240 (handles gnus-article-mime-handles))
4243 (and data (mm-save-part data "Delete MIME part and save to: "))))
4245 (with-current-buffer (mm-handle-buffer data)
4247 (insert "Content-Type: " (mm-handle-media-type data))
4248 (mml-insert-parameter-string (cdr (mm-handle-type data))
4251 (insert "Content-ID: " (message-make-message-id) "\n")
4252 (insert "Content-Transfer-Encoding: binary\n")
4255 (cdr (mm-make-handle nil
4256 `("message/external-body"
4257 (access-type . "LOCAL-FILE")
4259 ;; (set-buffer gnus-summary-buffer)
4260 (gnus-article-edit-part handles id))))
4262 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
4263 ;; parts...>') but with stripping would be nice.
4265 (defun gnus-mime-delete-part ()
4266 "Delete the MIME part under point.
4267 Replace it with some information about the removed part."
4269 (gnus-article-check-buffer)
4270 (when (gnus-group-read-only-p)
4271 (error "The current group does not support deleting of parts"))
4272 (when (mm-complicated-handles gnus-article-mime-handles)
4274 The current article has a complicated MIME structure, giving up..."))
4275 (when (or gnus-expert-user
4276 (gnus-yes-or-no-p "\
4277 Deleting parts may malfunction or destroy the article; continue? "))
4278 (let* ((data (get-text-property (point) 'gnus-data))
4279 (id (get-text-property (point) 'gnus-part))
4280 (handles gnus-article-mime-handles)
4284 (mail-decode-encoded-word-string (or (mm-handle-description data)
4287 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4289 (type (mm-handle-media-type data)))
4291 (error "No MIME part under point"))
4292 (with-current-buffer (mm-handle-buffer data)
4293 (let ((bsize (format "%s" (buffer-size))))
4298 "| The following attachment has been deleted:\n"
4300 "| Type: " type "\n"
4301 "| Filename: " filename "\n"
4302 "| Size (encoded): " bsize " Byte\n"
4303 "| Description: " description "\n"
4306 (cdr (mm-make-handle
4307 nil `("text/plain") nil nil
4309 (format "Deleted attachment (%s bytes)" bsize))))))
4310 ;; (set-buffer gnus-summary-buffer)
4311 (gnus-article-edit-part handles id))))
4313 (defun gnus-mime-save-part ()
4314 "Save the MIME part under point."
4316 (gnus-article-check-buffer)
4317 (let ((data (get-text-property (point) 'gnus-data)))
4319 (mm-save-part data))))
4321 (defun gnus-mime-pipe-part ()
4322 "Pipe the MIME part under point to a process."
4324 (gnus-article-check-buffer)
4325 (let ((data (get-text-property (point) 'gnus-data)))
4327 (mm-pipe-part data))))
4329 (defun gnus-mime-view-part ()
4330 "Interactively choose a viewing method for the MIME part under point."
4332 (gnus-article-check-buffer)
4333 (let ((data (get-text-property (point) 'gnus-data)))
4335 (setq gnus-article-mime-handles
4337 gnus-article-mime-handles (setq data (copy-sequence data))))
4338 (mm-interactively-view-part data))))
4340 (defun gnus-mime-view-part-as-type-internal ()
4341 (gnus-article-check-buffer)
4342 (let* ((handle (get-text-property (point) 'gnus-data))
4344 ;; Content-Type: foo/bar; name=...
4345 (mail-content-type-get (mm-handle-type handle) 'name)
4346 ;; Content-Disposition: attachment; filename=...
4347 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
4348 (def-type (and name (mm-default-file-encoding name))))
4349 (and def-type (cons def-type 0))))
4351 (defun gnus-mime-view-part-as-type (&optional mime-type)
4352 "Choose a MIME media type, and view the part as such."
4356 (let ((default (gnus-mime-view-part-as-type-internal)))
4358 (format "View as MIME type (default %s): "
4360 (mapcar #'list (mailcap-mime-types))
4363 (gnus-article-check-buffer)
4364 (let ((handle (get-text-property (point) 'gnus-data)))
4367 (mm-make-handle (mm-handle-buffer handle)
4368 (cons mime-type (cdr (mm-handle-type handle)))
4369 (mm-handle-encoding handle)
4370 (mm-handle-undisplayer handle)
4371 (mm-handle-disposition handle)
4372 (mm-handle-description handle)
4374 (mm-handle-id handle)))
4375 (setq gnus-article-mime-handles
4376 (mm-merge-handles gnus-article-mime-handles handle))
4377 (gnus-mm-display-part handle))))
4379 (defun gnus-mime-copy-part (&optional handle arg)
4380 "Put the MIME part under point into a new buffer.
4381 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4383 (interactive (list nil current-prefix-arg))
4384 (gnus-article-check-buffer)
4386 (setq handle (get-text-property (point) 'gnus-data)))
4388 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4390 (mail-content-type-get (mm-handle-disposition handle)
4392 contents dont-decode charset coding-system)
4393 (mm-with-unibyte-buffer
4394 (mm-insert-part handle)
4395 (setq contents (or (condition-case nil
4396 (mm-decompress-buffer filename nil 'sig)
4398 (setq dont-decode t)
4401 (setq filename (cond (filename (file-name-nondirectory filename))
4402 (dont-decode "*raw data*")
4407 (unless (setq charset (mail-content-type-get
4408 (mm-handle-type handle) 'charset))
4409 (unless (setq coding-system (mm-with-unibyte-buffer
4411 (mm-find-buffer-file-coding-system)))
4412 (setq charset gnus-newsgroup-charset))))
4414 (setq charset (or (cdr (assq arg
4415 gnus-summary-show-article-charset-alist))
4416 (mm-read-coding-system "Charset: ")))))
4417 (switch-to-buffer (generate-new-buffer filename))
4418 (if (or coding-system
4420 (setq coding-system (mm-charset-to-coding-system charset))
4421 (not (eq charset 'ascii))))
4423 (mm-enable-multibyte)
4424 (insert (mm-decode-coding-string contents coding-system))
4425 (setq buffer-file-coding-system
4426 (if (boundp 'last-coding-system-used)
4427 (symbol-value 'last-coding-system-used)
4429 (mm-disable-multibyte)
4431 (setq buffer-file-coding-system mm-binary-coding-system))
4432 ;; We do it this way to make `normal-mode' set the appropriate mode.
4435 (setq buffer-file-name (expand-file-name filename))
4437 (setq buffer-file-name nil))
4438 (goto-char (point-min)))))
4440 (defun gnus-mime-print-part (&optional handle filename)
4441 "Print the MIME part under point."
4442 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4443 (gnus-article-check-buffer)
4444 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4445 (contents (and handle (mm-get-part handle)))
4446 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4447 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4452 (mm-save-part-to-file handle file)
4453 (call-process shell-file-name nil
4454 (generate-new-buffer " *mm*")
4456 shell-command-switch
4458 printer file (mm-handle-type handle))))
4462 (gnus-print-buffer))
4463 (ps-despool filename)))))
4465 (defun gnus-mime-inline-part (&optional handle arg)
4466 "Insert the MIME part under point into the current buffer.
4467 Compressed files like .gz and .bz2 are decompressed."
4468 (interactive (list nil current-prefix-arg))
4469 (gnus-article-check-buffer)
4471 (setq handle (get-text-property (point) 'gnus-data)))
4474 (inhibit-read-only t)
4475 contents charset coding-system)
4476 (if (and (not arg) (mm-handle-undisplayer handle))
4477 (mm-remove-part handle)
4478 (mm-with-unibyte-buffer
4479 (mm-insert-part handle)
4481 (or (mm-decompress-buffer
4482 (or (mail-content-type-get (mm-handle-disposition handle)
4484 (mail-content-type-get (mm-handle-disposition handle)
4490 (unless (setq charset (mail-content-type-get
4491 (mm-handle-type handle) 'charset))
4492 (unless (setq coding-system
4493 (mm-with-unibyte-buffer
4495 (mm-find-buffer-file-coding-system)))
4496 (setq charset gnus-newsgroup-charset))))
4498 (if (mm-handle-undisplayer handle)
4499 (mm-remove-part handle))
4502 gnus-summary-show-article-charset-alist))
4503 (mm-read-coding-system "Charset: "))))
4505 (if (mm-handle-undisplayer handle)
4506 (mm-remove-part handle))))
4510 (if (or coding-system
4513 (mm-charset-to-coding-system charset))
4514 (not (eq coding-system 'ascii))))
4515 (mm-decode-coding-string contents coding-system)
4516 (mm-string-to-multibyte contents)))
4519 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4520 "Insert the MIME part under point into the current buffer using the
4522 (interactive (list nil current-prefix-arg))
4523 (gnus-article-check-buffer)
4524 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4527 (inhibit-read-only t))
4529 (if (mm-handle-undisplayer handle)
4530 (mm-remove-part handle))
4531 (let ((gnus-newsgroup-charset
4533 gnus-summary-show-article-charset-alist))
4534 (mm-read-coding-system "Charset: ")))
4535 (gnus-newsgroup-ignored-charsets 'gnus-all))
4536 (gnus-article-press-button)))))
4538 (defun gnus-mime-view-part-externally (&optional handle)
4539 "View the MIME part under point with an external viewer."
4541 (gnus-article-check-buffer)
4542 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4543 (mm-user-display-methods nil)
4544 (mm-inlined-types nil)
4545 (mail-parse-charset gnus-newsgroup-charset)
4546 (mail-parse-ignored-charsets
4547 (with-current-buffer gnus-summary-buffer
4548 gnus-newsgroup-ignored-charsets)))
4550 (if (mm-handle-undisplayer handle)
4551 (mm-remove-part handle)
4552 (mm-display-part handle)))))
4554 (defun gnus-mime-view-part-internally (&optional handle)
4555 "View the MIME part under point with an internal viewer.
4556 If no internal viewer is available, use an external viewer."
4558 (gnus-article-check-buffer)
4559 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4560 (mm-inlined-types '(".*"))
4561 (mm-inline-large-images t)
4562 (mail-parse-charset gnus-newsgroup-charset)
4563 (mail-parse-ignored-charsets
4564 (with-current-buffer gnus-summary-buffer
4565 gnus-newsgroup-ignored-charsets))
4566 (inhibit-read-only t))
4568 (if (mm-handle-undisplayer handle)
4569 (mm-remove-part handle)
4570 (mm-display-part handle)))))
4572 (defun gnus-mime-action-on-part (&optional action)
4573 "Do something with the MIME attachment at \(point\)."
4575 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4576 (gnus-article-check-buffer)
4577 (let ((action-pair (assoc action gnus-mime-action-alist)))
4579 (funcall (cdr action-pair)))))
4581 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
4582 "Call FUNCTION on MIME part N.
4583 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
4584 If INTERACTIVE, call FUNCTION interactivly."
4586 ;; Check whether the article is displayed.
4587 (unless (and (gnus-buffer-live-p gnus-article-buffer)
4588 (setq window (get-buffer-window gnus-article-buffer t))
4589 (frame-visible-p (setq frame (window-frame window))))
4590 (error "No article is displayed"))
4591 (with-current-buffer gnus-article-buffer
4592 ;; Check whether the article displays the right contents.
4593 (unless (with-current-buffer gnus-summary-buffer
4594 (eq gnus-current-article (gnus-summary-article-number)))
4595 (error "You should select the right article first"))
4596 ;; Check whether the specified part exists.
4597 (when (> n (length gnus-article-mime-handle-alist))
4598 (error "No such part")))
4601 ;; To select the window is needed so that the cursor
4602 ;; might be visible on the MIME button.
4603 (select-window (prog1
4605 (setq window (selected-window))
4606 ;; Article may be displayed in the other frame.
4607 (gnus-select-frame-set-input-focus
4610 (setq frame (selected-frame))))))
4611 (when (gnus-article-goto-part n)
4612 ;; We point the cursor and the arrow at the MIME button
4613 ;; when the `function' prompt the user for something.
4614 (let ((cursor-in-non-selected-windows t)
4615 (overlay-arrow-string "=>")
4616 (overlay-arrow-position (point-marker)))
4619 ((and no-handle interactive)
4620 (call-interactively function))
4626 (cdr (assq n gnus-article-mime-handle-alist))))
4629 (cdr (assq n gnus-article-mime-handle-alist)))))
4630 (set-marker overlay-arrow-position nil)
4631 (unless gnus-auto-select-part
4632 (gnus-select-frame-set-input-focus frame)
4633 (select-window window))))
4635 (if gnus-inhibit-mime-unbuttonizing
4636 ;; This is the default though the program shouldn't reach here.
4637 (error "No such part")
4638 ;; The part which doesn't have the MIME button is selected.
4639 ;; So, we display all the buttons and redo it.
4640 (let ((gnus-inhibit-mime-unbuttonizing t))
4641 (gnus-summary-show-article)
4642 (gnus-article-part-wrapper n function no-handle))))))
4644 (defun gnus-article-pipe-part (n)
4645 "Pipe MIME part N, which is the numerical prefix."
4647 (gnus-article-part-wrapper n 'mm-pipe-part))
4649 (defun gnus-article-save-part (n)
4650 "Save MIME part N, which is the numerical prefix."
4652 (gnus-article-part-wrapper n 'mm-save-part))
4654 (defun gnus-article-interactively-view-part (n)
4655 "View MIME part N interactively, which is the numerical prefix."
4657 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4659 (defun gnus-article-copy-part (n)
4660 "Copy MIME part N, which is the numerical prefix."
4662 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4664 (defun gnus-article-view-part-as-charset (n)
4665 "View MIME part N using a specified charset.
4666 N is the numerical prefix."
4668 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4670 (defun gnus-article-view-part-externally (n)
4671 "View MIME part N externally, which is the numerical prefix."
4673 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4675 (defun gnus-article-inline-part (n)
4676 "Inline MIME part N, which is the numerical prefix."
4678 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4680 (defun gnus-article-save-part-and-strip (n)
4681 "Save MIME part N and replace it with an external body.
4682 N is the numerical prefix."
4684 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
4686 (defun gnus-article-replace-part (n)
4687 "Replace MIME part N with an external body.
4688 N is the numerical prefix."
4690 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
4692 (defun gnus-article-delete-part (n)
4693 "Delete MIME part N and add some information about the removed part.
4694 N is the numerical prefix."
4696 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
4698 (defun gnus-article-mime-match-handle-first (condition)
4701 (dolist (ihandle gnus-article-mime-handle-alist)
4703 ((functionp condition)
4704 (funcall condition (cdr ihandle)))
4705 ((eq condition 'undisplayed)
4706 (not (or (mm-handle-undisplayer (cdr ihandle))
4707 (equal (mm-handle-media-type (cdr ihandle))
4708 "multipart/alternative"))))
4709 ((eq condition 'undisplayed-alternative)
4710 (not (mm-handle-undisplayer (cdr ihandle))))
4712 (gnus-article-goto-part (car ihandle))
4713 (or (not n) (< (car ihandle) n)))
4714 (setq n (car ihandle))))
4718 (defun gnus-article-view-part (&optional n)
4719 "View MIME part N, which is the numerical prefix."
4721 (with-current-buffer gnus-article-buffer
4722 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4723 gnus-article-mime-match-handle-function)))
4724 (when (> n (length gnus-article-mime-handle-alist))
4725 (error "No such part"))
4726 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4727 (when (gnus-article-goto-part n)
4728 (if (equal (car handle) "multipart/alternative")
4729 (gnus-article-press-button)
4730 (when (eq (gnus-mm-display-part handle) 'internal)
4731 (gnus-set-window-start)))))))
4733 (defsubst gnus-article-mime-total-parts ()
4734 (if (bufferp (car gnus-article-mime-handles))
4736 (1- (length gnus-article-mime-handles))))
4738 (defun gnus-mm-display-part (handle)
4739 "Display HANDLE and fix MIME button."
4740 (let ((id (get-text-property (point) 'gnus-part))
4742 (inhibit-read-only t))
4745 (let ((window (selected-window))
4746 (mail-parse-charset gnus-newsgroup-charset)
4747 (mail-parse-ignored-charsets
4748 (if (gnus-buffer-live-p gnus-summary-buffer)
4749 (with-current-buffer gnus-summary-buffer
4750 gnus-newsgroup-ignored-charsets)
4754 (let ((win (gnus-get-buffer-window (current-buffer) t))
4757 (select-window win))
4760 (if (mm-handle-displayed-p handle)
4761 ;; This will remove the part.
4762 (mm-display-part handle)
4764 (narrow-to-region (point)
4765 (if (eobp) (point) (1+ (point))))
4766 (mm-display-part handle)
4767 ;; We narrow to the part itself and
4768 ;; then call the treatment functions.
4769 (goto-char (point-min))
4771 (narrow-to-region (point) (point-max))
4774 (gnus-article-mime-total-parts)
4775 (mm-handle-media-type handle)))))
4776 (if (window-live-p window)
4777 (select-window window)))))
4780 (gnus-insert-mime-button
4781 handle id (list (mm-handle-displayed-p handle)))
4782 (goto-char point))))
4784 (defun gnus-article-goto-part (n)
4785 "Go to MIME part N."
4786 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4788 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4789 (let ((gnus-tmp-name
4790 (or (mail-content-type-get (mm-handle-type handle) 'name)
4791 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4792 (mail-content-type-get (mm-handle-type handle) 'url)
4794 (gnus-tmp-type (mm-handle-media-type handle))
4795 (gnus-tmp-description
4796 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4799 (if (if displayed (car displayed)
4800 (mm-handle-displayed-p handle))
4802 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4804 gnus-tmp-type-long b e)
4805 (when (string-match ".*/" gnus-tmp-name)
4806 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4807 (setq gnus-tmp-type-long (concat gnus-tmp-type
4808 (and (not (equal gnus-tmp-name ""))
4809 (concat "; " gnus-tmp-name))))
4810 (unless (equal gnus-tmp-description "")
4811 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4816 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4817 `(keymap ,gnus-mime-button-map
4818 gnus-callback gnus-mm-display-part
4819 gnus-part ,gnus-tmp-id
4820 article-type annotation
4823 ;; Exclude a newline.
4826 (widget-convert-button
4829 :action 'gnus-widget-press-button
4830 :button-keymap gnus-mime-button-map
4832 (lambda (widget/window &optional overlay pos)
4833 ;; Needed to properly clear the message due to a bug in
4834 ;; wid-edit (XEmacs only).
4835 (if (boundp 'help-echo-owns-message)
4836 (setq help-echo-owns-message t))
4838 "%S: %s the MIME part; %S: more options"
4839 (aref gnus-mouse-2 0)
4840 ;; XEmacs will get a single widget arg; Emacs 21 will get
4841 ;; window, overlay, position.
4842 (if (mm-handle-displayed-p
4844 (with-current-buffer (gnus-overlay-buffer overlay)
4845 (widget-get (widget-at (gnus-overlay-start overlay))
4847 (widget-get widget/window :mime-handle)))
4849 (aref gnus-down-mouse-3 0))))))
4851 (defun gnus-widget-press-button (elems el)
4852 (goto-char (widget-get elems :from))
4853 (gnus-article-press-button))
4855 (defvar gnus-displaying-mime nil)
4857 (defun gnus-display-mime (&optional ihandles)
4858 "Display the MIME parts."
4860 (save-selected-window
4861 (let ((window (get-buffer-window gnus-article-buffer))
4864 (select-window window)
4865 ;; We have to do this since selecting the window
4866 ;; may change the point. So we set the window point.
4867 (set-window-point window point)))
4868 (let ((handles ihandles)
4869 (inhibit-read-only t)
4872 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
4873 (when gnus-article-emulate-mime
4874 (mm-uu-dissect-text-parts handles)))
4875 (gnus-article-emulate-mime
4876 (setq handles (mm-uu-dissect))))
4877 (when (and (not ihandles)
4878 (not gnus-displaying-mime))
4879 ;; Top-level call; we clean up.
4880 (when gnus-article-mime-handles
4881 (mm-destroy-parts gnus-article-mime-handles)
4882 (setq gnus-article-mime-handle-alist nil));; A trick.
4883 (setq gnus-article-mime-handles handles)
4884 ;; We allow users to glean info from the handles.
4885 (when gnus-article-mime-part-function
4886 (gnus-mime-part-function handles)))
4888 (or (not (stringp (car handles)))
4891 (when (and (not ihandles)
4892 (not gnus-displaying-mime))
4893 ;; Clean up for mime parts.
4895 (delete-region (point) (point-max)))
4896 (let ((gnus-displaying-mime t))
4897 (gnus-mime-display-part handles)))
4900 (narrow-to-region (point) (point-max))
4901 (gnus-treat-article nil 1 1)
4904 ;; Highlight the headers.
4908 (narrow-to-region (point-min) (point))
4909 (gnus-article-save-original-date
4910 (gnus-treat-article 'head)))))))))
4912 (defcustom gnus-mime-display-multipart-as-mixed nil
4913 "Display \"multipart\" parts as \"multipart/mixed\".
4915 If t, it overrides nil values of
4916 `gnus-mime-display-multipart-alternative-as-mixed' and
4917 `gnus-mime-display-multipart-related-as-mixed'."
4918 :group 'gnus-article-mime
4921 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4922 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4924 :group 'gnus-article-mime
4927 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4928 "Display \"multipart/related\" parts as \"multipart/mixed\".
4930 If displaying \"text/html\" is discouraged \(see
4931 `mm-discouraged-alternatives'\) images or other material inside a
4932 \"multipart/related\" part might be overlooked when this variable is nil."
4934 :group 'gnus-article-mime
4937 (defun gnus-mime-display-part (handle)
4939 ;; Maybe a broken MIME message.
4942 ((not (stringp (car handle)))
4943 (gnus-mime-display-single handle))
4944 ;; User-defined multipart
4945 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4946 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4948 ;; multipart/alternative
4949 ((and (equal (car handle) "multipart/alternative")
4950 (not (or gnus-mime-display-multipart-as-mixed
4951 gnus-mime-display-multipart-alternative-as-mixed)))
4952 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4953 (push (cons id handle) gnus-article-mime-handle-alist)
4954 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4955 ;; multipart/related
4956 ((and (equal (car handle) "multipart/related")
4957 (not (or gnus-mime-display-multipart-as-mixed
4958 gnus-mime-display-multipart-related-as-mixed)))
4959 ;;;!!!We should find the start part, but we just default
4960 ;;;!!!to the first part.
4961 ;;(gnus-mime-display-part (cadr handle))
4962 ;;;!!! Most multipart/related is an HTML message plus images.
4963 ;;;!!! Unfortunately we are unable to let W3 display those
4964 ;;;!!! included images, so we just display it as a mixed multipart.
4965 ;;(gnus-mime-display-mixed (cdr handle))
4966 ;;;!!! No, w3 can display everything just fine.
4967 (gnus-mime-display-part (cadr handle)))
4968 ((equal (car handle) "multipart/signed")
4969 (gnus-add-wash-type 'signed)
4970 (gnus-mime-display-security handle))
4971 ((equal (car handle) "multipart/encrypted")
4972 (gnus-add-wash-type 'encrypted)
4973 (gnus-mime-display-security handle))
4974 ;; Other multiparts are handled like multipart/mixed.
4976 (gnus-mime-display-mixed (cdr handle)))))
4978 (defun gnus-mime-part-function (handles)
4979 (if (stringp (car handles))
4980 (mapcar 'gnus-mime-part-function (cdr handles))
4981 (funcall gnus-article-mime-part-function handles)))
4983 (defun gnus-mime-display-mixed (handles)
4984 (mapcar 'gnus-mime-display-part handles))
4986 (defun gnus-mime-display-single (handle)
4987 (let ((type (mm-handle-media-type handle))
4988 (ignored gnus-ignored-mime-types)
4995 (when (string-match (pop ignored) type)
4996 (throw 'ignored nil)))
4997 (if (and (setq not-attachment
4998 (and (not (mm-inline-override-p handle))
4999 (or (not (mm-handle-disposition handle))
5000 (equal (car (mm-handle-disposition handle))
5002 (mm-attachment-override-p handle))))
5003 (mm-automatic-display-p handle)
5005 (mm-inlinable-p handle)
5006 (mm-inlined-p handle))
5007 (mm-automatic-external-display-p type)))
5009 (when (equal (mm-handle-media-supertype handle) "text")
5011 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5013 (push (cons id handle) gnus-article-mime-handle-alist)
5014 (when (or (not display)
5015 (not (gnus-unbuttonized-mime-type-p type)))
5016 (gnus-insert-mime-button
5017 handle id (list (or display (and not-attachment text))))
5018 (gnus-article-insert-newline)
5019 ;; Remember modify the number of forward lines.
5027 (let ((mail-parse-charset gnus-newsgroup-charset)
5028 (mail-parse-ignored-charsets
5029 (save-excursion (condition-case ()
5030 (set-buffer gnus-summary-buffer)
5032 gnus-newsgroup-ignored-charsets)))
5033 (mm-display-part handle t))
5034 (goto-char (point-max)))
5035 ((and text not-attachment)
5039 (gnus-article-insert-newline)
5042 (let ((charset (mail-content-type-get (mm-handle-type handle)
5044 (cond ((not charset)
5045 (mm-string-as-multibyte (mm-get-part handle)))
5046 ((eq charset 'gnus-decoded)
5047 (with-current-buffer (mm-handle-buffer handle)
5050 (mm-decode-string (mm-get-part handle) charset)))))
5051 (goto-char (point-max))))
5055 (narrow-to-region beg (point))
5058 (gnus-article-mime-total-parts)
5059 (mm-handle-media-type handle)))))))))
5061 (defun gnus-unbuttonized-mime-type-p (type)
5062 "Say whether TYPE is to be unbuttonized."
5063 (unless gnus-inhibit-mime-unbuttonizing
5065 (let ((types gnus-unbuttonized-mime-types))
5067 (when (string-match (pop types) type)
5068 (throw 'found t)))))
5070 (let ((types gnus-buttonized-mime-types))
5072 (when (string-match (pop types) type)
5073 (throw 'found t)))))))))
5075 (defun gnus-article-insert-newline ()
5076 "Insert a newline, but mark it as undeletable."
5077 (gnus-put-text-property
5078 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5080 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5081 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5084 handle (inhibit-read-only t) from props begend not-pref)
5085 (save-window-excursion
5088 (narrow-to-region (car ibegend)
5091 (goto-char (car ibegend))
5094 (delete-region (point-min) (point-max))
5095 (mm-remove-parts handles))
5096 (setq begend (list (point-marker)))
5098 (unless (setq not-pref (cadr (member preferred ihandles)))
5099 (setq not-pref (car ihandles)))
5102 (not (gnus-unbuttonized-mime-type-p
5103 "multipart/alternative")))
5104 (gnus-add-text-properties
5107 (insert (format "%d. " id))
5111 (unless ,(not ibegend)
5112 (setq gnus-article-mime-handle-alist
5113 ',gnus-article-mime-handle-alist))
5114 (gnus-mime-display-alternative
5115 ',ihandles ',not-pref ',begend ,id))
5116 keymap ,gnus-mime-button-map
5117 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5118 face ,gnus-article-button-face
5120 article-type multipart))
5121 (widget-convert-button 'link from (point)
5122 :action 'gnus-widget-press-button
5123 :button-keymap gnus-widget-button-keymap)
5125 (while (setq handle (pop handles))
5126 (gnus-add-text-properties
5129 (insert (format "(%c) %-18s"
5130 (if (equal handle preferred) ?* ? )
5131 (mm-handle-media-type handle)))
5135 (unless ,(not ibegend)
5136 (setq gnus-article-mime-handle-alist
5137 ',gnus-article-mime-handle-alist))
5138 (gnus-mime-display-alternative
5139 ',ihandles ',handle ',begend ,id))
5140 keymap ,gnus-mime-button-map
5141 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5142 face ,gnus-article-button-face
5145 (widget-convert-button 'link from (point)
5146 :action 'gnus-widget-press-button
5147 :button-keymap gnus-widget-button-keymap)
5151 (if (stringp (car preferred))
5152 (gnus-display-mime preferred)
5153 (let ((mail-parse-charset gnus-newsgroup-charset)
5154 (mail-parse-ignored-charsets
5155 (with-current-buffer gnus-summary-buffer
5156 gnus-newsgroup-ignored-charsets)))
5157 (mm-display-part preferred)
5161 (narrow-to-region (car begend) (point-max))
5163 nil (length gnus-article-mime-handle-alist)
5164 (gnus-article-mime-total-parts)
5165 (mm-handle-media-type handle))))))
5166 (goto-char (point-max))
5167 (setcdr begend (point-marker)))))
5169 (goto-char point))))
5171 (defconst gnus-article-wash-status-strings
5172 (let ((alist '((cite "c" "Possible hidden citation text"
5173 " " "All citation text visible")
5174 (headers "h" "Hidden headers"
5175 " " "All headers visible.")
5176 (pgp "p" "Encrypted or signed message status hidden"
5177 " " "No hidden encryption nor digital signature status")
5178 (signature "s" "Signature has been hidden"
5179 " " "Signature is visible")
5180 (overstrike "o" "Overstrike (^H) characters applied"
5181 " " "No overstrike characters applied")
5182 (emphasis "e" "/*_Emphasis_*/ characters applied"
5183 " " "No /*_emphasis_*/ characters applied")))
5185 (dolist (entry alist result)
5186 (let ((key (nth 0 entry))
5187 (on (copy-sequence (nth 1 entry)))
5188 (on-help (nth 2 entry))
5189 (off (copy-sequence (nth 3 entry)))
5190 (off-help (nth 4 entry)))
5191 (put-text-property 0 1 'help-echo on-help on)
5192 (put-text-property 0 1 'help-echo off-help off)
5193 (push (list key on off) result))))
5194 "Alist of strings describing wash status in the mode line.
5195 Each entry has the form (KEY ON OF), where the KEY is a symbol
5196 representing the particular washing function, ON is the string to use
5197 in the article mode line when the washing function is active, and OFF
5198 is the string to use when it is inactive.")
5200 (defun gnus-article-wash-status-entry (key value)
5201 (let ((entry (assoc key gnus-article-wash-status-strings)))
5202 (if value (nth 1 entry) (nth 2 entry))))
5204 (defun gnus-article-wash-status ()
5205 "Return a string which display status of article washing."
5206 (with-current-buffer gnus-article-buffer
5207 (let ((cite (memq 'cite gnus-article-wash-types))
5208 (headers (memq 'headers gnus-article-wash-types))
5209 (boring (memq 'boring-headers gnus-article-wash-types))
5210 (pgp (memq 'pgp gnus-article-wash-types))
5211 (pem (memq 'pem gnus-article-wash-types))
5212 (signed (memq 'signed gnus-article-wash-types))
5213 (encrypted (memq 'encrypted gnus-article-wash-types))
5214 (signature (memq 'signature gnus-article-wash-types))
5215 (overstrike (memq 'overstrike gnus-article-wash-types))
5216 (emphasis (memq 'emphasis gnus-article-wash-types)))
5218 (gnus-article-wash-status-entry 'cite cite)
5219 (gnus-article-wash-status-entry 'headers (or headers boring))
5220 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5221 (gnus-article-wash-status-entry 'signature signature)
5222 (gnus-article-wash-status-entry 'overstrike overstrike)
5223 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5225 (defun gnus-add-wash-type (type)
5226 "Add a washing of TYPE to the current status."
5227 (add-to-list 'gnus-article-wash-types type))
5229 (defun gnus-delete-wash-type (type)
5230 "Add a washing of TYPE to the current status."
5231 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5233 (defun gnus-add-image (category image)
5234 "Add IMAGE of CATEGORY to the list of displayed images."
5235 (let ((entry (assq category gnus-article-image-alist)))
5237 (setq entry (list category))
5238 (push entry gnus-article-image-alist))
5239 (nconc entry (list image))))
5241 (defun gnus-delete-images (category)
5242 "Delete all images in CATEGORY."
5243 (let ((entry (assq category gnus-article-image-alist)))
5244 (dolist (image (cdr entry))
5245 (gnus-remove-image image category))
5246 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5247 (gnus-delete-wash-type category)))
5249 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5251 (defun gnus-article-maybe-hide-headers ()
5252 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5253 Provided for backwards compatibility."
5254 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5255 (not (with-current-buffer gnus-summary-buffer
5256 gnus-have-all-headers)))
5257 (not gnus-inhibit-hiding))
5258 (gnus-article-hide-headers)))
5262 (defun gnus-output-to-file (file-name)
5263 "Append the current article to a file named FILE-NAME."
5264 (let ((artbuf (current-buffer)))
5266 (insert-buffer-substring artbuf)
5267 ;; Append newline at end of the buffer as separator, and then
5269 (goto-char (point-max))
5271 (let ((file-name-coding-system nnmail-pathname-coding-system))
5272 (mm-append-to-file (point-min) (point-max) file-name))
5275 (defun gnus-narrow-to-page (&optional arg)
5276 "Narrow the article buffer to a page.
5277 If given a numerical ARG, move forward ARG pages."
5279 (setq arg (if arg (prefix-numeric-value arg) 0))
5281 (set-buffer gnus-article-buffer)
5282 (goto-char (point-min))
5284 ;; Remove any old next/prev buttons.
5285 (when (gnus-visual-p 'page-marker)
5286 (let ((inhibit-read-only t))
5287 (gnus-remove-text-with-property 'gnus-prev)
5288 (gnus-remove-text-with-property 'gnus-next)))
5291 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5293 (re-search-forward page-delimiter nil 'move arg)))
5294 (goto-char (match-end 0))
5296 (goto-char (point-min))
5297 (setq gnus-page-broken
5298 (and (re-search-forward page-delimiter nil t) t))))
5299 (when gnus-page-broken
5302 (if (re-search-forward page-delimiter nil 'move)
5305 (when (and (gnus-visual-p 'page-marker)
5306 (> (point-min) (save-restriction (widen) (point-min))))
5308 (goto-char (point-min))
5309 (gnus-insert-prev-page-button)))
5310 (when (and (gnus-visual-p 'page-marker)
5311 (< (point-max) (save-restriction (widen) (point-max))))
5313 (goto-char (point-max))
5314 (gnus-insert-next-page-button))))))
5316 ;; Article mode commands
5318 (defun gnus-article-goto-next-page ()
5319 "Show the next page of the article."
5321 (when (gnus-article-next-page)
5322 (goto-char (point-min))
5323 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5326 (defun gnus-article-goto-prev-page ()
5327 "Show the previous page of the article."
5330 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5331 (gnus-article-prev-page nil)))
5333 ;; This is cleaner but currently breaks `gnus-pick-mode':
5335 ;; (defun gnus-article-goto-next-page ()
5336 ;; "Show the next page of the article."
5338 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5339 ;; (gnus-summary-next-page)))
5341 ;; (defun gnus-article-goto-prev-page ()
5342 ;; "Show the next page of the article."
5344 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5345 ;; (gnus-summary-prev-page)))
5347 (defun gnus-article-next-page (&optional lines)
5348 "Show the next page of the current article.
5349 If end of article, return non-nil. Otherwise return nil.
5350 Argument LINES specifies lines to be scrolled up."
5352 (move-to-window-line -1)
5355 (and (pos-visible-in-window-p) ;Not continuation line.
5356 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5357 ;; Nothing in this page.
5358 (if (or (not gnus-page-broken)
5363 (eobp)))) ;Real end-of-buffer?
5365 (when gnus-article-over-scroll
5366 (gnus-article-next-page-1 lines))
5368 (gnus-narrow-to-page 1) ;Go to next page.
5370 ;; More in this page.
5371 (gnus-article-next-page-1 lines)
5374 (defmacro gnus-article-beginning-of-window ()
5375 "Move point to the beginning of the window.
5376 In Emacs, the point is placed at the line number which `scroll-margin'
5378 (if (featurep 'xemacs)
5379 '(move-to-window-line 0)
5380 '(move-to-window-line
5381 (min (max 0 scroll-margin)
5382 (max 1 (- (window-height)
5383 (if mode-line-format 1 0)
5384 (if header-line-format 1 0)))))))
5386 (defun gnus-article-next-page-1 (lines)
5387 (when (and (not (featurep 'xemacs))
5390 (numberp (symbol-value 'scroll-margin))
5391 (> (symbol-value 'scroll-margin) 0))
5392 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5393 ;; too many number of lines if `scroll-margin' is set as two or greater.
5394 (setq lines (min lines
5395 (max 0 (- (count-lines (window-start) (point-max))
5396 (symbol-value 'scroll-margin))))))
5398 (let ((scroll-in-place nil))
5401 ;; Long lines may cause an end-of-buffer error.
5402 (goto-char (point-max))))
5403 (gnus-article-beginning-of-window))
5405 (defun gnus-article-prev-page (&optional lines)
5406 "Show previous page of current article.
5407 Argument LINES specifies lines to be scrolled down."
5409 (move-to-window-line 0)
5410 (if (and gnus-page-broken
5412 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5414 (gnus-narrow-to-page -1) ;Go to previous page.
5415 (goto-char (point-max))
5419 (let ((scroll-in-place nil))
5420 (scroll-down lines))
5421 (beginning-of-buffer
5422 (goto-char (point-min))))
5423 (gnus-article-beginning-of-window))))
5425 (defun gnus-article-only-boring-p ()
5426 "Decide whether there is only boring text remaining in the article.
5427 Something \"interesting\" is a word of at least two letters that does
5428 not have a face in `gnus-article-boring-faces'."
5429 (when (and gnus-article-skip-boring
5430 (boundp 'gnus-article-boring-faces)
5431 (symbol-value 'gnus-article-boring-faces))
5434 (while (re-search-forward "\\b\\w\\w" nil t)
5436 (when (not (gnus-intersection
5437 (gnus-faces-at (point))
5438 (symbol-value 'gnus-article-boring-faces)))
5439 (throw 'only-boring nil)))
5440 (throw 'only-boring t)))))
5442 (defun gnus-article-refer-article ()
5443 "Read article specified by message-id around point."
5446 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5447 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5448 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5449 (let ((msg-id (concat "<" (match-string 0) ">")))
5450 (set-buffer gnus-summary-buffer)
5451 (gnus-summary-refer-article msg-id))
5452 (error "No references around point"))))
5454 (defun gnus-article-show-summary ()
5455 "Reconfigure windows to show summary buffer."
5457 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5458 (error "There is no summary buffer for this article buffer")
5459 (gnus-article-set-globals)
5460 (gnus-configure-windows 'article)
5461 (gnus-summary-goto-subject gnus-current-article)
5462 (gnus-summary-position-point)))
5464 (defun gnus-article-describe-briefly ()
5465 "Describe article mode commands briefly."
5467 (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")))
5469 (defun gnus-article-summary-command ()
5470 "Execute the last keystroke in the summary buffer."
5472 (let ((obuf (current-buffer))
5473 (owin (current-window-configuration))
5475 (switch-to-buffer gnus-article-current-summary 'norecord)
5476 (setq func (lookup-key (current-local-map) (this-command-keys)))
5477 (call-interactively func)
5479 (set-window-configuration owin)
5480 (set-window-point (get-buffer-window (current-buffer)) (point))))
5482 (defun gnus-article-summary-command-nosave ()
5483 "Execute the last keystroke in the summary buffer."
5486 (pop-to-buffer gnus-article-current-summary 'norecord)
5487 (setq func (lookup-key (current-local-map) (this-command-keys)))
5488 (call-interactively func)))
5490 (defun gnus-article-check-buffer ()
5491 "Beep if not in an article buffer."
5492 (unless (equal major-mode 'gnus-article-mode)
5493 (error "Command invoked outside of a Gnus article buffer")))
5495 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5496 "Read a summary buffer key sequence and execute it from the article buffer."
5498 (gnus-article-check-buffer)
5500 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5501 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5502 "=" "^" "\M-^" "|"))
5508 '("n" "Gn" "p" "Gp"))
5511 (set-buffer gnus-article-current-summary)
5512 (let (gnus-pick-mode)
5513 (push (or key last-command-event) unread-command-events)
5514 (setq keys (if (featurep 'xemacs)
5515 (events-to-keys (read-key-sequence nil))
5516 (read-key-sequence nil)))))
5520 (if (or (member keys nosaves)
5521 (member keys nosave-but-article)
5522 (member keys nosave-in-article))
5524 (save-window-excursion
5525 (pop-to-buffer gnus-article-current-summary 'norecord)
5526 ;; We disable the pick minor mode commands.
5527 (let (gnus-pick-mode)
5528 (setq func (lookup-key (current-local-map) keys))))
5532 (unless (member keys nosave-in-article)
5533 (set-buffer gnus-article-current-summary))
5534 (call-interactively func)
5535 (setq new-sum-point (point)))
5536 (when (member keys nosave-but-article)
5537 (pop-to-buffer gnus-article-buffer 'norecord)))
5538 ;; These commands should restore window configuration.
5539 (let ((obuf (current-buffer))
5540 (owin (current-window-configuration))
5542 win func in-buffer selected new-sum-start new-sum-hscroll)
5543 (cond (not-restore-window
5544 (pop-to-buffer gnus-article-current-summary 'norecord))
5545 ((setq win (get-buffer-window gnus-article-current-summary))
5546 (select-window win))
5548 (switch-to-buffer gnus-article-current-summary 'norecord)))
5549 (setq in-buffer (current-buffer))
5550 ;; We disable the pick minor mode commands.
5551 (if (and (setq func (let (gnus-pick-mode)
5552 (lookup-key (current-local-map) keys)))
5555 (call-interactively func)
5556 (when (eq win (selected-window))
5557 (setq new-sum-point (point)
5558 new-sum-start (window-start win)
5559 new-sum-hscroll (window-hscroll win)))
5560 (when (eq in-buffer (current-buffer))
5561 (setq selected (gnus-summary-select-article))
5563 (unless not-restore-window
5564 (set-window-configuration owin))
5565 (when (eq selected 'old)
5567 (set-window-start (get-buffer-window (current-buffer))
5569 (set-window-point (get-buffer-window (current-buffer))
5571 (when (and (not not-restore-window)
5573 (set-window-point win new-sum-point)
5574 (set-window-start win new-sum-start)
5575 (set-window-hscroll win new-sum-hscroll))))
5576 (set-window-configuration owin)
5579 (defun gnus-article-describe-key (key)
5580 "Display documentation of the function invoked by KEY. KEY is a string."
5581 (interactive "kDescribe key: ")
5582 (gnus-article-check-buffer)
5583 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5585 (set-buffer gnus-article-current-summary)
5586 (let (gnus-pick-mode)
5587 (if (featurep 'xemacs)
5589 (push (elt key 0) unread-command-events)
5590 (setq key (events-to-keys
5591 (read-key-sequence "Describe key: "))))
5592 (setq unread-command-events
5594 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5595 (string-to-list key)))
5596 (setq key (read-key-sequence "Describe key: "))))
5598 (describe-key key)))
5600 (defun gnus-article-describe-key-briefly (key &optional insert)
5601 "Display documentation of the function invoked by KEY. KEY is a string."
5602 (interactive "kDescribe key: \nP")
5603 (gnus-article-check-buffer)
5604 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5606 (set-buffer gnus-article-current-summary)
5607 (let (gnus-pick-mode)
5608 (if (featurep 'xemacs)
5610 (push (elt key 0) unread-command-events)
5611 (setq key (events-to-keys
5612 (read-key-sequence "Describe key: "))))
5613 (setq unread-command-events
5615 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5616 (string-to-list key)))
5617 (setq key (read-key-sequence "Describe key: "))))
5618 (describe-key-briefly key insert))
5619 (describe-key-briefly key insert)))
5621 (defun gnus-article-reply-with-original (&optional wide)
5622 "Start composing a reply mail to the current message.
5623 The text in the region will be yanked. If the region isn't active,
5624 the entire article will be yanked."
5626 (let ((article (cdr gnus-article-current))
5628 (if (not (gnus-region-active-p))
5629 (with-current-buffer gnus-summary-buffer
5630 (gnus-summary-reply (list (list article)) wide))
5631 (setq contents (buffer-substring (point) (mark t)))
5632 ;; Deactivate active regions.
5633 (when (and (boundp 'transient-mark-mode)
5634 transient-mark-mode)
5635 (setq mark-active nil))
5636 (with-current-buffer gnus-summary-buffer
5638 (list (list article contents)) wide)))))
5640 (defun gnus-article-followup-with-original ()
5641 "Compose a followup to the current article.
5642 The text in the region will be yanked. If the region isn't active,
5643 the entire article will be yanked."
5645 (let ((article (cdr gnus-article-current))
5647 (if (not (gnus-region-active-p))
5648 (with-current-buffer gnus-summary-buffer
5649 (gnus-summary-followup (list (list article))))
5650 (setq contents (buffer-substring (point) (mark t)))
5651 ;; Deactivate active regions.
5652 (when (and (boundp 'transient-mark-mode)
5653 transient-mark-mode)
5654 (setq mark-active nil))
5655 (with-current-buffer gnus-summary-buffer
5656 (gnus-summary-followup
5657 (list (list article contents)))))))
5659 (defun gnus-article-hide (&optional arg force)
5660 "Hide all the gruft in the current article.
5661 This means that signatures, cited text and (some) headers will be
5663 If given a prefix, show the hidden text instead."
5664 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5665 (gnus-article-hide-headers arg)
5666 (gnus-article-hide-list-identifiers arg)
5667 (gnus-article-hide-citation-maybe arg force)
5668 (gnus-article-hide-signature arg))
5670 (defun gnus-article-maybe-highlight ()
5671 "Do some article highlighting if article highlighting is requested."
5672 (when (gnus-visual-p 'article-highlight 'highlight)
5673 (gnus-article-highlight-some)))
5675 (defun gnus-check-group-server ()
5676 ;; Make sure the connection to the server is alive.
5677 (unless (gnus-server-opened
5678 (gnus-find-method-for-group gnus-newsgroup-name))
5679 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5680 (gnus-request-group gnus-newsgroup-name t)))
5683 (autoload 'nneething-get-file-name "nneething"))
5685 (defun gnus-request-article-this-buffer (article group)
5686 "Get an article and insert it into this buffer."
5687 (let (do-update-line sparse-header)
5691 (gnus-kill-all-overlays)
5692 (setq group (or group gnus-newsgroup-name))
5694 ;; Using `gnus-request-article' directly will insert the article into
5695 ;; `nntp-server-buffer' - so we'll save some time by not having to
5696 ;; copy it from the server buffer into the article buffer.
5698 ;; We only request an article by message-id when we do not have the
5699 ;; headers for it, so we'll have to get those.
5700 (when (stringp article)
5701 (gnus-read-header article))
5703 ;; If the article number is negative, that means that this article
5704 ;; doesn't belong in this newsgroup (possibly), so we find its
5705 ;; message-id and request it by id instead of number.
5706 (when (and (numberp article)
5708 (get-buffer gnus-summary-buffer)
5709 (gnus-buffer-exists-p gnus-summary-buffer))
5711 (set-buffer gnus-summary-buffer)
5712 (let ((header (gnus-summary-article-header article)))
5715 ((memq article gnus-newsgroup-sparse)
5716 ;; This is a sparse gap article.
5717 (setq do-update-line article)
5718 (setq article (mail-header-id header))
5719 (setq sparse-header (gnus-read-header article))
5720 (setq gnus-newsgroup-sparse
5721 (delq article gnus-newsgroup-sparse)))
5723 ;; It's a real article.
5724 (setq article (mail-header-id header)))
5726 ;; It is an extracted pseudo-article.
5727 (setq article 'pseudo)
5728 (gnus-request-pseudo-article header))))
5730 (let ((method (gnus-find-method-for-group
5731 gnus-newsgroup-name)))
5732 (when (and (eq (car method) 'nneething)
5734 (let ((dir (nneething-get-file-name
5735 (mail-header-id header))))
5736 (when (and (stringp dir)
5737 (file-directory-p dir))
5738 (setq article 'nneething)
5739 (gnus-group-enter-directory dir))))))))
5742 ;; Refuse to select canceled articles.
5743 ((and (numberp article)
5745 (get-buffer gnus-summary-buffer)
5746 (gnus-buffer-exists-p gnus-summary-buffer)
5747 (eq (cdr (with-current-buffer gnus-summary-buffer
5748 (assq article gnus-newsgroup-reads)))
5749 gnus-canceled-mark))
5751 ;; We first check `gnus-original-article-buffer'.
5752 ((and (get-buffer gnus-original-article-buffer)
5754 (with-current-buffer gnus-original-article-buffer
5755 (and (equal (car gnus-original-article) group)
5756 (eq (cdr gnus-original-article) article))))
5757 (insert-buffer-substring gnus-original-article-buffer)
5759 ;; Check the backlog.
5760 ((and gnus-keep-backlog
5761 (gnus-backlog-request-article group article (current-buffer)))
5763 ;; Check asynchronous pre-fetch.
5764 ((gnus-async-request-fetched-article group article (current-buffer))
5765 (gnus-async-prefetch-next group article gnus-summary-buffer)
5766 (when (and (numberp article) gnus-keep-backlog)
5767 (gnus-backlog-enter-article group article (current-buffer)))
5770 ((and gnus-use-cache
5772 (gnus-cache-request-article article group))
5774 ;; Check the agent cache.
5775 ((gnus-agent-request-article article group)
5777 ;; Get the article and put into the article buffer.
5778 ((or (stringp article)
5780 (let ((gnus-override-method gnus-override-method)
5781 (methods (and (stringp article)
5782 gnus-refer-article-method))
5783 (backend (car (gnus-find-method-for-group
5784 gnus-newsgroup-name)))
5786 (inhibit-read-only t))
5787 (if (or (not (listp methods))
5788 (and (symbolp (car methods))
5789 (assq (car methods) nnoo-definition-alist)))
5790 (setq methods (list methods)))
5791 (when (and (null gnus-override-method)
5793 (setq gnus-override-method (pop methods)))
5795 (when (eq gnus-override-method 'current)
5796 (setq gnus-override-method
5797 (with-current-buffer gnus-summary-buffer
5798 gnus-current-select-method)))
5800 (gnus-kill-all-overlays)
5801 (let ((gnus-newsgroup-name group))
5802 (gnus-check-group-server))
5804 ((gnus-request-article article group (current-buffer))
5805 (when (numberp article)
5806 (gnus-async-prefetch-next group article
5807 gnus-summary-buffer)
5808 (when gnus-keep-backlog
5809 (gnus-backlog-enter-article
5810 group article (current-buffer))))
5811 (setq result 'article))
5813 (setq gnus-override-method (pop methods)))
5814 ((not (string-match "^400 "
5815 (nnheader-get-report backend)))
5816 ;; If we get 400 server disconnect, reconnect and
5817 ;; retry; otherwise, assume the article has expired.
5818 (setq result 'done))))
5819 (and (eq result 'article) 'article)))
5823 ;; Associate this article with the current summary buffer.
5824 (setq gnus-article-current-summary gnus-summary-buffer)
5826 ;; Take the article from the original article buffer
5827 ;; and place it in the buffer it's supposed to be in.
5828 (when (and (get-buffer gnus-article-buffer)
5829 (equal (buffer-name (current-buffer))
5830 (buffer-name (get-buffer gnus-article-buffer))))
5832 (if (get-buffer gnus-original-article-buffer)
5833 (set-buffer gnus-original-article-buffer)
5834 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5835 (buffer-disable-undo)
5836 (setq major-mode 'gnus-original-article-mode)
5837 (setq buffer-read-only t))
5838 (let ((inhibit-read-only t))
5840 (insert-buffer-substring gnus-article-buffer))
5841 (setq gnus-original-article (cons group article)))
5844 (run-hooks 'gnus-article-decode-hook)
5845 ;; Mark article as decoded or not.
5846 (setq gnus-article-decoded-p gnus-article-decode-hook))
5848 ;; Update sparse articles.
5849 (when (and do-update-line
5850 (or (numberp article)
5852 (let ((buf (current-buffer)))
5853 (set-buffer gnus-summary-buffer)
5854 (gnus-summary-update-article do-update-line sparse-header)
5855 (gnus-summary-goto-subject do-update-line nil t)
5856 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5858 (set-buffer buf))))))
5864 (defcustom gnus-article-edit-mode-hook nil
5865 "Hook run in article edit mode buffers."
5866 :group 'gnus-article-various
5869 (defvar gnus-article-edit-done-function nil)
5871 (defvar gnus-article-edit-mode-map nil)
5873 ;; Should we be using derived.el for this?
5874 (unless gnus-article-edit-mode-map
5875 (setq gnus-article-edit-mode-map (make-keymap))
5876 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5878 (gnus-define-keys gnus-article-edit-mode-map
5879 "\C-c?" describe-mode
5880 "\C-c\C-c" gnus-article-edit-done
5881 "\C-c\C-k" gnus-article-edit-exit
5882 "\C-c\C-f\C-t" message-goto-to
5883 "\C-c\C-f\C-o" message-goto-from
5884 "\C-c\C-f\C-b" message-goto-bcc
5885 ;;"\C-c\C-f\C-w" message-goto-fcc
5886 "\C-c\C-f\C-c" message-goto-cc
5887 "\C-c\C-f\C-s" message-goto-subject
5888 "\C-c\C-f\C-r" message-goto-reply-to
5889 "\C-c\C-f\C-n" message-goto-newsgroups
5890 "\C-c\C-f\C-d" message-goto-distribution
5891 "\C-c\C-f\C-f" message-goto-followup-to
5892 "\C-c\C-f\C-m" message-goto-mail-followup-to
5893 "\C-c\C-f\C-k" message-goto-keywords
5894 "\C-c\C-f\C-u" message-goto-summary
5895 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5896 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5897 "\C-c\C-b" message-goto-body
5898 "\C-c\C-i" message-goto-signature
5900 "\C-c\C-t" message-insert-to
5901 "\C-c\C-n" message-insert-newsgroups
5902 "\C-c\C-o" message-sort-headers
5903 "\C-c\C-e" message-elide-region
5904 "\C-c\C-v" message-delete-not-region
5905 "\C-c\C-z" message-kill-to-signature
5906 "\M-\r" message-newline-and-reformat
5907 "\C-c\C-a" mml-attach-file
5908 "\C-a" message-beginning-of-line
5910 "\M-;" comment-region)
5912 (gnus-define-keys (gnus-article-edit-wash-map
5913 "\C-c\C-w" gnus-article-edit-mode-map)
5914 "f" gnus-article-edit-full-stops))
5917 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5919 ["Fetch To" message-insert-to t]
5920 ["Fetch Newsgroups" message-insert-newsgroups t]
5922 ["To" message-goto-to t]
5923 ["From" message-goto-from t]
5924 ["Subject" message-goto-subject t]
5925 ["Cc" message-goto-cc t]
5926 ["Reply-To" message-goto-reply-to t]
5927 ["Summary" message-goto-summary t]
5928 ["Keywords" message-goto-keywords t]
5929 ["Newsgroups" message-goto-newsgroups t]
5930 ["Followup-To" message-goto-followup-to t]
5931 ["Mail-Followup-To" message-goto-mail-followup-to t]
5932 ["Distribution" message-goto-distribution t]
5933 ["Body" message-goto-body t]
5934 ["Signature" message-goto-signature t]))
5936 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5937 "Major mode for editing articles.
5938 This is an extended text-mode.
5940 \\{gnus-article-edit-mode-map}"
5941 (make-local-variable 'gnus-article-edit-done-function)
5942 (make-local-variable 'gnus-prev-winconf)
5943 (set (make-local-variable 'font-lock-defaults)
5944 '(message-font-lock-keywords t))
5945 (set (make-local-variable 'mail-header-separator) "")
5946 (set (make-local-variable 'gnus-article-edit-mode) t)
5947 (easy-menu-add message-mode-field-menu message-mode-map)
5949 (setq buffer-read-only nil)
5950 (buffer-enable-undo)
5953 (defun gnus-article-edit (&optional force)
5954 "Edit the current article.
5955 This will have permanent effect only in mail groups.
5956 If FORCE is non-nil, allow editing of articles even in read-only
5959 (when (and (not force)
5960 (gnus-group-read-only-p))
5961 (error "The current newsgroup does not support article editing"))
5962 (gnus-article-date-original)
5963 (gnus-article-edit-article
5965 `(lambda (no-highlight)
5967 (gnus-summary-edit-article-done
5968 ,(or (mail-header-references gnus-current-headers) "")
5969 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5971 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
5972 "Start editing the contents of the current article buffer."
5973 (let ((winconf (current-window-configuration)))
5974 (set-buffer gnus-article-buffer)
5975 (let ((message-auto-save-directory
5976 ;; Don't associate the article buffer with a draft file.
5978 (gnus-article-edit-mode))
5979 (funcall start-func)
5980 (set-buffer-modified-p nil)
5981 (gnus-configure-windows 'edit-article)
5982 (setq gnus-article-edit-done-function exit-func)
5983 (setq gnus-prev-winconf winconf)
5985 (gnus-message 6 "C-c C-c to end edits"))))
5987 (defun gnus-article-edit-done (&optional arg)
5988 "Update the article edits and exit."
5990 (let ((func gnus-article-edit-done-function)
5991 (buf (current-buffer))
5992 (start (window-start))
5994 (winconf gnus-prev-winconf))
5995 (widen) ;; Widen it in case that users narrowed the buffer.
5998 ;; The cache and backlog have to be flushed somewhat.
5999 (when gnus-keep-backlog
6000 (gnus-backlog-remove-article
6001 (car gnus-article-current) (cdr gnus-article-current)))
6002 ;; Flush original article as well.
6004 (when (get-buffer gnus-original-article-buffer)
6005 (set-buffer gnus-original-article-buffer)
6006 (setq gnus-original-article nil)))
6007 (when gnus-use-cache
6008 (gnus-cache-update-article
6009 (car gnus-article-current) (cdr gnus-article-current)))
6010 ;; We remove all text props from the article buffer.
6011 (kill-all-local-variables)
6012 (set-text-properties (point-min) (point-max) nil)
6014 (set-window-configuration winconf)
6016 (set-window-start (get-buffer-window buf) start)
6017 (set-window-point (get-buffer-window buf) (point)))
6018 (gnus-summary-show-article))
6020 (defun gnus-article-edit-exit ()
6021 "Exit the article editing without updating."
6023 (when (or (not (buffer-modified-p))
6024 (yes-or-no-p "Article modified; kill anyway? "))
6025 (let ((curbuf (current-buffer))
6027 (window-start (window-start)))
6029 (if (gnus-buffer-live-p gnus-original-article-buffer)
6030 (insert-buffer-substring gnus-original-article-buffer))
6031 (let ((winconf gnus-prev-winconf))
6032 (kill-all-local-variables)
6034 (set-window-configuration winconf)
6035 ;; Tippy-toe some to make sure that point remains where it was.
6036 (save-current-buffer
6038 (set-window-start (get-buffer-window (current-buffer)) window-start)
6040 (gnus-summary-show-article)))
6042 (defun gnus-article-edit-full-stops ()
6043 "Interactively repair spacing at end of sentences."
6046 (goto-char (point-min))
6047 (search-forward-regexp "^$" nil t)
6048 (let ((case-fold-search nil))
6049 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6052 ;;; Article highlights
6055 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6057 ;;; Internal Variables:
6059 (defcustom gnus-button-url-regexp
6060 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6061 "\\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:]]\\)"
6062 "\\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\\)\\)")
6063 "Regular expression that matches URLs."
6064 :group 'gnus-article-buttons
6067 (defcustom gnus-button-valid-fqdn-regexp
6068 message-valid-fqdn-regexp
6069 "Regular expression that matches a valid FQDN."
6071 :group 'gnus-article-buttons
6074 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6075 (defcustom gnus-button-valid-localpart-regexp
6076 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*"
6077 "Regular expression that matches a localpart of mail addresses or MIDs."
6079 :group 'gnus-article-buttons
6082 (defcustom gnus-button-man-handler 'manual-entry
6083 "Function to use for displaying man pages.
6084 The function must take at least one argument with a string naming the
6087 :type '(choice (function-item :tag "Man" manual-entry)
6088 (function-item :tag "Woman" woman)
6089 (function :tag "Other"))
6090 :group 'gnus-article-buttons)
6092 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6093 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6094 If the default site is too slow, try to find a CTAN mirror, see
6095 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6096 the variable `gnus-button-handle-ctan'."
6098 :group 'gnus-article-buttons
6099 :link '(custom-manual "(gnus)Group Parameters")
6100 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6101 (const "http://tug.ctan.org/tex-archive/")
6102 (const "http://www.dante.de/CTAN/")
6103 (string :tag "Other")))
6105 (defcustom gnus-button-ctan-handler 'browse-url
6106 "Function to use for displaying CTAN links.
6107 The function must take one argument, the string naming the URL."
6109 :type '(choice (function-item :tag "Browse Url" browse-url)
6110 (function :tag "Other"))
6111 :group 'gnus-article-buttons)
6113 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6114 "Bogus strings removed from CTAN URLs."
6116 :group 'gnus-article-buttons
6117 :type '(choice (const "^/?tex-archive/\\|/")
6118 (regexp :tag "Other")))
6120 (defcustom gnus-button-ctan-directory-regexp
6122 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
6123 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
6124 "languages" "macros" "nonfree" "obsolete" "support" "systems"
6125 "tds" "tools" "usergrps" "web") t)
6126 "Regular expression for ctan directories.
6127 It should match all directories in the top level of `gnus-ctan-url'."
6129 :group 'gnus-article-buttons
6132 (defcustom gnus-button-mid-or-mail-regexp
6133 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
6134 gnus-button-valid-fqdn-regexp
6136 "Regular expression that matches a message ID or a mail address."
6138 :group 'gnus-article-buttons
6141 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6142 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6143 Strings like this can be either a message ID or a mail address. If it is one
6144 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6145 message ID or a mail address, respectively. If this variable is set to the
6146 symbol `ask', always query the user what do do. If it is a function, this
6147 function will be called with the string as it's only argument. The function
6148 must return `mid', `mail', `invalid' or `ask'."
6150 :group 'gnus-article-buttons
6151 :type '(choice (function-item :tag "Heuristic function"
6152 gnus-button-mid-or-mail-heuristic)
6157 (defcustom gnus-button-mid-or-mail-heuristic-alist
6158 '((-10.0 . ".+\\$.+@")
6161 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6162 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6163 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6164 (-1.0 . "^[^a-z]+@")
6166 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6167 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6168 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6169 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6172 (-1.0 . "^[0-9][0-9]")
6174 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6175 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6176 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6177 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6179 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6180 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6183 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6185 ;; compensation for TDMA dated mail addresses:
6186 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6188 (-20.0 . "\\.fsf@") ;; Gnus
6191 (-20.0 . "_-_") ;; Subject change in thread
6193 (-20.0 . "\\.ln@") ;; leafnode
6194 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6195 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6197 ;; (5.0 . "") ;; $local_part_len <= 7
6198 (10.0 . "^[^0-9]+@")
6199 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6200 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6203 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6205 (0.5 . "^[A-Z][a-z]")
6206 (0.5 . "^[A-Z][a-z][a-z]")
6207 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6208 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6209 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6211 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6212 address. The REGEXP is processed with `case-fold-search' set to nil."
6214 :group 'gnus-article-buttons
6215 :type '(repeat (cons (number :tag "Rate")
6216 (regexp :tag "Regexp"))))
6218 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6219 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6220 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6221 address, `ask' if unsure and `invalid' if the string is invalid."
6222 (let ((case-fold-search nil)
6223 (list gnus-button-mid-or-mail-heuristic-alist)
6224 (result 0) rate regexp lpartlen elem)
6226 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6227 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6228 ;; Certain special cases...
6231 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6232 "^[0-9]+\\.[0-9]+@compuserve\\|"
6233 "@public\\.gmane\\.org")
6235 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6236 (setq result 'mail))
6237 (when (string-match "@.*@\\| " mid-or-mail)
6238 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6239 (setq result 'invalid))
6240 ;; Nothing more to do, if result is not a number here...
6241 (when (numberp result)
6243 (setq elem (car list)
6247 (when (string-match regexp mid-or-mail)
6248 (setq result (+ result rate))
6250 9 "`%s' matched `%s', rate `%s', result `%s'."
6251 mid-or-mail regexp rate result)))
6252 (when (<= lpartlen 7)
6253 (setq result (+ result 5.0))
6254 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6255 mid-or-mail result))
6256 (when (>= lpartlen 12)
6257 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6259 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6260 ;; Long local part should contain realname if e-mail address,
6261 ;; too many digits: message-id.
6262 ;; $score -= 5.0 + 0.1 * $local_part_len;
6263 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6264 (setq result (+ result rate))
6266 9 "Many digits in `%s', rate `%s', result `%s'."
6267 mid-or-mail rate result))
6268 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6270 ;; Too few vowels [^aeiouy]{4,}.*\@
6271 (setq result (+ result -5.0))
6273 9 "Few vowels in `%s', rate `%s', result `%s'."
6274 mid-or-mail -5.0 result))
6276 (setq result (+ result 5.0))
6278 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6279 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6280 ;; Maybe we should make this a customizable alist: (condition . 'result)
6282 ((symbolp result) result)
6283 ;; Now convert number into proper results:
6284 ((< result -10.0) 'mid)
6285 ((> result 10.0) 'mail)
6288 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6289 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6290 (url-mid (concat "news" ":" mid-or-mail))
6291 (url-mailto (concat "mailto" ":" mid-or-mail)))
6292 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6293 (when (fboundp pref)
6295 ;; get rid of surrounding angles...
6297 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6298 (if (or (eq 'mid guessed) (eq 'mail guessed))
6302 (save-window-excursion
6303 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6306 (cond ((eq pref 'mid)
6307 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6308 (gnus-button-handle-news url-mid))
6310 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6311 (gnus-url-mailto url-mailto))
6312 (t (gnus-message 3 "Invalid string.")))))
6314 (defun gnus-button-handle-custom (fun arg)
6315 "Call function FUN on argument ARG.
6316 Both FUN and ARG are supposed to be strings. ARG will be passed
6317 as a symbol to FUN."
6318 (funcall (intern fun) (intern arg)))
6320 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6322 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6325 (defun gnus-button-handle-describe-function (url)
6326 "Call `describe-function' when pushing the corresponding URL button."
6329 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6331 (defun gnus-button-handle-describe-variable (url)
6332 "Call `describe-variable' when pushing the corresponding URL button."
6335 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6337 (defun gnus-button-handle-symbol (url)
6338 "Display help on variable or function.
6339 Calls `describe-variable' or `describe-function'."
6340 (let ((sym (intern url)))
6342 ((fboundp sym) (describe-function sym))
6343 ((boundp sym) (describe-variable sym))
6344 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6346 (defun gnus-button-handle-describe-key (url)
6347 "Call `describe-key' when pushing the corresponding URL button."
6349 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6350 (keys (ignore-errors (eval `(kbd ,key-string)))))
6353 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6355 (defun gnus-button-handle-apropos (url)
6356 "Call `apropos' when pushing the corresponding URL button."
6357 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6359 (defun gnus-button-handle-apropos-command (url)
6360 "Call `apropos' when pushing the corresponding URL button."
6362 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6364 (defun gnus-button-handle-apropos-variable (url)
6365 "Call `apropos' when pushing the corresponding URL button."
6367 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6368 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6370 (defun gnus-button-handle-apropos-documentation (url)
6371 "Call `apropos' when pushing the corresponding URL button."
6373 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6374 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6376 (defun gnus-button-handle-library (url)
6377 "Call `locate-library' when pushing the corresponding URL button."
6378 (gnus-message 9 "url=`%s'" url)
6379 (let* ((lib (locate-library url))
6380 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6382 (gnus-message 1 "Cannot locale library `%s'." url)
6383 (find-file-read-only file))))
6385 (defun gnus-button-handle-ctan (url)
6386 "Call `browse-url' when pushing a CTAN URL button."
6388 gnus-button-ctan-handler
6391 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6393 (defcustom gnus-button-tex-level 5
6394 "*Integer that says how many TeX-related buttons Gnus will show.
6395 The higher the number, the more buttons will appear and the more false
6396 positives are possible. Note that you can set this variable local to
6397 specific groups. Setting it higher in TeX groups is probably a good idea.
6398 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6399 how to set variables in specific groups."
6401 :group 'gnus-article-buttons
6402 :link '(custom-manual "(gnus)Group Parameters")
6405 (defcustom gnus-button-man-level 5
6406 "*Integer that says how many man-related buttons Gnus will show.
6407 The higher the number, the more buttons will appear and the more false
6408 positives are possible. Note that you can set this variable local to
6409 specific groups. Setting it higher in Unix groups is probably a good idea.
6410 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6411 how to set variables in specific groups."
6413 :group 'gnus-article-buttons
6414 :link '(custom-manual "(gnus)Group Parameters")
6417 (defcustom gnus-button-emacs-level 5
6418 "*Integer that says how many emacs-related buttons Gnus will show.
6419 The higher the number, the more buttons will appear and the more false
6420 positives are possible. Note that you can set this variable local to
6421 specific groups. Setting it higher in Emacs or Gnus related groups is
6422 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6423 `gnus-parameters' on how to set variables in specific groups."
6425 :group 'gnus-article-buttons
6426 :link '(custom-manual "(gnus)Group Parameters")
6429 (defcustom gnus-button-message-level 5
6430 "*Integer that says how many buttons for news or mail messages will appear.
6431 The higher the number, the more buttons will appear and the more false
6432 positives are possible."
6433 ;; mail addresses, MIDs, URLs for news, ...
6435 :group 'gnus-article-buttons
6438 (defcustom gnus-button-browse-level 5
6439 "*Integer that says how many buttons for browsing will appear.
6440 The higher the number, the more buttons will appear and the more false
6441 positives are possible."
6442 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6444 :group 'gnus-article-buttons
6447 (defcustom gnus-button-alist
6448 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6449 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6450 ((concat "\\b\\(nntp\\|news\\):\\("
6451 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6452 0 t gnus-button-handle-news 2)
6453 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6454 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6455 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6456 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6457 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6458 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6459 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6460 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6461 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6462 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6463 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6464 ;; RFC 2368 (The mailto URL scheme)
6465 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6466 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6467 ("\\bmailto:\\([^ \n\t]+\\)"
6468 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6470 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6471 gnus-button-ctan-directory-regexp
6472 "[^][>)!;:,'\n\t ]+\\)")
6473 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6474 ((concat "\\btex-archive/\\("
6475 gnus-button-ctan-directory-regexp
6476 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6477 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6480 gnus-button-ctan-directory-regexp
6481 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6482 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6483 ;; This is info (home-grown style) <info://foo/bar+baz>
6484 ("\\binfo://\\([^'\">\n\t ]+\\)"
6485 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6486 ;; Info GNOME style <info:foo#bar_baz>
6487 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6488 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6489 ;; Info KDE style <info:(foo)bar baz>
6490 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6491 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6492 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6493 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6494 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6495 ;; Info links like `C-h i d m CC Mode RET'
6496 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6498 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6499 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
6500 ;; Emacs help commands
6501 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6502 ;; regexp doesn't match arguments containing ` '.
6503 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6504 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6505 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6506 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6507 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6508 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6509 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6510 ;; The following entries may lead to many false positives so don't enable
6511 ;; them by default (use a high button level).
6512 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6513 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6514 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6515 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6516 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6517 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6518 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6519 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6520 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6521 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6522 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6523 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6524 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6525 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6526 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6527 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6528 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6529 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6530 ;; Unlike the other regexps we really have to require quoting
6531 ;; here to determine where it ends.
6532 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6533 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6534 ("<URL: *\\([^<>]*\\)>"
6535 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6536 ;; RFC 2396 (2.4.3., delims) ...
6537 ("\"URL: *\\([^\"]*\\)\""
6538 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6539 ;; RFC 2396 (2.4.3., delims) ...
6540 ("\"URL: *\\([^\"]*\\)\""
6541 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6543 (gnus-button-url-regexp
6544 0 (>= gnus-button-browse-level 0) browse-url 0)
6546 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6547 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6548 gnus-button-handle-man 1)
6549 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6550 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6551 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6552 gnus-button-handle-man 1)
6553 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6554 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6555 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6556 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6557 ;; MID or mail: To avoid too many false positives we don't try to catch
6558 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6559 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6560 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6561 ;; so that non-ambiguous entries (see above) match first.
6562 (gnus-button-mid-or-mail-regexp
6563 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6564 "*Alist of regexps matching buttons in article bodies.
6566 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6567 REGEXP: is the string (case insensitive) matching text around the button (can
6568 also be Lisp expression evaluating to a string),
6569 BUTTON: is the number of the regexp grouping actually matching the button,
6570 FORM: is a Lisp expression which must eval to true for the button to
6572 CALLBACK: is the function to call when the user push this button, and each
6573 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6575 CALLBACK can also be a variable, in that case the value of that
6576 variable it the real callback function."
6577 :group 'gnus-article-buttons
6578 :type '(repeat (list (choice regexp variable sexp)
6579 (integer :tag "Button")
6581 (function :tag "Callback")
6584 (integer :tag "Regexp group")))))
6586 (defcustom gnus-header-button-alist
6587 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6588 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6589 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6590 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6591 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6592 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6593 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6594 0 (>= gnus-button-browse-level 0) browse-url 0)
6595 ("^Subject:" gnus-button-url-regexp
6596 0 (>= gnus-button-browse-level 0) browse-url 0)
6597 ("^[^:]+:" gnus-button-url-regexp
6598 0 (>= gnus-button-browse-level 0) browse-url 0)
6599 ("^OpenPGP:.*url=" gnus-button-url-regexp
6600 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6601 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6602 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6603 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6604 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6605 "*Alist of headers and regexps to match buttons in article heads.
6607 This alist is very similar to `gnus-button-alist', except that each
6608 alist has an additional HEADER element first in each entry:
6610 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6612 HEADER is a regexp to match a header. For a fuller explanation, see
6613 `gnus-button-alist'."
6614 :group 'gnus-article-buttons
6615 :group 'gnus-article-headers
6616 :type '(repeat (list (regexp :tag "Header")
6617 (choice regexp variable)
6618 (integer :tag "Button")
6620 (function :tag "Callback")
6623 (integer :tag "Regexp group")))))
6627 (defun gnus-article-push-button (event)
6628 "Check text under the mouse pointer for a callback function.
6629 If the text under the mouse pointer has a `gnus-callback' property,
6630 call it with the value of the `gnus-data' text property."
6632 (set-buffer (window-buffer (posn-window (event-start event))))
6633 (let* ((pos (posn-point (event-start event)))
6634 (data (get-text-property pos 'gnus-data))
6635 (fun (get-text-property pos 'gnus-callback)))
6638 (funcall fun data))))
6640 (defun gnus-article-press-button ()
6641 "Check text at point for a callback function.
6642 If the text at point has a `gnus-callback' property,
6643 call it with the value of the `gnus-data' text property."
6645 (let ((data (get-text-property (point) 'gnus-data))
6646 (fun (get-text-property (point) 'gnus-callback)))
6648 (funcall fun data))))
6650 (defun gnus-article-highlight (&optional force)
6651 "Highlight current article.
6652 This function calls `gnus-article-highlight-headers',
6653 `gnus-article-highlight-citation',
6654 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6655 do the highlighting. See the documentation for those functions."
6656 (interactive (list 'force))
6657 (gnus-article-highlight-headers)
6658 (gnus-article-highlight-citation force)
6659 (gnus-article-highlight-signature)
6660 (gnus-article-add-buttons force)
6661 (gnus-article-add-buttons-to-head))
6663 (defun gnus-article-highlight-some (&optional force)
6664 "Highlight current article.
6665 This function calls `gnus-article-highlight-headers',
6666 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6667 do the highlighting. See the documentation for those functions."
6668 (interactive (list 'force))
6669 (gnus-article-highlight-headers)
6670 (gnus-article-highlight-signature)
6671 (gnus-article-add-buttons))
6673 (defun gnus-article-highlight-headers ()
6674 "Highlight article headers as specified by `gnus-header-face-alist'."
6676 (gnus-with-article-headers
6677 (let (regexp header-face field-face from hpoints fpoints)
6678 (dolist (entry gnus-header-face-alist)
6679 (goto-char (point-min))
6680 (setq regexp (concat "^\\("
6681 (if (string-equal "" (nth 0 entry))
6685 header-face (nth 1 entry)
6686 field-face (nth 2 entry))
6687 (while (and (re-search-forward regexp nil t)
6691 (unless (search-forward ":" nil t)
6693 (when (and header-face
6694 (not (memq (point) hpoints)))
6695 (push (point) hpoints)
6696 (gnus-put-text-property from (point) 'face header-face))
6697 (when (and field-face
6698 (not (memq (setq from (point)) fpoints)))
6700 (if (re-search-forward "^[^ \t]" nil t)
6702 (goto-char (point-max)))
6703 (gnus-put-text-property from (point) 'face field-face)))))))
6705 (defun gnus-article-highlight-signature ()
6706 "Highlight the signature in an article.
6707 It does this by highlighting everything after
6708 `gnus-signature-separator' using the face `gnus-signature'."
6710 (gnus-with-article-buffer
6711 (let ((inhibit-point-motion-hooks t))
6713 (when (and gnus-signature-face
6714 (gnus-article-narrow-to-signature))
6715 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6716 'face gnus-signature-face)
6718 (gnus-article-search-signature)
6719 (let ((start (match-beginning 0))
6720 (end (set-marker (make-marker) (1+ (match-end 0)))))
6721 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6724 (defun gnus-button-in-region-p (b e prop)
6725 "Say whether PROP exists in the region."
6726 (text-property-not-all b e prop nil))
6728 (defun gnus-article-add-buttons (&optional force)
6729 "Find external references in the article and make buttons of them.
6730 \"External references\" are things like Message-IDs and URLs, as
6731 specified by `gnus-button-alist'."
6732 (interactive (list 'force))
6733 (gnus-with-article-buffer
6734 (let ((inhibit-point-motion-hooks t)
6735 (case-fold-search t)
6736 (alist gnus-button-alist)
6738 ;; Remove all old markers.
6739 (let (marker entry new-list)
6740 (while (setq marker (pop gnus-button-marker-list))
6741 (if (or (< marker (point-min)) (>= marker (point-max)))
6742 (push marker new-list)
6744 (when (setq entry (gnus-button-entry))
6745 (put-text-property (match-beginning (nth 1 entry))
6746 (match-end (nth 1 entry))
6747 'gnus-callback nil))
6748 (set-marker marker nil)))
6749 (setq gnus-button-marker-list new-list))
6750 ;; We skip the headers.
6753 (while (setq entry (pop alist))
6754 (setq regexp (eval (car entry)))
6756 (while (re-search-forward regexp nil t)
6757 (let* ((start (and entry (match-beginning (nth 1 entry))))
6758 (end (and entry (match-end (nth 1 entry))))
6759 (from (match-beginning 0)))
6760 (when (and (or (eq t (nth 2 entry))
6761 (eval (nth 2 entry)))
6762 (not (gnus-button-in-region-p
6763 start end 'gnus-callback)))
6764 ;; That optional form returned non-nil, so we add the
6766 (gnus-article-add-button
6767 start end 'gnus-button-push
6768 (car (push (set-marker (make-marker) from)
6769 gnus-button-marker-list))))))))))
6771 ;; Add buttons to the head of an article.
6772 (defun gnus-article-add-buttons-to-head ()
6773 "Add buttons to the head of the article."
6775 (gnus-with-article-headers
6777 (dolist (entry gnus-header-button-alist)
6778 ;; Each alist entry.
6779 (goto-char (point-min))
6780 (while (re-search-forward (car entry) nil t)
6781 ;; Each header matching the entry.
6782 (setq beg (match-beginning 0))
6783 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6784 (match-beginning 0))
6787 (while (re-search-forward (eval (nth 1 entry)) end t)
6788 ;; Each match within a header.
6789 (let* ((entry (cdr entry))
6790 (start (match-beginning (nth 1 entry)))
6791 (end (match-end (nth 1 entry)))
6792 (form (nth 2 entry)))
6793 (goto-char (match-end 0))
6795 (gnus-article-add-button
6796 start end (nth 3 entry)
6797 (buffer-substring (match-beginning (nth 4 entry))
6798 (match-end (nth 4 entry)))))))
6799 (goto-char end))))))
6801 ;;; External functions:
6803 (defun gnus-article-add-button (from to fun &optional data)
6804 "Create a button between FROM and TO with callback FUN and data DATA."
6805 (when gnus-article-button-face
6806 (gnus-overlay-put (gnus-make-overlay from to)
6807 'face gnus-article-button-face))
6808 (gnus-add-text-properties
6810 (nconc (and gnus-article-mouse-face
6811 (list gnus-mouse-face-prop gnus-article-mouse-face))
6812 (list 'gnus-callback fun)
6813 (and data (list 'gnus-data data))))
6814 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6815 :button-keymap gnus-widget-button-keymap))
6817 ;;; Internal functions:
6819 (defun gnus-article-set-globals ()
6820 (with-current-buffer gnus-summary-buffer
6821 (gnus-set-global-variables)))
6823 (defun gnus-signature-toggle (end)
6824 (gnus-with-article-buffer
6825 (let ((inhibit-point-motion-hooks t))
6826 (if (text-property-any end (point-max) 'article-type 'signature)
6828 (gnus-delete-wash-type 'signature)
6829 (gnus-remove-text-properties-when
6830 'article-type 'signature end (point-max)
6831 (cons 'article-type (cons 'signature
6832 gnus-hidden-properties))))
6833 (gnus-add-wash-type 'signature)
6834 (gnus-add-text-properties-when
6835 'article-type nil end (point-max)
6836 (cons 'article-type (cons 'signature
6837 gnus-hidden-properties)))))
6838 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6839 (gnus-set-mode-line 'article))))
6841 (defun gnus-button-entry ()
6842 ;; Return the first entry in `gnus-button-alist' matching this place.
6843 (let ((alist gnus-button-alist)
6846 (setq entry (pop alist))
6847 (if (looking-at (eval (car entry)))
6852 (defun gnus-button-push (marker)
6853 ;; Push button starting at MARKER.
6856 (let* ((entry (gnus-button-entry))
6857 (inhibit-point-motion-hooks t)
6859 (args (mapcar (lambda (group)
6860 (let ((string (match-string group)))
6861 (set-text-properties
6862 0 (length string) nil string)
6869 (fboundp (symbol-value fun)))
6870 (apply (symbol-value fun) args))
6872 (gnus-message 1 "You must define `%S' to use this button"
6873 (cons fun args)))))))
6875 (defun gnus-parse-news-url (url)
6876 (let (scheme server port group message-id articles)
6879 (goto-char (point-min))
6880 (when (looking-at "\\([A-Za-z]+\\):")
6881 (setq scheme (match-string 1))
6882 (goto-char (match-end 0)))
6883 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
6884 (setq server (match-string 1))
6885 (setq port (if (stringp (match-string 3))
6886 (string-to-number (match-string 3))
6888 (goto-char (match-end 0)))
6891 ((looking-at "\\(.*@.*\\)")
6892 (setq message-id (match-string 1)))
6893 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6894 (setq group (match-string 1)
6895 articles (split-string (match-string 2) "-")))
6896 ((looking-at "\\([^/]+\\)/?")
6897 (setq group (match-string 1)))
6899 (error "Unknown news URL syntax"))))
6900 (list scheme server port group message-id articles)))
6902 (defun gnus-button-handle-news (url)
6904 (destructuring-bind (scheme server port group message-id articles)
6905 (gnus-parse-news-url url)
6909 (set-buffer gnus-summary-buffer)
6911 (let ((gnus-refer-article-method
6912 (nconc (list (list 'nntp server))
6913 gnus-refer-article-method))
6914 (nntp-port-number (or port "nntp")))
6915 (gnus-message 7 "Fetching %s with %s"
6916 message-id gnus-refer-article-method)
6917 (gnus-summary-refer-article message-id))
6918 (gnus-summary-refer-article message-id))))
6920 (gnus-button-fetch-group url)))))
6922 (defun gnus-button-handle-man (url)
6924 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6925 (when (eq gnus-button-man-handler 'woman)
6926 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
6927 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6928 (funcall gnus-button-man-handler url))
6930 (defun gnus-button-handle-info-url (url)
6931 "Fetch an info URL."
6932 (setq url (mm-subst-char-in-string ?+ ?\ url))
6934 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6935 (gnus-info-find-node
6936 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6938 ")" (gnus-url-unhex-string (match-string 2 url)))))
6939 ((string-match "([^)\"]+)[^\"]+" url)
6941 (gnus-replace-in-string
6942 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6943 (gnus-info-find-node url))
6944 (t (error "Can't parse %s" url))))
6946 (defun gnus-button-handle-info-url-gnome (url)
6947 "Fetch GNOME style info URL."
6948 (setq url (mm-subst-char-in-string ?_ ?\ url))
6949 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6950 (gnus-info-find-node
6952 (gnus-url-unhex-string
6953 (match-string 1 url))
6955 (or (gnus-url-unhex-string
6956 (match-string 2 url))
6958 (error "Can't parse %s" url)))
6960 (defun gnus-button-handle-info-url-kde (url)
6961 "Fetch KDE style info URL."
6962 (gnus-info-find-node (gnus-url-unhex-string url)))
6964 (defun gnus-button-handle-info-keystrokes (url)
6965 "Call `info' when pushing the corresponding URL button."
6966 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6971 (defun gnus-button-openpgp (url)
6972 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
6974 (mm-url-insert-file-contents-external url)
6975 (pgg-snarf-keys-region (point-min) (point-max))
6976 (pgg-display-output-buffer nil nil nil)))
6978 (defun gnus-button-message-id (message-id)
6980 (with-current-buffer gnus-summary-buffer
6981 (gnus-summary-refer-article message-id)))
6983 (defun gnus-button-fetch-group (address)
6984 "Fetch GROUP specified by ADDRESS."
6985 (if (not (string-match "[:/]" address))
6986 ;; This is just a simple group url.
6987 (gnus-group-read-ephemeral-group address gnus-select-method)
6990 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6992 (error "Can't parse %s" address)
6993 (gnus-group-read-ephemeral-group
6994 (match-string 4 address)
6995 `(nntp ,(match-string 1 address)
6996 (nntp-address ,(match-string 1 address))
6997 (nntp-port-number ,(if (match-end 3)
6998 (match-string 3 address)
7001 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
7003 (defun gnus-url-parse-query-string (query &optional downcase)
7004 (let (retval pairs cur key val)
7005 (setq pairs (split-string query "&"))
7007 (setq cur (car pairs)
7009 (if (not (string-match "=" cur))
7011 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7012 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7014 (setq key (downcase key)))
7015 (setq cur (assoc key retval))
7017 (setcdr cur (cons val (cdr cur)))
7018 (setq retval (cons (list key val) retval)))))
7021 (defun gnus-url-mailto (url)
7022 ;; Send mail to someone
7023 (when (string-match "mailto:/*\\(.*\\)" url)
7024 (setq url (substring url (match-beginning 1) nil)))
7025 (let (to args subject func)
7026 (setq args (gnus-url-parse-query-string
7027 (if (string-match "^\\?" url)
7029 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7030 (concat "to=" (match-string 1 url) "&"
7031 (match-string 2 url))
7032 (concat "to=" url)))
7034 subject (cdr-safe (assoc "subject" args)))
7037 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7040 (message-position-on-field (caar args)))
7041 (insert (gnus-replace-in-string
7042 (mapconcat 'identity (reverse (cdar args)) ", ")
7044 (setq args (cdr args)))
7047 (message-goto-subject))))
7049 (defun gnus-button-embedded-url (address)
7050 "Activate ADDRESS with `browse-url'."
7051 (browse-url (gnus-strip-whitespace address)))
7053 ;;; Next/prev buttons in the article buffer.
7055 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7056 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7058 (defvar gnus-prev-page-map
7059 (let ((map (make-sparse-keymap)))
7060 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7061 (define-key map "\r" 'gnus-button-prev-page)
7064 (defvar gnus-next-page-map
7065 (let ((map (make-sparse-keymap)))
7066 (unless (>= emacs-major-version 21)
7067 ;; XEmacs doesn't care.
7068 (set-keymap-parent map gnus-article-mode-map))
7069 (define-key map gnus-mouse-2 'gnus-button-next-page)
7070 (define-key map "\r" 'gnus-button-next-page)
7073 (defun gnus-insert-prev-page-button ()
7075 (inhibit-read-only t))
7077 gnus-prev-page-line-format nil
7078 `(keymap ,gnus-prev-page-map
7080 gnus-callback gnus-article-button-prev-page
7081 article-type annotation))
7082 (widget-convert-button
7084 ;; Exclude a newline.
7087 :action 'gnus-button-prev-page
7088 :button-keymap gnus-prev-page-map)))
7090 (defun gnus-button-next-page (&optional args more-args)
7091 "Go to the next page."
7093 (let ((win (selected-window)))
7094 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7095 (gnus-article-next-page)
7096 (select-window win)))
7098 (defun gnus-button-prev-page (&optional args more-args)
7099 "Go to the prev page."
7101 (let ((win (selected-window)))
7102 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7103 (gnus-article-prev-page)
7104 (select-window win)))
7106 (defun gnus-insert-next-page-button ()
7108 (inhibit-read-only t))
7109 (gnus-eval-format gnus-next-page-line-format nil
7110 `(keymap ,gnus-next-page-map
7112 gnus-callback gnus-article-button-next-page
7113 article-type annotation))
7114 (widget-convert-button
7116 ;; Exclude a newline.
7119 :action 'gnus-button-next-page
7120 :button-keymap gnus-next-page-map)))
7122 (defun gnus-article-button-next-page (arg)
7123 "Go to the next page."
7125 (let ((win (selected-window)))
7126 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7127 (gnus-article-next-page)
7128 (select-window win)))
7130 (defun gnus-article-button-prev-page (arg)
7131 "Go to the prev page."
7133 (let ((win (selected-window)))
7134 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7135 (gnus-article-prev-page)
7136 (select-window win)))
7138 (defvar gnus-decode-header-methods
7139 '(mail-decode-encoded-word-region)
7140 "List of methods used to decode headers.
7142 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7143 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7144 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7145 whose names match REGEXP.
7148 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7149 mail-decode-encoded-word-region
7150 (\"chinese\" . rfc1843-decode-region))
7153 (defvar gnus-decode-header-methods-cache nil)
7155 (defun gnus-multi-decode-header (start end)
7156 "Apply the functions from `gnus-encoded-word-methods' that match."
7157 (unless (and gnus-decode-header-methods-cache
7158 (eq gnus-newsgroup-name
7159 (car gnus-decode-header-methods-cache)))
7160 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7163 (nconc gnus-decode-header-methods-cache (list x))
7164 (if (and gnus-newsgroup-name
7165 (string-match (car x) gnus-newsgroup-name))
7166 (nconc gnus-decode-header-methods-cache
7168 gnus-decode-header-methods))
7169 (let ((xlist gnus-decode-header-methods-cache))
7172 (narrow-to-region start end)
7174 (funcall (pop xlist) (point-min) (point-max))))))
7177 ;;; Treatment top-level handling.
7180 (defun gnus-treat-article (condition &optional part-number total-parts type)
7181 (let ((length (- (point-max) (point-min)))
7182 (alist gnus-treatment-function-alist)
7183 (article-goto-body-goes-to-point-min-p t)
7187 (let ((list gnus-article-treat-types))
7189 (when (string-match (pop list) type)
7190 (throw 'found t)))))))
7191 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7193 (gnus-run-hooks 'gnus-part-display-hook)
7194 (dolist (elem alist)
7197 (when (gnus-buffer-live-p gnus-summary-buffer)
7198 (set-buffer gnus-summary-buffer))
7199 (symbol-value (car elem))))
7200 (when (and (or (consp val)
7202 (gnus-treat-predicate val)
7203 (or (not (get (car elem) 'highlight))
7206 (funcall (cadr elem)))))))
7208 ;; Dynamic variables.
7210 (defvar part-number)
7211 (defvar total-parts)
7216 (defun gnus-treat-predicate (val)
7223 (stringp (car val)))
7224 (apply 'gnus-or (mapcar `(lambda (s)
7225 (string-match s ,(or gnus-newsgroup-name "")))
7228 (let ((pred (pop val)))
7231 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7233 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7235 (not (gnus-treat-predicate (car val))))
7237 (equal (car val) type))
7239 (error "%S is not a valid predicate" pred)))))
7247 (eq part-number total-parts))
7251 (error "%S is not a valid value" val))))
7253 (defun gnus-article-encrypt-body (protocol &optional n)
7254 "Encrypt the article body."
7257 (or gnus-article-encrypt-protocol
7258 (completing-read "Encrypt protocol: "
7259 gnus-article-encrypt-protocol-alist
7261 current-prefix-arg))
7262 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7264 (error "Can't find the encrypt protocol %s" protocol))
7265 (if (member gnus-newsgroup-name '("nndraft:delayed"
7268 (error "Can't encrypt the article in group %s"
7269 gnus-newsgroup-name))
7270 (gnus-summary-iterate n
7272 (set-buffer gnus-summary-buffer)
7273 (let ((mail-parse-charset gnus-newsgroup-charset)
7274 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7275 (summary-buffer gnus-summary-buffer)
7277 (gnus-set-global-variables)
7278 (when (gnus-group-read-only-p)
7279 (error "The current newsgroup does not support article encrypt"))
7280 (gnus-summary-show-article t)
7282 (or (mail-header-references gnus-current-headers) ""))
7283 (set-buffer gnus-article-buffer)
7284 (let* ((inhibit-read-only t)
7286 (mapcar (lambda (field)
7287 (and (save-restriction
7288 (message-narrow-to-head)
7289 (goto-char (point-min))
7290 (search-forward field nil t))
7292 (message-narrow-to-field)
7294 (delete-region (point-min) (point-max))
7296 '("Content-Type:" "Content-Transfer-Encoding:"
7297 "Content-Disposition:"))))
7298 (message-narrow-to-head)
7299 (message-remove-header "MIME-Version")
7300 (goto-char (point-max))
7301 (setq point (point))
7302 (insert (apply 'concat headers))
7304 (narrow-to-region point (point-max))
7305 (let ((message-options message-options))
7306 (message-options-set 'message-sender user-mail-address)
7307 (message-options-set 'message-recipients user-mail-address)
7308 (message-options-set 'message-sign-encrypt 'not)
7310 (goto-char (point-min))
7311 (insert "MIME-Version: 1.0\n")
7313 (gnus-summary-edit-article-done
7314 references nil summary-buffer t))
7315 (when gnus-keep-backlog
7316 (gnus-backlog-remove-article
7317 (car gnus-article-current) (cdr gnus-article-current)))
7319 (when (get-buffer gnus-original-article-buffer)
7320 (set-buffer gnus-original-article-buffer)
7321 (setq gnus-original-article nil)))
7322 (when gnus-use-cache
7323 (gnus-cache-update-article
7324 (car gnus-article-current) (cdr gnus-article-current))))))))
7326 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7327 "The following specs can be used:
7328 %t The security MIME type
7331 %D Details if button is pressed")
7333 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7334 "The following specs can be used:
7335 %t The security MIME type
7338 %D Details if button is pressed")
7340 (defvar gnus-mime-security-button-line-format-alist
7341 '((?t gnus-tmp-type ?s)
7342 (?i gnus-tmp-info ?s)
7343 (?d gnus-tmp-details ?s)
7344 (?D gnus-tmp-pressed-details ?s)))
7346 (defvar gnus-mime-security-button-map
7347 (let ((map (make-sparse-keymap)))
7348 (define-key map gnus-mouse-2 'gnus-article-push-button)
7349 (define-key map "\r" 'gnus-article-press-button)
7352 (defvar gnus-mime-security-details-buffer nil)
7354 (defvar gnus-mime-security-button-pressed nil)
7356 (defvar gnus-mime-security-show-details-inline t
7357 "If non-nil, show details in the article buffer.")
7359 (defun gnus-mime-security-verify-or-decrypt (handle)
7360 (mm-remove-parts (cdr handle))
7361 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7362 point (inhibit-read-only t))
7364 (goto-char (car region)))
7366 (narrow-to-region (point) (point))
7367 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7368 (let* ((mm-verify-option 'known)
7369 (mm-decrypt-option 'known)
7370 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7371 (unless (eq nparts (cdr handle))
7372 (mm-destroy-parts (cdr handle))
7373 (setcdr handle nparts))))
7374 (setq point (point))
7375 (gnus-mime-display-security handle)
7376 (goto-char (point-max)))
7378 (delete-region (point) (cdr region))
7379 (set-marker (car region) nil)
7380 (set-marker (cdr region) nil))
7383 (defun gnus-mime-security-show-details (handle)
7384 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7386 (gnus-message 5 "No details.")
7387 (if gnus-mime-security-show-details-inline
7388 (let ((gnus-mime-security-button-pressed
7389 (not (get-text-property (point) 'gnus-mime-details)))
7390 (gnus-mime-security-button-line-format
7391 (get-text-property (point) 'gnus-line-format))
7392 (inhibit-read-only t))
7394 (while (eq (get-text-property (point) 'gnus-line-format)
7395 gnus-mime-security-button-line-format)
7399 (narrow-to-region (point) (point))
7400 (gnus-insert-mime-security-button handle))
7401 (delete-region (point)
7402 (or (text-property-not-all
7405 gnus-mime-security-button-line-format)
7408 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7409 (with-current-buffer gnus-mime-security-details-buffer
7412 (setq gnus-mime-security-details-buffer
7413 (gnus-get-buffer-create "*MIME Security Details*")))
7414 (with-current-buffer gnus-mime-security-details-buffer
7416 (goto-char (point-min)))
7417 (pop-to-buffer gnus-mime-security-details-buffer)))))
7419 (defun gnus-mime-security-press-button (handle)
7421 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7422 (gnus-mime-security-show-details handle)
7423 (gnus-mime-security-verify-or-decrypt handle))))
7425 (defun gnus-insert-mime-security-button (handle &optional displayed)
7426 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7429 (or (nth 2 (assoc protocol mm-verify-function-alist))
7430 (nth 2 (assoc protocol mm-decrypt-function-alist))
7432 (if (equal (car handle) "multipart/signed")
7433 " Signed" " Encrypted")
7436 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7439 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7440 gnus-tmp-pressed-details
7442 (setq gnus-tmp-details
7443 (if gnus-tmp-details
7444 (concat "\n" gnus-tmp-details)
7446 (setq gnus-tmp-pressed-details
7447 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7452 gnus-mime-security-button-line-format
7453 gnus-mime-security-button-line-format-alist
7454 `(keymap ,gnus-mime-security-button-map
7455 gnus-callback gnus-mime-security-press-button
7456 gnus-line-format ,gnus-mime-security-button-line-format
7457 gnus-mime-details ,gnus-mime-security-button-pressed
7458 article-type annotation
7461 ;; Exclude a newline.
7464 (widget-convert-button
7467 :action 'gnus-widget-press-button
7468 :button-keymap gnus-mime-security-button-map
7470 (lambda (widget/window &optional overlay pos)
7471 ;; Needed to properly clear the message due to a bug in
7472 ;; wid-edit (XEmacs only).
7473 (when (boundp 'help-echo-owns-message)
7474 (setq help-echo-owns-message t))
7477 (aref gnus-mouse-2 0))))))
7479 (defun gnus-mime-display-security (handle)
7481 (narrow-to-region (point) (point))
7482 (unless (gnus-unbuttonized-mime-type-p (car handle))
7483 (gnus-insert-mime-security-button handle))
7484 (gnus-mime-display-part (cadr handle))
7487 (unless (gnus-unbuttonized-mime-type-p (car handle))
7488 (let ((gnus-mime-security-button-line-format
7489 gnus-mime-security-button-end-line-format))
7490 (gnus-insert-mime-security-button handle)))
7491 (mm-set-handle-multipart-parameter
7493 (cons (set-marker (make-marker) (point-min))
7494 (set-marker (make-marker) (point-max))))))
7500 (run-hooks 'gnus-art-load-hook)
7502 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7503 ;;; gnus-art.el ends here