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.
32 (defvar tool-bar-map))
35 ;; Avoid the "Recursive load suspected" error in Emacs 21.1.
37 (let ((recursive-load-depth-limit 100))
50 (autoload 'gnus-msg-mail "gnus-msg" nil t)
51 (autoload 'gnus-button-mailto "gnus-msg")
52 (autoload 'gnus-button-reply "gnus-msg" nil t)
53 (autoload 'parse-time-string "parse-time" nil nil)
54 (autoload 'ansi-color-apply-on-region "ansi-color")
56 (defgroup gnus-article nil
58 :link '(custom-manual "(gnus)Article Buffer")
61 (defgroup gnus-article-treat nil
62 "Treating article parts."
63 :link '(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-hiding nil
67 "Hiding article parts."
68 :link '(custom-manual "(gnus)Article Hiding")
71 (defgroup gnus-article-highlight nil
72 "Article highlighting."
73 :link '(custom-manual "(gnus)Article Highlighting")
77 (defgroup gnus-article-signature nil
79 :link '(custom-manual "(gnus)Article Signature")
82 (defgroup gnus-article-headers nil
84 :link '(custom-manual "(gnus)Hiding Headers")
87 (defgroup gnus-article-washing nil
88 "Special commands on articles."
89 :link '(custom-manual "(gnus)Article Washing")
92 (defgroup gnus-article-emphasis nil
93 "Fontisizing articles."
94 :link '(custom-manual "(gnus)Article Fontisizing")
97 (defgroup gnus-article-saving nil
99 :link '(custom-manual "(gnus)Saving Articles")
100 :group 'gnus-article)
102 (defgroup gnus-article-mime nil
103 "Worshiping the MIME wonder."
104 :link '(custom-manual "(gnus)Using MIME")
105 :group 'gnus-article)
107 (defgroup gnus-article-buttons nil
108 "Pushable buttons in the article buffer."
109 :link '(custom-manual "(gnus)Article Buttons")
110 :group 'gnus-article)
112 (defgroup gnus-article-various nil
113 "Other article options."
114 :link '(custom-manual "(gnus)Misc Article")
115 :group 'gnus-article)
117 (defcustom gnus-ignored-headers
120 (concat "^" header ":"))
121 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
122 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
123 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
124 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
125 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
126 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
127 "X-Attribution" "X-Originating-IP" "Delivered-To"
128 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
129 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
130 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
131 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
132 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
133 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
134 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
135 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
136 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
137 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
138 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
139 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
140 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
141 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
142 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
143 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
144 "List-[A-Za-z]+" "X-Listprocessor-Version"
145 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
146 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
147 "X-Received" "Content-length" "X-precedence"
148 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
149 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
150 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
151 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
152 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
153 "X-Content-length" "X-Posting-Agent" "Original-Received"
154 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
155 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
156 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
157 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
158 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
159 "*All headers that start with this regexp will be hidden.
160 This variable can also be a list of regexps of headers to be ignored.
161 If `gnus-visible-headers' is non-nil, this variable will be ignored."
162 :type '(choice :custom-show nil
165 :group 'gnus-article-hiding)
167 (defcustom gnus-visible-headers
168 "^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:"
169 "*All headers that do not match this regexp will be hidden.
170 This variable can also be a list of regexp of headers to remain visible.
171 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
172 :type '(repeat :value-to-internal (lambda (widget value)
173 (custom-split-regexp-maybe value))
174 :match (lambda (widget value)
176 (widget-editable-list-match widget value)))
178 :group 'gnus-article-hiding)
180 (defcustom gnus-sorted-header-list
181 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
182 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
183 "*This variable is a list of regular expressions.
184 If it is non-nil, headers that match the regular expressions will
185 be placed first in the article buffer in the sequence specified by
187 :type '(repeat regexp)
188 :group 'gnus-article-hiding)
190 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
191 "Headers that are only to be displayed if they have interesting data.
192 Possible values in this list are:
194 'empty Headers with no content.
195 'newsgroups Newsgroup identical to Gnus group.
196 'to-address To identical to To-address.
197 'to-list To identical to To-list.
198 'cc-list CC identical to To-list.
199 'followup-to Followup-to identical to Newsgroups.
200 'reply-to Reply-to identical to From.
201 'date Date less than four days old.
202 'long-to To and/or Cc longer than 1024 characters.
203 'many-to Multiple To and/or Cc."
204 :type '(set (const :tag "Headers with no content." empty)
205 (const :tag "Newsgroups identical to Gnus group." newsgroups)
206 (const :tag "To identical to To-address." to-address)
207 (const :tag "To identical to To-list." to-list)
208 (const :tag "CC identical to To-list." cc-list)
209 (const :tag "Followup-to identical to Newsgroups." followup-to)
210 (const :tag "Reply-to identical to From." reply-to)
211 (const :tag "Date less than four days old." date)
212 (const :tag "To and/or Cc longer than 1024 characters." long-to)
213 (const :tag "Multiple To and/or Cc headers." many-to))
214 :group 'gnus-article-hiding)
216 (defcustom gnus-article-skip-boring nil
217 "Skip over text that is not worth reading.
218 By default, if you set this t, then Gnus will display citations and
219 signatures, but will never scroll down to show you a page consisting
220 only of boring text. Boring text is controlled by
221 `gnus-article-boring-faces'."
224 :group 'gnus-article-hiding)
226 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
227 "Regexp matching signature separator.
228 This can also be a list of regexps. In that case, it will be checked
229 from head to tail looking for a separator. Searches will be done from
230 the end of the buffer."
231 :type '(repeat string)
232 :group 'gnus-article-signature)
234 (defcustom gnus-signature-limit nil
235 "Provide a limit to what is considered a signature.
236 If it is a number, no signature may not be longer (in characters) than
237 that number. If it is a floating point number, no signature may be
238 longer (in lines) than that number. If it is a function, the function
239 will be called without any parameters, and if it returns nil, there is
240 no signature in the buffer. If it is a string, it will be used as a
241 regexp. If it matches, the text in question is not a signature.
243 This can also be a list of the above values."
244 :type '(choice (integer :value 200)
246 (function :value fun)
247 (regexp :value ".*"))
248 :group 'gnus-article-signature)
250 (defcustom gnus-hidden-properties '(invisible t intangible t)
251 "Property list to use for hiding text."
253 :group 'gnus-article-hiding)
255 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
256 ;; frames in a session.
257 (defcustom gnus-article-x-face-command
258 (if (featurep 'xemacs)
259 (if (or (gnus-image-type-available-p 'xface)
260 (gnus-image-type-available-p 'pbm))
261 'gnus-display-x-face-in-from
262 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
263 (if (gnus-image-type-available-p 'pbm)
264 'gnus-display-x-face-in-from
265 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
267 "*String or function to be executed to display an X-Face header.
268 If it is a string, the command will be executed in a sub-shell
269 asynchronously. The compressed face will be piped to this command."
270 :type `(choice string
271 (function-item gnus-display-x-face-in-from)
275 :group 'gnus-article-washing)
277 (defcustom gnus-article-x-face-too-ugly nil
278 "Regexp matching posters whose face shouldn't be shown automatically."
279 :type '(choice regexp (const nil))
280 :group 'gnus-article-washing)
282 (defcustom gnus-article-banner-alist nil
283 "Banner alist for stripping.
285 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
287 :type '(repeat (cons symbol regexp))
288 :group 'gnus-article-washing)
290 (gnus-define-group-parameter
293 "Alist of regexps (to match group names) and banner."
294 :variable-group gnus-article-washing
296 '(choice :tag "Banner"
298 (const :tag "Remove signature" signature)
299 (symbol :tag "Item in `gnus-article-banner-alist'" none)
301 (const :tag "None" nil))
303 "If non-nil, specify how to remove `banners' from articles.
305 Symbol `signature' means to remove signatures delimited by
306 `gnus-signature-separator'. Any other symbol is used to look up a
307 regular expression to match the banner in `gnus-article-banner-alist'.
308 A string is used as a regular expression to match the banner
311 (defcustom gnus-article-address-banner-alist nil
312 "Alist of mail addresses and banners.
313 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
314 to match a mail address in the From: header, BANNER is one of a symbol
315 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
316 If ADDRESS matches author's mail address, it will remove things like
317 advertisements. For example:
319 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
323 (regexp :tag "Address")
324 (choice :tag "Banner" :value nil
325 (const :tag "Remove signature" signature)
326 (symbol :tag "Item in `gnus-article-banner-alist'" none)
328 (const :tag "None" nil))))
330 :group 'gnus-article-washing)
332 (defmacro gnus-emphasis-custom-with-format (&rest body)
334 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
335 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
338 (defun gnus-emphasis-custom-value-to-external (value)
339 (gnus-emphasis-custom-with-format
340 (if (consp (car value))
341 (list (format format (car (car value)) (cdr (car value)))
343 (if (nth 1 value) 2 3)
347 (defun gnus-emphasis-custom-value-to-internal (value)
348 (gnus-emphasis-custom-with-format
349 (let ((regexp (concat "\\`"
350 (format (regexp-quote format)
351 "\\([^()]+\\)" "\\([^()]+\\)")
354 (if (string-match regexp (setq pattern (car value)))
355 (list (cons (match-string 1 pattern) (match-string 2 pattern))
360 (defcustom gnus-emphasis-alist
362 '(("\\*" "\\*" bold nil 2)
365 ("_/" "/_" underline-italic)
366 ("_\\*" "\\*_" underline-bold)
367 ("\\*/" "/\\*" bold-italic)
368 ("_\\*/" "/\\*_" underline-bold-italic))))
370 (gnus-emphasis-custom-with-format
371 (mapcar (lambda (spec)
372 (list (format format (car spec) (cadr spec))
375 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
377 '(;; I've never seen anyone use this strikethru convention whereas I've
378 ;; several times seen it triggered by normal text. --Stef
379 ;; Miles suggests that this form is sometimes used but for italics,
380 ;; so maybe we should map it to `italic'.
381 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
382 ;; 2 3 gnus-emphasis-strikethru)
383 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
384 2 3 gnus-emphasis-underline))))
385 "*Alist that says how to fontify certain phrases.
386 Each item looks like this:
388 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
390 The first element is a regular expression to be matched. The second
391 is a number that says what regular expression grouping used to find
392 the entire emphasized word. The third is a number that says what
393 regexp grouping should be displayed and highlighted. The fourth
394 is the face used for highlighting."
398 :format "%[Customizing Style%]\n%v"
400 (group :tag "Default"
401 :value ("" 0 0 default)
404 (let ((value (widget-get
405 (cadr (widget-get (widget-get widget :parent)
408 (if (not (eq (nth 2 value) 'default))
412 (gnus-emphasis-custom-value-to-external value))))
413 (widget-group-value-create widget))
415 (integer :format "Match group: %v")
416 (integer :format "Emphasize group: %v")
419 :value (("_" . "_") nil default)
421 (regexp :format "Start regexp: %v")
422 (regexp :format "End regexp: %v"))
423 (boolean :format "Show start and end patterns: %[%v%]\n"
424 :on " On " :off " Off ")
426 :get (lambda (symbol)
427 (mapcar 'gnus-emphasis-custom-value-to-internal
428 (default-value symbol)))
429 :set (lambda (symbol value)
430 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
432 :group 'gnus-article-emphasis)
434 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
435 "A regexp to describe whitespace which should not be emphasized.
436 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
437 The former avoids underlining of leading and trailing whitespace,
438 and the latter avoids underlining any whitespace at all."
440 :group 'gnus-article-emphasis
443 (defface gnus-emphasis-bold '((t (:bold t)))
444 "Face used for displaying strong emphasized text (*word*)."
445 :group 'gnus-article-emphasis)
447 (defface gnus-emphasis-italic '((t (:italic t)))
448 "Face used for displaying italic emphasized text (/word/)."
449 :group 'gnus-article-emphasis)
451 (defface gnus-emphasis-underline '((t (:underline t)))
452 "Face used for displaying underlined emphasized text (_word_)."
453 :group 'gnus-article-emphasis)
455 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
456 "Face used for displaying underlined bold emphasized text (_*word*_)."
457 :group 'gnus-article-emphasis)
459 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
460 "Face used for displaying underlined italic emphasized text (_/word/_)."
461 :group 'gnus-article-emphasis)
463 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
464 "Face used for displaying bold italic emphasized text (/*word*/)."
465 :group 'gnus-article-emphasis)
467 (defface gnus-emphasis-underline-bold-italic
468 '((t (:bold t :italic t :underline t)))
469 "Face used for displaying underlined bold italic emphasized text.
470 Example: (_/*word*/_)."
471 :group 'gnus-article-emphasis)
473 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
474 '((t (:strikethru t)))
475 '((t (:strike-through t))))
476 "Face used for displaying strike-through text (-word-)."
477 :group 'gnus-article-emphasis)
479 (defface gnus-emphasis-highlight-words
480 '((t (:background "black" :foreground "yellow")))
481 "Face used for displaying highlighted words."
482 :group 'gnus-article-emphasis)
484 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
485 "Format for display of Date headers in article bodies.
486 See `format-time-string' for the possible values.
488 The variable can also be function, which should return a complete Date
489 header. The function is called with one argument, the time, which can
490 be fed to `format-time-string'."
491 :type '(choice string function)
492 :link '(custom-manual "(gnus)Article Date")
493 :group 'gnus-article-washing)
495 (defcustom gnus-save-all-headers t
496 "*If non-nil, don't remove any headers before saving."
497 :group 'gnus-article-saving
500 (defcustom gnus-prompt-before-saving 'always
501 "*This variable says how much prompting is to be done when saving articles.
502 If it is nil, no prompting will be done, and the articles will be
503 saved to the default files. If this variable is `always', each and
504 every article that is saved will be preceded by a prompt, even when
505 saving large batches of articles. If this variable is neither nil not
506 `always', there the user will be prompted once for a file name for
507 each invocation of the saving commands."
508 :group 'gnus-article-saving
509 :type '(choice (item always)
510 (item :tag "never" nil)
511 (sexp :tag "once" :format "%t\n" :value t)))
513 (defcustom gnus-saved-headers gnus-visible-headers
514 "Headers to keep if `gnus-save-all-headers' is nil.
515 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
516 If that variable is nil, however, all headers that match this regexp
517 will be kept while the rest will be deleted before saving."
518 :group 'gnus-article-saving
521 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
522 "A function to save articles in your favourite format.
523 The function must be interactively callable (in other words, it must
524 be an Emacs command).
526 Gnus provides the following functions:
528 * gnus-summary-save-in-rmail (Rmail format)
529 * gnus-summary-save-in-mail (Unix mail format)
530 * gnus-summary-save-in-folder (MH folder)
531 * gnus-summary-save-in-file (article format)
532 * gnus-summary-save-body-in-file (article body)
533 * gnus-summary-save-in-vm (use VM's folder format)
534 * gnus-summary-write-to-file (article format -- overwrite)."
535 :group 'gnus-article-saving
536 :type '(radio (function-item gnus-summary-save-in-rmail)
537 (function-item gnus-summary-save-in-mail)
538 (function-item gnus-summary-save-in-folder)
539 (function-item gnus-summary-save-in-file)
540 (function-item gnus-summary-save-body-in-file)
541 (function-item gnus-summary-save-in-vm)
542 (function-item gnus-summary-write-to-file)))
544 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
545 "A function generating a file name to save articles in Rmail format.
546 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
547 :group 'gnus-article-saving
550 (defcustom gnus-mail-save-name 'gnus-plain-save-name
551 "A function generating a file name to save articles in Unix mail format.
552 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
553 :group 'gnus-article-saving
556 (defcustom gnus-folder-save-name 'gnus-folder-save-name
557 "A function generating a file name to save articles in MH folder.
558 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
559 :group 'gnus-article-saving
562 (defcustom gnus-file-save-name 'gnus-numeric-save-name
563 "A function generating a file name to save articles in article format.
564 The function is called with NEWSGROUP, HEADERS, and optional
566 :group 'gnus-article-saving
569 (defcustom gnus-split-methods
570 '((gnus-article-archive-name)
571 (gnus-article-nndoc-name))
572 "*Variable used to suggest where articles are to be saved.
573 For instance, if you would like to save articles related to Gnus in
574 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
575 you could set this variable to something like:
577 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
578 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
580 This variable is an alist where the key is the match and the
581 value is a list of possible files to save in if the match is
584 If the match is a string, it is used as a regexp match on the
585 article. If the match is a symbol, that symbol will be funcalled
586 from the buffer of the article to be saved with the newsgroup as
587 the parameter. If it is a list, it will be evaled in the same
590 If this form or function returns a string, this string will be
591 used as a possible file name; and if it returns a non-nil list,
592 that list will be used as possible file names."
593 :group 'gnus-article-saving
594 :type '(repeat (choice (list :value (fun) function)
595 (cons :value ("" "") regexp (repeat string))
598 (defcustom gnus-page-delimiter "^\^L"
599 "*Regexp describing what to use as article page delimiters.
600 The default value is \"^\^L\", which is a form linefeed at the
601 beginning of a line."
603 :group 'gnus-article-various)
605 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
606 "*The format specification for the article mode line.
607 See `gnus-summary-mode-line-format' for a closer description.
609 The following additional specs are available:
611 %w The article washing status.
612 %m The number of MIME parts in the article."
614 :group 'gnus-article-various)
616 (defcustom gnus-article-mode-hook nil
617 "*A hook for Gnus article mode."
619 :group 'gnus-article-various)
621 (when (featurep 'xemacs)
622 ;; Extracted from gnus-xmas-define in order to preserve user settings
623 (when (fboundp 'turn-off-scroll-in-place)
624 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
625 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
626 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
628 (defcustom gnus-article-menu-hook nil
629 "*Hook run after the creation of the article mode menu."
631 :group 'gnus-article-various)
633 (defcustom gnus-article-prepare-hook nil
634 "*A hook called after an article has been prepared in the article buffer."
636 :group 'gnus-article-various)
638 (defcustom gnus-copy-article-ignored-headers nil
639 "List of headers to be removed when copying an article.
640 Each element is a regular expression."
641 :version "23.0" ;; No Gnus
642 :type '(repeat regexp)
643 :group 'gnus-article-various)
645 (make-obsolete-variable 'gnus-article-hide-pgp-hook
646 "This variable is obsolete in Gnus 5.10.")
648 (defcustom gnus-article-button-face 'bold
649 "Face used for highlighting buttons in the article buffer.
651 An article button is a piece of text that you can activate by pressing
652 `RET' or `mouse-2' above it."
654 :group 'gnus-article-buttons)
656 (defcustom gnus-article-mouse-face 'highlight
657 "Face used for mouse highlighting in the article buffer.
659 Article buttons will be displayed in this face when the cursor is
662 :group 'gnus-article-buttons)
664 (defcustom gnus-signature-face 'gnus-signature
665 "Face used for highlighting a signature in the article buffer.
666 Obsolete; use the face `gnus-signature' for customizations instead."
668 :group 'gnus-article-highlight
669 :group 'gnus-article-signature)
671 (defface gnus-signature
674 "Face used for highlighting a signature in the article buffer."
675 :group 'gnus-article-highlight
676 :group 'gnus-article-signature)
677 ;; backward-compatibility alias
678 (put 'gnus-signature-face 'face-alias 'gnus-signature)
680 (defface gnus-header-from
683 (:foreground "spring green"))
686 (:foreground "red3"))
689 "Face used for displaying from headers."
690 :group 'gnus-article-headers
691 :group 'gnus-article-highlight)
692 ;; backward-compatibility alias
693 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
695 (defface gnus-header-subject
698 (:foreground "SeaGreen3"))
701 (:foreground "red4"))
703 (:bold t :italic t)))
704 "Face used for displaying subject headers."
705 :group 'gnus-article-headers
706 :group 'gnus-article-highlight)
707 ;; backward-compatibility alias
708 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
710 (defface gnus-header-newsgroups
713 (:foreground "yellow" :italic t))
716 (:foreground "MidnightBlue" :italic t))
719 "Face used for displaying newsgroups headers.
720 In the default setup this face is only used for crossposted
722 :group 'gnus-article-headers
723 :group 'gnus-article-highlight)
724 ;; backward-compatibility alias
725 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
727 (defface gnus-header-name
730 (:foreground "SeaGreen"))
733 (:foreground "maroon"))
736 "Face used for displaying header names."
737 :group 'gnus-article-headers
738 :group 'gnus-article-highlight)
739 ;; backward-compatibility alias
740 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
742 (defface gnus-header-content
745 (:foreground "forest green" :italic t))
748 (:foreground "indianred4" :italic t))
750 (:italic t))) "Face used for displaying header content."
751 :group 'gnus-article-headers
752 :group 'gnus-article-highlight)
753 ;; backward-compatibility alias
754 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
756 (defcustom gnus-header-face-alist
757 '(("From" nil gnus-header-from)
758 ("Subject" nil gnus-header-subject)
759 ("Newsgroups:.*," nil gnus-header-newsgroups)
760 ("" gnus-header-name gnus-header-content))
761 "*Controls highlighting of article headers.
763 An alist of the form (HEADER NAME CONTENT).
765 HEADER is a regular expression which should match the name of a
766 header and NAME and CONTENT are either face names or nil.
768 The name of each header field will be displayed using the face
769 specified by the first element in the list where HEADER matches
770 the header name and NAME is non-nil. Similarly, the content will
771 be displayed by the first non-nil matching CONTENT face."
772 :group 'gnus-article-headers
773 :group 'gnus-article-highlight
774 :type '(repeat (list (regexp :tag "Header")
776 (item :tag "skip" nil)
777 (face :value default))
778 (choice :tag "Content"
779 (item :tag "skip" nil)
780 (face :value default)))))
782 (defcustom gnus-article-decode-hook
783 '(article-decode-charset article-decode-encoded-words
784 article-decode-group-name article-decode-idna-rhs)
785 "*Hook run to decode charsets in articles."
786 :group 'gnus-article-headers
789 (defcustom gnus-display-mime-function 'gnus-display-mime
790 "Function to display MIME articles."
791 :group 'gnus-article-mime
794 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
795 "Function used to decode headers.")
797 (defvar gnus-article-dumbquotes-map
817 "Table for MS-to-Latin1 translation.")
819 (defcustom gnus-ignored-mime-types nil
820 "List of MIME types that should be ignored by Gnus."
822 :group 'gnus-article-mime
823 :type '(repeat regexp))
825 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
826 "List of MIME types that should not be given buttons when rendered inline.
827 See also `gnus-buttonized-mime-types' which may override this variable.
828 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
830 :group 'gnus-article-mime
831 :type '(repeat regexp))
833 (defcustom gnus-buttonized-mime-types nil
834 "List of MIME types that should be given buttons when rendered inline.
835 If set, this variable overrides `gnus-unbuttonized-mime-types'.
836 To see e.g. security buttons you could set this to
837 `(\"multipart/signed\")'.
838 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
840 :group 'gnus-article-mime
841 :type '(repeat regexp))
843 (defcustom gnus-inhibit-mime-unbuttonizing nil
844 "If non-nil, all MIME parts get buttons.
845 When nil (the default value), then some MIME parts do not get buttons,
846 as described by the variables `gnus-buttonized-mime-types' and
847 `gnus-unbuttonized-mime-types'."
849 :group 'gnus-article-mime
852 (defcustom gnus-body-boundary-delimiter "_"
853 "String used to delimit header and body.
854 This variable is used by `gnus-article-treat-body-boundary' which can
855 be controlled by `gnus-treat-body-boundary'."
857 :group 'gnus-article-various
858 :type '(choice (item :tag "None" :value nil)
861 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
863 "Defines the location of the faces database.
864 For information on obtaining this database of pretty pictures, please
865 see http://www.cs.indiana.edu/picons/ftp/index.html"
867 :type '(repeat directory)
868 :link '(url-link :tag "download"
869 "http://www.cs.indiana.edu/picons/ftp/index.html")
870 :link '(custom-manual "(gnus)Picons")
873 (defun gnus-picons-installed-p ()
874 "Say whether picons are installed on your machine."
875 (let ((installed nil))
876 (dolist (database gnus-picon-databases)
877 (when (file-exists-p database)
881 (defcustom gnus-article-mime-part-function nil
882 "Function called with a MIME handle as the argument.
883 This is meant for people who want to do something automatic based
884 on parts -- for instance, adding Vcard info to a database."
885 :group 'gnus-article-mime
888 (defcustom gnus-mime-multipart-functions nil
889 "An alist of MIME types to functions to display them."
891 :group 'gnus-article-mime
892 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
894 (defcustom gnus-article-date-lapsed-new-header nil
895 "Whether the X-Sent and Date headers can coexist.
896 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
897 either replace the old \"Date:\" header (if this variable is nil), or
898 be added below it (otherwise)."
900 :group 'gnus-article-headers
903 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
904 "Function called with a MIME handle as the argument.
905 This is meant for people who want to view first matched part.
906 For `undisplayed-alternative' (default), the first undisplayed
907 part or alternative part is used. For `undisplayed', the first
908 undisplayed part is used. For a function, the first part which
909 the function return t is used. For nil, the first part is
912 :group 'gnus-article-mime
914 (item :tag "first" :value nil)
915 (item :tag "undisplayed" :value undisplayed)
916 (item :tag "undisplayed or alternative"
917 :value undisplayed-alternative)
920 (defcustom gnus-mime-action-alist
921 '(("save to file" . gnus-mime-save-part)
922 ("save and strip" . gnus-mime-save-part-and-strip)
923 ("delete part" . gnus-mime-delete-part)
924 ("display as text" . gnus-mime-inline-part)
925 ("view the part" . gnus-mime-view-part)
926 ("pipe to command" . gnus-mime-pipe-part)
927 ("toggle display" . gnus-article-press-button)
928 ("toggle display" . gnus-article-view-part-as-charset)
929 ("view as type" . gnus-mime-view-part-as-type)
930 ("view internally" . gnus-mime-view-part-internally)
931 ("view externally" . gnus-mime-view-part-externally))
932 "An alist of actions that run on the MIME attachment."
933 :group 'gnus-article-mime
934 :type '(repeat (cons (string :tag "name")
937 (defcustom gnus-auto-select-part 1
938 "Advance to next MIME part when deleting or stripping parts.
940 When 0, point will be placed on the same part as before. When
941 positive (negative), move point forward (backwards) this many
942 parts. When nil, redisplay article."
943 :version "23.0" ;; No Gnus
944 :group 'gnus-article-mime
945 :type '(choice (const nil :tag "Redisplay article.")
946 (const 1 :tag "Next part.")
947 (const 0 :tag "Current part.")
951 ;;; The treatment variables
954 (defvar gnus-part-display-hook nil
955 "Hook called on parts that are to receive treatment.")
957 (defvar gnus-article-treat-custom
958 '(choice (const :tag "Off" nil)
960 (const :tag "Header" head)
961 (const :tag "Last" last)
962 (integer :tag "Less")
963 (repeat :tag "Groups" regexp)
964 (sexp :tag "Predicate")))
966 (defvar gnus-article-treat-head-custom
967 '(choice (const :tag "Off" nil)
968 (const :tag "Header" head)))
970 (defvar gnus-article-treat-types '("text/plain")
973 (defvar gnus-inhibit-treatment nil
974 "Whether to inhibit treatment.")
976 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
977 "Highlight the signature.
978 Valid values are nil, t, `head', `last', an integer or a predicate.
979 See Info node `(gnus)Customizing Articles'."
980 :group 'gnus-article-treat
981 :link '(custom-manual "(gnus)Customizing Articles")
982 :type gnus-article-treat-custom)
983 (put 'gnus-treat-highlight-signature 'highlight t)
985 (defcustom gnus-treat-buttonize 100000
987 Valid values are nil, t, `head', `last', an integer or a predicate.
988 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-buttonize 'highlight t)
994 (defcustom gnus-treat-buttonize-head 'head
995 "Add buttons to the head.
996 Valid values are nil, t, `head', `last', an integer or a predicate.
997 See Info node `(gnus)Customizing Articles' for details."
998 :group 'gnus-article-treat
999 :link '(custom-manual "(gnus)Customizing Articles")
1000 :type gnus-article-treat-head-custom)
1001 (put 'gnus-treat-buttonize-head 'highlight t)
1003 (defcustom gnus-treat-emphasize
1004 (and (or window-system
1008 Valid values are nil, t, `head', `last', an integer or a predicate.
1009 See Info node `(gnus)Customizing Articles' for details."
1010 :group 'gnus-article-treat
1011 :link '(custom-manual "(gnus)Customizing Articles")
1012 :type gnus-article-treat-custom)
1013 (put 'gnus-treat-emphasize 'highlight t)
1015 (defcustom gnus-treat-strip-cr nil
1016 "Remove carriage returns.
1017 Valid values are nil, t, `head', `last', an integer or a predicate.
1018 See Info node `(gnus)Customizing Articles' for details."
1020 :group 'gnus-article-treat
1021 :link '(custom-manual "(gnus)Customizing Articles")
1022 :type gnus-article-treat-custom)
1024 (defcustom gnus-treat-unsplit-urls nil
1025 "Remove newlines from within URLs.
1026 Valid values are nil, t, `head', `last', an integer or a predicate.
1027 See Info node `(gnus)Customizing Articles' for details."
1029 :group 'gnus-article-treat
1030 :link '(custom-manual "(gnus)Customizing Articles")
1031 :type gnus-article-treat-custom)
1033 (defcustom gnus-treat-leading-whitespace nil
1034 "Remove leading whitespace in headers.
1035 Valid values are nil, t, `head', `last', an integer or a predicate.
1036 See Info node `(gnus)Customizing Articles' for details."
1038 :group 'gnus-article-treat
1039 :link '(custom-manual "(gnus)Customizing Articles")
1040 :type gnus-article-treat-custom)
1042 (defcustom gnus-treat-hide-headers 'head
1044 Valid values are nil, t, `head', `last', an integer or a predicate.
1045 See Info node `(gnus)Customizing Articles' for details."
1046 :group 'gnus-article-treat
1047 :link '(custom-manual "(gnus)Customizing Articles")
1048 :type gnus-article-treat-head-custom)
1050 (defcustom gnus-treat-hide-boring-headers nil
1051 "Hide boring headers.
1052 Valid values are nil, t, `head', `last', an integer or a predicate.
1053 See Info node `(gnus)Customizing Articles' for details."
1054 :group 'gnus-article-treat
1055 :link '(custom-manual "(gnus)Customizing Articles")
1056 :type gnus-article-treat-head-custom)
1058 (defcustom gnus-treat-hide-signature nil
1059 "Hide the signature.
1060 Valid values are nil, t, `head', `last', an integer or a predicate.
1061 See Info node `(gnus)Customizing Articles' for details."
1062 :group 'gnus-article-treat
1063 :link '(custom-manual "(gnus)Customizing Articles")
1064 :type gnus-article-treat-custom)
1066 (defcustom gnus-treat-fill-article nil
1068 Valid values are nil, t, `head', `last', an integer or a predicate.
1069 See Info node `(gnus)Customizing Articles' for details."
1070 :group 'gnus-article-treat
1071 :link '(custom-manual "(gnus)Customizing Articles")
1072 :type gnus-article-treat-custom)
1074 (defcustom gnus-treat-hide-citation nil
1076 Valid values are nil, t, `head', `last', an integer or a predicate.
1077 See Info node `(gnus)Customizing Articles' for details."
1078 :group 'gnus-article-treat
1079 :link '(custom-manual "(gnus)Customizing Articles")
1080 :type gnus-article-treat-custom)
1082 (defcustom gnus-treat-hide-citation-maybe nil
1084 Valid values are nil, t, `head', `last', an integer or a predicate.
1085 See Info node `(gnus)Customizing Articles' for details."
1086 :group 'gnus-article-treat
1087 :link '(custom-manual "(gnus)Customizing Articles")
1088 :type gnus-article-treat-custom)
1090 (defcustom gnus-treat-strip-list-identifiers 'head
1091 "Strip list identifiers from `gnus-list-identifiers`.
1092 Valid values are nil, t, `head', `last', an integer or a predicate.
1093 See Info node `(gnus)Customizing Articles' for details."
1095 :group 'gnus-article-treat
1096 :link '(custom-manual "(gnus)Customizing Articles")
1097 :type gnus-article-treat-custom)
1099 (make-obsolete-variable 'gnus-treat-strip-pgp
1100 "This option is obsolete in Gnus 5.10.")
1102 (defcustom gnus-treat-strip-pem nil
1103 "Strip PEM signatures.
1104 Valid values are nil, t, `head', `last', an integer or a predicate.
1105 See Info node `(gnus)Customizing Articles' for details."
1106 :group 'gnus-article-treat
1107 :link '(custom-manual "(gnus)Customizing Articles")
1108 :type gnus-article-treat-custom)
1110 (defcustom gnus-treat-strip-banner t
1111 "Strip banners from articles.
1112 The banner to be stripped is specified in the `banner' group parameter.
1113 Valid values are nil, t, `head', `last', an integer or a predicate.
1114 See Info node `(gnus)Customizing Articles' for details."
1115 :group 'gnus-article-treat
1116 :link '(custom-manual "(gnus)Customizing Articles")
1117 :type gnus-article-treat-custom)
1119 (defcustom gnus-treat-highlight-headers 'head
1120 "Highlight the headers.
1121 Valid values are nil, t, `head', `last', an integer or a predicate.
1122 See Info node `(gnus)Customizing Articles' for details."
1123 :group 'gnus-article-treat
1124 :link '(custom-manual "(gnus)Customizing Articles")
1125 :type gnus-article-treat-head-custom)
1126 (put 'gnus-treat-highlight-headers 'highlight t)
1128 (defcustom gnus-treat-highlight-citation t
1129 "Highlight cited text.
1130 Valid values are nil, t, `head', `last', an integer or a predicate.
1131 See Info node `(gnus)Customizing Articles' for details."
1132 :group 'gnus-article-treat
1133 :link '(custom-manual "(gnus)Customizing Articles")
1134 :type gnus-article-treat-custom)
1135 (put 'gnus-treat-highlight-citation 'highlight t)
1137 (defcustom gnus-treat-date-ut nil
1138 "Display the Date in UT (GMT).
1139 Valid values are nil, t, `head', `last', an integer or a predicate.
1140 See Info node `(gnus)Customizing Articles' for details."
1141 :group 'gnus-article-treat
1142 :link '(custom-manual "(gnus)Customizing Articles")
1143 :type gnus-article-treat-head-custom)
1145 (defcustom gnus-treat-date-local nil
1146 "Display the Date in the local timezone.
1147 Valid values are nil, t, `head', `last', an integer or a predicate.
1148 See Info node `(gnus)Customizing Articles' for details."
1149 :group 'gnus-article-treat
1150 :link '(custom-manual "(gnus)Customizing Articles")
1151 :type gnus-article-treat-head-custom)
1153 (defcustom gnus-treat-date-english nil
1154 "Display the Date in a format that can be read aloud in English.
1155 Valid values are nil, t, `head', `last', an integer or a predicate.
1156 See Info node `(gnus)Customizing Articles' for details."
1158 :group 'gnus-article-treat
1159 :link '(custom-manual "(gnus)Customizing Articles")
1160 :type gnus-article-treat-head-custom)
1162 (defcustom gnus-treat-date-lapsed nil
1163 "Display the Date header in a way that says how much time has elapsed.
1164 Valid values are nil, t, `head', `last', an integer or a predicate.
1165 See Info node `(gnus)Customizing Articles' for details."
1166 :group 'gnus-article-treat
1167 :link '(custom-manual "(gnus)Customizing Articles")
1168 :type gnus-article-treat-head-custom)
1170 (defcustom gnus-treat-date-original nil
1171 "Display the date in the original timezone.
1172 Valid values are nil, t, `head', `last', an integer or a predicate.
1173 See Info node `(gnus)Customizing Articles' for details."
1174 :group 'gnus-article-treat
1175 :link '(custom-manual "(gnus)Customizing Articles")
1176 :type gnus-article-treat-head-custom)
1178 (defcustom gnus-treat-date-iso8601 nil
1179 "Display the date in the ISO8601 format.
1180 Valid values are nil, t, `head', `last', an integer or a predicate.
1181 See Info node `(gnus)Customizing Articles' for details."
1183 :group 'gnus-article-treat
1184 :link '(custom-manual "(gnus)Customizing Articles")
1185 :type gnus-article-treat-head-custom)
1187 (defcustom gnus-treat-date-user-defined nil
1188 "Display the date in a user-defined format.
1189 The format is defined by the `gnus-article-time-format' variable.
1190 Valid values are nil, t, `head', `last', an integer or a predicate.
1191 See Info node `(gnus)Customizing Articles' for details."
1192 :group 'gnus-article-treat
1193 :link '(custom-manual "(gnus)Customizing Articles")
1194 :type gnus-article-treat-head-custom)
1196 (defcustom gnus-treat-strip-headers-in-body t
1197 "Strip the X-No-Archive header line from the beginning of the body.
1198 Valid values are nil, t, `head', `last', an integer or a predicate.
1199 See Info node `(gnus)Customizing Articles' for details."
1201 :group 'gnus-article-treat
1202 :link '(custom-manual "(gnus)Customizing Articles")
1203 :type gnus-article-treat-custom)
1205 (defcustom gnus-treat-strip-trailing-blank-lines nil
1206 "Strip trailing blank lines.
1207 Valid values are nil, t, `head', `last', an integer or a predicate.
1208 See Info node `(gnus)Customizing Articles' for details."
1209 :group 'gnus-article-treat
1210 :link '(custom-manual "(gnus)Customizing Articles")
1211 :type gnus-article-treat-custom)
1213 (defcustom gnus-treat-strip-leading-blank-lines nil
1214 "Strip leading blank lines.
1215 Valid values are nil, t, `head', `last', an integer or a predicate.
1216 See Info node `(gnus)Customizing Articles' for details."
1217 :group 'gnus-article-treat
1218 :link '(custom-manual "(gnus)Customizing Articles")
1219 :type gnus-article-treat-custom)
1221 (defcustom gnus-treat-strip-multiple-blank-lines nil
1222 "Strip multiple blank lines.
1223 Valid values are nil, t, `head', `last', an integer or a predicate.
1224 See Info node `(gnus)Customizing Articles' for details."
1225 :group 'gnus-article-treat
1226 :link '(custom-manual "(gnus)Customizing Articles")
1227 :type gnus-article-treat-custom)
1229 (defcustom gnus-treat-unfold-headers 'head
1230 "Unfold folded header lines.
1231 Valid values are nil, t, `head', `last', an integer or a predicate.
1232 See Info node `(gnus)Customizing Articles' for details."
1234 :group 'gnus-article-treat
1235 :link '(custom-manual "(gnus)Customizing Articles")
1236 :type gnus-article-treat-custom)
1238 (defcustom gnus-treat-fold-headers nil
1240 Valid values are nil, t, `head', `last', an integer or a predicate.
1241 See Info node `(gnus)Customizing Articles' for details."
1243 :group 'gnus-article-treat
1244 :link '(custom-manual "(gnus)Customizing Articles")
1245 :type gnus-article-treat-custom)
1247 (defcustom gnus-treat-fold-newsgroups 'head
1248 "Fold the Newsgroups and Followup-To headers.
1249 Valid values are nil, t, `head', `last', an integer or a predicate.
1250 See Info node `(gnus)Customizing Articles' for details."
1252 :group 'gnus-article-treat
1253 :link '(custom-manual "(gnus)Customizing Articles")
1254 :type gnus-article-treat-custom)
1256 (defcustom gnus-treat-overstrike t
1257 "Treat overstrike highlighting.
1258 Valid values are nil, t, `head', `last', an integer or a predicate.
1259 See Info node `(gnus)Customizing Articles' for details."
1260 :group 'gnus-article-treat
1261 :link '(custom-manual "(gnus)Customizing Articles")
1262 :type gnus-article-treat-custom)
1263 (put 'gnus-treat-overstrike 'highlight t)
1265 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1266 "Treat ANSI SGR control sequences.
1267 Valid values are nil, t, `head', `last', an integer or a predicate.
1268 See Info node `(gnus)Customizing Articles' for details."
1269 :group 'gnus-article-treat
1270 :link '(custom-manual "(gnus)Customizing Articles")
1271 :type gnus-article-treat-custom)
1273 (make-obsolete-variable 'gnus-treat-display-xface
1274 'gnus-treat-display-x-face)
1276 (defcustom gnus-treat-display-x-face
1277 (and (not noninteractive)
1278 (or (and (fboundp 'image-type-available-p)
1279 (image-type-available-p 'xbm)
1280 (string-match "^0x" (shell-command-to-string "uncompface"))
1281 (executable-find "icontopbm"))
1282 (and (featurep 'xemacs)
1285 "Display X-Face headers.
1286 Valid values are nil, t, `head', `last', an integer or a predicate.
1287 See Info node `(gnus)Customizing Articles' and Info node
1288 `(gnus)X-Face' for details."
1289 :group 'gnus-article-treat
1291 :link '(custom-manual "(gnus)Customizing Articles")
1292 :link '(custom-manual "(gnus)X-Face")
1293 :type gnus-article-treat-head-custom
1294 :set (lambda (symbol value)
1297 (cond ((or (boundp symbol) (get symbol 'saved-value))
1299 ((boundp 'gnus-treat-display-xface)
1301 ** gnus-treat-display-xface is an obsolete variable;\
1302 use gnus-treat-display-x-face instead")
1303 (default-value 'gnus-treat-display-xface))
1304 ((get 'gnus-treat-display-xface 'saved-value)
1306 ** gnus-treat-display-xface is an obsolete variable;\
1307 use gnus-treat-display-x-face instead")
1308 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1311 (put 'gnus-treat-display-x-face 'highlight t)
1313 (defcustom gnus-treat-display-face
1314 (and (not noninteractive)
1315 (or (and (fboundp 'image-type-available-p)
1316 (image-type-available-p 'png))
1317 (and (featurep 'xemacs)
1320 "Display Face headers.
1321 Valid values are nil, t, `head', `last', an integer or a predicate.
1322 See Info node `(gnus)Customizing Articles' and Info node
1323 `(gnus)X-Face' for details."
1324 :group 'gnus-article-treat
1326 :link '(custom-manual "(gnus)Customizing Articles")
1327 :link '(custom-manual "(gnus)X-Face")
1328 :type gnus-article-treat-head-custom)
1329 (put 'gnus-treat-display-face 'highlight t)
1331 (defcustom gnus-treat-display-smileys
1332 (if (or (and (featurep 'xemacs)
1334 (and (fboundp 'image-type-available-p)
1335 (image-type-available-p 'pbm)))
1338 Valid values are nil, t, `head', `last', an integer or a predicate.
1339 See Info node `(gnus)Customizing Articles' and Info node
1340 `(gnus)Smileys' for details."
1341 :group 'gnus-article-treat
1343 :link '(custom-manual "(gnus)Customizing Articles")
1344 :link '(custom-manual "(gnus)Smileys")
1345 :type gnus-article-treat-custom)
1346 (put 'gnus-treat-display-smileys 'highlight t)
1348 (defcustom gnus-treat-from-picon
1349 (if (and (gnus-image-type-available-p 'xpm)
1350 (gnus-picons-installed-p))
1352 "Display picons in the From header.
1353 Valid values are nil, t, `head', `last', an integer or a predicate.
1354 See Info node `(gnus)Customizing Articles' and Info node
1355 `(gnus)Picons' for details."
1357 :group 'gnus-article-treat
1359 :link '(custom-manual "(gnus)Customizing Articles")
1360 :link '(custom-manual "(gnus)Picons")
1361 :type gnus-article-treat-head-custom)
1362 (put 'gnus-treat-from-picon 'highlight t)
1364 (defcustom gnus-treat-mail-picon
1365 (if (and (gnus-image-type-available-p 'xpm)
1366 (gnus-picons-installed-p))
1368 "Display picons in To and Cc headers.
1369 Valid values are nil, t, `head', `last', an integer or a predicate.
1370 See Info node `(gnus)Customizing Articles' and Info node
1371 `(gnus)Picons' for details."
1373 :group 'gnus-article-treat
1375 :link '(custom-manual "(gnus)Customizing Articles")
1376 :link '(custom-manual "(gnus)Picons")
1377 :type gnus-article-treat-head-custom)
1378 (put 'gnus-treat-mail-picon 'highlight t)
1380 (defcustom gnus-treat-newsgroups-picon
1381 (if (and (gnus-image-type-available-p 'xpm)
1382 (gnus-picons-installed-p))
1384 "Display picons in the Newsgroups and Followup-To headers.
1385 Valid values are nil, t, `head', `last', an integer or a predicate.
1386 See Info node `(gnus)Customizing Articles' and Info node
1387 `(gnus)Picons' for details."
1389 :group 'gnus-article-treat
1391 :link '(custom-manual "(gnus)Customizing Articles")
1392 :link '(custom-manual "(gnus)Picons")
1393 :type gnus-article-treat-head-custom)
1394 (put 'gnus-treat-newsgroups-picon 'highlight t)
1396 (defcustom gnus-treat-body-boundary
1397 (if (and (eq window-system 'x)
1398 (or gnus-treat-newsgroups-picon
1399 gnus-treat-mail-picon
1400 gnus-treat-from-picon))
1402 "Draw a boundary at the end of the headers.
1403 Valid values are nil and `head'.
1404 See Info node `(gnus)Customizing Articles' for details."
1406 :group 'gnus-article-treat
1407 :link '(custom-manual "(gnus)Customizing Articles")
1408 :type gnus-article-treat-head-custom)
1410 (defcustom gnus-treat-capitalize-sentences nil
1411 "Capitalize sentence-starting words.
1412 Valid values are nil, t, `head', `last', an integer or a predicate.
1413 See Info node `(gnus)Customizing Articles' for details."
1415 :group 'gnus-article-treat
1416 :link '(custom-manual "(gnus)Customizing Articles")
1417 :type gnus-article-treat-custom)
1419 (defcustom gnus-treat-wash-html nil
1421 Valid values are nil, t, `head', `last', an integer or a predicate.
1422 See Info node `(gnus)Customizing Articles' for details."
1424 :group 'gnus-article-treat
1425 :link '(custom-manual "(gnus)Customizing Articles")
1426 :type gnus-article-treat-custom)
1428 (defcustom gnus-treat-fill-long-lines nil
1430 Valid values are nil, t, `head', `last', an integer or a predicate.
1431 See Info node `(gnus)Customizing Articles' for details."
1432 :group 'gnus-article-treat
1433 :link '(custom-manual "(gnus)Customizing Articles")
1434 :type gnus-article-treat-custom)
1436 (defcustom gnus-treat-play-sounds nil
1438 Valid values are nil, t, `head', `last', an integer or a predicate.
1439 See Info node `(gnus)Customizing Articles' for details."
1441 :group 'gnus-article-treat
1442 :link '(custom-manual "(gnus)Customizing Articles")
1443 :type gnus-article-treat-custom)
1445 (defcustom gnus-treat-translate nil
1446 "Translate articles from one language to another.
1447 Valid values are nil, t, `head', `last', an integer or a predicate.
1448 See Info node `(gnus)Customizing Articles' for details."
1450 :group 'gnus-article-treat
1451 :link '(custom-manual "(gnus)Customizing Articles")
1452 :type gnus-article-treat-custom)
1454 (defcustom gnus-treat-x-pgp-sig nil
1456 To automatically treat X-PGP-Sig, set it to head.
1457 Valid values are nil, t, `head', `last', an integer or a predicate.
1458 See Info node `(gnus)Customizing Articles' for details."
1460 :group 'gnus-article-treat
1461 :group 'mime-security
1462 :link '(custom-manual "(gnus)Customizing Articles")
1463 :type gnus-article-treat-custom)
1465 (defvar gnus-article-encrypt-protocol-alist
1466 '(("PGP" . mml2015-self-encrypt)))
1468 ;; Set to nil if more than one protocol added to
1469 ;; gnus-article-encrypt-protocol-alist.
1470 (defcustom gnus-article-encrypt-protocol "PGP"
1471 "The protocol used for encrypt articles.
1472 It is a string, such as \"PGP\". If nil, ask user."
1475 :group 'mime-security)
1477 (defvar gnus-article-wash-function nil
1478 "Function used for converting HTML into text.")
1480 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1481 (mm-coding-system-p 'utf-8)
1482 (executable-find idna-program))
1483 "Whether IDNA decoding of headers is used when viewing messages.
1484 This requires GNU Libidn, and by default only enabled if it is found."
1486 :group 'gnus-article-headers
1489 (defcustom gnus-article-over-scroll nil
1490 "If non-nil, allow scrolling the article buffer even when there no more text."
1492 :group 'gnus-article
1495 ;;; Internal variables
1497 (defvar gnus-english-month-names
1498 '("January" "February" "March" "April" "May" "June" "July" "August"
1499 "September" "October" "November" "December"))
1501 (defvar gnus-button-regexp nil)
1502 (defvar gnus-button-marker-list nil)
1503 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1505 (defvar gnus-button-last nil)
1506 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1508 (defvar article-goto-body-goes-to-point-min-p nil)
1509 (defvar gnus-article-wash-types nil)
1510 (defvar gnus-article-emphasis-alist nil)
1511 (defvar gnus-article-image-alist nil)
1513 (defvar gnus-article-mime-handle-alist-1 nil)
1514 (defvar gnus-treatment-function-alist
1515 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1516 (gnus-treat-strip-banner gnus-article-strip-banner)
1517 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1518 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1519 (gnus-treat-buttonize gnus-article-add-buttons)
1520 (gnus-treat-fill-article gnus-article-fill-cited-article)
1521 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1522 (gnus-treat-strip-cr gnus-article-remove-cr)
1523 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1524 (gnus-treat-date-ut gnus-article-date-ut)
1525 (gnus-treat-date-local gnus-article-date-local)
1526 (gnus-treat-date-english gnus-article-date-english)
1527 (gnus-treat-date-original gnus-article-date-original)
1528 (gnus-treat-date-user-defined gnus-article-date-user)
1529 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1530 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1531 (gnus-treat-display-x-face gnus-article-display-x-face)
1532 (gnus-treat-display-face gnus-article-display-face)
1533 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1534 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1535 (gnus-treat-hide-signature gnus-article-hide-signature)
1536 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1537 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1538 (gnus-treat-strip-pem gnus-article-hide-pem)
1539 (gnus-treat-from-picon gnus-treat-from-picon)
1540 (gnus-treat-mail-picon gnus-treat-mail-picon)
1541 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1542 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1543 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1544 (gnus-treat-strip-trailing-blank-lines
1545 gnus-article-remove-trailing-blank-lines)
1546 (gnus-treat-strip-leading-blank-lines
1547 gnus-article-strip-leading-blank-lines)
1548 (gnus-treat-strip-multiple-blank-lines
1549 gnus-article-strip-multiple-blank-lines)
1550 (gnus-treat-overstrike gnus-article-treat-overstrike)
1551 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1552 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1553 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1554 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1555 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1556 (gnus-treat-display-smileys gnus-treat-smiley)
1557 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1558 (gnus-treat-wash-html gnus-article-wash-html)
1559 (gnus-treat-emphasize gnus-article-emphasize)
1560 (gnus-treat-hide-citation gnus-article-hide-citation)
1561 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1562 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1563 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1564 (gnus-treat-play-sounds gnus-earcon-display)))
1566 (defvar gnus-article-mime-handle-alist nil)
1567 (defvar article-lapsed-timer nil)
1568 (defvar gnus-article-current-summary nil)
1570 (defvar gnus-article-mode-syntax-table
1571 (let ((table (copy-syntax-table text-mode-syntax-table)))
1572 ;; This causes the citation match run O(2^n).
1573 ;; (modify-syntax-entry ?- "w" table)
1574 (modify-syntax-entry ?> ")<" table)
1575 (modify-syntax-entry ?< "(>" table)
1576 ;; make M-. in article buffers work for `foo' strings
1577 (modify-syntax-entry ?' " " table)
1578 (modify-syntax-entry ?` " " table)
1580 "Syntax table used in article mode buffers.
1581 Initialized from `text-mode-syntax-table.")
1583 (defvar gnus-save-article-buffer nil)
1585 (defvar gnus-article-mode-line-format-alist
1586 (nconc '((?w (gnus-article-wash-status) ?s)
1587 (?m (gnus-article-mime-part-status) ?s))
1588 gnus-summary-mode-line-format-alist))
1590 (defvar gnus-number-of-articles-to-be-saved nil)
1592 (defvar gnus-inhibit-hiding nil)
1594 (defvar gnus-article-edit-mode nil)
1596 ;;; Macros for dealing with the article buffer.
1598 (defmacro gnus-with-article-headers (&rest forms)
1600 (set-buffer gnus-article-buffer)
1602 (let ((inhibit-read-only t)
1603 (inhibit-point-motion-hooks t)
1604 (case-fold-search t))
1605 (article-narrow-to-head)
1608 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1609 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1611 (defmacro gnus-with-article-buffer (&rest forms)
1613 (set-buffer gnus-article-buffer)
1614 (let ((inhibit-read-only t))
1617 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1618 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1620 (defun gnus-article-goto-header (header)
1621 "Go to HEADER, which is a regular expression."
1622 (re-search-forward (concat "^\\(" header "\\):") nil t))
1624 (defsubst gnus-article-hide-text (b e props)
1625 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1626 (gnus-add-text-properties-when 'article-type nil b e props)
1627 (when (memq 'intangible props)
1629 (max (1- b) (point-min))
1630 b 'intangible (cddr (memq 'intangible props)))))
1632 (defsubst gnus-article-unhide-text (b e)
1633 "Remove hidden text properties from region between B and E."
1634 (remove-text-properties b e gnus-hidden-properties)
1635 (when (memq 'intangible gnus-hidden-properties)
1636 (put-text-property (max (1- b) (point-min))
1637 b 'intangible nil)))
1639 (defun gnus-article-hide-text-type (b e type)
1640 "Hide text of TYPE between B and E."
1641 (gnus-add-wash-type type)
1642 (gnus-article-hide-text
1643 b e (cons 'article-type (cons type gnus-hidden-properties))))
1645 (defun gnus-article-unhide-text-type (b e type)
1646 "Unhide text of TYPE between B and E."
1647 (gnus-delete-wash-type type)
1648 (remove-text-properties
1649 b e (cons 'article-type (cons type gnus-hidden-properties)))
1650 (when (memq 'intangible gnus-hidden-properties)
1651 (put-text-property (max (1- b) (point-min))
1652 b 'intangible nil)))
1654 (defun gnus-article-hide-text-of-type (type)
1655 "Hide text of TYPE in the current buffer."
1657 (let ((b (point-min))
1659 (while (setq b (text-property-any b e 'article-type type))
1660 (add-text-properties b (incf b) gnus-hidden-properties)))))
1662 (defun gnus-article-delete-text-of-type (type)
1663 "Delete text of TYPE in the current buffer."
1665 (let ((b (point-min)))
1666 (while (setq b (text-property-any b (point-max) 'article-type type))
1668 b (or (text-property-not-all b (point-max) 'article-type type)
1671 (defun gnus-article-delete-invisible-text ()
1672 "Delete all invisible text in the current buffer."
1674 (let ((b (point-min)))
1675 (while (setq b (text-property-any b (point-max) 'invisible t))
1677 b (or (text-property-not-all b (point-max) 'invisible t)
1680 (defun gnus-article-text-type-exists-p (type)
1681 "Say whether any text of type TYPE exists in the buffer."
1682 (text-property-any (point-min) (point-max) 'article-type type))
1684 (defsubst gnus-article-header-rank ()
1685 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1686 (let ((list gnus-sorted-header-list)
1689 (if (looking-at (car list))
1691 (setq list (cdr list))
1695 (defun article-hide-headers (&optional arg delete)
1696 "Hide unwanted headers and possibly sort them as well."
1698 ;; This function might be inhibited.
1699 (unless gnus-inhibit-hiding
1700 (let ((inhibit-read-only nil)
1701 (case-fold-search t)
1702 (max (1+ (length gnus-sorted-header-list)))
1703 (inhibit-point-motion-hooks t)
1704 (cur (current-buffer))
1705 ignored visible beg)
1707 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1708 ;; group parameters, so we should go to the summary buffer.
1711 (progn (set-buffer gnus-summary-buffer) t)
1713 (setq ignored (when (not gnus-visible-headers)
1714 (cond ((stringp gnus-ignored-headers)
1715 gnus-ignored-headers)
1716 ((listp gnus-ignored-headers)
1717 (mapconcat 'identity
1718 gnus-ignored-headers
1720 visible (cond ((stringp gnus-visible-headers)
1721 gnus-visible-headers)
1722 ((and gnus-visible-headers
1723 (listp gnus-visible-headers))
1724 (mapconcat 'identity
1725 gnus-visible-headers
1729 ;; First we narrow to just the headers.
1730 (article-narrow-to-head)
1731 ;; Hide any "From " lines at the beginning of (mail) articles.
1732 (while (looking-at "From ")
1735 (delete-region (point-min) (point)))
1736 ;; Then treat the rest of the header lines.
1737 ;; Then we use the two regular expressions
1738 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1739 ;; select which header lines is to remain visible in the
1741 (while (re-search-forward "^[^ \t:]*:" nil t)
1743 ;; Mark the rank of the header.
1745 (point) (1+ (point)) 'message-rank
1746 (if (or (and visible (looking-at visible))
1748 (not (looking-at ignored))))
1749 (gnus-article-header-rank)
1752 (message-sort-headers-1)
1753 (when (setq beg (text-property-any
1754 (point-min) (point-max) 'message-rank (+ 2 max)))
1755 ;; We delete the unwanted headers.
1756 (gnus-add-wash-type 'headers)
1757 (add-text-properties (point-min) (+ 5 (point-min))
1758 '(article-type headers dummy-invisible t))
1759 (delete-region beg (point-max))))))))
1761 (defun article-hide-boring-headers (&optional arg)
1762 "Toggle hiding of headers that aren't very interesting.
1763 If given a negative prefix, always show; if given a positive prefix,
1765 (interactive (gnus-article-hidden-arg))
1766 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1767 (not gnus-show-all-headers))
1770 (let ((inhibit-read-only t)
1771 (inhibit-point-motion-hooks t))
1772 (article-narrow-to-head)
1773 (dolist (elem gnus-boring-article-headers)
1774 (goto-char (point-min))
1776 ;; Hide empty headers.
1778 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1780 (gnus-article-hide-text-type
1784 (if (re-search-forward "^[^ \t]" nil t)
1788 ;; Hide boring Newsgroups header.
1789 ((eq elem 'newsgroups)
1790 (when (gnus-string-equal
1791 (gnus-fetch-field "newsgroups")
1792 (gnus-group-real-name
1793 (if (boundp 'gnus-newsgroup-name)
1796 (gnus-article-hide-header "newsgroups")))
1797 ((eq elem 'to-address)
1798 (let ((to (message-fetch-field "to"))
1800 (gnus-parameter-to-address
1801 (if (boundp 'gnus-newsgroup-name)
1802 gnus-newsgroup-name ""))))
1803 (when (and to to-address
1806 ;; only one address in To
1807 (nth 1 (mail-extract-address-components to))
1809 (gnus-article-hide-header "to"))))
1811 (let ((to (message-fetch-field "to"))
1813 (gnus-parameter-to-list
1814 (if (boundp 'gnus-newsgroup-name)
1815 gnus-newsgroup-name ""))))
1816 (when (and to to-list
1819 ;; only one address in To
1820 (nth 1 (mail-extract-address-components to))
1822 (gnus-article-hide-header "to"))))
1824 (let ((cc (message-fetch-field "cc"))
1826 (gnus-parameter-to-list
1827 (if (boundp 'gnus-newsgroup-name)
1828 gnus-newsgroup-name ""))))
1829 (when (and cc to-list
1832 ;; only one address in CC
1833 (nth 1 (mail-extract-address-components cc))
1835 (gnus-article-hide-header "cc"))))
1836 ((eq elem 'followup-to)
1837 (when (gnus-string-equal
1838 (message-fetch-field "followup-to")
1839 (message-fetch-field "newsgroups"))
1840 (gnus-article-hide-header "followup-to")))
1841 ((eq elem 'reply-to)
1842 (if (gnus-group-find-parameter
1843 gnus-newsgroup-name 'broken-reply-to)
1844 (gnus-article-hide-header "reply-to")
1845 (let ((from (message-fetch-field "from"))
1846 (reply-to (message-fetch-field "reply-to")))
1853 (lambda (x) (downcase (cadr x)))
1854 (mail-extract-address-components from t))
1857 (lambda (x) (downcase (cadr x)))
1858 (mail-extract-address-components reply-to t))
1860 (gnus-article-hide-header "reply-to")))))
1862 (let ((date (message-fetch-field "date")))
1864 (< (days-between (current-time-string) date)
1866 (gnus-article-hide-header "date"))))
1868 (let ((to (message-fetch-field "to"))
1869 (cc (message-fetch-field "cc")))
1870 (when (> (length to) 1024)
1871 (gnus-article-hide-header "to"))
1872 (when (> (length cc) 1024)
1873 (gnus-article-hide-header "cc"))))
1877 (goto-char (point-min))
1878 (while (re-search-forward "^to:" nil t)
1879 (setq to-count (1+ to-count)))
1880 (when (> to-count 1)
1881 (while (> to-count 0)
1882 (goto-char (point-min))
1884 (re-search-forward "^to:" nil nil to-count)
1886 (narrow-to-region (point) (point-max))
1887 (gnus-article-hide-header "to"))
1888 (setq to-count (1- to-count))))
1889 (goto-char (point-min))
1890 (while (re-search-forward "^cc:" nil t)
1891 (setq cc-count (1+ cc-count)))
1892 (when (> cc-count 1)
1893 (while (> cc-count 0)
1894 (goto-char (point-min))
1896 (re-search-forward "^cc:" nil nil cc-count)
1898 (narrow-to-region (point) (point-max))
1899 (gnus-article-hide-header "cc"))
1900 (setq cc-count (1- cc-count)))))))))))))
1902 (defun gnus-article-hide-header (header)
1904 (goto-char (point-min))
1905 (when (re-search-forward (concat "^" header ":") nil t)
1906 (gnus-article-hide-text-type
1910 (if (re-search-forward "^[^ \t]" nil t)
1915 (defvar gnus-article-normalized-header-length 40
1916 "Length of normalized headers.")
1918 (defun article-normalize-headers ()
1919 "Make all header lines 40 characters long."
1921 (let ((inhibit-read-only t)
1925 (article-narrow-to-head)
1928 ((< (setq column (- (point-at-eol) (point)))
1929 gnus-article-normalized-header-length)
1931 (insert (make-string
1932 (- gnus-article-normalized-header-length column)
1934 ((> column gnus-article-normalized-header-length)
1935 (gnus-put-text-property
1937 (forward-char gnus-article-normalized-header-length)
1944 (forward-line 1))))))
1946 (defun article-treat-dumbquotes ()
1947 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1948 Note that this function guesses whether a character is a sm*rtq**t* or
1949 not, so it should only be used interactively.
1951 Sm*rtq**t*s are M****s***'s unilateral extension to the
1952 iso-8859-1 character map in an attempt to provide more quoting
1953 characters. If you see something like \\222 or \\264 where
1954 you're expecting some kind of apostrophe or quotation mark, then
1957 (article-translate-strings gnus-article-dumbquotes-map))
1959 (defun article-translate-characters (from to)
1960 "Translate all characters in the body of the article according to FROM and TO.
1961 FROM is a string of characters to translate from; to is a string of
1962 characters to translate to."
1964 (when (article-goto-body)
1965 (let ((inhibit-read-only t)
1966 (x (make-string 225 ?x))
1968 (while (< (incf i) (length x))
1971 (while (< i (length from))
1972 (aset x (aref from i) (aref to i))
1974 (translate-region (point) (point-max) x)))))
1976 (defun article-translate-strings (map)
1977 "Translate all string in the body of the article according to MAP.
1978 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1980 (when (article-goto-body)
1981 (let ((inhibit-read-only t))
1984 (while (search-forward (car elem) nil t)
1985 (replace-match (cadr elem)))))))))
1987 (defun article-treat-overstrike ()
1988 "Translate overstrikes into bold text."
1991 (when (article-goto-body)
1992 (let ((inhibit-read-only t))
1993 (while (search-forward "\b" nil t)
1994 (let ((next (char-after))
1995 (previous (char-after (- (point) 2))))
1996 ;; We do the boldification/underlining by hiding the
1997 ;; overstrikes and putting the proper text property
2001 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2002 (put-text-property (point) (1+ (point)) 'face 'bold))
2004 (gnus-article-hide-text-type
2005 (1- (point)) (1+ (point)) 'overstrike)
2007 (- (point) 2) (1- (point)) 'face 'underline))
2009 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2011 (point) (1+ (point)) 'face 'underline)))))))))
2013 (defun article-treat-ansi-sequences ()
2014 "Translate ANSI SGR control sequences into overlays or extents."
2017 (when (article-goto-body)
2018 (let ((inhibit-read-only t))
2019 (ansi-color-apply-on-region (point) (point-max))))))
2021 (defun gnus-article-treat-unfold-headers ()
2022 "Unfold folded message headers.
2023 Only the headers that fit into the current window width will be
2026 (gnus-with-article-headers
2030 (mail-header-narrow-to-field)
2031 (let ((header (buffer-string)))
2034 (goto-char (point-min))
2035 (while (re-search-forward "\n[\t ]" nil t)
2036 (replace-match " " t t)))
2037 (setq length (- (point-max) (point-min) 1)))
2038 (when (< length (window-width))
2039 (while (re-search-forward "\n[\t ]" nil t)
2040 (replace-match " " t t)))
2041 (goto-char (point-max)))))))
2043 (defun gnus-article-treat-fold-headers ()
2044 "Fold message headers."
2046 (gnus-with-article-headers
2049 (mail-header-narrow-to-field)
2050 (mail-header-fold-field)
2051 (goto-char (point-max))))))
2053 (defun gnus-treat-smiley ()
2054 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2056 (gnus-with-article-buffer
2057 (if (memq 'smiley gnus-article-wash-types)
2058 (gnus-delete-images 'smiley)
2060 (let ((images (smiley-region (point) (point-max))))
2062 (gnus-add-wash-type 'smiley)
2063 (dolist (image images)
2064 (gnus-add-image 'smiley image)))))))
2066 (defun gnus-article-remove-images ()
2067 "Remove all images from the article buffer."
2069 (gnus-with-article-buffer
2070 (dolist (elem gnus-article-image-alist)
2071 (gnus-delete-images (car elem)))))
2073 (defun gnus-article-treat-fold-newsgroups ()
2074 "Unfold folded message headers.
2075 Only the headers that fit into the current window width will be
2078 (gnus-with-article-headers
2079 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2081 (mail-header-narrow-to-field)
2082 (while (re-search-forward ", *" nil t)
2083 (replace-match ", " t t))
2084 (mail-header-fold-field)
2085 (goto-char (point-max))))))
2087 (defun gnus-article-treat-body-boundary ()
2088 "Place a boundary line at the end of the headers."
2090 (when (and gnus-body-boundary-delimiter
2091 (> (length gnus-body-boundary-delimiter) 0))
2092 (gnus-with-article-headers
2093 (goto-char (point-max))
2094 (let ((start (point)))
2095 (insert "X-Boundary: ")
2096 (gnus-add-text-properties start (point) '(invisible t intangible t))
2098 (while (>= (1- (window-width)) (length str))
2099 (setq str (concat str gnus-body-boundary-delimiter)))
2100 (substring str 0 (1- (window-width))))
2102 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2104 (defun article-fill-long-lines ()
2105 "Fill lines that are wider than the window width."
2108 (let ((inhibit-read-only t)
2109 (width (window-width (get-buffer-window (current-buffer)))))
2112 (let ((adaptive-fill-mode nil)) ;Why? -sm
2115 (when (>= (current-column) (min fill-column width))
2116 (narrow-to-region (min (1+ (point)) (point-max))
2118 (let ((goback (point-marker)))
2119 (fill-paragraph nil)
2120 (goto-char (marker-position goback)))
2122 (forward-line 1)))))))
2124 (defun article-capitalize-sentences ()
2125 "Capitalize the first word in each sentence."
2128 (let ((inhibit-read-only t)
2129 (paragraph-start "^[\n\^L]"))
2133 (forward-sentence)))))
2135 (defun article-remove-cr ()
2136 "Remove trailing CRs and then translate remaining CRs into LFs."
2139 (let ((inhibit-read-only t))
2140 (goto-char (point-min))
2141 (while (re-search-forward "\r+$" nil t)
2142 (replace-match "" t t))
2143 (goto-char (point-min))
2144 (while (search-forward "\r" nil t)
2145 (replace-match "\n" t t)))))
2147 (defun article-remove-trailing-blank-lines ()
2148 "Remove all trailing blank lines from the article."
2151 (let ((inhibit-read-only t))
2152 (goto-char (point-max))
2156 (while (and (not (bobp))
2157 (looking-at "^[ \t]*$")
2158 (not (gnus-annotation-in-region-p
2159 (point) (point-at-eol))))
2165 (defvar gnus-face-properties-alist))
2167 (defun article-display-face ()
2168 "Display any Face headers in the header."
2170 (let ((wash-face-p buffer-read-only))
2171 (gnus-with-article-headers
2172 ;; When displaying parts, this function can be called several times on
2173 ;; the same article, without any intended toggle semantic (as typing `W
2174 ;; D d' would have). So face deletion must occur only when we come from
2175 ;; an interactive command, that is when the *Article* buffer is
2177 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2178 (gnus-delete-images 'face)
2179 (let (face faces from)
2180 (save-current-buffer
2181 (when (and wash-face-p
2182 (gnus-buffer-live-p gnus-original-article-buffer)
2183 (not (re-search-forward "^Face:[\t ]*" nil t)))
2184 (set-buffer gnus-original-article-buffer))
2186 (mail-narrow-to-head)
2187 (while (gnus-article-goto-header "Face")
2188 (push (mail-header-field-value) faces))))
2190 (goto-char (point-min))
2191 (let ((from (gnus-article-goto-header "from"))
2196 (insert "[no `from' set]\n"))
2198 (when (setq png (gnus-convert-face-to-png (pop faces)))
2200 (apply 'gnus-create-image png 'png t
2201 (cdr (assq 'png gnus-face-properties-alist))))
2203 (gnus-add-wash-type 'face)
2204 (gnus-add-image 'face image)
2205 (gnus-put-image image nil 'face))))))))))
2207 (defun article-display-x-face (&optional force)
2208 "Look for an X-Face header and display it if present."
2209 (interactive (list 'force))
2210 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2211 (gnus-with-article-headers
2212 ;; Delete the old process, if any.
2213 (when (process-status "article-x-face")
2214 (delete-process "article-x-face"))
2215 ;; See the comment in `article-display-face'.
2216 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2217 ;; We have already displayed X-Faces, so we remove them
2219 (gnus-delete-images 'xface)
2221 (let (x-faces from face)
2222 (save-current-buffer
2223 (when (and wash-face-p
2224 (gnus-buffer-live-p gnus-original-article-buffer)
2225 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2226 ;; If type `W f', use gnus-original-article-buffer,
2227 ;; otherwise use the current buffer because displaying
2228 ;; RFC822 parts calls this function too.
2229 (set-buffer gnus-original-article-buffer))
2231 (mail-narrow-to-head)
2232 (while (gnus-article-goto-header "X-Face")
2233 (push (mail-header-field-value) x-faces))
2234 (setq from (message-fetch-field "from"))))
2235 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2236 ;; single external face.
2237 (when (stringp gnus-article-x-face-command)
2238 (setq x-faces (list (car x-faces))))
2240 gnus-article-x-face-command
2242 ;; Check whether this face is censored.
2243 (not gnus-article-x-face-too-ugly)
2245 (not (string-match gnus-article-x-face-too-ugly
2247 (while (setq face (pop x-faces))
2248 ;; We display the face.
2249 (cond ((stringp gnus-article-x-face-command)
2250 ;; The command is a string, so we interpret the command
2251 ;; as a, well, command, and fork it off.
2252 (let ((process-connection-type nil))
2253 (gnus-set-process-query-on-exit-flag
2255 "article-x-face" nil shell-file-name
2256 shell-command-switch gnus-article-x-face-command)
2260 (process-send-region "article-x-face"
2261 (point-min) (point-max)))
2262 (process-send-eof "article-x-face")))
2263 ((functionp gnus-article-x-face-command)
2264 ;; The command is a lisp function, so we call it.
2265 (funcall gnus-article-x-face-command face))
2267 (error "%s is not a function"
2268 gnus-article-x-face-command))))))))))
2270 (defun article-decode-mime-words ()
2271 "Decode all MIME-encoded words in the article."
2273 (gnus-with-article-buffer
2274 (let ((inhibit-point-motion-hooks t)
2275 (mail-parse-charset gnus-newsgroup-charset)
2276 (mail-parse-ignored-charsets
2277 (with-current-buffer gnus-summary-buffer
2278 gnus-newsgroup-ignored-charsets)))
2279 (mail-decode-encoded-word-region (point-min) (point-max)))))
2281 (defun article-decode-charset (&optional prompt)
2282 "Decode charset-encoded text in the article.
2283 If PROMPT (the prefix), prompt for a coding system to use."
2285 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2286 (inhibit-read-only t)
2287 (mail-parse-charset gnus-newsgroup-charset)
2288 (mail-parse-ignored-charsets
2289 (save-excursion (condition-case nil
2290 (set-buffer gnus-summary-buffer)
2292 gnus-newsgroup-ignored-charsets))
2293 ct cte ctl charset format)
2296 (article-narrow-to-head)
2297 (setq ct (message-fetch-field "Content-Type" t)
2298 cte (message-fetch-field "Content-Transfer-Encoding" t)
2299 ctl (and ct (ignore-errors
2300 (mail-header-parse-content-type ct)))
2303 (mm-read-coding-system "Charset to decode: "))
2305 (mail-content-type-get ctl 'charset)))
2306 format (and ctl (mail-content-type-get ctl 'format)))
2308 (setq cte (mail-header-strip cte)))
2309 (if (and ctl (not (string-match "/" (car ctl))))
2311 (goto-char (point-max)))
2314 (narrow-to-region (point) (point-max))
2315 (when (and (eq mail-parse-charset 'gnus-decoded)
2316 (eq (mm-body-7-or-8) '8bit))
2317 ;; The text code could have been decoded.
2318 (setq charset mail-parse-charset))
2319 (when (and (or (not ctl)
2320 (equal (car ctl) "text/plain"))
2321 (not format)) ;; article with format will decode later.
2323 charset (and cte (intern (downcase
2324 (gnus-strip-whitespace cte))))
2327 (defun article-decode-encoded-words ()
2328 "Remove encoded-word encoding from headers."
2329 (let ((inhibit-point-motion-hooks t)
2330 (mail-parse-charset gnus-newsgroup-charset)
2331 (mail-parse-ignored-charsets
2332 (save-excursion (condition-case nil
2333 (set-buffer gnus-summary-buffer)
2335 gnus-newsgroup-ignored-charsets))
2336 (inhibit-read-only t))
2338 (article-narrow-to-head)
2339 (funcall gnus-decode-header-function (point-min) (point-max)))))
2341 (defun article-decode-group-name ()
2342 "Decode group names in `Newsgroups:'."
2343 (let ((inhibit-point-motion-hooks t)
2344 (inhibit-read-only t)
2345 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2346 (when (and (or gnus-group-name-charset-method-alist
2347 gnus-group-name-charset-group-alist)
2348 (gnus-buffer-live-p gnus-original-article-buffer))
2350 (article-narrow-to-head)
2351 (with-current-buffer gnus-original-article-buffer
2352 (goto-char (point-min)))
2353 (while (re-search-forward
2354 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2355 (replace-match (save-match-data
2356 (gnus-decode-newsgroups
2357 ;; XXX how to use data in article buffer?
2358 (with-current-buffer gnus-original-article-buffer
2360 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2363 gnus-newsgroup-name method))
2365 (goto-char (point-min))
2366 (with-current-buffer gnus-original-article-buffer
2367 (goto-char (point-min)))
2368 (while (re-search-forward
2369 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2370 (replace-match (save-match-data
2371 (gnus-decode-newsgroups
2372 ;; XXX how to use data in article buffer?
2373 (with-current-buffer gnus-original-article-buffer
2375 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2378 gnus-newsgroup-name method))
2381 (autoload 'idna-to-unicode "idna")
2383 (defun article-decode-idna-rhs ()
2384 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2387 (let ((inhibit-point-motion-hooks t)
2388 (inhibit-read-only t))
2389 (article-narrow-to-head)
2390 (goto-char (point-min))
2391 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2393 (when (save-match-data
2394 (and (setq ace (match-string 1))
2396 (and (re-search-backward "^[^ \t]" nil t)
2397 (looking-at "From\\|To\\|Cc")))
2398 (setq unicode (idna-to-unicode ace))))
2399 (unless (string= ace unicode)
2400 (replace-match unicode nil nil nil 1)))))))))
2402 (defun article-de-quoted-unreadable (&optional force read-charset)
2403 "Translate a quoted-printable-encoded article.
2404 If FORCE, decode the article whether it is marked as quoted-printable
2406 If READ-CHARSET, ask for a coding system."
2407 (interactive (list 'force current-prefix-arg))
2409 (let ((inhibit-read-only t) type charset)
2410 (if (gnus-buffer-live-p gnus-original-article-buffer)
2411 (with-current-buffer gnus-original-article-buffer
2413 (gnus-fetch-field "content-transfer-encoding"))
2414 (let* ((ct (gnus-fetch-field "content-type"))
2417 (mail-header-parse-content-type ct)))))
2418 (setq charset (and ctl
2419 (mail-content-type-get ctl 'charset)))
2420 (if (stringp charset)
2421 (setq charset (intern (downcase charset)))))))
2423 (setq charset (mm-read-coding-system "Charset: " charset)))
2425 (setq charset gnus-newsgroup-charset))
2427 (and type (let ((case-fold-search t))
2428 (string-match "quoted-printable" type))))
2430 (quoted-printable-decode-region
2431 (point) (point-max) (mm-charset-to-coding-system charset))))))
2433 (defun article-de-base64-unreadable (&optional force read-charset)
2434 "Translate a base64 article.
2435 If FORCE, decode the article whether it is marked as base64 not.
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 "base64" type))))
2461 (narrow-to-region (point) (point-max))
2462 (base64-decode-region (point-min) (point-max))
2463 (mm-decode-coding-region
2464 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2469 (defun article-decode-HZ ()
2470 "Translate a HZ-encoded article."
2474 (let ((inhibit-read-only t))
2475 (rfc1843-decode-region (point-min) (point-max)))))
2477 (defun article-unsplit-urls ()
2478 "Remove the newlines that some other mailers insert into URLs."
2481 (let ((inhibit-read-only t))
2482 (goto-char (point-min))
2483 (while (re-search-forward
2484 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2485 (replace-match "\\1\\3" t)))
2486 (when (interactive-p)
2487 (gnus-treat-article nil))))
2490 (defun article-wash-html (&optional read-charset)
2491 "Format an HTML article.
2492 If READ-CHARSET, ask for a coding system."
2495 (let ((inhibit-read-only t)
2497 (when (gnus-buffer-live-p gnus-original-article-buffer)
2498 (with-current-buffer gnus-original-article-buffer
2499 (let* ((ct (gnus-fetch-field "content-type"))
2502 (mail-header-parse-content-type ct)))))
2503 (setq charset (and ctl
2504 (mail-content-type-get ctl 'charset)))
2505 (when (stringp charset)
2506 (setq charset (intern (downcase charset)))))))
2508 (setq charset (mm-read-coding-system "Charset: " charset)))
2510 (setq charset gnus-newsgroup-charset))
2512 (save-window-excursion
2514 (narrow-to-region (point) (point-max))
2515 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2516 (entry (assq func mm-text-html-washer-alist)))
2518 (setq func (cdr entry)))
2523 (apply (car func) (cdr func))))))))))
2525 (defun gnus-article-wash-html-with-w3 ()
2526 "Wash the current buffer with w3."
2528 (let ((w3-strict-width (window-width))
2529 (url-standalone-mode t)
2530 (url-gateway-unplugged t)
2531 (w3-honor-stylesheets nil))
2533 (w3-region (point-min) (point-max))
2536 (defun gnus-article-wash-html-with-w3m ()
2537 "Wash the current buffer with emacs-w3m."
2540 (narrow-to-region (point) (point-max))
2541 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2542 w3m-force-redisplay)
2543 (w3m-region (point-min) (point-max)))
2544 (when (and mm-inline-text-html-with-w3m-keymap
2545 (boundp 'w3m-minor-mode-map)
2547 (add-text-properties
2548 (point-min) (point-max)
2549 (list 'keymap w3m-minor-mode-map
2550 ;; Put the mark meaning this part was rendered by emacs-w3m.
2551 'mm-inline-text-html-with-w3m t)))))
2553 (defun article-hide-list-identifiers ()
2554 "Remove list identifies from the Subject header.
2555 The `gnus-list-identifiers' variable specifies what to do."
2557 (let ((inhibit-point-motion-hooks t)
2558 (regexp (if (consp gnus-list-identifiers)
2559 (mapconcat 'identity gnus-list-identifiers " *\\|")
2560 gnus-list-identifiers))
2561 (inhibit-read-only t))
2565 (article-narrow-to-head)
2566 (goto-char (point-min))
2567 (while (re-search-forward
2568 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2570 (delete-region (match-beginning 2) (match-end 0))
2571 (beginning-of-line))
2572 (when (re-search-forward
2573 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2574 (delete-region (match-beginning 1) (match-end 1))))))))
2576 (defun article-hide-pem (&optional arg)
2577 "Toggle hiding of any PEM headers and signatures in the current article.
2578 If given a negative prefix, always show; if given a positive prefix,
2580 (interactive (gnus-article-hidden-arg))
2581 (unless (gnus-article-check-hidden-text 'pem arg)
2583 (let ((inhibit-read-only t) end)
2584 (goto-char (point-min))
2585 ;; Hide the horrendously ugly "header".
2586 (when (and (search-forward
2587 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2589 (setq end (1+ (match-beginning 0))))
2590 (gnus-add-wash-type 'pem)
2591 (gnus-article-hide-text-type
2593 (if (search-forward "\n\n" nil t)
2597 ;; Hide the trailer as well
2598 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2600 (gnus-article-hide-text-type
2601 (match-beginning 0) (match-end 0) 'pem)))))))
2603 (defun article-strip-banner ()
2604 "Strip the banners specified by the `banner' group parameter and by
2605 `gnus-article-address-banner-alist'."
2609 (let ((inhibit-point-motion-hooks t))
2610 (when (gnus-parameter-banner gnus-newsgroup-name)
2611 (article-really-strip-banner
2612 (gnus-parameter-banner gnus-newsgroup-name)))
2613 (when gnus-article-address-banner-alist
2614 ;; It is necessary to encode from fields before checking,
2615 ;; because `mail-header-parse-addresses' does not work
2616 ;; (reliably) on decoded headers. And more, it is
2617 ;; impossible to use `gnus-fetch-original-field' here,
2618 ;; because `article-strip-banner' may be called in draft
2619 ;; buffers to preview them.
2620 (let ((from (save-restriction
2622 (article-narrow-to-head)
2623 (mail-fetch-field "from"))))
2626 (caar (mail-header-parse-addresses
2627 (mail-encode-encoded-word-string from)))))
2629 (dolist (pair gnus-article-address-banner-alist)
2630 (when (string-match (car pair) from)
2632 (article-really-strip-banner (cdr pair)))))))))))))
2634 (defun article-really-strip-banner (banner)
2635 "Strip the banner specified by the argument."
2638 (let ((inhibit-point-motion-hooks t)
2639 (gnus-signature-limit nil)
2640 (inhibit-read-only t))
2643 ((eq banner 'signature)
2644 (when (gnus-article-narrow-to-signature)
2647 (delete-region (point) (point-max))))
2649 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2650 (while (re-search-forward banner nil t)
2651 (delete-region (match-beginning 0) (match-end 0)))))
2653 (while (re-search-forward banner nil t)
2654 (delete-region (match-beginning 0) (match-end 0)))))))))
2656 (defun article-babel ()
2657 "Translate article using an online translation service."
2660 (gnus-with-article-buffer
2661 (when (article-goto-body)
2662 (let* ((start (point))
2664 (orig (buffer-substring start end))
2665 (trans (babel-as-string orig)))
2667 (narrow-to-region start end)
2668 (delete-region start end)
2671 (defun article-hide-signature (&optional arg)
2672 "Hide the signature in the current article.
2673 If given a negative prefix, always show; if given a positive prefix,
2675 (interactive (gnus-article-hidden-arg))
2676 (unless (gnus-article-check-hidden-text 'signature arg)
2679 (let ((inhibit-read-only t))
2680 (when (gnus-article-narrow-to-signature)
2681 (gnus-article-hide-text-type
2682 (point-min) (point-max) 'signature))))))
2683 (gnus-set-mode-line 'article))
2685 (defun article-strip-headers-in-body ()
2686 "Strip offensive headers from bodies."
2690 (let ((case-fold-search t))
2691 (when (looking-at "x-no-archive:")
2692 (gnus-delete-line)))))
2694 (defun article-strip-leading-blank-lines ()
2695 "Remove all blank lines from the beginning of the article."
2698 (let ((inhibit-point-motion-hooks t)
2699 (inhibit-read-only t))
2700 (when (article-goto-body)
2701 (while (and (not (eobp))
2702 (looking-at "[ \t]*$"))
2703 (gnus-delete-line))))))
2705 (defun article-narrow-to-head ()
2706 "Narrow the buffer to the head of the message.
2707 Point is left at the beginning of the narrowed-to region."
2709 (goto-char (point-min))
2710 (if (search-forward "\n\n" nil 1)
2713 (goto-char (point-min)))
2715 (defun article-goto-body ()
2716 "Place point at the start of the body."
2717 (goto-char (point-min))
2719 ;; This variable is only bound when dealing with separate
2721 (article-goto-body-goes-to-point-min-p
2723 ((search-forward "\n\n" nil t)
2726 (goto-char (point-max))
2729 (defun article-strip-multiple-blank-lines ()
2730 "Replace consecutive blank lines with one empty line."
2733 (let ((inhibit-point-motion-hooks t)
2734 (inhibit-read-only t))
2735 ;; First make all blank lines empty.
2737 (while (re-search-forward "^[ \t]+$" nil t)
2738 (unless (gnus-annotation-in-region-p
2739 (match-beginning 0) (match-end 0))
2740 (replace-match "" nil t)))
2741 ;; Then replace multiple empty lines with a single empty line.
2743 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2744 (unless (gnus-annotation-in-region-p
2745 (match-beginning 0) (match-end 0))
2746 (delete-region (match-beginning 1) (match-end 1)))))))
2748 (defun article-strip-leading-space ()
2749 "Remove all white space from the beginning of the lines in the article."
2752 (let ((inhibit-point-motion-hooks t)
2753 (inhibit-read-only t))
2755 (while (re-search-forward "^[ \t]+" nil t)
2756 (replace-match "" t t)))))
2758 (defun article-strip-trailing-space ()
2759 "Remove all white space from the end of the lines in the article."
2762 (let ((inhibit-point-motion-hooks t)
2763 (inhibit-read-only t))
2765 (while (re-search-forward "[ \t]+$" nil t)
2766 (replace-match "" t t)))))
2768 (defun article-strip-blank-lines ()
2769 "Strip leading, trailing and multiple blank lines."
2771 (article-strip-leading-blank-lines)
2772 (article-remove-trailing-blank-lines)
2773 (article-strip-multiple-blank-lines))
2775 (defun article-strip-all-blank-lines ()
2776 "Strip all blank lines."
2779 (let ((inhibit-point-motion-hooks t)
2780 (inhibit-read-only t))
2782 (while (re-search-forward "^[ \t]*\n" nil t)
2783 (replace-match "" t t)))))
2785 (defun gnus-article-narrow-to-signature ()
2786 "Narrow to the signature; return t if a signature is found, else nil."
2787 (let ((inhibit-point-motion-hooks t))
2788 (when (gnus-article-search-signature)
2790 ;; Check whether we have some limits to what we consider
2791 ;; to be a signature.
2792 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2793 (list gnus-signature-limit)))
2795 (while (setq limit (pop limits))
2796 (if (or (and (integerp limit)
2797 (< (- (point-max) (point)) limit))
2799 (< (count-lines (point) (point-max)) limit))
2800 (and (functionp limit)
2802 (and (stringp limit)
2803 (not (re-search-forward limit nil t))))
2804 () ; This limit did not succeed.
2808 (narrow-to-region (point) (point-max))
2811 (defun gnus-article-search-signature ()
2812 "Search the current buffer for the signature separator.
2813 Put point at the beginning of the signature separator."
2814 (let ((cur (point)))
2815 (goto-char (point-max))
2816 (if (if (stringp gnus-signature-separator)
2817 (re-search-backward gnus-signature-separator nil t)
2818 (let ((seps gnus-signature-separator))
2820 (not (re-search-backward (car seps) nil t)))
2827 (defun gnus-article-hidden-arg ()
2828 "Return the current prefix arg as a number, or 0 if no prefix."
2829 (list (if current-prefix-arg
2830 (prefix-numeric-value current-prefix-arg)
2833 (defun gnus-article-check-hidden-text (type arg)
2834 "Return nil if hiding is necessary.
2835 Arg can be nil or a number. nil and positive means hide, negative
2836 means show, 0 means toggle."
2839 (let ((hide (gnus-article-hidden-text-p type)))
2845 (gnus-article-show-hidden-text type)
2848 (if (eq hide 'hidden)
2850 (gnus-article-show-hidden-text type)
2854 (defun gnus-article-hidden-text-p (type)
2855 "Say whether the current buffer contains hidden text of type TYPE."
2856 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2858 (not (get-text-property pos 'invisible))
2859 (not (get-text-property pos 'dummy-invisible)))
2861 (text-property-any (1+ pos) (point-max) 'article-type type)))
2866 (defun gnus-article-show-hidden-text (type &optional dummy)
2867 "Show all hidden text of type TYPE.
2868 Originally it is hide instead of DUMMY."
2869 (let ((inhibit-read-only t)
2870 (inhibit-point-motion-hooks t))
2871 (gnus-remove-text-properties-when
2873 (point-min) (point-max)
2874 (cons 'article-type (cons type
2875 gnus-hidden-properties)))
2876 (gnus-delete-wash-type type)))
2878 (defconst article-time-units
2879 `((year . ,(* 365.25 24 60 60))
2880 (week . ,(* 7 24 60 60))
2881 (day . ,(* 24 60 60))
2885 "Mapping from time units to seconds.")
2887 (defun gnus-article-forward-header ()
2888 "Move point to the start of the next header.
2889 If the current header is a continuation header, this can be several
2894 (if (looking-at "[ \t]+[^ \t]")
2898 (defun article-date-ut (&optional type highlight)
2899 "Convert DATE date to universal time in the current article.
2900 If TYPE is `local', convert to local time; if it is `lapsed', output
2901 how much time has lapsed since DATE. For `lapsed', the value of
2902 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2903 should replace the \"Date:\" one, or should be added below it."
2904 (interactive (list 'ut t))
2905 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2906 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
2910 (article-lapsed-timer
2914 (case-fold-search t)
2915 (inhibit-read-only t)
2916 (inhibit-point-motion-hooks t)
2917 pos date bface eface)
2921 (goto-char (point-min))
2922 (while (or (setq date (get-text-property (setq pos (point))
2924 (when (setq pos (next-single-property-change
2925 (point) 'original-date))
2926 (setq date (get-text-property pos 'original-date))
2928 (narrow-to-region pos (or (text-property-any pos (point-max)
2931 (goto-char (point-min))
2932 (when (re-search-forward tdate-regexp nil t)
2933 (setq bface (get-text-property (point-at-bol) 'face)
2934 eface (get-text-property (1- (point-at-eol)) 'face)))
2935 (goto-char (point-min))
2937 ;; Delete any old Date headers.
2938 (while (re-search-forward date-regexp nil t)
2940 (delete-region (point-at-bol) (progn
2941 (gnus-article-forward-header)
2943 (delete-region (point-at-bol) (progn
2944 (gnus-article-forward-header)
2947 (setq pos (point))))
2948 (when (and (not pos)
2949 (re-search-forward tdate-regexp nil t))
2951 (gnus-goto-char pos)
2952 (insert (article-make-date-line date (or type 'ut)))
2958 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2959 (put-text-property (match-beginning 1) (1+ (match-end 1))
2961 (put-text-property (match-beginning 2) (match-end 2)
2963 (put-text-property (point-min) (1- (point-max)) 'original-date date)
2964 (goto-char (point-max))
2967 (defun article-make-date-line (date type)
2968 "Return a DATE line of TYPE."
2969 (unless (memq type '(local ut original user iso8601 lapsed english))
2970 (error "Unknown conversion type: %s" type))
2972 (let ((time (date-to-time date)))
2974 ;; Convert to the local timezone.
2976 (concat "Date: " (message-make-date time)))
2977 ;; Convert to Universal Time.
2982 (let* ((e (parse-time-string date))
2983 (tm (apply 'encode-time e))
2985 (ls (- (cadr tm) (car (current-time-zone time)))))
2986 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2987 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2991 ;; Get the original date from the article.
2992 ((eq type 'original)
2993 (concat "Date: " (if (string-match "\n+$" date)
2994 (substring date 0 (match-beginning 0))
2996 ;; Let the user define the format.
2998 (let ((format (or (condition-case nil
2999 (with-current-buffer gnus-summary-buffer
3000 gnus-article-time-format)
3002 gnus-article-time-format)))
3003 (if (functionp format)
3004 (funcall format time)
3005 (concat "Date: " (format-time-string format time)))))
3008 (let ((tz (car (current-time-zone time))))
3011 (format-time-string "%Y%m%dT%H%M%S" time)
3012 (format "%s%02d%02d"
3013 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3014 (/ (% (abs tz) 3600) 60)))))
3015 ;; Do an X-Sent lapsed format.
3017 ;; If the date is seriously mangled, the timezone functions are
3018 ;; liable to bug out, so we ignore all errors.
3019 (let* ((now (current-time))
3020 (real-time (subtract-time now time))
3021 (real-sec (and real-time
3022 (+ (* (float (car real-time)) 65536)
3024 (sec (and real-time (abs real-sec)))
3034 ;; This is a bit convoluted, but basically we go
3035 ;; through the time units for years, weeks, etc,
3036 ;; and divide things to see whether that results
3037 ;; in positive answers.
3040 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3041 ;; The (remaining) seconds are too few to
3042 ;; be divided into this time unit.
3044 ;; It's big enough, so we output it.
3045 (setq sec (- sec (* num (cdr unit))))
3047 (concat (if prev ", " "") (int-to-string
3049 " " (symbol-name (car unit))
3050 (if (> num 1) "s" ""))
3052 article-time-units "")
3053 ;; If dates are odd, then it might appear like the
3054 ;; article was sent in the future.
3057 " in the future"))))))
3058 ;; Display the date in proper English
3060 (let ((dtime (decode-time time)))
3063 (number-to-string (nth 3 dtime))
3064 (let ((digit (% (nth 3 dtime) 10)))
3066 ((memq (nth 3 dtime) '(11 12 13)) "th")
3072 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3074 (number-to-string (nth 5 dtime))
3076 (format "%02d" (nth 2 dtime))
3078 (format "%02d" (nth 1 dtime)))))))
3080 (format "Date: %s (from Gnus)" date))))
3082 (defun article-date-local (&optional highlight)
3083 "Convert the current article date to the local timezone."
3084 (interactive (list t))
3085 (article-date-ut 'local highlight))
3087 (defun article-date-english (&optional highlight)
3088 "Convert the current article date to something that is proper English."
3089 (interactive (list t))
3090 (article-date-ut 'english highlight))
3092 (defun article-date-original (&optional highlight)
3093 "Convert the current article date to what it was originally.
3094 This is only useful if you have used some other date conversion
3095 function and want to see what the date was before converting."
3096 (interactive (list t))
3097 (article-date-ut 'original highlight))
3099 (defun article-date-lapsed (&optional highlight)
3100 "Convert the current article date to time lapsed since it was sent."
3101 (interactive (list t))
3102 (article-date-ut 'lapsed highlight))
3104 (defun article-update-date-lapsed ()
3105 "Function to be run from a timer to update the lapsed time line."
3107 (let (deactivate-mark)
3112 (set-buffer (window-buffer w))
3113 (when (eq major-mode 'gnus-article-mode)
3114 (let ((mark (point-marker)))
3115 (goto-char (point-min))
3116 (when (re-search-forward "^X-Sent:" nil t)
3117 (article-date-lapsed t))
3118 (goto-char (marker-position mark))
3119 (move-marker mark nil))))
3122 (defun gnus-start-date-timer (&optional n)
3123 "Start a timer to update the X-Sent header in the article buffers.
3124 The numerical prefix says how frequently (in seconds) the function
3129 (gnus-stop-date-timer)
3130 (setq article-lapsed-timer
3131 (run-at-time 1 n 'article-update-date-lapsed)))
3133 (defun gnus-stop-date-timer ()
3134 "Stop the X-Sent timer."
3136 (when article-lapsed-timer
3137 (nnheader-cancel-timer article-lapsed-timer)
3138 (setq article-lapsed-timer nil)))
3140 (defun article-date-user (&optional highlight)
3141 "Convert the current article date to the user-defined format.
3142 This format is defined by the `gnus-article-time-format' variable."
3143 (interactive (list t))
3144 (article-date-ut 'user highlight))
3146 (defun article-date-iso8601 (&optional highlight)
3147 "Convert the current article date to ISO8601."
3148 (interactive (list t))
3149 (article-date-ut 'iso8601 highlight))
3151 (defmacro gnus-article-save-original-date (&rest forms)
3152 "Save the original date as a text property and evaluate FORMS."
3153 `(let* ((case-fold-search t)
3155 (goto-char (point-min))
3156 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3159 (date (when (and start
3160 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3162 (buffer-substring-no-properties start
3163 (match-beginning 0)))))
3164 (goto-char (point-max))
3165 (skip-chars-backward "\n")
3166 (put-text-property (point-min) (point) 'original-date date)
3168 (goto-char (point-max))
3169 (skip-chars-backward "\n")
3170 (put-text-property (point-min) (point) 'original-date date)))
3172 ;; (defun article-show-all ()
3173 ;; "Show all hidden text in the article buffer."
3176 ;; (let ((inhibit-read-only t))
3177 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3179 (defun article-remove-leading-whitespace ()
3180 "Remove excessive whitespace from all headers."
3184 (let ((inhibit-read-only t))
3185 (article-narrow-to-head)
3186 (goto-char (point-min))
3187 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3188 (delete-region (match-beginning 1) (match-end 1)))))))
3190 (defun article-emphasize (&optional arg)
3191 "Emphasize text according to `gnus-emphasis-alist'."
3192 (interactive (gnus-article-hidden-arg))
3193 (unless (gnus-article-check-hidden-text 'emphasis arg)
3197 (with-current-buffer gnus-summary-buffer
3198 gnus-article-emphasis-alist)
3200 gnus-emphasis-alist))
3201 (inhibit-read-only t)
3202 (props (append '(article-type emphasis)
3203 gnus-hidden-properties))
3204 regexp elem beg invisible visible face)
3207 (while (setq elem (pop alist))
3209 (setq regexp (car elem)
3210 invisible (nth 1 elem)
3211 visible (nth 2 elem)
3213 (while (re-search-forward regexp nil t)
3214 (when (and (match-beginning visible) (match-beginning invisible))
3215 (gnus-article-hide-text
3216 (match-beginning invisible) (match-end invisible) props)
3217 (gnus-article-unhide-text-type
3218 (match-beginning visible) (match-end visible) 'emphasis)
3219 (gnus-put-overlay-excluding-newlines
3220 (match-beginning visible) (match-end visible) 'face face)
3221 (gnus-add-wash-type 'emphasis)
3222 (goto-char (match-end invisible)))))))))
3224 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3225 "Setup newsgroup emphasis alist."
3226 (unless gnus-article-emphasis-alist
3227 (let ((name (and gnus-newsgroup-name
3228 (gnus-group-real-name gnus-newsgroup-name))))
3229 (make-local-variable 'gnus-article-emphasis-alist)
3230 (setq gnus-article-emphasis-alist
3232 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3233 (while (setq elem (pop alist))
3234 (when (and name (string-match (car elem) name))
3236 highlight (copy-sequence (cdr elem)))))
3238 (copy-sequence highlight-words)
3239 (if gnus-newsgroup-name
3240 (copy-sequence (gnus-group-find-parameter
3241 gnus-newsgroup-name 'highlight-words t)))
3242 gnus-emphasis-alist)))))
3245 (defvar gnus-summary-article-menu)
3246 (defvar gnus-summary-post-menu))
3248 ;;; Saving functions.
3250 (defun gnus-article-save (save-buffer file &optional num)
3251 "Save the currently selected article."
3252 (unless gnus-save-all-headers
3253 ;; Remove headers according to `gnus-saved-headers'.
3254 (let ((gnus-visible-headers
3255 (or gnus-saved-headers gnus-visible-headers))
3256 (gnus-article-buffer save-buffer))
3258 (set-buffer save-buffer)
3259 (article-hide-headers 1 t))))
3260 (save-window-excursion
3261 (if (not gnus-default-article-saver)
3262 (error "No default saver is defined")
3263 ;; !!! Magic! The saving functions all save
3264 ;; `gnus-save-article-buffer' (or so they think), but we
3265 ;; bind that variable to our save-buffer.
3266 (set-buffer gnus-article-buffer)
3267 (let* ((gnus-save-article-buffer save-buffer)
3270 ((not gnus-prompt-before-saving) 'default)
3271 ((eq gnus-prompt-before-saving 'always) nil)
3273 (gnus-number-of-articles-to-be-saved
3274 (when (eq gnus-prompt-before-saving t)
3276 (set-buffer gnus-article-current-summary)
3277 (funcall gnus-default-article-saver filename)))))
3279 (defun gnus-read-save-file-name (prompt &optional filename
3280 function group headers variable)
3282 (funcall function group headers (symbol-value variable)))
3287 ((eq filename 'default)
3293 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3296 (if (and gnus-number-of-articles-to-be-saved
3297 (> gnus-number-of-articles-to-be-saved 1))
3298 (format "these %d articles"
3299 gnus-number-of-articles-to-be-saved)
3302 ;; Let the split methods have their say.
3304 ;; No split name was found.
3307 (concat prompt " (default "
3308 (file-name-nondirectory default-name) ") ")
3309 (file-name-directory default-name)
3311 ;; A single group name is returned.
3312 ((stringp split-name)
3314 (funcall function split-name headers
3315 (symbol-value variable)))
3317 (concat prompt " (default "
3318 (file-name-nondirectory default-name) ") ")
3319 (file-name-directory default-name)
3321 ;; A single split name was found
3322 ((= 1 (length split-name))
3323 (let* ((name (expand-file-name
3325 gnus-article-save-directory))
3326 (dir (cond ((file-directory-p name)
3327 (file-name-as-directory name))
3328 ((file-exists-p name) name)
3329 (t gnus-article-save-directory))))
3331 (concat prompt " (default " name ") ")
3333 ;; A list of splits was found.
3335 (setq split-name (nreverse split-name))
3337 (let ((file-name-history
3338 (nconc split-name file-name-history)))
3342 (concat prompt " (`M-p' for defaults) ")
3343 gnus-article-save-directory
3345 gnus-article-save-directory)))
3346 (car (push result file-name-history)))))))
3347 ;; Create the directory.
3348 (gnus-make-directory (file-name-directory file))
3349 ;; If we have read a directory, we append the default file name.
3350 (when (file-directory-p file)
3351 (setq file (expand-file-name (file-name-nondirectory
3353 (file-name-as-directory file))))
3354 ;; Possibly translate some characters.
3355 (nnheader-translate-file-chars file))))))
3356 (gnus-make-directory (file-name-directory result))
3357 (set variable result)))
3359 (defun gnus-article-archive-name (group)
3360 "Return the first instance of an \"Archive-name\" in the current buffer."
3361 (let ((case-fold-search t))
3362 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3363 (nnheader-concat gnus-article-save-directory
3364 (match-string 1)))))
3366 (defun gnus-article-nndoc-name (group)
3367 "If GROUP is an nndoc group, return the name of the parent group."
3368 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3369 (gnus-group-get-parameter group 'save-article-group)))
3371 (defun gnus-summary-save-in-rmail (&optional filename)
3372 "Append this article to Rmail file.
3373 Optional argument FILENAME specifies file name.
3374 Directory to save to is default to `gnus-article-save-directory'."
3375 (setq filename (gnus-read-save-file-name
3376 "Save %s in rmail file:" filename
3377 gnus-rmail-save-name gnus-newsgroup-name
3378 gnus-current-headers 'gnus-newsgroup-last-rmail))
3379 (gnus-eval-in-buffer-window gnus-save-article-buffer
3383 (gnus-output-to-rmail filename))))
3386 (defun gnus-summary-save-in-mail (&optional filename)
3387 "Append this article to Unix mail file.
3388 Optional argument FILENAME specifies file name.
3389 Directory to save to is default to `gnus-article-save-directory'."
3390 (setq filename (gnus-read-save-file-name
3391 "Save %s in Unix mail file:" filename
3392 gnus-mail-save-name gnus-newsgroup-name
3393 gnus-current-headers 'gnus-newsgroup-last-mail))
3394 (gnus-eval-in-buffer-window gnus-save-article-buffer
3398 (if (and (file-readable-p filename)
3399 (file-regular-p filename)
3400 (mail-file-babyl-p filename))
3401 (rmail-output-to-rmail-file filename t)
3402 (gnus-output-to-mail filename)))))
3405 (defun gnus-summary-save-in-file (&optional filename overwrite)
3406 "Append this article to file.
3407 Optional argument FILENAME specifies file name.
3408 Directory to save to is default to `gnus-article-save-directory'."
3409 (setq filename (gnus-read-save-file-name
3410 "Save %s in file:" filename
3411 gnus-file-save-name gnus-newsgroup-name
3412 gnus-current-headers 'gnus-newsgroup-last-file))
3413 (gnus-eval-in-buffer-window gnus-save-article-buffer
3417 (when (and overwrite
3418 (file-exists-p filename))
3419 (delete-file filename))
3420 (gnus-output-to-file filename))))
3423 (defun gnus-summary-write-to-file (&optional filename)
3424 "Write this article to a file, overwriting it if the file exists.
3425 Optional argument FILENAME specifies file name.
3426 The directory to save in defaults to `gnus-article-save-directory'."
3427 (gnus-summary-save-in-file nil t))
3429 (defun gnus-summary-save-body-in-file (&optional filename)
3430 "Append this article body to a file.
3431 Optional argument FILENAME specifies file name.
3432 The directory to save in defaults to `gnus-article-save-directory'."
3433 (setq filename (gnus-read-save-file-name
3434 "Save %s body in file:" filename
3435 gnus-file-save-name gnus-newsgroup-name
3436 gnus-current-headers 'gnus-newsgroup-last-file))
3437 (gnus-eval-in-buffer-window gnus-save-article-buffer
3441 (when (article-goto-body)
3442 (narrow-to-region (point) (point-max)))
3443 (gnus-output-to-file filename))))
3446 (defun gnus-summary-save-in-pipe (&optional command)
3447 "Pipe this article to subprocess."
3449 (cond ((and (eq command 'default)
3450 gnus-last-shell-command)
3451 gnus-last-shell-command)
3456 "Shell command on %s: "
3457 (if (and gnus-number-of-articles-to-be-saved
3458 (> gnus-number-of-articles-to-be-saved 1))
3459 (format "these %d articles"
3460 gnus-number-of-articles-to-be-saved)
3462 gnus-last-shell-command))))
3463 (when (string-equal command "")
3464 (if gnus-last-shell-command
3465 (setq command gnus-last-shell-command)
3466 (error "A command is required")))
3467 (gnus-eval-in-buffer-window gnus-article-buffer
3470 (shell-command-on-region (point-min) (point-max) command nil)))
3471 (setq gnus-last-shell-command command))
3473 (defun gnus-summary-pipe-to-muttprint (&optional command)
3474 "Pipe this article to muttprint."
3475 (setq command (read-string
3476 "Print using command: " gnus-summary-muttprint-program
3477 nil gnus-summary-muttprint-program))
3478 (gnus-summary-save-in-pipe command))
3480 ;;; Article file names when saving.
3482 (defun gnus-capitalize-newsgroup (newsgroup)
3483 "Capitalize NEWSGROUP name."
3484 (when (not (zerop (length newsgroup)))
3485 (concat (char-to-string (upcase (aref newsgroup 0)))
3486 (substring newsgroup 1))))
3488 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3489 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3490 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3491 Otherwise, it is like ~/News/news/group/num."
3494 (concat (if (gnus-use-long-file-name 'not-save)
3495 (gnus-capitalize-newsgroup newsgroup)
3496 (gnus-newsgroup-directory-form newsgroup))
3497 "/" (int-to-string (mail-header-number headers)))
3498 gnus-article-save-directory)))
3500 (string-equal (file-name-directory default)
3501 (file-name-directory last-file))
3502 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3504 (or last-file default))))
3506 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3507 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3508 If variable `gnus-use-long-file-name' is non-nil, it is
3509 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3512 (concat (if (gnus-use-long-file-name 'not-save)
3514 (gnus-newsgroup-directory-form newsgroup))
3515 "/" (int-to-string (mail-header-number headers)))
3516 gnus-article-save-directory)))
3518 (string-equal (file-name-directory default)
3519 (file-name-directory last-file))
3520 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3522 (or last-file default))))
3524 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3525 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3526 If variable `gnus-use-long-file-name' is non-nil, it is
3527 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3530 (if (gnus-use-long-file-name 'not-save)
3533 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3535 gnus-article-save-directory)))
3537 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3538 "Generate file name from sender."
3539 (let ((from (mail-header-from headers)))
3541 (if (and from (string-match "\\([^ <]+\\)@" from))
3542 (match-string 1 from)
3544 gnus-article-save-directory)))
3546 (defun article-verify-x-pgp-sig ()
3549 (if (gnus-buffer-live-p gnus-original-article-buffer)
3550 (let ((sig (with-current-buffer gnus-original-article-buffer
3551 (gnus-fetch-field "X-PGP-Sig")))
3555 (mml2015-clear-verify-function))
3557 (insert-buffer-substring gnus-original-article-buffer)
3558 (setq items (split-string sig))
3559 (message-narrow-to-head)
3560 (let ((inhibit-point-motion-hooks t)
3561 (case-fold-search t))
3562 ;; Don't verify multiple headers.
3563 (setq headers (mapconcat (lambda (header)
3565 (mail-fetch-field header)
3567 (split-string (nth 1 items) ",") "")))
3568 (delete-region (point-min) (point-max))
3569 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3570 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3575 (if (looking-at "^-")
3578 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3579 (insert "Version: " (car items) "\n\n")
3580 (insert (mapconcat 'identity (cddr items) "\n"))
3581 (insert "\n-----END PGP SIGNATURE-----\n")
3582 (let ((mm-security-handle (list (format "multipart/signed"))))
3583 (mml2015-clean-buffer)
3584 (let ((coding-system-for-write (or gnus-newsgroup-charset
3586 (funcall (mml2015-clear-verify-function)))
3588 (or (mm-handle-multipart-ctl-parameter
3589 mm-security-handle 'gnus-details)
3590 (mm-handle-multipart-ctl-parameter
3591 mm-security-handle 'gnus-info)))))
3593 (let ((inhibit-read-only t) bface eface)
3595 (message-narrow-to-head)
3596 (goto-char (point-max))
3598 (setq bface (get-text-property (point-at-bol) 'face)
3599 eface (get-text-property (1- (point-at-eol)) 'face))
3600 (message-remove-header "X-Gnus-PGP-Verify")
3601 (if (re-search-forward "^X-PGP-Sig:" nil t)
3603 (goto-char (point-max)))
3604 (narrow-to-region (point) (point))
3605 (insert "X-Gnus-PGP-Verify: " info "\n")
3606 (goto-char (point-min))
3609 (if (not (looking-at "^[ \t]"))
3613 (goto-char (point-min))
3614 (when (looking-at "\\([^:]+\\): *")
3615 (put-text-property (match-beginning 1) (1+ (match-end 1))
3617 (put-text-property (match-end 0) (point-max)
3618 'face eface)))))))))
3620 (defun article-verify-cancel-lock ()
3621 "Verify Cancel-Lock header."
3623 (if (gnus-buffer-live-p gnus-original-article-buffer)
3624 (canlock-verify gnus-original-article-buffer)))
3631 (setq afunc (car func)
3634 gfunc (intern (format "gnus-%s" func))))
3636 (when (fboundp afunc)
3637 `(lambda (&optional interactive &rest args)
3638 ,(documentation afunc t)
3639 (interactive (list t))
3641 (set-buffer gnus-article-buffer)
3643 (call-interactively ',afunc)
3644 (apply ',afunc args))))))))
3645 '(article-hide-headers
3646 article-verify-x-pgp-sig
3647 article-verify-cancel-lock
3648 article-hide-boring-headers
3649 article-treat-overstrike
3650 article-treat-ansi-sequences
3651 article-fill-long-lines
3652 article-capitalize-sentences
3654 article-remove-leading-whitespace
3655 article-display-x-face
3656 article-display-face
3657 article-de-quoted-unreadable
3658 article-de-base64-unreadable
3661 article-unsplit-urls
3662 article-hide-list-identifiers
3663 article-strip-banner
3666 article-hide-signature
3667 article-strip-headers-in-body
3668 article-remove-trailing-blank-lines
3669 article-strip-leading-blank-lines
3670 article-strip-multiple-blank-lines
3671 article-strip-leading-space
3672 article-strip-trailing-space
3673 article-strip-blank-lines
3674 article-strip-all-blank-lines
3676 article-date-english
3677 article-date-iso8601
3678 article-date-original
3680 article-decode-mime-words
3681 article-decode-charset
3682 article-decode-encoded-words
3686 article-treat-dumbquotes
3687 article-normalize-headers
3688 ;; (article-show-all . gnus-article-show-all-headers)
3692 ;;; Gnus article mode
3695 (put 'gnus-article-mode 'mode-class 'special)
3697 (set-keymap-parent gnus-article-mode-map widget-keymap)
3699 (gnus-define-keys gnus-article-mode-map
3700 " " gnus-article-goto-next-page
3701 "\177" gnus-article-goto-prev-page
3702 [delete] gnus-article-goto-prev-page
3703 [backspace] gnus-article-goto-prev-page
3704 "\C-c^" gnus-article-refer-article
3705 "h" gnus-article-show-summary
3706 "s" gnus-article-show-summary
3707 "\C-c\C-m" gnus-article-mail
3708 "?" gnus-article-describe-briefly
3709 "e" gnus-summary-edit-article
3710 "<" beginning-of-buffer
3712 "\C-c\C-i" gnus-info-find-node
3714 "R" gnus-article-reply-with-original
3715 "F" gnus-article-followup-with-original
3716 "\C-hk" gnus-article-describe-key
3717 "\C-hc" gnus-article-describe-key-briefly
3719 "\C-d" gnus-article-read-summary-keys
3720 "\M-*" gnus-article-read-summary-keys
3721 "\M-#" gnus-article-read-summary-keys
3722 "\M-^" gnus-article-read-summary-keys
3723 "\M-g" gnus-article-read-summary-keys)
3725 (substitute-key-definition
3726 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3728 (defun gnus-article-make-menu-bar ()
3729 (unless (boundp 'gnus-article-commands-menu)
3730 (gnus-summary-make-menu-bar))
3731 (gnus-turn-off-edit-menu 'article)
3732 (unless (boundp 'gnus-article-article-menu)
3734 gnus-article-article-menu gnus-article-mode-map ""
3736 ["Scroll forwards" gnus-article-goto-next-page t]
3737 ["Scroll backwards" gnus-article-goto-prev-page t]
3738 ["Show summary" gnus-article-show-summary t]
3739 ["Fetch Message-ID at point" gnus-article-refer-article t]
3740 ["Mail to address at point" gnus-article-mail t]
3741 ["Send a bug report" gnus-bug t]))
3744 gnus-article-treatment-menu gnus-article-mode-map ""
3745 ;; Fixme: this should use :active (and maybe :visible).
3747 ["Hide headers" gnus-article-hide-headers t]
3748 ["Hide signature" gnus-article-hide-signature t]
3749 ["Hide citation" gnus-article-hide-citation t]
3750 ["Treat overstrike" gnus-article-treat-overstrike t]
3751 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3752 ["Remove carriage return" gnus-article-remove-cr t]
3753 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3754 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3755 ["Remove base64" gnus-article-de-base64-unreadable t]
3756 ["Treat html" gnus-article-wash-html t]
3757 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3758 ["Decode HZ" gnus-article-decode-HZ t]))
3760 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3762 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3764 (gnus-run-hooks 'gnus-article-menu-hook)))
3766 (defun gnus-article-mode ()
3767 "Major mode for displaying an article.
3769 All normal editing commands are switched off.
3771 The following commands are available in addition to all summary mode
3773 \\<gnus-article-mode-map>
3774 \\[gnus-article-next-page]\t Scroll the article one page forwards
3775 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3776 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3777 \\[gnus-article-show-summary]\t Display the summary buffer
3778 \\[gnus-article-mail]\t Send a reply to the address near point
3779 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3780 \\[gnus-info-find-node]\t Go to the Gnus info node"
3782 (kill-all-local-variables)
3783 (gnus-simplify-mode-line)
3784 (setq mode-name "Article")
3785 (setq major-mode 'gnus-article-mode)
3786 (make-local-variable 'minor-mode-alist)
3787 (use-local-map gnus-article-mode-map)
3788 (when (gnus-visual-p 'article-menu 'menu)
3789 (gnus-article-make-menu-bar)
3790 (when gnus-summary-tool-bar-map
3791 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3792 (gnus-update-format-specifications nil 'article-mode)
3793 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3794 (set (make-local-variable 'gnus-page-broken) nil)
3795 (make-local-variable 'gnus-button-marker-list)
3796 (make-local-variable 'gnus-article-current-summary)
3797 (make-local-variable 'gnus-article-mime-handles)
3798 (make-local-variable 'gnus-article-decoded-p)
3799 (make-local-variable 'gnus-article-mime-handle-alist)
3800 (make-local-variable 'gnus-article-wash-types)
3801 (make-local-variable 'gnus-article-image-alist)
3802 (make-local-variable 'gnus-article-charset)
3803 (make-local-variable 'gnus-article-ignored-charsets)
3804 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3805 (set (make-local-variable 'nobreak-char-display) nil)
3806 (gnus-set-default-directory)
3807 (buffer-disable-undo)
3808 (setq buffer-read-only t
3809 show-trailing-whitespace nil)
3810 (set-syntax-table gnus-article-mode-syntax-table)
3811 (mm-enable-multibyte)
3812 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3814 (defun gnus-article-setup-buffer ()
3815 "Initialize the article buffer."
3816 (let* ((name (if gnus-single-article-buffer "*Article*"
3817 (concat "*Article " gnus-newsgroup-name "*")))
3819 (progn (string-match "\\*Article" name)
3820 (concat " *Original Article"
3821 (substring name (match-end 0))))))
3822 (setq gnus-article-buffer name)
3823 (setq gnus-original-article-buffer original)
3824 (setq gnus-article-mime-handle-alist nil)
3825 ;; This might be a variable local to the summary buffer.
3826 (unless gnus-single-article-buffer
3828 (set-buffer gnus-summary-buffer)
3829 (setq gnus-article-buffer name)
3830 (setq gnus-original-article-buffer original)
3831 (gnus-set-global-variables)))
3832 (gnus-article-setup-highlight-words)
3833 ;; Init original article buffer.
3835 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3836 (mm-enable-multibyte)
3837 (setq major-mode 'gnus-original-article-mode)
3838 (make-local-variable 'gnus-original-article))
3839 (if (and (get-buffer name)
3840 (with-current-buffer name
3841 (if gnus-article-edit-mode
3842 (if (y-or-n-p "Article mode edit in progress; discard? ")
3844 (set-buffer-modified-p nil)
3845 (gnus-kill-buffer name)
3848 (error "Action aborted"))
3852 (set (make-local-variable 'gnus-article-edit-mode) nil)
3853 (when gnus-article-mime-handles
3854 (mm-destroy-parts gnus-article-mime-handles)
3855 (setq gnus-article-mime-handles nil))
3856 ;; Set it to nil in article-buffer!
3857 (setq gnus-article-mime-handle-alist nil)
3858 (buffer-disable-undo)
3859 (setq buffer-read-only t)
3860 ;; This list just keeps growing if we don't reset it.
3861 (setq gnus-button-marker-list nil)
3862 (unless (eq major-mode 'gnus-article-mode)
3863 (gnus-article-mode))
3866 (set-buffer (gnus-get-buffer-create name))
3868 (make-local-variable 'gnus-summary-buffer)
3869 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3870 (current-buffer)))))
3872 ;; Set article window start at LINE, where LINE is the number of lines
3873 ;; from the head of the article.
3874 (defun gnus-article-set-window-start (&optional line)
3876 (gnus-get-buffer-window gnus-article-buffer t)
3878 (set-buffer gnus-article-buffer)
3879 (goto-char (point-min))
3882 (gnus-message 6 "Moved to bookmark")
3883 (search-forward "\n\n" nil t)
3887 (defun gnus-article-prepare (article &optional all-headers header)
3888 "Prepare ARTICLE in article mode buffer.
3889 ARTICLE should either be an article number or a Message-ID.
3890 If ARTICLE is an id, HEADER should be the article headers.
3891 If ALL-HEADERS is non-nil, no headers are hidden."
3893 ;; Make sure we start in a summary buffer.
3894 (unless (eq major-mode 'gnus-summary-mode)
3895 (set-buffer gnus-summary-buffer))
3896 (setq gnus-summary-buffer (current-buffer))
3897 (let* ((gnus-article (if header (mail-header-number header) article))
3898 (summary-buffer (current-buffer))
3899 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3900 (group gnus-newsgroup-name)
3903 (gnus-article-setup-buffer)
3904 (set-buffer gnus-article-buffer)
3905 ;; Deactivate active regions.
3906 (when (and (boundp 'transient-mark-mode)
3907 transient-mark-mode)
3908 (setq mark-active nil))
3909 (if (not (setq result (let ((inhibit-read-only t))
3910 (gnus-request-article-this-buffer
3912 ;; There is no such article.
3914 (when (and (numberp article)
3915 (not (memq article gnus-newsgroup-sparse)))
3916 (setq gnus-article-current
3917 (cons gnus-newsgroup-name article))
3918 (set-buffer gnus-summary-buffer)
3919 (setq gnus-current-article article)
3920 (if (and (memq article gnus-newsgroup-undownloaded)
3921 (not (gnus-online (gnus-find-method-for-group
3922 gnus-newsgroup-name))))
3924 (gnus-summary-set-agent-mark article)
3925 (message "Message marked for downloading"))
3926 (gnus-summary-mark-article article gnus-canceled-mark)
3927 (unless (memq article gnus-newsgroup-sparse)
3928 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3929 (if (or (eq result 'pseudo)
3930 (eq result 'nneething))
3933 (set-buffer summary-buffer)
3934 (push article gnus-newsgroup-history)
3935 (setq gnus-last-article gnus-current-article
3936 gnus-current-article 0
3937 gnus-current-headers nil
3938 gnus-article-current nil)
3939 (if (eq result 'nneething)
3940 (gnus-configure-windows 'summary)
3941 (gnus-configure-windows 'article))
3942 (gnus-set-global-variables))
3943 (let ((gnus-article-mime-handle-alist-1
3944 gnus-article-mime-handle-alist))
3945 (gnus-set-mode-line 'article)))
3946 ;; The result from the `request' was an actual article -
3947 ;; or at least some text that is now displayed in the
3949 (when (and (numberp article)
3950 (not (eq article gnus-current-article)))
3951 ;; Seems like a new article has been selected.
3952 ;; `gnus-current-article' must be an article number.
3954 (set-buffer summary-buffer)
3955 (push article gnus-newsgroup-history)
3956 (setq gnus-last-article gnus-current-article
3957 gnus-current-article article
3958 gnus-current-headers
3959 (gnus-summary-article-header gnus-current-article)
3960 gnus-article-current
3961 (cons gnus-newsgroup-name gnus-current-article))
3962 (unless (vectorp gnus-current-headers)
3963 (setq gnus-current-headers nil))
3964 (gnus-summary-goto-subject gnus-current-article)
3965 (when (gnus-summary-show-thread)
3966 ;; If the summary buffer really was folded, the
3967 ;; previous goto may not actually have gone to
3968 ;; the right article, but the thread root instead.
3970 (gnus-summary-goto-subject gnus-current-article))
3971 (gnus-run-hooks 'gnus-mark-article-hook)
3972 (gnus-set-mode-line 'summary)
3973 (when (gnus-visual-p 'article-highlight 'highlight)
3974 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3975 ;; Set the global newsgroup variables here.
3976 (gnus-set-global-variables)
3977 (setq gnus-have-all-headers
3978 (or all-headers gnus-show-all-headers))))
3980 (gnus-configure-windows 'article))
3981 (when (or (numberp article)
3983 (gnus-article-prepare-display)
3985 (goto-char (point-min))
3986 (when gnus-break-pages
3987 (gnus-narrow-to-page)))
3988 (let ((gnus-article-mime-handle-alist-1
3989 gnus-article-mime-handle-alist))
3990 (gnus-set-mode-line 'article))
3994 (set-window-point (get-buffer-window (current-buffer)) (point))
3995 (gnus-configure-windows 'article)
3999 (defun gnus-article-prepare-display ()
4000 "Make the current buffer look like a nice article."
4001 ;; Hooks for getting information from the article.
4002 ;; This hook must be called before being narrowed.
4003 (let ((gnus-article-buffer (current-buffer))
4005 (inhibit-read-only t))
4006 (unless (eq major-mode 'gnus-article-mode)
4007 (gnus-article-mode))
4008 (setq buffer-read-only nil
4009 gnus-article-wash-types nil
4010 gnus-article-image-alist nil)
4011 (gnus-run-hooks 'gnus-tmp-internal-hook)
4012 (when gnus-display-mime-function
4013 (funcall gnus-display-mime-function))
4014 (gnus-run-hooks 'gnus-article-prepare-hook)))
4017 ;;; Gnus MIME viewing functions
4020 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4021 "Format of the MIME buttons.
4023 Valid specifiers include:
4025 %T MIME type, along with additional info
4026 %n The `name' parameter
4027 %d The description, if any
4028 %l The length of the encoded part
4029 %p The part identifier number
4030 %e Dots if the part isn't displayed
4032 General format specifiers can also be used. See Info node
4033 `(gnus)Formatting Variables'.")
4035 (defvar gnus-mime-button-line-format-alist
4036 '((?t gnus-tmp-type ?s)
4037 (?T gnus-tmp-type-long ?s)
4038 (?n gnus-tmp-name ?s)
4039 (?d gnus-tmp-description ?s)
4041 (?l gnus-tmp-length ?d)
4042 (?e gnus-tmp-dots ?s)))
4044 (defvar gnus-mime-button-commands
4045 '((gnus-article-press-button "\r" "Toggle Display")
4046 (gnus-mime-view-part "v" "View Interactively...")
4047 (gnus-mime-view-part-as-type "t" "View As Type...")
4048 (gnus-mime-view-part-as-charset "C" "View As charset...")
4049 (gnus-mime-save-part "o" "Save...")
4050 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4051 (gnus-mime-delete-part "d" "Delete part")
4052 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4053 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4054 (gnus-mime-view-part-internally "E" "View Internally")
4055 (gnus-mime-view-part-externally "e" "View Externally")
4056 (gnus-mime-print-part "p" "Print")
4057 (gnus-mime-pipe-part "|" "Pipe To Command...")
4058 (gnus-mime-action-on-part "." "Take action on the part...")))
4060 (defun gnus-article-mime-part-status ()
4061 (if gnus-article-mime-handle-alist-1
4062 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4064 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4067 (defvar gnus-mime-button-map
4068 (let ((map (make-sparse-keymap)))
4069 (define-key map gnus-mouse-2 'gnus-article-push-button)
4070 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4071 (dolist (c gnus-mime-button-commands)
4072 (define-key map (cadr c) (car c)))
4076 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4078 ,@(mapcar (lambda (c)
4079 (vector (caddr c) (car c) :enable t))
4080 gnus-mime-button-commands)))
4082 (defun gnus-mime-button-menu (event prefix)
4083 "Construct a context-sensitive menu of MIME commands."
4084 (interactive "e\nP")
4085 (save-window-excursion
4086 (let ((pos (event-start event)))
4087 (select-window (posn-window pos))
4088 (goto-char (posn-point pos))
4089 (gnus-article-check-buffer)
4090 (popup-menu gnus-mime-button-menu nil prefix))))
4092 (defun gnus-mime-view-all-parts (&optional handles)
4093 "View all the MIME parts."
4095 (with-current-buffer gnus-article-buffer
4096 (let ((handles (or handles gnus-article-mime-handles))
4097 (mail-parse-charset gnus-newsgroup-charset)
4098 (mail-parse-ignored-charsets
4099 (with-current-buffer gnus-summary-buffer
4100 gnus-newsgroup-ignored-charsets)))
4102 (mm-remove-parts handles)
4103 (goto-char (point-min))
4104 (or (search-forward "\n\n") (goto-char (point-max)))
4105 (let ((inhibit-read-only t))
4106 (delete-region (point) (point-max))
4107 (mm-display-parts handles))))))
4109 (defun gnus-article-jump-to-part (n)
4110 "Jump to MIME part N."
4112 (pop-to-buffer gnus-article-buffer)
4113 (let ((parts (length gnus-article-mime-handle-alist)))
4116 (read-string ;; Emacs 21 doesn't have `read-number'.
4117 (format "Jump to part (2..%s): " parts)))))
4118 (unless (and (integerp n) (<= n parts) (>= n 1))
4121 (gnus-message 7 "Invalid part `%s', using %s instead."
4124 (gnus-message 9 "Jumping to part %s." n)
4125 (gnus-article-goto-part n)))
4128 (defsubst gnus-article-edit-part (handles &optional current-id)
4129 "Edit an article in order to delete a mime part.
4130 This function is exclusively used by `gnus-mime-save-part-and-strip'
4131 and `gnus-mime-delete-part', and not provided at run-time normally."
4132 (gnus-article-edit-article
4134 (buffer-disable-undo)
4136 (let ((mail-parse-charset (or gnus-article-charset
4137 ',gnus-newsgroup-charset))
4138 (mail-parse-ignored-charsets
4139 (or gnus-article-ignored-charsets
4140 ',gnus-newsgroup-ignored-charsets))
4141 (mbl mml-buffer-list))
4142 (setq mml-buffer-list nil)
4143 (insert-buffer-substring gnus-original-article-buffer)
4144 (mime-to-mml ',handles)
4145 (setq gnus-article-mime-handles nil)
4146 (let ((mbl1 mml-buffer-list))
4147 (setq mml-buffer-list mbl)
4148 (set (make-local-variable 'mml-buffer-list) mbl1))
4149 (gnus-make-local-hook 'kill-buffer-hook)
4150 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4151 `(lambda (no-highlight)
4152 (let ((mail-parse-charset (or gnus-article-charset
4153 ',gnus-newsgroup-charset))
4154 (message-options message-options)
4155 (message-options-set-recipient)
4156 (mail-parse-ignored-charsets
4157 (or gnus-article-ignored-charsets
4158 ',gnus-newsgroup-ignored-charsets)))
4160 (mml-destroy-buffers)
4161 (remove-hook 'kill-buffer-hook
4162 'mml-destroy-buffers t)
4163 (kill-local-variable 'mml-buffer-list))
4164 (gnus-summary-edit-article-done
4165 ,(or (mail-header-references gnus-current-headers) "")
4166 ,(gnus-group-read-only-p)
4167 ,gnus-summary-buffer no-highlight))
4169 (gnus-article-edit-done)
4170 (gnus-summary-expand-window)
4171 (gnus-summary-show-article)
4172 (when (and current-id (integerp gnus-auto-select-part))
4173 (gnus-article-jump-to-part
4174 (+ current-id gnus-auto-select-part)))))
4176 (defun gnus-mime-save-part-and-strip ()
4177 "Save the MIME part under point then replace it with an external body."
4179 (gnus-article-check-buffer)
4180 (when (gnus-group-read-only-p)
4181 (error "The current group does not support deleting of parts"))
4182 (when (mm-complicated-handles gnus-article-mime-handles)
4184 The current article has a complicated MIME structure, giving up..."))
4185 (let* ((data (get-text-property (point) 'gnus-data))
4186 (id (get-text-property (point) 'gnus-part))
4188 (handles gnus-article-mime-handles))
4189 (setq file (and data (mm-save-part data)))
4191 (with-current-buffer (mm-handle-buffer data)
4193 (insert "Content-Type: " (mm-handle-media-type data))
4194 (mml-insert-parameter-string (cdr (mm-handle-type data))
4197 (insert "Content-ID: " (message-make-message-id) "\n")
4198 (insert "Content-Transfer-Encoding: binary\n")
4201 (cdr (mm-make-handle nil
4202 `("message/external-body"
4203 (access-type . "LOCAL-FILE")
4205 ;; (set-buffer gnus-summary-buffer)
4206 (gnus-article-edit-part handles id))))
4208 (defun gnus-mime-delete-part ()
4209 "Delete the MIME part under point.
4210 Replace it with some information about the removed part."
4212 (gnus-article-check-buffer)
4213 (when (gnus-group-read-only-p)
4214 (error "The current group does not support deleting of parts"))
4215 (when (mm-complicated-handles gnus-article-mime-handles)
4217 The current article has a complicated MIME structure, giving up..."))
4218 (when (or gnus-expert-user
4219 (gnus-yes-or-no-p "\
4220 Deleting parts may malfunction or destroy the article; continue? "))
4221 (let* ((data (get-text-property (point) 'gnus-data))
4222 (id (get-text-property (point) 'gnus-part))
4223 (handles gnus-article-mime-handles)
4227 (mail-decode-encoded-word-string (or (mm-handle-description data)
4230 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4232 (type (mm-handle-media-type data)))
4234 (error "No MIME part under point"))
4235 (with-current-buffer (mm-handle-buffer data)
4236 (let ((bsize (format "%s" (buffer-size))))
4241 "| The following attachment has been deleted:\n"
4243 "| Type: " type "\n"
4244 "| Filename: " filename "\n"
4245 "| Size (encoded): " bsize " Byte\n"
4246 "| Description: " description "\n"
4249 (cdr (mm-make-handle
4250 nil `("text/plain") nil nil
4252 (format "Deleted attachment (%s bytes)" bsize))))))
4253 ;; (set-buffer gnus-summary-buffer)
4254 (gnus-article-edit-part handles id))))
4256 (defun gnus-mime-save-part ()
4257 "Save the MIME part under point."
4259 (gnus-article-check-buffer)
4260 (let ((data (get-text-property (point) 'gnus-data)))
4262 (mm-save-part data))))
4264 (defun gnus-mime-pipe-part ()
4265 "Pipe the MIME part under point to a process."
4267 (gnus-article-check-buffer)
4268 (let ((data (get-text-property (point) 'gnus-data)))
4270 (mm-pipe-part data))))
4272 (defun gnus-mime-view-part ()
4273 "Interactively choose a viewing method for the MIME part under point."
4275 (gnus-article-check-buffer)
4276 (let ((data (get-text-property (point) 'gnus-data)))
4278 (setq gnus-article-mime-handles
4280 gnus-article-mime-handles (setq data (copy-sequence data))))
4281 (mm-interactively-view-part data))))
4283 (defun gnus-mime-view-part-as-type-internal ()
4284 (gnus-article-check-buffer)
4285 (let* ((name (mail-content-type-get
4286 (mm-handle-type (get-text-property (point) 'gnus-data))
4288 (def-type (and name (mm-default-file-encoding name))))
4289 (and def-type (cons def-type 0))))
4291 (defun gnus-mime-view-part-as-type (&optional mime-type)
4292 "Choose a MIME media type, and view the part as such."
4295 (setq mime-type (completing-read
4296 "View as MIME type: "
4297 (mapcar #'list (mailcap-mime-types))
4299 (gnus-mime-view-part-as-type-internal))))
4300 (gnus-article-check-buffer)
4301 (let ((handle (get-text-property (point) 'gnus-data)))
4304 (mm-make-handle (mm-handle-buffer handle)
4305 (cons mime-type (cdr (mm-handle-type handle)))
4306 (mm-handle-encoding handle)
4307 (mm-handle-undisplayer handle)
4308 (mm-handle-disposition handle)
4309 (mm-handle-description handle)
4311 (mm-handle-id handle)))
4312 (setq gnus-article-mime-handles
4313 (mm-merge-handles gnus-article-mime-handles handle))
4314 (gnus-mm-display-part handle))))
4316 (defun gnus-mime-copy-part (&optional handle arg)
4317 "Put the MIME part under point into a new buffer.
4318 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4320 (interactive (list nil current-prefix-arg))
4321 (gnus-article-check-buffer)
4323 (setq handle (get-text-property (point) 'gnus-data)))
4325 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4327 (mail-content-type-get (mm-handle-disposition handle)
4329 contents dont-decode charset coding-system)
4330 (mm-with-unibyte-buffer
4331 (mm-insert-part handle)
4332 (setq contents (or (condition-case nil
4333 (mm-decompress-buffer filename nil 'sig)
4335 (setq dont-decode t)
4338 (setq filename (cond (filename (file-name-nondirectory filename))
4339 (dont-decode "*raw data*")
4344 (unless (setq charset (mail-content-type-get
4345 (mm-handle-type handle) 'charset))
4346 (unless (setq coding-system (mm-with-unibyte-buffer
4348 (mm-find-buffer-file-coding-system)))
4349 (setq charset gnus-newsgroup-charset))))
4351 (setq charset (or (cdr (assq arg
4352 gnus-summary-show-article-charset-alist))
4353 (mm-read-coding-system "Charset: ")))))
4354 (switch-to-buffer (generate-new-buffer filename))
4355 (if (or coding-system
4357 (setq coding-system (mm-charset-to-coding-system charset))
4358 (not (eq charset 'ascii))))
4360 (mm-enable-multibyte)
4361 (insert (mm-decode-coding-string contents coding-system))
4362 (setq buffer-file-coding-system
4363 (if (boundp 'last-coding-system-used)
4364 (symbol-value 'last-coding-system-used)
4366 (mm-disable-multibyte)
4368 (setq buffer-file-coding-system mm-binary-coding-system))
4369 ;; We do it this way to make `normal-mode' set the appropriate mode.
4372 (setq buffer-file-name (expand-file-name filename))
4374 (setq buffer-file-name nil))
4375 (goto-char (point-min)))))
4377 (defun gnus-mime-print-part (&optional handle filename)
4378 "Print the MIME part under point."
4379 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4380 (gnus-article-check-buffer)
4381 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4382 (contents (and handle (mm-get-part handle)))
4383 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4384 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4389 (mm-save-part-to-file handle file)
4390 (call-process shell-file-name nil
4391 (generate-new-buffer " *mm*")
4393 shell-command-switch
4395 printer file (mm-handle-type handle))))
4399 (gnus-print-buffer))
4400 (ps-despool filename)))))
4402 (defun gnus-mime-inline-part (&optional handle arg)
4403 "Insert the MIME part under point into the current buffer.
4404 Compressed files like .gz and .bz2 are decompressed."
4405 (interactive (list nil current-prefix-arg))
4406 (gnus-article-check-buffer)
4408 (setq handle (get-text-property (point) 'gnus-data)))
4411 (inhibit-read-only t)
4412 contents charset coding-system)
4413 (if (and (not arg) (mm-handle-undisplayer handle))
4414 (mm-remove-part handle)
4415 (mm-with-unibyte-buffer
4416 (mm-insert-part handle)
4418 (or (mm-decompress-buffer
4419 (or (mail-content-type-get (mm-handle-disposition handle)
4421 (mail-content-type-get (mm-handle-disposition handle)
4427 (unless (setq charset (mail-content-type-get
4428 (mm-handle-type handle) 'charset))
4429 (unless (setq coding-system
4430 (mm-with-unibyte-buffer
4432 (mm-find-buffer-file-coding-system)))
4433 (setq charset gnus-newsgroup-charset))))
4435 (if (mm-handle-undisplayer handle)
4436 (mm-remove-part handle))
4439 gnus-summary-show-article-charset-alist))
4440 (mm-read-coding-system "Charset: "))))
4442 (if (mm-handle-undisplayer handle)
4443 (mm-remove-part handle))))
4447 (if (or coding-system
4450 (mm-charset-to-coding-system charset))
4451 (not (eq coding-system 'ascii))))
4452 (mm-decode-coding-string contents coding-system)
4453 (mm-string-to-multibyte contents)))
4456 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4457 "Insert the MIME part under point into the current buffer using the
4459 (interactive (list nil current-prefix-arg))
4460 (gnus-article-check-buffer)
4461 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4464 (inhibit-read-only t))
4466 (if (mm-handle-undisplayer handle)
4467 (mm-remove-part handle))
4468 (let ((gnus-newsgroup-charset
4470 gnus-summary-show-article-charset-alist))
4471 (mm-read-coding-system "Charset: ")))
4472 (gnus-newsgroup-ignored-charsets 'gnus-all))
4473 (gnus-article-press-button)))))
4475 (defun gnus-mime-view-part-externally (&optional handle)
4476 "View the MIME part under point with an external viewer."
4478 (gnus-article-check-buffer)
4479 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4480 (mm-user-display-methods nil)
4481 (mm-inlined-types nil)
4482 (mail-parse-charset gnus-newsgroup-charset)
4483 (mail-parse-ignored-charsets
4484 (with-current-buffer gnus-summary-buffer
4485 gnus-newsgroup-ignored-charsets)))
4487 (if (mm-handle-undisplayer handle)
4488 (mm-remove-part handle)
4489 (mm-display-part handle)))))
4491 (defun gnus-mime-view-part-internally (&optional handle)
4492 "View the MIME part under point with an internal viewer.
4493 If no internal viewer is available, use an external viewer."
4495 (gnus-article-check-buffer)
4496 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4497 (mm-inlined-types '(".*"))
4498 (mm-inline-large-images t)
4499 (mail-parse-charset gnus-newsgroup-charset)
4500 (mail-parse-ignored-charsets
4501 (with-current-buffer gnus-summary-buffer
4502 gnus-newsgroup-ignored-charsets))
4503 (inhibit-read-only t))
4505 (if (mm-handle-undisplayer handle)
4506 (mm-remove-part handle)
4507 (mm-display-part handle)))))
4509 (defun gnus-mime-action-on-part (&optional action)
4510 "Do something with the MIME attachment at \(point\)."
4512 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4513 (gnus-article-check-buffer)
4514 (let ((action-pair (assoc action gnus-mime-action-alist)))
4516 (funcall (cdr action-pair)))))
4518 (defun gnus-article-part-wrapper (n function)
4519 (with-current-buffer gnus-article-buffer
4520 (when (> n (length gnus-article-mime-handle-alist))
4521 (error "No such part"))
4522 (gnus-article-goto-part n)
4523 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4524 (funcall function handle))))
4526 (defun gnus-article-pipe-part (n)
4527 "Pipe MIME part N, which is the numerical prefix."
4529 (gnus-article-part-wrapper n 'mm-pipe-part))
4531 (defun gnus-article-save-part (n)
4532 "Save MIME part N, which is the numerical prefix."
4534 (gnus-article-part-wrapper n 'mm-save-part))
4536 (defun gnus-article-interactively-view-part (n)
4537 "View MIME part N interactively, which is the numerical prefix."
4539 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4541 (defun gnus-article-copy-part (n)
4542 "Copy MIME part N, which is the numerical prefix."
4544 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4546 (defun gnus-article-view-part-as-charset (n)
4547 "View MIME part N using a specified charset.
4548 N is the numerical prefix."
4550 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4552 (defun gnus-article-view-part-externally (n)
4553 "View MIME part N externally, which is the numerical prefix."
4555 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4557 (defun gnus-article-inline-part (n)
4558 "Inline MIME part N, which is the numerical prefix."
4560 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4562 (defun gnus-article-mime-match-handle-first (condition)
4565 (dolist (ihandle gnus-article-mime-handle-alist)
4567 ((functionp condition)
4568 (funcall condition (cdr ihandle)))
4569 ((eq condition 'undisplayed)
4570 (not (or (mm-handle-undisplayer (cdr ihandle))
4571 (equal (mm-handle-media-type (cdr ihandle))
4572 "multipart/alternative"))))
4573 ((eq condition 'undisplayed-alternative)
4574 (not (mm-handle-undisplayer (cdr ihandle))))
4576 (gnus-article-goto-part (car ihandle))
4577 (or (not n) (< (car ihandle) n)))
4578 (setq n (car ihandle))))
4582 (defun gnus-article-view-part (&optional n)
4583 "View MIME part N, which is the numerical prefix."
4585 (with-current-buffer gnus-article-buffer
4586 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4587 gnus-article-mime-match-handle-function)))
4588 (when (> n (length gnus-article-mime-handle-alist))
4589 (error "No such part"))
4590 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4591 (when (gnus-article-goto-part n)
4592 (if (equal (car handle) "multipart/alternative")
4593 (gnus-article-press-button)
4594 (when (eq (gnus-mm-display-part handle) 'internal)
4595 (gnus-set-window-start)))))))
4597 (defsubst gnus-article-mime-total-parts ()
4598 (if (bufferp (car gnus-article-mime-handles))
4600 (1- (length gnus-article-mime-handles))))
4602 (defun gnus-mm-display-part (handle)
4603 "Display HANDLE and fix MIME button."
4604 (let ((id (get-text-property (point) 'gnus-part))
4606 (inhibit-read-only t))
4609 (let ((window (selected-window))
4610 (mail-parse-charset gnus-newsgroup-charset)
4611 (mail-parse-ignored-charsets
4612 (if (gnus-buffer-live-p gnus-summary-buffer)
4613 (with-current-buffer gnus-summary-buffer
4614 gnus-newsgroup-ignored-charsets)
4618 (let ((win (gnus-get-buffer-window (current-buffer) t))
4621 (select-window win))
4624 (if (mm-handle-displayed-p handle)
4625 ;; This will remove the part.
4626 (mm-display-part handle)
4628 (narrow-to-region (point)
4629 (if (eobp) (point) (1+ (point))))
4630 (mm-display-part handle)
4631 ;; We narrow to the part itself and
4632 ;; then call the treatment functions.
4633 (goto-char (point-min))
4635 (narrow-to-region (point) (point-max))
4638 (gnus-article-mime-total-parts)
4639 (mm-handle-media-type handle)))))
4640 (if (window-live-p window)
4641 (select-window window)))))
4644 (gnus-insert-mime-button
4645 handle id (list (mm-handle-displayed-p handle)))
4646 (goto-char point))))
4648 (defun gnus-article-goto-part (n)
4649 "Go to MIME part N."
4650 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4652 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4653 (let ((gnus-tmp-name
4654 (or (mail-content-type-get (mm-handle-type handle) 'name)
4655 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4656 (mail-content-type-get (mm-handle-type handle) 'url)
4658 (gnus-tmp-type (mm-handle-media-type handle))
4659 (gnus-tmp-description
4660 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4663 (if (if displayed (car displayed)
4664 (mm-handle-displayed-p handle))
4666 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4668 gnus-tmp-type-long b e)
4669 (when (string-match ".*/" gnus-tmp-name)
4670 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4671 (setq gnus-tmp-type-long (concat gnus-tmp-type
4672 (and (not (equal gnus-tmp-name ""))
4673 (concat "; " gnus-tmp-name))))
4674 (unless (equal gnus-tmp-description "")
4675 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4680 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4681 `(keymap ,gnus-mime-button-map
4682 gnus-callback gnus-mm-display-part
4683 gnus-part ,gnus-tmp-id
4684 article-type annotation
4687 ;; Exclude a newline.
4690 (widget-convert-button
4693 :action 'gnus-widget-press-button
4694 :button-keymap gnus-mime-button-map
4696 (lambda (widget/window &optional overlay pos)
4697 ;; Needed to properly clear the message due to a bug in
4698 ;; wid-edit (XEmacs only).
4699 (if (boundp 'help-echo-owns-message)
4700 (setq help-echo-owns-message t))
4702 "%S: %s the MIME part; %S: more options"
4703 (aref gnus-mouse-2 0)
4704 ;; XEmacs will get a single widget arg; Emacs 21 will get
4705 ;; window, overlay, position.
4706 (if (mm-handle-displayed-p
4708 (with-current-buffer (gnus-overlay-buffer overlay)
4709 (widget-get (widget-at (gnus-overlay-start overlay))
4711 (widget-get widget/window :mime-handle)))
4713 (aref gnus-down-mouse-3 0))))))
4715 (defun gnus-widget-press-button (elems el)
4716 (goto-char (widget-get elems :from))
4717 (gnus-article-press-button))
4719 (defvar gnus-displaying-mime nil)
4721 (defun gnus-display-mime (&optional ihandles)
4722 "Display the MIME parts."
4724 (save-selected-window
4725 (let ((window (get-buffer-window gnus-article-buffer))
4728 (select-window window)
4729 ;; We have to do this since selecting the window
4730 ;; may change the point. So we set the window point.
4731 (set-window-point window point)))
4732 (let ((handles ihandles)
4733 (inhibit-read-only t)
4736 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
4737 (when gnus-article-emulate-mime
4738 (mm-uu-dissect-text-parts handles)))
4739 (gnus-article-emulate-mime
4740 (setq handles (mm-uu-dissect))))
4741 (when (and (not ihandles)
4742 (not gnus-displaying-mime))
4743 ;; Top-level call; we clean up.
4744 (when gnus-article-mime-handles
4745 (mm-destroy-parts gnus-article-mime-handles)
4746 (setq gnus-article-mime-handle-alist nil));; A trick.
4747 (setq gnus-article-mime-handles handles)
4748 ;; We allow users to glean info from the handles.
4749 (when gnus-article-mime-part-function
4750 (gnus-mime-part-function handles)))
4752 (or (not (stringp (car handles)))
4755 (when (and (not ihandles)
4756 (not gnus-displaying-mime))
4757 ;; Clean up for mime parts.
4759 (delete-region (point) (point-max)))
4760 (let ((gnus-displaying-mime t))
4761 (gnus-mime-display-part handles)))
4764 (narrow-to-region (point) (point-max))
4765 (gnus-treat-article nil 1 1)
4768 ;; Highlight the headers.
4772 (narrow-to-region (point-min) (point))
4773 (gnus-article-save-original-date
4774 (gnus-treat-article 'head)))))))))
4776 (defcustom gnus-mime-display-multipart-as-mixed nil
4777 "Display \"multipart\" parts as \"multipart/mixed\".
4779 If t, it overrides nil values of
4780 `gnus-mime-display-multipart-alternative-as-mixed' and
4781 `gnus-mime-display-multipart-related-as-mixed'."
4782 :group 'gnus-article-mime
4785 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4786 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4788 :group 'gnus-article-mime
4791 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4792 "Display \"multipart/related\" parts as \"multipart/mixed\".
4794 If displaying \"text/html\" is discouraged \(see
4795 `mm-discouraged-alternatives'\) images or other material inside a
4796 \"multipart/related\" part might be overlooked when this variable is nil."
4798 :group 'gnus-article-mime
4801 (defun gnus-mime-display-part (handle)
4804 ((not (stringp (car handle)))
4805 (gnus-mime-display-single handle))
4806 ;; User-defined multipart
4807 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4808 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4810 ;; multipart/alternative
4811 ((and (equal (car handle) "multipart/alternative")
4812 (not (or gnus-mime-display-multipart-as-mixed
4813 gnus-mime-display-multipart-alternative-as-mixed)))
4814 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4815 (push (cons id handle) gnus-article-mime-handle-alist)
4816 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4817 ;; multipart/related
4818 ((and (equal (car handle) "multipart/related")
4819 (not (or gnus-mime-display-multipart-as-mixed
4820 gnus-mime-display-multipart-related-as-mixed)))
4821 ;;;!!!We should find the start part, but we just default
4822 ;;;!!!to the first part.
4823 ;;(gnus-mime-display-part (cadr handle))
4824 ;;;!!! Most multipart/related is an HTML message plus images.
4825 ;;;!!! Unfortunately we are unable to let W3 display those
4826 ;;;!!! included images, so we just display it as a mixed multipart.
4827 ;;(gnus-mime-display-mixed (cdr handle))
4828 ;;;!!! No, w3 can display everything just fine.
4829 (gnus-mime-display-part (cadr handle)))
4830 ((equal (car handle) "multipart/signed")
4831 (gnus-add-wash-type 'signed)
4832 (gnus-mime-display-security handle))
4833 ((equal (car handle) "multipart/encrypted")
4834 (gnus-add-wash-type 'encrypted)
4835 (gnus-mime-display-security handle))
4836 ;; Other multiparts are handled like multipart/mixed.
4838 (gnus-mime-display-mixed (cdr handle)))))
4840 (defun gnus-mime-part-function (handles)
4841 (if (stringp (car handles))
4842 (mapcar 'gnus-mime-part-function (cdr handles))
4843 (funcall gnus-article-mime-part-function handles)))
4845 (defun gnus-mime-display-mixed (handles)
4846 (mapcar 'gnus-mime-display-part handles))
4848 (defun gnus-mime-display-single (handle)
4849 (let ((type (mm-handle-media-type handle))
4850 (ignored gnus-ignored-mime-types)
4857 (when (string-match (pop ignored) type)
4858 (throw 'ignored nil)))
4859 (if (and (setq not-attachment
4860 (and (not (mm-inline-override-p handle))
4861 (or (not (mm-handle-disposition handle))
4862 (equal (car (mm-handle-disposition handle))
4864 (mm-attachment-override-p handle))))
4865 (mm-automatic-display-p handle)
4867 (mm-inlinable-p handle)
4868 (mm-inlined-p handle))
4869 (mm-automatic-external-display-p type)))
4871 (when (equal (mm-handle-media-supertype handle) "text")
4873 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4875 (push (cons id handle) gnus-article-mime-handle-alist)
4876 (when (or (not display)
4877 (not (gnus-unbuttonized-mime-type-p type)))
4878 (gnus-insert-mime-button
4879 handle id (list (or display (and not-attachment text))))
4880 (gnus-article-insert-newline)
4881 ;; Remember modify the number of forward lines.
4889 (let ((mail-parse-charset gnus-newsgroup-charset)
4890 (mail-parse-ignored-charsets
4891 (save-excursion (condition-case ()
4892 (set-buffer gnus-summary-buffer)
4894 gnus-newsgroup-ignored-charsets)))
4895 (mm-display-part handle t))
4896 (goto-char (point-max)))
4897 ((and text not-attachment)
4901 (gnus-article-insert-newline)
4902 (mm-display-inline handle)
4903 (goto-char (point-max))))
4907 (narrow-to-region beg (point))
4910 (gnus-article-mime-total-parts)
4911 (mm-handle-media-type handle)))))))))
4913 (defun gnus-unbuttonized-mime-type-p (type)
4914 "Say whether TYPE is to be unbuttonized."
4915 (unless gnus-inhibit-mime-unbuttonizing
4917 (let ((types gnus-unbuttonized-mime-types))
4919 (when (string-match (pop types) type)
4920 (throw 'found t)))))
4922 (let ((types gnus-buttonized-mime-types))
4924 (when (string-match (pop types) type)
4925 (throw 'found t)))))))))
4927 (defun gnus-article-insert-newline ()
4928 "Insert a newline, but mark it as undeletable."
4929 (gnus-put-text-property
4930 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4932 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4933 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4936 handle (inhibit-read-only t) from props begend not-pref)
4937 (save-window-excursion
4940 (narrow-to-region (car ibegend)
4943 (goto-char (car ibegend))
4946 (delete-region (point-min) (point-max))
4947 (mm-remove-parts handles))
4948 (setq begend (list (point-marker)))
4950 (unless (setq not-pref (cadr (member preferred ihandles)))
4951 (setq not-pref (car ihandles)))
4954 (not (gnus-unbuttonized-mime-type-p
4955 "multipart/alternative")))
4956 (gnus-add-text-properties
4959 (insert (format "%d. " id))
4963 (unless ,(not ibegend)
4964 (setq gnus-article-mime-handle-alist
4965 ',gnus-article-mime-handle-alist))
4966 (gnus-mime-display-alternative
4967 ',ihandles ',not-pref ',begend ,id))
4968 keymap ,gnus-mime-button-map
4969 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4970 face ,gnus-article-button-face
4973 (widget-convert-button 'link from (point)
4974 :action 'gnus-widget-press-button
4975 :button-keymap gnus-widget-button-keymap)
4977 (while (setq handle (pop handles))
4978 (gnus-add-text-properties
4981 (insert (format "(%c) %-18s"
4982 (if (equal handle preferred) ?* ? )
4983 (mm-handle-media-type handle)))
4987 (unless ,(not ibegend)
4988 (setq gnus-article-mime-handle-alist
4989 ',gnus-article-mime-handle-alist))
4990 (gnus-mime-display-alternative
4991 ',ihandles ',handle ',begend ,id))
4992 keymap ,gnus-mime-button-map
4993 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4994 face ,gnus-article-button-face
4997 (widget-convert-button 'link from (point)
4998 :action 'gnus-widget-press-button
4999 :button-keymap gnus-widget-button-keymap)
5003 (if (stringp (car preferred))
5004 (gnus-display-mime preferred)
5005 (let ((mail-parse-charset gnus-newsgroup-charset)
5006 (mail-parse-ignored-charsets
5007 (with-current-buffer gnus-summary-buffer
5008 gnus-newsgroup-ignored-charsets)))
5009 (mm-display-part preferred)
5013 (narrow-to-region (car begend) (point-max))
5015 nil (length gnus-article-mime-handle-alist)
5016 (gnus-article-mime-total-parts)
5017 (mm-handle-media-type handle))))))
5018 (goto-char (point-max))
5019 (setcdr begend (point-marker)))))
5021 (goto-char point))))
5023 (defconst gnus-article-wash-status-strings
5024 (let ((alist '((cite "c" "Possible hidden citation text"
5025 " " "All citation text visible")
5026 (headers "h" "Hidden headers"
5027 " " "All headers visible.")
5028 (pgp "p" "Encrypted or signed message status hidden"
5029 " " "No hidden encryption nor digital signature status")
5030 (signature "s" "Signature has been hidden"
5031 " " "Signature is visible")
5032 (overstrike "o" "Overstrike (^H) characters applied"
5033 " " "No overstrike characters applied")
5034 (emphasis "e" "/*_Emphasis_*/ characters applied"
5035 " " "No /*_emphasis_*/ characters applied")))
5037 (dolist (entry alist result)
5038 (let ((key (nth 0 entry))
5039 (on (copy-sequence (nth 1 entry)))
5040 (on-help (nth 2 entry))
5041 (off (copy-sequence (nth 3 entry)))
5042 (off-help (nth 4 entry)))
5043 (put-text-property 0 1 'help-echo on-help on)
5044 (put-text-property 0 1 'help-echo off-help off)
5045 (push (list key on off) result))))
5046 "Alist of strings describing wash status in the mode line.
5047 Each entry has the form (KEY ON OF), where the KEY is a symbol
5048 representing the particular washing function, ON is the string to use
5049 in the article mode line when the washing function is active, and OFF
5050 is the string to use when it is inactive.")
5052 (defun gnus-article-wash-status-entry (key value)
5053 (let ((entry (assoc key gnus-article-wash-status-strings)))
5054 (if value (nth 1 entry) (nth 2 entry))))
5056 (defun gnus-article-wash-status ()
5057 "Return a string which display status of article washing."
5058 (with-current-buffer gnus-article-buffer
5059 (let ((cite (memq 'cite gnus-article-wash-types))
5060 (headers (memq 'headers gnus-article-wash-types))
5061 (boring (memq 'boring-headers gnus-article-wash-types))
5062 (pgp (memq 'pgp gnus-article-wash-types))
5063 (pem (memq 'pem gnus-article-wash-types))
5064 (signed (memq 'signed gnus-article-wash-types))
5065 (encrypted (memq 'encrypted gnus-article-wash-types))
5066 (signature (memq 'signature gnus-article-wash-types))
5067 (overstrike (memq 'overstrike gnus-article-wash-types))
5068 (emphasis (memq 'emphasis gnus-article-wash-types)))
5070 (gnus-article-wash-status-entry 'cite cite)
5071 (gnus-article-wash-status-entry 'headers (or headers boring))
5072 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5073 (gnus-article-wash-status-entry 'signature signature)
5074 (gnus-article-wash-status-entry 'overstrike overstrike)
5075 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5077 (defun gnus-add-wash-type (type)
5078 "Add a washing of TYPE to the current status."
5079 (add-to-list 'gnus-article-wash-types type))
5081 (defun gnus-delete-wash-type (type)
5082 "Add a washing of TYPE to the current status."
5083 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5085 (defun gnus-add-image (category image)
5086 "Add IMAGE of CATEGORY to the list of displayed images."
5087 (let ((entry (assq category gnus-article-image-alist)))
5089 (setq entry (list category))
5090 (push entry gnus-article-image-alist))
5091 (nconc entry (list image))))
5093 (defun gnus-delete-images (category)
5094 "Delete all images in CATEGORY."
5095 (let ((entry (assq category gnus-article-image-alist)))
5096 (dolist (image (cdr entry))
5097 (gnus-remove-image image category))
5098 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5099 (gnus-delete-wash-type category)))
5101 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5103 (defun gnus-article-maybe-hide-headers ()
5104 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5105 Provided for backwards compatibility."
5106 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5107 (not (with-current-buffer gnus-summary-buffer
5108 gnus-have-all-headers)))
5109 (not gnus-inhibit-hiding))
5110 (gnus-article-hide-headers)))
5114 (defun gnus-output-to-file (file-name)
5115 "Append the current article to a file named FILE-NAME."
5116 (let ((artbuf (current-buffer)))
5118 (insert-buffer-substring artbuf)
5119 ;; Append newline at end of the buffer as separator, and then
5121 (goto-char (point-max))
5123 (let ((file-name-coding-system nnmail-pathname-coding-system))
5124 (mm-append-to-file (point-min) (point-max) file-name))
5127 (defun gnus-narrow-to-page (&optional arg)
5128 "Narrow the article buffer to a page.
5129 If given a numerical ARG, move forward ARG pages."
5131 (setq arg (if arg (prefix-numeric-value arg) 0))
5133 (set-buffer gnus-article-buffer)
5134 (goto-char (point-min))
5136 ;; Remove any old next/prev buttons.
5137 (when (gnus-visual-p 'page-marker)
5138 (let ((inhibit-read-only t))
5139 (gnus-remove-text-with-property 'gnus-prev)
5140 (gnus-remove-text-with-property 'gnus-next)))
5143 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5145 (re-search-forward page-delimiter nil 'move arg)))
5146 (goto-char (match-end 0))
5148 (goto-char (point-min))
5149 (setq gnus-page-broken
5150 (and (re-search-forward page-delimiter nil t) t))))
5151 (when gnus-page-broken
5154 (if (re-search-forward page-delimiter nil 'move)
5157 (when (and (gnus-visual-p 'page-marker)
5158 (> (point-min) (save-restriction (widen) (point-min))))
5160 (goto-char (point-min))
5161 (gnus-insert-prev-page-button)))
5162 (when (and (gnus-visual-p 'page-marker)
5163 (< (point-max) (save-restriction (widen) (point-max))))
5165 (goto-char (point-max))
5166 (gnus-insert-next-page-button))))))
5168 ;; Article mode commands
5170 (defun gnus-article-goto-next-page ()
5171 "Show the next page of the article."
5173 (when (gnus-article-next-page)
5174 (goto-char (point-min))
5175 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5178 (defun gnus-article-goto-prev-page ()
5179 "Show the previous page of the article."
5182 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5183 (gnus-article-prev-page nil)))
5185 ;; This is cleaner but currently breaks `gnus-pick-mode':
5187 ;; (defun gnus-article-goto-next-page ()
5188 ;; "Show the next page of the article."
5190 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5191 ;; (gnus-summary-next-page)))
5193 ;; (defun gnus-article-goto-prev-page ()
5194 ;; "Show the next page of the article."
5196 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5197 ;; (gnus-summary-prev-page)))
5199 (defun gnus-article-next-page (&optional lines)
5200 "Show the next page of the current article.
5201 If end of article, return non-nil. Otherwise return nil.
5202 Argument LINES specifies lines to be scrolled up."
5204 (move-to-window-line -1)
5207 (and (pos-visible-in-window-p) ;Not continuation line.
5208 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5209 ;; Nothing in this page.
5210 (if (or (not gnus-page-broken)
5215 (eobp)))) ;Real end-of-buffer?
5217 (when gnus-article-over-scroll
5218 (gnus-article-next-page-1 lines))
5220 (gnus-narrow-to-page 1) ;Go to next page.
5222 ;; More in this page.
5223 (gnus-article-next-page-1 lines)
5226 (defmacro gnus-article-beginning-of-window ()
5227 "Move point to the beginning of the window.
5228 In Emacs, the point is placed at the line number which `scroll-margin'
5230 (if (featurep 'xemacs)
5231 '(move-to-window-line 0)
5232 '(move-to-window-line
5233 (min (max 0 scroll-margin)
5234 (max 1 (- (window-height)
5235 (if mode-line-format 1 0)
5236 (if header-line-format 1 0)))))))
5238 (defun gnus-article-next-page-1 (lines)
5239 (when (and (not (featurep 'xemacs))
5242 (numberp (symbol-value 'scroll-margin))
5243 (> (symbol-value 'scroll-margin) 0))
5244 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5245 ;; too many number of lines if `scroll-margin' is set as two or greater.
5246 (setq lines (min lines
5247 (max 0 (- (count-lines (window-start) (point-max))
5248 (symbol-value 'scroll-margin))))))
5250 (let ((scroll-in-place nil))
5253 ;; Long lines may cause an end-of-buffer error.
5254 (goto-char (point-max))))
5255 (gnus-article-beginning-of-window))
5257 (defun gnus-article-prev-page (&optional lines)
5258 "Show previous page of current article.
5259 Argument LINES specifies lines to be scrolled down."
5261 (move-to-window-line 0)
5262 (if (and gnus-page-broken
5264 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5266 (gnus-narrow-to-page -1) ;Go to previous page.
5267 (goto-char (point-max))
5271 (let ((scroll-in-place nil))
5272 (scroll-down lines))
5273 (beginning-of-buffer
5274 (goto-char (point-min))))
5275 (gnus-article-beginning-of-window))))
5277 (defun gnus-article-only-boring-p ()
5278 "Decide whether there is only boring text remaining in the article.
5279 Something \"interesting\" is a word of at least two letters that does
5280 not have a face in `gnus-article-boring-faces'."
5281 (when (and gnus-article-skip-boring
5282 (boundp 'gnus-article-boring-faces)
5283 (symbol-value 'gnus-article-boring-faces))
5286 (while (re-search-forward "\\b\\w\\w" nil t)
5288 (when (not (gnus-intersection
5289 (gnus-faces-at (point))
5290 (symbol-value 'gnus-article-boring-faces)))
5291 (throw 'only-boring nil)))
5292 (throw 'only-boring t)))))
5294 (defun gnus-article-refer-article ()
5295 "Read article specified by message-id around point."
5298 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5299 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5300 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5301 (let ((msg-id (concat "<" (match-string 0) ">")))
5302 (set-buffer gnus-summary-buffer)
5303 (gnus-summary-refer-article msg-id))
5304 (error "No references around point"))))
5306 (defun gnus-article-show-summary ()
5307 "Reconfigure windows to show summary buffer."
5309 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5310 (error "There is no summary buffer for this article buffer")
5311 (gnus-article-set-globals)
5312 (gnus-configure-windows 'article)
5313 (gnus-summary-goto-subject gnus-current-article)
5314 (gnus-summary-position-point)))
5316 (defun gnus-article-describe-briefly ()
5317 "Describe article mode commands briefly."
5319 (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")))
5321 (defun gnus-article-summary-command ()
5322 "Execute the last keystroke in the summary buffer."
5324 (let ((obuf (current-buffer))
5325 (owin (current-window-configuration))
5327 (switch-to-buffer gnus-article-current-summary 'norecord)
5328 (setq func (lookup-key (current-local-map) (this-command-keys)))
5329 (call-interactively func)
5331 (set-window-configuration owin)
5332 (set-window-point (get-buffer-window (current-buffer)) (point))))
5334 (defun gnus-article-summary-command-nosave ()
5335 "Execute the last keystroke in the summary buffer."
5338 (pop-to-buffer gnus-article-current-summary 'norecord)
5339 (setq func (lookup-key (current-local-map) (this-command-keys)))
5340 (call-interactively func)))
5342 (defun gnus-article-check-buffer ()
5343 "Beep if not in an article buffer."
5344 (unless (equal major-mode 'gnus-article-mode)
5345 (error "Command invoked outside of a Gnus article buffer")))
5347 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5348 "Read a summary buffer key sequence and execute it from the article buffer."
5350 (gnus-article-check-buffer)
5352 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5353 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5354 "=" "^" "\M-^" "|"))
5360 '("n" "Gn" "p" "Gp"))
5363 (set-buffer gnus-article-current-summary)
5364 (let (gnus-pick-mode)
5365 (push (or key last-command-event) unread-command-events)
5366 (setq keys (if (featurep 'xemacs)
5367 (events-to-keys (read-key-sequence nil))
5368 (read-key-sequence nil)))))
5372 (if (or (member keys nosaves)
5373 (member keys nosave-but-article)
5374 (member keys nosave-in-article))
5376 (save-window-excursion
5377 (pop-to-buffer gnus-article-current-summary 'norecord)
5378 ;; We disable the pick minor mode commands.
5379 (let (gnus-pick-mode)
5380 (setq func (lookup-key (current-local-map) keys))))
5384 (unless (member keys nosave-in-article)
5385 (set-buffer gnus-article-current-summary))
5386 (call-interactively func)
5387 (setq new-sum-point (point)))
5388 (when (member keys nosave-but-article)
5389 (pop-to-buffer gnus-article-buffer 'norecord)))
5390 ;; These commands should restore window configuration.
5391 (let ((obuf (current-buffer))
5392 (owin (current-window-configuration))
5394 win func in-buffer selected new-sum-start new-sum-hscroll)
5395 (cond (not-restore-window
5396 (pop-to-buffer gnus-article-current-summary 'norecord))
5397 ((setq win (get-buffer-window gnus-article-current-summary))
5398 (select-window win))
5400 (switch-to-buffer gnus-article-current-summary 'norecord)))
5401 (setq in-buffer (current-buffer))
5402 ;; We disable the pick minor mode commands.
5403 (if (and (setq func (let (gnus-pick-mode)
5404 (lookup-key (current-local-map) keys)))
5407 (call-interactively func)
5408 (when (eq win (selected-window))
5409 (setq new-sum-point (point)
5410 new-sum-start (window-start win)
5411 new-sum-hscroll (window-hscroll win)))
5412 (when (eq in-buffer (current-buffer))
5413 (setq selected (gnus-summary-select-article))
5415 (unless not-restore-window
5416 (set-window-configuration owin))
5417 (when (eq selected 'old)
5419 (set-window-start (get-buffer-window (current-buffer))
5421 (set-window-point (get-buffer-window (current-buffer))
5423 (when (and (not not-restore-window)
5425 (set-window-point win new-sum-point)
5426 (set-window-start win new-sum-start)
5427 (set-window-hscroll win new-sum-hscroll))))
5428 (set-window-configuration owin)
5431 (defun gnus-article-describe-key (key)
5432 "Display documentation of the function invoked by KEY. KEY is a string."
5433 (interactive "kDescribe key: ")
5434 (gnus-article-check-buffer)
5435 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5437 (set-buffer gnus-article-current-summary)
5438 (let (gnus-pick-mode)
5439 (if (featurep 'xemacs)
5441 (push (elt key 0) unread-command-events)
5442 (setq key (events-to-keys
5443 (read-key-sequence "Describe key: "))))
5444 (setq unread-command-events
5446 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5447 (string-to-list key)))
5448 (setq key (read-key-sequence "Describe key: "))))
5450 (describe-key key)))
5452 (defun gnus-article-describe-key-briefly (key &optional insert)
5453 "Display documentation of the function invoked by KEY. KEY is a string."
5454 (interactive "kDescribe key: \nP")
5455 (gnus-article-check-buffer)
5456 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5458 (set-buffer gnus-article-current-summary)
5459 (let (gnus-pick-mode)
5460 (if (featurep 'xemacs)
5462 (push (elt key 0) unread-command-events)
5463 (setq key (events-to-keys
5464 (read-key-sequence "Describe key: "))))
5465 (setq unread-command-events
5467 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5468 (string-to-list key)))
5469 (setq key (read-key-sequence "Describe key: "))))
5470 (describe-key-briefly key insert))
5471 (describe-key-briefly key insert)))
5473 (defun gnus-article-reply-with-original (&optional wide)
5474 "Start composing a reply mail to the current message.
5475 The text in the region will be yanked. If the region isn't active,
5476 the entire article will be yanked."
5478 (let ((article (cdr gnus-article-current))
5480 (if (not (gnus-region-active-p))
5481 (with-current-buffer gnus-summary-buffer
5482 (gnus-summary-reply (list (list article)) wide))
5483 (setq contents (buffer-substring (point) (mark t)))
5484 ;; Deactivate active regions.
5485 (when (and (boundp 'transient-mark-mode)
5486 transient-mark-mode)
5487 (setq mark-active nil))
5488 (with-current-buffer gnus-summary-buffer
5490 (list (list article contents)) wide)))))
5492 (defun gnus-article-followup-with-original ()
5493 "Compose a followup to the current article.
5494 The text in the region will be yanked. If the region isn't active,
5495 the entire article will be yanked."
5497 (let ((article (cdr gnus-article-current))
5499 (if (not (gnus-region-active-p))
5500 (with-current-buffer gnus-summary-buffer
5501 (gnus-summary-followup (list (list article))))
5502 (setq contents (buffer-substring (point) (mark t)))
5503 ;; Deactivate active regions.
5504 (when (and (boundp 'transient-mark-mode)
5505 transient-mark-mode)
5506 (setq mark-active nil))
5507 (with-current-buffer gnus-summary-buffer
5508 (gnus-summary-followup
5509 (list (list article contents)))))))
5511 (defun gnus-article-hide (&optional arg force)
5512 "Hide all the gruft in the current article.
5513 This means that signatures, cited text and (some) headers will be
5515 If given a prefix, show the hidden text instead."
5516 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5517 (gnus-article-hide-headers arg)
5518 (gnus-article-hide-list-identifiers arg)
5519 (gnus-article-hide-citation-maybe arg force)
5520 (gnus-article-hide-signature arg))
5522 (defun gnus-article-maybe-highlight ()
5523 "Do some article highlighting if article highlighting is requested."
5524 (when (gnus-visual-p 'article-highlight 'highlight)
5525 (gnus-article-highlight-some)))
5527 (defun gnus-check-group-server ()
5528 ;; Make sure the connection to the server is alive.
5529 (unless (gnus-server-opened
5530 (gnus-find-method-for-group gnus-newsgroup-name))
5531 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5532 (gnus-request-group gnus-newsgroup-name t)))
5535 (autoload 'nneething-get-file-name "nneething"))
5537 (defun gnus-request-article-this-buffer (article group)
5538 "Get an article and insert it into this buffer."
5539 (let (do-update-line sparse-header)
5543 (gnus-kill-all-overlays)
5544 (setq group (or group gnus-newsgroup-name))
5546 ;; Using `gnus-request-article' directly will insert the article into
5547 ;; `nntp-server-buffer' - so we'll save some time by not having to
5548 ;; copy it from the server buffer into the article buffer.
5550 ;; We only request an article by message-id when we do not have the
5551 ;; headers for it, so we'll have to get those.
5552 (when (stringp article)
5553 (gnus-read-header article))
5555 ;; If the article number is negative, that means that this article
5556 ;; doesn't belong in this newsgroup (possibly), so we find its
5557 ;; message-id and request it by id instead of number.
5558 (when (and (numberp article)
5560 (get-buffer gnus-summary-buffer)
5561 (gnus-buffer-exists-p gnus-summary-buffer))
5563 (set-buffer gnus-summary-buffer)
5564 (let ((header (gnus-summary-article-header article)))
5567 ((memq article gnus-newsgroup-sparse)
5568 ;; This is a sparse gap article.
5569 (setq do-update-line article)
5570 (setq article (mail-header-id header))
5571 (setq sparse-header (gnus-read-header article))
5572 (setq gnus-newsgroup-sparse
5573 (delq article gnus-newsgroup-sparse)))
5575 ;; It's a real article.
5576 (setq article (mail-header-id header)))
5578 ;; It is an extracted pseudo-article.
5579 (setq article 'pseudo)
5580 (gnus-request-pseudo-article header))))
5582 (let ((method (gnus-find-method-for-group
5583 gnus-newsgroup-name)))
5584 (when (and (eq (car method) 'nneething)
5586 (let ((dir (nneething-get-file-name
5587 (mail-header-id header))))
5588 (when (and (stringp dir)
5589 (file-directory-p dir))
5590 (setq article 'nneething)
5591 (gnus-group-enter-directory dir))))))))
5594 ;; Refuse to select canceled articles.
5595 ((and (numberp article)
5597 (get-buffer gnus-summary-buffer)
5598 (gnus-buffer-exists-p gnus-summary-buffer)
5599 (eq (cdr (with-current-buffer gnus-summary-buffer
5600 (assq article gnus-newsgroup-reads)))
5601 gnus-canceled-mark))
5603 ;; We first check `gnus-original-article-buffer'.
5604 ((and (get-buffer gnus-original-article-buffer)
5606 (with-current-buffer gnus-original-article-buffer
5607 (and (equal (car gnus-original-article) group)
5608 (eq (cdr gnus-original-article) article))))
5609 (insert-buffer-substring gnus-original-article-buffer)
5611 ;; Check the backlog.
5612 ((and gnus-keep-backlog
5613 (gnus-backlog-request-article group article (current-buffer)))
5615 ;; Check asynchronous pre-fetch.
5616 ((gnus-async-request-fetched-article group article (current-buffer))
5617 (gnus-async-prefetch-next group article gnus-summary-buffer)
5618 (when (and (numberp article) gnus-keep-backlog)
5619 (gnus-backlog-enter-article group article (current-buffer)))
5622 ((and gnus-use-cache
5624 (gnus-cache-request-article article group))
5626 ;; Check the agent cache.
5627 ((gnus-agent-request-article article group)
5629 ;; Get the article and put into the article buffer.
5630 ((or (stringp article)
5632 (let ((gnus-override-method gnus-override-method)
5633 (methods (and (stringp article)
5634 gnus-refer-article-method))
5635 (backend (car (gnus-find-method-for-group
5636 gnus-newsgroup-name)))
5638 (inhibit-read-only t))
5639 (if (or (not (listp methods))
5640 (and (symbolp (car methods))
5641 (assq (car methods) nnoo-definition-alist)))
5642 (setq methods (list methods)))
5643 (when (and (null gnus-override-method)
5645 (setq gnus-override-method (pop methods)))
5647 (when (eq gnus-override-method 'current)
5648 (setq gnus-override-method
5649 (with-current-buffer gnus-summary-buffer
5650 gnus-current-select-method)))
5652 (gnus-kill-all-overlays)
5653 (let ((gnus-newsgroup-name group))
5654 (gnus-check-group-server))
5656 ((gnus-request-article article group (current-buffer))
5657 (when (numberp article)
5658 (gnus-async-prefetch-next group article
5659 gnus-summary-buffer)
5660 (when gnus-keep-backlog
5661 (gnus-backlog-enter-article
5662 group article (current-buffer))))
5663 (setq result 'article))
5665 (setq gnus-override-method (pop methods)))
5666 ((not (string-match "^400 "
5667 (nnheader-get-report backend)))
5668 ;; If we get 400 server disconnect, reconnect and
5669 ;; retry; otherwise, assume the article has expired.
5670 (setq result 'done))))
5671 (and (eq result 'article) 'article)))
5675 ;; Associate this article with the current summary buffer.
5676 (setq gnus-article-current-summary gnus-summary-buffer)
5678 ;; Take the article from the original article buffer
5679 ;; and place it in the buffer it's supposed to be in.
5680 (when (and (get-buffer gnus-article-buffer)
5681 (equal (buffer-name (current-buffer))
5682 (buffer-name (get-buffer gnus-article-buffer))))
5684 (if (get-buffer gnus-original-article-buffer)
5685 (set-buffer gnus-original-article-buffer)
5686 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5687 (buffer-disable-undo)
5688 (setq major-mode 'gnus-original-article-mode)
5689 (setq buffer-read-only t))
5690 (let ((inhibit-read-only t))
5692 (insert-buffer-substring gnus-article-buffer))
5693 (setq gnus-original-article (cons group article)))
5696 (run-hooks 'gnus-article-decode-hook)
5697 ;; Mark article as decoded or not.
5698 (setq gnus-article-decoded-p gnus-article-decode-hook))
5700 ;; Update sparse articles.
5701 (when (and do-update-line
5702 (or (numberp article)
5704 (let ((buf (current-buffer)))
5705 (set-buffer gnus-summary-buffer)
5706 (gnus-summary-update-article do-update-line sparse-header)
5707 (gnus-summary-goto-subject do-update-line nil t)
5708 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5710 (set-buffer buf))))))
5716 (defcustom gnus-article-edit-mode-hook nil
5717 "Hook run in article edit mode buffers."
5718 :group 'gnus-article-various
5721 (defvar gnus-article-edit-done-function nil)
5723 (defvar gnus-article-edit-mode-map nil)
5725 ;; Should we be using derived.el for this?
5726 (unless gnus-article-edit-mode-map
5727 (setq gnus-article-edit-mode-map (make-keymap))
5728 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5730 (gnus-define-keys gnus-article-edit-mode-map
5731 "\C-c?" describe-mode
5732 "\C-c\C-c" gnus-article-edit-done
5733 "\C-c\C-k" gnus-article-edit-exit
5734 "\C-c\C-f\C-t" message-goto-to
5735 "\C-c\C-f\C-o" message-goto-from
5736 "\C-c\C-f\C-b" message-goto-bcc
5737 ;;"\C-c\C-f\C-w" message-goto-fcc
5738 "\C-c\C-f\C-c" message-goto-cc
5739 "\C-c\C-f\C-s" message-goto-subject
5740 "\C-c\C-f\C-r" message-goto-reply-to
5741 "\C-c\C-f\C-n" message-goto-newsgroups
5742 "\C-c\C-f\C-d" message-goto-distribution
5743 "\C-c\C-f\C-f" message-goto-followup-to
5744 "\C-c\C-f\C-m" message-goto-mail-followup-to
5745 "\C-c\C-f\C-k" message-goto-keywords
5746 "\C-c\C-f\C-u" message-goto-summary
5747 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5748 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5749 "\C-c\C-b" message-goto-body
5750 "\C-c\C-i" message-goto-signature
5752 "\C-c\C-t" message-insert-to
5753 "\C-c\C-n" message-insert-newsgroups
5754 "\C-c\C-o" message-sort-headers
5755 "\C-c\C-e" message-elide-region
5756 "\C-c\C-v" message-delete-not-region
5757 "\C-c\C-z" message-kill-to-signature
5758 "\M-\r" message-newline-and-reformat
5759 "\C-c\C-a" mml-attach-file
5760 "\C-a" message-beginning-of-line
5762 "\M-;" comment-region)
5764 (gnus-define-keys (gnus-article-edit-wash-map
5765 "\C-c\C-w" gnus-article-edit-mode-map)
5766 "f" gnus-article-edit-full-stops))
5769 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5771 ["Fetch To" message-insert-to t]
5772 ["Fetch Newsgroups" message-insert-newsgroups t]
5774 ["To" message-goto-to t]
5775 ["From" message-goto-from t]
5776 ["Subject" message-goto-subject t]
5777 ["Cc" message-goto-cc t]
5778 ["Reply-To" message-goto-reply-to t]
5779 ["Summary" message-goto-summary t]
5780 ["Keywords" message-goto-keywords t]
5781 ["Newsgroups" message-goto-newsgroups t]
5782 ["Followup-To" message-goto-followup-to t]
5783 ["Mail-Followup-To" message-goto-mail-followup-to t]
5784 ["Distribution" message-goto-distribution t]
5785 ["Body" message-goto-body t]
5786 ["Signature" message-goto-signature t]))
5788 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5789 "Major mode for editing articles.
5790 This is an extended text-mode.
5792 \\{gnus-article-edit-mode-map}"
5793 (make-local-variable 'gnus-article-edit-done-function)
5794 (make-local-variable 'gnus-prev-winconf)
5795 (set (make-local-variable 'font-lock-defaults)
5796 '(message-font-lock-keywords t))
5797 (set (make-local-variable 'mail-header-separator) "")
5798 (set (make-local-variable 'gnus-article-edit-mode) t)
5799 (easy-menu-add message-mode-field-menu message-mode-map)
5801 (setq buffer-read-only nil)
5802 (buffer-enable-undo)
5805 (defun gnus-article-edit (&optional force)
5806 "Edit the current article.
5807 This will have permanent effect only in mail groups.
5808 If FORCE is non-nil, allow editing of articles even in read-only
5811 (when (and (not force)
5812 (gnus-group-read-only-p))
5813 (error "The current newsgroup does not support article editing"))
5814 (gnus-article-date-original)
5815 (gnus-article-edit-article
5817 `(lambda (no-highlight)
5819 (gnus-summary-edit-article-done
5820 ,(or (mail-header-references gnus-current-headers) "")
5821 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5823 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
5824 "Start editing the contents of the current article buffer."
5825 (let ((winconf (current-window-configuration)))
5826 (set-buffer gnus-article-buffer)
5827 (let ((message-auto-save-directory
5828 ;; Don't associate the article buffer with a draft file.
5830 (gnus-article-edit-mode))
5831 (funcall start-func)
5832 (set-buffer-modified-p nil)
5833 (gnus-configure-windows 'edit-article)
5834 (setq gnus-article-edit-done-function exit-func)
5835 (setq gnus-prev-winconf winconf)
5837 (gnus-message 6 "C-c C-c to end edits"))))
5839 (defun gnus-article-edit-done (&optional arg)
5840 "Update the article edits and exit."
5842 (let ((func gnus-article-edit-done-function)
5843 (buf (current-buffer))
5844 (start (window-start))
5846 (winconf gnus-prev-winconf))
5847 (widen) ;; Widen it in case that users narrowed the buffer.
5850 ;; The cache and backlog have to be flushed somewhat.
5851 (when gnus-keep-backlog
5852 (gnus-backlog-remove-article
5853 (car gnus-article-current) (cdr gnus-article-current)))
5854 ;; Flush original article as well.
5856 (when (get-buffer gnus-original-article-buffer)
5857 (set-buffer gnus-original-article-buffer)
5858 (setq gnus-original-article nil)))
5859 (when gnus-use-cache
5860 (gnus-cache-update-article
5861 (car gnus-article-current) (cdr gnus-article-current)))
5862 ;; We remove all text props from the article buffer.
5863 (kill-all-local-variables)
5864 (set-text-properties (point-min) (point-max) nil)
5866 (set-window-configuration winconf)
5868 (set-window-start (get-buffer-window buf) start)
5869 (set-window-point (get-buffer-window buf) (point)))
5870 (gnus-summary-show-article))
5872 (defun gnus-article-edit-exit ()
5873 "Exit the article editing without updating."
5875 (when (or (not (buffer-modified-p))
5876 (yes-or-no-p "Article modified; kill anyway? "))
5877 (let ((curbuf (current-buffer))
5879 (window-start (window-start)))
5881 (if (gnus-buffer-live-p gnus-original-article-buffer)
5882 (insert-buffer-substring gnus-original-article-buffer))
5883 (let ((winconf gnus-prev-winconf))
5884 (kill-all-local-variables)
5886 (set-window-configuration winconf)
5887 ;; Tippy-toe some to make sure that point remains where it was.
5888 (save-current-buffer
5890 (set-window-start (get-buffer-window (current-buffer)) window-start)
5892 (gnus-summary-show-article)))
5894 (defun gnus-article-edit-full-stops ()
5895 "Interactively repair spacing at end of sentences."
5898 (goto-char (point-min))
5899 (search-forward-regexp "^$" nil t)
5900 (let ((case-fold-search nil))
5901 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5904 ;;; Article highlights
5907 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5909 ;;; Internal Variables:
5911 (defcustom gnus-button-url-regexp
5912 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5913 "\\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:]]\\)"
5914 "\\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\\)\\)")
5915 "Regular expression that matches URLs."
5916 :group 'gnus-article-buttons
5919 (defcustom gnus-button-valid-fqdn-regexp
5920 message-valid-fqdn-regexp
5921 "Regular expression that matches a valid FQDN."
5923 :group 'gnus-article-buttons
5926 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5927 (defcustom gnus-button-valid-localpart-regexp
5928 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*"
5929 "Regular expression that matches a localpart of mail addresses or MIDs."
5931 :group 'gnus-article-buttons
5934 (defcustom gnus-button-man-handler 'manual-entry
5935 "Function to use for displaying man pages.
5936 The function must take at least one argument with a string naming the
5939 :type '(choice (function-item :tag "Man" manual-entry)
5940 (function-item :tag "Woman" woman)
5941 (function :tag "Other"))
5942 :group 'gnus-article-buttons)
5944 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5945 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5946 If the default site is too slow, try to find a CTAN mirror, see
5947 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5948 the variable `gnus-button-handle-ctan'."
5950 :group 'gnus-article-buttons
5951 :link '(custom-manual "(gnus)Group Parameters")
5952 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5953 (const "http://tug.ctan.org/tex-archive/")
5954 (const "http://www.dante.de/CTAN/")
5955 (string :tag "Other")))
5957 (defcustom gnus-button-ctan-handler 'browse-url
5958 "Function to use for displaying CTAN links.
5959 The function must take one argument, the string naming the URL."
5961 :type '(choice (function-item :tag "Browse Url" browse-url)
5962 (function :tag "Other"))
5963 :group 'gnus-article-buttons)
5965 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5966 "Bogus strings removed from CTAN URLs."
5968 :group 'gnus-article-buttons
5969 :type '(choice (const "^/?tex-archive/\\|/")
5970 (regexp :tag "Other")))
5972 (defcustom gnus-button-ctan-directory-regexp
5974 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
5975 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
5976 "languages" "macros" "nonfree" "obsolete" "support" "systems"
5977 "tds" "tools" "usergrps" "web") t)
5978 "Regular expression for ctan directories.
5979 It should match all directories in the top level of `gnus-ctan-url'."
5981 :group 'gnus-article-buttons
5984 (defcustom gnus-button-mid-or-mail-regexp
5985 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
5986 gnus-button-valid-fqdn-regexp
5988 "Regular expression that matches a message ID or a mail address."
5990 :group 'gnus-article-buttons
5993 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5994 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5995 Strings like this can be either a message ID or a mail address. If it is one
5996 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5997 message ID or a mail address, respectively. If this variable is set to the
5998 symbol `ask', always query the user what do do. If it is a function, this
5999 function will be called with the string as it's only argument. The function
6000 must return `mid', `mail', `invalid' or `ask'."
6002 :group 'gnus-article-buttons
6003 :type '(choice (function-item :tag "Heuristic function"
6004 gnus-button-mid-or-mail-heuristic)
6009 (defcustom gnus-button-mid-or-mail-heuristic-alist
6010 '((-10.0 . ".+\\$.+@")
6013 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6014 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6015 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6016 (-1.0 . "^[^a-z]+@")
6018 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6019 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6020 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6021 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6024 (-1.0 . "^[0-9][0-9]")
6026 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6027 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6028 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6029 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6031 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6032 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6035 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6037 ;; compensation for TDMA dated mail addresses:
6038 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6040 (-20.0 . "\\.fsf@") ;; Gnus
6043 (-20.0 . "_-_") ;; Subject change in thread
6045 (-20.0 . "\\.ln@") ;; leafnode
6046 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6047 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6049 ;; (5.0 . "") ;; $local_part_len <= 7
6050 (10.0 . "^[^0-9]+@")
6051 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6052 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6055 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6057 (0.5 . "^[A-Z][a-z]")
6058 (0.5 . "^[A-Z][a-z][a-z]")
6059 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6060 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6061 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6063 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6064 address. The REGEXP is processed with `case-fold-search' set to nil."
6066 :group 'gnus-article-buttons
6067 :type '(repeat (cons (number :tag "Rate")
6068 (regexp :tag "Regexp"))))
6070 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6071 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6072 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6073 address, `ask' if unsure and `invalid' if the string is invalid."
6074 (let ((case-fold-search nil)
6075 (list gnus-button-mid-or-mail-heuristic-alist)
6076 (result 0) rate regexp lpartlen elem)
6078 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6079 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6080 ;; Certain special cases...
6083 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6084 "^[0-9]+\\.[0-9]+@compuserve\\|"
6085 "@public\\.gmane\\.org")
6087 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6088 (setq result 'mail))
6089 (when (string-match "@.*@\\| " mid-or-mail)
6090 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6091 (setq result 'invalid))
6092 ;; Nothing more to do, if result is not a number here...
6093 (when (numberp result)
6095 (setq elem (car list)
6099 (when (string-match regexp mid-or-mail)
6100 (setq result (+ result rate))
6102 9 "`%s' matched `%s', rate `%s', result `%s'."
6103 mid-or-mail regexp rate result)))
6104 (when (<= lpartlen 7)
6105 (setq result (+ result 5.0))
6106 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6107 mid-or-mail result))
6108 (when (>= lpartlen 12)
6109 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6111 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6112 ;; Long local part should contain realname if e-mail address,
6113 ;; too many digits: message-id.
6114 ;; $score -= 5.0 + 0.1 * $local_part_len;
6115 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6116 (setq result (+ result rate))
6118 9 "Many digits in `%s', rate `%s', result `%s'."
6119 mid-or-mail rate result))
6120 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6122 ;; Too few vowels [^aeiouy]{4,}.*\@
6123 (setq result (+ result -5.0))
6125 9 "Few vowels in `%s', rate `%s', result `%s'."
6126 mid-or-mail -5.0 result))
6128 (setq result (+ result 5.0))
6130 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6131 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6132 ;; Maybe we should make this a customizable alist: (condition . 'result)
6134 ((symbolp result) result)
6135 ;; Now convert number into proper results:
6136 ((< result -10.0) 'mid)
6137 ((> result 10.0) 'mail)
6140 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6141 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6142 (url-mid (concat "news" ":" mid-or-mail))
6143 (url-mailto (concat "mailto" ":" mid-or-mail)))
6144 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6145 (when (fboundp pref)
6147 ;; get rid of surrounding angles...
6149 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6150 (if (or (eq 'mid guessed) (eq 'mail guessed))
6154 (save-window-excursion
6155 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6158 (cond ((eq pref 'mid)
6159 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6160 (gnus-button-handle-news url-mid))
6162 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6163 (gnus-url-mailto url-mailto))
6164 (t (gnus-message 3 "Invalid string.")))))
6166 (defun gnus-button-handle-custom (url)
6167 "Follow a Custom URL."
6168 (customize-apropos (gnus-url-unhex-string url)))
6170 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6172 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6175 (defun gnus-button-handle-describe-function (url)
6176 "Call `describe-function' when pushing the corresponding URL button."
6179 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6181 (defun gnus-button-handle-describe-variable (url)
6182 "Call `describe-variable' when pushing the corresponding URL button."
6185 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6187 (defun gnus-button-handle-symbol (url)
6188 "Display help on variable or function.
6189 Calls `describe-variable' or `describe-function'."
6190 (let ((sym (intern url)))
6192 ((fboundp sym) (describe-function sym))
6193 ((boundp sym) (describe-variable sym))
6194 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6196 (defun gnus-button-handle-describe-key (url)
6197 "Call `describe-key' when pushing the corresponding URL button."
6199 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6200 (keys (ignore-errors (eval `(kbd ,key-string)))))
6203 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6205 (defun gnus-button-handle-apropos (url)
6206 "Call `apropos' when pushing the corresponding URL button."
6207 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6209 (defun gnus-button-handle-apropos-command (url)
6210 "Call `apropos' when pushing the corresponding URL button."
6212 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6214 (defun gnus-button-handle-apropos-variable (url)
6215 "Call `apropos' when pushing the corresponding URL button."
6217 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6218 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6220 (defun gnus-button-handle-apropos-documentation (url)
6221 "Call `apropos' when pushing the corresponding URL button."
6223 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6224 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6226 (defun gnus-button-handle-library (url)
6227 "Call `locate-library' when pushing the corresponding URL button."
6228 (gnus-message 9 "url=`%s'" url)
6229 (let* ((lib (locate-library url))
6230 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6232 (gnus-message 1 "Cannot locale library `%s'." url)
6233 (find-file-read-only file))))
6235 (defun gnus-button-handle-ctan (url)
6236 "Call `browse-url' when pushing a CTAN URL button."
6238 gnus-button-ctan-handler
6241 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6243 (defcustom gnus-button-tex-level 5
6244 "*Integer that says how many TeX-related buttons Gnus will show.
6245 The higher the number, the more buttons will appear and the more false
6246 positives are possible. Note that you can set this variable local to
6247 specific groups. Setting it higher in TeX groups is probably a good idea.
6248 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6249 how to set variables in specific groups."
6251 :group 'gnus-article-buttons
6252 :link '(custom-manual "(gnus)Group Parameters")
6255 (defcustom gnus-button-man-level 5
6256 "*Integer that says how many man-related buttons Gnus will show.
6257 The higher the number, the more buttons will appear and the more false
6258 positives are possible. Note that you can set this variable local to
6259 specific groups. Setting it higher in Unix groups is probably a good idea.
6260 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6261 how to set variables in specific groups."
6263 :group 'gnus-article-buttons
6264 :link '(custom-manual "(gnus)Group Parameters")
6267 (defcustom gnus-button-emacs-level 5
6268 "*Integer that says how many emacs-related buttons Gnus will show.
6269 The higher the number, the more buttons will appear and the more false
6270 positives are possible. Note that you can set this variable local to
6271 specific groups. Setting it higher in Emacs or Gnus related groups is
6272 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6273 `gnus-parameters' on how to set variables in specific groups."
6275 :group 'gnus-article-buttons
6276 :link '(custom-manual "(gnus)Group Parameters")
6279 (defcustom gnus-button-message-level 5
6280 "*Integer that says how many buttons for news or mail messages will appear.
6281 The higher the number, the more buttons will appear and the more false
6282 positives are possible."
6283 ;; mail addresses, MIDs, URLs for news, ...
6285 :group 'gnus-article-buttons
6288 (defcustom gnus-button-browse-level 5
6289 "*Integer that says how many buttons for browsing will appear.
6290 The higher the number, the more buttons will appear and the more false
6291 positives are possible."
6292 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6294 :group 'gnus-article-buttons
6297 (defcustom gnus-button-alist
6298 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6299 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6300 ((concat "\\b\\(nntp\\|news\\):\\("
6301 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6302 0 t gnus-button-handle-news 2)
6303 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6304 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6305 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6306 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6307 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6308 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6309 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6310 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6311 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6312 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6313 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6314 ;; RFC 2368 (The mailto URL scheme)
6315 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6316 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6317 ("\\bmailto:\\([^ \n\t]+\\)"
6318 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6320 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6321 gnus-button-ctan-directory-regexp
6322 "[^][>)!;:,'\n\t ]+\\)")
6323 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6324 ((concat "\\btex-archive/\\("
6325 gnus-button-ctan-directory-regexp
6326 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6327 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6330 gnus-button-ctan-directory-regexp
6331 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6332 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6333 ;; This is info (home-grown style) <info://foo/bar+baz>
6334 ("\\binfo://\\([^'\">\n\t ]+\\)"
6335 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6336 ;; Info GNOME style <info:foo#bar_baz>
6337 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6338 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6339 ;; Info KDE style <info:(foo)bar baz>
6340 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6341 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6342 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6343 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6344 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6345 ;; Info links like `C-h i d m CC Mode RET'
6346 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6348 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6349 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6350 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6351 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6352 ;; Emacs help commands
6353 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6354 ;; regexp doesn't match arguments containing ` '.
6355 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6356 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6357 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6358 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6359 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6360 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6361 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6362 ;; The following entries may lead to many false positives so don't enable
6363 ;; them by default (use a high button level).
6364 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6365 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6366 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6367 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6368 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6369 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6370 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6371 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6372 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6373 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6374 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6375 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6376 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6377 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6378 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6379 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6380 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6381 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6382 ;; Unlike the other regexps we really have to require quoting
6383 ;; here to determine where it ends.
6384 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6385 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6386 ("<URL: *\\([^<>]*\\)>"
6387 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6388 ;; RFC 2396 (2.4.3., delims) ...
6389 ("\"URL: *\\([^\"]*\\)\""
6390 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6391 ;; RFC 2396 (2.4.3., delims) ...
6392 ("\"URL: *\\([^\"]*\\)\""
6393 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6395 (gnus-button-url-regexp
6396 0 (>= gnus-button-browse-level 0) browse-url 0)
6398 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6399 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6400 gnus-button-handle-man 1)
6401 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6402 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6403 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6404 gnus-button-handle-man 1)
6405 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6406 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6407 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6408 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6409 ;; MID or mail: To avoid too many false positives we don't try to catch
6410 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6411 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6412 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6413 ;; so that non-ambiguous entries (see above) match first.
6414 (gnus-button-mid-or-mail-regexp
6415 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6416 "*Alist of regexps matching buttons in article bodies.
6418 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6419 REGEXP: is the string (case insensitive) matching text around the button (can
6420 also be Lisp expression evaluating to a string),
6421 BUTTON: is the number of the regexp grouping actually matching the button,
6422 FORM: is a Lisp expression which must eval to true for the button to
6424 CALLBACK: is the function to call when the user push this button, and each
6425 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6427 CALLBACK can also be a variable, in that case the value of that
6428 variable it the real callback function."
6429 :group 'gnus-article-buttons
6430 :type '(repeat (list (choice regexp variable sexp)
6431 (integer :tag "Button")
6433 (function :tag "Callback")
6436 (integer :tag "Regexp group")))))
6438 (defcustom gnus-header-button-alist
6439 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6440 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6441 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6442 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6443 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6444 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6445 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6446 0 (>= gnus-button-browse-level 0) browse-url 0)
6447 ("^Subject:" gnus-button-url-regexp
6448 0 (>= gnus-button-browse-level 0) browse-url 0)
6449 ("^[^:]+:" gnus-button-url-regexp
6450 0 (>= gnus-button-browse-level 0) browse-url 0)
6451 ("^OpenPGP:.*url=" gnus-button-url-regexp
6452 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6453 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6454 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6455 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6456 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6457 "*Alist of headers and regexps to match buttons in article heads.
6459 This alist is very similar to `gnus-button-alist', except that each
6460 alist has an additional HEADER element first in each entry:
6462 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6464 HEADER is a regexp to match a header. For a fuller explanation, see
6465 `gnus-button-alist'."
6466 :group 'gnus-article-buttons
6467 :group 'gnus-article-headers
6468 :type '(repeat (list (regexp :tag "Header")
6469 (choice regexp variable)
6470 (integer :tag "Button")
6472 (function :tag "Callback")
6475 (integer :tag "Regexp group")))))
6479 (defun gnus-article-push-button (event)
6480 "Check text under the mouse pointer for a callback function.
6481 If the text under the mouse pointer has a `gnus-callback' property,
6482 call it with the value of the `gnus-data' text property."
6484 (set-buffer (window-buffer (posn-window (event-start event))))
6485 (let* ((pos (posn-point (event-start event)))
6486 (data (get-text-property pos 'gnus-data))
6487 (fun (get-text-property pos 'gnus-callback)))
6490 (funcall fun data))))
6492 (defun gnus-article-press-button ()
6493 "Check text at point for a callback function.
6494 If the text at point has a `gnus-callback' property,
6495 call it with the value of the `gnus-data' text property."
6497 (let ((data (get-text-property (point) 'gnus-data))
6498 (fun (get-text-property (point) 'gnus-callback)))
6500 (funcall fun data))))
6502 (defun gnus-article-highlight (&optional force)
6503 "Highlight current article.
6504 This function calls `gnus-article-highlight-headers',
6505 `gnus-article-highlight-citation',
6506 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6507 do the highlighting. See the documentation for those functions."
6508 (interactive (list 'force))
6509 (gnus-article-highlight-headers)
6510 (gnus-article-highlight-citation force)
6511 (gnus-article-highlight-signature)
6512 (gnus-article-add-buttons force)
6513 (gnus-article-add-buttons-to-head))
6515 (defun gnus-article-highlight-some (&optional force)
6516 "Highlight current article.
6517 This function calls `gnus-article-highlight-headers',
6518 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6519 do the highlighting. See the documentation for those functions."
6520 (interactive (list 'force))
6521 (gnus-article-highlight-headers)
6522 (gnus-article-highlight-signature)
6523 (gnus-article-add-buttons))
6525 (defun gnus-article-highlight-headers ()
6526 "Highlight article headers as specified by `gnus-header-face-alist'."
6528 (gnus-with-article-headers
6529 (let (regexp header-face field-face from hpoints fpoints)
6530 (dolist (entry gnus-header-face-alist)
6531 (goto-char (point-min))
6532 (setq regexp (concat "^\\("
6533 (if (string-equal "" (nth 0 entry))
6537 header-face (nth 1 entry)
6538 field-face (nth 2 entry))
6539 (while (and (re-search-forward regexp nil t)
6543 (unless (search-forward ":" nil t)
6545 (when (and header-face
6546 (not (memq (point) hpoints)))
6547 (push (point) hpoints)
6548 (gnus-put-text-property from (point) 'face header-face))
6549 (when (and field-face
6550 (not (memq (setq from (point)) fpoints)))
6552 (if (re-search-forward "^[^ \t]" nil t)
6554 (goto-char (point-max)))
6555 (gnus-put-text-property from (point) 'face field-face)))))))
6557 (defun gnus-article-highlight-signature ()
6558 "Highlight the signature in an article.
6559 It does this by highlighting everything after
6560 `gnus-signature-separator' using the face `gnus-signature'."
6562 (gnus-with-article-buffer
6563 (let ((inhibit-point-motion-hooks t))
6565 (when (and gnus-signature-face
6566 (gnus-article-narrow-to-signature))
6567 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6568 'face gnus-signature-face)
6570 (gnus-article-search-signature)
6571 (let ((start (match-beginning 0))
6572 (end (set-marker (make-marker) (1+ (match-end 0)))))
6573 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6576 (defun gnus-button-in-region-p (b e prop)
6577 "Say whether PROP exists in the region."
6578 (text-property-not-all b e prop nil))
6580 (defun gnus-article-add-buttons (&optional force)
6581 "Find external references in the article and make buttons of them.
6582 \"External references\" are things like Message-IDs and URLs, as
6583 specified by `gnus-button-alist'."
6584 (interactive (list 'force))
6585 (gnus-with-article-buffer
6586 (let ((inhibit-point-motion-hooks t)
6587 (case-fold-search t)
6588 (alist gnus-button-alist)
6590 ;; Remove all old markers.
6591 (let (marker entry new-list)
6592 (while (setq marker (pop gnus-button-marker-list))
6593 (if (or (< marker (point-min)) (>= marker (point-max)))
6594 (push marker new-list)
6596 (when (setq entry (gnus-button-entry))
6597 (put-text-property (match-beginning (nth 1 entry))
6598 (match-end (nth 1 entry))
6599 'gnus-callback nil))
6600 (set-marker marker nil)))
6601 (setq gnus-button-marker-list new-list))
6602 ;; We skip the headers.
6605 (while (setq entry (pop alist))
6606 (setq regexp (eval (car entry)))
6608 (while (re-search-forward regexp nil t)
6609 (let* ((start (and entry (match-beginning (nth 1 entry))))
6610 (end (and entry (match-end (nth 1 entry))))
6611 (from (match-beginning 0)))
6612 (when (and (or (eq t (nth 2 entry))
6613 (eval (nth 2 entry)))
6614 (not (gnus-button-in-region-p
6615 start end 'gnus-callback)))
6616 ;; That optional form returned non-nil, so we add the
6618 (gnus-article-add-button
6619 start end 'gnus-button-push
6620 (car (push (set-marker (make-marker) from)
6621 gnus-button-marker-list))))))))))
6623 ;; Add buttons to the head of an article.
6624 (defun gnus-article-add-buttons-to-head ()
6625 "Add buttons to the head of the article."
6627 (gnus-with-article-headers
6629 (dolist (entry gnus-header-button-alist)
6630 ;; Each alist entry.
6631 (goto-char (point-min))
6632 (while (re-search-forward (car entry) nil t)
6633 ;; Each header matching the entry.
6634 (setq beg (match-beginning 0))
6635 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6636 (match-beginning 0))
6639 (while (re-search-forward (eval (nth 1 entry)) end t)
6640 ;; Each match within a header.
6641 (let* ((entry (cdr entry))
6642 (start (match-beginning (nth 1 entry)))
6643 (end (match-end (nth 1 entry)))
6644 (form (nth 2 entry)))
6645 (goto-char (match-end 0))
6647 (gnus-article-add-button
6648 start end (nth 3 entry)
6649 (buffer-substring (match-beginning (nth 4 entry))
6650 (match-end (nth 4 entry)))))))
6651 (goto-char end))))))
6653 ;;; External functions:
6655 (defun gnus-article-add-button (from to fun &optional data)
6656 "Create a button between FROM and TO with callback FUN and data DATA."
6657 (when gnus-article-button-face
6658 (gnus-overlay-put (gnus-make-overlay from to)
6659 'face gnus-article-button-face))
6660 (gnus-add-text-properties
6662 (nconc (and gnus-article-mouse-face
6663 (list gnus-mouse-face-prop gnus-article-mouse-face))
6664 (list 'gnus-callback fun)
6665 (and data (list 'gnus-data data))))
6666 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6667 :button-keymap gnus-widget-button-keymap))
6669 ;;; Internal functions:
6671 (defun gnus-article-set-globals ()
6672 (with-current-buffer gnus-summary-buffer
6673 (gnus-set-global-variables)))
6675 (defun gnus-signature-toggle (end)
6676 (gnus-with-article-buffer
6677 (let ((inhibit-point-motion-hooks t))
6678 (if (text-property-any end (point-max) 'article-type 'signature)
6680 (gnus-delete-wash-type 'signature)
6681 (gnus-remove-text-properties-when
6682 'article-type 'signature end (point-max)
6683 (cons 'article-type (cons 'signature
6684 gnus-hidden-properties))))
6685 (gnus-add-wash-type 'signature)
6686 (gnus-add-text-properties-when
6687 'article-type nil end (point-max)
6688 (cons 'article-type (cons 'signature
6689 gnus-hidden-properties)))))
6690 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6691 (gnus-set-mode-line 'article))))
6693 (defun gnus-button-entry ()
6694 ;; Return the first entry in `gnus-button-alist' matching this place.
6695 (let ((alist gnus-button-alist)
6698 (setq entry (pop alist))
6699 (if (looking-at (eval (car entry)))
6704 (defun gnus-button-push (marker)
6705 ;; Push button starting at MARKER.
6708 (let* ((entry (gnus-button-entry))
6709 (inhibit-point-motion-hooks t)
6711 (args (mapcar (lambda (group)
6712 (let ((string (match-string group)))
6713 (set-text-properties
6714 0 (length string) nil string)
6721 (fboundp (symbol-value fun)))
6722 (apply (symbol-value fun) args))
6724 (gnus-message 1 "You must define `%S' to use this button"
6725 (cons fun args)))))))
6727 (defun gnus-parse-news-url (url)
6728 (let (scheme server port group message-id articles)
6731 (goto-char (point-min))
6732 (when (looking-at "\\([A-Za-z]+\\):")
6733 (setq scheme (match-string 1))
6734 (goto-char (match-end 0)))
6735 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
6736 (setq server (match-string 1))
6737 (setq port (if (stringp (match-string 3))
6738 (string-to-number (match-string 3))
6740 (goto-char (match-end 0)))
6743 ((looking-at "\\(.*@.*\\)")
6744 (setq message-id (match-string 1)))
6745 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6746 (setq group (match-string 1)
6747 articles (split-string (match-string 2) "-")))
6748 ((looking-at "\\([^/]+\\)/?")
6749 (setq group (match-string 1)))
6751 (error "Unknown news URL syntax"))))
6752 (list scheme server port group message-id articles)))
6754 (defun gnus-button-handle-news (url)
6756 (destructuring-bind (scheme server port group message-id articles)
6757 (gnus-parse-news-url url)
6761 (set-buffer gnus-summary-buffer)
6763 (let ((gnus-refer-article-method
6764 (nconc (list (list 'nntp server))
6765 gnus-refer-article-method))
6766 (nntp-port-number (or port "nntp")))
6767 (gnus-message 7 "Fetching %s with %s"
6768 message-id gnus-refer-article-method)
6769 (gnus-summary-refer-article message-id))
6770 (gnus-summary-refer-article message-id))))
6772 (gnus-button-fetch-group url)))))
6774 (defun gnus-button-handle-man (url)
6776 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6777 (when (eq gnus-button-man-handler 'woman)
6778 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
6779 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6780 (funcall gnus-button-man-handler url))
6782 (defun gnus-button-handle-info-url (url)
6783 "Fetch an info URL."
6784 (setq url (mm-subst-char-in-string ?+ ?\ url))
6786 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6787 (gnus-info-find-node
6788 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6790 ")" (gnus-url-unhex-string (match-string 2 url)))))
6791 ((string-match "([^)\"]+)[^\"]+" url)
6793 (gnus-replace-in-string
6794 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6795 (gnus-info-find-node url))
6796 (t (error "Can't parse %s" url))))
6798 (defun gnus-button-handle-info-url-gnome (url)
6799 "Fetch GNOME style info URL."
6800 (setq url (mm-subst-char-in-string ?_ ?\ url))
6801 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6802 (gnus-info-find-node
6804 (gnus-url-unhex-string
6805 (match-string 1 url))
6807 (or (gnus-url-unhex-string
6808 (match-string 2 url))
6810 (error "Can't parse %s" url)))
6812 (defun gnus-button-handle-info-url-kde (url)
6813 "Fetch KDE style info URL."
6814 (gnus-info-find-node (gnus-url-unhex-string url)))
6816 (defun gnus-button-handle-info-keystrokes (url)
6817 "Call `info' when pushing the corresponding URL button."
6818 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6823 (defun gnus-button-openpgp (url)
6824 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
6826 (mm-url-insert-file-contents-external url)
6827 (pgg-snarf-keys-region (point-min) (point-max))
6828 (pgg-display-output-buffer nil nil nil)))
6830 (defun gnus-button-message-id (message-id)
6832 (with-current-buffer gnus-summary-buffer
6833 (gnus-summary-refer-article message-id)))
6835 (defun gnus-button-fetch-group (address)
6836 "Fetch GROUP specified by ADDRESS."
6837 (if (not (string-match "[:/]" address))
6838 ;; This is just a simple group url.
6839 (gnus-group-read-ephemeral-group address gnus-select-method)
6842 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6844 (error "Can't parse %s" address)
6845 (gnus-group-read-ephemeral-group
6846 (match-string 4 address)
6847 `(nntp ,(match-string 1 address)
6848 (nntp-address ,(match-string 1 address))
6849 (nntp-port-number ,(if (match-end 3)
6850 (match-string 3 address)
6853 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
6855 (defun gnus-url-parse-query-string (query &optional downcase)
6856 (let (retval pairs cur key val)
6857 (setq pairs (split-string query "&"))
6859 (setq cur (car pairs)
6861 (if (not (string-match "=" cur))
6863 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6864 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6866 (setq key (downcase key)))
6867 (setq cur (assoc key retval))
6869 (setcdr cur (cons val (cdr cur)))
6870 (setq retval (cons (list key val) retval)))))
6873 (defun gnus-url-mailto (url)
6874 ;; Send mail to someone
6875 (when (string-match "mailto:/*\\(.*\\)" url)
6876 (setq url (substring url (match-beginning 1) nil)))
6877 (let (to args subject func)
6878 (setq args (gnus-url-parse-query-string
6879 (if (string-match "^\\?" url)
6881 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6882 (concat "to=" (match-string 1 url) "&"
6883 (match-string 2 url))
6884 (concat "to=" url)))
6886 subject (cdr-safe (assoc "subject" args)))
6889 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6892 (message-position-on-field (caar args)))
6893 (insert (gnus-replace-in-string
6894 (mapconcat 'identity (reverse (cdar args)) ", ")
6896 (setq args (cdr args)))
6899 (message-goto-subject))))
6901 (defun gnus-button-embedded-url (address)
6902 "Activate ADDRESS with `browse-url'."
6903 (browse-url (gnus-strip-whitespace address)))
6905 ;;; Next/prev buttons in the article buffer.
6907 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6908 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6910 (defvar gnus-prev-page-map
6911 (let ((map (make-sparse-keymap)))
6912 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6913 (define-key map "\r" 'gnus-button-prev-page)
6916 (defvar gnus-next-page-map
6917 (let ((map (make-sparse-keymap)))
6918 (unless (>= emacs-major-version 21)
6919 ;; XEmacs doesn't care.
6920 (set-keymap-parent map gnus-article-mode-map))
6921 (define-key map gnus-mouse-2 'gnus-button-next-page)
6922 (define-key map "\r" 'gnus-button-next-page)
6925 (defun gnus-insert-prev-page-button ()
6927 (inhibit-read-only t))
6929 gnus-prev-page-line-format nil
6930 `(keymap ,gnus-prev-page-map
6932 gnus-callback gnus-article-button-prev-page
6933 article-type annotation))
6934 (widget-convert-button
6936 ;; Exclude a newline.
6939 :action 'gnus-button-prev-page
6940 :button-keymap gnus-prev-page-map)))
6942 (defun gnus-button-next-page (&optional args more-args)
6943 "Go to the next page."
6945 (let ((win (selected-window)))
6946 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6947 (gnus-article-next-page)
6948 (select-window win)))
6950 (defun gnus-button-prev-page (&optional args more-args)
6951 "Go to the prev page."
6953 (let ((win (selected-window)))
6954 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6955 (gnus-article-prev-page)
6956 (select-window win)))
6958 (defun gnus-insert-next-page-button ()
6960 (inhibit-read-only t))
6961 (gnus-eval-format gnus-next-page-line-format nil
6962 `(keymap ,gnus-next-page-map
6964 gnus-callback gnus-article-button-next-page
6965 article-type annotation))
6966 (widget-convert-button
6968 ;; Exclude a newline.
6971 :action 'gnus-button-next-page
6972 :button-keymap gnus-next-page-map)))
6974 (defun gnus-article-button-next-page (arg)
6975 "Go to the next page."
6977 (let ((win (selected-window)))
6978 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6979 (gnus-article-next-page)
6980 (select-window win)))
6982 (defun gnus-article-button-prev-page (arg)
6983 "Go to the prev page."
6985 (let ((win (selected-window)))
6986 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6987 (gnus-article-prev-page)
6988 (select-window win)))
6990 (defvar gnus-decode-header-methods
6991 '(mail-decode-encoded-word-region)
6992 "List of methods used to decode headers.
6994 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6995 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
6996 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6997 whose names match REGEXP.
7000 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7001 mail-decode-encoded-word-region
7002 (\"chinese\" . rfc1843-decode-region))
7005 (defvar gnus-decode-header-methods-cache nil)
7007 (defun gnus-multi-decode-header (start end)
7008 "Apply the functions from `gnus-encoded-word-methods' that match."
7009 (unless (and gnus-decode-header-methods-cache
7010 (eq gnus-newsgroup-name
7011 (car gnus-decode-header-methods-cache)))
7012 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7015 (nconc gnus-decode-header-methods-cache (list x))
7016 (if (and gnus-newsgroup-name
7017 (string-match (car x) gnus-newsgroup-name))
7018 (nconc gnus-decode-header-methods-cache
7020 gnus-decode-header-methods))
7021 (let ((xlist gnus-decode-header-methods-cache))
7024 (narrow-to-region start end)
7026 (funcall (pop xlist) (point-min) (point-max))))))
7029 ;;; Treatment top-level handling.
7032 (defun gnus-treat-article (condition &optional part-number total-parts type)
7033 (let ((length (- (point-max) (point-min)))
7034 (alist gnus-treatment-function-alist)
7035 (article-goto-body-goes-to-point-min-p t)
7039 (let ((list gnus-article-treat-types))
7041 (when (string-match (pop list) type)
7042 (throw 'found t)))))))
7043 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7045 (gnus-run-hooks 'gnus-part-display-hook)
7046 (dolist (elem alist)
7049 (when (gnus-buffer-live-p gnus-summary-buffer)
7050 (set-buffer gnus-summary-buffer))
7051 (symbol-value (car elem))))
7052 (when (and (or (consp val)
7054 (gnus-treat-predicate val)
7055 (or (not (get (car elem) 'highlight))
7058 (funcall (cadr elem)))))))
7060 ;; Dynamic variables.
7062 (defvar part-number)
7063 (defvar total-parts)
7068 (defun gnus-treat-predicate (val)
7075 (stringp (car val)))
7076 (apply 'gnus-or (mapcar `(lambda (s)
7077 (string-match s ,(or gnus-newsgroup-name "")))
7080 (let ((pred (pop val)))
7083 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7085 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7087 (not (gnus-treat-predicate (car val))))
7089 (equal (car val) type))
7091 (error "%S is not a valid predicate" pred)))))
7097 (eq part-number total-parts))
7101 (error "%S is not a valid value" val))))
7103 (defun gnus-article-encrypt-body (protocol &optional n)
7104 "Encrypt the article body."
7107 (or gnus-article-encrypt-protocol
7108 (completing-read "Encrypt protocol: "
7109 gnus-article-encrypt-protocol-alist
7111 current-prefix-arg))
7112 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7114 (error "Can't find the encrypt protocol %s" protocol))
7115 (if (member gnus-newsgroup-name '("nndraft:delayed"
7118 (error "Can't encrypt the article in group %s"
7119 gnus-newsgroup-name))
7120 (gnus-summary-iterate n
7122 (set-buffer gnus-summary-buffer)
7123 (let ((mail-parse-charset gnus-newsgroup-charset)
7124 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7125 (summary-buffer gnus-summary-buffer)
7127 (gnus-set-global-variables)
7128 (when (gnus-group-read-only-p)
7129 (error "The current newsgroup does not support article encrypt"))
7130 (gnus-summary-show-article t)
7132 (or (mail-header-references gnus-current-headers) ""))
7133 (set-buffer gnus-article-buffer)
7134 (let* ((inhibit-read-only t)
7136 (mapcar (lambda (field)
7137 (and (save-restriction
7138 (message-narrow-to-head)
7139 (goto-char (point-min))
7140 (search-forward field nil t))
7142 (message-narrow-to-field)
7144 (delete-region (point-min) (point-max))
7146 '("Content-Type:" "Content-Transfer-Encoding:"
7147 "Content-Disposition:"))))
7148 (message-narrow-to-head)
7149 (message-remove-header "MIME-Version")
7150 (goto-char (point-max))
7151 (setq point (point))
7152 (insert (apply 'concat headers))
7154 (narrow-to-region point (point-max))
7155 (let ((message-options message-options))
7156 (message-options-set 'message-sender user-mail-address)
7157 (message-options-set 'message-recipients user-mail-address)
7158 (message-options-set 'message-sign-encrypt 'not)
7160 (goto-char (point-min))
7161 (insert "MIME-Version: 1.0\n")
7163 (gnus-summary-edit-article-done
7164 references nil summary-buffer t))
7165 (when gnus-keep-backlog
7166 (gnus-backlog-remove-article
7167 (car gnus-article-current) (cdr gnus-article-current)))
7169 (when (get-buffer gnus-original-article-buffer)
7170 (set-buffer gnus-original-article-buffer)
7171 (setq gnus-original-article nil)))
7172 (when gnus-use-cache
7173 (gnus-cache-update-article
7174 (car gnus-article-current) (cdr gnus-article-current))))))))
7176 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7177 "The following specs can be used:
7178 %t The security MIME type
7181 %D Details if button is pressed")
7183 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7184 "The following specs can be used:
7185 %t The security MIME type
7188 %D Details if button is pressed")
7190 (defvar gnus-mime-security-button-line-format-alist
7191 '((?t gnus-tmp-type ?s)
7192 (?i gnus-tmp-info ?s)
7193 (?d gnus-tmp-details ?s)
7194 (?D gnus-tmp-pressed-details ?s)))
7196 (defvar gnus-mime-security-button-map
7197 (let ((map (make-sparse-keymap)))
7198 (define-key map gnus-mouse-2 'gnus-article-push-button)
7199 (define-key map "\r" 'gnus-article-press-button)
7202 (defvar gnus-mime-security-details-buffer nil)
7204 (defvar gnus-mime-security-button-pressed nil)
7206 (defvar gnus-mime-security-show-details-inline t
7207 "If non-nil, show details in the article buffer.")
7209 (defun gnus-mime-security-verify-or-decrypt (handle)
7210 (mm-remove-parts (cdr handle))
7211 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7212 point (inhibit-read-only t))
7214 (goto-char (car region)))
7216 (narrow-to-region (point) (point))
7217 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7218 (let* ((mm-verify-option 'known)
7219 (mm-decrypt-option 'known)
7220 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7221 (unless (eq nparts (cdr handle))
7222 (mm-destroy-parts (cdr handle))
7223 (setcdr handle nparts))))
7224 (setq point (point))
7225 (gnus-mime-display-security handle)
7226 (goto-char (point-max)))
7228 (delete-region (point) (cdr region))
7229 (set-marker (car region) nil)
7230 (set-marker (cdr region) nil))
7233 (defun gnus-mime-security-show-details (handle)
7234 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7236 (gnus-message 5 "No details.")
7237 (if gnus-mime-security-show-details-inline
7238 (let ((gnus-mime-security-button-pressed
7239 (not (get-text-property (point) 'gnus-mime-details)))
7240 (gnus-mime-security-button-line-format
7241 (get-text-property (point) 'gnus-line-format))
7242 (inhibit-read-only t))
7244 (while (eq (get-text-property (point) 'gnus-line-format)
7245 gnus-mime-security-button-line-format)
7249 (narrow-to-region (point) (point))
7250 (gnus-insert-mime-security-button handle))
7251 (delete-region (point)
7252 (or (text-property-not-all
7255 gnus-mime-security-button-line-format)
7258 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7259 (with-current-buffer gnus-mime-security-details-buffer
7262 (setq gnus-mime-security-details-buffer
7263 (gnus-get-buffer-create "*MIME Security Details*")))
7264 (with-current-buffer gnus-mime-security-details-buffer
7266 (goto-char (point-min)))
7267 (pop-to-buffer gnus-mime-security-details-buffer)))))
7269 (defun gnus-mime-security-press-button (handle)
7271 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7272 (gnus-mime-security-show-details handle)
7273 (gnus-mime-security-verify-or-decrypt handle))))
7275 (defun gnus-insert-mime-security-button (handle &optional displayed)
7276 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7279 (or (nth 2 (assoc protocol mm-verify-function-alist))
7280 (nth 2 (assoc protocol mm-decrypt-function-alist))
7282 (if (equal (car handle) "multipart/signed")
7283 " Signed" " Encrypted")
7286 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7289 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7290 gnus-tmp-pressed-details
7292 (setq gnus-tmp-details
7293 (if gnus-tmp-details
7294 (concat "\n" gnus-tmp-details)
7296 (setq gnus-tmp-pressed-details
7297 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7302 gnus-mime-security-button-line-format
7303 gnus-mime-security-button-line-format-alist
7304 `(keymap ,gnus-mime-security-button-map
7305 gnus-callback gnus-mime-security-press-button
7306 gnus-line-format ,gnus-mime-security-button-line-format
7307 gnus-mime-details ,gnus-mime-security-button-pressed
7308 article-type annotation
7311 ;; Exclude a newline.
7314 (widget-convert-button
7317 :action 'gnus-widget-press-button
7318 :button-keymap gnus-mime-security-button-map
7320 (lambda (widget/window &optional overlay pos)
7321 ;; Needed to properly clear the message due to a bug in
7322 ;; wid-edit (XEmacs only).
7323 (when (boundp 'help-echo-owns-message)
7324 (setq help-echo-owns-message t))
7327 (aref gnus-mouse-2 0))))))
7329 (defun gnus-mime-display-security (handle)
7331 (narrow-to-region (point) (point))
7332 (unless (gnus-unbuttonized-mime-type-p (car handle))
7333 (gnus-insert-mime-security-button handle))
7334 (gnus-mime-display-mixed (cdr handle))
7337 (unless (gnus-unbuttonized-mime-type-p (car handle))
7338 (let ((gnus-mime-security-button-line-format
7339 gnus-mime-security-button-end-line-format))
7340 (gnus-insert-mime-security-button handle)))
7341 (mm-set-handle-multipart-parameter
7343 (cons (set-marker (make-marker) (point-min))
7344 (set-marker (make-marker) (point-max))))))
7350 (run-hooks 'gnus-art-load-hook)
7352 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7353 ;;; gnus-art.el ends here