1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
46 (autoload 'gnus-msg-mail "gnus-msg" nil t)
47 (autoload 'gnus-button-mailto "gnus-msg")
48 (autoload 'gnus-button-reply "gnus-msg" nil t)
50 (defgroup gnus-article nil
52 :link '(custom-manual "(gnus)The Article Buffer")
55 (defgroup gnus-article-treat nil
56 "Treating article parts."
57 :link '(custom-manual "(gnus)Article Hiding")
60 (defgroup gnus-article-hiding nil
61 "Hiding article parts."
62 :link '(custom-manual "(gnus)Article Hiding")
65 (defgroup gnus-article-highlight nil
66 "Article highlighting."
67 :link '(custom-manual "(gnus)Article Highlighting")
71 (defgroup gnus-article-signature nil
73 :link '(custom-manual "(gnus)Article Signature")
76 (defgroup gnus-article-headers nil
78 :link '(custom-manual "(gnus)Hiding Headers")
81 (defgroup gnus-article-washing nil
82 "Special commands on articles."
83 :link '(custom-manual "(gnus)Article Washing")
86 (defgroup gnus-article-emphasis nil
87 "Fontisizing articles."
88 :link '(custom-manual "(gnus)Article Fontisizing")
91 (defgroup gnus-article-saving nil
93 :link '(custom-manual "(gnus)Saving Articles")
96 (defgroup gnus-article-mime nil
97 "Worshiping the MIME wonder."
98 :link '(custom-manual "(gnus)Using MIME")
101 (defgroup gnus-article-buttons nil
102 "Pushable buttons in the article buffer."
103 :link '(custom-manual "(gnus)Article Buttons")
104 :group 'gnus-article)
106 (defgroup gnus-article-various nil
107 "Other article options."
108 :link '(custom-manual "(gnus)Misc Article")
109 :group 'gnus-article)
111 (defcustom gnus-ignored-headers
114 (concat "^" header ":"))
115 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
116 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
117 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
118 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
119 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
120 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
121 "X-Attribution" "X-Originating-IP" "Delivered-To"
122 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
123 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
124 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
125 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
126 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
127 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
128 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
129 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
130 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
131 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
132 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
133 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
134 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
135 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
136 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
137 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
138 "List-[A-Za-z]+" "X-Listprocessor-Version"
139 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
140 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
141 "X-Received" "Content-length" "X-precedence"
142 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
143 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
144 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
145 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
146 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
147 "X-Content-length" "X-Posting-Agent" "Original-Received"
148 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
149 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
150 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
151 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
152 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
153 "*All headers that start with this regexp will be hidden.
154 This variable can also be a list of regexps of headers to be ignored.
155 If `gnus-visible-headers' is non-nil, this variable will be ignored."
156 :type '(choice :custom-show nil
159 :group 'gnus-article-hiding)
161 (defcustom gnus-visible-headers
162 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
163 "*All headers that do not match this regexp will be hidden.
164 This variable can also be a list of regexp of headers to remain visible.
165 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
166 :type '(repeat :value-to-internal (lambda (widget value)
167 (custom-split-regexp-maybe value))
168 :match (lambda (widget value)
170 (widget-editable-list-match widget value)))
172 :group 'gnus-article-hiding)
174 (defcustom gnus-sorted-header-list
175 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
176 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
177 "*This variable is a list of regular expressions.
178 If it is non-nil, headers that match the regular expressions will
179 be placed first in the article buffer in the sequence specified by
181 :type '(repeat regexp)
182 :group 'gnus-article-hiding)
184 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
185 "Headers that are only to be displayed if they have interesting data.
186 Possible values in this list are:
188 'empty Headers with no content.
189 'newsgroups Newsgroup identical to Gnus group.
190 'to-address To identical to To-address.
191 'to-list To identical to To-list.
192 'cc-list CC identical to To-list.
193 'followup-to Followup-to identical to Newsgroups.
194 'reply-to Reply-to identical to From.
195 'date Date less than four days old.
196 'long-to To and/or Cc longer than 1024 characters.
197 'many-to Multiple To and/or Cc."
198 :type '(set (const :tag "Headers with no content." empty)
199 (const :tag "Newsgroups identical to Gnus group." newsgroups)
200 (const :tag "To identical to To-address." to-address)
201 (const :tag "To identical to To-list." to-list)
202 (const :tag "CC identical to To-list." cc-list)
203 (const :tag "Followup-to identical to Newsgroups." followup-to)
204 (const :tag "Reply-to identical to From." reply-to)
205 (const :tag "Date less than four days old." date)
206 (const :tag "To and/or Cc longer than 1024 characters." long-to)
207 (const :tag "Multiple To and/or Cc headers." many-to))
208 :group 'gnus-article-hiding)
210 (defcustom gnus-article-skip-boring nil
211 "Skip over text that is not worth reading.
212 By default, if you set this t, then Gnus will display citations and
213 signatures, but will never scroll down to show you a page consisting
214 only of boring text. Boring text is controlled by
215 `gnus-article-boring-faces'."
217 :group 'gnus-article-hiding)
219 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
220 "Regexp matching signature separator.
221 This can also be a list of regexps. In that case, it will be checked
222 from head to tail looking for a separator. Searches will be done from
223 the end of the buffer."
224 :type '(repeat string)
225 :group 'gnus-article-signature)
227 (defcustom gnus-signature-limit nil
228 "Provide a limit to what is considered a signature.
229 If it is a number, no signature may not be longer (in characters) than
230 that number. If it is a floating point number, no signature may be
231 longer (in lines) than that number. If it is a function, the function
232 will be called without any parameters, and if it returns nil, there is
233 no signature in the buffer. If it is a string, it will be used as a
234 regexp. If it matches, the text in question is not a signature."
235 :type '(choice (integer :value 200)
237 (function :value fun)
238 (regexp :value ".*"))
239 :group 'gnus-article-signature)
241 (defcustom gnus-hidden-properties '(invisible t intangible t)
242 "Property list to use for hiding text."
244 :group 'gnus-article-hiding)
246 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
247 ;; frames in a session.
248 (defcustom gnus-article-x-face-command
249 (if (featurep 'xemacs)
250 (if (or (gnus-image-type-available-p 'xface)
251 (gnus-image-type-available-p 'pbm))
252 'gnus-display-x-face-in-from
253 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
254 (if (gnus-image-type-available-p 'pbm)
255 'gnus-display-x-face-in-from
256 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
258 "*String or function to be executed to display an X-Face header.
259 If it is a string, the command will be executed in a sub-shell
260 asynchronously. The compressed face will be piped to this command."
261 :type `(choice string
262 (function-item gnus-display-x-face-in-from)
266 :group 'gnus-article-washing)
268 (defcustom gnus-article-x-face-too-ugly nil
269 "Regexp matching posters whose face shouldn't be shown automatically."
270 :type '(choice regexp (const nil))
271 :group 'gnus-article-washing)
273 (defcustom gnus-article-banner-alist nil
274 "Banner alist for stripping.
276 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
278 :type '(repeat (cons symbol regexp))
279 :group 'gnus-article-washing)
281 (gnus-define-group-parameter
284 "Alist of regexps (to match group names) and banner."
285 :variable-group gnus-article-washing
287 '(choice :tag "Banner"
289 (const :tag "Remove signature" signature)
290 (symbol :tag "Item in `gnus-article-banner-alist'" none)
292 (const :tag "None" nil))
294 "If non-nil, specify how to remove `banners' from articles.
296 Symbol `signature' means to remove signatures delimited by
297 `gnus-signature-separator'. Any other symbol is used to look up a
298 regular expression to match the banner in `gnus-article-banner-alist'.
299 A string is used as a regular expression to match the banner
302 (defcustom gnus-article-address-banner-alist nil
303 "Alist of mail addresses and banners.
304 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
305 to match a mail address in the From: header, BANNER is one of a symbol
306 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
307 If ADDRESS matches author's mail address, it will remove things like
308 advertisements. For example:
310 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
314 (regexp :tag "Address")
315 (choice :tag "Banner" :value nil
316 (const :tag "Remove signature" signature)
317 (symbol :tag "Item in `gnus-article-banner-alist'" none)
319 (const :tag "None" nil))))
320 :group 'gnus-article-washing)
322 (defcustom gnus-emphasis-alist
324 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
329 ("_/" "/_" underline-italic)
330 ("_\\*" "\\*_" underline-bold)
331 ("\\*/" "/\\*" bold-italic)
332 ("_\\*/" "/\\*_" underline-bold-italic))))
336 (format format (car spec) (cadr spec))
337 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
339 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
340 2 3 gnus-emphasis-strikethru)
341 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
342 2 3 gnus-emphasis-underline)))
343 "*Alist that says how to fontify certain phrases.
344 Each item looks like this:
346 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
348 The first element is a regular expression to be matched. The second
349 is a number that says what regular expression grouping used to find
350 the entire emphasized word. The third is a number that says what
351 regexp grouping should be displayed and highlighted. The fourth
352 is the face used for highlighting."
353 :type '(repeat (list :value ("" 0 0 default)
355 (integer :tag "Match group")
356 (integer :tag "Emphasize group")
358 :group 'gnus-article-emphasis)
360 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
361 "A regexp to describe whitespace which should not be emphasized.
362 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
363 The former avoids underlining of leading and trailing whitespace,
364 and the latter avoids underlining any whitespace at all."
366 :group 'gnus-article-emphasis
369 (defface gnus-emphasis-bold '((t (:bold t)))
370 "Face used for displaying strong emphasized text (*word*)."
371 :group 'gnus-article-emphasis)
373 (defface gnus-emphasis-italic '((t (:italic t)))
374 "Face used for displaying italic emphasized text (/word/)."
375 :group 'gnus-article-emphasis)
377 (defface gnus-emphasis-underline '((t (:underline t)))
378 "Face used for displaying underlined emphasized text (_word_)."
379 :group 'gnus-article-emphasis)
381 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
382 "Face used for displaying underlined bold emphasized text (_*word*_)."
383 :group 'gnus-article-emphasis)
385 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
386 "Face used for displaying underlined italic emphasized text (_/word/_)."
387 :group 'gnus-article-emphasis)
389 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
390 "Face used for displaying bold italic emphasized text (/*word*/)."
391 :group 'gnus-article-emphasis)
393 (defface gnus-emphasis-underline-bold-italic
394 '((t (:bold t :italic t :underline t)))
395 "Face used for displaying underlined bold italic emphasized text.
396 Example: (_/*word*/_)."
397 :group 'gnus-article-emphasis)
399 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
400 "Face used for displaying strike-through text (-word-)."
401 :group 'gnus-article-emphasis)
403 (defface gnus-emphasis-highlight-words
404 '((t (:background "black" :foreground "yellow")))
405 "Face used for displaying highlighted words."
406 :group 'gnus-article-emphasis)
408 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
409 "Format for display of Date headers in article bodies.
410 See `format-time-string' for the possible values.
412 The variable can also be function, which should return a complete Date
413 header. The function is called with one argument, the time, which can
414 be fed to `format-time-string'."
415 :type '(choice string symbol)
416 :link '(custom-manual "(gnus)Article Date")
417 :group 'gnus-article-washing)
420 (autoload 'mail-extract-address-components "mail-extr"))
422 (defcustom gnus-save-all-headers t
423 "*If non-nil, don't remove any headers before saving."
424 :group 'gnus-article-saving
427 (defcustom gnus-prompt-before-saving 'always
428 "*This variable says how much prompting is to be done when saving articles.
429 If it is nil, no prompting will be done, and the articles will be
430 saved to the default files. If this variable is `always', each and
431 every article that is saved will be preceded by a prompt, even when
432 saving large batches of articles. If this variable is neither nil not
433 `always', there the user will be prompted once for a file name for
434 each invocation of the saving commands."
435 :group 'gnus-article-saving
436 :type '(choice (item always)
437 (item :tag "never" nil)
438 (sexp :tag "once" :format "%t\n" :value t)))
440 (defcustom gnus-saved-headers gnus-visible-headers
441 "Headers to keep if `gnus-save-all-headers' is nil.
442 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
443 If that variable is nil, however, all headers that match this regexp
444 will be kept while the rest will be deleted before saving."
445 :group 'gnus-article-saving
448 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
449 "A function to save articles in your favourite format.
450 The function must be interactively callable (in other words, it must
451 be an Emacs command).
453 Gnus provides the following functions:
455 * gnus-summary-save-in-rmail (Rmail format)
456 * gnus-summary-save-in-mail (Unix mail format)
457 * gnus-summary-save-in-folder (MH folder)
458 * gnus-summary-save-in-file (article format)
459 * gnus-summary-save-body-in-file (article body)
460 * gnus-summary-save-in-vm (use VM's folder format)
461 * gnus-summary-write-to-file (article format -- overwrite)."
462 :group 'gnus-article-saving
463 :type '(radio (function-item gnus-summary-save-in-rmail)
464 (function-item gnus-summary-save-in-mail)
465 (function-item gnus-summary-save-in-folder)
466 (function-item gnus-summary-save-in-file)
467 (function-item gnus-summary-save-body-in-file)
468 (function-item gnus-summary-save-in-vm)
469 (function-item gnus-summary-write-to-file)))
471 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
472 "A function generating a file name to save articles in Rmail format.
473 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
474 :group 'gnus-article-saving
477 (defcustom gnus-mail-save-name 'gnus-plain-save-name
478 "A function generating a file name to save articles in Unix mail format.
479 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
480 :group 'gnus-article-saving
483 (defcustom gnus-folder-save-name 'gnus-folder-save-name
484 "A function generating a file name to save articles in MH folder.
485 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
486 :group 'gnus-article-saving
489 (defcustom gnus-file-save-name 'gnus-numeric-save-name
490 "A function generating a file name to save articles in article format.
491 The function is called with NEWSGROUP, HEADERS, and optional
493 :group 'gnus-article-saving
496 (defcustom gnus-split-methods
497 '((gnus-article-archive-name)
498 (gnus-article-nndoc-name))
499 "*Variable used to suggest where articles are to be saved.
500 For instance, if you would like to save articles related to Gnus in
501 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
502 you could set this variable to something like:
504 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
505 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
507 This variable is an alist where the where the key is the match and the
508 value is a list of possible files to save in if the match is non-nil.
510 If the match is a string, it is used as a regexp match on the
511 article. If the match is a symbol, that symbol will be funcalled
512 from the buffer of the article to be saved with the newsgroup as the
513 parameter. If it is a list, it will be evaled in the same buffer.
515 If this form or function returns a string, this string will be used as
516 a possible file name; and if it returns a non-nil list, that list will
517 be used as possible file names."
518 :group 'gnus-article-saving
519 :type '(repeat (choice (list :value (fun) function)
520 (cons :value ("" "") regexp (repeat string))
523 (defcustom gnus-page-delimiter "^\^L"
524 "*Regexp describing what to use as article page delimiters.
525 The default value is \"^\^L\", which is a form linefeed at the
526 beginning of a line."
528 :group 'gnus-article-various)
530 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
531 "*The format specification for the article mode line.
532 See `gnus-summary-mode-line-format' for a closer description.
534 The following additional specs are available:
536 %w The article washing status.
537 %m The number of MIME parts in the article."
539 :group 'gnus-article-various)
541 (defcustom gnus-article-mode-hook nil
542 "*A hook for Gnus article mode."
544 :group 'gnus-article-various)
546 (when (featurep 'xemacs)
547 ;; Extracted from gnus-xmas-define in order to preserve user settings
548 (when (fboundp 'turn-off-scroll-in-place)
549 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
550 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
551 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
553 (defcustom gnus-article-menu-hook nil
554 "*Hook run after the creation of the article mode menu."
556 :group 'gnus-article-various)
558 (defcustom gnus-article-prepare-hook nil
559 "*A hook called after an article has been prepared in the article buffer."
561 :group 'gnus-article-various)
563 (make-obsolete-variable 'gnus-article-hide-pgp-hook
564 "This variable is obsolete in Gnus 5.10.")
566 (defcustom gnus-article-button-face 'bold
567 "Face used for highlighting buttons in the article buffer.
569 An article button is a piece of text that you can activate by pressing
570 `RET' or `mouse-2' above it."
572 :group 'gnus-article-buttons)
574 (defcustom gnus-article-mouse-face 'highlight
575 "Face used for mouse highlighting in the article buffer.
577 Article buttons will be displayed in this face when the cursor is
580 :group 'gnus-article-buttons)
582 (defcustom gnus-signature-face 'gnus-signature-face
583 "Face used for highlighting a signature in the article buffer.
584 Obsolete; use the face `gnus-signature-face' for customizations instead."
586 :group 'gnus-article-highlight
587 :group 'gnus-article-signature)
589 (defface gnus-signature-face
592 "Face used for highlighting a signature in the article buffer."
593 :group 'gnus-article-highlight
594 :group 'gnus-article-signature)
596 (defface gnus-header-from-face
599 (:foreground "spring green"))
602 (:foreground "red3"))
605 "Face used for displaying from headers."
606 :group 'gnus-article-headers
607 :group 'gnus-article-highlight)
609 (defface gnus-header-subject-face
612 (:foreground "SeaGreen3"))
615 (:foreground "red4"))
617 (:bold t :italic t)))
618 "Face used for displaying subject headers."
619 :group 'gnus-article-headers
620 :group 'gnus-article-highlight)
622 (defface gnus-header-newsgroups-face
625 (:foreground "yellow" :italic t))
628 (:foreground "MidnightBlue" :italic t))
631 "Face used for displaying newsgroups headers.
632 In the default setup this face is only used for crossposted
634 :group 'gnus-article-headers
635 :group 'gnus-article-highlight)
637 (defface gnus-header-name-face
640 (:foreground "SeaGreen"))
643 (:foreground "maroon"))
646 "Face used for displaying header names."
647 :group 'gnus-article-headers
648 :group 'gnus-article-highlight)
650 (defface gnus-header-content-face
653 (:foreground "forest green" :italic t))
656 (:foreground "indianred4" :italic t))
658 (:italic t))) "Face used for displaying header content."
659 :group 'gnus-article-headers
660 :group 'gnus-article-highlight)
662 (defcustom gnus-header-face-alist
663 '(("From" nil gnus-header-from-face)
664 ("Subject" nil gnus-header-subject-face)
665 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
666 ("" gnus-header-name-face gnus-header-content-face))
667 "*Controls highlighting of article headers.
669 An alist of the form (HEADER NAME CONTENT).
671 HEADER is a regular expression which should match the name of a
672 header and NAME and CONTENT are either face names or nil.
674 The name of each header field will be displayed using the face
675 specified by the first element in the list where HEADER matches
676 the header name and NAME is non-nil. Similarly, the content will
677 be displayed by the first non-nil matching CONTENT face."
678 :group 'gnus-article-headers
679 :group 'gnus-article-highlight
680 :type '(repeat (list (regexp :tag "Header")
682 (item :tag "skip" nil)
683 (face :value default))
684 (choice :tag "Content"
685 (item :tag "skip" nil)
686 (face :value default)))))
688 (defcustom gnus-article-decode-hook
689 '(article-decode-charset article-decode-encoded-words
690 article-decode-group-name article-decode-idna-rhs)
691 "*Hook run to decode charsets in articles."
692 :group 'gnus-article-headers
695 (defcustom gnus-display-mime-function 'gnus-display-mime
696 "Function to display MIME articles."
697 :group 'gnus-article-mime
700 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
701 "Function used to decode headers.")
703 (defvar gnus-article-dumbquotes-map
723 "Table for MS-to-Latin1 translation.")
725 (defcustom gnus-ignored-mime-types nil
726 "List of MIME types that should be ignored by Gnus."
728 :group 'gnus-article-mime
729 :type '(repeat regexp))
731 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
732 "List of MIME types that should not be given buttons when rendered inline.
733 See also `gnus-buttonized-mime-types' which may override this variable.
734 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
736 :group 'gnus-article-mime
737 :type '(repeat regexp))
739 (defcustom gnus-buttonized-mime-types nil
740 "List of MIME types that should be given buttons when rendered inline.
741 If set, this variable overrides `gnus-unbuttonized-mime-types'.
742 To see e.g. security buttons you could set this to
743 `(\"multipart/signed\")'.
744 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
746 :group 'gnus-article-mime
747 :type '(repeat regexp))
749 (defcustom gnus-inhibit-mime-unbuttonizing nil
750 "If non-nil, all MIME parts get buttons.
751 When nil (the default value), then some MIME parts do not get buttons,
752 as described by the variables `gnus-buttonized-mime-types' and
753 `gnus-unbuttonized-mime-types'."
757 (defcustom gnus-body-boundary-delimiter "_"
758 "String used to delimit header and body.
759 This variable is used by `gnus-article-treat-body-boundary' which can
760 be controlled by `gnus-treat-body-boundary'."
761 :group 'gnus-article-various
762 :type '(choice (item :tag "None" :value nil)
765 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
766 "Defines the location of the faces database.
767 For information on obtaining this database of pretty pictures, please
768 see http://www.cs.indiana.edu/picons/ftp/index.html"
769 :type '(repeat directory)
770 :link '(url-link :tag "download"
771 "http://www.cs.indiana.edu/picons/ftp/index.html")
772 :link '(custom-manual "(gnus)Picons")
775 (defun gnus-picons-installed-p ()
776 "Say whether picons are installed on your machine."
777 (let ((installed nil))
778 (dolist (database gnus-picon-databases)
779 (when (file-exists-p database)
783 (defcustom gnus-article-mime-part-function nil
784 "Function called with a MIME handle as the argument.
785 This is meant for people who want to do something automatic based
786 on parts -- for instance, adding Vcard info to a database."
787 :group 'gnus-article-mime
790 (defcustom gnus-mime-multipart-functions nil
791 "An alist of MIME types to functions to display them."
793 :group 'gnus-article-mime
796 (defcustom gnus-article-date-lapsed-new-header nil
797 "Whether the X-Sent and Date headers can coexist.
798 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
799 either replace the old \"Date:\" header (if this variable is nil), or
800 be added below it (otherwise)."
802 :group 'gnus-article-headers
805 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
806 "Function called with a MIME handle as the argument.
807 This is meant for people who want to view first matched part.
808 For `undisplayed-alternative' (default), the first undisplayed
809 part or alternative part is used. For `undisplayed', the first
810 undisplayed part is used. For a function, the first part which
811 the function return t is used. For nil, the first part is
814 :group 'gnus-article-mime
816 (item :tag "first" :value nil)
817 (item :tag "undisplayed" :value undisplayed)
818 (item :tag "undisplayed or alternative"
819 :value undisplayed-alternative)
822 (defcustom gnus-mime-action-alist
823 '(("save to file" . gnus-mime-save-part)
824 ("save and strip" . gnus-mime-save-part-and-strip)
825 ("delete part" . gnus-mime-delete-part)
826 ("display as text" . gnus-mime-inline-part)
827 ("view the part" . gnus-mime-view-part)
828 ("pipe to command" . gnus-mime-pipe-part)
829 ("toggle display" . gnus-article-press-button)
830 ("toggle display" . gnus-article-view-part-as-charset)
831 ("view as type" . gnus-mime-view-part-as-type)
832 ("view internally" . gnus-mime-view-part-internally)
833 ("view externally" . gnus-mime-view-part-externally))
834 "An alist of actions that run on the MIME attachment."
835 :group 'gnus-article-mime
836 :type '(repeat (cons (string :tag "name")
840 ;;; The treatment variables
843 (defvar gnus-part-display-hook nil
844 "Hook called on parts that are to receive treatment.")
846 (defvar gnus-article-treat-custom
847 '(choice (const :tag "Off" nil)
849 (const :tag "Header" head)
850 (const :tag "Last" last)
851 (integer :tag "Less")
852 (repeat :tag "Groups" regexp)
853 (sexp :tag "Predicate")))
855 (defvar gnus-article-treat-head-custom
856 '(choice (const :tag "Off" nil)
857 (const :tag "Header" head)))
859 (defvar gnus-article-treat-types '("text/plain")
862 (defvar gnus-inhibit-treatment nil
863 "Whether to inhibit treatment.")
865 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
866 "Highlight the signature.
867 Valid values are nil, t, `head', `last', an integer or a predicate.
868 See Info node `(gnus)Customizing Articles'."
869 :group 'gnus-article-treat
870 :link '(custom-manual "(gnus)Customizing Articles")
871 :type gnus-article-treat-custom)
872 (put 'gnus-treat-highlight-signature 'highlight t)
874 (defcustom gnus-treat-buttonize 100000
876 Valid values are nil, t, `head', `last', an integer or a predicate.
877 See Info node `(gnus)Customizing Articles'."
878 :group 'gnus-article-treat
879 :link '(custom-manual "(gnus)Customizing Articles")
880 :type gnus-article-treat-custom)
881 (put 'gnus-treat-buttonize 'highlight t)
883 (defcustom gnus-treat-buttonize-head 'head
884 "Add buttons to the head.
885 Valid values are nil, t, `head', `last', an integer or a predicate.
886 See Info node `(gnus)Customizing Articles' for details."
887 :group 'gnus-article-treat
888 :link '(custom-manual "(gnus)Customizing Articles")
889 :type gnus-article-treat-head-custom)
890 (put 'gnus-treat-buttonize-head 'highlight t)
892 (defcustom gnus-treat-emphasize
893 (and (or window-system
895 (>= (string-to-number emacs-version) 21))
898 Valid values are nil, t, `head', `last', an integer or a predicate.
899 See Info node `(gnus)Customizing Articles' for details."
900 :group 'gnus-article-treat
901 :link '(custom-manual "(gnus)Customizing Articles")
902 :type gnus-article-treat-custom)
903 (put 'gnus-treat-emphasize 'highlight t)
905 (defcustom gnus-treat-strip-cr nil
906 "Remove carriage returns.
907 Valid values are nil, t, `head', `last', an integer or a predicate.
908 See Info node `(gnus)Customizing Articles' for details."
909 :group 'gnus-article-treat
910 :link '(custom-manual "(gnus)Customizing Articles")
911 :type gnus-article-treat-custom)
913 (defcustom gnus-treat-unsplit-urls nil
914 "Remove newlines from within URLs.
915 Valid values are nil, t, `head', `last', an integer or a predicate.
916 See Info node `(gnus)Customizing Articles' for details."
917 :group 'gnus-article-treat
918 :link '(custom-manual "(gnus)Customizing Articles")
919 :type gnus-article-treat-custom)
921 (defcustom gnus-treat-leading-whitespace nil
922 "Remove leading whitespace in headers.
923 Valid values are nil, t, `head', `last', an integer or a predicate.
924 See Info node `(gnus)Customizing Articles' for details."
925 :group 'gnus-article-treat
926 :link '(custom-manual "(gnus)Customizing Articles")
927 :type gnus-article-treat-custom)
929 (defcustom gnus-treat-hide-headers 'head
931 Valid values are nil, t, `head', `last', an integer or a predicate.
932 See Info node `(gnus)Customizing Articles' for details."
933 :group 'gnus-article-treat
934 :link '(custom-manual "(gnus)Customizing Articles")
935 :type gnus-article-treat-head-custom)
937 (defcustom gnus-treat-hide-boring-headers nil
938 "Hide boring headers.
939 Valid values are nil, t, `head', `last', an integer or a predicate.
940 See Info node `(gnus)Customizing Articles' for details."
941 :group 'gnus-article-treat
942 :link '(custom-manual "(gnus)Customizing Articles")
943 :type gnus-article-treat-head-custom)
945 (defcustom gnus-treat-hide-signature nil
947 Valid values are nil, t, `head', `last', an integer or a predicate.
948 See Info node `(gnus)Customizing Articles' for details."
949 :group 'gnus-article-treat
950 :link '(custom-manual "(gnus)Customizing Articles")
951 :type gnus-article-treat-custom)
953 (defcustom gnus-treat-fill-article nil
955 Valid values are nil, t, `head', `last', an integer or a predicate.
956 See Info node `(gnus)Customizing Articles' for details."
957 :group 'gnus-article-treat
958 :link '(custom-manual "(gnus)Customizing Articles")
959 :type gnus-article-treat-custom)
961 (defcustom gnus-treat-hide-citation nil
963 Valid values are nil, t, `head', `last', an integer or a predicate.
964 See Info node `(gnus)Customizing Articles' for details."
965 :group 'gnus-article-treat
966 :link '(custom-manual "(gnus)Customizing Articles")
967 :type gnus-article-treat-custom)
969 (defcustom gnus-treat-hide-citation-maybe nil
971 Valid values are nil, t, `head', `last', an integer or a predicate.
972 See Info node `(gnus)Customizing Articles' for details."
973 :group 'gnus-article-treat
974 :link '(custom-manual "(gnus)Customizing Articles")
975 :type gnus-article-treat-custom)
977 (defcustom gnus-treat-strip-list-identifiers 'head
978 "Strip list identifiers from `gnus-list-identifiers`.
979 Valid values are nil, t, `head', `last', an integer or a predicate.
980 See Info node `(gnus)Customizing Articles' for details."
982 :group 'gnus-article-treat
983 :link '(custom-manual "(gnus)Customizing Articles")
984 :type gnus-article-treat-custom)
986 (make-obsolete-variable 'gnus-treat-strip-pgp
987 "This option is obsolete in Gnus 5.10.")
989 (defcustom gnus-treat-strip-pem nil
990 "Strip PEM signatures.
991 Valid values are nil, t, `head', `last', an integer or a predicate.
992 See Info node `(gnus)Customizing Articles' for details."
993 :group 'gnus-article-treat
994 :link '(custom-manual "(gnus)Customizing Articles")
995 :type gnus-article-treat-custom)
997 (defcustom gnus-treat-strip-banner t
998 "Strip banners from articles.
999 The banner to be stripped is specified in the `banner' group parameter.
1000 Valid values are nil, t, `head', `last', an integer or a predicate.
1001 See Info node `(gnus)Customizing Articles' for details."
1002 :group 'gnus-article-treat
1003 :link '(custom-manual "(gnus)Customizing Articles")
1004 :type gnus-article-treat-custom)
1006 (defcustom gnus-treat-highlight-headers 'head
1007 "Highlight the headers.
1008 Valid values are nil, t, `head', `last', an integer or a predicate.
1009 See Info node `(gnus)Customizing Articles' for details."
1010 :group 'gnus-article-treat
1011 :link '(custom-manual "(gnus)Customizing Articles")
1012 :type gnus-article-treat-head-custom)
1013 (put 'gnus-treat-highlight-headers 'highlight t)
1015 (defcustom gnus-treat-highlight-citation t
1016 "Highlight cited text.
1017 Valid values are nil, t, `head', `last', an integer or a predicate.
1018 See Info node `(gnus)Customizing Articles' for details."
1019 :group 'gnus-article-treat
1020 :link '(custom-manual "(gnus)Customizing Articles")
1021 :type gnus-article-treat-custom)
1022 (put 'gnus-treat-highlight-citation 'highlight t)
1024 (defcustom gnus-treat-date-ut nil
1025 "Display the Date in UT (GMT).
1026 Valid values are nil, t, `head', `last', an integer or a predicate.
1027 See Info node `(gnus)Customizing Articles' for details."
1028 :group 'gnus-article-treat
1029 :link '(custom-manual "(gnus)Customizing Articles")
1030 :type gnus-article-treat-head-custom)
1032 (defcustom gnus-treat-date-local nil
1033 "Display the Date in the local timezone.
1034 Valid values are nil, t, `head', `last', an integer or a predicate.
1035 See Info node `(gnus)Customizing Articles' for details."
1036 :group 'gnus-article-treat
1037 :link '(custom-manual "(gnus)Customizing Articles")
1038 :type gnus-article-treat-head-custom)
1040 (defcustom gnus-treat-date-english nil
1041 "Display the Date in a format that can be read aloud in English.
1042 Valid values are nil, t, `head', `last', an integer or a predicate.
1043 See Info node `(gnus)Customizing Articles' for details."
1044 :group 'gnus-article-treat
1045 :link '(custom-manual "(gnus)Customizing Articles")
1046 :type gnus-article-treat-head-custom)
1048 (defcustom gnus-treat-date-lapsed nil
1049 "Display the Date header in a way that says how much time has elapsed.
1050 Valid values are nil, t, `head', `last', an integer or a predicate.
1051 See Info node `(gnus)Customizing Articles' for details."
1052 :group 'gnus-article-treat
1053 :link '(custom-manual "(gnus)Customizing Articles")
1054 :type gnus-article-treat-head-custom)
1056 (defcustom gnus-treat-date-original nil
1057 "Display the date in the original timezone.
1058 Valid values are nil, t, `head', `last', an integer or a predicate.
1059 See Info node `(gnus)Customizing Articles' for details."
1060 :group 'gnus-article-treat
1061 :link '(custom-manual "(gnus)Customizing Articles")
1062 :type gnus-article-treat-head-custom)
1064 (defcustom gnus-treat-date-iso8601 nil
1065 "Display the date in the ISO8601 format.
1066 Valid values are nil, t, `head', `last', an integer or a predicate.
1067 See Info node `(gnus)Customizing Articles' for details."
1069 :group 'gnus-article-treat
1070 :link '(custom-manual "(gnus)Customizing Articles")
1071 :type gnus-article-treat-head-custom)
1073 (defcustom gnus-treat-date-user-defined nil
1074 "Display the date in a user-defined format.
1075 The format is defined by the `gnus-article-time-format' variable.
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-head-custom)
1082 (defcustom gnus-treat-strip-headers-in-body t
1083 "Strip the X-No-Archive header line from the beginning of the body.
1084 Valid values are nil, t, `head', `last', an integer or a predicate.
1085 See Info node `(gnus)Customizing Articles' for details."
1087 :group 'gnus-article-treat
1088 :link '(custom-manual "(gnus)Customizing Articles")
1089 :type gnus-article-treat-custom)
1091 (defcustom gnus-treat-strip-trailing-blank-lines nil
1092 "Strip trailing blank lines.
1093 Valid values are nil, t, `head', `last', an integer or a predicate.
1094 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 (defcustom gnus-treat-strip-leading-blank-lines nil
1100 "Strip leading blank lines.
1101 Valid values are nil, t, `head', `last', an integer or a predicate.
1102 See Info node `(gnus)Customizing Articles' for details."
1103 :group 'gnus-article-treat
1104 :link '(custom-manual "(gnus)Customizing Articles")
1105 :type gnus-article-treat-custom)
1107 (defcustom gnus-treat-strip-multiple-blank-lines nil
1108 "Strip multiple blank lines.
1109 Valid values are nil, t, `head', `last', an integer or a predicate.
1110 See Info node `(gnus)Customizing Articles' for details."
1111 :group 'gnus-article-treat
1112 :link '(custom-manual "(gnus)Customizing Articles")
1113 :type gnus-article-treat-custom)
1115 (defcustom gnus-treat-unfold-headers 'head
1116 "Unfold folded header lines.
1117 Valid values are nil, t, `head', `last', an integer or a predicate.
1118 See Info node `(gnus)Customizing Articles' for details."
1119 :group 'gnus-article-treat
1120 :link '(custom-manual "(gnus)Customizing Articles")
1121 :type gnus-article-treat-custom)
1123 (defcustom gnus-treat-fold-headers nil
1125 Valid values are nil, t, `head', `last', an integer or a predicate.
1126 See Info node `(gnus)Customizing Articles' for details."
1127 :group 'gnus-article-treat
1128 :link '(custom-manual "(gnus)Customizing Articles")
1129 :type gnus-article-treat-custom)
1131 (defcustom gnus-treat-fold-newsgroups 'head
1132 "Fold the Newsgroups and Followup-To headers.
1133 Valid values are nil, t, `head', `last', an integer or a predicate.
1134 See Info node `(gnus)Customizing Articles' for details."
1135 :group 'gnus-article-treat
1136 :link '(custom-manual "(gnus)Customizing Articles")
1137 :type gnus-article-treat-custom)
1139 (defcustom gnus-treat-overstrike t
1140 "Treat overstrike highlighting.
1141 Valid values are nil, t, `head', `last', an integer or a predicate.
1142 See Info node `(gnus)Customizing Articles' for details."
1143 :group 'gnus-article-treat
1144 :link '(custom-manual "(gnus)Customizing Articles")
1145 :type gnus-article-treat-custom)
1146 (put 'gnus-treat-overstrike 'highlight t)
1148 (make-obsolete-variable 'gnus-treat-display-xface
1149 'gnus-treat-display-x-face)
1151 (defcustom gnus-treat-display-x-face
1152 (and (not noninteractive)
1153 (or (and (fboundp 'image-type-available-p)
1154 (image-type-available-p 'xbm)
1155 (string-match "^0x" (shell-command-to-string "uncompface"))
1156 (executable-find "icontopbm"))
1157 (and (featurep 'xemacs)
1160 "Display X-Face headers.
1161 Valid values are nil, t, `head', `last', an integer or a predicate.
1162 See Info node `(gnus)Customizing Articles' and Info node
1163 `(gnus)X-Face' for details."
1164 :group 'gnus-article-treat
1166 :link '(custom-manual "(gnus)Customizing Articles")
1167 :link '(custom-manual "(gnus)X-Face")
1168 :type gnus-article-treat-head-custom
1169 :set (lambda (symbol value)
1172 (cond ((or (boundp symbol) (get symbol 'saved-value))
1174 ((boundp 'gnus-treat-display-xface)
1176 ** gnus-treat-display-xface is an obsolete variable;\
1177 use gnus-treat-display-x-face instead")
1178 (default-value 'gnus-treat-display-xface))
1179 ((get 'gnus-treat-display-xface 'saved-value)
1181 ** gnus-treat-display-xface is an obsolete variable;\
1182 use gnus-treat-display-x-face instead")
1183 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1186 (put 'gnus-treat-display-x-face 'highlight t)
1188 (defcustom gnus-treat-display-face
1189 (and (not noninteractive)
1190 (or (and (fboundp 'image-type-available-p)
1191 (image-type-available-p 'png))
1192 (and (featurep 'xemacs)
1195 "Display Face headers.
1196 Valid values are nil, t, `head', `last', an integer or a predicate.
1197 See Info node `(gnus)Customizing Articles' and Info node
1198 `(gnus)X-Face' for details."
1199 :group 'gnus-article-treat
1201 :link '(custom-manual "(gnus)Customizing Articles")
1202 :link '(custom-manual "(gnus)X-Face")
1203 :type gnus-article-treat-head-custom)
1204 (put 'gnus-treat-display-face 'highlight t)
1206 (defcustom gnus-treat-display-smileys
1207 (if (or (and (featurep 'xemacs)
1209 (and (fboundp 'image-type-available-p)
1210 (image-type-available-p 'pbm)))
1213 Valid values are nil, t, `head', `last', an integer or a predicate.
1214 See Info node `(gnus)Customizing Articles' and Info node
1215 `(gnus)Smileys' for details."
1216 :group 'gnus-article-treat
1218 :link '(custom-manual "(gnus)Customizing Articles")
1219 :link '(custom-manual "(gnus)Smileys")
1220 :type gnus-article-treat-custom)
1221 (put 'gnus-treat-display-smileys 'highlight t)
1223 (defcustom gnus-treat-from-picon
1224 (if (and (gnus-image-type-available-p 'xpm)
1225 (gnus-picons-installed-p))
1227 "Display picons in the From header.
1228 Valid values are nil, t, `head', `last', an integer or a predicate.
1229 See Info node `(gnus)Customizing Articles' and Info node
1230 `(gnus)Picons' for details."
1231 :group 'gnus-article-treat
1233 :link '(custom-manual "(gnus)Customizing Articles")
1234 :link '(custom-manual "(gnus)Picons")
1235 :type gnus-article-treat-head-custom)
1236 (put 'gnus-treat-from-picon 'highlight t)
1238 (defcustom gnus-treat-mail-picon
1239 (if (and (gnus-image-type-available-p 'xpm)
1240 (gnus-picons-installed-p))
1242 "Display picons in To and Cc headers.
1243 Valid values are nil, t, `head', `last', an integer or a predicate.
1244 See Info node `(gnus)Customizing Articles' and Info node
1245 `(gnus)Picons' for details."
1246 :group 'gnus-article-treat
1248 :link '(custom-manual "(gnus)Customizing Articles")
1249 :link '(custom-manual "(gnus)Picons")
1250 :type gnus-article-treat-head-custom)
1251 (put 'gnus-treat-mail-picon 'highlight t)
1253 (defcustom gnus-treat-newsgroups-picon
1254 (if (and (gnus-image-type-available-p 'xpm)
1255 (gnus-picons-installed-p))
1257 "Display picons in the Newsgroups and Followup-To headers.
1258 Valid values are nil, t, `head', `last', an integer or a predicate.
1259 See Info node `(gnus)Customizing Articles' and Info node
1260 `(gnus)Picons' for details."
1261 :group 'gnus-article-treat
1263 :link '(custom-manual "(gnus)Customizing Articles")
1264 :link '(custom-manual "(gnus)Picons")
1265 :type gnus-article-treat-head-custom)
1266 (put 'gnus-treat-newsgroups-picon 'highlight t)
1268 (defcustom gnus-treat-body-boundary
1269 (if (or gnus-treat-newsgroups-picon
1270 gnus-treat-mail-picon
1271 gnus-treat-from-picon)
1273 "Draw a boundary at the end of the headers.
1274 Valid values are nil, t, `head', `last', an integer or a predicate.
1275 See Info node `(gnus)Customizing Articles' for details."
1277 :group 'gnus-article-treat
1278 :link '(custom-manual "(gnus)Customizing Articles")
1279 :type gnus-article-treat-custom)
1281 (defcustom gnus-treat-capitalize-sentences nil
1282 "Capitalize sentence-starting words.
1283 Valid values are nil, t, `head', `last', an integer or a predicate.
1284 See Info node `(gnus)Customizing Articles' for details."
1286 :group 'gnus-article-treat
1287 :link '(custom-manual "(gnus)Customizing Articles")
1288 :type gnus-article-treat-custom)
1290 (defcustom gnus-treat-wash-html nil
1292 Valid values are nil, t, `head', `last', an integer or a predicate.
1293 See Info node `(gnus)Customizing Articles' for details."
1294 :group 'gnus-article-treat
1295 :link '(custom-manual "(gnus)Customizing Articles")
1296 :type gnus-article-treat-custom)
1298 (defcustom gnus-treat-fill-long-lines nil
1300 Valid values are nil, t, `head', `last', an integer or a predicate.
1301 See Info node `(gnus)Customizing Articles' for details."
1302 :group 'gnus-article-treat
1303 :link '(custom-manual "(gnus)Customizing Articles")
1304 :type gnus-article-treat-custom)
1306 (defcustom gnus-treat-play-sounds nil
1308 Valid values are nil, t, `head', `last', an integer or a predicate.
1309 See Info node `(gnus)Customizing Articles' for details."
1311 :group 'gnus-article-treat
1312 :link '(custom-manual "(gnus)Customizing Articles")
1313 :type gnus-article-treat-custom)
1315 (defcustom gnus-treat-translate nil
1316 "Translate articles from one language to another.
1317 Valid values are nil, t, `head', `last', an integer or a predicate.
1318 See Info node `(gnus)Customizing Articles' for details."
1320 :group 'gnus-article-treat
1321 :link '(custom-manual "(gnus)Customizing Articles")
1322 :type gnus-article-treat-custom)
1324 (defcustom gnus-treat-x-pgp-sig nil
1326 To automatically treat X-PGP-Sig, set it to head.
1327 Valid values are nil, t, `head', `last', an integer or a predicate.
1328 See Info node `(gnus)Customizing Articles' for details."
1329 :group 'gnus-article-treat
1330 :group 'mime-security
1331 :link '(custom-manual "(gnus)Customizing Articles")
1332 :type gnus-article-treat-custom)
1334 (defvar gnus-article-encrypt-protocol-alist
1335 '(("PGP" . mml2015-self-encrypt)))
1337 ;; Set to nil if more than one protocol added to
1338 ;; gnus-article-encrypt-protocol-alist.
1339 (defcustom gnus-article-encrypt-protocol "PGP"
1340 "The protocol used for encrypt articles.
1341 It is a string, such as \"PGP\". If nil, ask user."
1343 :group 'mime-security)
1345 (defvar gnus-article-wash-function nil
1346 "Function used for converting HTML into text.")
1348 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1349 (mm-coding-system-p 'utf-8)
1350 (executable-find idna-program))
1351 "Whether IDNA decoding of headers is used when viewing messages.
1352 This requires GNU Libidn, and by default only enabled if it is found."
1353 :group 'gnus-article-headers
1356 (defcustom gnus-article-over-scroll nil
1357 "If non-nil, allow scrolling the article buffer even when there no more text."
1358 :group 'gnus-article
1361 ;;; Internal variables
1363 (defvar gnus-english-month-names
1364 '("January" "February" "March" "April" "May" "June" "July" "August"
1365 "September" "October" "November" "December"))
1367 (defvar article-goto-body-goes-to-point-min-p nil)
1368 (defvar gnus-article-wash-types nil)
1369 (defvar gnus-article-emphasis-alist nil)
1370 (defvar gnus-article-image-alist nil)
1372 (defvar gnus-article-mime-handle-alist-1 nil)
1373 (defvar gnus-treatment-function-alist
1374 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1375 (gnus-treat-strip-banner gnus-article-strip-banner)
1376 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1377 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1378 (gnus-treat-buttonize gnus-article-add-buttons)
1379 (gnus-treat-fill-article gnus-article-fill-cited-article)
1380 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1381 (gnus-treat-strip-cr gnus-article-remove-cr)
1382 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1383 (gnus-treat-date-ut gnus-article-date-ut)
1384 (gnus-treat-date-local gnus-article-date-local)
1385 (gnus-treat-date-english gnus-article-date-english)
1386 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1387 (gnus-treat-date-original gnus-article-date-original)
1388 (gnus-treat-date-user-defined gnus-article-date-user)
1389 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1390 (gnus-treat-display-x-face gnus-article-display-x-face)
1391 (gnus-treat-display-face gnus-article-display-face)
1392 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1393 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1394 (gnus-treat-hide-signature gnus-article-hide-signature)
1395 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1396 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1397 (gnus-treat-strip-pem gnus-article-hide-pem)
1398 (gnus-treat-from-picon gnus-treat-from-picon)
1399 (gnus-treat-mail-picon gnus-treat-mail-picon)
1400 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1401 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1402 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1403 (gnus-treat-strip-trailing-blank-lines
1404 gnus-article-remove-trailing-blank-lines)
1405 (gnus-treat-strip-leading-blank-lines
1406 gnus-article-strip-leading-blank-lines)
1407 (gnus-treat-strip-multiple-blank-lines
1408 gnus-article-strip-multiple-blank-lines)
1409 (gnus-treat-overstrike gnus-article-treat-overstrike)
1410 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1411 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1412 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1413 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1414 (gnus-treat-display-smileys gnus-treat-smiley)
1415 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1416 (gnus-treat-wash-html gnus-article-wash-html)
1417 (gnus-treat-emphasize gnus-article-emphasize)
1418 (gnus-treat-hide-citation gnus-article-hide-citation)
1419 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1420 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1421 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1422 (gnus-treat-play-sounds gnus-earcon-display)))
1424 (defvar gnus-article-mime-handle-alist nil)
1425 (defvar article-lapsed-timer nil)
1426 (defvar gnus-article-current-summary nil)
1428 (defvar gnus-article-mode-syntax-table
1429 (let ((table (copy-syntax-table text-mode-syntax-table)))
1430 ;; This causes the citation match run O(2^n).
1431 ;; (modify-syntax-entry ?- "w" table)
1432 (modify-syntax-entry ?> ")<" table)
1433 (modify-syntax-entry ?< "(>" table)
1434 ;; make M-. in article buffers work for `foo' strings
1435 (modify-syntax-entry ?' " " table)
1436 (modify-syntax-entry ?` " " table)
1438 "Syntax table used in article mode buffers.
1439 Initialized from `text-mode-syntax-table.")
1441 (defvar gnus-save-article-buffer nil)
1443 (defvar gnus-article-mode-line-format-alist
1444 (nconc '((?w (gnus-article-wash-status) ?s)
1445 (?m (gnus-article-mime-part-status) ?s))
1446 gnus-summary-mode-line-format-alist))
1448 (defvar gnus-number-of-articles-to-be-saved nil)
1450 (defvar gnus-inhibit-hiding nil)
1452 ;;; Macros for dealing with the article buffer.
1454 (defmacro gnus-with-article-headers (&rest forms)
1456 (set-buffer gnus-article-buffer)
1458 (let ((buffer-read-only nil)
1459 (inhibit-point-motion-hooks t)
1460 (case-fold-search t))
1461 (article-narrow-to-head)
1464 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1465 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1467 (defmacro gnus-with-article-buffer (&rest forms)
1469 (set-buffer gnus-article-buffer)
1470 (let ((buffer-read-only nil))
1473 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1474 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1476 (defun gnus-article-goto-header (header)
1477 "Go to HEADER, which is a regular expression."
1478 (re-search-forward (concat "^\\(" header "\\):") nil t))
1480 (defsubst gnus-article-hide-text (b e props)
1481 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1482 (gnus-add-text-properties-when 'article-type nil b e props)
1483 (when (memq 'intangible props)
1485 (max (1- b) (point-min))
1486 b 'intangible (cddr (memq 'intangible props)))))
1488 (defsubst gnus-article-unhide-text (b e)
1489 "Remove hidden text properties from region between B and E."
1490 (remove-text-properties b e gnus-hidden-properties)
1491 (when (memq 'intangible gnus-hidden-properties)
1492 (put-text-property (max (1- b) (point-min))
1493 b 'intangible nil)))
1495 (defun gnus-article-hide-text-type (b e type)
1496 "Hide text of TYPE between B and E."
1497 (gnus-add-wash-type type)
1498 (gnus-article-hide-text
1499 b e (cons 'article-type (cons type gnus-hidden-properties))))
1501 (defun gnus-article-unhide-text-type (b e type)
1502 "Unhide text of TYPE between B and E."
1503 (gnus-delete-wash-type type)
1504 (remove-text-properties
1505 b e (cons 'article-type (cons type gnus-hidden-properties)))
1506 (when (memq 'intangible gnus-hidden-properties)
1507 (put-text-property (max (1- b) (point-min))
1508 b 'intangible nil)))
1510 (defun gnus-article-hide-text-of-type (type)
1511 "Hide text of TYPE in the current buffer."
1513 (let ((b (point-min))
1515 (while (setq b (text-property-any b e 'article-type type))
1516 (add-text-properties b (incf b) gnus-hidden-properties)))))
1518 (defun gnus-article-delete-text-of-type (type)
1519 "Delete text of TYPE in the current buffer."
1521 (let ((b (point-min)))
1522 (while (setq b (text-property-any b (point-max) 'article-type type))
1524 b (or (text-property-not-all b (point-max) 'article-type type)
1527 (defun gnus-article-delete-invisible-text ()
1528 "Delete all invisible text in the current buffer."
1530 (let ((b (point-min)))
1531 (while (setq b (text-property-any b (point-max) 'invisible t))
1533 b (or (text-property-not-all b (point-max) 'invisible t)
1536 (defun gnus-article-text-type-exists-p (type)
1537 "Say whether any text of type TYPE exists in the buffer."
1538 (text-property-any (point-min) (point-max) 'article-type type))
1540 (defsubst gnus-article-header-rank ()
1541 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1542 (let ((list gnus-sorted-header-list)
1545 (if (looking-at (car list))
1547 (setq list (cdr list))
1551 (defun article-hide-headers (&optional arg delete)
1552 "Hide unwanted headers and possibly sort them as well."
1554 ;; This function might be inhibited.
1555 (unless gnus-inhibit-hiding
1558 (let ((buffer-read-only nil)
1559 (case-fold-search t)
1560 (max (1+ (length gnus-sorted-header-list)))
1561 (ignored (when (not gnus-visible-headers)
1562 (cond ((stringp gnus-ignored-headers)
1563 gnus-ignored-headers)
1564 ((listp gnus-ignored-headers)
1565 (mapconcat 'identity gnus-ignored-headers
1568 (cond ((stringp gnus-visible-headers)
1569 gnus-visible-headers)
1570 ((and gnus-visible-headers
1571 (listp gnus-visible-headers))
1572 (mapconcat 'identity gnus-visible-headers "\\|"))))
1573 (inhibit-point-motion-hooks t)
1575 ;; First we narrow to just the headers.
1576 (article-narrow-to-head)
1577 ;; Hide any "From " lines at the beginning of (mail) articles.
1578 (while (looking-at "From ")
1581 (delete-region (point-min) (point)))
1582 ;; Then treat the rest of the header lines.
1583 ;; Then we use the two regular expressions
1584 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1585 ;; select which header lines is to remain visible in the
1587 (while (re-search-forward "^[^ \t:]*:" nil t)
1589 ;; Mark the rank of the header.
1591 (point) (1+ (point)) 'message-rank
1592 (if (or (and visible (looking-at visible))
1594 (not (looking-at ignored))))
1595 (gnus-article-header-rank)
1598 (message-sort-headers-1)
1599 (when (setq beg (text-property-any
1600 (point-min) (point-max) 'message-rank (+ 2 max)))
1601 ;; We delete the unwanted headers.
1602 (gnus-add-wash-type 'headers)
1603 (add-text-properties (point-min) (+ 5 (point-min))
1604 '(article-type headers dummy-invisible t))
1605 (delete-region beg (point-max))))))))
1607 (defun article-hide-boring-headers (&optional arg)
1608 "Toggle hiding of headers that aren't very interesting.
1609 If given a negative prefix, always show; if given a positive prefix,
1611 (interactive (gnus-article-hidden-arg))
1612 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1613 (not gnus-show-all-headers))
1616 (let ((buffer-read-only nil)
1617 (list gnus-boring-article-headers)
1618 (inhibit-point-motion-hooks t)
1620 (article-narrow-to-head)
1622 (setq elem (pop list))
1623 (goto-char (point-min))
1625 ;; Hide empty headers.
1627 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1629 (gnus-article-hide-text-type
1633 (if (re-search-forward "^[^ \t]" nil t)
1637 ;; Hide boring Newsgroups header.
1638 ((eq elem 'newsgroups)
1639 (when (gnus-string-equal
1640 (gnus-fetch-field "newsgroups")
1641 (gnus-group-real-name
1642 (if (boundp 'gnus-newsgroup-name)
1645 (gnus-article-hide-header "newsgroups")))
1646 ((eq elem 'to-address)
1647 (let ((to (message-fetch-field "to"))
1649 (gnus-parameter-to-address
1650 (if (boundp 'gnus-newsgroup-name)
1651 gnus-newsgroup-name ""))))
1652 (when (and to to-address
1655 ;; only one address in To
1656 (nth 1 (mail-extract-address-components to))
1658 (gnus-article-hide-header "to"))))
1660 (let ((to (message-fetch-field "to"))
1662 (gnus-parameter-to-list
1663 (if (boundp 'gnus-newsgroup-name)
1664 gnus-newsgroup-name ""))))
1665 (when (and to to-list
1668 ;; only one address in To
1669 (nth 1 (mail-extract-address-components to))
1671 (gnus-article-hide-header "to"))))
1673 (let ((cc (message-fetch-field "cc"))
1675 (gnus-parameter-to-list
1676 (if (boundp 'gnus-newsgroup-name)
1677 gnus-newsgroup-name ""))))
1678 (when (and cc to-list
1681 ;; only one address in CC
1682 (nth 1 (mail-extract-address-components cc))
1684 (gnus-article-hide-header "cc"))))
1685 ((eq elem 'followup-to)
1686 (when (gnus-string-equal
1687 (message-fetch-field "followup-to")
1688 (message-fetch-field "newsgroups"))
1689 (gnus-article-hide-header "followup-to")))
1690 ((eq elem 'reply-to)
1691 (if (gnus-group-find-parameter
1692 gnus-newsgroup-name 'broken-reply-to)
1693 (gnus-article-hide-header "reply-to")
1694 (let ((from (message-fetch-field "from"))
1695 (reply-to (message-fetch-field "reply-to")))
1700 (nth 1 (mail-extract-address-components from))
1701 (nth 1 (mail-extract-address-components reply-to)))))
1702 (gnus-article-hide-header "reply-to")))))
1704 (let ((date (message-fetch-field "date")))
1706 (< (days-between (current-time-string) date)
1708 (gnus-article-hide-header "date"))))
1710 (let ((to (message-fetch-field "to"))
1711 (cc (message-fetch-field "cc")))
1712 (when (> (length to) 1024)
1713 (gnus-article-hide-header "to"))
1714 (when (> (length cc) 1024)
1715 (gnus-article-hide-header "cc"))))
1719 (goto-char (point-min))
1720 (while (re-search-forward "^to:" nil t)
1721 (setq to-count (1+ to-count)))
1722 (when (> to-count 1)
1723 (while (> to-count 0)
1724 (goto-char (point-min))
1726 (re-search-forward "^to:" nil nil to-count)
1728 (narrow-to-region (point) (point-max))
1729 (gnus-article-hide-header "to"))
1730 (setq to-count (1- to-count))))
1731 (goto-char (point-min))
1732 (while (re-search-forward "^cc:" nil t)
1733 (setq cc-count (1+ cc-count)))
1734 (when (> cc-count 1)
1735 (while (> cc-count 0)
1736 (goto-char (point-min))
1738 (re-search-forward "^cc:" nil nil cc-count)
1740 (narrow-to-region (point) (point-max))
1741 (gnus-article-hide-header "cc"))
1742 (setq cc-count (1- cc-count)))))))))))))
1744 (defun gnus-article-hide-header (header)
1746 (goto-char (point-min))
1747 (when (re-search-forward (concat "^" header ":") nil t)
1748 (gnus-article-hide-text-type
1752 (if (re-search-forward "^[^ \t]" nil t)
1757 (defvar gnus-article-normalized-header-length 40
1758 "Length of normalized headers.")
1760 (defun article-normalize-headers ()
1761 "Make all header lines 40 characters long."
1763 (let ((buffer-read-only nil)
1767 (article-narrow-to-head)
1770 ((< (setq column (- (gnus-point-at-eol) (point)))
1771 gnus-article-normalized-header-length)
1773 (insert (make-string
1774 (- gnus-article-normalized-header-length column)
1776 ((> column gnus-article-normalized-header-length)
1777 (gnus-put-text-property
1779 (forward-char gnus-article-normalized-header-length)
1786 (forward-line 1))))))
1788 (defun article-treat-dumbquotes ()
1789 "Translate M****s*** sm*rtq**t*s into proper text.
1790 Note that this function guesses whether a character is a sm*rtq**t* or
1791 not, so it should only be used interactively.
1793 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1794 in an attempt to provide more quoting characters. If you see
1795 something like \\222 or \\264 where you're expecting some kind of
1796 apostrophe or quotation mark, then try this wash."
1798 (article-translate-strings gnus-article-dumbquotes-map))
1800 (defun article-translate-characters (from to)
1801 "Translate all characters in the body of the article according to FROM and TO.
1802 FROM is a string of characters to translate from; to is a string of
1803 characters to translate to."
1805 (when (article-goto-body)
1806 (let ((buffer-read-only nil)
1807 (x (make-string 225 ?x))
1809 (while (< (incf i) (length x))
1812 (while (< i (length from))
1813 (aset x (aref from i) (aref to i))
1815 (translate-region (point) (point-max) x)))))
1817 (defun article-translate-strings (map)
1818 "Translate all string in the body of the article according to MAP.
1819 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1821 (when (article-goto-body)
1822 (let ((buffer-read-only nil)
1824 (while (setq elem (pop map))
1826 (while (search-forward (car elem) nil t)
1827 (replace-match (cadr elem)))))))))
1829 (defun article-treat-overstrike ()
1830 "Translate overstrikes into bold text."
1833 (when (article-goto-body)
1834 (let ((buffer-read-only nil))
1835 (while (search-forward "\b" nil t)
1836 (let ((next (char-after))
1837 (previous (char-after (- (point) 2))))
1838 ;; We do the boldification/underlining by hiding the
1839 ;; overstrikes and putting the proper text property
1843 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1844 (put-text-property (point) (1+ (point)) 'face 'bold))
1846 (gnus-article-hide-text-type
1847 (1- (point)) (1+ (point)) 'overstrike)
1849 (- (point) 2) (1- (point)) 'face 'underline))
1851 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1853 (point) (1+ (point)) 'face 'underline)))))))))
1855 (defun gnus-article-treat-unfold-headers ()
1856 "Unfold folded message headers.
1857 Only the headers that fit into the current window width will be
1860 (gnus-with-article-headers
1864 (mail-header-narrow-to-field)
1865 (let ((header (buffer-string)))
1868 (goto-char (point-min))
1869 (while (re-search-forward "\n[\t ]" nil t)
1870 (replace-match " " t t)))
1871 (setq length (- (point-max) (point-min) 1)))
1872 (when (< length (window-width))
1873 (while (re-search-forward "\n[\t ]" nil t)
1874 (replace-match " " t t)))
1875 (goto-char (point-max)))))))
1877 (defun gnus-article-treat-fold-headers ()
1878 "Fold message headers."
1880 (gnus-with-article-headers
1883 (mail-header-narrow-to-field)
1884 (mail-header-fold-field)
1885 (goto-char (point-max))))))
1887 (defun gnus-treat-smiley ()
1888 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1890 (gnus-with-article-buffer
1891 (if (memq 'smiley gnus-article-wash-types)
1892 (gnus-delete-images 'smiley)
1894 (let ((images (smiley-region (point) (point-max))))
1896 (gnus-add-wash-type 'smiley)
1897 (dolist (image images)
1898 (gnus-add-image 'smiley image)))))))
1900 (defun gnus-article-remove-images ()
1901 "Remove all images from the article buffer."
1903 (gnus-with-article-buffer
1904 (dolist (elem gnus-article-image-alist)
1905 (gnus-delete-images (car elem)))))
1907 (defun gnus-article-treat-fold-newsgroups ()
1908 "Unfold folded message headers.
1909 Only the headers that fit into the current window width will be
1912 (gnus-with-article-headers
1913 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1915 (mail-header-narrow-to-field)
1916 (while (re-search-forward ", *" nil t)
1917 (replace-match ", " t t))
1918 (mail-header-fold-field)
1919 (goto-char (point-max))))))
1921 (defun gnus-article-treat-body-boundary ()
1922 "Place a boundary line at the end of the headers."
1924 (when (and gnus-body-boundary-delimiter
1925 (> (length gnus-body-boundary-delimiter) 0))
1926 (gnus-with-article-headers
1927 (goto-char (point-max))
1928 (let ((start (point)))
1929 (insert "X-Boundary: ")
1930 (gnus-add-text-properties start (point) '(invisible t intangible t))
1932 (while (>= (1- (window-width)) (length str))
1933 (setq str (concat str gnus-body-boundary-delimiter)))
1934 (substring str 0 (1- (window-width))))
1936 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1938 (defun article-fill-long-lines ()
1939 "Fill lines that are wider than the window width."
1942 (let ((buffer-read-only nil)
1943 (width (window-width (get-buffer-window (current-buffer)))))
1946 (let ((adaptive-fill-mode nil)) ;Why? -sm
1949 (when (>= (current-column) (min fill-column width))
1950 (narrow-to-region (min (1+ (point)) (point-max))
1951 (gnus-point-at-bol))
1952 (let ((goback (point-marker)))
1953 (fill-paragraph nil)
1954 (goto-char (marker-position goback)))
1956 (forward-line 1)))))))
1958 (defun article-capitalize-sentences ()
1959 "Capitalize the first word in each sentence."
1962 (let ((buffer-read-only nil)
1963 (paragraph-start "^[\n\^L]"))
1967 (forward-sentence)))))
1969 (defun article-remove-cr ()
1970 "Remove trailing CRs and then translate remaining CRs into LFs."
1973 (let ((buffer-read-only nil))
1974 (goto-char (point-min))
1975 (while (re-search-forward "\r+$" nil t)
1976 (replace-match "" t t))
1977 (goto-char (point-min))
1978 (while (search-forward "\r" nil t)
1979 (replace-match "\n" t t)))))
1981 (defun article-remove-trailing-blank-lines ()
1982 "Remove all trailing blank lines from the article."
1985 (let ((buffer-read-only nil))
1986 (goto-char (point-max))
1990 (while (and (not (bobp))
1991 (looking-at "^[ \t]*$")
1992 (not (gnus-annotation-in-region-p
1993 (point) (gnus-point-at-eol))))
1998 (defun article-display-face ()
1999 "Display any Face headers in the header."
2001 (let ((wash-face-p buffer-read-only))
2002 (gnus-with-article-headers
2003 ;; When displaying parts, this function can be called several times on
2004 ;; the same article, without any intended toggle semantic (as typing `W
2005 ;; D d' would have). So face deletion must occur only when we come from
2006 ;; an interactive command, that is when the *Article* buffer is
2008 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2009 (gnus-delete-images 'face)
2012 (when (and wash-face-p
2014 (goto-char (point-min))
2015 (not (re-search-forward "^Face:[\t ]*" nil t)))
2016 (gnus-buffer-live-p gnus-original-article-buffer))
2017 (set-buffer gnus-original-article-buffer))
2019 (mail-narrow-to-head)
2020 (while (gnus-article-goto-header "Face")
2021 (push (mail-header-field-value) faces))))
2022 (while (setq face (pop faces))
2023 (let ((png (gnus-convert-face-to-png face))
2026 (setq image (gnus-create-image png 'png t))
2027 (gnus-article-goto-header "from")
2029 (insert "From: [no `from' set]\n")
2031 (gnus-add-wash-type 'face)
2032 (gnus-add-image 'face image)
2033 (gnus-put-image image nil 'face))))))
2036 (defun article-display-x-face (&optional force)
2037 "Look for an X-Face header and display it if present."
2038 (interactive (list 'force))
2039 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2040 (gnus-with-article-headers
2041 ;; Delete the old process, if any.
2042 (when (process-status "article-x-face")
2043 (delete-process "article-x-face"))
2044 ;; See the comment in `article-display-face'.
2045 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2046 ;; We have already displayed X-Faces, so we remove them
2048 (gnus-delete-images 'xface)
2050 (let (x-faces from face)
2052 (when (and wash-face-p
2054 (goto-char (point-min))
2055 (not (re-search-forward
2056 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2057 (gnus-buffer-live-p gnus-original-article-buffer))
2058 ;; If type `W f', use gnus-original-article-buffer,
2059 ;; otherwise use the current buffer because displaying
2060 ;; RFC822 parts calls this function too.
2061 (set-buffer gnus-original-article-buffer))
2063 (mail-narrow-to-head)
2064 (while (gnus-article-goto-header "X-Face")
2065 (push (mail-header-field-value) x-faces))
2066 (setq from (message-fetch-field "from"))))
2067 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2068 ;; single external face.
2069 (when (stringp gnus-article-x-face-command)
2070 (setq x-faces (list (car x-faces))))
2071 (while (and (setq face (pop x-faces))
2072 gnus-article-x-face-command
2074 ;; Check whether this face is censored.
2075 (not gnus-article-x-face-too-ugly)
2076 (and gnus-article-x-face-too-ugly from
2077 (not (string-match gnus-article-x-face-too-ugly
2079 ;; We display the face.
2080 (cond ((stringp gnus-article-x-face-command)
2081 ;; The command is a string, so we interpret the command
2082 ;; as a, well, command, and fork it off.
2083 (let ((process-connection-type nil))
2084 (process-kill-without-query
2086 "article-x-face" nil shell-file-name
2087 shell-command-switch gnus-article-x-face-command))
2090 (process-send-region "article-x-face"
2091 (point-min) (point-max)))
2092 (process-send-eof "article-x-face")))
2093 ((functionp gnus-article-x-face-command)
2094 ;; The command is a lisp function, so we call it.
2095 (funcall gnus-article-x-face-command face))
2097 (error "%s is not a function"
2098 gnus-article-x-face-command)))))))))
2100 (defun article-decode-mime-words ()
2101 "Decode all MIME-encoded words in the article."
2104 (set-buffer gnus-article-buffer)
2105 (let ((inhibit-point-motion-hooks t)
2107 (mail-parse-charset gnus-newsgroup-charset)
2108 (mail-parse-ignored-charsets
2109 (save-excursion (set-buffer gnus-summary-buffer)
2110 gnus-newsgroup-ignored-charsets)))
2111 (mail-decode-encoded-word-region (point-min) (point-max)))))
2113 (defun article-decode-charset (&optional prompt)
2114 "Decode charset-encoded text in the article.
2115 If PROMPT (the prefix), prompt for a coding system to use."
2117 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2119 (mail-parse-charset gnus-newsgroup-charset)
2120 (mail-parse-ignored-charsets
2121 (save-excursion (condition-case nil
2122 (set-buffer gnus-summary-buffer)
2124 gnus-newsgroup-ignored-charsets))
2125 ct cte ctl charset format)
2128 (article-narrow-to-head)
2129 (setq ct (message-fetch-field "Content-Type" t)
2130 cte (message-fetch-field "Content-Transfer-Encoding" t)
2131 ctl (and ct (ignore-errors
2132 (mail-header-parse-content-type ct)))
2135 (mm-read-coding-system "Charset to decode: "))
2137 (mail-content-type-get ctl 'charset)))
2138 format (and ctl (mail-content-type-get ctl 'format)))
2140 (setq cte (mail-header-strip cte)))
2141 (if (and ctl (not (string-match "/" (car ctl))))
2143 (goto-char (point-max)))
2146 (narrow-to-region (point) (point-max))
2147 (when (and (eq mail-parse-charset 'gnus-decoded)
2148 (eq (mm-body-7-or-8) '8bit))
2149 ;; The text code could have been decoded.
2150 (setq charset mail-parse-charset))
2151 (when (and (or (not ctl)
2152 (equal (car ctl) "text/plain"))
2153 (not format)) ;; article with format will decode later.
2155 charset (and cte (intern (downcase
2156 (gnus-strip-whitespace cte))))
2159 (defun article-decode-encoded-words ()
2160 "Remove encoded-word encoding from headers."
2161 (let ((inhibit-point-motion-hooks t)
2162 (mail-parse-charset gnus-newsgroup-charset)
2163 (mail-parse-ignored-charsets
2164 (save-excursion (condition-case nil
2165 (set-buffer gnus-summary-buffer)
2167 gnus-newsgroup-ignored-charsets))
2170 (article-narrow-to-head)
2171 (funcall gnus-decode-header-function (point-min) (point-max)))))
2173 (defun article-decode-group-name ()
2174 "Decode group names in `Newsgroups:'."
2175 (let ((inhibit-point-motion-hooks t)
2177 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2178 (when (and (or gnus-group-name-charset-method-alist
2179 gnus-group-name-charset-group-alist)
2180 (gnus-buffer-live-p gnus-original-article-buffer))
2182 (article-narrow-to-head)
2183 (with-current-buffer gnus-original-article-buffer
2184 (goto-char (point-min)))
2185 (while (re-search-forward
2186 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2187 (replace-match (save-match-data
2188 (gnus-decode-newsgroups
2189 ;; XXX how to use data in article buffer?
2190 (with-current-buffer gnus-original-article-buffer
2192 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2195 gnus-newsgroup-name method))
2197 (goto-char (point-min))
2198 (with-current-buffer gnus-original-article-buffer
2199 (goto-char (point-min)))
2200 (while (re-search-forward
2201 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2202 (replace-match (save-match-data
2203 (gnus-decode-newsgroups
2204 ;; XXX how to use data in article buffer?
2205 (with-current-buffer gnus-original-article-buffer
2207 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2210 gnus-newsgroup-name method))
2213 (autoload 'idna-to-unicode "idna")
2215 (defun article-decode-idna-rhs ()
2216 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2219 (let ((inhibit-point-motion-hooks t)
2221 (article-narrow-to-head)
2222 (goto-char (point-min))
2223 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2225 (when (save-match-data
2226 (and (setq ace (match-string 1))
2228 (and (re-search-backward "^[^ \t]" nil t)
2229 (looking-at "From\\|To\\|Cc")))
2230 (save-excursion (backward-char)
2231 (message-idna-inside-rhs-p))
2232 (setq unicode (idna-to-unicode ace))))
2233 (unless (string= ace unicode)
2234 (replace-match unicode nil nil nil 1)))))))))
2236 (defun article-de-quoted-unreadable (&optional force read-charset)
2237 "Translate a quoted-printable-encoded article.
2238 If FORCE, decode the article whether it is marked as quoted-printable
2240 If READ-CHARSET, ask for a coding system."
2241 (interactive (list 'force current-prefix-arg))
2243 (let ((buffer-read-only nil) type charset)
2244 (if (gnus-buffer-live-p gnus-original-article-buffer)
2245 (with-current-buffer gnus-original-article-buffer
2247 (gnus-fetch-field "content-transfer-encoding"))
2248 (let* ((ct (gnus-fetch-field "content-type"))
2251 (mail-header-parse-content-type ct)))))
2252 (setq charset (and ctl
2253 (mail-content-type-get ctl 'charset)))
2254 (if (stringp charset)
2255 (setq charset (intern (downcase charset)))))))
2257 (setq charset (mm-read-coding-system "Charset: " charset)))
2259 (setq charset gnus-newsgroup-charset))
2261 (and type (let ((case-fold-search t))
2262 (string-match "quoted-printable" type))))
2264 (quoted-printable-decode-region
2265 (point) (point-max) (mm-charset-to-coding-system charset))))))
2267 (defun article-de-base64-unreadable (&optional force read-charset)
2268 "Translate a base64 article.
2269 If FORCE, decode the article whether it is marked as base64 not.
2270 If READ-CHARSET, ask for a coding system."
2271 (interactive (list 'force current-prefix-arg))
2273 (let ((buffer-read-only nil) type charset)
2274 (if (gnus-buffer-live-p gnus-original-article-buffer)
2275 (with-current-buffer gnus-original-article-buffer
2277 (gnus-fetch-field "content-transfer-encoding"))
2278 (let* ((ct (gnus-fetch-field "content-type"))
2281 (mail-header-parse-content-type ct)))))
2282 (setq charset (and ctl
2283 (mail-content-type-get ctl 'charset)))
2284 (if (stringp charset)
2285 (setq charset (intern (downcase charset)))))))
2287 (setq charset (mm-read-coding-system "Charset: " charset)))
2289 (setq charset gnus-newsgroup-charset))
2291 (and type (let ((case-fold-search t))
2292 (string-match "base64" type))))
2295 (narrow-to-region (point) (point-max))
2296 (base64-decode-region (point-min) (point-max))
2297 (mm-decode-coding-region
2298 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2303 (defun article-decode-HZ ()
2304 "Translate a HZ-encoded article."
2308 (let ((buffer-read-only nil))
2309 (rfc1843-decode-region (point-min) (point-max)))))
2311 (defun article-unsplit-urls ()
2312 "Remove the newlines that some other mailers insert into URLs."
2315 (let ((buffer-read-only nil))
2316 (goto-char (point-min))
2317 (while (re-search-forward
2318 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2319 (replace-match "\\1\\3" t)))
2320 (when (interactive-p)
2321 (gnus-treat-article nil))))
2324 (defun article-wash-html (&optional read-charset)
2325 "Format an HTML article.
2326 If READ-CHARSET, ask for a coding system."
2329 (let ((buffer-read-only nil)
2331 (when (gnus-buffer-live-p gnus-original-article-buffer)
2332 (with-current-buffer gnus-original-article-buffer
2333 (let* ((ct (gnus-fetch-field "content-type"))
2336 (mail-header-parse-content-type ct)))))
2337 (setq charset (and ctl
2338 (mail-content-type-get ctl 'charset)))
2339 (when (stringp charset)
2340 (setq charset (intern (downcase charset)))))))
2342 (setq charset (mm-read-coding-system "Charset: " charset)))
2344 (setq charset gnus-newsgroup-charset))
2346 (save-window-excursion
2348 (narrow-to-region (point) (point-max))
2349 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2350 (entry (assq func mm-text-html-washer-alist)))
2352 (setq func (cdr entry)))
2357 (apply (car func) (cdr func))))))))))
2359 (defun gnus-article-wash-html-with-w3 ()
2360 "Wash the current buffer with w3."
2362 (let ((w3-strict-width (window-width))
2363 (url-standalone-mode t)
2364 (url-gateway-unplugged t)
2365 (w3-honor-stylesheets nil))
2367 (w3-region (point-min) (point-max))
2370 (defun gnus-article-wash-html-with-w3m ()
2371 "Wash the current buffer with emacs-w3m."
2374 (narrow-to-region (point) (point-max))
2375 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2378 w3m-force-redisplay)
2379 (w3m-region (point-min) (point-max)))
2380 (when mm-inline-text-html-with-w3m-keymap
2381 (add-text-properties
2382 (point-min) (point-max)
2383 (nconc (mm-w3m-local-map-property)
2384 '(mm-inline-text-html-with-w3m t))))))
2386 (defun article-hide-list-identifiers ()
2387 "Remove list identifies from the Subject header.
2388 The `gnus-list-identifiers' variable specifies what to do."
2390 (let ((inhibit-point-motion-hooks t)
2391 (regexp (if (consp gnus-list-identifiers)
2392 (mapconcat 'identity gnus-list-identifiers " *\\|")
2393 gnus-list-identifiers))
2398 (article-narrow-to-head)
2399 (goto-char (point-min))
2400 (while (re-search-forward
2401 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2403 (delete-region (match-beginning 2) (match-end 0))
2404 (beginning-of-line))
2405 (when (re-search-forward
2406 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2407 (delete-region (match-beginning 1) (match-end 1))))))))
2409 (defun article-hide-pem (&optional arg)
2410 "Toggle hiding of any PEM headers and signatures in the current article.
2411 If given a negative prefix, always show; if given a positive prefix,
2413 (interactive (gnus-article-hidden-arg))
2414 (unless (gnus-article-check-hidden-text 'pem arg)
2416 (let (buffer-read-only end)
2417 (goto-char (point-min))
2418 ;; Hide the horrendously ugly "header".
2419 (when (and (search-forward
2420 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2422 (setq end (1+ (match-beginning 0))))
2423 (gnus-add-wash-type 'pem)
2424 (gnus-article-hide-text-type
2426 (if (search-forward "\n\n" nil t)
2430 ;; Hide the trailer as well
2431 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2433 (gnus-article-hide-text-type
2434 (match-beginning 0) (match-end 0) 'pem)))))))
2436 (defun article-strip-banner ()
2437 "Strip the banners specified by the `banner' group parameter and by
2438 `gnus-article-address-banner-alist'."
2442 (let ((inhibit-point-motion-hooks t))
2443 (when (gnus-parameter-banner gnus-newsgroup-name)
2444 (article-really-strip-banner
2445 (gnus-parameter-banner gnus-newsgroup-name)))
2446 (when gnus-article-address-banner-alist
2447 (article-really-strip-banner
2448 (let ((from (save-restriction
2450 (article-narrow-to-head)
2451 (mail-fetch-field "from"))))
2454 (caar (mail-header-parse-addresses from))))
2456 (dolist (pair gnus-article-address-banner-alist)
2457 (when (string-match (car pair) from)
2458 (throw 'found (cdr pair)))))))))))))
2460 (defun article-really-strip-banner (banner)
2461 "Strip the banner specified by the argument."
2464 (let ((inhibit-point-motion-hooks t)
2465 (gnus-signature-limit nil)
2469 ((eq banner 'signature)
2470 (when (gnus-article-narrow-to-signature)
2473 (delete-region (point) (point-max))))
2475 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2476 (while (re-search-forward banner nil t)
2477 (delete-region (match-beginning 0) (match-end 0)))))
2479 (while (re-search-forward banner nil t)
2480 (delete-region (match-beginning 0) (match-end 0)))))))))
2482 (defun article-babel ()
2483 "Translate article using an online translation service."
2487 (set-buffer gnus-article-buffer)
2488 (when (article-goto-body)
2489 (let* ((buffer-read-only nil)
2492 (orig (buffer-substring start end))
2493 (trans (babel-as-string orig)))
2495 (narrow-to-region start end)
2496 (delete-region start end)
2499 (defun article-hide-signature (&optional arg)
2500 "Hide the signature in the current article.
2501 If given a negative prefix, always show; if given a positive prefix,
2503 (interactive (gnus-article-hidden-arg))
2504 (unless (gnus-article-check-hidden-text 'signature arg)
2507 (let ((buffer-read-only nil))
2508 (when (gnus-article-narrow-to-signature)
2509 (gnus-article-hide-text-type
2510 (point-min) (point-max) 'signature))))))
2511 (gnus-set-mode-line 'article))
2513 (defun article-strip-headers-in-body ()
2514 "Strip offensive headers from bodies."
2518 (let ((case-fold-search t))
2519 (when (looking-at "x-no-archive:")
2520 (gnus-delete-line)))))
2522 (defun article-strip-leading-blank-lines ()
2523 "Remove all blank lines from the beginning of the article."
2526 (let ((inhibit-point-motion-hooks t)
2528 (when (article-goto-body)
2529 (while (and (not (eobp))
2530 (looking-at "[ \t]*$"))
2531 (gnus-delete-line))))))
2533 (defun article-narrow-to-head ()
2534 "Narrow the buffer to the head of the message.
2535 Point is left at the beginning of the narrowed-to region."
2537 (goto-char (point-min))
2538 (if (search-forward "\n\n" nil 1)
2541 (goto-char (point-min)))
2543 (defun article-goto-body ()
2544 "Place point at the start of the body."
2545 (goto-char (point-min))
2547 ;; This variable is only bound when dealing with separate
2549 (article-goto-body-goes-to-point-min-p
2551 ((search-forward "\n\n" nil t)
2554 (goto-char (point-max))
2557 (defun article-strip-multiple-blank-lines ()
2558 "Replace consecutive blank lines with one empty line."
2561 (let ((inhibit-point-motion-hooks t)
2563 ;; First make all blank lines empty.
2565 (while (re-search-forward "^[ \t]+$" nil t)
2566 (unless (gnus-annotation-in-region-p
2567 (match-beginning 0) (match-end 0))
2568 (replace-match "" nil t)))
2569 ;; Then replace multiple empty lines with a single empty line.
2571 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2572 (unless (gnus-annotation-in-region-p
2573 (match-beginning 0) (match-end 0))
2574 (delete-region (match-beginning 1) (match-end 1)))))))
2576 (defun article-strip-leading-space ()
2577 "Remove all white space from the beginning of the lines in the article."
2580 (let ((inhibit-point-motion-hooks t)
2583 (while (re-search-forward "^[ \t]+" nil t)
2584 (replace-match "" t t)))))
2586 (defun article-strip-trailing-space ()
2587 "Remove all white space from the end of the lines in the article."
2590 (let ((inhibit-point-motion-hooks t)
2593 (while (re-search-forward "[ \t]+$" nil t)
2594 (replace-match "" t t)))))
2596 (defun article-strip-blank-lines ()
2597 "Strip leading, trailing and multiple blank lines."
2599 (article-strip-leading-blank-lines)
2600 (article-remove-trailing-blank-lines)
2601 (article-strip-multiple-blank-lines))
2603 (defun article-strip-all-blank-lines ()
2604 "Strip all blank lines."
2607 (let ((inhibit-point-motion-hooks t)
2610 (while (re-search-forward "^[ \t]*\n" nil t)
2611 (replace-match "" t t)))))
2613 (defun gnus-article-narrow-to-signature ()
2614 "Narrow to the signature; return t if a signature is found, else nil."
2615 (let ((inhibit-point-motion-hooks t))
2616 (when (gnus-article-search-signature)
2618 ;; Check whether we have some limits to what we consider
2619 ;; to be a signature.
2620 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2621 (list gnus-signature-limit)))
2623 (while (setq limit (pop limits))
2624 (if (or (and (integerp limit)
2625 (< (- (point-max) (point)) limit))
2627 (< (count-lines (point) (point-max)) limit))
2628 (and (functionp limit)
2630 (and (stringp limit)
2631 (not (re-search-forward limit nil t))))
2632 () ; This limit did not succeed.
2636 (narrow-to-region (point) (point-max))
2639 (defun gnus-article-search-signature ()
2640 "Search the current buffer for the signature separator.
2641 Put point at the beginning of the signature separator."
2642 (let ((cur (point)))
2643 (goto-char (point-max))
2644 (if (if (stringp gnus-signature-separator)
2645 (re-search-backward gnus-signature-separator nil t)
2646 (let ((seps gnus-signature-separator))
2648 (not (re-search-backward (car seps) nil t)))
2655 (defun gnus-article-hidden-arg ()
2656 "Return the current prefix arg as a number, or 0 if no prefix."
2657 (list (if current-prefix-arg
2658 (prefix-numeric-value current-prefix-arg)
2661 (defun gnus-article-check-hidden-text (type arg)
2662 "Return nil if hiding is necessary.
2663 Arg can be nil or a number. nil and positive means hide, negative
2664 means show, 0 means toggle."
2667 (let ((hide (gnus-article-hidden-text-p type)))
2673 (gnus-article-show-hidden-text type)
2676 (if (eq hide 'hidden)
2678 (gnus-article-show-hidden-text type)
2682 (defun gnus-article-hidden-text-p (type)
2683 "Say whether the current buffer contains hidden text of type TYPE."
2684 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2686 (not (get-text-property pos 'invisible))
2687 (not (get-text-property pos 'dummy-invisible)))
2689 (text-property-any (1+ pos) (point-max) 'article-type type)))
2694 (defun gnus-article-show-hidden-text (type &optional dummy)
2695 "Show all hidden text of type TYPE.
2696 Originally it is hide instead of DUMMY."
2697 (let ((buffer-read-only nil)
2698 (inhibit-point-motion-hooks t))
2699 (gnus-remove-text-properties-when
2701 (point-min) (point-max)
2702 (cons 'article-type (cons type
2703 gnus-hidden-properties)))
2704 (gnus-delete-wash-type type)))
2706 (defconst article-time-units
2707 `((year . ,(* 365.25 24 60 60))
2708 (week . ,(* 7 24 60 60))
2709 (day . ,(* 24 60 60))
2713 "Mapping from time units to seconds.")
2715 (defun gnus-article-forward-header ()
2716 "Move point to the start of the next header.
2717 If the current header is a continuation header, this can be several
2722 (if (looking-at "[ \t]+[^ \t]")
2726 (defun article-date-ut (&optional type highlight header)
2727 "Convert DATE date to universal time in the current article.
2728 If TYPE is `local', convert to local time; if it is `lapsed', output
2729 how much time has lapsed since DATE. For `lapsed', the value of
2730 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2731 should replace the \"Date:\" one, or should be added below it."
2732 (interactive (list 'ut t))
2733 (let* ((header (or header
2734 (message-fetch-field "date")
2736 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2739 ((not gnus-article-date-lapsed-new-header)
2745 (date (if (vectorp header) (mail-header-date header)
2747 (inhibit-point-motion-hooks t)
2752 (article-narrow-to-head)
2753 (when (re-search-forward tdate-regexp nil t)
2754 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2755 date (or (get-text-property (gnus-point-at-bol)
2758 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2760 (when (and date (not (string= date "")))
2761 (goto-char (point-min))
2762 (let ((buffer-read-only nil))
2763 ;; Delete any old Date headers.
2764 (while (re-search-forward date-regexp nil t)
2766 (delete-region (progn (beginning-of-line) (point))
2767 (progn (gnus-article-forward-header)
2769 (delete-region (progn (beginning-of-line) (point))
2770 (progn (gnus-article-forward-header)
2773 (setq pos (point))))
2774 (when (and (not pos)
2775 (re-search-forward tdate-regexp nil t))
2779 (insert (article-make-date-line date (or type 'ut)))
2785 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2786 (put-text-property (match-beginning 1) (1+ (match-end 1))
2787 'original-date date)
2788 (put-text-property (match-beginning 1) (1+ (match-end 1))
2790 (put-text-property (match-beginning 2) (match-end 2)
2793 (defun article-make-date-line (date type)
2794 "Return a DATE line of TYPE."
2795 (unless (memq type '(local ut original user iso8601 lapsed english))
2796 (error "Unknown conversion type: %s" type))
2798 (let ((time (date-to-time date)))
2800 ;; Convert to the local timezone.
2802 (let ((tz (car (current-time-zone time))))
2803 (format "Date: %s %s%02d%02d" (current-time-string time)
2804 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2805 (/ (% (abs tz) 3600) 60))))
2806 ;; Convert to Universal Time.
2809 (current-time-string
2810 (let* ((e (parse-time-string date))
2811 (tm (apply 'encode-time e))
2813 (ls (- (cadr tm) (car (current-time-zone time)))))
2814 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2815 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2818 ;; Get the original date from the article.
2819 ((eq type 'original)
2820 (concat "Date: " (if (string-match "\n+$" date)
2821 (substring date 0 (match-beginning 0))
2823 ;; Let the user define the format.
2825 (let ((format (or (condition-case nil
2826 (with-current-buffer gnus-summary-buffer
2827 gnus-article-time-format)
2829 gnus-article-time-format)))
2830 (if (functionp format)
2831 (funcall format time)
2832 (concat "Date: " (format-time-string format time)))))
2835 (let ((tz (car (current-time-zone time))))
2838 (format-time-string "%Y%m%dT%H%M%S" time)
2839 (format "%s%02d%02d"
2840 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2841 (/ (% (abs tz) 3600) 60)))))
2842 ;; Do an X-Sent lapsed format.
2844 ;; If the date is seriously mangled, the timezone functions are
2845 ;; liable to bug out, so we ignore all errors.
2846 (let* ((now (current-time))
2847 (real-time (subtract-time now time))
2848 (real-sec (and real-time
2849 (+ (* (float (car real-time)) 65536)
2851 (sec (and real-time (abs real-sec)))
2861 ;; This is a bit convoluted, but basically we go
2862 ;; through the time units for years, weeks, etc,
2863 ;; and divide things to see whether that results
2864 ;; in positive answers.
2867 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2868 ;; The (remaining) seconds are too few to
2869 ;; be divided into this time unit.
2871 ;; It's big enough, so we output it.
2872 (setq sec (- sec (* num (cdr unit))))
2874 (concat (if prev ", " "") (int-to-string
2876 " " (symbol-name (car unit))
2877 (if (> num 1) "s" ""))
2879 article-time-units "")
2880 ;; If dates are odd, then it might appear like the
2881 ;; article was sent in the future.
2884 " in the future"))))))
2885 ;; Display the date in proper English
2887 (let ((dtime (decode-time time)))
2890 (number-to-string (nth 3 dtime))
2891 (let ((digit (% (nth 3 dtime) 10)))
2893 ((memq (nth 3 dtime) '(11 12 13)) "th")
2899 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2901 (number-to-string (nth 5 dtime))
2903 (format "%02d" (nth 2 dtime))
2905 (format "%02d" (nth 1 dtime)))))))
2907 (format "Date: %s (from Gnus)" date))))
2909 (defun article-date-local (&optional highlight)
2910 "Convert the current article date to the local timezone."
2911 (interactive (list t))
2912 (article-date-ut 'local highlight))
2914 (defun article-date-english (&optional highlight)
2915 "Convert the current article date to something that is proper English."
2916 (interactive (list t))
2917 (article-date-ut 'english highlight))
2919 (defun article-date-original (&optional highlight)
2920 "Convert the current article date to what it was originally.
2921 This is only useful if you have used some other date conversion
2922 function and want to see what the date was before converting."
2923 (interactive (list t))
2924 (article-date-ut 'original highlight))
2926 (defun article-date-lapsed (&optional highlight)
2927 "Convert the current article date to time lapsed since it was sent."
2928 (interactive (list t))
2929 (article-date-ut 'lapsed highlight))
2931 (defun article-update-date-lapsed ()
2932 "Function to be run from a timer to update the lapsed time line."
2933 (let (deactivate-mark)
2938 (set-buffer (window-buffer w))
2939 (when (eq major-mode 'gnus-article-mode)
2940 (let ((mark (point-marker)))
2941 (goto-char (point-min))
2942 (when (re-search-forward "^X-Sent:" nil t)
2943 (article-date-lapsed t))
2944 (goto-char (marker-position mark))
2945 (move-marker mark nil))))
2948 (defun gnus-start-date-timer (&optional n)
2949 "Start a timer to update the X-Sent header in the article buffers.
2950 The numerical prefix says how frequently (in seconds) the function
2955 (gnus-stop-date-timer)
2956 (setq article-lapsed-timer
2957 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2959 (defun gnus-stop-date-timer ()
2960 "Stop the X-Sent timer."
2962 (when article-lapsed-timer
2963 (nnheader-cancel-timer article-lapsed-timer)
2964 (setq article-lapsed-timer nil)))
2966 (defun article-date-user (&optional highlight)
2967 "Convert the current article date to the user-defined format.
2968 This format is defined by the `gnus-article-time-format' variable."
2969 (interactive (list t))
2970 (article-date-ut 'user highlight))
2972 (defun article-date-iso8601 (&optional highlight)
2973 "Convert the current article date to ISO8601."
2974 (interactive (list t))
2975 (article-date-ut 'iso8601 highlight))
2977 ;; (defun article-show-all ()
2978 ;; "Show all hidden text in the article buffer."
2981 ;; (let ((buffer-read-only nil))
2982 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2984 (defun article-remove-leading-whitespace ()
2985 "Remove excessive whitespace from all headers."
2989 (let ((buffer-read-only nil))
2990 (article-narrow-to-head)
2991 (goto-char (point-min))
2992 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2993 (delete-region (match-beginning 1) (match-end 1)))))))
2995 (defun article-emphasize (&optional arg)
2996 "Emphasize text according to `gnus-emphasis-alist'."
2997 (interactive (gnus-article-hidden-arg))
2998 (unless (gnus-article-check-hidden-text 'emphasis arg)
3002 (with-current-buffer gnus-summary-buffer
3003 gnus-article-emphasis-alist)
3005 gnus-emphasis-alist))
3006 (buffer-read-only nil)
3007 (props (append '(article-type emphasis)
3008 gnus-hidden-properties))
3009 regexp elem beg invisible visible face)
3012 (while (setq elem (pop alist))
3014 (setq regexp (car elem)
3015 invisible (nth 1 elem)
3016 visible (nth 2 elem)
3018 (while (re-search-forward regexp nil t)
3019 (when (and (match-beginning visible) (match-beginning invisible))
3020 (gnus-article-hide-text
3021 (match-beginning invisible) (match-end invisible) props)
3022 (gnus-article-unhide-text-type
3023 (match-beginning visible) (match-end visible) 'emphasis)
3024 (gnus-put-overlay-excluding-newlines
3025 (match-beginning visible) (match-end visible) 'face face)
3026 (gnus-add-wash-type 'emphasis)
3027 (goto-char (match-end invisible)))))))))
3029 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3030 "Setup newsgroup emphasis alist."
3031 (unless gnus-article-emphasis-alist
3032 (let ((name (and gnus-newsgroup-name
3033 (gnus-group-real-name gnus-newsgroup-name))))
3034 (make-local-variable 'gnus-article-emphasis-alist)
3035 (setq gnus-article-emphasis-alist
3037 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3038 (while (setq elem (pop alist))
3039 (when (and name (string-match (car elem) name))
3041 highlight (copy-sequence (cdr elem)))))
3043 (copy-sequence highlight-words)
3044 (if gnus-newsgroup-name
3045 (copy-sequence (gnus-group-find-parameter
3046 gnus-newsgroup-name 'highlight-words t)))
3047 gnus-emphasis-alist)))))
3050 (defvar gnus-summary-article-menu)
3051 (defvar gnus-summary-post-menu))
3053 ;;; Saving functions.
3055 (defun gnus-article-save (save-buffer file &optional num)
3056 "Save the currently selected article."
3057 (unless gnus-save-all-headers
3058 ;; Remove headers according to `gnus-saved-headers'.
3059 (let ((gnus-visible-headers
3060 (or gnus-saved-headers gnus-visible-headers))
3061 (gnus-article-buffer save-buffer))
3063 (set-buffer save-buffer)
3064 (article-hide-headers 1 t))))
3065 (save-window-excursion
3066 (if (not gnus-default-article-saver)
3067 (error "No default saver is defined")
3068 ;; !!! Magic! The saving functions all save
3069 ;; `gnus-save-article-buffer' (or so they think), but we
3070 ;; bind that variable to our save-buffer.
3071 (set-buffer gnus-article-buffer)
3072 (let* ((gnus-save-article-buffer save-buffer)
3075 ((not gnus-prompt-before-saving) 'default)
3076 ((eq gnus-prompt-before-saving 'always) nil)
3078 (gnus-number-of-articles-to-be-saved
3079 (when (eq gnus-prompt-before-saving t)
3081 (set-buffer gnus-article-current-summary)
3082 (funcall gnus-default-article-saver filename)))))
3084 (defun gnus-read-save-file-name (prompt &optional filename
3085 function group headers variable)
3087 (funcall function group headers (symbol-value variable)))
3092 ((eq filename 'default)
3098 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3101 (if (and gnus-number-of-articles-to-be-saved
3102 (> gnus-number-of-articles-to-be-saved 1))
3103 (format "these %d articles"
3104 gnus-number-of-articles-to-be-saved)
3107 ;; Let the split methods have their say.
3109 ;; No split name was found.
3112 (concat prompt " (default "
3113 (file-name-nondirectory default-name) ") ")
3114 (file-name-directory default-name)
3116 ;; A single group name is returned.
3117 ((stringp split-name)
3119 (funcall function split-name headers
3120 (symbol-value variable)))
3122 (concat prompt " (default "
3123 (file-name-nondirectory default-name) ") ")
3124 (file-name-directory default-name)
3126 ;; A single split name was found
3127 ((= 1 (length split-name))
3128 (let* ((name (expand-file-name
3130 gnus-article-save-directory))
3131 (dir (cond ((file-directory-p name)
3132 (file-name-as-directory name))
3133 ((file-exists-p name) name)
3134 (t gnus-article-save-directory))))
3136 (concat prompt " (default " name ") ")
3138 ;; A list of splits was found.
3140 (setq split-name (nreverse split-name))
3142 (let ((file-name-history
3143 (nconc split-name file-name-history)))
3147 (concat prompt " (`M-p' for defaults) ")
3148 gnus-article-save-directory
3150 gnus-article-save-directory)))
3151 (car (push result file-name-history)))))))
3152 ;; Create the directory.
3153 (gnus-make-directory (file-name-directory file))
3154 ;; If we have read a directory, we append the default file name.
3155 (when (file-directory-p file)
3156 (setq file (expand-file-name (file-name-nondirectory
3158 (file-name-as-directory file))))
3159 ;; Possibly translate some characters.
3160 (nnheader-translate-file-chars file))))))
3161 (gnus-make-directory (file-name-directory result))
3162 (set variable result)))
3164 (defun gnus-article-archive-name (group)
3165 "Return the first instance of an \"Archive-name\" in the current buffer."
3166 (let ((case-fold-search t))
3167 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3168 (nnheader-concat gnus-article-save-directory
3169 (match-string 1)))))
3171 (defun gnus-article-nndoc-name (group)
3172 "If GROUP is an nndoc group, return the name of the parent group."
3173 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3174 (gnus-group-get-parameter group 'save-article-group)))
3176 (defun gnus-summary-save-in-rmail (&optional filename)
3177 "Append this article to Rmail file.
3178 Optional argument FILENAME specifies file name.
3179 Directory to save to is default to `gnus-article-save-directory'."
3180 (setq filename (gnus-read-save-file-name
3181 "Save %s in rmail file:" filename
3182 gnus-rmail-save-name gnus-newsgroup-name
3183 gnus-current-headers 'gnus-newsgroup-last-rmail))
3184 (gnus-eval-in-buffer-window gnus-save-article-buffer
3188 (gnus-output-to-rmail filename))))
3191 (defun gnus-summary-save-in-mail (&optional filename)
3192 "Append this article to Unix mail file.
3193 Optional argument FILENAME specifies file name.
3194 Directory to save to is default to `gnus-article-save-directory'."
3195 (setq filename (gnus-read-save-file-name
3196 "Save %s in Unix mail file:" filename
3197 gnus-mail-save-name gnus-newsgroup-name
3198 gnus-current-headers 'gnus-newsgroup-last-mail))
3199 (gnus-eval-in-buffer-window gnus-save-article-buffer
3203 (if (and (file-readable-p filename)
3204 (file-regular-p filename)
3205 (mail-file-babyl-p filename))
3206 (rmail-output-to-rmail-file filename t)
3207 (gnus-output-to-mail filename)))))
3210 (defun gnus-summary-save-in-file (&optional filename overwrite)
3211 "Append this article to file.
3212 Optional argument FILENAME specifies file name.
3213 Directory to save to is default to `gnus-article-save-directory'."
3214 (setq filename (gnus-read-save-file-name
3215 "Save %s in file:" filename
3216 gnus-file-save-name gnus-newsgroup-name
3217 gnus-current-headers 'gnus-newsgroup-last-file))
3218 (gnus-eval-in-buffer-window gnus-save-article-buffer
3222 (when (and overwrite
3223 (file-exists-p filename))
3224 (delete-file filename))
3225 (gnus-output-to-file filename))))
3228 (defun gnus-summary-write-to-file (&optional filename)
3229 "Write this article to a file, overwriting it if the file exists.
3230 Optional argument FILENAME specifies file name.
3231 The directory to save in defaults to `gnus-article-save-directory'."
3232 (gnus-summary-save-in-file nil t))
3234 (defun gnus-summary-save-body-in-file (&optional filename)
3235 "Append this article body to a file.
3236 Optional argument FILENAME specifies file name.
3237 The directory to save in defaults to `gnus-article-save-directory'."
3238 (setq filename (gnus-read-save-file-name
3239 "Save %s body in file:" filename
3240 gnus-file-save-name gnus-newsgroup-name
3241 gnus-current-headers 'gnus-newsgroup-last-file))
3242 (gnus-eval-in-buffer-window gnus-save-article-buffer
3246 (when (article-goto-body)
3247 (narrow-to-region (point) (point-max)))
3248 (gnus-output-to-file filename))))
3251 (defun gnus-summary-save-in-pipe (&optional command)
3252 "Pipe this article to subprocess."
3254 (cond ((and (eq command 'default)
3255 gnus-last-shell-command)
3256 gnus-last-shell-command)
3261 "Shell command on %s: "
3262 (if (and gnus-number-of-articles-to-be-saved
3263 (> gnus-number-of-articles-to-be-saved 1))
3264 (format "these %d articles"
3265 gnus-number-of-articles-to-be-saved)
3267 gnus-last-shell-command))))
3268 (when (string-equal command "")
3269 (if gnus-last-shell-command
3270 (setq command gnus-last-shell-command)
3271 (error "A command is required")))
3272 (gnus-eval-in-buffer-window gnus-article-buffer
3275 (shell-command-on-region (point-min) (point-max) command nil)))
3276 (setq gnus-last-shell-command command))
3278 (defmacro gnus-read-string (prompt &optional initial-contents history
3280 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3281 (if (and (featurep 'xemacs)
3282 (< emacs-minor-version 2))
3283 `(read-string ,prompt ,initial-contents ,history)
3284 `(read-string ,prompt ,initial-contents ,history ,default-value)))
3286 (defun gnus-summary-pipe-to-muttprint (&optional command)
3287 "Pipe this article to muttprint."
3288 (setq command (gnus-read-string
3289 "Print using command: " gnus-summary-muttprint-program
3290 nil gnus-summary-muttprint-program))
3291 (gnus-summary-save-in-pipe command))
3293 ;;; Article file names when saving.
3295 (defun gnus-capitalize-newsgroup (newsgroup)
3296 "Capitalize NEWSGROUP name."
3297 (when (not (zerop (length newsgroup)))
3298 (concat (char-to-string (upcase (aref newsgroup 0)))
3299 (substring newsgroup 1))))
3301 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3302 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3303 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3304 Otherwise, it is like ~/News/news/group/num."
3307 (concat (if (gnus-use-long-file-name 'not-save)
3308 (gnus-capitalize-newsgroup newsgroup)
3309 (gnus-newsgroup-directory-form newsgroup))
3310 "/" (int-to-string (mail-header-number headers)))
3311 gnus-article-save-directory)))
3313 (string-equal (file-name-directory default)
3314 (file-name-directory last-file))
3315 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3317 (or last-file default))))
3319 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3320 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3321 If variable `gnus-use-long-file-name' is non-nil, it is
3322 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3325 (concat (if (gnus-use-long-file-name 'not-save)
3327 (gnus-newsgroup-directory-form newsgroup))
3328 "/" (int-to-string (mail-header-number headers)))
3329 gnus-article-save-directory)))
3331 (string-equal (file-name-directory default)
3332 (file-name-directory last-file))
3333 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3335 (or last-file default))))
3337 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3338 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3339 If variable `gnus-use-long-file-name' is non-nil, it is
3340 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3343 (if (gnus-use-long-file-name 'not-save)
3346 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3348 gnus-article-save-directory)))
3350 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3351 "Generate file name from sender."
3352 (let ((from (mail-header-from headers)))
3354 (if (and from (string-match "\\([^ <]+\\)@" from))
3355 (match-string 1 from)
3357 gnus-article-save-directory)))
3359 (defun article-verify-x-pgp-sig ()
3362 (if (gnus-buffer-live-p gnus-original-article-buffer)
3363 (let ((sig (with-current-buffer gnus-original-article-buffer
3364 (gnus-fetch-field "X-PGP-Sig")))
3368 (mml2015-clear-verify-function))
3370 (insert-buffer-substring gnus-original-article-buffer)
3371 (setq items (split-string sig))
3372 (message-narrow-to-head)
3373 (let ((inhibit-point-motion-hooks t)
3374 (case-fold-search t))
3375 ;; Don't verify multiple headers.
3376 (setq headers (mapconcat (lambda (header)
3378 (mail-fetch-field header)
3380 (split-string (nth 1 items) ",") "")))
3381 (delete-region (point-min) (point-max))
3382 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3383 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3388 (if (looking-at "^-")
3391 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3392 (insert "Version: " (car items) "\n\n")
3393 (insert (mapconcat 'identity (cddr items) "\n"))
3394 (insert "\n-----END PGP SIGNATURE-----\n")
3395 (let ((mm-security-handle (list (format "multipart/signed"))))
3396 (mml2015-clean-buffer)
3397 (let ((coding-system-for-write (or gnus-newsgroup-charset
3399 (funcall (mml2015-clear-verify-function)))
3401 (or (mm-handle-multipart-ctl-parameter
3402 mm-security-handle 'gnus-details)
3403 (mm-handle-multipart-ctl-parameter
3404 mm-security-handle 'gnus-info)))))
3406 (let (buffer-read-only bface eface)
3408 (message-narrow-to-head)
3409 (goto-char (point-max))
3411 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3412 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3413 (message-remove-header "X-Gnus-PGP-Verify")
3414 (if (re-search-forward "^X-PGP-Sig:" nil t)
3416 (goto-char (point-max)))
3417 (narrow-to-region (point) (point))
3418 (insert "X-Gnus-PGP-Verify: " info "\n")
3419 (goto-char (point-min))
3422 (if (not (looking-at "^[ \t]"))
3426 (goto-char (point-min))
3427 (when (looking-at "\\([^:]+\\): *")
3428 (put-text-property (match-beginning 1) (1+ (match-end 1))
3430 (put-text-property (match-end 0) (point-max)
3431 'face eface)))))))))
3433 (defun article-verify-cancel-lock ()
3434 "Verify Cancel-Lock header."
3436 (if (gnus-buffer-live-p gnus-original-article-buffer)
3437 (canlock-verify gnus-original-article-buffer)))
3444 (setq afunc (car func)
3447 gfunc (intern (format "gnus-%s" func))))
3449 (when (fboundp afunc)
3450 `(lambda (&optional interactive &rest args)
3451 ,(documentation afunc t)
3452 (interactive (list t))
3454 (set-buffer gnus-article-buffer)
3456 (call-interactively ',afunc)
3457 (apply ',afunc args))))))))
3458 '(article-hide-headers
3459 article-verify-x-pgp-sig
3460 article-verify-cancel-lock
3461 article-hide-boring-headers
3462 article-treat-overstrike
3463 article-fill-long-lines
3464 article-capitalize-sentences
3466 article-remove-leading-whitespace
3467 article-display-x-face
3468 article-display-face
3469 article-de-quoted-unreadable
3470 article-de-base64-unreadable
3473 article-unsplit-urls
3474 article-hide-list-identifiers
3475 article-strip-banner
3478 article-hide-signature
3479 article-strip-headers-in-body
3480 article-remove-trailing-blank-lines
3481 article-strip-leading-blank-lines
3482 article-strip-multiple-blank-lines
3483 article-strip-leading-space
3484 article-strip-trailing-space
3485 article-strip-blank-lines
3486 article-strip-all-blank-lines
3488 article-date-english
3489 article-date-iso8601
3490 article-date-original
3492 article-decode-mime-words
3493 article-decode-charset
3494 article-decode-encoded-words
3498 article-treat-dumbquotes
3499 article-normalize-headers
3500 ;; (article-show-all . gnus-article-show-all-headers)
3504 ;;; Gnus article mode
3507 (put 'gnus-article-mode 'mode-class 'special)
3509 (set-keymap-parent gnus-article-mode-map widget-keymap)
3511 (gnus-define-keys gnus-article-mode-map
3512 " " gnus-article-goto-next-page
3513 "\177" gnus-article-goto-prev-page
3514 [delete] gnus-article-goto-prev-page
3515 [backspace] gnus-article-goto-prev-page
3516 "\C-c^" gnus-article-refer-article
3517 "h" gnus-article-show-summary
3518 "s" gnus-article-show-summary
3519 "\C-c\C-m" gnus-article-mail
3520 "?" gnus-article-describe-briefly
3521 "e" gnus-summary-edit-article
3522 "<" beginning-of-buffer
3524 "\C-c\C-i" gnus-info-find-node
3526 "R" gnus-article-reply-with-original
3527 "F" gnus-article-followup-with-original
3528 "\C-hk" gnus-article-describe-key
3529 "\C-hc" gnus-article-describe-key-briefly
3531 "\C-d" gnus-article-read-summary-keys
3532 "\M-*" gnus-article-read-summary-keys
3533 "\M-#" gnus-article-read-summary-keys
3534 "\M-^" gnus-article-read-summary-keys
3535 "\M-g" gnus-article-read-summary-keys)
3537 (substitute-key-definition
3538 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3540 (defun gnus-article-make-menu-bar ()
3541 (unless (boundp 'gnus-article-commands-menu)
3542 (gnus-summary-make-menu-bar))
3543 (gnus-turn-off-edit-menu 'article)
3544 (unless (boundp 'gnus-article-article-menu)
3546 gnus-article-article-menu gnus-article-mode-map ""
3548 ["Scroll forwards" gnus-article-goto-next-page t]
3549 ["Scroll backwards" gnus-article-goto-prev-page t]
3550 ["Show summary" gnus-article-show-summary t]
3551 ["Fetch Message-ID at point" gnus-article-refer-article t]
3552 ["Mail to address at point" gnus-article-mail t]
3553 ["Send a bug report" gnus-bug t]))
3556 gnus-article-treatment-menu gnus-article-mode-map ""
3557 ;; Fixme: this should use :active (and maybe :visible).
3559 ["Hide headers" gnus-article-hide-headers t]
3560 ["Hide signature" gnus-article-hide-signature t]
3561 ["Hide citation" gnus-article-hide-citation t]
3562 ["Treat overstrike" gnus-article-treat-overstrike t]
3563 ["Remove carriage return" gnus-article-remove-cr t]
3564 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3565 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3566 ["Remove base64" gnus-article-de-base64-unreadable t]
3567 ["Treat html" gnus-article-wash-html t]
3568 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3569 ["Decode HZ" gnus-article-decode-HZ t]))
3571 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3573 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3575 (gnus-run-hooks 'gnus-article-menu-hook)))
3577 (defun gnus-article-mode ()
3578 "Major mode for displaying an article.
3580 All normal editing commands are switched off.
3582 The following commands are available in addition to all summary mode
3584 \\<gnus-article-mode-map>
3585 \\[gnus-article-next-page]\t Scroll the article one page forwards
3586 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3587 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3588 \\[gnus-article-show-summary]\t Display the summary buffer
3589 \\[gnus-article-mail]\t Send a reply to the address near point
3590 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3591 \\[gnus-info-find-node]\t Go to the Gnus info node"
3593 (gnus-simplify-mode-line)
3594 (setq mode-name "Article")
3595 (setq major-mode 'gnus-article-mode)
3596 (make-local-variable 'minor-mode-alist)
3597 (use-local-map gnus-article-mode-map)
3598 (when (gnus-visual-p 'article-menu 'menu)
3599 (gnus-article-make-menu-bar)
3600 (when gnus-summary-tool-bar-map
3601 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3602 (gnus-update-format-specifications nil 'article-mode)
3603 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3604 (make-local-variable 'gnus-page-broken)
3605 (make-local-variable 'gnus-button-marker-list)
3606 (make-local-variable 'gnus-article-current-summary)
3607 (make-local-variable 'gnus-article-mime-handles)
3608 (make-local-variable 'gnus-article-decoded-p)
3609 (make-local-variable 'gnus-article-mime-handle-alist)
3610 (make-local-variable 'gnus-article-wash-types)
3611 (make-local-variable 'gnus-article-image-alist)
3612 (make-local-variable 'gnus-article-charset)
3613 (make-local-variable 'gnus-article-ignored-charsets)
3614 (gnus-set-default-directory)
3615 (buffer-disable-undo)
3616 (setq buffer-read-only t)
3617 (set-syntax-table gnus-article-mode-syntax-table)
3618 (mm-enable-multibyte)
3619 (gnus-run-hooks 'gnus-article-mode-hook))
3621 (defun gnus-article-setup-buffer ()
3622 "Initialize the article buffer."
3623 (let* ((name (if gnus-single-article-buffer "*Article*"
3624 (concat "*Article " gnus-newsgroup-name "*")))
3626 (progn (string-match "\\*Article" name)
3627 (concat " *Original Article"
3628 (substring name (match-end 0))))))
3629 (setq gnus-article-buffer name)
3630 (setq gnus-original-article-buffer original)
3631 (setq gnus-article-mime-handle-alist nil)
3632 ;; This might be a variable local to the summary buffer.
3633 (unless gnus-single-article-buffer
3635 (set-buffer gnus-summary-buffer)
3636 (setq gnus-article-buffer name)
3637 (setq gnus-original-article-buffer original)
3638 (gnus-set-global-variables)))
3639 (gnus-article-setup-highlight-words)
3640 ;; Init original article buffer.
3642 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3643 (mm-enable-multibyte)
3644 (setq major-mode 'gnus-original-article-mode)
3645 (make-local-variable 'gnus-original-article))
3646 (if (get-buffer name)
3649 (when (and gnus-article-edit-mode
3652 (y-or-n-p "Article mode edit in progress; discard? ")))
3653 (error "Action aborted"))
3654 (set (make-local-variable 'gnus-article-edit-mode) nil)
3655 (when gnus-article-mime-handles
3656 (mm-destroy-parts gnus-article-mime-handles)
3657 (setq gnus-article-mime-handles nil))
3658 ;; Set it to nil in article-buffer!
3659 (setq gnus-article-mime-handle-alist nil)
3660 (buffer-disable-undo)
3661 (setq buffer-read-only t)
3662 ;; This list just keeps growing if we don't reset it.
3663 (setq gnus-button-marker-list nil)
3664 (unless (eq major-mode 'gnus-article-mode)
3665 (gnus-article-mode))
3668 (set-buffer (gnus-get-buffer-create name))
3670 (make-local-variable 'gnus-summary-buffer)
3671 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3672 (current-buffer)))))
3674 ;; Set article window start at LINE, where LINE is the number of lines
3675 ;; from the head of the article.
3676 (defun gnus-article-set-window-start (&optional line)
3678 (gnus-get-buffer-window gnus-article-buffer t)
3680 (set-buffer gnus-article-buffer)
3681 (goto-char (point-min))
3684 (gnus-message 6 "Moved to bookmark")
3685 (search-forward "\n\n" nil t)
3689 (defun gnus-article-prepare (article &optional all-headers header)
3690 "Prepare ARTICLE in article mode buffer.
3691 ARTICLE should either be an article number or a Message-ID.
3692 If ARTICLE is an id, HEADER should be the article headers.
3693 If ALL-HEADERS is non-nil, no headers are hidden."
3695 ;; Make sure we start in a summary buffer.
3696 (unless (eq major-mode 'gnus-summary-mode)
3697 (set-buffer gnus-summary-buffer))
3698 (setq gnus-summary-buffer (current-buffer))
3699 (let* ((gnus-article (if header (mail-header-number header) article))
3700 (summary-buffer (current-buffer))
3701 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3702 (group gnus-newsgroup-name)
3705 (gnus-article-setup-buffer)
3706 (set-buffer gnus-article-buffer)
3707 ;; Deactivate active regions.
3708 (when (and (boundp 'transient-mark-mode)
3709 transient-mark-mode)
3710 (setq mark-active nil))
3711 (if (not (setq result (let ((buffer-read-only nil))
3712 (gnus-request-article-this-buffer
3714 ;; There is no such article.
3716 (when (and (numberp article)
3717 (not (memq article gnus-newsgroup-sparse)))
3718 (setq gnus-article-current
3719 (cons gnus-newsgroup-name article))
3720 (set-buffer gnus-summary-buffer)
3721 (setq gnus-current-article article)
3722 (if (and (memq article gnus-newsgroup-undownloaded)
3723 (not (gnus-online (gnus-find-method-for-group
3724 gnus-newsgroup-name))))
3726 (gnus-summary-set-agent-mark article)
3727 (message "Message marked for downloading"))
3728 (gnus-summary-mark-article article gnus-canceled-mark)
3729 (unless (memq article gnus-newsgroup-sparse)
3730 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3731 (if (or (eq result 'pseudo)
3732 (eq result 'nneething))
3735 (set-buffer summary-buffer)
3736 (push article gnus-newsgroup-history)
3737 (setq gnus-last-article gnus-current-article
3738 gnus-current-article 0
3739 gnus-current-headers nil
3740 gnus-article-current nil)
3741 (if (eq result 'nneething)
3742 (gnus-configure-windows 'summary)
3743 (gnus-configure-windows 'article))
3744 (gnus-set-global-variables))
3745 (let ((gnus-article-mime-handle-alist-1
3746 gnus-article-mime-handle-alist))
3747 (gnus-set-mode-line 'article)))
3748 ;; The result from the `request' was an actual article -
3749 ;; or at least some text that is now displayed in the
3751 (when (and (numberp article)
3752 (not (eq article gnus-current-article)))
3753 ;; Seems like a new article has been selected.
3754 ;; `gnus-current-article' must be an article number.
3756 (set-buffer summary-buffer)
3757 (push article gnus-newsgroup-history)
3758 (setq gnus-last-article gnus-current-article
3759 gnus-current-article article
3760 gnus-current-headers
3761 (gnus-summary-article-header gnus-current-article)
3762 gnus-article-current
3763 (cons gnus-newsgroup-name gnus-current-article))
3764 (unless (vectorp gnus-current-headers)
3765 (setq gnus-current-headers nil))
3766 (gnus-summary-goto-subject gnus-current-article)
3767 (when (gnus-summary-show-thread)
3768 ;; If the summary buffer really was folded, the
3769 ;; previous goto may not actually have gone to
3770 ;; the right article, but the thread root instead.
3772 (gnus-summary-goto-subject gnus-current-article))
3773 (gnus-run-hooks 'gnus-mark-article-hook)
3774 (gnus-set-mode-line 'summary)
3775 (when (gnus-visual-p 'article-highlight 'highlight)
3776 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3777 ;; Set the global newsgroup variables here.
3778 (gnus-set-global-variables)
3779 (setq gnus-have-all-headers
3780 (or all-headers gnus-show-all-headers))))
3782 (gnus-configure-windows 'article))
3783 (when (or (numberp article)
3785 (gnus-article-prepare-display)
3787 (goto-char (point-min))
3788 (setq gnus-page-broken
3789 (when gnus-break-pages
3790 (gnus-narrow-to-page)
3792 (let ((gnus-article-mime-handle-alist-1
3793 gnus-article-mime-handle-alist))
3794 (gnus-set-mode-line 'article))
3798 (set-window-point (get-buffer-window (current-buffer)) (point))
3799 (gnus-configure-windows 'article)
3803 (defun gnus-article-prepare-display ()
3804 "Make the current buffer look like a nice article."
3805 ;; Hooks for getting information from the article.
3806 ;; This hook must be called before being narrowed.
3807 (let ((gnus-article-buffer (current-buffer))
3809 (unless (eq major-mode 'gnus-article-mode)
3810 (gnus-article-mode))
3811 (setq buffer-read-only nil
3812 gnus-article-wash-types nil
3813 gnus-article-image-alist nil)
3814 (gnus-run-hooks 'gnus-tmp-internal-hook)
3815 (when gnus-display-mime-function
3816 (funcall gnus-display-mime-function))
3817 (gnus-run-hooks 'gnus-article-prepare-hook)))
3820 ;;; Gnus MIME viewing functions
3823 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3824 "Format of the MIME buttons.
3826 Valid specifiers include:
3828 %T MIME type, along with additional info
3829 %n The `name' parameter
3830 %d The description, if any
3831 %l The length of the encoded part
3832 %p The part identifier number
3833 %e Dots if the part isn't displayed
3835 General format specifiers can also be used. See Info node
3836 `(gnus)Formatting Variables'.")
3838 (defvar gnus-mime-button-line-format-alist
3839 '((?t gnus-tmp-type ?s)
3840 (?T gnus-tmp-type-long ?s)
3841 (?n gnus-tmp-name ?s)
3842 (?d gnus-tmp-description ?s)
3844 (?l gnus-tmp-length ?d)
3845 (?e gnus-tmp-dots ?s)))
3847 (defvar gnus-mime-button-commands
3848 '((gnus-article-press-button "\r" "Toggle Display")
3849 (gnus-mime-view-part "v" "View Interactively...")
3850 (gnus-mime-view-part-as-type "t" "View As Type...")
3851 (gnus-mime-view-part-as-charset "C" "View As charset...")
3852 (gnus-mime-save-part "o" "Save...")
3853 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3854 (gnus-mime-delete-part "d" "Delete part")
3855 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3856 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3857 (gnus-mime-view-part-internally "E" "View Internally")
3858 (gnus-mime-view-part-externally "e" "View Externally")
3859 (gnus-mime-print-part "p" "Print")
3860 (gnus-mime-pipe-part "|" "Pipe To Command...")
3861 (gnus-mime-action-on-part "." "Take action on the part...")))
3863 (defun gnus-article-mime-part-status ()
3864 (if gnus-article-mime-handle-alist-1
3865 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3867 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3870 (defvar gnus-mime-button-map
3871 (let ((map (make-sparse-keymap)))
3872 (unless (>= (string-to-number emacs-version) 21)
3873 ;; XEmacs doesn't care.
3874 (set-keymap-parent map gnus-article-mode-map))
3875 (define-key map gnus-mouse-2 'gnus-article-push-button)
3876 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3877 (dolist (c gnus-mime-button-commands)
3878 (define-key map (cadr c) (car c)))
3882 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
3884 ,@(mapcar (lambda (c)
3885 (vector (caddr c) (car c) :enable t))
3886 gnus-mime-button-commands)))
3889 (define-compiler-macro popup-menu (&whole form
3890 menu &optional position prefix)
3891 (if (and (fboundp 'popup-menu)
3892 (not (memq 'popup-menu (assoc "lmenu" load-history))))
3894 ;; Gnus is probably running under Emacs 20.
3895 `(let* ((menu (cdr ,menu))
3896 (response (x-popup-menu
3898 (cons "" (mapcar (lambda (c)
3899 (cons (caddr c) (car c)))
3902 (call-interactively (nth 3 (assq response menu))))))))
3904 (defun gnus-mime-button-menu (event prefix)
3905 "Construct a context-sensitive menu of MIME commands."
3906 (interactive "e\nP")
3907 (save-window-excursion
3908 (let ((pos (event-start event)))
3909 (select-window (posn-window pos))
3910 (goto-char (posn-point pos))
3911 (gnus-article-check-buffer)
3912 (popup-menu gnus-mime-button-menu nil prefix))))
3914 (defun gnus-mime-view-all-parts (&optional handles)
3915 "View all the MIME parts."
3917 (save-current-buffer
3918 (set-buffer gnus-article-buffer)
3919 (let ((handles (or handles gnus-article-mime-handles))
3920 (mail-parse-charset gnus-newsgroup-charset)
3921 (mail-parse-ignored-charsets
3922 (with-current-buffer gnus-summary-buffer
3923 gnus-newsgroup-ignored-charsets)))
3925 (mm-remove-parts handles)
3926 (goto-char (point-min))
3927 (or (search-forward "\n\n") (goto-char (point-max)))
3928 (let (buffer-read-only)
3929 (delete-region (point) (point-max))
3930 (mm-display-parts handles))))))
3932 (defun gnus-mime-save-part-and-strip ()
3933 "Save the MIME part under point then replace it with an external body."
3935 (gnus-article-check-buffer)
3936 (let* ((data (get-text-property (point) 'gnus-data))
3938 (handles gnus-article-mime-handles))
3939 (if (mm-multiple-handles gnus-article-mime-handles)
3940 (error "This function is not implemented"))
3941 (setq file (and data (mm-save-part data)))
3943 (with-current-buffer (mm-handle-buffer data)
3945 (insert "Content-Type: " (mm-handle-media-type data))
3946 (mml-insert-parameter-string (cdr (mm-handle-type data))
3949 (insert "Content-ID: " (message-make-message-id) "\n")
3950 (insert "Content-Transfer-Encoding: binary\n")
3953 (cdr (mm-make-handle nil
3954 `("message/external-body"
3955 (access-type . "LOCAL-FILE")
3957 (set-buffer gnus-summary-buffer)
3958 (gnus-article-edit-article
3961 (let ((mail-parse-charset (or gnus-article-charset
3962 ',gnus-newsgroup-charset))
3963 (mail-parse-ignored-charsets
3964 (or gnus-article-ignored-charsets
3965 ',gnus-newsgroup-ignored-charsets))
3966 (mbl mml-buffer-list))
3967 (setq mml-buffer-list nil)
3968 (insert-buffer gnus-original-article-buffer)
3969 (mime-to-mml ',handles)
3970 (setq gnus-article-mime-handles nil)
3971 (let ((mbl1 mml-buffer-list))
3972 (setq mml-buffer-list mbl)
3973 (set (make-local-variable 'mml-buffer-list) mbl1))
3974 (gnus-make-local-hook 'kill-buffer-hook)
3975 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3976 `(lambda (no-highlight)
3977 (let ((mail-parse-charset (or gnus-article-charset
3978 ',gnus-newsgroup-charset))
3979 (message-options message-options)
3980 (message-options-set-recipient)
3981 (mail-parse-ignored-charsets
3982 (or gnus-article-ignored-charsets
3983 ',gnus-newsgroup-ignored-charsets)))
3985 (mml-destroy-buffers)
3986 (remove-hook 'kill-buffer-hook
3987 'mml-destroy-buffers t)
3988 (kill-local-variable 'mml-buffer-list))
3989 (gnus-summary-edit-article-done
3990 ,(or (mail-header-references gnus-current-headers) "")
3991 ,(gnus-group-read-only-p)
3992 ,gnus-summary-buffer no-highlight))))))
3994 (defun gnus-mime-delete-part ()
3995 "Delete the MIME part under point.
3996 Replace it with some information about the removed part."
3998 (gnus-article-check-buffer)
3999 (unless (and gnus-novice-user
4000 (not (gnus-yes-or-no-p
4001 "Really delete attachment forever? ")))
4002 (let* ((data (get-text-property (point) 'gnus-data))
4003 (handles gnus-article-mime-handles)
4007 (mail-decode-encoded-word-string (or (mm-handle-description data)
4010 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4012 (type (mm-handle-media-type data)))
4013 (if (mm-multiple-handles gnus-article-mime-handles)
4014 (error "This function is not implemented"))
4015 (with-current-buffer (mm-handle-buffer data)
4016 (let ((bsize (format "%s" (buffer-size))))
4020 "<#part type=text/plain nofile=yes disposition=attachment"
4021 " description=\"Deleted attachment (" bsize " Byte)\">"
4023 "| The following attachment has been deleted:\n"
4025 "| Type: " type "\n"
4026 "| Filename: " filename "\n"
4027 "| Size (encoded): " bsize " Byte\n"
4028 "| Description: " description "\n"
4032 (cdr (mm-make-handle nil `("text/plain"))))))
4033 (set-buffer gnus-summary-buffer)
4034 ;; FIXME: maybe some of the following code (borrowed from
4035 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4036 (gnus-article-edit-article
4039 (let ((mail-parse-charset (or gnus-article-charset
4040 ',gnus-newsgroup-charset))
4041 (mail-parse-ignored-charsets
4042 (or gnus-article-ignored-charsets
4043 ',gnus-newsgroup-ignored-charsets))
4044 (mbl mml-buffer-list))
4045 (setq mml-buffer-list nil)
4046 (insert-buffer gnus-original-article-buffer)
4047 (mime-to-mml ',handles)
4048 (setq gnus-article-mime-handles nil)
4049 (let ((mbl1 mml-buffer-list))
4050 (setq mml-buffer-list mbl)
4051 (set (make-local-variable 'mml-buffer-list) mbl1))
4052 (gnus-make-local-hook 'kill-buffer-hook)
4053 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4054 `(lambda (no-highlight)
4055 (let ((mail-parse-charset (or gnus-article-charset
4056 ',gnus-newsgroup-charset))
4057 (message-options message-options)
4058 (message-options-set-recipient)
4059 (mail-parse-ignored-charsets
4060 (or gnus-article-ignored-charsets
4061 ',gnus-newsgroup-ignored-charsets)))
4063 (mml-destroy-buffers)
4064 (remove-hook 'kill-buffer-hook
4065 'mml-destroy-buffers t)
4066 (kill-local-variable 'mml-buffer-list))
4067 (gnus-summary-edit-article-done
4068 ,(or (mail-header-references gnus-current-headers) "")
4069 ,(gnus-group-read-only-p)
4070 ,gnus-summary-buffer no-highlight)))))
4071 ;; Not in `gnus-mime-save-part-and-strip':
4072 (gnus-article-edit-done)
4073 (gnus-summary-expand-window)
4074 (gnus-summary-show-article))
4076 (defun gnus-mime-save-part ()
4077 "Save the MIME part under point."
4079 (gnus-article-check-buffer)
4080 (let ((data (get-text-property (point) 'gnus-data)))
4082 (mm-save-part data))))
4084 (defun gnus-mime-pipe-part ()
4085 "Pipe the MIME part under point to a process."
4087 (gnus-article-check-buffer)
4088 (let ((data (get-text-property (point) 'gnus-data)))
4090 (mm-pipe-part data))))
4092 (defun gnus-mime-view-part ()
4093 "Interactively choose a viewing method for the MIME part under point."
4095 (gnus-article-check-buffer)
4096 (let ((data (get-text-property (point) 'gnus-data)))
4098 (setq gnus-article-mime-handles
4100 gnus-article-mime-handles (setq data (copy-sequence data))))
4101 (mm-interactively-view-part data))))
4103 (defun gnus-mime-view-part-as-type-internal ()
4104 (gnus-article-check-buffer)
4105 (let* ((name (mail-content-type-get
4106 (mm-handle-type (get-text-property (point) 'gnus-data))
4108 (def-type (and name (mm-default-file-encoding name))))
4109 (and def-type (cons def-type 0))))
4111 (defun gnus-mime-view-part-as-type (&optional mime-type)
4112 "Choose a MIME media type, and view the part as such."
4115 (setq mime-type (completing-read
4116 "View as MIME type: "
4117 (mapcar #'list (mailcap-mime-types))
4119 (gnus-mime-view-part-as-type-internal))))
4120 (gnus-article-check-buffer)
4121 (let ((handle (get-text-property (point) 'gnus-data)))
4124 (mm-make-handle (mm-handle-buffer handle)
4125 (cons mime-type (cdr (mm-handle-type handle)))
4126 (mm-handle-encoding handle)
4127 (mm-handle-undisplayer handle)
4128 (mm-handle-disposition handle)
4129 (mm-handle-description handle)
4131 (mm-handle-id handle)))
4132 (setq gnus-article-mime-handles
4133 (mm-merge-handles gnus-article-mime-handles handle))
4134 (gnus-mm-display-part handle))))
4137 (require 'jka-compr))
4139 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4140 ;; emacs can do that itself.
4142 (defun gnus-mime-jka-compr-maybe-uncompress ()
4143 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4144 The uncompress method used is derived from `buffer-file-name'."
4145 (when (and (fboundp 'jka-compr-installed-p)
4146 (jka-compr-installed-p))
4147 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4149 (let ((basename (file-name-nondirectory buffer-file-name))
4150 (args (jka-compr-info-uncompress-args info))
4151 (prog (jka-compr-info-uncompress-program info))
4152 (message (jka-compr-info-uncompress-message info))
4153 (err-file (jka-compr-make-temp-name)))
4155 (message "%s %s..." message basename))
4157 (unless (memq (apply 'call-process-region
4158 (point-min) (point-max)
4160 t (list t err-file) nil
4162 jka-compr-acceptable-retval-list)
4163 (jka-compr-error prog args basename message err-file))
4164 (jka-compr-delete-temp-file err-file)))))))
4166 (defun gnus-mime-copy-part (&optional handle)
4167 "Put the MIME part under point into a new buffer.
4168 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4171 (gnus-article-check-buffer)
4172 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4173 (contents (and handle (mm-get-part handle)))
4175 (file-name-nondirectory
4177 (mail-content-type-get (mm-handle-type handle) 'name)
4178 (mail-content-type-get (mm-handle-disposition handle)
4181 (buffer (and base (generate-new-buffer base))))
4183 (switch-to-buffer buffer)
4185 ;; We do it this way to make `normal-mode' set the appropriate mode.
4188 (setq buffer-file-name (expand-file-name base))
4189 (gnus-mime-jka-compr-maybe-uncompress)
4191 (setq buffer-file-name nil))
4192 (goto-char (point-min)))))
4194 (defun gnus-mime-print-part (&optional handle filename)
4195 "Print the MIME part under point."
4196 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4197 (gnus-article-check-buffer)
4198 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4199 (contents (and handle (mm-get-part handle)))
4200 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4201 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4206 (mm-save-part-to-file handle file)
4207 (call-process shell-file-name nil
4208 (generate-new-buffer " *mm*")
4210 shell-command-switch
4212 printer file (mm-handle-type handle))))
4216 (gnus-print-buffer))
4217 (ps-despool filename)))))
4219 (defun gnus-mime-inline-part (&optional handle arg)
4220 "Insert the MIME part under point into the current buffer."
4221 (interactive (list nil current-prefix-arg))
4222 (gnus-article-check-buffer)
4223 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4228 (if (and (not arg) (mm-handle-undisplayer handle))
4229 (mm-remove-part handle)
4230 (setq contents (mm-get-part handle))
4233 (setq charset (or (mail-content-type-get
4234 (mm-handle-type handle) 'charset)
4235 gnus-newsgroup-charset)))
4237 (if (mm-handle-undisplayer handle)
4238 (mm-remove-part handle))
4241 gnus-summary-show-article-charset-alist))
4242 (mm-read-coding-system "Charset: ")))))
4244 (mm-insert-inline handle
4246 (setq charset (mm-charset-to-coding-system
4248 (not (eq charset 'ascii)))
4249 (mm-decode-coding-string contents charset)
4253 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4254 "Insert the MIME part under point into the current buffer using the
4256 (interactive (list nil current-prefix-arg))
4257 (gnus-article-check-buffer)
4258 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4263 (if (mm-handle-undisplayer handle)
4264 (mm-remove-part handle))
4265 (let ((gnus-newsgroup-charset
4267 gnus-summary-show-article-charset-alist))
4268 (mm-read-coding-system "Charset: ")))
4269 (gnus-newsgroup-ignored-charsets 'gnus-all))
4270 (gnus-article-press-button)))))
4272 (defun gnus-mime-view-part-externally (&optional handle)
4273 "View the MIME part under point with an external viewer."
4275 (gnus-article-check-buffer)
4276 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4277 (mm-user-display-methods nil)
4278 (mm-inlined-types nil)
4279 (mail-parse-charset gnus-newsgroup-charset)
4280 (mail-parse-ignored-charsets
4281 (save-excursion (set-buffer gnus-summary-buffer)
4282 gnus-newsgroup-ignored-charsets)))
4284 (if (mm-handle-undisplayer handle)
4285 (mm-remove-part handle)
4286 (mm-display-part handle)))))
4288 (defun gnus-mime-view-part-internally (&optional handle)
4289 "View the MIME part under point with an internal viewer.
4290 If no internal viewer is available, use an external viewer."
4292 (gnus-article-check-buffer)
4293 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4294 (mm-inlined-types '(".*"))
4295 (mm-inline-large-images t)
4296 (mail-parse-charset gnus-newsgroup-charset)
4297 (mail-parse-ignored-charsets
4298 (save-excursion (set-buffer gnus-summary-buffer)
4299 gnus-newsgroup-ignored-charsets))
4302 (if (mm-handle-undisplayer handle)
4303 (mm-remove-part handle)
4304 (mm-display-part handle)))))
4306 (defun gnus-mime-action-on-part (&optional action)
4307 "Do something with the MIME attachment at \(point\)."
4309 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4310 (gnus-article-check-buffer)
4311 (let ((action-pair (assoc action gnus-mime-action-alist)))
4313 (funcall (cdr action-pair)))))
4315 (defun gnus-article-part-wrapper (n function)
4316 (save-current-buffer
4317 (set-buffer gnus-article-buffer)
4318 (when (> n (length gnus-article-mime-handle-alist))
4319 (error "No such part"))
4320 (gnus-article-goto-part n)
4321 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4322 (funcall function handle))))
4324 (defun gnus-article-pipe-part (n)
4325 "Pipe MIME part N, which is the numerical prefix."
4327 (gnus-article-part-wrapper n 'mm-pipe-part))
4329 (defun gnus-article-save-part (n)
4330 "Save MIME part N, which is the numerical prefix."
4332 (gnus-article-part-wrapper n 'mm-save-part))
4334 (defun gnus-article-interactively-view-part (n)
4335 "View MIME part N interactively, which is the numerical prefix."
4337 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4339 (defun gnus-article-copy-part (n)
4340 "Copy MIME part N, which is the numerical prefix."
4342 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4344 (defun gnus-article-view-part-as-charset (n)
4345 "View MIME part N using a specified charset.
4346 N is the numerical prefix."
4348 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4350 (defun gnus-article-view-part-externally (n)
4351 "View MIME part N externally, which is the numerical prefix."
4353 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4355 (defun gnus-article-inline-part (n)
4356 "Inline MIME part N, which is the numerical prefix."
4358 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4360 (defun gnus-article-mime-match-handle-first (condition)
4362 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4363 (while (setq ihandle (pop alist))
4365 ((functionp condition)
4366 (funcall condition (cdr ihandle)))
4367 ((eq condition 'undisplayed)
4368 (not (or (mm-handle-undisplayer (cdr ihandle))
4369 (equal (mm-handle-media-type (cdr ihandle))
4370 "multipart/alternative"))))
4371 ((eq condition 'undisplayed-alternative)
4372 (not (mm-handle-undisplayer (cdr ihandle))))
4374 (gnus-article-goto-part (car ihandle))
4375 (or (not n) (< (car ihandle) n)))
4376 (setq n (car ihandle))))
4380 (defun gnus-article-view-part (&optional n)
4381 "View MIME part N, which is the numerical prefix."
4383 (save-current-buffer
4384 (set-buffer gnus-article-buffer)
4385 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4386 gnus-article-mime-match-handle-function)))
4387 (when (> n (length gnus-article-mime-handle-alist))
4388 (error "No such part"))
4389 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4390 (when (gnus-article-goto-part n)
4391 (if (equal (car handle) "multipart/alternative")
4392 (gnus-article-press-button)
4393 (when (eq (gnus-mm-display-part handle) 'internal)
4394 (gnus-set-window-start)))))))
4396 (defsubst gnus-article-mime-total-parts ()
4397 (if (bufferp (car gnus-article-mime-handles))
4399 (1- (length gnus-article-mime-handles))))
4401 (defun gnus-mm-display-part (handle)
4402 "Display HANDLE and fix MIME button."
4403 (let ((id (get-text-property (point) 'gnus-part))
4408 (let ((window (selected-window))
4409 (mail-parse-charset gnus-newsgroup-charset)
4410 (mail-parse-ignored-charsets
4411 (if (gnus-buffer-live-p gnus-summary-buffer)
4413 (set-buffer gnus-summary-buffer)
4414 gnus-newsgroup-ignored-charsets)
4418 (let ((win (gnus-get-buffer-window (current-buffer) t))
4421 (select-window win))
4424 (if (mm-handle-displayed-p handle)
4425 ;; This will remove the part.
4426 (mm-display-part handle)
4428 (narrow-to-region (point)
4429 (if (eobp) (point) (1+ (point))))
4430 (mm-display-part handle)
4431 ;; We narrow to the part itself and
4432 ;; then call the treatment functions.
4433 (goto-char (point-min))
4435 (narrow-to-region (point) (point-max))
4438 (gnus-article-mime-total-parts)
4439 (mm-handle-media-type handle)))))
4440 (if (window-live-p window)
4441 (select-window window)))))
4444 (gnus-insert-mime-button
4445 handle id (list (mm-handle-displayed-p handle)))
4446 (goto-char point))))
4448 (defun gnus-article-goto-part (n)
4449 "Go to MIME part N."
4450 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4452 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4453 (let ((gnus-tmp-name
4454 (or (mail-content-type-get (mm-handle-type handle) 'name)
4455 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4456 (mail-content-type-get (mm-handle-type handle) 'url)
4458 (gnus-tmp-type (mm-handle-media-type handle))
4459 (gnus-tmp-description
4460 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4463 (if (if displayed (car displayed)
4464 (mm-handle-displayed-p handle))
4466 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4468 gnus-tmp-type-long b e)
4469 (when (string-match ".*/" gnus-tmp-name)
4470 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4471 (setq gnus-tmp-type-long (concat gnus-tmp-type
4472 (and (not (equal gnus-tmp-name ""))
4473 (concat "; " gnus-tmp-name))))
4474 (unless (equal gnus-tmp-description "")
4475 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4480 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4481 `(,@(gnus-local-map-property gnus-mime-button-map)
4482 gnus-callback gnus-mm-display-part
4483 gnus-part ,gnus-tmp-id
4484 article-type annotation
4487 ;; Exclude a newline.
4490 (widget-convert-button
4493 :action 'gnus-widget-press-button
4494 :button-keymap gnus-mime-button-map
4496 (lambda (widget/window &optional overlay pos)
4497 ;; Needed to properly clear the message due to a bug in
4498 ;; wid-edit (XEmacs only).
4499 (if (boundp 'help-echo-owns-message)
4500 (setq help-echo-owns-message t))
4502 "%S: %s the MIME part; %S: more options"
4503 (aref gnus-mouse-2 0)
4504 ;; XEmacs will get a single widget arg; Emacs 21 will get
4505 ;; window, overlay, position.
4506 (if (mm-handle-displayed-p
4508 (with-current-buffer (gnus-overlay-buffer overlay)
4509 (widget-get (widget-at (gnus-overlay-start overlay))
4511 (widget-get widget/window :mime-handle)))
4513 (aref gnus-down-mouse-3 0))))))
4515 (defun gnus-widget-press-button (elems el)
4516 (goto-char (widget-get elems :from))
4517 (gnus-article-press-button))
4519 (defvar gnus-displaying-mime nil)
4521 (defun gnus-display-mime (&optional ihandles)
4522 "Display the MIME parts."
4524 (save-selected-window
4525 (let ((window (get-buffer-window gnus-article-buffer))
4528 (select-window window)
4529 ;; We have to do this since selecting the window
4530 ;; may change the point. So we set the window point.
4531 (set-window-point window point)))
4532 (let* ((handles (or ihandles
4533 (mm-dissect-buffer nil gnus-article-loose-mime)
4534 (and gnus-article-emulate-mime
4536 buffer-read-only handle name type b e display)
4537 (when (and (not ihandles)
4538 (not gnus-displaying-mime))
4539 ;; Top-level call; we clean up.
4540 (when gnus-article-mime-handles
4541 (mm-destroy-parts gnus-article-mime-handles)
4542 (setq gnus-article-mime-handle-alist nil));; A trick.
4543 (setq gnus-article-mime-handles handles)
4544 ;; We allow users to glean info from the handles.
4545 (when gnus-article-mime-part-function
4546 (gnus-mime-part-function handles)))
4548 (or (not (stringp (car handles)))
4551 (when (and (not ihandles)
4552 (not gnus-displaying-mime))
4553 ;; Clean up for mime parts.
4555 (delete-region (point) (point-max)))
4556 (let ((gnus-displaying-mime t))
4557 (gnus-mime-display-part handles)))
4560 (narrow-to-region (point) (point-max))
4561 (gnus-treat-article nil 1 1)
4564 ;; Highlight the headers.
4568 (narrow-to-region (point-min) (point))
4569 (gnus-treat-article 'head))))))))
4571 (defcustom gnus-mime-display-multipart-as-mixed nil
4572 "Display \"multipart\" parts as \"multipart/mixed\".
4574 If t, it overrides nil values of
4575 `gnus-mime-display-multipart-alternative-as-mixed' and
4576 `gnus-mime-display-multipart-related-as-mixed'."
4577 :group 'gnus-article-mime
4580 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4581 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4582 :group 'gnus-article-mime
4585 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4586 "Display \"multipart/related\" parts as \"multipart/mixed\".
4588 If displaying \"text/html\" is discouraged \(see
4589 `mm-discouraged-alternatives'\) images or other material inside a
4590 \"multipart/related\" part might be overlooked when this variable is nil."
4591 :group 'gnus-article-mime
4594 (defun gnus-mime-display-part (handle)
4597 ((not (stringp (car handle)))
4598 (gnus-mime-display-single handle))
4599 ;; User-defined multipart
4600 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4601 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4603 ;; multipart/alternative
4604 ((and (equal (car handle) "multipart/alternative")
4605 (not (or gnus-mime-display-multipart-as-mixed
4606 gnus-mime-display-multipart-alternative-as-mixed)))
4607 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4608 (push (cons id handle) gnus-article-mime-handle-alist)
4609 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4610 ;; multipart/related
4611 ((and (equal (car handle) "multipart/related")
4612 (not (or gnus-mime-display-multipart-as-mixed
4613 gnus-mime-display-multipart-related-as-mixed)))
4614 ;;;!!!We should find the start part, but we just default
4615 ;;;!!!to the first part.
4616 ;;(gnus-mime-display-part (cadr handle))
4617 ;;;!!! Most multipart/related is an HTML message plus images.
4618 ;;;!!! Unfortunately we are unable to let W3 display those
4619 ;;;!!! included images, so we just display it as a mixed multipart.
4620 ;;(gnus-mime-display-mixed (cdr handle))
4621 ;;;!!! No, w3 can display everything just fine.
4622 (gnus-mime-display-part (cadr handle)))
4623 ((equal (car handle) "multipart/signed")
4624 (gnus-add-wash-type 'signed)
4625 (gnus-mime-display-security handle))
4626 ((equal (car handle) "multipart/encrypted")
4627 (gnus-add-wash-type 'encrypted)
4628 (gnus-mime-display-security handle))
4629 ;; Other multiparts are handled like multipart/mixed.
4631 (gnus-mime-display-mixed (cdr handle)))))
4633 (defun gnus-mime-part-function (handles)
4634 (if (stringp (car handles))
4635 (mapcar 'gnus-mime-part-function (cdr handles))
4636 (funcall gnus-article-mime-part-function handles)))
4638 (defun gnus-mime-display-mixed (handles)
4639 (mapcar 'gnus-mime-display-part handles))
4641 (defun gnus-mime-display-single (handle)
4642 (let ((type (mm-handle-media-type handle))
4643 (ignored gnus-ignored-mime-types)
4650 (when (string-match (pop ignored) type)
4651 (throw 'ignored nil)))
4652 (if (and (setq not-attachment
4653 (and (not (mm-inline-override-p handle))
4654 (or (not (mm-handle-disposition handle))
4655 (equal (car (mm-handle-disposition handle))
4657 (mm-attachment-override-p handle))))
4658 (mm-automatic-display-p handle)
4660 (mm-inlinable-p handle)
4661 (mm-inlined-p handle))
4662 (mm-automatic-external-display-p type)))
4664 (when (equal (mm-handle-media-supertype handle) "text")
4666 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4668 (push (cons id handle) gnus-article-mime-handle-alist)
4669 (when (or (not display)
4670 (not (gnus-unbuttonized-mime-type-p type)))
4671 ;(gnus-article-insert-newline)
4672 (gnus-insert-mime-button
4673 handle id (list (or display (and not-attachment text))))
4674 (gnus-article-insert-newline)
4675 ;(gnus-article-insert-newline)
4676 ;; Remember modify the number of forward lines.
4684 (let ((mail-parse-charset gnus-newsgroup-charset)
4685 (mail-parse-ignored-charsets
4686 (save-excursion (condition-case ()
4687 (set-buffer gnus-summary-buffer)
4689 gnus-newsgroup-ignored-charsets)))
4690 (mm-display-part handle t))
4691 (goto-char (point-max)))
4692 ((and text not-attachment)
4696 (gnus-article-insert-newline)
4697 (mm-insert-inline handle (mm-get-part handle))
4698 (goto-char (point-max))))
4702 (narrow-to-region beg (point))
4705 (gnus-article-mime-total-parts)
4706 (mm-handle-media-type handle)))))))))
4708 (defun gnus-unbuttonized-mime-type-p (type)
4709 "Say whether TYPE is to be unbuttonized."
4710 (unless gnus-inhibit-mime-unbuttonizing
4712 (let ((types gnus-unbuttonized-mime-types))
4714 (when (string-match (pop types) type)
4715 (throw 'found t)))))
4717 (let ((types gnus-buttonized-mime-types))
4719 (when (string-match (pop types) type)
4720 (throw 'found t)))))))))
4722 (defun gnus-article-insert-newline ()
4723 "Insert a newline, but mark it as undeletable."
4724 (gnus-put-text-property
4725 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4727 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4728 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4731 handle buffer-read-only from props begend not-pref)
4732 (save-window-excursion
4735 (narrow-to-region (car ibegend)
4738 (goto-char (car ibegend))
4741 (delete-region (point-min) (point-max))
4742 (mm-remove-parts handles))
4743 (setq begend (list (point-marker)))
4745 (unless (setq not-pref (cadr (member preferred ihandles)))
4746 (setq not-pref (car ihandles)))
4749 (not (gnus-unbuttonized-mime-type-p
4750 "multipart/alternative")))
4751 (gnus-add-text-properties
4754 (insert (format "%d. " id))
4758 (unless ,(not ibegend)
4759 (setq gnus-article-mime-handle-alist
4760 ',gnus-article-mime-handle-alist))
4761 (gnus-mime-display-alternative
4762 ',ihandles ',not-pref ',begend ,id))
4763 ,@(gnus-local-map-property gnus-mime-button-map)
4764 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4765 face ,gnus-article-button-face
4768 (widget-convert-button 'link from (point)
4769 :action 'gnus-widget-press-button
4770 :button-keymap gnus-widget-button-keymap)
4772 (while (setq handle (pop handles))
4773 (gnus-add-text-properties
4776 (insert (format "(%c) %-18s"
4777 (if (equal handle preferred) ?* ? )
4778 (mm-handle-media-type handle)))
4782 (unless ,(not ibegend)
4783 (setq gnus-article-mime-handle-alist
4784 ',gnus-article-mime-handle-alist))
4785 (gnus-mime-display-alternative
4786 ',ihandles ',handle ',begend ,id))
4787 ,@(gnus-local-map-property gnus-mime-button-map)
4788 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4789 face ,gnus-article-button-face
4792 (widget-convert-button 'link from (point)
4793 :action 'gnus-widget-press-button
4794 :button-keymap gnus-widget-button-keymap)
4798 (if (stringp (car preferred))
4799 (gnus-display-mime preferred)
4800 (let ((mail-parse-charset gnus-newsgroup-charset)
4801 (mail-parse-ignored-charsets
4802 (save-excursion (set-buffer gnus-summary-buffer)
4803 gnus-newsgroup-ignored-charsets)))
4804 (mm-display-part preferred)
4808 (narrow-to-region (car begend) (point-max))
4810 nil (length gnus-article-mime-handle-alist)
4811 (gnus-article-mime-total-parts)
4812 (mm-handle-media-type handle))))))
4813 (goto-char (point-max))
4814 (setcdr begend (point-marker)))))
4816 (goto-char point))))
4818 (defconst gnus-article-wash-status-strings
4819 (let ((alist '((cite "c" "Possible hidden citation text"
4820 " " "All citation text visible")
4821 (headers "h" "Hidden headers"
4822 " " "All headers visible.")
4823 (pgp "p" "Encrypted or signed message status hidden"
4824 " " "No hidden encryption nor digital signature status")
4825 (signature "s" "Signature has been hidden"
4826 " " "Signature is visible")
4827 (overstrike "o" "Overstrike (^H) characters applied"
4828 " " "No overstrike characters applied")
4829 (emphasis "e" "/*_Emphasis_*/ characters applied"
4830 " " "No /*_emphasis_*/ characters applied")))
4832 (dolist (entry alist result)
4833 (let ((key (nth 0 entry))
4834 (on (copy-sequence (nth 1 entry)))
4835 (on-help (nth 2 entry))
4836 (off (copy-sequence (nth 3 entry)))
4837 (off-help (nth 4 entry)))
4838 (put-text-property 0 1 'help-echo on-help on)
4839 (put-text-property 0 1 'help-echo off-help off)
4840 (push (list key on off) result))))
4841 "Alist of strings describing wash status in the mode line.
4842 Each entry has the form (KEY ON OF), where the KEY is a symbol
4843 representing the particular washing function, ON is the string to use
4844 in the article mode line when the washing function is active, and OFF
4845 is the string to use when it is inactive.")
4847 (defun gnus-article-wash-status-entry (key value)
4848 (let ((entry (assoc key gnus-article-wash-status-strings)))
4849 (if value (nth 1 entry) (nth 2 entry))))
4851 (defun gnus-article-wash-status ()
4852 "Return a string which display status of article washing."
4854 (set-buffer gnus-article-buffer)
4855 (let ((cite (memq 'cite gnus-article-wash-types))
4856 (headers (memq 'headers gnus-article-wash-types))
4857 (boring (memq 'boring-headers gnus-article-wash-types))
4858 (pgp (memq 'pgp gnus-article-wash-types))
4859 (pem (memq 'pem gnus-article-wash-types))
4860 (signed (memq 'signed gnus-article-wash-types))
4861 (encrypted (memq 'encrypted gnus-article-wash-types))
4862 (signature (memq 'signature gnus-article-wash-types))
4863 (overstrike (memq 'overstrike gnus-article-wash-types))
4864 (emphasis (memq 'emphasis gnus-article-wash-types)))
4866 (gnus-article-wash-status-entry 'cite cite)
4867 (gnus-article-wash-status-entry 'headers (or headers boring))
4868 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4869 (gnus-article-wash-status-entry 'signature signature)
4870 (gnus-article-wash-status-entry 'overstrike overstrike)
4871 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4873 (defun gnus-add-wash-type (type)
4874 "Add a washing of TYPE to the current status."
4875 (add-to-list 'gnus-article-wash-types type))
4877 (defun gnus-delete-wash-type (type)
4878 "Add a washing of TYPE to the current status."
4879 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4881 (defun gnus-add-image (category image)
4882 "Add IMAGE of CATEGORY to the list of displayed images."
4883 (let ((entry (assq category gnus-article-image-alist)))
4885 (setq entry (list category))
4886 (push entry gnus-article-image-alist))
4887 (nconc entry (list image))))
4889 (defun gnus-delete-images (category)
4890 "Delete all images in CATEGORY."
4891 (let ((entry (assq category gnus-article-image-alist)))
4892 (dolist (image (cdr entry))
4893 (gnus-remove-image image category))
4894 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4895 (gnus-delete-wash-type category)))
4897 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4899 (defun gnus-article-maybe-hide-headers ()
4900 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4901 Provided for backwards compatibility."
4902 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4903 (not (save-excursion (set-buffer gnus-summary-buffer)
4904 gnus-have-all-headers)))
4905 (not gnus-inhibit-hiding))
4906 (gnus-article-hide-headers)))
4910 (defun gnus-output-to-file (file-name)
4911 "Append the current article to a file named FILE-NAME."
4912 (let ((artbuf (current-buffer)))
4914 (insert-buffer-substring artbuf)
4915 ;; Append newline at end of the buffer as separator, and then
4917 (goto-char (point-max))
4919 (let ((file-name-coding-system nnmail-pathname-coding-system))
4920 (mm-append-to-file (point-min) (point-max) file-name))
4923 (defun gnus-narrow-to-page (&optional arg)
4924 "Narrow the article buffer to a page.
4925 If given a numerical ARG, move forward ARG pages."
4927 (setq arg (if arg (prefix-numeric-value arg) 0))
4929 (set-buffer gnus-article-buffer)
4930 (goto-char (point-min))
4932 ;; Remove any old next/prev buttons.
4933 (when (gnus-visual-p 'page-marker)
4934 (let ((buffer-read-only nil))
4935 (gnus-remove-text-with-property 'gnus-prev)
4936 (gnus-remove-text-with-property 'gnus-next)))
4939 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4941 (re-search-forward page-delimiter nil 'move arg)))
4942 (goto-char (match-end 0)))
4945 (if (re-search-forward page-delimiter nil 'move)
4948 (when (and (gnus-visual-p 'page-marker)
4949 (not (= (point-min) 1)))
4951 (goto-char (point-min))
4952 (gnus-insert-prev-page-button)))
4953 (when (and (gnus-visual-p 'page-marker)
4954 (< (+ (point-max) 2) (buffer-size)))
4956 (goto-char (point-max))
4957 (gnus-insert-next-page-button)))))
4959 ;; Article mode commands
4961 (defun gnus-article-goto-next-page ()
4962 "Show the next page of the article."
4964 (when (gnus-article-next-page)
4965 (goto-char (point-min))
4966 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4969 (defun gnus-article-goto-prev-page ()
4970 "Show the next page of the article."
4973 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4974 (gnus-article-prev-page nil)))
4976 ;; This is cleaner but currently breaks `gnus-pick-mode':
4978 ;; (defun gnus-article-goto-next-page ()
4979 ;; "Show the next page of the article."
4981 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
4982 ;; (gnus-summary-next-page)))
4984 ;; (defun gnus-article-goto-prev-page ()
4985 ;; "Show the next page of the article."
4987 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
4988 ;; (gnus-summary-prev-page)))
4990 (defun gnus-article-next-page (&optional lines)
4991 "Show the next page of the current article.
4992 If end of article, return non-nil. Otherwise return nil.
4993 Argument LINES specifies lines to be scrolled up."
4995 (move-to-window-line -1)
4998 (and (pos-visible-in-window-p) ;Not continuation line.
4999 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5000 ;; Nothing in this page.
5001 (if (or (not gnus-page-broken)
5004 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
5006 (when gnus-article-over-scroll
5007 (gnus-article-next-page-1 lines))
5009 (gnus-narrow-to-page 1) ;Go to next page.
5011 ;; More in this page.
5012 (gnus-article-next-page-1 lines)
5015 (defun gnus-article-next-page-1 (lines)
5016 (let ((scroll-in-place nil))
5020 ;; Long lines may cause an end-of-buffer error.
5021 (goto-char (point-max)))))
5022 (move-to-window-line 0))
5024 (defun gnus-article-prev-page (&optional lines)
5025 "Show previous page of current article.
5026 Argument LINES specifies lines to be scrolled down."
5028 (move-to-window-line 0)
5029 (if (and gnus-page-broken
5031 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5033 (gnus-narrow-to-page -1) ;Go to previous page.
5034 (goto-char (point-max))
5036 (let ((scroll-in-place nil))
5040 (beginning-of-buffer
5041 (goto-char (point-min))))
5042 (move-to-window-line 0)))))
5044 (defun gnus-article-only-boring-p ()
5045 "Decide whether there is only boring text remaining in the article.
5046 Something \"interesting\" is a word of at least two letters that does
5047 not have a face in `gnus-article-boring-faces'."
5048 (when (and gnus-article-skip-boring
5049 (boundp 'gnus-article-boring-faces)
5050 (symbol-value 'gnus-article-boring-faces))
5053 (while (re-search-forward "\\b\\w\\w" nil t)
5055 (when (not (gnus-intersection
5056 (gnus-faces-at (point))
5057 (symbol-value 'gnus-article-boring-faces)))
5058 (throw 'only-boring nil)))
5059 (throw 'only-boring t)))))
5061 (defun gnus-article-refer-article ()
5062 "Read article specified by message-id around point."
5065 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5066 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5067 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5068 (let ((msg-id (concat "<" (match-string 0) ">")))
5069 (set-buffer gnus-summary-buffer)
5070 (gnus-summary-refer-article msg-id))
5071 (error "No references around point"))))
5073 (defun gnus-article-show-summary ()
5074 "Reconfigure windows to show summary buffer."
5076 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5077 (error "There is no summary buffer for this article buffer")
5078 (gnus-article-set-globals)
5079 (gnus-configure-windows 'article)
5080 (gnus-summary-goto-subject gnus-current-article)
5081 (gnus-summary-position-point)))
5083 (defun gnus-article-describe-briefly ()
5084 "Describe article mode commands briefly."
5086 (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")))
5088 (defun gnus-article-summary-command ()
5089 "Execute the last keystroke in the summary buffer."
5091 (let ((obuf (current-buffer))
5092 (owin (current-window-configuration))
5094 (switch-to-buffer gnus-article-current-summary 'norecord)
5095 (setq func (lookup-key (current-local-map) (this-command-keys)))
5096 (call-interactively func)
5098 (set-window-configuration owin)
5099 (set-window-point (get-buffer-window (current-buffer)) (point))))
5101 (defun gnus-article-summary-command-nosave ()
5102 "Execute the last keystroke in the summary buffer."
5105 (pop-to-buffer gnus-article-current-summary 'norecord)
5106 (setq func (lookup-key (current-local-map) (this-command-keys)))
5107 (call-interactively func)))
5109 (defun gnus-article-check-buffer ()
5110 "Beep if not in an article buffer."
5111 (unless (equal major-mode 'gnus-article-mode)
5112 (error "Command invoked outside of a Gnus article buffer")))
5114 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5115 "Read a summary buffer key sequence and execute it from the article buffer."
5117 (gnus-article-check-buffer)
5119 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5120 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5121 "=" "^" "\M-^" "|"))
5127 '("n" "Gn" "p" "Gp"))
5130 (set-buffer gnus-article-current-summary)
5131 (let (gnus-pick-mode)
5132 (push (or key last-command-event) unread-command-events)
5133 (setq keys (if (featurep 'xemacs)
5134 (events-to-keys (read-key-sequence nil))
5135 (read-key-sequence nil)))))
5139 (if (or (member keys nosaves)
5140 (member keys nosave-but-article)
5141 (member keys nosave-in-article))
5143 (save-window-excursion
5144 (pop-to-buffer gnus-article-current-summary 'norecord)
5145 ;; We disable the pick minor mode commands.
5146 (let (gnus-pick-mode)
5147 (setq func (lookup-key (current-local-map) keys))))
5151 (unless (member keys nosave-in-article)
5152 (set-buffer gnus-article-current-summary))
5153 (call-interactively func)
5154 (setq new-sum-point (point)))
5155 (when (member keys nosave-but-article)
5156 (pop-to-buffer gnus-article-buffer 'norecord)))
5157 ;; These commands should restore window configuration.
5158 (let ((obuf (current-buffer))
5159 (owin (current-window-configuration))
5161 (summary gnus-article-current-summary)
5162 func in-buffer selected)
5163 (if not-restore-window
5164 (pop-to-buffer summary 'norecord)
5165 (switch-to-buffer summary 'norecord))
5166 (setq in-buffer (current-buffer))
5167 ;; We disable the pick minor mode commands.
5168 (if (and (setq func (let (gnus-pick-mode)
5169 (lookup-key (current-local-map) keys)))
5172 (call-interactively func)
5173 (setq new-sum-point (point))
5174 (when (eq in-buffer (current-buffer))
5175 (setq selected (gnus-summary-select-article))
5177 (unless not-restore-window
5178 (set-window-configuration owin))
5179 (when (eq selected 'old)
5181 (set-window-start (get-buffer-window (current-buffer))
5183 (set-window-point (get-buffer-window (current-buffer))
5185 (let ((win (get-buffer-window gnus-article-current-summary)))
5187 (set-window-point win new-sum-point)))) )
5188 (switch-to-buffer gnus-article-buffer)
5191 (defun gnus-article-describe-key (key)
5192 "Display documentation of the function invoked by KEY. KEY is a string."
5193 (interactive "kDescribe key: ")
5194 (gnus-article-check-buffer)
5195 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5197 (set-buffer gnus-article-current-summary)
5198 (let (gnus-pick-mode)
5199 (if (featurep 'xemacs)
5201 (push (elt key 0) unread-command-events)
5202 (setq key (events-to-keys
5203 (read-key-sequence "Describe key: "))))
5204 (setq unread-command-events
5206 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5207 (string-to-list key)))
5208 (setq key (read-key-sequence "Describe key: "))))
5210 (describe-key key)))
5212 (defun gnus-article-describe-key-briefly (key &optional insert)
5213 "Display documentation of the function invoked by KEY. KEY is a string."
5214 (interactive "kDescribe key: \nP")
5215 (gnus-article-check-buffer)
5216 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5218 (set-buffer gnus-article-current-summary)
5219 (let (gnus-pick-mode)
5220 (if (featurep 'xemacs)
5222 (push (elt key 0) unread-command-events)
5223 (setq key (events-to-keys
5224 (read-key-sequence "Describe key: "))))
5225 (setq unread-command-events
5227 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5228 (string-to-list key)))
5229 (setq key (read-key-sequence "Describe key: "))))
5230 (describe-key-briefly key insert))
5231 (describe-key-briefly key insert)))
5233 (defun gnus-article-reply-with-original (&optional wide)
5234 "Start composing a reply mail to the current message.
5235 The text in the region will be yanked. If the region isn't active,
5236 the entire article will be yanked."
5238 (let ((article (cdr gnus-article-current))
5240 (if (not (gnus-mark-active-p))
5241 (with-current-buffer gnus-summary-buffer
5242 (gnus-summary-reply (list (list article)) wide))
5243 (setq contents (buffer-substring (point) (mark t)))
5244 ;; Deactivate active regions.
5245 (when (and (boundp 'transient-mark-mode)
5246 transient-mark-mode)
5247 (setq mark-active nil))
5248 (with-current-buffer gnus-summary-buffer
5250 (list (list article contents)) wide)))))
5252 (defun gnus-article-followup-with-original ()
5253 "Compose a followup to the current article.
5254 The text in the region will be yanked. If the region isn't active,
5255 the entire article will be yanked."
5257 (let ((article (cdr gnus-article-current))
5259 (if (not (gnus-mark-active-p))
5260 (with-current-buffer gnus-summary-buffer
5261 (gnus-summary-followup (list (list article))))
5262 (setq contents (buffer-substring (point) (mark t)))
5263 ;; Deactivate active regions.
5264 (when (and (boundp 'transient-mark-mode)
5265 transient-mark-mode)
5266 (setq mark-active nil))
5267 (with-current-buffer gnus-summary-buffer
5268 (gnus-summary-followup
5269 (list (list article contents)))))))
5271 (defun gnus-article-hide (&optional arg force)
5272 "Hide all the gruft in the current article.
5273 This means that signatures, cited text and (some) headers will be
5275 If given a prefix, show the hidden text instead."
5276 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5277 (gnus-article-hide-headers arg)
5278 (gnus-article-hide-list-identifiers arg)
5279 (gnus-article-hide-citation-maybe arg force)
5280 (gnus-article-hide-signature arg))
5282 (defun gnus-article-maybe-highlight ()
5283 "Do some article highlighting if article highlighting is requested."
5284 (when (gnus-visual-p 'article-highlight 'highlight)
5285 (gnus-article-highlight-some)))
5287 (defun gnus-check-group-server ()
5288 ;; Make sure the connection to the server is alive.
5289 (unless (gnus-server-opened
5290 (gnus-find-method-for-group gnus-newsgroup-name))
5291 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5292 (gnus-request-group gnus-newsgroup-name t)))
5295 (autoload 'nneething-get-file-name "nneething"))
5297 (defun gnus-request-article-this-buffer (article group)
5298 "Get an article and insert it into this buffer."
5299 (let (do-update-line sparse-header)
5303 (gnus-kill-all-overlays)
5304 (setq group (or group gnus-newsgroup-name))
5306 ;; Using `gnus-request-article' directly will insert the article into
5307 ;; `nntp-server-buffer' - so we'll save some time by not having to
5308 ;; copy it from the server buffer into the article buffer.
5310 ;; We only request an article by message-id when we do not have the
5311 ;; headers for it, so we'll have to get those.
5312 (when (stringp article)
5313 (gnus-read-header article))
5315 ;; If the article number is negative, that means that this article
5316 ;; doesn't belong in this newsgroup (possibly), so we find its
5317 ;; message-id and request it by id instead of number.
5318 (when (and (numberp article)
5320 (get-buffer gnus-summary-buffer)
5321 (gnus-buffer-exists-p gnus-summary-buffer))
5323 (set-buffer gnus-summary-buffer)
5324 (let ((header (gnus-summary-article-header article)))
5327 ((memq article gnus-newsgroup-sparse)
5328 ;; This is a sparse gap article.
5329 (setq do-update-line article)
5330 (setq article (mail-header-id header))
5331 (setq sparse-header (gnus-read-header article))
5332 (setq gnus-newsgroup-sparse
5333 (delq article gnus-newsgroup-sparse)))
5335 ;; It's a real article.
5336 (setq article (mail-header-id header)))
5338 ;; It is an extracted pseudo-article.
5339 (setq article 'pseudo)
5340 (gnus-request-pseudo-article header))))
5342 (let ((method (gnus-find-method-for-group
5343 gnus-newsgroup-name)))
5344 (when (and (eq (car method) 'nneething)
5346 (let ((dir (nneething-get-file-name
5347 (mail-header-id header))))
5348 (when (and (stringp dir)
5349 (file-directory-p dir))
5350 (setq article 'nneething)
5351 (gnus-group-enter-directory dir))))))))
5354 ;; Refuse to select canceled articles.
5355 ((and (numberp article)
5357 (get-buffer gnus-summary-buffer)
5358 (gnus-buffer-exists-p gnus-summary-buffer)
5359 (eq (cdr (save-excursion
5360 (set-buffer gnus-summary-buffer)
5361 (assq article gnus-newsgroup-reads)))
5362 gnus-canceled-mark))
5364 ;; We first check `gnus-original-article-buffer'.
5365 ((and (get-buffer gnus-original-article-buffer)
5368 (set-buffer gnus-original-article-buffer)
5369 (and (equal (car gnus-original-article) group)
5370 (eq (cdr gnus-original-article) article))))
5371 (insert-buffer-substring gnus-original-article-buffer)
5373 ;; Check the backlog.
5374 ((and gnus-keep-backlog
5375 (gnus-backlog-request-article group article (current-buffer)))
5377 ;; Check asynchronous pre-fetch.
5378 ((gnus-async-request-fetched-article group article (current-buffer))
5379 (gnus-async-prefetch-next group article gnus-summary-buffer)
5380 (when (and (numberp article) gnus-keep-backlog)
5381 (gnus-backlog-enter-article group article (current-buffer)))
5384 ((and gnus-use-cache
5386 (gnus-cache-request-article article group))
5388 ;; Check the agent cache.
5389 ((gnus-agent-request-article article group)
5391 ;; Get the article and put into the article buffer.
5392 ((or (stringp article)
5394 (let ((gnus-override-method gnus-override-method)
5395 (methods (and (stringp article)
5396 gnus-refer-article-method))
5397 (backend (car (gnus-find-method-for-group
5398 gnus-newsgroup-name)))
5400 (buffer-read-only nil))
5401 (if (or (not (listp methods))
5402 (and (symbolp (car methods))
5403 (assq (car methods) nnoo-definition-alist)))
5404 (setq methods (list methods)))
5405 (when (and (null gnus-override-method)
5407 (setq gnus-override-method (pop methods)))
5409 (when (eq gnus-override-method 'current)
5410 (setq gnus-override-method
5411 (with-current-buffer gnus-summary-buffer
5412 gnus-current-select-method)))
5414 (gnus-kill-all-overlays)
5415 (let ((gnus-newsgroup-name group))
5416 (gnus-check-group-server))
5418 ((gnus-request-article article group (current-buffer))
5419 (when (numberp article)
5420 (gnus-async-prefetch-next group article
5421 gnus-summary-buffer)
5422 (when gnus-keep-backlog
5423 (gnus-backlog-enter-article
5424 group article (current-buffer))))
5425 (setq result 'article))
5427 (setq gnus-override-method (pop methods)))
5428 ((not (string-match "^400 "
5429 (nnheader-get-report backend)))
5430 ;; If we get 400 server disconnect, reconnect and
5431 ;; retry; otherwise, assume the article has expired.
5432 (setq result 'done))))
5433 (and (eq result 'article) 'article)))
5437 ;; Associate this article with the current summary buffer.
5438 (setq gnus-article-current-summary gnus-summary-buffer)
5440 ;; Take the article from the original article buffer
5441 ;; and place it in the buffer it's supposed to be in.
5442 (when (and (get-buffer gnus-article-buffer)
5443 (equal (buffer-name (current-buffer))
5444 (buffer-name (get-buffer gnus-article-buffer))))
5446 (if (get-buffer gnus-original-article-buffer)
5447 (set-buffer gnus-original-article-buffer)
5448 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5449 (buffer-disable-undo)
5450 (setq major-mode 'gnus-original-article-mode)
5451 (setq buffer-read-only t))
5452 (let (buffer-read-only)
5454 (insert-buffer-substring gnus-article-buffer))
5455 (setq gnus-original-article (cons group article)))
5458 (run-hooks 'gnus-article-decode-hook)
5459 ;; Mark article as decoded or not.
5460 (setq gnus-article-decoded-p gnus-article-decode-hook))
5462 ;; Update sparse articles.
5463 (when (and do-update-line
5464 (or (numberp article)
5466 (let ((buf (current-buffer)))
5467 (set-buffer gnus-summary-buffer)
5468 (gnus-summary-update-article do-update-line sparse-header)
5469 (gnus-summary-goto-subject do-update-line nil t)
5470 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5472 (set-buffer buf))))))
5478 (defcustom gnus-article-edit-mode-hook nil
5479 "Hook run in article edit mode buffers."
5480 :group 'gnus-article-various
5483 (defvar gnus-article-edit-done-function nil)
5485 (defvar gnus-article-edit-mode-map nil)
5486 (defvar gnus-article-edit-mode nil)
5488 ;; Should we be using derived.el for this?
5489 (unless gnus-article-edit-mode-map
5490 (setq gnus-article-edit-mode-map (make-keymap))
5491 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5493 (gnus-define-keys gnus-article-edit-mode-map
5494 "\C-c?" describe-mode
5495 "\C-c\C-c" gnus-article-edit-done
5496 "\C-c\C-k" gnus-article-edit-exit
5497 "\C-c\C-f\C-t" message-goto-to
5498 "\C-c\C-f\C-o" message-goto-from
5499 "\C-c\C-f\C-b" message-goto-bcc
5500 ;;"\C-c\C-f\C-w" message-goto-fcc
5501 "\C-c\C-f\C-c" message-goto-cc
5502 "\C-c\C-f\C-s" message-goto-subject
5503 "\C-c\C-f\C-r" message-goto-reply-to
5504 "\C-c\C-f\C-n" message-goto-newsgroups
5505 "\C-c\C-f\C-d" message-goto-distribution
5506 "\C-c\C-f\C-f" message-goto-followup-to
5507 "\C-c\C-f\C-m" message-goto-mail-followup-to
5508 "\C-c\C-f\C-k" message-goto-keywords
5509 "\C-c\C-f\C-u" message-goto-summary
5510 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5511 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5512 "\C-c\C-b" message-goto-body
5513 "\C-c\C-i" message-goto-signature
5515 "\C-c\C-t" message-insert-to
5516 "\C-c\C-n" message-insert-newsgroups
5517 "\C-c\C-o" message-sort-headers
5518 "\C-c\C-e" message-elide-region
5519 "\C-c\C-v" message-delete-not-region
5520 "\C-c\C-z" message-kill-to-signature
5521 "\M-\r" message-newline-and-reformat
5522 "\C-c\C-a" mml-attach-file
5523 "\C-a" message-beginning-of-line
5525 "\M-;" comment-region)
5527 (gnus-define-keys (gnus-article-edit-wash-map
5528 "\C-c\C-w" gnus-article-edit-mode-map)
5529 "f" gnus-article-edit-full-stops))
5532 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5534 ["Fetch To" message-insert-to t]
5535 ["Fetch Newsgroups" message-insert-newsgroups t]
5537 ["To" message-goto-to t]
5538 ["From" message-goto-from t]
5539 ["Subject" message-goto-subject t]
5540 ["Cc" message-goto-cc t]
5541 ["Reply-To" message-goto-reply-to t]
5542 ["Summary" message-goto-summary t]
5543 ["Keywords" message-goto-keywords t]
5544 ["Newsgroups" message-goto-newsgroups t]
5545 ["Followup-To" message-goto-followup-to t]
5546 ["Mail-Followup-To" message-goto-mail-followup-to t]
5547 ["Distribution" message-goto-distribution t]
5548 ["Body" message-goto-body t]
5549 ["Signature" message-goto-signature t]))
5551 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5552 "Major mode for editing articles.
5553 This is an extended text-mode.
5555 \\{gnus-article-edit-mode-map}"
5556 (make-local-variable 'gnus-article-edit-done-function)
5557 (make-local-variable 'gnus-prev-winconf)
5558 (set (make-local-variable 'font-lock-defaults)
5559 '(message-font-lock-keywords t))
5560 (set (make-local-variable 'mail-header-separator) "")
5561 (set (make-local-variable 'gnus-article-edit-mode) t)
5562 (easy-menu-add message-mode-field-menu message-mode-map)
5564 (setq buffer-read-only nil)
5565 (buffer-enable-undo)
5568 (defun gnus-article-edit (&optional force)
5569 "Edit the current article.
5570 This will have permanent effect only in mail groups.
5571 If FORCE is non-nil, allow editing of articles even in read-only
5574 (when (and (not force)
5575 (gnus-group-read-only-p))
5576 (error "The current newsgroup does not support article editing"))
5577 (gnus-article-date-original)
5578 (gnus-article-edit-article
5580 `(lambda (no-highlight)
5582 (gnus-summary-edit-article-done
5583 ,(or (mail-header-references gnus-current-headers) "")
5584 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5586 (defun gnus-article-edit-article (start-func exit-func)
5587 "Start editing the contents of the current article buffer."
5588 (let ((winconf (current-window-configuration)))
5589 (set-buffer gnus-article-buffer)
5590 (gnus-article-edit-mode)
5591 (funcall start-func)
5592 (set-buffer-modified-p nil)
5593 (gnus-configure-windows 'edit-article)
5594 (setq gnus-article-edit-done-function exit-func)
5595 (setq gnus-prev-winconf winconf)
5596 (gnus-message 6 "C-c C-c to end edits")))
5598 (defun gnus-article-edit-done (&optional arg)
5599 "Update the article edits and exit."
5601 (let ((func gnus-article-edit-done-function)
5602 (buf (current-buffer))
5603 (start (window-start))
5605 (winconf gnus-prev-winconf))
5606 (widen) ;; Widen it in case that users narrowed the buffer.
5609 ;; The cache and backlog have to be flushed somewhat.
5610 (when gnus-keep-backlog
5611 (gnus-backlog-remove-article
5612 (car gnus-article-current) (cdr gnus-article-current)))
5613 ;; Flush original article as well.
5615 (when (get-buffer gnus-original-article-buffer)
5616 (set-buffer gnus-original-article-buffer)
5617 (setq gnus-original-article nil)))
5618 (when gnus-use-cache
5619 (gnus-cache-update-article
5620 (car gnus-article-current) (cdr gnus-article-current)))
5621 ;; We remove all text props from the article buffer.
5622 (kill-all-local-variables)
5623 (gnus-set-text-properties (point-min) (point-max) nil)
5625 (set-window-configuration winconf)
5627 (set-window-start (get-buffer-window buf) start)
5628 (set-window-point (get-buffer-window buf) (point)))
5629 (gnus-summary-show-article))
5631 (defun gnus-article-edit-exit ()
5632 "Exit the article editing without updating."
5634 (when (or (not (buffer-modified-p))
5635 (yes-or-no-p "Article modified; kill anyway? "))
5636 (let ((curbuf (current-buffer))
5638 (window-start (window-start)))
5640 (if (gnus-buffer-live-p gnus-original-article-buffer)
5641 (insert-buffer gnus-original-article-buffer))
5642 (let ((winconf gnus-prev-winconf))
5643 (kill-all-local-variables)
5645 (set-window-configuration winconf)
5646 ;; Tippy-toe some to make sure that point remains where it was.
5647 (save-current-buffer
5649 (set-window-start (get-buffer-window (current-buffer)) window-start)
5651 (gnus-summary-show-article)))
5653 (defun gnus-article-edit-full-stops ()
5654 "Interactively repair spacing at end of sentences."
5657 (goto-char (point-min))
5658 (search-forward-regexp "^$" nil t)
5659 (let ((case-fold-search nil))
5660 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5663 ;;; Article highlights
5666 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5668 ;;; Internal Variables:
5670 (defcustom gnus-button-url-regexp
5671 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5672 "\\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:]]\\)"
5673 "\\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\\)\\)")
5674 "Regular expression that matches URLs."
5675 :group 'gnus-article-buttons
5678 (defcustom gnus-button-valid-fqdn-regexp
5679 message-valid-fqdn-regexp
5680 "Regular expression that matches a valid FQDN."
5681 :group 'gnus-article-buttons
5684 (defcustom gnus-button-man-handler 'manual-entry
5685 "Function to use for displaying man pages.
5686 The function must take at least one argument with a string naming the
5688 :type '(choice (function-item :tag "Man" manual-entry)
5689 (function-item :tag "Woman" woman)
5690 (function :tag "Other"))
5691 :group 'gnus-article-buttons)
5693 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5694 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5695 If the default site is too slow, try to find a CTAN mirror, see
5696 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5697 the variable `gnus-button-handle-ctan'."
5698 :group 'gnus-article-buttons
5699 :link '(custom-manual "(gnus)Group Parameters")
5700 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5701 (const "http://tug.ctan.org/tex-archive/")
5702 (const "http://www.dante.de/CTAN/")
5703 (string :tag "Other")))
5705 (defcustom gnus-button-ctan-handler 'browse-url
5706 "Function to use for displaying CTAN links.
5707 The function must take one argument, the string naming the URL."
5708 :type '(choice (function-item :tag "Browse Url" browse-url)
5709 (function :tag "Other"))
5710 :group 'gnus-article-buttons)
5712 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5713 "Bogus strings removed from CTAN URLs."
5714 :group 'gnus-article-buttons
5715 :type '(choice (const "^/?tex-archive/\\|/")
5716 (regexp :tag "Other")))
5718 (defcustom gnus-button-ctan-directory-regexp
5720 "\\("; Cannot use `\(?: ... \)' (compatibility with Emacs 20).
5721 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5722 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5723 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5725 "Regular expression for ctan directories.
5726 It should match all directories in the top level of `gnus-ctan-url'."
5727 :group 'gnus-article-buttons
5730 (defcustom gnus-button-mid-or-mail-regexp
5731 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
5732 gnus-button-valid-fqdn-regexp
5734 "Regular expression that matches a message ID or a mail address."
5735 :group 'gnus-article-buttons
5738 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5739 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5740 Strings like this can be either a message ID or a mail address. If it is one
5741 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5742 message ID or a mail address, respectively. If this variable is set to the
5743 symbol `ask', always query the user what do do. If it is a function, this
5744 function will be called with the string as it's only argument. The function
5745 must return `mid', `mail', `invalid' or `ask'."
5746 :group 'gnus-article-buttons
5747 :type '(choice (function-item :tag "Heuristic function"
5748 gnus-button-mid-or-mail-heuristic)
5753 (defcustom gnus-button-mid-or-mail-heuristic-alist
5754 '((-10.0 . ".+\\$.+@")
5757 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5758 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5759 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5760 (-1.0 . "^[^a-z]+@")
5762 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5763 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5764 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5765 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5768 (-1.0 . "^[0-9][0-9]")
5770 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5771 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5772 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5773 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5775 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5776 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5779 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5781 ;; compensation for TDMA dated mail addresses:
5782 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5784 (-20.0 . "\\.fsf@") ;; Gnus
5787 (-20.0 . "_-_") ;; Subject change in thread
5789 (-20.0 . "\\.ln@") ;; leafnode
5790 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5791 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5793 ;; (5.0 . "") ;; $local_part_len <= 7
5794 (10.0 . "^[^0-9]+@")
5795 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5796 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5799 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5801 (0.5 . "^[A-Z][a-z]")
5802 (0.5 . "^[A-Z][a-z][a-z]")
5803 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5804 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5805 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5807 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5808 address. The REGEXP is processed with `case-fold-search' set to nil."
5809 :group 'gnus-article-buttons
5810 :type '(repeat (cons (number :tag "Rate")
5811 (regexp :tag "Regexp"))))
5813 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5814 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5815 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5816 address, `ask' if unsure and `invalid' if the string is invalid."
5817 (let ((case-fold-search nil)
5818 (list gnus-button-mid-or-mail-heuristic-alist)
5819 (result 0) rate regexp lpartlen elem)
5821 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5822 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5823 ;; Certain special cases...
5826 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$" "\\|"
5827 "^[0-9]+\.[0-9]+\@compuserve")
5829 (gnus-message 8 "`%s' is a known mail address.")
5830 (setq result 'mail))
5831 (when (string-match "@.*@\\| " mid-or-mail)
5832 (gnus-message 8 "`%s' is invalid.")
5833 (setq result 'invalid))
5834 ;; Nothing more to do, if result is not a number here...
5835 (when (numberp result)
5837 (setq elem (car list)
5841 (when (string-match regexp mid-or-mail)
5842 (setq result (+ result rate))
5844 9 "`%s' matched `%s', rate `%s', result `%s'."
5845 mid-or-mail regexp rate result)))
5846 (when (<= lpartlen 7)
5847 (setq result (+ result 5.0))
5848 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
5849 mid-or-mail result))
5850 (when (>= lpartlen 12)
5851 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
5853 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
5854 ;; Long local part should contain realname if e-mail address,
5855 ;; too many digits: message-id.
5856 ;; $score -= 5.0 + 0.1 * $local_part_len;
5857 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
5858 (setq result (+ result rate))
5860 9 "Many digits in `%s', rate `%s', result `%s'."
5861 mid-or-mail rate result))
5862 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
5864 ;; Too few vowels [^aeiouy]{4,}.*\@
5865 (setq result (+ result -5.0))
5867 9 "Few vowels in `%s', rate `%s', result `%s'."
5868 mid-or-mail -5.0 result))
5870 (setq result (+ result 5.0))
5872 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
5873 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
5875 ;; Maybe we should make this a customizable alist: (condition . 'result)
5876 ((< result -10.0) 'mid)
5877 ((> result 10.0) 'mail)
5880 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5881 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
5882 (url-mid (concat "news" ":" mid-or-mail))
5883 (url-mailto (concat "mailto" ":" mid-or-mail)))
5884 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5885 (when (fboundp pref)
5887 ;; get rid of surrounding angles...
5889 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
5890 (if (or (eq 'mid guessed) (eq 'mail guessed))
5894 (save-window-excursion
5895 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5898 (cond ((eq pref 'mid)
5899 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
5900 (gnus-button-handle-news url-mid))
5902 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
5903 (gnus-url-mailto url-mailto))
5904 (t (gnus-message 3 "Invalid string.")))))
5906 (defun gnus-button-handle-custom (url)
5907 "Follow a Custom URL."
5908 (customize-apropos (gnus-url-unhex-string url)))
5910 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5912 ;; FIXME: Maybe we should merge some of the functions that do quite similar
5915 (defun gnus-button-handle-describe-function (url)
5916 "Call `describe-function' when pushing the corresponding URL button."
5919 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5921 (defun gnus-button-handle-describe-variable (url)
5922 "Call `describe-variable' when pushing the corresponding URL button."
5925 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5927 (defun gnus-button-handle-symbol (url)
5928 "Display help on variable or function.
5929 Calls `describe-variable' or `describe-function'."
5930 (let ((sym (intern url)))
5932 ((fboundp sym) (describe-function sym))
5933 ((boundp sym) (describe-variable sym))
5934 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
5936 (defun gnus-button-handle-describe-key (url)
5937 "Call `describe-key' when pushing the corresponding URL button."
5939 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5940 (keys (ignore-errors (eval `(kbd ,key-string)))))
5943 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5945 (defun gnus-button-handle-apropos (url)
5946 "Call `apropos' when pushing the corresponding URL button."
5947 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5949 (defun gnus-button-handle-apropos-command (url)
5950 "Call `apropos' when pushing the corresponding URL button."
5952 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5954 (defun gnus-button-handle-apropos-variable (url)
5955 "Call `apropos' when pushing the corresponding URL button."
5957 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5958 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5960 (defun gnus-button-handle-apropos-documentation (url)
5961 "Call `apropos' when pushing the corresponding URL button."
5963 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
5964 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5966 (defun gnus-button-handle-library (url)
5967 "Call `locate-library' when pushing the corresponding URL button."
5968 (gnus-message 9 "url=`%s'" url)
5969 (let* ((lib (locate-library url))
5970 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
5972 (gnus-message 1 "Cannot locale library `%s'." url)
5973 (find-file-read-only file))))
5975 (defun gnus-button-handle-ctan (url)
5976 "Call `browse-url' when pushing a CTAN URL button."
5978 gnus-button-ctan-handler
5981 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
5983 (defcustom gnus-button-tex-level 5
5984 "*Integer that says how many TeX-related buttons Gnus will show.
5985 The higher the number, the more buttons will appear and the more false
5986 positives are possible. Note that you can set this variable local to
5987 specific groups. Setting it higher in TeX groups is probably a good idea.
5988 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5989 how to set variables in specific groups."
5990 :group 'gnus-article-buttons
5991 :link '(custom-manual "(gnus)Group Parameters")
5994 (defcustom gnus-button-man-level 5
5995 "*Integer that says how many man-related buttons Gnus will show.
5996 The higher the number, the more buttons will appear and the more false
5997 positives are possible. Note that you can set this variable local to
5998 specific groups. Setting it higher in Unix groups is probably a good idea.
5999 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6000 how to set variables in specific groups."
6001 :group 'gnus-article-buttons
6002 :link '(custom-manual "(gnus)Group Parameters")
6005 (defcustom gnus-button-emacs-level 5
6006 "*Integer that says how many emacs-related buttons Gnus will show.
6007 The higher the number, the more buttons will appear and the more false
6008 positives are possible. Note that you can set this variable local to
6009 specific groups. Setting it higher in Emacs or Gnus related groups is
6010 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6011 `gnus-parameters' on how to set variables in specific groups."
6012 :group 'gnus-article-buttons
6013 :link '(custom-manual "(gnus)Group Parameters")
6016 (defcustom gnus-button-message-level 5
6017 "*Integer that says how many buttons for news or mail messages will appear.
6018 The higher the number, the more buttons will appear and the more false
6019 positives are possible."
6020 ;; mail addresses, MIDs, URLs for news, ...
6021 :group 'gnus-article-buttons
6024 (defcustom gnus-button-browse-level 5
6025 "*Integer that says how many buttons for browsing will appear.
6026 The higher the number, the more buttons will appear and the more false
6027 positives are possible."
6028 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6029 :group 'gnus-article-buttons
6032 (defcustom gnus-button-alist
6033 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6034 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6035 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6036 gnus-button-handle-news 2)
6037 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6038 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6039 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6040 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6041 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6042 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6043 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6044 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6045 ("mailto:\\([-a-z.@_+0-9%=?]+\\)"
6046 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6047 ("\\bmailto:\\([^ \n\t]+\\)"
6048 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6050 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6051 gnus-button-ctan-directory-regexp
6052 "[^][>)!;:,'\n\t ]+\\)")
6053 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6054 ((concat "\\btex-archive/\\("
6055 gnus-button-ctan-directory-regexp
6056 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6057 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6060 gnus-button-ctan-directory-regexp
6061 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6062 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6063 ;; This is info (home-grown style) <info://foo/bar+baz>
6064 ("\\binfo://\\([^'\">\n\t ]+\\)"
6065 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6066 ;; Info GNOME style <info:foo#bar_baz>
6067 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6068 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6069 ;; Info KDE style <info:(foo)bar baz>
6070 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6071 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6072 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6073 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6074 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6075 ;; Info links like `C-h i d m CC Mode RET'
6076 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6078 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6079 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6080 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6081 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6082 ;; Emacs help commands
6083 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6084 ;; regexp doesn't match arguments containing ` '.
6085 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6086 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6087 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6088 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6089 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6090 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6091 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6092 ;; The following entries may lead to many false positives so don't enable
6093 ;; them by default (use a high button level):
6094 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6095 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6096 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6097 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6098 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6099 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6100 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6101 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6102 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6103 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6104 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6105 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6106 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6107 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6108 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6109 ;; Unlike the other regexps we really have to require quoting
6110 ;; here to determine where it ends.
6111 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6112 ;; This is how URLs _should_ be embedded in text (RFC 1738)...
6113 ("<URL: *\\([^<>]*\\)>"
6114 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6116 (gnus-button-url-regexp
6117 0 (>= gnus-button-browse-level 0) browse-url 0)
6119 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6120 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6121 gnus-button-handle-man 1)
6122 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6123 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6124 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6125 gnus-button-handle-man 1)
6126 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6127 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6128 ("\\b\\([a-z][-+_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6129 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6130 ;; MID or mail: To avoid too many false positives we don't try to catch
6131 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6132 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6133 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6134 ;; so that non-ambiguous entries (see above) match first.
6135 (gnus-button-mid-or-mail-regexp
6136 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6137 "*Alist of regexps matching buttons in article bodies.
6139 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6140 REGEXP: is the string (case insensitive) matching text around the button (can
6141 also be Lisp expression evaluating to a string),
6142 BUTTON: is the number of the regexp grouping actually matching the button,
6143 FORM: is a Lisp expression which must eval to true for the button to
6145 CALLBACK: is the function to call when the user push this button, and each
6146 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6148 CALLBACK can also be a variable, in that case the value of that
6149 variable it the real callback function."
6150 :group 'gnus-article-buttons
6151 :type '(repeat (list (choice regexp variable sexp)
6152 (integer :tag "Button")
6154 (function :tag "Callback")
6157 (integer :tag "Regexp group")))))
6159 (defcustom gnus-header-button-alist
6160 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6161 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6162 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6163 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6164 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6165 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6166 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6167 0 (>= gnus-button-browse-level 0) browse-url 0)
6168 ("^Subject:" gnus-button-url-regexp
6169 0 (>= gnus-button-browse-level 0) browse-url 0)
6170 ("^[^:]+:" gnus-button-url-regexp
6171 0 (>= gnus-button-browse-level 0) browse-url 0)
6172 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)"
6173 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6174 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6175 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6176 "*Alist of headers and regexps to match buttons in article heads.
6178 This alist is very similar to `gnus-button-alist', except that each
6179 alist has an additional HEADER element first in each entry:
6181 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6183 HEADER is a regexp to match a header. For a fuller explanation, see
6184 `gnus-button-alist'."
6185 :group 'gnus-article-buttons
6186 :group 'gnus-article-headers
6187 :type '(repeat (list (regexp :tag "Header")
6188 (choice regexp variable)
6189 (integer :tag "Button")
6191 (function :tag "Callback")
6194 (integer :tag "Regexp group")))))
6196 (defvar gnus-button-regexp nil)
6197 (defvar gnus-button-marker-list nil)
6198 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6200 (defvar gnus-button-last nil)
6201 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6205 (defun gnus-article-push-button (event)
6206 "Check text under the mouse pointer for a callback function.
6207 If the text under the mouse pointer has a `gnus-callback' property,
6208 call it with the value of the `gnus-data' text property."
6210 (set-buffer (window-buffer (posn-window (event-start event))))
6211 (let* ((pos (posn-point (event-start event)))
6212 (data (get-text-property pos 'gnus-data))
6213 (fun (get-text-property pos 'gnus-callback)))
6216 (funcall fun data))))
6218 (defun gnus-article-press-button ()
6219 "Check text at point for a callback function.
6220 If the text at point has a `gnus-callback' property,
6221 call it with the value of the `gnus-data' text property."
6223 (let ((data (get-text-property (point) 'gnus-data))
6224 (fun (get-text-property (point) 'gnus-callback)))
6226 (funcall fun data))))
6228 (defun gnus-article-highlight (&optional force)
6229 "Highlight current article.
6230 This function calls `gnus-article-highlight-headers',
6231 `gnus-article-highlight-citation',
6232 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6233 do the highlighting. See the documentation for those functions."
6234 (interactive (list 'force))
6235 (gnus-article-highlight-headers)
6236 (gnus-article-highlight-citation force)
6237 (gnus-article-highlight-signature)
6238 (gnus-article-add-buttons force)
6239 (gnus-article-add-buttons-to-head))
6241 (defun gnus-article-highlight-some (&optional force)
6242 "Highlight current article.
6243 This function calls `gnus-article-highlight-headers',
6244 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6245 do the highlighting. See the documentation for those functions."
6246 (interactive (list 'force))
6247 (gnus-article-highlight-headers)
6248 (gnus-article-highlight-signature)
6249 (gnus-article-add-buttons))
6251 (defun gnus-article-highlight-headers ()
6252 "Highlight article headers as specified by `gnus-header-face-alist'."
6255 (set-buffer gnus-article-buffer)
6257 (let ((alist gnus-header-face-alist)
6258 (buffer-read-only nil)
6259 (case-fold-search t)
6260 (inhibit-point-motion-hooks t)
6261 entry regexp header-face field-face from hpoints fpoints)
6262 (article-narrow-to-head)
6263 (while (setq entry (pop alist))
6264 (goto-char (point-min))
6265 (setq regexp (concat "^\\("
6266 (if (string-equal "" (nth 0 entry))
6270 header-face (nth 1 entry)
6271 field-face (nth 2 entry))
6272 (while (and (re-search-forward regexp nil t)
6276 (unless (search-forward ":" nil t)
6278 (when (and header-face
6279 (not (memq (point) hpoints)))
6280 (push (point) hpoints)
6281 (gnus-put-text-property from (point) 'face header-face))
6282 (when (and field-face
6283 (not (memq (setq from (point)) fpoints)))
6285 (if (re-search-forward "^[^ \t]" nil t)
6287 (goto-char (point-max)))
6288 (gnus-put-text-property from (point) 'face field-face))))))))
6290 (defun gnus-article-highlight-signature ()
6291 "Highlight the signature in an article.
6292 It does this by highlighting everything after
6293 `gnus-signature-separator' using `gnus-signature-face'."
6296 (set-buffer gnus-article-buffer)
6297 (let ((buffer-read-only nil)
6298 (inhibit-point-motion-hooks t))
6300 (when (and gnus-signature-face
6301 (gnus-article-narrow-to-signature))
6302 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6303 'face gnus-signature-face)
6305 (gnus-article-search-signature)
6306 (let ((start (match-beginning 0))
6307 (end (set-marker (make-marker) (1+ (match-end 0)))))
6308 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6311 (defun gnus-button-in-region-p (b e prop)
6312 "Say whether PROP exists in the region."
6313 (text-property-not-all b e prop nil))
6315 (defun gnus-article-add-buttons (&optional force)
6316 "Find external references in the article and make buttons of them.
6317 \"External references\" are things like Message-IDs and URLs, as
6318 specified by `gnus-button-alist'."
6319 (interactive (list 'force))
6321 (set-buffer gnus-article-buffer)
6322 (let ((buffer-read-only nil)
6323 (inhibit-point-motion-hooks t)
6324 (case-fold-search t)
6325 (alist gnus-button-alist)
6327 ;; Remove all old markers.
6328 (let (marker entry new-list)
6329 (while (setq marker (pop gnus-button-marker-list))
6330 (if (or (< marker (point-min)) (>= marker (point-max)))
6331 (push marker new-list)
6333 (when (setq entry (gnus-button-entry))
6334 (put-text-property (match-beginning (nth 1 entry))
6335 (match-end (nth 1 entry))
6336 'gnus-callback nil))
6337 (set-marker marker nil)))
6338 (setq gnus-button-marker-list new-list))
6339 ;; We skip the headers.
6342 (while (setq entry (pop alist))
6343 (setq regexp (eval (car entry)))
6345 (while (re-search-forward regexp nil t)
6346 (let* ((start (and entry (match-beginning (nth 1 entry))))
6347 (end (and entry (match-end (nth 1 entry))))
6348 (from (match-beginning 0)))
6349 (when (and (or (eq t (nth 2 entry))
6350 (eval (nth 2 entry)))
6351 (not (gnus-button-in-region-p
6352 start end 'gnus-callback)))
6353 ;; That optional form returned non-nil, so we add the
6355 (gnus-article-add-button
6356 start end 'gnus-button-push
6357 (car (push (set-marker (make-marker) from)
6358 gnus-button-marker-list))))))))))
6360 ;; Add buttons to the head of an article.
6361 (defun gnus-article-add-buttons-to-head ()
6362 "Add buttons to the head of the article."
6365 (set-buffer gnus-article-buffer)
6367 (let ((buffer-read-only nil)
6368 (inhibit-point-motion-hooks t)
6369 (case-fold-search t)
6370 (alist gnus-header-button-alist)
6372 (article-narrow-to-head)
6374 ;; Each alist entry.
6375 (setq entry (car alist)
6377 (goto-char (point-min))
6378 (while (re-search-forward (car entry) nil t)
6379 ;; Each header matching the entry.
6380 (setq beg (match-beginning 0))
6381 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6382 (match-beginning 0))
6385 (while (re-search-forward (eval (nth 1 entry)) end t)
6386 ;; Each match within a header.
6387 (let* ((entry (cdr entry))
6388 (start (match-beginning (nth 1 entry)))
6389 (end (match-end (nth 1 entry)))
6390 (form (nth 2 entry)))
6391 (goto-char (match-end 0))
6393 (gnus-article-add-button
6394 start end (nth 3 entry)
6395 (buffer-substring (match-beginning (nth 4 entry))
6396 (match-end (nth 4 entry)))))))
6397 (goto-char end)))))))
6399 ;;; External functions:
6401 (defun gnus-article-add-button (from to fun &optional data)
6402 "Create a button between FROM and TO with callback FUN and data DATA."
6403 (when gnus-article-button-face
6404 (gnus-overlay-put (gnus-make-overlay from to)
6405 'face gnus-article-button-face))
6406 (gnus-add-text-properties
6408 (nconc (and gnus-article-mouse-face
6409 (list gnus-mouse-face-prop gnus-article-mouse-face))
6410 (list 'gnus-callback fun)
6411 (and data (list 'gnus-data data))))
6412 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6413 :button-keymap gnus-widget-button-keymap))
6415 ;;; Internal functions:
6417 (defun gnus-article-set-globals ()
6419 (set-buffer gnus-summary-buffer)
6420 (gnus-set-global-variables)))
6422 (defun gnus-signature-toggle (end)
6424 (set-buffer gnus-article-buffer)
6425 (let ((buffer-read-only nil)
6426 (inhibit-point-motion-hooks t))
6427 (if (text-property-any end (point-max) 'article-type 'signature)
6429 (gnus-delete-wash-type 'signature)
6430 (gnus-remove-text-properties-when
6431 'article-type 'signature end (point-max)
6432 (cons 'article-type (cons 'signature
6433 gnus-hidden-properties))))
6434 (gnus-add-wash-type 'signature)
6435 (gnus-add-text-properties-when
6436 'article-type nil end (point-max)
6437 (cons 'article-type (cons 'signature
6438 gnus-hidden-properties)))))
6439 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6440 (gnus-set-mode-line 'article))))
6442 (defun gnus-button-entry ()
6443 ;; Return the first entry in `gnus-button-alist' matching this place.
6444 (let ((alist gnus-button-alist)
6447 (setq entry (pop alist))
6448 (if (looking-at (eval (car entry)))
6453 (defun gnus-button-push (marker)
6454 ;; Push button starting at MARKER.
6457 (let* ((entry (gnus-button-entry))
6458 (inhibit-point-motion-hooks t)
6460 (args (mapcar (lambda (group)
6461 (let ((string (match-string group)))
6462 (gnus-set-text-properties
6463 0 (length string) nil string)
6470 (fboundp (symbol-value fun)))
6471 (apply (symbol-value fun) args))
6473 (gnus-message 1 "You must define `%S' to use this button"
6474 (cons fun args)))))))
6476 (defun gnus-parse-news-url (url)
6477 (let (scheme server group message-id articles)
6480 (goto-char (point-min))
6481 (when (looking-at "\\([A-Za-z]+\\):")
6482 (setq scheme (match-string 1))
6483 (goto-char (match-end 0)))
6484 (when (looking-at "//\\([^/]+\\)/")
6485 (setq server (match-string 1))
6486 (goto-char (match-end 0)))
6489 ((looking-at "\\(.*@.*\\)")
6490 (setq message-id (match-string 1)))
6491 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6492 (setq group (match-string 1)
6493 articles (split-string (match-string 2) "-")))
6494 ((looking-at "\\([^/]+\\)/?")
6495 (setq group (match-string 1)))
6497 (error "Unknown news URL syntax"))))
6498 (list scheme server group message-id articles)))
6500 (defun gnus-button-handle-news (url)
6502 (destructuring-bind (scheme server group message-id articles)
6503 (gnus-parse-news-url url)
6507 (set-buffer gnus-summary-buffer)
6509 (let ((gnus-refer-article-method (list (list 'nntp server))))
6510 (gnus-summary-refer-article message-id))
6511 (gnus-summary-refer-article message-id))))
6513 (gnus-button-fetch-group url)))))
6515 (defun gnus-button-handle-man (url)
6517 (funcall gnus-button-man-handler url))
6519 (defun gnus-button-handle-info-url (url)
6520 "Fetch an info URL."
6521 (setq url (mm-subst-char-in-string ?+ ?\ url))
6523 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6524 (gnus-info-find-node
6525 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6527 ")" (gnus-url-unhex-string (match-string 2 url)))))
6528 ((string-match "([^)\"]+)[^\"]+" url)
6530 (gnus-replace-in-string
6531 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6532 (gnus-info-find-node url))
6533 (t (error "Can't parse %s" url))))
6535 (defun gnus-button-handle-info-url-gnome (url)
6536 "Fetch GNOME style info URL."
6537 (setq url (mm-subst-char-in-string ?_ ?\ url))
6538 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6539 (gnus-info-find-node
6541 (gnus-url-unhex-string
6542 (match-string 1 url))
6544 (or (gnus-url-unhex-string
6545 (match-string 2 url))
6547 (error "Can't parse %s" url)))
6549 (defun gnus-button-handle-info-url-kde (url)
6550 "Fetch KDE style info URL."
6551 (gnus-info-find-node (gnus-url-unhex-string url)))
6553 (defun gnus-button-handle-info-keystrokes (url)
6554 "Call `info' when pushing the corresponding URL button."
6555 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6560 (defun gnus-button-message-id (message-id)
6563 (set-buffer gnus-summary-buffer)
6564 (gnus-summary-refer-article message-id)))
6566 (defun gnus-button-fetch-group (address)
6567 "Fetch GROUP specified by ADDRESS."
6568 (if (not (string-match "[:/]" address))
6569 ;; This is just a simple group url.
6570 (gnus-group-read-ephemeral-group address gnus-select-method)
6573 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6575 (error "Can't parse %s" address)
6576 (gnus-group-read-ephemeral-group
6577 (match-string 4 address)
6578 `(nntp ,(match-string 1 address)
6579 (nntp-address ,(match-string 1 address))
6580 (nntp-port-number ,(if (match-end 3)
6581 (match-string 3 address)
6584 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6586 (defun gnus-url-parse-query-string (query &optional downcase)
6587 (let (retval pairs cur key val)
6588 (setq pairs (split-string query "&"))
6590 (setq cur (car pairs)
6592 (if (not (string-match "=" cur))
6594 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6595 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6597 (setq key (downcase key)))
6598 (setq cur (assoc key retval))
6600 (setcdr cur (cons val (cdr cur)))
6601 (setq retval (cons (list key val) retval)))))
6604 (defun gnus-url-mailto (url)
6605 ;; Send mail to someone
6606 (when (string-match "mailto:/*\\(.*\\)" url)
6607 (setq url (substring url (match-beginning 1) nil)))
6608 (let (to args subject func)
6609 (if (string-match (regexp-quote "?") url)
6610 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6611 args (gnus-url-parse-query-string
6612 (substring url (match-end 0) nil) t))
6613 (setq to (gnus-url-unhex-string url)))
6614 (setq args (cons (list "to" to) args)
6615 subject (cdr-safe (assoc "subject" args)))
6618 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6621 (message-position-on-field (caar args)))
6622 (insert (mapconcat 'identity (cdar args) ", "))
6623 (setq args (cdr args)))
6626 (message-goto-subject))))
6628 (defun gnus-button-embedded-url (address)
6629 "Activate ADDRESS with `browse-url'."
6630 (browse-url (gnus-strip-whitespace address)))
6632 ;;; Next/prev buttons in the article buffer.
6634 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6635 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6637 (defvar gnus-prev-page-map
6638 (let ((map (make-sparse-keymap)))
6639 (unless (>= emacs-major-version 21)
6640 ;; XEmacs doesn't care.
6641 (set-keymap-parent map gnus-article-mode-map))
6642 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6643 (define-key map "\r" 'gnus-button-prev-page)
6646 (defun gnus-insert-prev-page-button ()
6648 (buffer-read-only nil))
6650 gnus-prev-page-line-format nil
6651 `(,@(gnus-local-map-property gnus-prev-page-map)
6653 gnus-callback gnus-article-button-prev-page
6654 article-type annotation))
6655 (widget-convert-button
6657 ;; Exclude a newline.
6660 :action 'gnus-button-prev-page
6661 :button-keymap gnus-prev-page-map)))
6663 (defvar gnus-prev-page-map
6664 (let ((map (make-sparse-keymap)))
6665 (unless (>= emacs-major-version 21)
6666 ;; XEmacs doesn't care.
6667 (set-keymap-parent map gnus-article-mode-map))
6668 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6669 (define-key map "\r" 'gnus-button-prev-page)
6672 (defvar gnus-next-page-map
6673 (let ((map (make-sparse-keymap)))
6674 (unless (>= emacs-major-version 21)
6675 ;; XEmacs doesn't care.
6676 (set-keymap-parent map gnus-article-mode-map))
6677 (define-key map gnus-mouse-2 'gnus-button-next-page)
6678 (define-key map "\r" 'gnus-button-next-page)
6681 (defun gnus-button-next-page (&optional args more-args)
6682 "Go to the next page."
6684 (let ((win (selected-window)))
6685 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6686 (gnus-article-next-page)
6687 (select-window win)))
6689 (defun gnus-button-prev-page (&optional args more-args)
6690 "Go to the prev page."
6692 (let ((win (selected-window)))
6693 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6694 (gnus-article-prev-page)
6695 (select-window win)))
6697 (defun gnus-insert-next-page-button ()
6699 (buffer-read-only nil))
6700 (gnus-eval-format gnus-next-page-line-format nil
6701 `(,@(gnus-local-map-property gnus-next-page-map)
6703 gnus-callback gnus-article-button-next-page
6704 article-type annotation))
6705 (widget-convert-button
6707 ;; Exclude a newline.
6710 :action 'gnus-button-next-page
6711 :button-keymap gnus-next-page-map)))
6713 (defun gnus-article-button-next-page (arg)
6714 "Go to the next page."
6716 (let ((win (selected-window)))
6717 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6718 (gnus-article-next-page)
6719 (select-window win)))
6721 (defun gnus-article-button-prev-page (arg)
6722 "Go to the prev page."
6724 (let ((win (selected-window)))
6725 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6726 (gnus-article-prev-page)
6727 (select-window win)))
6729 (defvar gnus-decode-header-methods
6730 '(mail-decode-encoded-word-region)
6731 "List of methods used to decode headers.
6733 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6734 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6735 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6736 whose names match REGEXP.
6739 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6740 mail-decode-encoded-word-region
6741 (\"chinese\" . rfc1843-decode-region))
6744 (defvar gnus-decode-header-methods-cache nil)
6746 (defun gnus-multi-decode-header (start end)
6747 "Apply the functions from `gnus-encoded-word-methods' that match."
6748 (unless (and gnus-decode-header-methods-cache
6749 (eq gnus-newsgroup-name
6750 (car gnus-decode-header-methods-cache)))
6751 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6754 (nconc gnus-decode-header-methods-cache (list x))
6755 (if (and gnus-newsgroup-name
6756 (string-match (car x) gnus-newsgroup-name))
6757 (nconc gnus-decode-header-methods-cache
6759 gnus-decode-header-methods))
6760 (let ((xlist gnus-decode-header-methods-cache))
6763 (narrow-to-region start end)
6765 (funcall (pop xlist) (point-min) (point-max))))))
6768 ;;; Treatment top-level handling.
6771 (defun gnus-treat-article (condition &optional part-number total-parts type)
6772 (let ((length (- (point-max) (point-min)))
6773 (alist gnus-treatment-function-alist)
6774 (article-goto-body-goes-to-point-min-p t)
6778 (let ((list gnus-article-treat-types))
6780 (when (string-match (pop list) type)
6781 (throw 'found t)))))))
6782 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6784 (gnus-run-hooks 'gnus-part-display-hook)
6785 (dolist (elem alist)
6788 (when (gnus-buffer-live-p gnus-summary-buffer)
6789 (set-buffer gnus-summary-buffer))
6790 (symbol-value (car elem))))
6791 (when (and (or (consp val)
6793 (gnus-treat-predicate val)
6794 (or (not (get (car elem) 'highlight))
6797 (funcall (cadr elem)))))))
6799 ;; Dynamic variables.
6801 (defvar part-number)
6802 (defvar total-parts)
6807 (defun gnus-treat-predicate (val)
6814 (stringp (car val)))
6815 (apply 'gnus-or (mapcar `(lambda (s)
6816 (string-match s ,(or gnus-newsgroup-name "")))
6819 (let ((pred (pop val)))
6822 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6824 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6826 (not (gnus-treat-predicate (car val))))
6828 (equal (car val) type))
6830 (error "%S is not a valid predicate" pred)))))
6836 (eq part-number total-parts))
6840 (error "%S is not a valid value" val))))
6842 (defun gnus-article-encrypt-body (protocol &optional n)
6843 "Encrypt the article body."
6846 (or gnus-article-encrypt-protocol
6847 (completing-read "Encrypt protocol: "
6848 gnus-article-encrypt-protocol-alist
6850 current-prefix-arg))
6851 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6853 (error (format "Can't find the encrypt protocol %s" protocol)))
6854 (if (member gnus-newsgroup-name '("nndraft:delayed"
6857 (error "Can't encrypt the article in group %s"
6858 gnus-newsgroup-name))
6859 (gnus-summary-iterate n
6861 (set-buffer gnus-summary-buffer)
6862 (let ((mail-parse-charset gnus-newsgroup-charset)
6863 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6864 (summary-buffer gnus-summary-buffer)
6866 (gnus-set-global-variables)
6867 (when (gnus-group-read-only-p)
6868 (error "The current newsgroup does not support article encrypt"))
6869 (gnus-summary-show-article t)
6871 (or (mail-header-references gnus-current-headers) ""))
6872 (set-buffer gnus-article-buffer)
6873 (let* ((buffer-read-only nil)
6875 (mapcar (lambda (field)
6876 (and (save-restriction
6877 (message-narrow-to-head)
6878 (goto-char (point-min))
6879 (search-forward field nil t))
6881 (message-narrow-to-field)
6883 (delete-region (point-min) (point-max))
6885 '("Content-Type:" "Content-Transfer-Encoding:"
6886 "Content-Disposition:"))))
6887 (message-narrow-to-head)
6888 (message-remove-header "MIME-Version")
6889 (goto-char (point-max))
6890 (setq point (point))
6891 (insert (apply 'concat headers))
6893 (narrow-to-region point (point-max))
6894 (let ((message-options message-options))
6895 (message-options-set 'message-sender user-mail-address)
6896 (message-options-set 'message-recipients user-mail-address)
6897 (message-options-set 'message-sign-encrypt 'not)
6899 (goto-char (point-min))
6900 (insert "MIME-Version: 1.0\n")
6902 (gnus-summary-edit-article-done
6903 references nil summary-buffer t))
6904 (when gnus-keep-backlog
6905 (gnus-backlog-remove-article
6906 (car gnus-article-current) (cdr gnus-article-current)))
6908 (when (get-buffer gnus-original-article-buffer)
6909 (set-buffer gnus-original-article-buffer)
6910 (setq gnus-original-article nil)))
6911 (when gnus-use-cache
6912 (gnus-cache-update-article
6913 (car gnus-article-current) (cdr gnus-article-current))))))))
6915 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6916 "The following specs can be used:
6917 %t The security MIME type
6920 %D Details if button is pressed")
6922 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6923 "The following specs can be used:
6924 %t The security MIME type
6927 %D Details if button is pressed")
6929 (defvar gnus-mime-security-button-line-format-alist
6930 '((?t gnus-tmp-type ?s)
6931 (?i gnus-tmp-info ?s)
6932 (?d gnus-tmp-details ?s)
6933 (?D gnus-tmp-pressed-details ?s)))
6935 (defvar gnus-mime-security-button-map
6936 (let ((map (make-sparse-keymap)))
6937 (unless (>= (string-to-number emacs-version) 21)
6938 (set-keymap-parent map gnus-article-mode-map))
6939 (define-key map gnus-mouse-2 'gnus-article-push-button)
6940 (define-key map "\r" 'gnus-article-press-button)
6943 (defvar gnus-mime-security-details-buffer nil)
6945 (defvar gnus-mime-security-button-pressed nil)
6947 (defvar gnus-mime-security-show-details-inline t
6948 "If non-nil, show details in the article buffer.")
6950 (defun gnus-mime-security-verify-or-decrypt (handle)
6951 (mm-remove-parts (cdr handle))
6952 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6953 point buffer-read-only)
6955 (goto-char (car region)))
6957 (narrow-to-region (point) (point))
6958 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6959 (let* ((mm-verify-option 'known)
6960 (mm-decrypt-option 'known)
6961 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6962 (unless (eq nparts (cdr handle))
6963 (mm-destroy-parts (cdr handle))
6964 (setcdr handle nparts))))
6965 (setq point (point))
6966 (gnus-mime-display-security handle)
6967 (goto-char (point-max)))
6969 (delete-region (point) (cdr region))
6970 (set-marker (car region) nil)
6971 (set-marker (cdr region) nil))
6974 (defun gnus-mime-security-show-details (handle)
6975 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6977 (gnus-message 5 "No details.")
6978 (if gnus-mime-security-show-details-inline
6979 (let ((gnus-mime-security-button-pressed
6980 (not (get-text-property (point) 'gnus-mime-details)))
6981 (gnus-mime-security-button-line-format
6982 (get-text-property (point) 'gnus-line-format))
6985 (while (eq (get-text-property (point) 'gnus-line-format)
6986 gnus-mime-security-button-line-format)
6990 (narrow-to-region (point) (point))
6991 (gnus-insert-mime-security-button handle))
6992 (delete-region (point)
6993 (or (text-property-not-all
6996 gnus-mime-security-button-line-format)
6999 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7000 (with-current-buffer gnus-mime-security-details-buffer
7003 (setq gnus-mime-security-details-buffer
7004 (gnus-get-buffer-create "*MIME Security Details*")))
7005 (with-current-buffer gnus-mime-security-details-buffer
7007 (goto-char (point-min)))
7008 (pop-to-buffer gnus-mime-security-details-buffer)))))
7010 (defun gnus-mime-security-press-button (handle)
7012 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7013 (gnus-mime-security-show-details handle)
7014 (gnus-mime-security-verify-or-decrypt handle))))
7016 (defun gnus-insert-mime-security-button (handle &optional displayed)
7017 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7020 (or (nth 2 (assoc protocol mm-verify-function-alist))
7021 (nth 2 (assoc protocol mm-decrypt-function-alist))
7023 (if (equal (car handle) "multipart/signed")
7024 " Signed" " Encrypted")
7027 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7030 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7031 gnus-tmp-pressed-details
7033 (setq gnus-tmp-details
7034 (if gnus-tmp-details
7035 (concat "\n" gnus-tmp-details)
7037 (setq gnus-tmp-pressed-details
7038 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7043 gnus-mime-security-button-line-format
7044 gnus-mime-security-button-line-format-alist
7045 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7046 gnus-callback gnus-mime-security-press-button
7047 gnus-line-format ,gnus-mime-security-button-line-format
7048 gnus-mime-details ,gnus-mime-security-button-pressed
7049 article-type annotation
7052 ;; Exclude a newline.
7055 (widget-convert-button
7058 :action 'gnus-widget-press-button
7059 :button-keymap gnus-mime-security-button-map
7061 (lambda (widget/window &optional overlay pos)
7062 ;; Needed to properly clear the message due to a bug in
7063 ;; wid-edit (XEmacs only).
7064 (when (boundp 'help-echo-owns-message)
7065 (setq help-echo-owns-message t))
7068 (aref gnus-mouse-2 0))))))
7070 (defun gnus-mime-display-security (handle)
7072 (narrow-to-region (point) (point))
7073 (unless (gnus-unbuttonized-mime-type-p (car handle))
7074 (gnus-insert-mime-security-button handle))
7075 (gnus-mime-display-mixed (cdr handle))
7078 (unless (gnus-unbuttonized-mime-type-p (car handle))
7079 (let ((gnus-mime-security-button-line-format
7080 gnus-mime-security-button-end-line-format))
7081 (gnus-insert-mime-security-button handle)))
7082 (mm-set-handle-multipart-parameter
7084 (cons (set-marker (make-marker) (point-min))
7085 (set-marker (make-marker) (point-max))))))
7091 (run-hooks 'gnus-art-load-hook)
7093 ;;; gnus-art.el ends here