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)
49 (autoload 'ansi-color-apply-on-region "ansi-color")
51 (defgroup gnus-article nil
53 :link '(custom-manual "(gnus)The Article Buffer")
56 (defgroup gnus-article-treat nil
57 "Treating article parts."
58 :link '(custom-manual "(gnus)Article Hiding")
61 (defgroup gnus-article-hiding nil
62 "Hiding article parts."
63 :link '(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-highlight nil
67 "Article highlighting."
68 :link '(custom-manual "(gnus)Article Highlighting")
72 (defgroup gnus-article-signature nil
74 :link '(custom-manual "(gnus)Article Signature")
77 (defgroup gnus-article-headers nil
79 :link '(custom-manual "(gnus)Hiding Headers")
82 (defgroup gnus-article-washing nil
83 "Special commands on articles."
84 :link '(custom-manual "(gnus)Article Washing")
87 (defgroup gnus-article-emphasis nil
88 "Fontisizing articles."
89 :link '(custom-manual "(gnus)Article Fontisizing")
92 (defgroup gnus-article-saving nil
94 :link '(custom-manual "(gnus)Saving Articles")
97 (defgroup gnus-article-mime nil
98 "Worshiping the MIME wonder."
99 :link '(custom-manual "(gnus)Using MIME")
100 :group 'gnus-article)
102 (defgroup gnus-article-buttons nil
103 "Pushable buttons in the article buffer."
104 :link '(custom-manual "(gnus)Article Buttons")
105 :group 'gnus-article)
107 (defgroup gnus-article-various nil
108 "Other article options."
109 :link '(custom-manual "(gnus)Misc Article")
110 :group 'gnus-article)
112 (defcustom gnus-ignored-headers
115 (concat "^" header ":"))
116 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
117 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
118 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
119 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
120 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
121 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
122 "X-Attribution" "X-Originating-IP" "Delivered-To"
123 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
124 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
125 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
126 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
127 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
128 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
129 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
130 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
131 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
132 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
133 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
134 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
135 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
136 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
137 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
138 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
139 "List-[A-Za-z]+" "X-Listprocessor-Version"
140 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
141 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
142 "X-Received" "Content-length" "X-precedence"
143 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
144 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
145 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
146 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
147 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
148 "X-Content-length" "X-Posting-Agent" "Original-Received"
149 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
150 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
151 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
152 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
153 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
154 "*All headers that start with this regexp will be hidden.
155 This variable can also be a list of regexps of headers to be ignored.
156 If `gnus-visible-headers' is non-nil, this variable will be ignored."
157 :type '(choice :custom-show nil
160 :group 'gnus-article-hiding)
162 (defcustom gnus-visible-headers
163 "^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:"
164 "*All headers that do not match this regexp will be hidden.
165 This variable can also be a list of regexp of headers to remain visible.
166 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
167 :type '(repeat :value-to-internal (lambda (widget value)
168 (custom-split-regexp-maybe value))
169 :match (lambda (widget value)
171 (widget-editable-list-match widget value)))
173 :group 'gnus-article-hiding)
175 (defcustom gnus-sorted-header-list
176 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
177 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
178 "*This variable is a list of regular expressions.
179 If it is non-nil, headers that match the regular expressions will
180 be placed first in the article buffer in the sequence specified by
182 :type '(repeat regexp)
183 :group 'gnus-article-hiding)
185 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
186 "Headers that are only to be displayed if they have interesting data.
187 Possible values in this list are:
189 'empty Headers with no content.
190 'newsgroups Newsgroup identical to Gnus group.
191 'to-address To identical to To-address.
192 'to-list To identical to To-list.
193 'cc-list CC identical to To-list.
194 'followup-to Followup-to identical to Newsgroups.
195 'reply-to Reply-to identical to From.
196 'date Date less than four days old.
197 'long-to To and/or Cc longer than 1024 characters.
198 'many-to Multiple To and/or Cc."
199 :type '(set (const :tag "Headers with no content." empty)
200 (const :tag "Newsgroups identical to Gnus group." newsgroups)
201 (const :tag "To identical to To-address." to-address)
202 (const :tag "To identical to To-list." to-list)
203 (const :tag "CC identical to To-list." cc-list)
204 (const :tag "Followup-to identical to Newsgroups." followup-to)
205 (const :tag "Reply-to identical to From." reply-to)
206 (const :tag "Date less than four days old." date)
207 (const :tag "To and/or Cc longer than 1024 characters." long-to)
208 (const :tag "Multiple To and/or Cc headers." many-to))
209 :group 'gnus-article-hiding)
211 (defcustom gnus-article-skip-boring nil
212 "Skip over text that is not worth reading.
213 By default, if you set this t, then Gnus will display citations and
214 signatures, but will never scroll down to show you a page consisting
215 only of boring text. Boring text is controlled by
216 `gnus-article-boring-faces'."
218 :group 'gnus-article-hiding)
220 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
221 "Regexp matching signature separator.
222 This can also be a list of regexps. In that case, it will be checked
223 from head to tail looking for a separator. Searches will be done from
224 the end of the buffer."
225 :type '(repeat string)
226 :group 'gnus-article-signature)
228 (defcustom gnus-signature-limit nil
229 "Provide a limit to what is considered a signature.
230 If it is a number, no signature may not be longer (in characters) than
231 that number. If it is a floating point number, no signature may be
232 longer (in lines) than that number. If it is a function, the function
233 will be called without any parameters, and if it returns nil, there is
234 no signature in the buffer. If it is a string, it will be used as a
235 regexp. If it matches, the text in question is not a signature."
236 :type '(choice (integer :value 200)
238 (function :value fun)
239 (regexp :value ".*"))
240 :group 'gnus-article-signature)
242 (defcustom gnus-hidden-properties '(invisible t intangible t)
243 "Property list to use for hiding text."
245 :group 'gnus-article-hiding)
247 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
248 ;; frames in a session.
249 (defcustom gnus-article-x-face-command
250 (if (featurep 'xemacs)
251 (if (or (gnus-image-type-available-p 'xface)
252 (gnus-image-type-available-p 'pbm))
253 'gnus-display-x-face-in-from
254 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
255 (if (gnus-image-type-available-p 'pbm)
256 'gnus-display-x-face-in-from
257 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
259 "*String or function to be executed to display an X-Face header.
260 If it is a string, the command will be executed in a sub-shell
261 asynchronously. The compressed face will be piped to this command."
262 :type `(choice string
263 (function-item gnus-display-x-face-in-from)
267 :group 'gnus-article-washing)
269 (defcustom gnus-article-x-face-too-ugly nil
270 "Regexp matching posters whose face shouldn't be shown automatically."
271 :type '(choice regexp (const nil))
272 :group 'gnus-article-washing)
274 (defcustom gnus-article-banner-alist nil
275 "Banner alist for stripping.
277 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
279 :type '(repeat (cons symbol regexp))
280 :group 'gnus-article-washing)
282 (gnus-define-group-parameter
285 "Alist of regexps (to match group names) and banner."
286 :variable-group gnus-article-washing
288 '(choice :tag "Banner"
290 (const :tag "Remove signature" signature)
291 (symbol :tag "Item in `gnus-article-banner-alist'" none)
293 (const :tag "None" nil))
295 "If non-nil, specify how to remove `banners' from articles.
297 Symbol `signature' means to remove signatures delimited by
298 `gnus-signature-separator'. Any other symbol is used to look up a
299 regular expression to match the banner in `gnus-article-banner-alist'.
300 A string is used as a regular expression to match the banner
303 (defcustom gnus-article-address-banner-alist nil
304 "Alist of mail addresses and banners.
305 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
306 to match a mail address in the From: header, BANNER is one of a symbol
307 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
308 If ADDRESS matches author's mail address, it will remove things like
309 advertisements. For example:
311 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
315 (regexp :tag "Address")
316 (choice :tag "Banner" :value nil
317 (const :tag "Remove signature" signature)
318 (symbol :tag "Item in `gnus-article-banner-alist'" none)
320 (const :tag "None" nil))))
321 :group 'gnus-article-washing)
323 (defcustom gnus-emphasis-alist
325 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
330 ("_/" "/_" underline-italic)
331 ("_\\*" "\\*_" underline-bold)
332 ("\\*/" "/\\*" bold-italic)
333 ("_\\*/" "/\\*_" underline-bold-italic))))
337 (format format (car spec) (cadr spec))
338 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
340 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
341 2 3 gnus-emphasis-strikethru)
342 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
343 2 3 gnus-emphasis-underline)))
344 "*Alist that says how to fontify certain phrases.
345 Each item looks like this:
347 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
349 The first element is a regular expression to be matched. The second
350 is a number that says what regular expression grouping used to find
351 the entire emphasized word. The third is a number that says what
352 regexp grouping should be displayed and highlighted. The fourth
353 is the face used for highlighting."
354 :type '(repeat (list :value ("" 0 0 default)
356 (integer :tag "Match group")
357 (integer :tag "Emphasize group")
359 :group 'gnus-article-emphasis)
361 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
362 "A regexp to describe whitespace which should not be emphasized.
363 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
364 The former avoids underlining of leading and trailing whitespace,
365 and the latter avoids underlining any whitespace at all."
367 :group 'gnus-article-emphasis
370 (defface gnus-emphasis-bold '((t (:bold t)))
371 "Face used for displaying strong emphasized text (*word*)."
372 :group 'gnus-article-emphasis)
374 (defface gnus-emphasis-italic '((t (:italic t)))
375 "Face used for displaying italic emphasized text (/word/)."
376 :group 'gnus-article-emphasis)
378 (defface gnus-emphasis-underline '((t (:underline t)))
379 "Face used for displaying underlined emphasized text (_word_)."
380 :group 'gnus-article-emphasis)
382 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
383 "Face used for displaying underlined bold emphasized text (_*word*_)."
384 :group 'gnus-article-emphasis)
386 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
387 "Face used for displaying underlined italic emphasized text (_/word/_)."
388 :group 'gnus-article-emphasis)
390 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
391 "Face used for displaying bold italic emphasized text (/*word*/)."
392 :group 'gnus-article-emphasis)
394 (defface gnus-emphasis-underline-bold-italic
395 '((t (:bold t :italic t :underline t)))
396 "Face used for displaying underlined bold italic emphasized text.
397 Example: (_/*word*/_)."
398 :group 'gnus-article-emphasis)
400 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
401 '((t (:strikethru t)))
402 '((t (:strike-through t))))
403 "Face used for displaying strike-through text (-word-)."
404 :group 'gnus-article-emphasis)
406 (defface gnus-emphasis-highlight-words
407 '((t (:background "black" :foreground "yellow")))
408 "Face used for displaying highlighted words."
409 :group 'gnus-article-emphasis)
411 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
412 "Format for display of Date headers in article bodies.
413 See `format-time-string' for the possible values.
415 The variable can also be function, which should return a complete Date
416 header. The function is called with one argument, the time, which can
417 be fed to `format-time-string'."
418 :type '(choice string symbol)
419 :link '(custom-manual "(gnus)Article Date")
420 :group 'gnus-article-washing)
423 (autoload 'mail-extract-address-components "mail-extr"))
425 (defcustom gnus-save-all-headers t
426 "*If non-nil, don't remove any headers before saving."
427 :group 'gnus-article-saving
430 (defcustom gnus-prompt-before-saving 'always
431 "*This variable says how much prompting is to be done when saving articles.
432 If it is nil, no prompting will be done, and the articles will be
433 saved to the default files. If this variable is `always', each and
434 every article that is saved will be preceded by a prompt, even when
435 saving large batches of articles. If this variable is neither nil not
436 `always', there the user will be prompted once for a file name for
437 each invocation of the saving commands."
438 :group 'gnus-article-saving
439 :type '(choice (item always)
440 (item :tag "never" nil)
441 (sexp :tag "once" :format "%t\n" :value t)))
443 (defcustom gnus-saved-headers gnus-visible-headers
444 "Headers to keep if `gnus-save-all-headers' is nil.
445 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
446 If that variable is nil, however, all headers that match this regexp
447 will be kept while the rest will be deleted before saving."
448 :group 'gnus-article-saving
451 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
452 "A function to save articles in your favourite format.
453 The function must be interactively callable (in other words, it must
454 be an Emacs command).
456 Gnus provides the following functions:
458 * gnus-summary-save-in-rmail (Rmail format)
459 * gnus-summary-save-in-mail (Unix mail format)
460 * gnus-summary-save-in-folder (MH folder)
461 * gnus-summary-save-in-file (article format)
462 * gnus-summary-save-body-in-file (article body)
463 * gnus-summary-save-in-vm (use VM's folder format)
464 * gnus-summary-write-to-file (article format -- overwrite)."
465 :group 'gnus-article-saving
466 :type '(radio (function-item gnus-summary-save-in-rmail)
467 (function-item gnus-summary-save-in-mail)
468 (function-item gnus-summary-save-in-folder)
469 (function-item gnus-summary-save-in-file)
470 (function-item gnus-summary-save-body-in-file)
471 (function-item gnus-summary-save-in-vm)
472 (function-item gnus-summary-write-to-file)))
474 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
475 "A function generating a file name to save articles in Rmail format.
476 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
477 :group 'gnus-article-saving
480 (defcustom gnus-mail-save-name 'gnus-plain-save-name
481 "A function generating a file name to save articles in Unix mail format.
482 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
483 :group 'gnus-article-saving
486 (defcustom gnus-folder-save-name 'gnus-folder-save-name
487 "A function generating a file name to save articles in MH folder.
488 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
489 :group 'gnus-article-saving
492 (defcustom gnus-file-save-name 'gnus-numeric-save-name
493 "A function generating a file name to save articles in article format.
494 The function is called with NEWSGROUP, HEADERS, and optional
496 :group 'gnus-article-saving
499 (defcustom gnus-split-methods
500 '((gnus-article-archive-name)
501 (gnus-article-nndoc-name))
502 "*Variable used to suggest where articles are to be saved.
503 For instance, if you would like to save articles related to Gnus in
504 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
505 you could set this variable to something like:
507 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
508 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
510 This variable is an alist where the where the key is the match and the
511 value is a list of possible files to save in if the match is non-nil.
513 If the match is a string, it is used as a regexp match on the
514 article. If the match is a symbol, that symbol will be funcalled
515 from the buffer of the article to be saved with the newsgroup as the
516 parameter. If it is a list, it will be evaled in the same buffer.
518 If this form or function returns a string, this string will be used as
519 a possible file name; and if it returns a non-nil list, that list will
520 be used as possible file names."
521 :group 'gnus-article-saving
522 :type '(repeat (choice (list :value (fun) function)
523 (cons :value ("" "") regexp (repeat string))
526 (defcustom gnus-page-delimiter "^\^L"
527 "*Regexp describing what to use as article page delimiters.
528 The default value is \"^\^L\", which is a form linefeed at the
529 beginning of a line."
531 :group 'gnus-article-various)
533 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
534 "*The format specification for the article mode line.
535 See `gnus-summary-mode-line-format' for a closer description.
537 The following additional specs are available:
539 %w The article washing status.
540 %m The number of MIME parts in the article."
542 :group 'gnus-article-various)
544 (defcustom gnus-article-mode-hook nil
545 "*A hook for Gnus article mode."
547 :group 'gnus-article-various)
549 (when (featurep 'xemacs)
550 ;; Extracted from gnus-xmas-define in order to preserve user settings
551 (when (fboundp 'turn-off-scroll-in-place)
552 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
553 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
554 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
556 (defcustom gnus-article-menu-hook nil
557 "*Hook run after the creation of the article mode menu."
559 :group 'gnus-article-various)
561 (defcustom gnus-article-prepare-hook nil
562 "*A hook called after an article has been prepared in the article buffer."
564 :group 'gnus-article-various)
566 (make-obsolete-variable 'gnus-article-hide-pgp-hook
567 "This variable is obsolete in Gnus 5.10.")
569 (defcustom gnus-article-button-face 'bold
570 "Face used for highlighting buttons in the article buffer.
572 An article button is a piece of text that you can activate by pressing
573 `RET' or `mouse-2' above it."
575 :group 'gnus-article-buttons)
577 (defcustom gnus-article-mouse-face 'highlight
578 "Face used for mouse highlighting in the article buffer.
580 Article buttons will be displayed in this face when the cursor is
583 :group 'gnus-article-buttons)
585 (defcustom gnus-signature-face 'gnus-signature-face
586 "Face used for highlighting a signature in the article buffer.
587 Obsolete; use the face `gnus-signature-face' for customizations instead."
589 :group 'gnus-article-highlight
590 :group 'gnus-article-signature)
592 (defface gnus-signature-face
595 "Face used for highlighting a signature in the article buffer."
596 :group 'gnus-article-highlight
597 :group 'gnus-article-signature)
599 (defface gnus-header-from-face
602 (:foreground "spring green"))
605 (:foreground "red3"))
608 "Face used for displaying from headers."
609 :group 'gnus-article-headers
610 :group 'gnus-article-highlight)
612 (defface gnus-header-subject-face
615 (:foreground "SeaGreen3"))
618 (:foreground "red4"))
620 (:bold t :italic t)))
621 "Face used for displaying subject headers."
622 :group 'gnus-article-headers
623 :group 'gnus-article-highlight)
625 (defface gnus-header-newsgroups-face
628 (:foreground "yellow" :italic t))
631 (:foreground "MidnightBlue" :italic t))
634 "Face used for displaying newsgroups headers.
635 In the default setup this face is only used for crossposted
637 :group 'gnus-article-headers
638 :group 'gnus-article-highlight)
640 (defface gnus-header-name-face
643 (:foreground "SeaGreen"))
646 (:foreground "maroon"))
649 "Face used for displaying header names."
650 :group 'gnus-article-headers
651 :group 'gnus-article-highlight)
653 (defface gnus-header-content-face
656 (:foreground "forest green" :italic t))
659 (:foreground "indianred4" :italic t))
661 (:italic t))) "Face used for displaying header content."
662 :group 'gnus-article-headers
663 :group 'gnus-article-highlight)
665 (defcustom gnus-header-face-alist
666 '(("From" nil gnus-header-from-face)
667 ("Subject" nil gnus-header-subject-face)
668 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
669 ("" gnus-header-name-face gnus-header-content-face))
670 "*Controls highlighting of article headers.
672 An alist of the form (HEADER NAME CONTENT).
674 HEADER is a regular expression which should match the name of a
675 header and NAME and CONTENT are either face names or nil.
677 The name of each header field will be displayed using the face
678 specified by the first element in the list where HEADER matches
679 the header name and NAME is non-nil. Similarly, the content will
680 be displayed by the first non-nil matching CONTENT face."
681 :group 'gnus-article-headers
682 :group 'gnus-article-highlight
683 :type '(repeat (list (regexp :tag "Header")
685 (item :tag "skip" nil)
686 (face :value default))
687 (choice :tag "Content"
688 (item :tag "skip" nil)
689 (face :value default)))))
691 (defcustom gnus-article-decode-hook
692 '(article-decode-charset article-decode-encoded-words
693 article-decode-group-name article-decode-idna-rhs)
694 "*Hook run to decode charsets in articles."
695 :group 'gnus-article-headers
698 (defcustom gnus-display-mime-function 'gnus-display-mime
699 "Function to display MIME articles."
700 :group 'gnus-article-mime
703 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
704 "Function used to decode headers.")
706 (defvar gnus-article-dumbquotes-map
726 "Table for MS-to-Latin1 translation.")
728 (defcustom gnus-ignored-mime-types nil
729 "List of MIME types that should be ignored by Gnus."
731 :group 'gnus-article-mime
732 :type '(repeat regexp))
734 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
735 "List of MIME types that should not be given buttons when rendered inline.
736 See also `gnus-buttonized-mime-types' which may override this variable.
737 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
739 :group 'gnus-article-mime
740 :type '(repeat regexp))
742 (defcustom gnus-buttonized-mime-types nil
743 "List of MIME types that should be given buttons when rendered inline.
744 If set, this variable overrides `gnus-unbuttonized-mime-types'.
745 To see e.g. security buttons you could set this to
746 `(\"multipart/signed\")'.
747 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
749 :group 'gnus-article-mime
750 :type '(repeat regexp))
752 (defcustom gnus-inhibit-mime-unbuttonizing nil
753 "If non-nil, all MIME parts get buttons.
754 When nil (the default value), then some MIME parts do not get buttons,
755 as described by the variables `gnus-buttonized-mime-types' and
756 `gnus-unbuttonized-mime-types'."
760 (defcustom gnus-body-boundary-delimiter "_"
761 "String used to delimit header and body.
762 This variable is used by `gnus-article-treat-body-boundary' which can
763 be controlled by `gnus-treat-body-boundary'."
764 :group 'gnus-article-various
765 :type '(choice (item :tag "None" :value nil)
768 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
769 "Defines the location of the faces database.
770 For information on obtaining this database of pretty pictures, please
771 see http://www.cs.indiana.edu/picons/ftp/index.html"
772 :type '(repeat directory)
773 :link '(url-link :tag "download"
774 "http://www.cs.indiana.edu/picons/ftp/index.html")
775 :link '(custom-manual "(gnus)Picons")
778 (defun gnus-picons-installed-p ()
779 "Say whether picons are installed on your machine."
780 (let ((installed nil))
781 (dolist (database gnus-picon-databases)
782 (when (file-exists-p database)
786 (defcustom gnus-article-mime-part-function nil
787 "Function called with a MIME handle as the argument.
788 This is meant for people who want to do something automatic based
789 on parts -- for instance, adding Vcard info to a database."
790 :group 'gnus-article-mime
793 (defcustom gnus-mime-multipart-functions nil
794 "An alist of MIME types to functions to display them."
796 :group 'gnus-article-mime
799 (defcustom gnus-article-date-lapsed-new-header nil
800 "Whether the X-Sent and Date headers can coexist.
801 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
802 either replace the old \"Date:\" header (if this variable is nil), or
803 be added below it (otherwise)."
805 :group 'gnus-article-headers
808 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
809 "Function called with a MIME handle as the argument.
810 This is meant for people who want to view first matched part.
811 For `undisplayed-alternative' (default), the first undisplayed
812 part or alternative part is used. For `undisplayed', the first
813 undisplayed part is used. For a function, the first part which
814 the function return t is used. For nil, the first part is
817 :group 'gnus-article-mime
819 (item :tag "first" :value nil)
820 (item :tag "undisplayed" :value undisplayed)
821 (item :tag "undisplayed or alternative"
822 :value undisplayed-alternative)
825 (defcustom gnus-mime-action-alist
826 '(("save to file" . gnus-mime-save-part)
827 ("save and strip" . gnus-mime-save-part-and-strip)
828 ("delete part" . gnus-mime-delete-part)
829 ("display as text" . gnus-mime-inline-part)
830 ("view the part" . gnus-mime-view-part)
831 ("pipe to command" . gnus-mime-pipe-part)
832 ("toggle display" . gnus-article-press-button)
833 ("toggle display" . gnus-article-view-part-as-charset)
834 ("view as type" . gnus-mime-view-part-as-type)
835 ("view internally" . gnus-mime-view-part-internally)
836 ("view externally" . gnus-mime-view-part-externally))
837 "An alist of actions that run on the MIME attachment."
838 :group 'gnus-article-mime
839 :type '(repeat (cons (string :tag "name")
843 ;;; The treatment variables
846 (defvar gnus-part-display-hook nil
847 "Hook called on parts that are to receive treatment.")
849 (defvar gnus-article-treat-custom
850 '(choice (const :tag "Off" nil)
852 (const :tag "Header" head)
853 (const :tag "Last" last)
854 (integer :tag "Less")
855 (repeat :tag "Groups" regexp)
856 (sexp :tag "Predicate")))
858 (defvar gnus-article-treat-head-custom
859 '(choice (const :tag "Off" nil)
860 (const :tag "Header" head)))
862 (defvar gnus-article-treat-types '("text/plain")
865 (defvar gnus-inhibit-treatment nil
866 "Whether to inhibit treatment.")
868 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
869 "Highlight the signature.
870 Valid values are nil, t, `head', `last', an integer or a predicate.
871 See Info node `(gnus)Customizing Articles'."
872 :group 'gnus-article-treat
873 :link '(custom-manual "(gnus)Customizing Articles")
874 :type gnus-article-treat-custom)
875 (put 'gnus-treat-highlight-signature 'highlight t)
877 (defcustom gnus-treat-buttonize 100000
879 Valid values are nil, t, `head', `last', an integer or a predicate.
880 See Info node `(gnus)Customizing Articles'."
881 :group 'gnus-article-treat
882 :link '(custom-manual "(gnus)Customizing Articles")
883 :type gnus-article-treat-custom)
884 (put 'gnus-treat-buttonize 'highlight t)
886 (defcustom gnus-treat-buttonize-head 'head
887 "Add buttons to the head.
888 Valid values are nil, t, `head', `last', an integer or a predicate.
889 See Info node `(gnus)Customizing Articles' for details."
890 :group 'gnus-article-treat
891 :link '(custom-manual "(gnus)Customizing Articles")
892 :type gnus-article-treat-head-custom)
893 (put 'gnus-treat-buttonize-head 'highlight t)
895 (defcustom gnus-treat-emphasize
896 (and (or window-system
898 (>= (string-to-number emacs-version) 21))
901 Valid values are nil, t, `head', `last', an integer or a predicate.
902 See Info node `(gnus)Customizing Articles' for details."
903 :group 'gnus-article-treat
904 :link '(custom-manual "(gnus)Customizing Articles")
905 :type gnus-article-treat-custom)
906 (put 'gnus-treat-emphasize 'highlight t)
908 (defcustom gnus-treat-strip-cr nil
909 "Remove carriage returns.
910 Valid values are nil, t, `head', `last', an integer or a predicate.
911 See Info node `(gnus)Customizing Articles' for details."
912 :group 'gnus-article-treat
913 :link '(custom-manual "(gnus)Customizing Articles")
914 :type gnus-article-treat-custom)
916 (defcustom gnus-treat-unsplit-urls nil
917 "Remove newlines from within URLs.
918 Valid values are nil, t, `head', `last', an integer or a predicate.
919 See Info node `(gnus)Customizing Articles' for details."
920 :group 'gnus-article-treat
921 :link '(custom-manual "(gnus)Customizing Articles")
922 :type gnus-article-treat-custom)
924 (defcustom gnus-treat-leading-whitespace nil
925 "Remove leading whitespace in headers.
926 Valid values are nil, t, `head', `last', an integer or a predicate.
927 See Info node `(gnus)Customizing Articles' for details."
928 :group 'gnus-article-treat
929 :link '(custom-manual "(gnus)Customizing Articles")
930 :type gnus-article-treat-custom)
932 (defcustom gnus-treat-hide-headers 'head
934 Valid values are nil, t, `head', `last', an integer or a predicate.
935 See Info node `(gnus)Customizing Articles' for details."
936 :group 'gnus-article-treat
937 :link '(custom-manual "(gnus)Customizing Articles")
938 :type gnus-article-treat-head-custom)
940 (defcustom gnus-treat-hide-boring-headers nil
941 "Hide boring headers.
942 Valid values are nil, t, `head', `last', an integer or a predicate.
943 See Info node `(gnus)Customizing Articles' for details."
944 :group 'gnus-article-treat
945 :link '(custom-manual "(gnus)Customizing Articles")
946 :type gnus-article-treat-head-custom)
948 (defcustom gnus-treat-hide-signature nil
950 Valid values are nil, t, `head', `last', an integer or a predicate.
951 See Info node `(gnus)Customizing Articles' for details."
952 :group 'gnus-article-treat
953 :link '(custom-manual "(gnus)Customizing Articles")
954 :type gnus-article-treat-custom)
956 (defcustom gnus-treat-fill-article nil
958 Valid values are nil, t, `head', `last', an integer or a predicate.
959 See Info node `(gnus)Customizing Articles' for details."
960 :group 'gnus-article-treat
961 :link '(custom-manual "(gnus)Customizing Articles")
962 :type gnus-article-treat-custom)
964 (defcustom gnus-treat-hide-citation nil
966 Valid values are nil, t, `head', `last', an integer or a predicate.
967 See Info node `(gnus)Customizing Articles' for details."
968 :group 'gnus-article-treat
969 :link '(custom-manual "(gnus)Customizing Articles")
970 :type gnus-article-treat-custom)
972 (defcustom gnus-treat-hide-citation-maybe nil
974 Valid values are nil, t, `head', `last', an integer or a predicate.
975 See Info node `(gnus)Customizing Articles' for details."
976 :group 'gnus-article-treat
977 :link '(custom-manual "(gnus)Customizing Articles")
978 :type gnus-article-treat-custom)
980 (defcustom gnus-treat-strip-list-identifiers 'head
981 "Strip list identifiers from `gnus-list-identifiers`.
982 Valid values are nil, t, `head', `last', an integer or a predicate.
983 See Info node `(gnus)Customizing Articles' for details."
985 :group 'gnus-article-treat
986 :link '(custom-manual "(gnus)Customizing Articles")
987 :type gnus-article-treat-custom)
989 (make-obsolete-variable 'gnus-treat-strip-pgp
990 "This option is obsolete in Gnus 5.10.")
992 (defcustom gnus-treat-strip-pem nil
993 "Strip PEM signatures.
994 Valid values are nil, t, `head', `last', an integer or a predicate.
995 See Info node `(gnus)Customizing Articles' for details."
996 :group 'gnus-article-treat
997 :link '(custom-manual "(gnus)Customizing Articles")
998 :type gnus-article-treat-custom)
1000 (defcustom gnus-treat-strip-banner t
1001 "Strip banners from articles.
1002 The banner to be stripped is specified in the `banner' group parameter.
1003 Valid values are nil, t, `head', `last', an integer or a predicate.
1004 See Info node `(gnus)Customizing Articles' for details."
1005 :group 'gnus-article-treat
1006 :link '(custom-manual "(gnus)Customizing Articles")
1007 :type gnus-article-treat-custom)
1009 (defcustom gnus-treat-highlight-headers 'head
1010 "Highlight the headers.
1011 Valid values are nil, t, `head', `last', an integer or a predicate.
1012 See Info node `(gnus)Customizing Articles' for details."
1013 :group 'gnus-article-treat
1014 :link '(custom-manual "(gnus)Customizing Articles")
1015 :type gnus-article-treat-head-custom)
1016 (put 'gnus-treat-highlight-headers 'highlight t)
1018 (defcustom gnus-treat-highlight-citation t
1019 "Highlight cited text.
1020 Valid values are nil, t, `head', `last', an integer or a predicate.
1021 See Info node `(gnus)Customizing Articles' for details."
1022 :group 'gnus-article-treat
1023 :link '(custom-manual "(gnus)Customizing Articles")
1024 :type gnus-article-treat-custom)
1025 (put 'gnus-treat-highlight-citation 'highlight t)
1027 (defcustom gnus-treat-date-ut nil
1028 "Display the Date in UT (GMT).
1029 Valid values are nil, t, `head', `last', an integer or a predicate.
1030 See Info node `(gnus)Customizing Articles' for details."
1031 :group 'gnus-article-treat
1032 :link '(custom-manual "(gnus)Customizing Articles")
1033 :type gnus-article-treat-head-custom)
1035 (defcustom gnus-treat-date-local nil
1036 "Display the Date in the local timezone.
1037 Valid values are nil, t, `head', `last', an integer or a predicate.
1038 See Info node `(gnus)Customizing Articles' for details."
1039 :group 'gnus-article-treat
1040 :link '(custom-manual "(gnus)Customizing Articles")
1041 :type gnus-article-treat-head-custom)
1043 (defcustom gnus-treat-date-english nil
1044 "Display the Date in a format that can be read aloud in English.
1045 Valid values are nil, t, `head', `last', an integer or a predicate.
1046 See Info node `(gnus)Customizing Articles' for details."
1047 :group 'gnus-article-treat
1048 :link '(custom-manual "(gnus)Customizing Articles")
1049 :type gnus-article-treat-head-custom)
1051 (defcustom gnus-treat-date-lapsed nil
1052 "Display the Date header in a way that says how much time has elapsed.
1053 Valid values are nil, t, `head', `last', an integer or a predicate.
1054 See Info node `(gnus)Customizing Articles' for details."
1055 :group 'gnus-article-treat
1056 :link '(custom-manual "(gnus)Customizing Articles")
1057 :type gnus-article-treat-head-custom)
1059 (defcustom gnus-treat-date-original nil
1060 "Display the date in the original timezone.
1061 Valid values are nil, t, `head', `last', an integer or a predicate.
1062 See Info node `(gnus)Customizing Articles' for details."
1063 :group 'gnus-article-treat
1064 :link '(custom-manual "(gnus)Customizing Articles")
1065 :type gnus-article-treat-head-custom)
1067 (defcustom gnus-treat-date-iso8601 nil
1068 "Display the date in the ISO8601 format.
1069 Valid values are nil, t, `head', `last', an integer or a predicate.
1070 See Info node `(gnus)Customizing Articles' for details."
1072 :group 'gnus-article-treat
1073 :link '(custom-manual "(gnus)Customizing Articles")
1074 :type gnus-article-treat-head-custom)
1076 (defcustom gnus-treat-date-user-defined nil
1077 "Display the date in a user-defined format.
1078 The format is defined by the `gnus-article-time-format' variable.
1079 Valid values are nil, t, `head', `last', an integer or a predicate.
1080 See Info node `(gnus)Customizing Articles' for details."
1081 :group 'gnus-article-treat
1082 :link '(custom-manual "(gnus)Customizing Articles")
1083 :type gnus-article-treat-head-custom)
1085 (defcustom gnus-treat-strip-headers-in-body t
1086 "Strip the X-No-Archive header line from the beginning of the body.
1087 Valid values are nil, t, `head', `last', an integer or a predicate.
1088 See Info node `(gnus)Customizing Articles' for details."
1090 :group 'gnus-article-treat
1091 :link '(custom-manual "(gnus)Customizing Articles")
1092 :type gnus-article-treat-custom)
1094 (defcustom gnus-treat-strip-trailing-blank-lines nil
1095 "Strip trailing blank lines.
1096 Valid values are nil, t, `head', `last', an integer or a predicate.
1097 See Info node `(gnus)Customizing Articles' for details."
1098 :group 'gnus-article-treat
1099 :link '(custom-manual "(gnus)Customizing Articles")
1100 :type gnus-article-treat-custom)
1102 (defcustom gnus-treat-strip-leading-blank-lines nil
1103 "Strip leading blank lines.
1104 Valid values are nil, t, `head', `last', an integer or a predicate.
1105 See Info node `(gnus)Customizing Articles' for details."
1106 :group 'gnus-article-treat
1107 :link '(custom-manual "(gnus)Customizing Articles")
1108 :type gnus-article-treat-custom)
1110 (defcustom gnus-treat-strip-multiple-blank-lines nil
1111 "Strip multiple blank lines.
1112 Valid values are nil, t, `head', `last', an integer or a predicate.
1113 See Info node `(gnus)Customizing Articles' for details."
1114 :group 'gnus-article-treat
1115 :link '(custom-manual "(gnus)Customizing Articles")
1116 :type gnus-article-treat-custom)
1118 (defcustom gnus-treat-unfold-headers 'head
1119 "Unfold folded header lines.
1120 Valid values are nil, t, `head', `last', an integer or a predicate.
1121 See Info node `(gnus)Customizing Articles' for details."
1122 :group 'gnus-article-treat
1123 :link '(custom-manual "(gnus)Customizing Articles")
1124 :type gnus-article-treat-custom)
1126 (defcustom gnus-treat-fold-headers nil
1128 Valid values are nil, t, `head', `last', an integer or a predicate.
1129 See Info node `(gnus)Customizing Articles' for details."
1130 :group 'gnus-article-treat
1131 :link '(custom-manual "(gnus)Customizing Articles")
1132 :type gnus-article-treat-custom)
1134 (defcustom gnus-treat-fold-newsgroups 'head
1135 "Fold the Newsgroups and Followup-To headers.
1136 Valid values are nil, t, `head', `last', an integer or a predicate.
1137 See Info node `(gnus)Customizing Articles' for details."
1138 :group 'gnus-article-treat
1139 :link '(custom-manual "(gnus)Customizing Articles")
1140 :type gnus-article-treat-custom)
1142 (defcustom gnus-treat-overstrike t
1143 "Treat overstrike highlighting.
1144 Valid values are nil, t, `head', `last', an integer or a predicate.
1145 See Info node `(gnus)Customizing Articles' for details."
1146 :group 'gnus-article-treat
1147 :link '(custom-manual "(gnus)Customizing Articles")
1148 :type gnus-article-treat-custom)
1149 (put 'gnus-treat-overstrike 'highlight t)
1151 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1152 "Treat ANSI SGR control sequences.
1153 Valid values are nil, t, `head', `last', an integer or a predicate.
1154 See Info node `(gnus)Customizing Articles' for details."
1155 :group 'gnus-article-treat
1156 :link '(custom-manual "(gnus)Customizing Articles")
1157 :type gnus-article-treat-custom)
1159 (make-obsolete-variable 'gnus-treat-display-xface
1160 'gnus-treat-display-x-face)
1162 (defcustom gnus-treat-display-x-face
1163 (and (not noninteractive)
1164 (or (and (fboundp 'image-type-available-p)
1165 (image-type-available-p 'xbm)
1166 (string-match "^0x" (shell-command-to-string "uncompface"))
1167 (executable-find "icontopbm"))
1168 (and (featurep 'xemacs)
1171 "Display X-Face headers.
1172 Valid values are nil, t, `head', `last', an integer or a predicate.
1173 See Info node `(gnus)Customizing Articles' and Info node
1174 `(gnus)X-Face' for details."
1175 :group 'gnus-article-treat
1177 :link '(custom-manual "(gnus)Customizing Articles")
1178 :link '(custom-manual "(gnus)X-Face")
1179 :type gnus-article-treat-head-custom
1180 :set (lambda (symbol value)
1183 (cond ((or (boundp symbol) (get symbol 'saved-value))
1185 ((boundp 'gnus-treat-display-xface)
1187 ** gnus-treat-display-xface is an obsolete variable;\
1188 use gnus-treat-display-x-face instead")
1189 (default-value 'gnus-treat-display-xface))
1190 ((get 'gnus-treat-display-xface 'saved-value)
1192 ** gnus-treat-display-xface is an obsolete variable;\
1193 use gnus-treat-display-x-face instead")
1194 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1197 (put 'gnus-treat-display-x-face 'highlight t)
1199 (defcustom gnus-treat-display-face
1200 (and (not noninteractive)
1201 (or (and (fboundp 'image-type-available-p)
1202 (image-type-available-p 'png))
1203 (and (featurep 'xemacs)
1206 "Display Face headers.
1207 Valid values are nil, t, `head', `last', an integer or a predicate.
1208 See Info node `(gnus)Customizing Articles' and Info node
1209 `(gnus)X-Face' for details."
1210 :group 'gnus-article-treat
1212 :link '(custom-manual "(gnus)Customizing Articles")
1213 :link '(custom-manual "(gnus)X-Face")
1214 :type gnus-article-treat-head-custom)
1215 (put 'gnus-treat-display-face 'highlight t)
1217 (defcustom gnus-treat-display-smileys
1218 (if (or (and (featurep 'xemacs)
1220 (and (fboundp 'image-type-available-p)
1221 (image-type-available-p 'pbm)))
1224 Valid values are nil, t, `head', `last', an integer or a predicate.
1225 See Info node `(gnus)Customizing Articles' and Info node
1226 `(gnus)Smileys' for details."
1227 :group 'gnus-article-treat
1229 :link '(custom-manual "(gnus)Customizing Articles")
1230 :link '(custom-manual "(gnus)Smileys")
1231 :type gnus-article-treat-custom)
1232 (put 'gnus-treat-display-smileys 'highlight t)
1234 (defcustom gnus-treat-from-picon
1235 (if (and (gnus-image-type-available-p 'xpm)
1236 (gnus-picons-installed-p))
1238 "Display picons in the From header.
1239 Valid values are nil, t, `head', `last', an integer or a predicate.
1240 See Info node `(gnus)Customizing Articles' and Info node
1241 `(gnus)Picons' for details."
1242 :group 'gnus-article-treat
1244 :link '(custom-manual "(gnus)Customizing Articles")
1245 :link '(custom-manual "(gnus)Picons")
1246 :type gnus-article-treat-head-custom)
1247 (put 'gnus-treat-from-picon 'highlight t)
1249 (defcustom gnus-treat-mail-picon
1250 (if (and (gnus-image-type-available-p 'xpm)
1251 (gnus-picons-installed-p))
1253 "Display picons in To and Cc headers.
1254 Valid values are nil, t, `head', `last', an integer or a predicate.
1255 See Info node `(gnus)Customizing Articles' and Info node
1256 `(gnus)Picons' for details."
1257 :group 'gnus-article-treat
1259 :link '(custom-manual "(gnus)Customizing Articles")
1260 :link '(custom-manual "(gnus)Picons")
1261 :type gnus-article-treat-head-custom)
1262 (put 'gnus-treat-mail-picon 'highlight t)
1264 (defcustom gnus-treat-newsgroups-picon
1265 (if (and (gnus-image-type-available-p 'xpm)
1266 (gnus-picons-installed-p))
1268 "Display picons in the Newsgroups and Followup-To headers.
1269 Valid values are nil, t, `head', `last', an integer or a predicate.
1270 See Info node `(gnus)Customizing Articles' and Info node
1271 `(gnus)Picons' for details."
1272 :group 'gnus-article-treat
1274 :link '(custom-manual "(gnus)Customizing Articles")
1275 :link '(custom-manual "(gnus)Picons")
1276 :type gnus-article-treat-head-custom)
1277 (put 'gnus-treat-newsgroups-picon 'highlight t)
1279 (defcustom gnus-treat-body-boundary
1280 (if (or gnus-treat-newsgroups-picon
1281 gnus-treat-mail-picon
1282 gnus-treat-from-picon)
1284 "Draw a boundary at the end of the headers.
1285 Valid values are nil and `head'.
1286 See Info node `(gnus)Customizing Articles' for details."
1288 :group 'gnus-article-treat
1289 :link '(custom-manual "(gnus)Customizing Articles")
1290 :type gnus-article-treat-head-custom)
1292 (defcustom gnus-treat-capitalize-sentences nil
1293 "Capitalize sentence-starting words.
1294 Valid values are nil, t, `head', `last', an integer or a predicate.
1295 See Info node `(gnus)Customizing Articles' for details."
1297 :group 'gnus-article-treat
1298 :link '(custom-manual "(gnus)Customizing Articles")
1299 :type gnus-article-treat-custom)
1301 (defcustom gnus-treat-wash-html nil
1303 Valid values are nil, t, `head', `last', an integer or a predicate.
1304 See Info node `(gnus)Customizing Articles' for details."
1305 :group 'gnus-article-treat
1306 :link '(custom-manual "(gnus)Customizing Articles")
1307 :type gnus-article-treat-custom)
1309 (defcustom gnus-treat-fill-long-lines nil
1311 Valid values are nil, t, `head', `last', an integer or a predicate.
1312 See Info node `(gnus)Customizing Articles' for details."
1313 :group 'gnus-article-treat
1314 :link '(custom-manual "(gnus)Customizing Articles")
1315 :type gnus-article-treat-custom)
1317 (defcustom gnus-treat-play-sounds nil
1319 Valid values are nil, t, `head', `last', an integer or a predicate.
1320 See Info node `(gnus)Customizing Articles' for details."
1322 :group 'gnus-article-treat
1323 :link '(custom-manual "(gnus)Customizing Articles")
1324 :type gnus-article-treat-custom)
1326 (defcustom gnus-treat-translate nil
1327 "Translate articles from one language to another.
1328 Valid values are nil, t, `head', `last', an integer or a predicate.
1329 See Info node `(gnus)Customizing Articles' for details."
1331 :group 'gnus-article-treat
1332 :link '(custom-manual "(gnus)Customizing Articles")
1333 :type gnus-article-treat-custom)
1335 (defcustom gnus-treat-x-pgp-sig nil
1337 To automatically treat X-PGP-Sig, set it to head.
1338 Valid values are nil, t, `head', `last', an integer or a predicate.
1339 See Info node `(gnus)Customizing Articles' for details."
1340 :group 'gnus-article-treat
1341 :group 'mime-security
1342 :link '(custom-manual "(gnus)Customizing Articles")
1343 :type gnus-article-treat-custom)
1345 (defvar gnus-article-encrypt-protocol-alist
1346 '(("PGP" . mml2015-self-encrypt)))
1348 ;; Set to nil if more than one protocol added to
1349 ;; gnus-article-encrypt-protocol-alist.
1350 (defcustom gnus-article-encrypt-protocol "PGP"
1351 "The protocol used for encrypt articles.
1352 It is a string, such as \"PGP\". If nil, ask user."
1354 :group 'mime-security)
1356 (defvar gnus-article-wash-function nil
1357 "Function used for converting HTML into text.")
1359 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1360 (mm-coding-system-p 'utf-8)
1361 (executable-find idna-program))
1362 "Whether IDNA decoding of headers is used when viewing messages.
1363 This requires GNU Libidn, and by default only enabled if it is found."
1364 :group 'gnus-article-headers
1367 (defcustom gnus-article-over-scroll nil
1368 "If non-nil, allow scrolling the article buffer even when there no more text."
1369 :group 'gnus-article
1372 ;;; Internal variables
1374 (defvar gnus-english-month-names
1375 '("January" "February" "March" "April" "May" "June" "July" "August"
1376 "September" "October" "November" "December"))
1378 (defvar article-goto-body-goes-to-point-min-p nil)
1379 (defvar gnus-article-wash-types nil)
1380 (defvar gnus-article-emphasis-alist nil)
1381 (defvar gnus-article-image-alist nil)
1383 (defvar gnus-article-mime-handle-alist-1 nil)
1384 (defvar gnus-treatment-function-alist
1385 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1386 (gnus-treat-strip-banner gnus-article-strip-banner)
1387 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1388 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1389 (gnus-treat-buttonize gnus-article-add-buttons)
1390 (gnus-treat-fill-article gnus-article-fill-cited-article)
1391 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1392 (gnus-treat-strip-cr gnus-article-remove-cr)
1393 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1394 (gnus-treat-date-ut gnus-article-date-ut)
1395 (gnus-treat-date-local gnus-article-date-local)
1396 (gnus-treat-date-english gnus-article-date-english)
1397 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1398 (gnus-treat-date-original gnus-article-date-original)
1399 (gnus-treat-date-user-defined gnus-article-date-user)
1400 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1401 (gnus-treat-display-x-face gnus-article-display-x-face)
1402 (gnus-treat-display-face gnus-article-display-face)
1403 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1404 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1405 (gnus-treat-hide-signature gnus-article-hide-signature)
1406 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1407 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1408 (gnus-treat-strip-pem gnus-article-hide-pem)
1409 (gnus-treat-from-picon gnus-treat-from-picon)
1410 (gnus-treat-mail-picon gnus-treat-mail-picon)
1411 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1412 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1413 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1414 (gnus-treat-strip-trailing-blank-lines
1415 gnus-article-remove-trailing-blank-lines)
1416 (gnus-treat-strip-leading-blank-lines
1417 gnus-article-strip-leading-blank-lines)
1418 (gnus-treat-strip-multiple-blank-lines
1419 gnus-article-strip-multiple-blank-lines)
1420 (gnus-treat-overstrike gnus-article-treat-overstrike)
1421 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1422 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1423 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1424 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1425 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1426 (gnus-treat-display-smileys gnus-treat-smiley)
1427 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1428 (gnus-treat-wash-html gnus-article-wash-html)
1429 (gnus-treat-emphasize gnus-article-emphasize)
1430 (gnus-treat-hide-citation gnus-article-hide-citation)
1431 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1432 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1433 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1434 (gnus-treat-play-sounds gnus-earcon-display)))
1436 (defvar gnus-article-mime-handle-alist nil)
1437 (defvar article-lapsed-timer nil)
1438 (defvar gnus-article-current-summary nil)
1440 (defvar gnus-article-mode-syntax-table
1441 (let ((table (copy-syntax-table text-mode-syntax-table)))
1442 ;; This causes the citation match run O(2^n).
1443 ;; (modify-syntax-entry ?- "w" table)
1444 (modify-syntax-entry ?> ")<" table)
1445 (modify-syntax-entry ?< "(>" table)
1446 ;; make M-. in article buffers work for `foo' strings
1447 (modify-syntax-entry ?' " " table)
1448 (modify-syntax-entry ?` " " table)
1450 "Syntax table used in article mode buffers.
1451 Initialized from `text-mode-syntax-table.")
1453 (defvar gnus-save-article-buffer nil)
1455 (defvar gnus-article-mode-line-format-alist
1456 (nconc '((?w (gnus-article-wash-status) ?s)
1457 (?m (gnus-article-mime-part-status) ?s))
1458 gnus-summary-mode-line-format-alist))
1460 (defvar gnus-number-of-articles-to-be-saved nil)
1462 (defvar gnus-inhibit-hiding nil)
1464 ;;; Macros for dealing with the article buffer.
1466 (defmacro gnus-with-article-headers (&rest forms)
1468 (set-buffer gnus-article-buffer)
1470 (let ((buffer-read-only nil)
1471 (inhibit-point-motion-hooks t)
1472 (case-fold-search t))
1473 (article-narrow-to-head)
1476 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1477 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1479 (defmacro gnus-with-article-buffer (&rest forms)
1481 (set-buffer gnus-article-buffer)
1482 (let ((buffer-read-only nil))
1485 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1486 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1488 (defun gnus-article-goto-header (header)
1489 "Go to HEADER, which is a regular expression."
1490 (re-search-forward (concat "^\\(" header "\\):") nil t))
1492 (defsubst gnus-article-hide-text (b e props)
1493 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1494 (gnus-add-text-properties-when 'article-type nil b e props)
1495 (when (memq 'intangible props)
1497 (max (1- b) (point-min))
1498 b 'intangible (cddr (memq 'intangible props)))))
1500 (defsubst gnus-article-unhide-text (b e)
1501 "Remove hidden text properties from region between B and E."
1502 (remove-text-properties b e gnus-hidden-properties)
1503 (when (memq 'intangible gnus-hidden-properties)
1504 (put-text-property (max (1- b) (point-min))
1505 b 'intangible nil)))
1507 (defun gnus-article-hide-text-type (b e type)
1508 "Hide text of TYPE between B and E."
1509 (gnus-add-wash-type type)
1510 (gnus-article-hide-text
1511 b e (cons 'article-type (cons type gnus-hidden-properties))))
1513 (defun gnus-article-unhide-text-type (b e type)
1514 "Unhide text of TYPE between B and E."
1515 (gnus-delete-wash-type type)
1516 (remove-text-properties
1517 b e (cons 'article-type (cons type gnus-hidden-properties)))
1518 (when (memq 'intangible gnus-hidden-properties)
1519 (put-text-property (max (1- b) (point-min))
1520 b 'intangible nil)))
1522 (defun gnus-article-hide-text-of-type (type)
1523 "Hide text of TYPE in the current buffer."
1525 (let ((b (point-min))
1527 (while (setq b (text-property-any b e 'article-type type))
1528 (add-text-properties b (incf b) gnus-hidden-properties)))))
1530 (defun gnus-article-delete-text-of-type (type)
1531 "Delete text of TYPE in the current buffer."
1533 (let ((b (point-min)))
1534 (while (setq b (text-property-any b (point-max) 'article-type type))
1536 b (or (text-property-not-all b (point-max) 'article-type type)
1539 (defun gnus-article-delete-invisible-text ()
1540 "Delete all invisible text in the current buffer."
1542 (let ((b (point-min)))
1543 (while (setq b (text-property-any b (point-max) 'invisible t))
1545 b (or (text-property-not-all b (point-max) 'invisible t)
1548 (defun gnus-article-text-type-exists-p (type)
1549 "Say whether any text of type TYPE exists in the buffer."
1550 (text-property-any (point-min) (point-max) 'article-type type))
1552 (defsubst gnus-article-header-rank ()
1553 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1554 (let ((list gnus-sorted-header-list)
1557 (if (looking-at (car list))
1559 (setq list (cdr list))
1563 (defun article-hide-headers (&optional arg delete)
1564 "Hide unwanted headers and possibly sort them as well."
1566 ;; This function might be inhibited.
1567 (unless gnus-inhibit-hiding
1570 (let ((buffer-read-only nil)
1571 (case-fold-search t)
1572 (max (1+ (length gnus-sorted-header-list)))
1573 (ignored (when (not gnus-visible-headers)
1574 (cond ((stringp gnus-ignored-headers)
1575 gnus-ignored-headers)
1576 ((listp gnus-ignored-headers)
1577 (mapconcat 'identity gnus-ignored-headers
1580 (cond ((stringp gnus-visible-headers)
1581 gnus-visible-headers)
1582 ((and gnus-visible-headers
1583 (listp gnus-visible-headers))
1584 (mapconcat 'identity gnus-visible-headers "\\|"))))
1585 (inhibit-point-motion-hooks t)
1587 ;; First we narrow to just the headers.
1588 (article-narrow-to-head)
1589 ;; Hide any "From " lines at the beginning of (mail) articles.
1590 (while (looking-at "From ")
1593 (delete-region (point-min) (point)))
1594 ;; Then treat the rest of the header lines.
1595 ;; Then we use the two regular expressions
1596 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1597 ;; select which header lines is to remain visible in the
1599 (while (re-search-forward "^[^ \t:]*:" nil t)
1601 ;; Mark the rank of the header.
1603 (point) (1+ (point)) 'message-rank
1604 (if (or (and visible (looking-at visible))
1606 (not (looking-at ignored))))
1607 (gnus-article-header-rank)
1610 (message-sort-headers-1)
1611 (when (setq beg (text-property-any
1612 (point-min) (point-max) 'message-rank (+ 2 max)))
1613 ;; We delete the unwanted headers.
1614 (gnus-add-wash-type 'headers)
1615 (add-text-properties (point-min) (+ 5 (point-min))
1616 '(article-type headers dummy-invisible t))
1617 (delete-region beg (point-max))))))))
1619 (defun article-hide-boring-headers (&optional arg)
1620 "Toggle hiding of headers that aren't very interesting.
1621 If given a negative prefix, always show; if given a positive prefix,
1623 (interactive (gnus-article-hidden-arg))
1624 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1625 (not gnus-show-all-headers))
1628 (let ((buffer-read-only nil)
1629 (list gnus-boring-article-headers)
1630 (inhibit-point-motion-hooks t)
1632 (article-narrow-to-head)
1634 (setq elem (pop list))
1635 (goto-char (point-min))
1637 ;; Hide empty headers.
1639 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1641 (gnus-article-hide-text-type
1645 (if (re-search-forward "^[^ \t]" nil t)
1649 ;; Hide boring Newsgroups header.
1650 ((eq elem 'newsgroups)
1651 (when (gnus-string-equal
1652 (gnus-fetch-field "newsgroups")
1653 (gnus-group-real-name
1654 (if (boundp 'gnus-newsgroup-name)
1657 (gnus-article-hide-header "newsgroups")))
1658 ((eq elem 'to-address)
1659 (let ((to (message-fetch-field "to"))
1661 (gnus-parameter-to-address
1662 (if (boundp 'gnus-newsgroup-name)
1663 gnus-newsgroup-name ""))))
1664 (when (and to to-address
1667 ;; only one address in To
1668 (nth 1 (mail-extract-address-components to))
1670 (gnus-article-hide-header "to"))))
1672 (let ((to (message-fetch-field "to"))
1674 (gnus-parameter-to-list
1675 (if (boundp 'gnus-newsgroup-name)
1676 gnus-newsgroup-name ""))))
1677 (when (and to to-list
1680 ;; only one address in To
1681 (nth 1 (mail-extract-address-components to))
1683 (gnus-article-hide-header "to"))))
1685 (let ((cc (message-fetch-field "cc"))
1687 (gnus-parameter-to-list
1688 (if (boundp 'gnus-newsgroup-name)
1689 gnus-newsgroup-name ""))))
1690 (when (and cc to-list
1693 ;; only one address in CC
1694 (nth 1 (mail-extract-address-components cc))
1696 (gnus-article-hide-header "cc"))))
1697 ((eq elem 'followup-to)
1698 (when (gnus-string-equal
1699 (message-fetch-field "followup-to")
1700 (message-fetch-field "newsgroups"))
1701 (gnus-article-hide-header "followup-to")))
1702 ((eq elem 'reply-to)
1703 (if (gnus-group-find-parameter
1704 gnus-newsgroup-name 'broken-reply-to)
1705 (gnus-article-hide-header "reply-to")
1706 (let ((from (message-fetch-field "from"))
1707 (reply-to (message-fetch-field "reply-to")))
1714 (lambda (x) (downcase (cadr x)))
1715 (mail-extract-address-components from t))
1718 (lambda (x) (downcase (cadr x)))
1719 (mail-extract-address-components reply-to t))
1721 (gnus-article-hide-header "reply-to")))))
1723 (let ((date (message-fetch-field "date")))
1725 (< (days-between (current-time-string) date)
1727 (gnus-article-hide-header "date"))))
1729 (let ((to (message-fetch-field "to"))
1730 (cc (message-fetch-field "cc")))
1731 (when (> (length to) 1024)
1732 (gnus-article-hide-header "to"))
1733 (when (> (length cc) 1024)
1734 (gnus-article-hide-header "cc"))))
1738 (goto-char (point-min))
1739 (while (re-search-forward "^to:" nil t)
1740 (setq to-count (1+ to-count)))
1741 (when (> to-count 1)
1742 (while (> to-count 0)
1743 (goto-char (point-min))
1745 (re-search-forward "^to:" nil nil to-count)
1747 (narrow-to-region (point) (point-max))
1748 (gnus-article-hide-header "to"))
1749 (setq to-count (1- to-count))))
1750 (goto-char (point-min))
1751 (while (re-search-forward "^cc:" nil t)
1752 (setq cc-count (1+ cc-count)))
1753 (when (> cc-count 1)
1754 (while (> cc-count 0)
1755 (goto-char (point-min))
1757 (re-search-forward "^cc:" nil nil cc-count)
1759 (narrow-to-region (point) (point-max))
1760 (gnus-article-hide-header "cc"))
1761 (setq cc-count (1- cc-count)))))))))))))
1763 (defun gnus-article-hide-header (header)
1765 (goto-char (point-min))
1766 (when (re-search-forward (concat "^" header ":") nil t)
1767 (gnus-article-hide-text-type
1771 (if (re-search-forward "^[^ \t]" nil t)
1776 (defvar gnus-article-normalized-header-length 40
1777 "Length of normalized headers.")
1779 (defun article-normalize-headers ()
1780 "Make all header lines 40 characters long."
1782 (let ((buffer-read-only nil)
1786 (article-narrow-to-head)
1789 ((< (setq column (- (point-at-eol) (point)))
1790 gnus-article-normalized-header-length)
1792 (insert (make-string
1793 (- gnus-article-normalized-header-length column)
1795 ((> column gnus-article-normalized-header-length)
1796 (gnus-put-text-property
1798 (forward-char gnus-article-normalized-header-length)
1805 (forward-line 1))))))
1807 (defun article-treat-dumbquotes ()
1808 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1809 Note that this function guesses whether a character is a sm*rtq**t* or
1810 not, so it should only be used interactively.
1812 Sm*rtq**t*s are M****s***'s unilateral extension to the
1813 iso-8859-1 character map in an attempt to provide more quoting
1814 characters. If you see something like \\222 or \\264 where
1815 you're expecting some kind of apostrophe or quotation mark, then
1818 (article-translate-strings gnus-article-dumbquotes-map))
1820 (defun article-translate-characters (from to)
1821 "Translate all characters in the body of the article according to FROM and TO.
1822 FROM is a string of characters to translate from; to is a string of
1823 characters to translate to."
1825 (when (article-goto-body)
1826 (let ((buffer-read-only nil)
1827 (x (make-string 225 ?x))
1829 (while (< (incf i) (length x))
1832 (while (< i (length from))
1833 (aset x (aref from i) (aref to i))
1835 (translate-region (point) (point-max) x)))))
1837 (defun article-translate-strings (map)
1838 "Translate all string in the body of the article according to MAP.
1839 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1841 (when (article-goto-body)
1842 (let ((buffer-read-only nil)
1844 (while (setq elem (pop map))
1846 (while (search-forward (car elem) nil t)
1847 (replace-match (cadr elem)))))))))
1849 (defun article-treat-overstrike ()
1850 "Translate overstrikes into bold text."
1853 (when (article-goto-body)
1854 (let ((buffer-read-only nil))
1855 (while (search-forward "\b" nil t)
1856 (let ((next (char-after))
1857 (previous (char-after (- (point) 2))))
1858 ;; We do the boldification/underlining by hiding the
1859 ;; overstrikes and putting the proper text property
1863 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1864 (put-text-property (point) (1+ (point)) 'face 'bold))
1866 (gnus-article-hide-text-type
1867 (1- (point)) (1+ (point)) 'overstrike)
1869 (- (point) 2) (1- (point)) 'face 'underline))
1871 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1873 (point) (1+ (point)) 'face 'underline)))))))))
1875 (defun article-treat-ansi-sequences ()
1876 "Translate ANSI SGR control sequences into overlays or extents."
1879 (when (article-goto-body)
1880 (let ((buffer-read-only nil))
1881 (ansi-color-apply-on-region (point) (point-max))))))
1883 (defun gnus-article-treat-unfold-headers ()
1884 "Unfold folded message headers.
1885 Only the headers that fit into the current window width will be
1888 (gnus-with-article-headers
1892 (mail-header-narrow-to-field)
1893 (let ((header (buffer-string)))
1896 (goto-char (point-min))
1897 (while (re-search-forward "\n[\t ]" nil t)
1898 (replace-match " " t t)))
1899 (setq length (- (point-max) (point-min) 1)))
1900 (when (< length (window-width))
1901 (while (re-search-forward "\n[\t ]" nil t)
1902 (replace-match " " t t)))
1903 (goto-char (point-max)))))))
1905 (defun gnus-article-treat-fold-headers ()
1906 "Fold message headers."
1908 (gnus-with-article-headers
1911 (mail-header-narrow-to-field)
1912 (mail-header-fold-field)
1913 (goto-char (point-max))))))
1915 (defun gnus-treat-smiley ()
1916 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1918 (gnus-with-article-buffer
1919 (if (memq 'smiley gnus-article-wash-types)
1920 (gnus-delete-images 'smiley)
1922 (let ((images (smiley-region (point) (point-max))))
1924 (gnus-add-wash-type 'smiley)
1925 (dolist (image images)
1926 (gnus-add-image 'smiley image)))))))
1928 (defun gnus-article-remove-images ()
1929 "Remove all images from the article buffer."
1931 (gnus-with-article-buffer
1932 (dolist (elem gnus-article-image-alist)
1933 (gnus-delete-images (car elem)))))
1935 (defun gnus-article-treat-fold-newsgroups ()
1936 "Unfold folded message headers.
1937 Only the headers that fit into the current window width will be
1940 (gnus-with-article-headers
1941 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1943 (mail-header-narrow-to-field)
1944 (while (re-search-forward ", *" nil t)
1945 (replace-match ", " t t))
1946 (mail-header-fold-field)
1947 (goto-char (point-max))))))
1949 (defun gnus-article-treat-body-boundary ()
1950 "Place a boundary line at the end of the headers."
1952 (when (and gnus-body-boundary-delimiter
1953 (> (length gnus-body-boundary-delimiter) 0))
1954 (gnus-with-article-headers
1955 (goto-char (point-max))
1956 (let ((start (point)))
1957 (insert "X-Boundary: ")
1958 (gnus-add-text-properties start (point) '(invisible t intangible t))
1960 (while (>= (1- (window-width)) (length str))
1961 (setq str (concat str gnus-body-boundary-delimiter)))
1962 (substring str 0 (1- (window-width))))
1964 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1966 (defun article-fill-long-lines ()
1967 "Fill lines that are wider than the window width."
1970 (let ((buffer-read-only nil)
1971 (width (window-width (get-buffer-window (current-buffer)))))
1974 (let ((adaptive-fill-mode nil)) ;Why? -sm
1977 (when (>= (current-column) (min fill-column width))
1978 (narrow-to-region (min (1+ (point)) (point-max))
1980 (let ((goback (point-marker)))
1981 (fill-paragraph nil)
1982 (goto-char (marker-position goback)))
1984 (forward-line 1)))))))
1986 (defun article-capitalize-sentences ()
1987 "Capitalize the first word in each sentence."
1990 (let ((buffer-read-only nil)
1991 (paragraph-start "^[\n\^L]"))
1995 (forward-sentence)))))
1997 (defun article-remove-cr ()
1998 "Remove trailing CRs and then translate remaining CRs into LFs."
2001 (let ((buffer-read-only nil))
2002 (goto-char (point-min))
2003 (while (re-search-forward "\r+$" nil t)
2004 (replace-match "" t t))
2005 (goto-char (point-min))
2006 (while (search-forward "\r" nil t)
2007 (replace-match "\n" t t)))))
2009 (defun article-remove-trailing-blank-lines ()
2010 "Remove all trailing blank lines from the article."
2013 (let ((buffer-read-only nil))
2014 (goto-char (point-max))
2018 (while (and (not (bobp))
2019 (looking-at "^[ \t]*$")
2020 (not (gnus-annotation-in-region-p
2021 (point) (point-at-eol))))
2026 (defun article-display-face ()
2027 "Display any Face headers in the header."
2029 (let ((wash-face-p buffer-read-only))
2030 (gnus-with-article-headers
2031 ;; When displaying parts, this function can be called several times on
2032 ;; the same article, without any intended toggle semantic (as typing `W
2033 ;; D d' would have). So face deletion must occur only when we come from
2034 ;; an interactive command, that is when the *Article* buffer is
2036 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2037 (gnus-delete-images 'face)
2040 (when (and wash-face-p
2042 (goto-char (point-min))
2043 (not (re-search-forward "^Face:[\t ]*" nil t)))
2044 (gnus-buffer-live-p gnus-original-article-buffer))
2045 (set-buffer gnus-original-article-buffer))
2047 (mail-narrow-to-head)
2048 (while (gnus-article-goto-header "Face")
2049 (push (mail-header-field-value) faces))))
2050 (while (setq face (pop faces))
2051 (let ((png (gnus-convert-face-to-png face))
2054 (setq image (gnus-create-image png 'png t))
2055 (gnus-article-goto-header "from")
2057 (insert "From: [no `from' set]\n")
2059 (gnus-add-wash-type 'face)
2060 (gnus-add-image 'face image)
2061 (gnus-put-image image nil 'face))))))
2064 (defun article-display-x-face (&optional force)
2065 "Look for an X-Face header and display it if present."
2066 (interactive (list 'force))
2067 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2068 (gnus-with-article-headers
2069 ;; Delete the old process, if any.
2070 (when (process-status "article-x-face")
2071 (delete-process "article-x-face"))
2072 ;; See the comment in `article-display-face'.
2073 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2074 ;; We have already displayed X-Faces, so we remove them
2076 (gnus-delete-images 'xface)
2078 (let (x-faces from face)
2080 (when (and wash-face-p
2082 (goto-char (point-min))
2083 (not (re-search-forward
2084 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2085 (gnus-buffer-live-p gnus-original-article-buffer))
2086 ;; If type `W f', use gnus-original-article-buffer,
2087 ;; otherwise use the current buffer because displaying
2088 ;; RFC822 parts calls this function too.
2089 (set-buffer gnus-original-article-buffer))
2091 (mail-narrow-to-head)
2092 (while (gnus-article-goto-header "X-Face")
2093 (push (mail-header-field-value) x-faces))
2094 (setq from (message-fetch-field "from"))))
2095 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2096 ;; single external face.
2097 (when (stringp gnus-article-x-face-command)
2098 (setq x-faces (list (car x-faces))))
2099 (while (and (setq face (pop x-faces))
2100 gnus-article-x-face-command
2102 ;; Check whether this face is censored.
2103 (not gnus-article-x-face-too-ugly)
2104 (and gnus-article-x-face-too-ugly from
2105 (not (string-match gnus-article-x-face-too-ugly
2107 ;; We display the face.
2108 (cond ((stringp gnus-article-x-face-command)
2109 ;; The command is a string, so we interpret the command
2110 ;; as a, well, command, and fork it off.
2111 (let ((process-connection-type nil))
2112 (process-kill-without-query
2114 "article-x-face" nil shell-file-name
2115 shell-command-switch gnus-article-x-face-command))
2118 (process-send-region "article-x-face"
2119 (point-min) (point-max)))
2120 (process-send-eof "article-x-face")))
2121 ((functionp gnus-article-x-face-command)
2122 ;; The command is a lisp function, so we call it.
2123 (funcall gnus-article-x-face-command face))
2125 (error "%s is not a function"
2126 gnus-article-x-face-command)))))))))
2128 (defun article-decode-mime-words ()
2129 "Decode all MIME-encoded words in the article."
2132 (set-buffer gnus-article-buffer)
2133 (let ((inhibit-point-motion-hooks t)
2135 (mail-parse-charset gnus-newsgroup-charset)
2136 (mail-parse-ignored-charsets
2137 (save-excursion (set-buffer gnus-summary-buffer)
2138 gnus-newsgroup-ignored-charsets)))
2139 (mail-decode-encoded-word-region (point-min) (point-max)))))
2141 (defun article-decode-charset (&optional prompt)
2142 "Decode charset-encoded text in the article.
2143 If PROMPT (the prefix), prompt for a coding system to use."
2145 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2147 (mail-parse-charset gnus-newsgroup-charset)
2148 (mail-parse-ignored-charsets
2149 (save-excursion (condition-case nil
2150 (set-buffer gnus-summary-buffer)
2152 gnus-newsgroup-ignored-charsets))
2153 ct cte ctl charset format)
2156 (article-narrow-to-head)
2157 (setq ct (message-fetch-field "Content-Type" t)
2158 cte (message-fetch-field "Content-Transfer-Encoding" t)
2159 ctl (and ct (ignore-errors
2160 (mail-header-parse-content-type ct)))
2163 (mm-read-coding-system "Charset to decode: "))
2165 (mail-content-type-get ctl 'charset)))
2166 format (and ctl (mail-content-type-get ctl 'format)))
2168 (setq cte (mail-header-strip cte)))
2169 (if (and ctl (not (string-match "/" (car ctl))))
2171 (goto-char (point-max)))
2174 (narrow-to-region (point) (point-max))
2175 (when (and (eq mail-parse-charset 'gnus-decoded)
2176 (eq (mm-body-7-or-8) '8bit))
2177 ;; The text code could have been decoded.
2178 (setq charset mail-parse-charset))
2179 (when (and (or (not ctl)
2180 (equal (car ctl) "text/plain"))
2181 (not format)) ;; article with format will decode later.
2183 charset (and cte (intern (downcase
2184 (gnus-strip-whitespace cte))))
2187 (defun article-decode-encoded-words ()
2188 "Remove encoded-word encoding from headers."
2189 (let ((inhibit-point-motion-hooks t)
2190 (mail-parse-charset gnus-newsgroup-charset)
2191 (mail-parse-ignored-charsets
2192 (save-excursion (condition-case nil
2193 (set-buffer gnus-summary-buffer)
2195 gnus-newsgroup-ignored-charsets))
2198 (article-narrow-to-head)
2199 (funcall gnus-decode-header-function (point-min) (point-max)))))
2201 (defun article-decode-group-name ()
2202 "Decode group names in `Newsgroups:'."
2203 (let ((inhibit-point-motion-hooks t)
2205 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2206 (when (and (or gnus-group-name-charset-method-alist
2207 gnus-group-name-charset-group-alist)
2208 (gnus-buffer-live-p gnus-original-article-buffer))
2210 (article-narrow-to-head)
2211 (with-current-buffer gnus-original-article-buffer
2212 (goto-char (point-min)))
2213 (while (re-search-forward
2214 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2215 (replace-match (save-match-data
2216 (gnus-decode-newsgroups
2217 ;; XXX how to use data in article buffer?
2218 (with-current-buffer gnus-original-article-buffer
2220 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2223 gnus-newsgroup-name method))
2225 (goto-char (point-min))
2226 (with-current-buffer gnus-original-article-buffer
2227 (goto-char (point-min)))
2228 (while (re-search-forward
2229 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2230 (replace-match (save-match-data
2231 (gnus-decode-newsgroups
2232 ;; XXX how to use data in article buffer?
2233 (with-current-buffer gnus-original-article-buffer
2235 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2238 gnus-newsgroup-name method))
2241 (autoload 'idna-to-unicode "idna")
2243 (defun article-decode-idna-rhs ()
2244 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2247 (let ((inhibit-point-motion-hooks t)
2249 (article-narrow-to-head)
2250 (goto-char (point-min))
2251 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2253 (when (save-match-data
2254 (and (setq ace (match-string 1))
2256 (and (re-search-backward "^[^ \t]" nil t)
2257 (looking-at "From\\|To\\|Cc")))
2258 (save-excursion (backward-char)
2259 (message-idna-inside-rhs-p))
2260 (setq unicode (idna-to-unicode ace))))
2261 (unless (string= ace unicode)
2262 (replace-match unicode nil nil nil 1)))))))))
2264 (defun article-de-quoted-unreadable (&optional force read-charset)
2265 "Translate a quoted-printable-encoded article.
2266 If FORCE, decode the article whether it is marked as quoted-printable
2268 If READ-CHARSET, ask for a coding system."
2269 (interactive (list 'force current-prefix-arg))
2271 (let ((buffer-read-only nil) type charset)
2272 (if (gnus-buffer-live-p gnus-original-article-buffer)
2273 (with-current-buffer gnus-original-article-buffer
2275 (gnus-fetch-field "content-transfer-encoding"))
2276 (let* ((ct (gnus-fetch-field "content-type"))
2279 (mail-header-parse-content-type ct)))))
2280 (setq charset (and ctl
2281 (mail-content-type-get ctl 'charset)))
2282 (if (stringp charset)
2283 (setq charset (intern (downcase charset)))))))
2285 (setq charset (mm-read-coding-system "Charset: " charset)))
2287 (setq charset gnus-newsgroup-charset))
2289 (and type (let ((case-fold-search t))
2290 (string-match "quoted-printable" type))))
2292 (quoted-printable-decode-region
2293 (point) (point-max) (mm-charset-to-coding-system charset))))))
2295 (defun article-de-base64-unreadable (&optional force read-charset)
2296 "Translate a base64 article.
2297 If FORCE, decode the article whether it is marked as base64 not.
2298 If READ-CHARSET, ask for a coding system."
2299 (interactive (list 'force current-prefix-arg))
2301 (let ((buffer-read-only nil) type charset)
2302 (if (gnus-buffer-live-p gnus-original-article-buffer)
2303 (with-current-buffer gnus-original-article-buffer
2305 (gnus-fetch-field "content-transfer-encoding"))
2306 (let* ((ct (gnus-fetch-field "content-type"))
2309 (mail-header-parse-content-type ct)))))
2310 (setq charset (and ctl
2311 (mail-content-type-get ctl 'charset)))
2312 (if (stringp charset)
2313 (setq charset (intern (downcase charset)))))))
2315 (setq charset (mm-read-coding-system "Charset: " charset)))
2317 (setq charset gnus-newsgroup-charset))
2319 (and type (let ((case-fold-search t))
2320 (string-match "base64" type))))
2323 (narrow-to-region (point) (point-max))
2324 (base64-decode-region (point-min) (point-max))
2325 (mm-decode-coding-region
2326 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2331 (defun article-decode-HZ ()
2332 "Translate a HZ-encoded article."
2336 (let ((buffer-read-only nil))
2337 (rfc1843-decode-region (point-min) (point-max)))))
2339 (defun article-unsplit-urls ()
2340 "Remove the newlines that some other mailers insert into URLs."
2343 (let ((buffer-read-only nil))
2344 (goto-char (point-min))
2345 (while (re-search-forward
2346 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2347 (replace-match "\\1\\3" t)))
2348 (when (interactive-p)
2349 (gnus-treat-article nil))))
2352 (defun article-wash-html (&optional read-charset)
2353 "Format an HTML article.
2354 If READ-CHARSET, ask for a coding system."
2357 (let ((buffer-read-only nil)
2359 (when (gnus-buffer-live-p gnus-original-article-buffer)
2360 (with-current-buffer gnus-original-article-buffer
2361 (let* ((ct (gnus-fetch-field "content-type"))
2364 (mail-header-parse-content-type ct)))))
2365 (setq charset (and ctl
2366 (mail-content-type-get ctl 'charset)))
2367 (when (stringp charset)
2368 (setq charset (intern (downcase charset)))))))
2370 (setq charset (mm-read-coding-system "Charset: " charset)))
2372 (setq charset gnus-newsgroup-charset))
2374 (save-window-excursion
2376 (narrow-to-region (point) (point-max))
2377 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2378 (entry (assq func mm-text-html-washer-alist)))
2380 (setq func (cdr entry)))
2385 (apply (car func) (cdr func))))))))))
2387 (defun gnus-article-wash-html-with-w3 ()
2388 "Wash the current buffer with w3."
2390 (let ((w3-strict-width (window-width))
2391 (url-standalone-mode t)
2392 (url-gateway-unplugged t)
2393 (w3-honor-stylesheets nil))
2395 (w3-region (point-min) (point-max))
2398 (defun gnus-article-wash-html-with-w3m ()
2399 "Wash the current buffer with emacs-w3m."
2402 (narrow-to-region (point) (point-max))
2403 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2406 w3m-force-redisplay)
2407 (w3m-region (point-min) (point-max)))
2408 (when (and mm-inline-text-html-with-w3m-keymap
2409 (boundp 'w3m-minor-mode-map)
2411 (add-text-properties
2412 (point-min) (point-max)
2413 (list 'keymap w3m-minor-mode-map
2414 ;; Put the mark meaning this part was rendered by emacs-w3m.
2415 'mm-inline-text-html-with-w3m t)))))
2417 (defun article-hide-list-identifiers ()
2418 "Remove list identifies from the Subject header.
2419 The `gnus-list-identifiers' variable specifies what to do."
2421 (let ((inhibit-point-motion-hooks t)
2422 (regexp (if (consp gnus-list-identifiers)
2423 (mapconcat 'identity gnus-list-identifiers " *\\|")
2424 gnus-list-identifiers))
2429 (article-narrow-to-head)
2430 (goto-char (point-min))
2431 (while (re-search-forward
2432 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2434 (delete-region (match-beginning 2) (match-end 0))
2435 (beginning-of-line))
2436 (when (re-search-forward
2437 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2438 (delete-region (match-beginning 1) (match-end 1))))))))
2440 (defun article-hide-pem (&optional arg)
2441 "Toggle hiding of any PEM headers and signatures in the current article.
2442 If given a negative prefix, always show; if given a positive prefix,
2444 (interactive (gnus-article-hidden-arg))
2445 (unless (gnus-article-check-hidden-text 'pem arg)
2447 (let (buffer-read-only end)
2448 (goto-char (point-min))
2449 ;; Hide the horrendously ugly "header".
2450 (when (and (search-forward
2451 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2453 (setq end (1+ (match-beginning 0))))
2454 (gnus-add-wash-type 'pem)
2455 (gnus-article-hide-text-type
2457 (if (search-forward "\n\n" nil t)
2461 ;; Hide the trailer as well
2462 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2464 (gnus-article-hide-text-type
2465 (match-beginning 0) (match-end 0) 'pem)))))))
2467 (defun article-strip-banner ()
2468 "Strip the banners specified by the `banner' group parameter and by
2469 `gnus-article-address-banner-alist'."
2473 (let ((inhibit-point-motion-hooks t))
2474 (when (gnus-parameter-banner gnus-newsgroup-name)
2475 (article-really-strip-banner
2476 (gnus-parameter-banner gnus-newsgroup-name)))
2477 (when gnus-article-address-banner-alist
2478 (article-really-strip-banner
2479 (let ((from (save-restriction
2481 (article-narrow-to-head)
2482 (mail-fetch-field "from"))))
2485 (caar (mail-header-parse-addresses from))))
2487 (dolist (pair gnus-article-address-banner-alist)
2488 (when (string-match (car pair) from)
2489 (throw 'found (cdr pair)))))))))))))
2491 (defun article-really-strip-banner (banner)
2492 "Strip the banner specified by the argument."
2495 (let ((inhibit-point-motion-hooks t)
2496 (gnus-signature-limit nil)
2500 ((eq banner 'signature)
2501 (when (gnus-article-narrow-to-signature)
2504 (delete-region (point) (point-max))))
2506 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2507 (while (re-search-forward banner nil t)
2508 (delete-region (match-beginning 0) (match-end 0)))))
2510 (while (re-search-forward banner nil t)
2511 (delete-region (match-beginning 0) (match-end 0)))))))))
2513 (defun article-babel ()
2514 "Translate article using an online translation service."
2518 (set-buffer gnus-article-buffer)
2519 (when (article-goto-body)
2520 (let* ((buffer-read-only nil)
2523 (orig (buffer-substring start end))
2524 (trans (babel-as-string orig)))
2526 (narrow-to-region start end)
2527 (delete-region start end)
2530 (defun article-hide-signature (&optional arg)
2531 "Hide the signature in the current article.
2532 If given a negative prefix, always show; if given a positive prefix,
2534 (interactive (gnus-article-hidden-arg))
2535 (unless (gnus-article-check-hidden-text 'signature arg)
2538 (let ((buffer-read-only nil))
2539 (when (gnus-article-narrow-to-signature)
2540 (gnus-article-hide-text-type
2541 (point-min) (point-max) 'signature))))))
2542 (gnus-set-mode-line 'article))
2544 (defun article-strip-headers-in-body ()
2545 "Strip offensive headers from bodies."
2549 (let ((case-fold-search t))
2550 (when (looking-at "x-no-archive:")
2551 (gnus-delete-line)))))
2553 (defun article-strip-leading-blank-lines ()
2554 "Remove all blank lines from the beginning of the article."
2557 (let ((inhibit-point-motion-hooks t)
2559 (when (article-goto-body)
2560 (while (and (not (eobp))
2561 (looking-at "[ \t]*$"))
2562 (gnus-delete-line))))))
2564 (defun article-narrow-to-head ()
2565 "Narrow the buffer to the head of the message.
2566 Point is left at the beginning of the narrowed-to region."
2568 (goto-char (point-min))
2569 (if (search-forward "\n\n" nil 1)
2572 (goto-char (point-min)))
2574 (defun article-goto-body ()
2575 "Place point at the start of the body."
2576 (goto-char (point-min))
2578 ;; This variable is only bound when dealing with separate
2580 (article-goto-body-goes-to-point-min-p
2582 ((search-forward "\n\n" nil t)
2585 (goto-char (point-max))
2588 (defun article-strip-multiple-blank-lines ()
2589 "Replace consecutive blank lines with one empty line."
2592 (let ((inhibit-point-motion-hooks t)
2594 ;; First make all blank lines empty.
2596 (while (re-search-forward "^[ \t]+$" nil t)
2597 (unless (gnus-annotation-in-region-p
2598 (match-beginning 0) (match-end 0))
2599 (replace-match "" nil t)))
2600 ;; Then replace multiple empty lines with a single empty line.
2602 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2603 (unless (gnus-annotation-in-region-p
2604 (match-beginning 0) (match-end 0))
2605 (delete-region (match-beginning 1) (match-end 1)))))))
2607 (defun article-strip-leading-space ()
2608 "Remove all white space from the beginning of the lines in the article."
2611 (let ((inhibit-point-motion-hooks t)
2614 (while (re-search-forward "^[ \t]+" nil t)
2615 (replace-match "" t t)))))
2617 (defun article-strip-trailing-space ()
2618 "Remove all white space from the end of the lines in the article."
2621 (let ((inhibit-point-motion-hooks t)
2624 (while (re-search-forward "[ \t]+$" nil t)
2625 (replace-match "" t t)))))
2627 (defun article-strip-blank-lines ()
2628 "Strip leading, trailing and multiple blank lines."
2630 (article-strip-leading-blank-lines)
2631 (article-remove-trailing-blank-lines)
2632 (article-strip-multiple-blank-lines))
2634 (defun article-strip-all-blank-lines ()
2635 "Strip all blank lines."
2638 (let ((inhibit-point-motion-hooks t)
2641 (while (re-search-forward "^[ \t]*\n" nil t)
2642 (replace-match "" t t)))))
2644 (defun gnus-article-narrow-to-signature ()
2645 "Narrow to the signature; return t if a signature is found, else nil."
2646 (let ((inhibit-point-motion-hooks t))
2647 (when (gnus-article-search-signature)
2649 ;; Check whether we have some limits to what we consider
2650 ;; to be a signature.
2651 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2652 (list gnus-signature-limit)))
2654 (while (setq limit (pop limits))
2655 (if (or (and (integerp limit)
2656 (< (- (point-max) (point)) limit))
2658 (< (count-lines (point) (point-max)) limit))
2659 (and (functionp limit)
2661 (and (stringp limit)
2662 (not (re-search-forward limit nil t))))
2663 () ; This limit did not succeed.
2667 (narrow-to-region (point) (point-max))
2670 (defun gnus-article-search-signature ()
2671 "Search the current buffer for the signature separator.
2672 Put point at the beginning of the signature separator."
2673 (let ((cur (point)))
2674 (goto-char (point-max))
2675 (if (if (stringp gnus-signature-separator)
2676 (re-search-backward gnus-signature-separator nil t)
2677 (let ((seps gnus-signature-separator))
2679 (not (re-search-backward (car seps) nil t)))
2686 (defun gnus-article-hidden-arg ()
2687 "Return the current prefix arg as a number, or 0 if no prefix."
2688 (list (if current-prefix-arg
2689 (prefix-numeric-value current-prefix-arg)
2692 (defun gnus-article-check-hidden-text (type arg)
2693 "Return nil if hiding is necessary.
2694 Arg can be nil or a number. nil and positive means hide, negative
2695 means show, 0 means toggle."
2698 (let ((hide (gnus-article-hidden-text-p type)))
2704 (gnus-article-show-hidden-text type)
2707 (if (eq hide 'hidden)
2709 (gnus-article-show-hidden-text type)
2713 (defun gnus-article-hidden-text-p (type)
2714 "Say whether the current buffer contains hidden text of type TYPE."
2715 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2717 (not (get-text-property pos 'invisible))
2718 (not (get-text-property pos 'dummy-invisible)))
2720 (text-property-any (1+ pos) (point-max) 'article-type type)))
2725 (defun gnus-article-show-hidden-text (type &optional dummy)
2726 "Show all hidden text of type TYPE.
2727 Originally it is hide instead of DUMMY."
2728 (let ((buffer-read-only nil)
2729 (inhibit-point-motion-hooks t))
2730 (gnus-remove-text-properties-when
2732 (point-min) (point-max)
2733 (cons 'article-type (cons type
2734 gnus-hidden-properties)))
2735 (gnus-delete-wash-type type)))
2737 (defconst article-time-units
2738 `((year . ,(* 365.25 24 60 60))
2739 (week . ,(* 7 24 60 60))
2740 (day . ,(* 24 60 60))
2744 "Mapping from time units to seconds.")
2746 (defun gnus-article-forward-header ()
2747 "Move point to the start of the next header.
2748 If the current header is a continuation header, this can be several
2753 (if (looking-at "[ \t]+[^ \t]")
2757 (defun article-date-ut (&optional type highlight header)
2758 "Convert DATE date to universal time in the current article.
2759 If TYPE is `local', convert to local time; if it is `lapsed', output
2760 how much time has lapsed since DATE. For `lapsed', the value of
2761 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2762 should replace the \"Date:\" one, or should be added below it."
2763 (interactive (list 'ut t))
2764 (let* ((header (or header
2765 (message-fetch-field "date")
2767 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2770 ((not gnus-article-date-lapsed-new-header)
2776 (date (if (vectorp header) (mail-header-date header)
2778 (inhibit-point-motion-hooks t)
2783 (article-narrow-to-head)
2784 (when (re-search-forward tdate-regexp nil t)
2785 (setq bface (get-text-property (point-at-bol) 'face)
2786 date (or (get-text-property (point-at-bol)
2789 eface (get-text-property (1- (point-at-eol)) 'face))
2791 (when (and date (not (string= date "")))
2792 (goto-char (point-min))
2793 (let ((buffer-read-only nil))
2794 ;; Delete any old Date headers.
2795 (while (re-search-forward date-regexp nil t)
2797 (delete-region (progn (beginning-of-line) (point))
2798 (progn (gnus-article-forward-header)
2800 (delete-region (progn (beginning-of-line) (point))
2801 (progn (gnus-article-forward-header)
2804 (setq pos (point))))
2805 (when (and (not pos)
2806 (re-search-forward tdate-regexp nil t))
2810 (insert (article-make-date-line date (or type 'ut)))
2816 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2817 (put-text-property (match-beginning 1) (1+ (match-end 1))
2818 'original-date date)
2819 (put-text-property (match-beginning 1) (1+ (match-end 1))
2821 (put-text-property (match-beginning 2) (match-end 2)
2824 (defun article-make-date-line (date type)
2825 "Return a DATE line of TYPE."
2826 (unless (memq type '(local ut original user iso8601 lapsed english))
2827 (error "Unknown conversion type: %s" type))
2829 (let ((time (date-to-time date)))
2831 ;; Convert to the local timezone.
2833 (let ((tz (car (current-time-zone time))))
2834 (format "Date: %s %s%02d%02d" (current-time-string time)
2835 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2836 (/ (% (abs tz) 3600) 60))))
2837 ;; Convert to Universal Time.
2840 (current-time-string
2841 (let* ((e (parse-time-string date))
2842 (tm (apply 'encode-time e))
2844 (ls (- (cadr tm) (car (current-time-zone time)))))
2845 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2846 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2849 ;; Get the original date from the article.
2850 ((eq type 'original)
2851 (concat "Date: " (if (string-match "\n+$" date)
2852 (substring date 0 (match-beginning 0))
2854 ;; Let the user define the format.
2856 (let ((format (or (condition-case nil
2857 (with-current-buffer gnus-summary-buffer
2858 gnus-article-time-format)
2860 gnus-article-time-format)))
2861 (if (functionp format)
2862 (funcall format time)
2863 (concat "Date: " (format-time-string format time)))))
2866 (let ((tz (car (current-time-zone time))))
2869 (format-time-string "%Y%m%dT%H%M%S" time)
2870 (format "%s%02d%02d"
2871 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2872 (/ (% (abs tz) 3600) 60)))))
2873 ;; Do an X-Sent lapsed format.
2875 ;; If the date is seriously mangled, the timezone functions are
2876 ;; liable to bug out, so we ignore all errors.
2877 (let* ((now (current-time))
2878 (real-time (subtract-time now time))
2879 (real-sec (and real-time
2880 (+ (* (float (car real-time)) 65536)
2882 (sec (and real-time (abs real-sec)))
2892 ;; This is a bit convoluted, but basically we go
2893 ;; through the time units for years, weeks, etc,
2894 ;; and divide things to see whether that results
2895 ;; in positive answers.
2898 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2899 ;; The (remaining) seconds are too few to
2900 ;; be divided into this time unit.
2902 ;; It's big enough, so we output it.
2903 (setq sec (- sec (* num (cdr unit))))
2905 (concat (if prev ", " "") (int-to-string
2907 " " (symbol-name (car unit))
2908 (if (> num 1) "s" ""))
2910 article-time-units "")
2911 ;; If dates are odd, then it might appear like the
2912 ;; article was sent in the future.
2915 " in the future"))))))
2916 ;; Display the date in proper English
2918 (let ((dtime (decode-time time)))
2921 (number-to-string (nth 3 dtime))
2922 (let ((digit (% (nth 3 dtime) 10)))
2924 ((memq (nth 3 dtime) '(11 12 13)) "th")
2930 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2932 (number-to-string (nth 5 dtime))
2934 (format "%02d" (nth 2 dtime))
2936 (format "%02d" (nth 1 dtime)))))))
2938 (format "Date: %s (from Gnus)" date))))
2940 (defun article-date-local (&optional highlight)
2941 "Convert the current article date to the local timezone."
2942 (interactive (list t))
2943 (article-date-ut 'local highlight))
2945 (defun article-date-english (&optional highlight)
2946 "Convert the current article date to something that is proper English."
2947 (interactive (list t))
2948 (article-date-ut 'english highlight))
2950 (defun article-date-original (&optional highlight)
2951 "Convert the current article date to what it was originally.
2952 This is only useful if you have used some other date conversion
2953 function and want to see what the date was before converting."
2954 (interactive (list t))
2955 (article-date-ut 'original highlight))
2957 (defun article-date-lapsed (&optional highlight)
2958 "Convert the current article date to time lapsed since it was sent."
2959 (interactive (list t))
2960 (article-date-ut 'lapsed highlight))
2962 (defun article-update-date-lapsed ()
2963 "Function to be run from a timer to update the lapsed time line."
2964 (let (deactivate-mark)
2969 (set-buffer (window-buffer w))
2970 (when (eq major-mode 'gnus-article-mode)
2971 (let ((mark (point-marker)))
2972 (goto-char (point-min))
2973 (when (re-search-forward "^X-Sent:" nil t)
2974 (article-date-lapsed t))
2975 (goto-char (marker-position mark))
2976 (move-marker mark nil))))
2979 (defun gnus-start-date-timer (&optional n)
2980 "Start a timer to update the X-Sent header in the article buffers.
2981 The numerical prefix says how frequently (in seconds) the function
2986 (gnus-stop-date-timer)
2987 (setq article-lapsed-timer
2988 (run-at-time 1 n 'article-update-date-lapsed)))
2990 (defun gnus-stop-date-timer ()
2991 "Stop the X-Sent timer."
2993 (when article-lapsed-timer
2994 (nnheader-cancel-timer article-lapsed-timer)
2995 (setq article-lapsed-timer nil)))
2997 (defun article-date-user (&optional highlight)
2998 "Convert the current article date to the user-defined format.
2999 This format is defined by the `gnus-article-time-format' variable."
3000 (interactive (list t))
3001 (article-date-ut 'user highlight))
3003 (defun article-date-iso8601 (&optional highlight)
3004 "Convert the current article date to ISO8601."
3005 (interactive (list t))
3006 (article-date-ut 'iso8601 highlight))
3008 ;; (defun article-show-all ()
3009 ;; "Show all hidden text in the article buffer."
3012 ;; (let ((buffer-read-only nil))
3013 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3015 (defun article-remove-leading-whitespace ()
3016 "Remove excessive whitespace from all headers."
3020 (let ((buffer-read-only nil))
3021 (article-narrow-to-head)
3022 (goto-char (point-min))
3023 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3024 (delete-region (match-beginning 1) (match-end 1)))))))
3026 (defun article-emphasize (&optional arg)
3027 "Emphasize text according to `gnus-emphasis-alist'."
3028 (interactive (gnus-article-hidden-arg))
3029 (unless (gnus-article-check-hidden-text 'emphasis arg)
3033 (with-current-buffer gnus-summary-buffer
3034 gnus-article-emphasis-alist)
3036 gnus-emphasis-alist))
3037 (buffer-read-only nil)
3038 (props (append '(article-type emphasis)
3039 gnus-hidden-properties))
3040 regexp elem beg invisible visible face)
3043 (while (setq elem (pop alist))
3045 (setq regexp (car elem)
3046 invisible (nth 1 elem)
3047 visible (nth 2 elem)
3049 (while (re-search-forward regexp nil t)
3050 (when (and (match-beginning visible) (match-beginning invisible))
3051 (gnus-article-hide-text
3052 (match-beginning invisible) (match-end invisible) props)
3053 (gnus-article-unhide-text-type
3054 (match-beginning visible) (match-end visible) 'emphasis)
3055 (gnus-put-overlay-excluding-newlines
3056 (match-beginning visible) (match-end visible) 'face face)
3057 (gnus-add-wash-type 'emphasis)
3058 (goto-char (match-end invisible)))))))))
3060 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3061 "Setup newsgroup emphasis alist."
3062 (unless gnus-article-emphasis-alist
3063 (let ((name (and gnus-newsgroup-name
3064 (gnus-group-real-name gnus-newsgroup-name))))
3065 (make-local-variable 'gnus-article-emphasis-alist)
3066 (setq gnus-article-emphasis-alist
3068 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3069 (while (setq elem (pop alist))
3070 (when (and name (string-match (car elem) name))
3072 highlight (copy-sequence (cdr elem)))))
3074 (copy-sequence highlight-words)
3075 (if gnus-newsgroup-name
3076 (copy-sequence (gnus-group-find-parameter
3077 gnus-newsgroup-name 'highlight-words t)))
3078 gnus-emphasis-alist)))))
3081 (defvar gnus-summary-article-menu)
3082 (defvar gnus-summary-post-menu))
3084 ;;; Saving functions.
3086 (defun gnus-article-save (save-buffer file &optional num)
3087 "Save the currently selected article."
3088 (unless gnus-save-all-headers
3089 ;; Remove headers according to `gnus-saved-headers'.
3090 (let ((gnus-visible-headers
3091 (or gnus-saved-headers gnus-visible-headers))
3092 (gnus-article-buffer save-buffer))
3094 (set-buffer save-buffer)
3095 (article-hide-headers 1 t))))
3096 (save-window-excursion
3097 (if (not gnus-default-article-saver)
3098 (error "No default saver is defined")
3099 ;; !!! Magic! The saving functions all save
3100 ;; `gnus-save-article-buffer' (or so they think), but we
3101 ;; bind that variable to our save-buffer.
3102 (set-buffer gnus-article-buffer)
3103 (let* ((gnus-save-article-buffer save-buffer)
3106 ((not gnus-prompt-before-saving) 'default)
3107 ((eq gnus-prompt-before-saving 'always) nil)
3109 (gnus-number-of-articles-to-be-saved
3110 (when (eq gnus-prompt-before-saving t)
3112 (set-buffer gnus-article-current-summary)
3113 (funcall gnus-default-article-saver filename)))))
3115 (defun gnus-read-save-file-name (prompt &optional filename
3116 function group headers variable)
3118 (funcall function group headers (symbol-value variable)))
3123 ((eq filename 'default)
3129 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3132 (if (and gnus-number-of-articles-to-be-saved
3133 (> gnus-number-of-articles-to-be-saved 1))
3134 (format "these %d articles"
3135 gnus-number-of-articles-to-be-saved)
3138 ;; Let the split methods have their say.
3140 ;; No split name was found.
3143 (concat prompt " (default "
3144 (file-name-nondirectory default-name) ") ")
3145 (file-name-directory default-name)
3147 ;; A single group name is returned.
3148 ((stringp split-name)
3150 (funcall function split-name headers
3151 (symbol-value variable)))
3153 (concat prompt " (default "
3154 (file-name-nondirectory default-name) ") ")
3155 (file-name-directory default-name)
3157 ;; A single split name was found
3158 ((= 1 (length split-name))
3159 (let* ((name (expand-file-name
3161 gnus-article-save-directory))
3162 (dir (cond ((file-directory-p name)
3163 (file-name-as-directory name))
3164 ((file-exists-p name) name)
3165 (t gnus-article-save-directory))))
3167 (concat prompt " (default " name ") ")
3169 ;; A list of splits was found.
3171 (setq split-name (nreverse split-name))
3173 (let ((file-name-history
3174 (nconc split-name file-name-history)))
3178 (concat prompt " (`M-p' for defaults) ")
3179 gnus-article-save-directory
3181 gnus-article-save-directory)))
3182 (car (push result file-name-history)))))))
3183 ;; Create the directory.
3184 (gnus-make-directory (file-name-directory file))
3185 ;; If we have read a directory, we append the default file name.
3186 (when (file-directory-p file)
3187 (setq file (expand-file-name (file-name-nondirectory
3189 (file-name-as-directory file))))
3190 ;; Possibly translate some characters.
3191 (nnheader-translate-file-chars file))))))
3192 (gnus-make-directory (file-name-directory result))
3193 (set variable result)))
3195 (defun gnus-article-archive-name (group)
3196 "Return the first instance of an \"Archive-name\" in the current buffer."
3197 (let ((case-fold-search t))
3198 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3199 (nnheader-concat gnus-article-save-directory
3200 (match-string 1)))))
3202 (defun gnus-article-nndoc-name (group)
3203 "If GROUP is an nndoc group, return the name of the parent group."
3204 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3205 (gnus-group-get-parameter group 'save-article-group)))
3207 (defun gnus-summary-save-in-rmail (&optional filename)
3208 "Append this article to Rmail file.
3209 Optional argument FILENAME specifies file name.
3210 Directory to save to is default to `gnus-article-save-directory'."
3211 (setq filename (gnus-read-save-file-name
3212 "Save %s in rmail file:" filename
3213 gnus-rmail-save-name gnus-newsgroup-name
3214 gnus-current-headers 'gnus-newsgroup-last-rmail))
3215 (gnus-eval-in-buffer-window gnus-save-article-buffer
3219 (gnus-output-to-rmail filename))))
3222 (defun gnus-summary-save-in-mail (&optional filename)
3223 "Append this article to Unix mail file.
3224 Optional argument FILENAME specifies file name.
3225 Directory to save to is default to `gnus-article-save-directory'."
3226 (setq filename (gnus-read-save-file-name
3227 "Save %s in Unix mail file:" filename
3228 gnus-mail-save-name gnus-newsgroup-name
3229 gnus-current-headers 'gnus-newsgroup-last-mail))
3230 (gnus-eval-in-buffer-window gnus-save-article-buffer
3234 (if (and (file-readable-p filename)
3235 (file-regular-p filename)
3236 (mail-file-babyl-p filename))
3237 (rmail-output-to-rmail-file filename t)
3238 (gnus-output-to-mail filename)))))
3241 (defun gnus-summary-save-in-file (&optional filename overwrite)
3242 "Append this article to file.
3243 Optional argument FILENAME specifies file name.
3244 Directory to save to is default to `gnus-article-save-directory'."
3245 (setq filename (gnus-read-save-file-name
3246 "Save %s in file:" filename
3247 gnus-file-save-name gnus-newsgroup-name
3248 gnus-current-headers 'gnus-newsgroup-last-file))
3249 (gnus-eval-in-buffer-window gnus-save-article-buffer
3253 (when (and overwrite
3254 (file-exists-p filename))
3255 (delete-file filename))
3256 (gnus-output-to-file filename))))
3259 (defun gnus-summary-write-to-file (&optional filename)
3260 "Write this article to a file, overwriting it if the file exists.
3261 Optional argument FILENAME specifies file name.
3262 The directory to save in defaults to `gnus-article-save-directory'."
3263 (gnus-summary-save-in-file nil t))
3265 (defun gnus-summary-save-body-in-file (&optional filename)
3266 "Append this article body to a file.
3267 Optional argument FILENAME specifies file name.
3268 The directory to save in defaults to `gnus-article-save-directory'."
3269 (setq filename (gnus-read-save-file-name
3270 "Save %s body in file:" filename
3271 gnus-file-save-name gnus-newsgroup-name
3272 gnus-current-headers 'gnus-newsgroup-last-file))
3273 (gnus-eval-in-buffer-window gnus-save-article-buffer
3277 (when (article-goto-body)
3278 (narrow-to-region (point) (point-max)))
3279 (gnus-output-to-file filename))))
3282 (defun gnus-summary-save-in-pipe (&optional command)
3283 "Pipe this article to subprocess."
3285 (cond ((and (eq command 'default)
3286 gnus-last-shell-command)
3287 gnus-last-shell-command)
3292 "Shell command on %s: "
3293 (if (and gnus-number-of-articles-to-be-saved
3294 (> gnus-number-of-articles-to-be-saved 1))
3295 (format "these %d articles"
3296 gnus-number-of-articles-to-be-saved)
3298 gnus-last-shell-command))))
3299 (when (string-equal command "")
3300 (if gnus-last-shell-command
3301 (setq command gnus-last-shell-command)
3302 (error "A command is required")))
3303 (gnus-eval-in-buffer-window gnus-article-buffer
3306 (shell-command-on-region (point-min) (point-max) command nil)))
3307 (setq gnus-last-shell-command command))
3309 (defun gnus-summary-pipe-to-muttprint (&optional command)
3310 "Pipe this article to muttprint."
3311 (setq command (read-string
3312 "Print using command: " gnus-summary-muttprint-program
3313 nil gnus-summary-muttprint-program))
3314 (gnus-summary-save-in-pipe command))
3316 ;;; Article file names when saving.
3318 (defun gnus-capitalize-newsgroup (newsgroup)
3319 "Capitalize NEWSGROUP name."
3320 (when (not (zerop (length newsgroup)))
3321 (concat (char-to-string (upcase (aref newsgroup 0)))
3322 (substring newsgroup 1))))
3324 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3325 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3326 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3327 Otherwise, it is like ~/News/news/group/num."
3330 (concat (if (gnus-use-long-file-name 'not-save)
3331 (gnus-capitalize-newsgroup newsgroup)
3332 (gnus-newsgroup-directory-form newsgroup))
3333 "/" (int-to-string (mail-header-number headers)))
3334 gnus-article-save-directory)))
3336 (string-equal (file-name-directory default)
3337 (file-name-directory last-file))
3338 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3340 (or last-file default))))
3342 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3343 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3344 If variable `gnus-use-long-file-name' is non-nil, it is
3345 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3348 (concat (if (gnus-use-long-file-name 'not-save)
3350 (gnus-newsgroup-directory-form newsgroup))
3351 "/" (int-to-string (mail-header-number headers)))
3352 gnus-article-save-directory)))
3354 (string-equal (file-name-directory default)
3355 (file-name-directory last-file))
3356 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3358 (or last-file default))))
3360 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3361 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3362 If variable `gnus-use-long-file-name' is non-nil, it is
3363 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3366 (if (gnus-use-long-file-name 'not-save)
3369 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3371 gnus-article-save-directory)))
3373 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3374 "Generate file name from sender."
3375 (let ((from (mail-header-from headers)))
3377 (if (and from (string-match "\\([^ <]+\\)@" from))
3378 (match-string 1 from)
3380 gnus-article-save-directory)))
3382 (defun article-verify-x-pgp-sig ()
3385 (if (gnus-buffer-live-p gnus-original-article-buffer)
3386 (let ((sig (with-current-buffer gnus-original-article-buffer
3387 (gnus-fetch-field "X-PGP-Sig")))
3391 (mml2015-clear-verify-function))
3393 (insert-buffer-substring gnus-original-article-buffer)
3394 (setq items (split-string sig))
3395 (message-narrow-to-head)
3396 (let ((inhibit-point-motion-hooks t)
3397 (case-fold-search t))
3398 ;; Don't verify multiple headers.
3399 (setq headers (mapconcat (lambda (header)
3401 (mail-fetch-field header)
3403 (split-string (nth 1 items) ",") "")))
3404 (delete-region (point-min) (point-max))
3405 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3406 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3411 (if (looking-at "^-")
3414 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3415 (insert "Version: " (car items) "\n\n")
3416 (insert (mapconcat 'identity (cddr items) "\n"))
3417 (insert "\n-----END PGP SIGNATURE-----\n")
3418 (let ((mm-security-handle (list (format "multipart/signed"))))
3419 (mml2015-clean-buffer)
3420 (let ((coding-system-for-write (or gnus-newsgroup-charset
3422 (funcall (mml2015-clear-verify-function)))
3424 (or (mm-handle-multipart-ctl-parameter
3425 mm-security-handle 'gnus-details)
3426 (mm-handle-multipart-ctl-parameter
3427 mm-security-handle 'gnus-info)))))
3429 (let (buffer-read-only bface eface)
3431 (message-narrow-to-head)
3432 (goto-char (point-max))
3434 (setq bface (get-text-property (point-at-bol) 'face)
3435 eface (get-text-property (1- (point-at-eol)) 'face))
3436 (message-remove-header "X-Gnus-PGP-Verify")
3437 (if (re-search-forward "^X-PGP-Sig:" nil t)
3439 (goto-char (point-max)))
3440 (narrow-to-region (point) (point))
3441 (insert "X-Gnus-PGP-Verify: " info "\n")
3442 (goto-char (point-min))
3445 (if (not (looking-at "^[ \t]"))
3449 (goto-char (point-min))
3450 (when (looking-at "\\([^:]+\\): *")
3451 (put-text-property (match-beginning 1) (1+ (match-end 1))
3453 (put-text-property (match-end 0) (point-max)
3454 'face eface)))))))))
3456 (defun article-verify-cancel-lock ()
3457 "Verify Cancel-Lock header."
3459 (if (gnus-buffer-live-p gnus-original-article-buffer)
3460 (canlock-verify gnus-original-article-buffer)))
3467 (setq afunc (car func)
3470 gfunc (intern (format "gnus-%s" func))))
3472 (when (fboundp afunc)
3473 `(lambda (&optional interactive &rest args)
3474 ,(documentation afunc t)
3475 (interactive (list t))
3477 (set-buffer gnus-article-buffer)
3479 (call-interactively ',afunc)
3480 (apply ',afunc args))))))))
3481 '(article-hide-headers
3482 article-verify-x-pgp-sig
3483 article-verify-cancel-lock
3484 article-hide-boring-headers
3485 article-treat-overstrike
3486 article-treat-ansi-sequences
3487 article-fill-long-lines
3488 article-capitalize-sentences
3490 article-remove-leading-whitespace
3491 article-display-x-face
3492 article-display-face
3493 article-de-quoted-unreadable
3494 article-de-base64-unreadable
3497 article-unsplit-urls
3498 article-hide-list-identifiers
3499 article-strip-banner
3502 article-hide-signature
3503 article-strip-headers-in-body
3504 article-remove-trailing-blank-lines
3505 article-strip-leading-blank-lines
3506 article-strip-multiple-blank-lines
3507 article-strip-leading-space
3508 article-strip-trailing-space
3509 article-strip-blank-lines
3510 article-strip-all-blank-lines
3512 article-date-english
3513 article-date-iso8601
3514 article-date-original
3516 article-decode-mime-words
3517 article-decode-charset
3518 article-decode-encoded-words
3522 article-treat-dumbquotes
3523 article-normalize-headers
3524 ;; (article-show-all . gnus-article-show-all-headers)
3528 ;;; Gnus article mode
3531 (put 'gnus-article-mode 'mode-class 'special)
3533 (set-keymap-parent gnus-article-mode-map widget-keymap)
3535 (gnus-define-keys gnus-article-mode-map
3536 " " gnus-article-goto-next-page
3537 "\177" gnus-article-goto-prev-page
3538 [delete] gnus-article-goto-prev-page
3539 [backspace] gnus-article-goto-prev-page
3540 "\C-c^" gnus-article-refer-article
3541 "h" gnus-article-show-summary
3542 "s" gnus-article-show-summary
3543 "\C-c\C-m" gnus-article-mail
3544 "?" gnus-article-describe-briefly
3545 "e" gnus-summary-edit-article
3546 "<" beginning-of-buffer
3548 "\C-c\C-i" gnus-info-find-node
3550 "R" gnus-article-reply-with-original
3551 "F" gnus-article-followup-with-original
3552 "\C-hk" gnus-article-describe-key
3553 "\C-hc" gnus-article-describe-key-briefly
3555 "\C-d" gnus-article-read-summary-keys
3556 "\M-*" gnus-article-read-summary-keys
3557 "\M-#" gnus-article-read-summary-keys
3558 "\M-^" gnus-article-read-summary-keys
3559 "\M-g" gnus-article-read-summary-keys)
3561 (substitute-key-definition
3562 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3564 (defun gnus-article-make-menu-bar ()
3565 (unless (boundp 'gnus-article-commands-menu)
3566 (gnus-summary-make-menu-bar))
3567 (gnus-turn-off-edit-menu 'article)
3568 (unless (boundp 'gnus-article-article-menu)
3570 gnus-article-article-menu gnus-article-mode-map ""
3572 ["Scroll forwards" gnus-article-goto-next-page t]
3573 ["Scroll backwards" gnus-article-goto-prev-page t]
3574 ["Show summary" gnus-article-show-summary t]
3575 ["Fetch Message-ID at point" gnus-article-refer-article t]
3576 ["Mail to address at point" gnus-article-mail t]
3577 ["Send a bug report" gnus-bug t]))
3580 gnus-article-treatment-menu gnus-article-mode-map ""
3581 ;; Fixme: this should use :active (and maybe :visible).
3583 ["Hide headers" gnus-article-hide-headers t]
3584 ["Hide signature" gnus-article-hide-signature t]
3585 ["Hide citation" gnus-article-hide-citation t]
3586 ["Treat overstrike" gnus-article-treat-overstrike t]
3587 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3588 ["Remove carriage return" gnus-article-remove-cr t]
3589 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3590 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3591 ["Remove base64" gnus-article-de-base64-unreadable t]
3592 ["Treat html" gnus-article-wash-html t]
3593 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3594 ["Decode HZ" gnus-article-decode-HZ t]))
3596 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3598 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3600 (gnus-run-hooks 'gnus-article-menu-hook)))
3602 (defun gnus-article-mode ()
3603 "Major mode for displaying an article.
3605 All normal editing commands are switched off.
3607 The following commands are available in addition to all summary mode
3609 \\<gnus-article-mode-map>
3610 \\[gnus-article-next-page]\t Scroll the article one page forwards
3611 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3612 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3613 \\[gnus-article-show-summary]\t Display the summary buffer
3614 \\[gnus-article-mail]\t Send a reply to the address near point
3615 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3616 \\[gnus-info-find-node]\t Go to the Gnus info node"
3618 (gnus-simplify-mode-line)
3619 (setq mode-name "Article")
3620 (setq major-mode 'gnus-article-mode)
3621 (make-local-variable 'minor-mode-alist)
3622 (use-local-map gnus-article-mode-map)
3623 (when (gnus-visual-p 'article-menu 'menu)
3624 (gnus-article-make-menu-bar)
3625 (when gnus-summary-tool-bar-map
3626 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3627 (gnus-update-format-specifications nil 'article-mode)
3628 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3629 (set (make-local-variable 'gnus-page-broken) nil)
3630 (make-local-variable 'gnus-button-marker-list)
3631 (make-local-variable 'gnus-article-current-summary)
3632 (make-local-variable 'gnus-article-mime-handles)
3633 (make-local-variable 'gnus-article-decoded-p)
3634 (make-local-variable 'gnus-article-mime-handle-alist)
3635 (make-local-variable 'gnus-article-wash-types)
3636 (make-local-variable 'gnus-article-image-alist)
3637 (make-local-variable 'gnus-article-charset)
3638 (make-local-variable 'gnus-article-ignored-charsets)
3639 (gnus-set-default-directory)
3640 (buffer-disable-undo)
3641 (setq buffer-read-only t)
3642 (set-syntax-table gnus-article-mode-syntax-table)
3643 (mm-enable-multibyte)
3644 (gnus-run-hooks 'gnus-article-mode-hook))
3646 (defun gnus-article-setup-buffer ()
3647 "Initialize the article buffer."
3648 (let* ((name (if gnus-single-article-buffer "*Article*"
3649 (concat "*Article " gnus-newsgroup-name "*")))
3651 (progn (string-match "\\*Article" name)
3652 (concat " *Original Article"
3653 (substring name (match-end 0))))))
3654 (setq gnus-article-buffer name)
3655 (setq gnus-original-article-buffer original)
3656 (setq gnus-article-mime-handle-alist nil)
3657 ;; This might be a variable local to the summary buffer.
3658 (unless gnus-single-article-buffer
3660 (set-buffer gnus-summary-buffer)
3661 (setq gnus-article-buffer name)
3662 (setq gnus-original-article-buffer original)
3663 (gnus-set-global-variables)))
3664 (gnus-article-setup-highlight-words)
3665 ;; Init original article buffer.
3667 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3668 (mm-enable-multibyte)
3669 (setq major-mode 'gnus-original-article-mode)
3670 (make-local-variable 'gnus-original-article))
3671 (if (get-buffer name)
3674 (when (and gnus-article-edit-mode
3677 (y-or-n-p "Article mode edit in progress; discard? ")))
3678 (error "Action aborted"))
3679 (set (make-local-variable 'gnus-article-edit-mode) nil)
3680 (when gnus-article-mime-handles
3681 (mm-destroy-parts gnus-article-mime-handles)
3682 (setq gnus-article-mime-handles nil))
3683 ;; Set it to nil in article-buffer!
3684 (setq gnus-article-mime-handle-alist nil)
3685 (buffer-disable-undo)
3686 (setq buffer-read-only t)
3687 ;; This list just keeps growing if we don't reset it.
3688 (setq gnus-button-marker-list nil)
3689 (unless (eq major-mode 'gnus-article-mode)
3690 (gnus-article-mode))
3693 (set-buffer (gnus-get-buffer-create name))
3695 (make-local-variable 'gnus-summary-buffer)
3696 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3697 (current-buffer)))))
3699 ;; Set article window start at LINE, where LINE is the number of lines
3700 ;; from the head of the article.
3701 (defun gnus-article-set-window-start (&optional line)
3703 (gnus-get-buffer-window gnus-article-buffer t)
3705 (set-buffer gnus-article-buffer)
3706 (goto-char (point-min))
3709 (gnus-message 6 "Moved to bookmark")
3710 (search-forward "\n\n" nil t)
3714 (defun gnus-article-prepare (article &optional all-headers header)
3715 "Prepare ARTICLE in article mode buffer.
3716 ARTICLE should either be an article number or a Message-ID.
3717 If ARTICLE is an id, HEADER should be the article headers.
3718 If ALL-HEADERS is non-nil, no headers are hidden."
3720 ;; Make sure we start in a summary buffer.
3721 (unless (eq major-mode 'gnus-summary-mode)
3722 (set-buffer gnus-summary-buffer))
3723 (setq gnus-summary-buffer (current-buffer))
3724 (let* ((gnus-article (if header (mail-header-number header) article))
3725 (summary-buffer (current-buffer))
3726 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3727 (group gnus-newsgroup-name)
3730 (gnus-article-setup-buffer)
3731 (set-buffer gnus-article-buffer)
3732 ;; Deactivate active regions.
3733 (when (and (boundp 'transient-mark-mode)
3734 transient-mark-mode)
3735 (setq mark-active nil))
3736 (if (not (setq result (let ((buffer-read-only nil))
3737 (gnus-request-article-this-buffer
3739 ;; There is no such article.
3741 (when (and (numberp article)
3742 (not (memq article gnus-newsgroup-sparse)))
3743 (setq gnus-article-current
3744 (cons gnus-newsgroup-name article))
3745 (set-buffer gnus-summary-buffer)
3746 (setq gnus-current-article article)
3747 (if (and (memq article gnus-newsgroup-undownloaded)
3748 (not (gnus-online (gnus-find-method-for-group
3749 gnus-newsgroup-name))))
3751 (gnus-summary-set-agent-mark article)
3752 (message "Message marked for downloading"))
3753 (gnus-summary-mark-article article gnus-canceled-mark)
3754 (unless (memq article gnus-newsgroup-sparse)
3755 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3756 (if (or (eq result 'pseudo)
3757 (eq result 'nneething))
3760 (set-buffer summary-buffer)
3761 (push article gnus-newsgroup-history)
3762 (setq gnus-last-article gnus-current-article
3763 gnus-current-article 0
3764 gnus-current-headers nil
3765 gnus-article-current nil)
3766 (if (eq result 'nneething)
3767 (gnus-configure-windows 'summary)
3768 (gnus-configure-windows 'article))
3769 (gnus-set-global-variables))
3770 (let ((gnus-article-mime-handle-alist-1
3771 gnus-article-mime-handle-alist))
3772 (gnus-set-mode-line 'article)))
3773 ;; The result from the `request' was an actual article -
3774 ;; or at least some text that is now displayed in the
3776 (when (and (numberp article)
3777 (not (eq article gnus-current-article)))
3778 ;; Seems like a new article has been selected.
3779 ;; `gnus-current-article' must be an article number.
3781 (set-buffer summary-buffer)
3782 (push article gnus-newsgroup-history)
3783 (setq gnus-last-article gnus-current-article
3784 gnus-current-article article
3785 gnus-current-headers
3786 (gnus-summary-article-header gnus-current-article)
3787 gnus-article-current
3788 (cons gnus-newsgroup-name gnus-current-article))
3789 (unless (vectorp gnus-current-headers)
3790 (setq gnus-current-headers nil))
3791 (gnus-summary-goto-subject gnus-current-article)
3792 (when (gnus-summary-show-thread)
3793 ;; If the summary buffer really was folded, the
3794 ;; previous goto may not actually have gone to
3795 ;; the right article, but the thread root instead.
3797 (gnus-summary-goto-subject gnus-current-article))
3798 (gnus-run-hooks 'gnus-mark-article-hook)
3799 (gnus-set-mode-line 'summary)
3800 (when (gnus-visual-p 'article-highlight 'highlight)
3801 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3802 ;; Set the global newsgroup variables here.
3803 (gnus-set-global-variables)
3804 (setq gnus-have-all-headers
3805 (or all-headers gnus-show-all-headers))))
3807 (gnus-configure-windows 'article))
3808 (when (or (numberp article)
3810 (gnus-article-prepare-display)
3812 (goto-char (point-min))
3813 (when gnus-break-pages
3814 (gnus-narrow-to-page)))
3815 (let ((gnus-article-mime-handle-alist-1
3816 gnus-article-mime-handle-alist))
3817 (gnus-set-mode-line 'article))
3821 (set-window-point (get-buffer-window (current-buffer)) (point))
3822 (gnus-configure-windows 'article)
3826 (defun gnus-article-prepare-display ()
3827 "Make the current buffer look like a nice article."
3828 ;; Hooks for getting information from the article.
3829 ;; This hook must be called before being narrowed.
3830 (let ((gnus-article-buffer (current-buffer))
3832 (unless (eq major-mode 'gnus-article-mode)
3833 (gnus-article-mode))
3834 (setq buffer-read-only nil
3835 gnus-article-wash-types nil
3836 gnus-article-image-alist nil)
3837 (gnus-run-hooks 'gnus-tmp-internal-hook)
3838 (when gnus-display-mime-function
3839 (funcall gnus-display-mime-function))
3840 (gnus-run-hooks 'gnus-article-prepare-hook)))
3843 ;;; Gnus MIME viewing functions
3846 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3847 "Format of the MIME buttons.
3849 Valid specifiers include:
3851 %T MIME type, along with additional info
3852 %n The `name' parameter
3853 %d The description, if any
3854 %l The length of the encoded part
3855 %p The part identifier number
3856 %e Dots if the part isn't displayed
3858 General format specifiers can also be used. See Info node
3859 `(gnus)Formatting Variables'.")
3861 (defvar gnus-mime-button-line-format-alist
3862 '((?t gnus-tmp-type ?s)
3863 (?T gnus-tmp-type-long ?s)
3864 (?n gnus-tmp-name ?s)
3865 (?d gnus-tmp-description ?s)
3867 (?l gnus-tmp-length ?d)
3868 (?e gnus-tmp-dots ?s)))
3870 (defvar gnus-mime-button-commands
3871 '((gnus-article-press-button "\r" "Toggle Display")
3872 (gnus-mime-view-part "v" "View Interactively...")
3873 (gnus-mime-view-part-as-type "t" "View As Type...")
3874 (gnus-mime-view-part-as-charset "C" "View As charset...")
3875 (gnus-mime-save-part "o" "Save...")
3876 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3877 (gnus-mime-delete-part "d" "Delete part")
3878 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3879 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3880 (gnus-mime-view-part-internally "E" "View Internally")
3881 (gnus-mime-view-part-externally "e" "View Externally")
3882 (gnus-mime-print-part "p" "Print")
3883 (gnus-mime-pipe-part "|" "Pipe To Command...")
3884 (gnus-mime-action-on-part "." "Take action on the part...")))
3886 (defun gnus-article-mime-part-status ()
3887 (if gnus-article-mime-handle-alist-1
3888 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3890 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3893 (defvar gnus-mime-button-map
3894 (let ((map (make-sparse-keymap)))
3895 (unless (>= (string-to-number emacs-version) 21)
3896 ;; XEmacs doesn't care.
3897 (set-keymap-parent map gnus-article-mode-map))
3898 (define-key map gnus-mouse-2 'gnus-article-push-button)
3899 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3900 (dolist (c gnus-mime-button-commands)
3901 (define-key map (cadr c) (car c)))
3905 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
3907 ,@(mapcar (lambda (c)
3908 (vector (caddr c) (car c) :enable t))
3909 gnus-mime-button-commands)))
3911 (defun gnus-mime-button-menu (event prefix)
3912 "Construct a context-sensitive menu of MIME commands."
3913 (interactive "e\nP")
3914 (save-window-excursion
3915 (let ((pos (event-start event)))
3916 (select-window (posn-window pos))
3917 (goto-char (posn-point pos))
3918 (gnus-article-check-buffer)
3919 (popup-menu gnus-mime-button-menu nil prefix))))
3921 (defun gnus-mime-view-all-parts (&optional handles)
3922 "View all the MIME parts."
3924 (save-current-buffer
3925 (set-buffer gnus-article-buffer)
3926 (let ((handles (or handles gnus-article-mime-handles))
3927 (mail-parse-charset gnus-newsgroup-charset)
3928 (mail-parse-ignored-charsets
3929 (with-current-buffer gnus-summary-buffer
3930 gnus-newsgroup-ignored-charsets)))
3932 (mm-remove-parts handles)
3933 (goto-char (point-min))
3934 (or (search-forward "\n\n") (goto-char (point-max)))
3935 (let (buffer-read-only)
3936 (delete-region (point) (point-max))
3937 (mm-display-parts handles))))))
3939 (defun gnus-mime-save-part-and-strip ()
3940 "Save the MIME part under point then replace it with an external body."
3942 (gnus-article-check-buffer)
3943 (let* ((data (get-text-property (point) 'gnus-data))
3945 (handles gnus-article-mime-handles))
3946 (if (mm-multiple-handles gnus-article-mime-handles)
3947 (error "This function is not implemented"))
3948 (setq file (and data (mm-save-part data)))
3950 (with-current-buffer (mm-handle-buffer data)
3952 (insert "Content-Type: " (mm-handle-media-type data))
3953 (mml-insert-parameter-string (cdr (mm-handle-type data))
3956 (insert "Content-ID: " (message-make-message-id) "\n")
3957 (insert "Content-Transfer-Encoding: binary\n")
3960 (cdr (mm-make-handle nil
3961 `("message/external-body"
3962 (access-type . "LOCAL-FILE")
3964 (set-buffer gnus-summary-buffer)
3965 (gnus-article-edit-article
3968 (let ((mail-parse-charset (or gnus-article-charset
3969 ',gnus-newsgroup-charset))
3970 (mail-parse-ignored-charsets
3971 (or gnus-article-ignored-charsets
3972 ',gnus-newsgroup-ignored-charsets))
3973 (mbl mml-buffer-list))
3974 (setq mml-buffer-list nil)
3975 (insert-buffer gnus-original-article-buffer)
3976 (mime-to-mml ',handles)
3977 (setq gnus-article-mime-handles nil)
3978 (let ((mbl1 mml-buffer-list))
3979 (setq mml-buffer-list mbl)
3980 (set (make-local-variable 'mml-buffer-list) mbl1))
3981 (gnus-make-local-hook 'kill-buffer-hook)
3982 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3983 `(lambda (no-highlight)
3984 (let ((mail-parse-charset (or gnus-article-charset
3985 ',gnus-newsgroup-charset))
3986 (message-options message-options)
3987 (message-options-set-recipient)
3988 (mail-parse-ignored-charsets
3989 (or gnus-article-ignored-charsets
3990 ',gnus-newsgroup-ignored-charsets)))
3992 (mml-destroy-buffers)
3993 (remove-hook 'kill-buffer-hook
3994 'mml-destroy-buffers t)
3995 (kill-local-variable 'mml-buffer-list))
3996 (gnus-summary-edit-article-done
3997 ,(or (mail-header-references gnus-current-headers) "")
3998 ,(gnus-group-read-only-p)
3999 ,gnus-summary-buffer no-highlight))))))
4001 (defun gnus-mime-delete-part ()
4002 "Delete the MIME part under point.
4003 Replace it with some information about the removed part."
4005 (gnus-article-check-buffer)
4006 (unless (and gnus-novice-user
4007 (not (gnus-yes-or-no-p
4008 "Really delete attachment forever? ")))
4009 (let* ((data (get-text-property (point) 'gnus-data))
4010 (handles gnus-article-mime-handles)
4014 (mail-decode-encoded-word-string (or (mm-handle-description data)
4017 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4019 (type (mm-handle-media-type data)))
4020 (if (mm-multiple-handles gnus-article-mime-handles)
4021 (error "This function is not implemented"))
4022 (with-current-buffer (mm-handle-buffer data)
4023 (let ((bsize (format "%s" (buffer-size))))
4028 "| The following attachment has been deleted:\n"
4030 "| Type: " type "\n"
4031 "| Filename: " filename "\n"
4032 "| Size (encoded): " bsize " Byte\n"
4033 "| Description: " description "\n"
4036 (cdr (mm-make-handle
4037 nil `("text/plain") nil nil
4039 (format "Deleted attachment (%s bytes)" bsize))))))
4040 (set-buffer gnus-summary-buffer)
4041 ;; FIXME: maybe some of the following code (borrowed from
4042 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4043 (gnus-article-edit-article
4046 (let ((mail-parse-charset (or gnus-article-charset
4047 ',gnus-newsgroup-charset))
4048 (mail-parse-ignored-charsets
4049 (or gnus-article-ignored-charsets
4050 ',gnus-newsgroup-ignored-charsets))
4051 (mbl mml-buffer-list))
4052 (setq mml-buffer-list nil)
4053 (insert-buffer gnus-original-article-buffer)
4054 (mime-to-mml ',handles)
4055 (setq gnus-article-mime-handles nil)
4056 (let ((mbl1 mml-buffer-list))
4057 (setq mml-buffer-list mbl)
4058 (set (make-local-variable 'mml-buffer-list) mbl1))
4059 (gnus-make-local-hook 'kill-buffer-hook)
4060 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4061 `(lambda (no-highlight)
4062 (let ((mail-parse-charset (or gnus-article-charset
4063 ',gnus-newsgroup-charset))
4064 (message-options message-options)
4065 (message-options-set-recipient)
4066 (mail-parse-ignored-charsets
4067 (or gnus-article-ignored-charsets
4068 ',gnus-newsgroup-ignored-charsets)))
4070 (mml-destroy-buffers)
4071 (remove-hook 'kill-buffer-hook
4072 'mml-destroy-buffers t)
4073 (kill-local-variable 'mml-buffer-list))
4074 (gnus-summary-edit-article-done
4075 ,(or (mail-header-references gnus-current-headers) "")
4076 ,(gnus-group-read-only-p)
4077 ,gnus-summary-buffer no-highlight)))))
4078 ;; Not in `gnus-mime-save-part-and-strip':
4079 (gnus-article-edit-done)
4080 (gnus-summary-expand-window)
4081 (gnus-summary-show-article))
4083 (defun gnus-mime-save-part ()
4084 "Save the MIME part under point."
4086 (gnus-article-check-buffer)
4087 (let ((data (get-text-property (point) 'gnus-data)))
4089 (mm-save-part data))))
4091 (defun gnus-mime-pipe-part ()
4092 "Pipe the MIME part under point to a process."
4094 (gnus-article-check-buffer)
4095 (let ((data (get-text-property (point) 'gnus-data)))
4097 (mm-pipe-part data))))
4099 (defun gnus-mime-view-part ()
4100 "Interactively choose a viewing method for the MIME part under point."
4102 (gnus-article-check-buffer)
4103 (let ((data (get-text-property (point) 'gnus-data)))
4105 (setq gnus-article-mime-handles
4107 gnus-article-mime-handles (setq data (copy-sequence data))))
4108 (mm-interactively-view-part data))))
4110 (defun gnus-mime-view-part-as-type-internal ()
4111 (gnus-article-check-buffer)
4112 (let* ((name (mail-content-type-get
4113 (mm-handle-type (get-text-property (point) 'gnus-data))
4115 (def-type (and name (mm-default-file-encoding name))))
4116 (and def-type (cons def-type 0))))
4118 (defun gnus-mime-view-part-as-type (&optional mime-type)
4119 "Choose a MIME media type, and view the part as such."
4122 (setq mime-type (completing-read
4123 "View as MIME type: "
4124 (mapcar #'list (mailcap-mime-types))
4126 (gnus-mime-view-part-as-type-internal))))
4127 (gnus-article-check-buffer)
4128 (let ((handle (get-text-property (point) 'gnus-data)))
4131 (mm-make-handle (mm-handle-buffer handle)
4132 (cons mime-type (cdr (mm-handle-type handle)))
4133 (mm-handle-encoding handle)
4134 (mm-handle-undisplayer handle)
4135 (mm-handle-disposition handle)
4136 (mm-handle-description handle)
4138 (mm-handle-id handle)))
4139 (setq gnus-article-mime-handles
4140 (mm-merge-handles gnus-article-mime-handles handle))
4141 (gnus-mm-display-part handle))))
4144 (require 'jka-compr))
4146 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4147 ;; emacs can do that itself.
4149 (defun gnus-mime-jka-compr-maybe-uncompress ()
4150 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4151 The uncompress method used is derived from `buffer-file-name'."
4152 (when (and (fboundp 'jka-compr-installed-p)
4153 (jka-compr-installed-p))
4154 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4156 (let ((basename (file-name-nondirectory buffer-file-name))
4157 (args (jka-compr-info-uncompress-args info))
4158 (prog (jka-compr-info-uncompress-program info))
4159 (message (jka-compr-info-uncompress-message info))
4160 (err-file (jka-compr-make-temp-name)))
4162 (message "%s %s..." message basename))
4164 (unless (memq (apply 'call-process-region
4165 (point-min) (point-max)
4167 t (list t err-file) nil
4169 jka-compr-acceptable-retval-list)
4170 (jka-compr-error prog args basename message err-file))
4171 (jka-compr-delete-temp-file err-file)))))))
4173 (defun gnus-mime-copy-part (&optional handle)
4174 "Put the MIME part under point into a new buffer.
4175 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4178 (gnus-article-check-buffer)
4179 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4180 (contents (and handle (mm-get-part handle)))
4182 (file-name-nondirectory
4184 (mail-content-type-get (mm-handle-type handle) 'name)
4185 (mail-content-type-get (mm-handle-disposition handle)
4188 (buffer (and base (generate-new-buffer base))))
4190 (switch-to-buffer buffer)
4192 ;; We do it this way to make `normal-mode' set the appropriate mode.
4195 (setq buffer-file-name (expand-file-name base))
4196 (gnus-mime-jka-compr-maybe-uncompress)
4198 (setq buffer-file-name nil))
4199 (goto-char (point-min)))))
4201 (defun gnus-mime-print-part (&optional handle filename)
4202 "Print the MIME part under point."
4203 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4204 (gnus-article-check-buffer)
4205 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4206 (contents (and handle (mm-get-part handle)))
4207 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4208 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4213 (mm-save-part-to-file handle file)
4214 (call-process shell-file-name nil
4215 (generate-new-buffer " *mm*")
4217 shell-command-switch
4219 printer file (mm-handle-type handle))))
4223 (gnus-print-buffer))
4224 (ps-despool filename)))))
4226 (defun gnus-mime-inline-part (&optional handle arg)
4227 "Insert the MIME part under point into the current buffer."
4228 (interactive (list nil current-prefix-arg))
4229 (gnus-article-check-buffer)
4230 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4235 (if (and (not arg) (mm-handle-undisplayer handle))
4236 (mm-remove-part handle)
4237 (setq contents (mm-get-part handle))
4240 (setq charset (or (mail-content-type-get
4241 (mm-handle-type handle) 'charset)
4242 gnus-newsgroup-charset)))
4244 (if (mm-handle-undisplayer handle)
4245 (mm-remove-part handle))
4248 gnus-summary-show-article-charset-alist))
4249 (mm-read-coding-system "Charset: ")))))
4251 (mm-insert-inline handle
4253 (setq charset (mm-charset-to-coding-system
4255 (not (eq charset 'ascii)))
4256 (mm-decode-coding-string contents charset)
4260 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4261 "Insert the MIME part under point into the current buffer using the
4263 (interactive (list nil current-prefix-arg))
4264 (gnus-article-check-buffer)
4265 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4270 (if (mm-handle-undisplayer handle)
4271 (mm-remove-part handle))
4272 (let ((gnus-newsgroup-charset
4274 gnus-summary-show-article-charset-alist))
4275 (mm-read-coding-system "Charset: ")))
4276 (gnus-newsgroup-ignored-charsets 'gnus-all))
4277 (gnus-article-press-button)))))
4279 (defun gnus-mime-view-part-externally (&optional handle)
4280 "View the MIME part under point with an external viewer."
4282 (gnus-article-check-buffer)
4283 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4284 (mm-user-display-methods nil)
4285 (mm-inlined-types nil)
4286 (mail-parse-charset gnus-newsgroup-charset)
4287 (mail-parse-ignored-charsets
4288 (save-excursion (set-buffer gnus-summary-buffer)
4289 gnus-newsgroup-ignored-charsets)))
4291 (if (mm-handle-undisplayer handle)
4292 (mm-remove-part handle)
4293 (mm-display-part handle)))))
4295 (defun gnus-mime-view-part-internally (&optional handle)
4296 "View the MIME part under point with an internal viewer.
4297 If no internal viewer is available, use an external viewer."
4299 (gnus-article-check-buffer)
4300 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4301 (mm-inlined-types '(".*"))
4302 (mm-inline-large-images t)
4303 (mail-parse-charset gnus-newsgroup-charset)
4304 (mail-parse-ignored-charsets
4305 (save-excursion (set-buffer gnus-summary-buffer)
4306 gnus-newsgroup-ignored-charsets))
4309 (if (mm-handle-undisplayer handle)
4310 (mm-remove-part handle)
4311 (mm-display-part handle)))))
4313 (defun gnus-mime-action-on-part (&optional action)
4314 "Do something with the MIME attachment at \(point\)."
4316 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4317 (gnus-article-check-buffer)
4318 (let ((action-pair (assoc action gnus-mime-action-alist)))
4320 (funcall (cdr action-pair)))))
4322 (defun gnus-article-part-wrapper (n function)
4323 (save-current-buffer
4324 (set-buffer gnus-article-buffer)
4325 (when (> n (length gnus-article-mime-handle-alist))
4326 (error "No such part"))
4327 (gnus-article-goto-part n)
4328 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4329 (funcall function handle))))
4331 (defun gnus-article-pipe-part (n)
4332 "Pipe MIME part N, which is the numerical prefix."
4334 (gnus-article-part-wrapper n 'mm-pipe-part))
4336 (defun gnus-article-save-part (n)
4337 "Save MIME part N, which is the numerical prefix."
4339 (gnus-article-part-wrapper n 'mm-save-part))
4341 (defun gnus-article-interactively-view-part (n)
4342 "View MIME part N interactively, which is the numerical prefix."
4344 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4346 (defun gnus-article-copy-part (n)
4347 "Copy MIME part N, which is the numerical prefix."
4349 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4351 (defun gnus-article-view-part-as-charset (n)
4352 "View MIME part N using a specified charset.
4353 N is the numerical prefix."
4355 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4357 (defun gnus-article-view-part-externally (n)
4358 "View MIME part N externally, which is the numerical prefix."
4360 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4362 (defun gnus-article-inline-part (n)
4363 "Inline MIME part N, which is the numerical prefix."
4365 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4367 (defun gnus-article-mime-match-handle-first (condition)
4369 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4370 (while (setq ihandle (pop alist))
4372 ((functionp condition)
4373 (funcall condition (cdr ihandle)))
4374 ((eq condition 'undisplayed)
4375 (not (or (mm-handle-undisplayer (cdr ihandle))
4376 (equal (mm-handle-media-type (cdr ihandle))
4377 "multipart/alternative"))))
4378 ((eq condition 'undisplayed-alternative)
4379 (not (mm-handle-undisplayer (cdr ihandle))))
4381 (gnus-article-goto-part (car ihandle))
4382 (or (not n) (< (car ihandle) n)))
4383 (setq n (car ihandle))))
4387 (defun gnus-article-view-part (&optional n)
4388 "View MIME part N, which is the numerical prefix."
4390 (save-current-buffer
4391 (set-buffer gnus-article-buffer)
4392 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4393 gnus-article-mime-match-handle-function)))
4394 (when (> n (length gnus-article-mime-handle-alist))
4395 (error "No such part"))
4396 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4397 (when (gnus-article-goto-part n)
4398 (if (equal (car handle) "multipart/alternative")
4399 (gnus-article-press-button)
4400 (when (eq (gnus-mm-display-part handle) 'internal)
4401 (gnus-set-window-start)))))))
4403 (defsubst gnus-article-mime-total-parts ()
4404 (if (bufferp (car gnus-article-mime-handles))
4406 (1- (length gnus-article-mime-handles))))
4408 (defun gnus-mm-display-part (handle)
4409 "Display HANDLE and fix MIME button."
4410 (let ((id (get-text-property (point) 'gnus-part))
4415 (let ((window (selected-window))
4416 (mail-parse-charset gnus-newsgroup-charset)
4417 (mail-parse-ignored-charsets
4418 (if (gnus-buffer-live-p gnus-summary-buffer)
4420 (set-buffer gnus-summary-buffer)
4421 gnus-newsgroup-ignored-charsets)
4425 (let ((win (gnus-get-buffer-window (current-buffer) t))
4428 (select-window win))
4431 (if (mm-handle-displayed-p handle)
4432 ;; This will remove the part.
4433 (mm-display-part handle)
4435 (narrow-to-region (point)
4436 (if (eobp) (point) (1+ (point))))
4437 (mm-display-part handle)
4438 ;; We narrow to the part itself and
4439 ;; then call the treatment functions.
4440 (goto-char (point-min))
4442 (narrow-to-region (point) (point-max))
4445 (gnus-article-mime-total-parts)
4446 (mm-handle-media-type handle)))))
4447 (if (window-live-p window)
4448 (select-window window)))))
4451 (gnus-insert-mime-button
4452 handle id (list (mm-handle-displayed-p handle)))
4453 (goto-char point))))
4455 (defun gnus-article-goto-part (n)
4456 "Go to MIME part N."
4457 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4459 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4460 (let ((gnus-tmp-name
4461 (or (mail-content-type-get (mm-handle-type handle) 'name)
4462 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4463 (mail-content-type-get (mm-handle-type handle) 'url)
4465 (gnus-tmp-type (mm-handle-media-type handle))
4466 (gnus-tmp-description
4467 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4470 (if (if displayed (car displayed)
4471 (mm-handle-displayed-p handle))
4473 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4475 gnus-tmp-type-long b e)
4476 (when (string-match ".*/" gnus-tmp-name)
4477 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4478 (setq gnus-tmp-type-long (concat gnus-tmp-type
4479 (and (not (equal gnus-tmp-name ""))
4480 (concat "; " gnus-tmp-name))))
4481 (unless (equal gnus-tmp-description "")
4482 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4487 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4488 `(keymap ,gnus-mime-button-map
4489 gnus-callback gnus-mm-display-part
4490 gnus-part ,gnus-tmp-id
4491 article-type annotation
4494 ;; Exclude a newline.
4497 (widget-convert-button
4500 :action 'gnus-widget-press-button
4501 :button-keymap gnus-mime-button-map
4503 (lambda (widget/window &optional overlay pos)
4504 ;; Needed to properly clear the message due to a bug in
4505 ;; wid-edit (XEmacs only).
4506 (if (boundp 'help-echo-owns-message)
4507 (setq help-echo-owns-message t))
4509 "%S: %s the MIME part; %S: more options"
4510 (aref gnus-mouse-2 0)
4511 ;; XEmacs will get a single widget arg; Emacs 21 will get
4512 ;; window, overlay, position.
4513 (if (mm-handle-displayed-p
4515 (with-current-buffer (gnus-overlay-buffer overlay)
4516 (widget-get (widget-at (gnus-overlay-start overlay))
4518 (widget-get widget/window :mime-handle)))
4520 (aref gnus-down-mouse-3 0))))))
4522 (defun gnus-widget-press-button (elems el)
4523 (goto-char (widget-get elems :from))
4524 (gnus-article-press-button))
4526 (defvar gnus-displaying-mime nil)
4528 (defun gnus-display-mime (&optional ihandles)
4529 "Display the MIME parts."
4531 (save-selected-window
4532 (let ((window (get-buffer-window gnus-article-buffer))
4535 (select-window window)
4536 ;; We have to do this since selecting the window
4537 ;; may change the point. So we set the window point.
4538 (set-window-point window point)))
4539 (let* ((handles (or ihandles
4540 (mm-dissect-buffer nil gnus-article-loose-mime)
4541 (and gnus-article-emulate-mime
4543 buffer-read-only handle name type b e display)
4544 (when (and (not ihandles)
4545 (not gnus-displaying-mime))
4546 ;; Top-level call; we clean up.
4547 (when gnus-article-mime-handles
4548 (mm-destroy-parts gnus-article-mime-handles)
4549 (setq gnus-article-mime-handle-alist nil));; A trick.
4550 (setq gnus-article-mime-handles handles)
4551 ;; We allow users to glean info from the handles.
4552 (when gnus-article-mime-part-function
4553 (gnus-mime-part-function handles)))
4555 (or (not (stringp (car handles)))
4558 (when (and (not ihandles)
4559 (not gnus-displaying-mime))
4560 ;; Clean up for mime parts.
4562 (delete-region (point) (point-max)))
4563 (let ((gnus-displaying-mime t))
4564 (gnus-mime-display-part handles)))
4567 (narrow-to-region (point) (point-max))
4568 (gnus-treat-article nil 1 1)
4571 ;; Highlight the headers.
4575 (narrow-to-region (point-min) (point))
4576 (gnus-treat-article 'head))))))))
4578 (defcustom gnus-mime-display-multipart-as-mixed nil
4579 "Display \"multipart\" parts as \"multipart/mixed\".
4581 If t, it overrides nil values of
4582 `gnus-mime-display-multipart-alternative-as-mixed' and
4583 `gnus-mime-display-multipart-related-as-mixed'."
4584 :group 'gnus-article-mime
4587 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4588 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4589 :group 'gnus-article-mime
4592 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4593 "Display \"multipart/related\" parts as \"multipart/mixed\".
4595 If displaying \"text/html\" is discouraged \(see
4596 `mm-discouraged-alternatives'\) images or other material inside a
4597 \"multipart/related\" part might be overlooked when this variable is nil."
4598 :group 'gnus-article-mime
4601 (defun gnus-mime-display-part (handle)
4604 ((not (stringp (car handle)))
4605 (gnus-mime-display-single handle))
4606 ;; User-defined multipart
4607 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4608 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4610 ;; multipart/alternative
4611 ((and (equal (car handle) "multipart/alternative")
4612 (not (or gnus-mime-display-multipart-as-mixed
4613 gnus-mime-display-multipart-alternative-as-mixed)))
4614 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4615 (push (cons id handle) gnus-article-mime-handle-alist)
4616 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4617 ;; multipart/related
4618 ((and (equal (car handle) "multipart/related")
4619 (not (or gnus-mime-display-multipart-as-mixed
4620 gnus-mime-display-multipart-related-as-mixed)))
4621 ;;;!!!We should find the start part, but we just default
4622 ;;;!!!to the first part.
4623 ;;(gnus-mime-display-part (cadr handle))
4624 ;;;!!! Most multipart/related is an HTML message plus images.
4625 ;;;!!! Unfortunately we are unable to let W3 display those
4626 ;;;!!! included images, so we just display it as a mixed multipart.
4627 ;;(gnus-mime-display-mixed (cdr handle))
4628 ;;;!!! No, w3 can display everything just fine.
4629 (gnus-mime-display-part (cadr handle)))
4630 ((equal (car handle) "multipart/signed")
4631 (gnus-add-wash-type 'signed)
4632 (gnus-mime-display-security handle))
4633 ((equal (car handle) "multipart/encrypted")
4634 (gnus-add-wash-type 'encrypted)
4635 (gnus-mime-display-security handle))
4636 ;; Other multiparts are handled like multipart/mixed.
4638 (gnus-mime-display-mixed (cdr handle)))))
4640 (defun gnus-mime-part-function (handles)
4641 (if (stringp (car handles))
4642 (mapcar 'gnus-mime-part-function (cdr handles))
4643 (funcall gnus-article-mime-part-function handles)))
4645 (defun gnus-mime-display-mixed (handles)
4646 (mapcar 'gnus-mime-display-part handles))
4648 (defun gnus-mime-display-single (handle)
4649 (let ((type (mm-handle-media-type handle))
4650 (ignored gnus-ignored-mime-types)
4657 (when (string-match (pop ignored) type)
4658 (throw 'ignored nil)))
4659 (if (and (setq not-attachment
4660 (and (not (mm-inline-override-p handle))
4661 (or (not (mm-handle-disposition handle))
4662 (equal (car (mm-handle-disposition handle))
4664 (mm-attachment-override-p handle))))
4665 (mm-automatic-display-p handle)
4667 (mm-inlinable-p handle)
4668 (mm-inlined-p handle))
4669 (mm-automatic-external-display-p type)))
4671 (when (equal (mm-handle-media-supertype handle) "text")
4673 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4675 (push (cons id handle) gnus-article-mime-handle-alist)
4676 (when (or (not display)
4677 (not (gnus-unbuttonized-mime-type-p type)))
4678 ;(gnus-article-insert-newline)
4679 (gnus-insert-mime-button
4680 handle id (list (or display (and not-attachment text))))
4681 (gnus-article-insert-newline)
4682 ;(gnus-article-insert-newline)
4683 ;; Remember modify the number of forward lines.
4691 (let ((mail-parse-charset gnus-newsgroup-charset)
4692 (mail-parse-ignored-charsets
4693 (save-excursion (condition-case ()
4694 (set-buffer gnus-summary-buffer)
4696 gnus-newsgroup-ignored-charsets)))
4697 (mm-display-part handle t))
4698 (goto-char (point-max)))
4699 ((and text not-attachment)
4703 (gnus-article-insert-newline)
4704 (mm-insert-inline handle (mm-get-part handle))
4705 (goto-char (point-max))))
4709 (narrow-to-region beg (point))
4712 (gnus-article-mime-total-parts)
4713 (mm-handle-media-type handle)))))))))
4715 (defun gnus-unbuttonized-mime-type-p (type)
4716 "Say whether TYPE is to be unbuttonized."
4717 (unless gnus-inhibit-mime-unbuttonizing
4719 (let ((types gnus-unbuttonized-mime-types))
4721 (when (string-match (pop types) type)
4722 (throw 'found t)))))
4724 (let ((types gnus-buttonized-mime-types))
4726 (when (string-match (pop types) type)
4727 (throw 'found t)))))))))
4729 (defun gnus-article-insert-newline ()
4730 "Insert a newline, but mark it as undeletable."
4731 (gnus-put-text-property
4732 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4734 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4735 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4738 handle buffer-read-only from props begend not-pref)
4739 (save-window-excursion
4742 (narrow-to-region (car ibegend)
4745 (goto-char (car ibegend))
4748 (delete-region (point-min) (point-max))
4749 (mm-remove-parts handles))
4750 (setq begend (list (point-marker)))
4752 (unless (setq not-pref (cadr (member preferred ihandles)))
4753 (setq not-pref (car ihandles)))
4756 (not (gnus-unbuttonized-mime-type-p
4757 "multipart/alternative")))
4758 (gnus-add-text-properties
4761 (insert (format "%d. " id))
4765 (unless ,(not ibegend)
4766 (setq gnus-article-mime-handle-alist
4767 ',gnus-article-mime-handle-alist))
4768 (gnus-mime-display-alternative
4769 ',ihandles ',not-pref ',begend ,id))
4770 keymap ,gnus-mime-button-map
4771 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4772 face ,gnus-article-button-face
4775 (widget-convert-button 'link from (point)
4776 :action 'gnus-widget-press-button
4777 :button-keymap gnus-widget-button-keymap)
4779 (while (setq handle (pop handles))
4780 (gnus-add-text-properties
4783 (insert (format "(%c) %-18s"
4784 (if (equal handle preferred) ?* ? )
4785 (mm-handle-media-type handle)))
4789 (unless ,(not ibegend)
4790 (setq gnus-article-mime-handle-alist
4791 ',gnus-article-mime-handle-alist))
4792 (gnus-mime-display-alternative
4793 ',ihandles ',handle ',begend ,id))
4794 keymap ,gnus-mime-button-map
4795 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4796 face ,gnus-article-button-face
4799 (widget-convert-button 'link from (point)
4800 :action 'gnus-widget-press-button
4801 :button-keymap gnus-widget-button-keymap)
4805 (if (stringp (car preferred))
4806 (gnus-display-mime preferred)
4807 (let ((mail-parse-charset gnus-newsgroup-charset)
4808 (mail-parse-ignored-charsets
4809 (save-excursion (set-buffer gnus-summary-buffer)
4810 gnus-newsgroup-ignored-charsets)))
4811 (mm-display-part preferred)
4815 (narrow-to-region (car begend) (point-max))
4817 nil (length gnus-article-mime-handle-alist)
4818 (gnus-article-mime-total-parts)
4819 (mm-handle-media-type handle))))))
4820 (goto-char (point-max))
4821 (setcdr begend (point-marker)))))
4823 (goto-char point))))
4825 (defconst gnus-article-wash-status-strings
4826 (let ((alist '((cite "c" "Possible hidden citation text"
4827 " " "All citation text visible")
4828 (headers "h" "Hidden headers"
4829 " " "All headers visible.")
4830 (pgp "p" "Encrypted or signed message status hidden"
4831 " " "No hidden encryption nor digital signature status")
4832 (signature "s" "Signature has been hidden"
4833 " " "Signature is visible")
4834 (overstrike "o" "Overstrike (^H) characters applied"
4835 " " "No overstrike characters applied")
4836 (emphasis "e" "/*_Emphasis_*/ characters applied"
4837 " " "No /*_emphasis_*/ characters applied")))
4839 (dolist (entry alist result)
4840 (let ((key (nth 0 entry))
4841 (on (copy-sequence (nth 1 entry)))
4842 (on-help (nth 2 entry))
4843 (off (copy-sequence (nth 3 entry)))
4844 (off-help (nth 4 entry)))
4845 (put-text-property 0 1 'help-echo on-help on)
4846 (put-text-property 0 1 'help-echo off-help off)
4847 (push (list key on off) result))))
4848 "Alist of strings describing wash status in the mode line.
4849 Each entry has the form (KEY ON OF), where the KEY is a symbol
4850 representing the particular washing function, ON is the string to use
4851 in the article mode line when the washing function is active, and OFF
4852 is the string to use when it is inactive.")
4854 (defun gnus-article-wash-status-entry (key value)
4855 (let ((entry (assoc key gnus-article-wash-status-strings)))
4856 (if value (nth 1 entry) (nth 2 entry))))
4858 (defun gnus-article-wash-status ()
4859 "Return a string which display status of article washing."
4861 (set-buffer gnus-article-buffer)
4862 (let ((cite (memq 'cite gnus-article-wash-types))
4863 (headers (memq 'headers gnus-article-wash-types))
4864 (boring (memq 'boring-headers gnus-article-wash-types))
4865 (pgp (memq 'pgp gnus-article-wash-types))
4866 (pem (memq 'pem gnus-article-wash-types))
4867 (signed (memq 'signed gnus-article-wash-types))
4868 (encrypted (memq 'encrypted gnus-article-wash-types))
4869 (signature (memq 'signature gnus-article-wash-types))
4870 (overstrike (memq 'overstrike gnus-article-wash-types))
4871 (emphasis (memq 'emphasis gnus-article-wash-types)))
4873 (gnus-article-wash-status-entry 'cite cite)
4874 (gnus-article-wash-status-entry 'headers (or headers boring))
4875 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4876 (gnus-article-wash-status-entry 'signature signature)
4877 (gnus-article-wash-status-entry 'overstrike overstrike)
4878 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4880 (defun gnus-add-wash-type (type)
4881 "Add a washing of TYPE to the current status."
4882 (add-to-list 'gnus-article-wash-types type))
4884 (defun gnus-delete-wash-type (type)
4885 "Add a washing of TYPE to the current status."
4886 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4888 (defun gnus-add-image (category image)
4889 "Add IMAGE of CATEGORY to the list of displayed images."
4890 (let ((entry (assq category gnus-article-image-alist)))
4892 (setq entry (list category))
4893 (push entry gnus-article-image-alist))
4894 (nconc entry (list image))))
4896 (defun gnus-delete-images (category)
4897 "Delete all images in CATEGORY."
4898 (let ((entry (assq category gnus-article-image-alist)))
4899 (dolist (image (cdr entry))
4900 (gnus-remove-image image category))
4901 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4902 (gnus-delete-wash-type category)))
4904 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4906 (defun gnus-article-maybe-hide-headers ()
4907 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4908 Provided for backwards compatibility."
4909 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4910 (not (save-excursion (set-buffer gnus-summary-buffer)
4911 gnus-have-all-headers)))
4912 (not gnus-inhibit-hiding))
4913 (gnus-article-hide-headers)))
4917 (defun gnus-output-to-file (file-name)
4918 "Append the current article to a file named FILE-NAME."
4919 (let ((artbuf (current-buffer)))
4921 (insert-buffer-substring artbuf)
4922 ;; Append newline at end of the buffer as separator, and then
4924 (goto-char (point-max))
4926 (let ((file-name-coding-system nnmail-pathname-coding-system))
4927 (mm-append-to-file (point-min) (point-max) file-name))
4930 (defun gnus-narrow-to-page (&optional arg)
4931 "Narrow the article buffer to a page.
4932 If given a numerical ARG, move forward ARG pages."
4934 (setq arg (if arg (prefix-numeric-value arg) 0))
4936 (set-buffer gnus-article-buffer)
4937 (goto-char (point-min))
4939 ;; Remove any old next/prev buttons.
4940 (when (gnus-visual-p 'page-marker)
4941 (let ((buffer-read-only nil))
4942 (gnus-remove-text-with-property 'gnus-prev)
4943 (gnus-remove-text-with-property 'gnus-next)))
4946 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4948 (re-search-forward page-delimiter nil 'move arg)))
4949 (goto-char (match-end 0))
4951 (goto-char (point-min))
4952 (setq gnus-page-broken
4953 (and (re-search-forward page-delimiter nil t) t))))
4954 (when gnus-page-broken
4957 (if (re-search-forward page-delimiter nil 'move)
4960 (when (and (gnus-visual-p 'page-marker)
4961 (not (= (point-min) 1)))
4963 (goto-char (point-min))
4964 (gnus-insert-prev-page-button)))
4965 (when (and (gnus-visual-p 'page-marker)
4966 (< (+ (point-max) 2) (buffer-size)))
4968 (goto-char (point-max))
4969 (gnus-insert-next-page-button))))))
4971 ;; Article mode commands
4973 (defun gnus-article-goto-next-page ()
4974 "Show the next page of the article."
4976 (when (gnus-article-next-page)
4977 (goto-char (point-min))
4978 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4981 (defun gnus-article-goto-prev-page ()
4982 "Show the previous page of the article."
4985 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4986 (gnus-article-prev-page nil)))
4988 ;; This is cleaner but currently breaks `gnus-pick-mode':
4990 ;; (defun gnus-article-goto-next-page ()
4991 ;; "Show the next page of the article."
4993 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
4994 ;; (gnus-summary-next-page)))
4996 ;; (defun gnus-article-goto-prev-page ()
4997 ;; "Show the next page of the article."
4999 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5000 ;; (gnus-summary-prev-page)))
5002 (defun gnus-article-next-page (&optional lines)
5003 "Show the next page of the current article.
5004 If end of article, return non-nil. Otherwise return nil.
5005 Argument LINES specifies lines to be scrolled up."
5007 (move-to-window-line -1)
5010 (and (pos-visible-in-window-p) ;Not continuation line.
5011 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5012 ;; Nothing in this page.
5013 (if (or (not gnus-page-broken)
5017 (eobp)))) ;Real end-of-buffer?
5019 (when gnus-article-over-scroll
5020 (gnus-article-next-page-1 lines))
5022 (gnus-narrow-to-page 1) ;Go to next page.
5024 ;; More in this page.
5025 (gnus-article-next-page-1 lines)
5028 (defun gnus-article-next-page-1 (lines)
5029 (let ((scroll-in-place nil))
5033 ;; Long lines may cause an end-of-buffer error.
5034 (goto-char (point-max)))))
5035 (move-to-window-line 0))
5037 (defun gnus-article-prev-page (&optional lines)
5038 "Show previous page of current article.
5039 Argument LINES specifies lines to be scrolled down."
5041 (move-to-window-line 0)
5042 (if (and gnus-page-broken
5044 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5046 (gnus-narrow-to-page -1) ;Go to previous page.
5047 (goto-char (point-max))
5049 (let ((scroll-in-place nil))
5053 (beginning-of-buffer
5054 (goto-char (point-min))))
5055 (move-to-window-line 0)))))
5057 (defun gnus-article-only-boring-p ()
5058 "Decide whether there is only boring text remaining in the article.
5059 Something \"interesting\" is a word of at least two letters that does
5060 not have a face in `gnus-article-boring-faces'."
5061 (when (and gnus-article-skip-boring
5062 (boundp 'gnus-article-boring-faces)
5063 (symbol-value 'gnus-article-boring-faces))
5066 (while (re-search-forward "\\b\\w\\w" nil t)
5068 (when (not (gnus-intersection
5069 (gnus-faces-at (point))
5070 (symbol-value 'gnus-article-boring-faces)))
5071 (throw 'only-boring nil)))
5072 (throw 'only-boring t)))))
5074 (defun gnus-article-refer-article ()
5075 "Read article specified by message-id around point."
5078 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5079 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5080 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5081 (let ((msg-id (concat "<" (match-string 0) ">")))
5082 (set-buffer gnus-summary-buffer)
5083 (gnus-summary-refer-article msg-id))
5084 (error "No references around point"))))
5086 (defun gnus-article-show-summary ()
5087 "Reconfigure windows to show summary buffer."
5089 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5090 (error "There is no summary buffer for this article buffer")
5091 (gnus-article-set-globals)
5092 (gnus-configure-windows 'article)
5093 (gnus-summary-goto-subject gnus-current-article)
5094 (gnus-summary-position-point)))
5096 (defun gnus-article-describe-briefly ()
5097 "Describe article mode commands briefly."
5099 (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")))
5101 (defun gnus-article-summary-command ()
5102 "Execute the last keystroke in the summary buffer."
5104 (let ((obuf (current-buffer))
5105 (owin (current-window-configuration))
5107 (switch-to-buffer gnus-article-current-summary 'norecord)
5108 (setq func (lookup-key (current-local-map) (this-command-keys)))
5109 (call-interactively func)
5111 (set-window-configuration owin)
5112 (set-window-point (get-buffer-window (current-buffer)) (point))))
5114 (defun gnus-article-summary-command-nosave ()
5115 "Execute the last keystroke in the summary buffer."
5118 (pop-to-buffer gnus-article-current-summary 'norecord)
5119 (setq func (lookup-key (current-local-map) (this-command-keys)))
5120 (call-interactively func)))
5122 (defun gnus-article-check-buffer ()
5123 "Beep if not in an article buffer."
5124 (unless (equal major-mode 'gnus-article-mode)
5125 (error "Command invoked outside of a Gnus article buffer")))
5127 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5128 "Read a summary buffer key sequence and execute it from the article buffer."
5130 (gnus-article-check-buffer)
5132 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5133 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5134 "=" "^" "\M-^" "|"))
5140 '("n" "Gn" "p" "Gp"))
5143 (set-buffer gnus-article-current-summary)
5144 (let (gnus-pick-mode)
5145 (push (or key last-command-event) unread-command-events)
5146 (setq keys (if (featurep 'xemacs)
5147 (events-to-keys (read-key-sequence nil))
5148 (read-key-sequence nil)))))
5152 (if (or (member keys nosaves)
5153 (member keys nosave-but-article)
5154 (member keys nosave-in-article))
5156 (save-window-excursion
5157 (pop-to-buffer gnus-article-current-summary 'norecord)
5158 ;; We disable the pick minor mode commands.
5159 (let (gnus-pick-mode)
5160 (setq func (lookup-key (current-local-map) keys))))
5164 (unless (member keys nosave-in-article)
5165 (set-buffer gnus-article-current-summary))
5166 (call-interactively func)
5167 (setq new-sum-point (point)))
5168 (when (member keys nosave-but-article)
5169 (pop-to-buffer gnus-article-buffer 'norecord)))
5170 ;; These commands should restore window configuration.
5171 (let ((obuf (current-buffer))
5172 (owin (current-window-configuration))
5174 (summary gnus-article-current-summary)
5175 func in-buffer selected)
5176 (if not-restore-window
5177 (pop-to-buffer summary 'norecord)
5178 (switch-to-buffer summary 'norecord))
5179 (setq in-buffer (current-buffer))
5180 ;; We disable the pick minor mode commands.
5181 (if (and (setq func (let (gnus-pick-mode)
5182 (lookup-key (current-local-map) keys)))
5185 (call-interactively func)
5186 (setq new-sum-point (point))
5187 (when (eq in-buffer (current-buffer))
5188 (setq selected (gnus-summary-select-article))
5190 (unless not-restore-window
5191 (set-window-configuration owin))
5192 (when (eq selected 'old)
5194 (set-window-start (get-buffer-window (current-buffer))
5196 (set-window-point (get-buffer-window (current-buffer))
5198 (let ((win (get-buffer-window gnus-article-current-summary)))
5200 (set-window-point win new-sum-point)))) )
5201 (switch-to-buffer gnus-article-buffer)
5204 (defun gnus-article-describe-key (key)
5205 "Display documentation of the function invoked by KEY. KEY is a string."
5206 (interactive "kDescribe key: ")
5207 (gnus-article-check-buffer)
5208 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5210 (set-buffer gnus-article-current-summary)
5211 (let (gnus-pick-mode)
5212 (if (featurep 'xemacs)
5214 (push (elt key 0) unread-command-events)
5215 (setq key (events-to-keys
5216 (read-key-sequence "Describe key: "))))
5217 (setq unread-command-events
5219 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5220 (string-to-list key)))
5221 (setq key (read-key-sequence "Describe key: "))))
5223 (describe-key key)))
5225 (defun gnus-article-describe-key-briefly (key &optional insert)
5226 "Display documentation of the function invoked by KEY. KEY is a string."
5227 (interactive "kDescribe key: \nP")
5228 (gnus-article-check-buffer)
5229 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5231 (set-buffer gnus-article-current-summary)
5232 (let (gnus-pick-mode)
5233 (if (featurep 'xemacs)
5235 (push (elt key 0) unread-command-events)
5236 (setq key (events-to-keys
5237 (read-key-sequence "Describe key: "))))
5238 (setq unread-command-events
5240 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5241 (string-to-list key)))
5242 (setq key (read-key-sequence "Describe key: "))))
5243 (describe-key-briefly key insert))
5244 (describe-key-briefly key insert)))
5246 (defun gnus-article-reply-with-original (&optional wide)
5247 "Start composing a reply mail to the current message.
5248 The text in the region will be yanked. If the region isn't active,
5249 the entire article will be yanked."
5251 (let ((article (cdr gnus-article-current))
5253 (if (not (gnus-mark-active-p))
5254 (with-current-buffer gnus-summary-buffer
5255 (gnus-summary-reply (list (list article)) wide))
5256 (setq contents (buffer-substring (point) (mark t)))
5257 ;; Deactivate active regions.
5258 (when (and (boundp 'transient-mark-mode)
5259 transient-mark-mode)
5260 (setq mark-active nil))
5261 (with-current-buffer gnus-summary-buffer
5263 (list (list article contents)) wide)))))
5265 (defun gnus-article-followup-with-original ()
5266 "Compose a followup to the current article.
5267 The text in the region will be yanked. If the region isn't active,
5268 the entire article will be yanked."
5270 (let ((article (cdr gnus-article-current))
5272 (if (not (gnus-mark-active-p))
5273 (with-current-buffer gnus-summary-buffer
5274 (gnus-summary-followup (list (list article))))
5275 (setq contents (buffer-substring (point) (mark t)))
5276 ;; Deactivate active regions.
5277 (when (and (boundp 'transient-mark-mode)
5278 transient-mark-mode)
5279 (setq mark-active nil))
5280 (with-current-buffer gnus-summary-buffer
5281 (gnus-summary-followup
5282 (list (list article contents)))))))
5284 (defun gnus-article-hide (&optional arg force)
5285 "Hide all the gruft in the current article.
5286 This means that signatures, cited text and (some) headers will be
5288 If given a prefix, show the hidden text instead."
5289 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5290 (gnus-article-hide-headers arg)
5291 (gnus-article-hide-list-identifiers arg)
5292 (gnus-article-hide-citation-maybe arg force)
5293 (gnus-article-hide-signature arg))
5295 (defun gnus-article-maybe-highlight ()
5296 "Do some article highlighting if article highlighting is requested."
5297 (when (gnus-visual-p 'article-highlight 'highlight)
5298 (gnus-article-highlight-some)))
5300 (defun gnus-check-group-server ()
5301 ;; Make sure the connection to the server is alive.
5302 (unless (gnus-server-opened
5303 (gnus-find-method-for-group gnus-newsgroup-name))
5304 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5305 (gnus-request-group gnus-newsgroup-name t)))
5308 (autoload 'nneething-get-file-name "nneething"))
5310 (defun gnus-request-article-this-buffer (article group)
5311 "Get an article and insert it into this buffer."
5312 (let (do-update-line sparse-header)
5316 (gnus-kill-all-overlays)
5317 (setq group (or group gnus-newsgroup-name))
5319 ;; Using `gnus-request-article' directly will insert the article into
5320 ;; `nntp-server-buffer' - so we'll save some time by not having to
5321 ;; copy it from the server buffer into the article buffer.
5323 ;; We only request an article by message-id when we do not have the
5324 ;; headers for it, so we'll have to get those.
5325 (when (stringp article)
5326 (gnus-read-header article))
5328 ;; If the article number is negative, that means that this article
5329 ;; doesn't belong in this newsgroup (possibly), so we find its
5330 ;; message-id and request it by id instead of number.
5331 (when (and (numberp article)
5333 (get-buffer gnus-summary-buffer)
5334 (gnus-buffer-exists-p gnus-summary-buffer))
5336 (set-buffer gnus-summary-buffer)
5337 (let ((header (gnus-summary-article-header article)))
5340 ((memq article gnus-newsgroup-sparse)
5341 ;; This is a sparse gap article.
5342 (setq do-update-line article)
5343 (setq article (mail-header-id header))
5344 (setq sparse-header (gnus-read-header article))
5345 (setq gnus-newsgroup-sparse
5346 (delq article gnus-newsgroup-sparse)))
5348 ;; It's a real article.
5349 (setq article (mail-header-id header)))
5351 ;; It is an extracted pseudo-article.
5352 (setq article 'pseudo)
5353 (gnus-request-pseudo-article header))))
5355 (let ((method (gnus-find-method-for-group
5356 gnus-newsgroup-name)))
5357 (when (and (eq (car method) 'nneething)
5359 (let ((dir (nneething-get-file-name
5360 (mail-header-id header))))
5361 (when (and (stringp dir)
5362 (file-directory-p dir))
5363 (setq article 'nneething)
5364 (gnus-group-enter-directory dir))))))))
5367 ;; Refuse to select canceled articles.
5368 ((and (numberp article)
5370 (get-buffer gnus-summary-buffer)
5371 (gnus-buffer-exists-p gnus-summary-buffer)
5372 (eq (cdr (save-excursion
5373 (set-buffer gnus-summary-buffer)
5374 (assq article gnus-newsgroup-reads)))
5375 gnus-canceled-mark))
5377 ;; We first check `gnus-original-article-buffer'.
5378 ((and (get-buffer gnus-original-article-buffer)
5381 (set-buffer gnus-original-article-buffer)
5382 (and (equal (car gnus-original-article) group)
5383 (eq (cdr gnus-original-article) article))))
5384 (insert-buffer-substring gnus-original-article-buffer)
5386 ;; Check the backlog.
5387 ((and gnus-keep-backlog
5388 (gnus-backlog-request-article group article (current-buffer)))
5390 ;; Check asynchronous pre-fetch.
5391 ((gnus-async-request-fetched-article group article (current-buffer))
5392 (gnus-async-prefetch-next group article gnus-summary-buffer)
5393 (when (and (numberp article) gnus-keep-backlog)
5394 (gnus-backlog-enter-article group article (current-buffer)))
5397 ((and gnus-use-cache
5399 (gnus-cache-request-article article group))
5401 ;; Check the agent cache.
5402 ((gnus-agent-request-article article group)
5404 ;; Get the article and put into the article buffer.
5405 ((or (stringp article)
5407 (let ((gnus-override-method gnus-override-method)
5408 (methods (and (stringp article)
5409 gnus-refer-article-method))
5410 (backend (car (gnus-find-method-for-group
5411 gnus-newsgroup-name)))
5413 (buffer-read-only nil))
5414 (if (or (not (listp methods))
5415 (and (symbolp (car methods))
5416 (assq (car methods) nnoo-definition-alist)))
5417 (setq methods (list methods)))
5418 (when (and (null gnus-override-method)
5420 (setq gnus-override-method (pop methods)))
5422 (when (eq gnus-override-method 'current)
5423 (setq gnus-override-method
5424 (with-current-buffer gnus-summary-buffer
5425 gnus-current-select-method)))
5427 (gnus-kill-all-overlays)
5428 (let ((gnus-newsgroup-name group))
5429 (gnus-check-group-server))
5431 ((gnus-request-article article group (current-buffer))
5432 (when (numberp article)
5433 (gnus-async-prefetch-next group article
5434 gnus-summary-buffer)
5435 (when gnus-keep-backlog
5436 (gnus-backlog-enter-article
5437 group article (current-buffer))))
5438 (setq result 'article))
5440 (setq gnus-override-method (pop methods)))
5441 ((not (string-match "^400 "
5442 (nnheader-get-report backend)))
5443 ;; If we get 400 server disconnect, reconnect and
5444 ;; retry; otherwise, assume the article has expired.
5445 (setq result 'done))))
5446 (and (eq result 'article) 'article)))
5450 ;; Associate this article with the current summary buffer.
5451 (setq gnus-article-current-summary gnus-summary-buffer)
5453 ;; Take the article from the original article buffer
5454 ;; and place it in the buffer it's supposed to be in.
5455 (when (and (get-buffer gnus-article-buffer)
5456 (equal (buffer-name (current-buffer))
5457 (buffer-name (get-buffer gnus-article-buffer))))
5459 (if (get-buffer gnus-original-article-buffer)
5460 (set-buffer gnus-original-article-buffer)
5461 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5462 (buffer-disable-undo)
5463 (setq major-mode 'gnus-original-article-mode)
5464 (setq buffer-read-only t))
5465 (let (buffer-read-only)
5467 (insert-buffer-substring gnus-article-buffer))
5468 (setq gnus-original-article (cons group article)))
5471 (run-hooks 'gnus-article-decode-hook)
5472 ;; Mark article as decoded or not.
5473 (setq gnus-article-decoded-p gnus-article-decode-hook))
5475 ;; Update sparse articles.
5476 (when (and do-update-line
5477 (or (numberp article)
5479 (let ((buf (current-buffer)))
5480 (set-buffer gnus-summary-buffer)
5481 (gnus-summary-update-article do-update-line sparse-header)
5482 (gnus-summary-goto-subject do-update-line nil t)
5483 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5485 (set-buffer buf))))))
5491 (defcustom gnus-article-edit-mode-hook nil
5492 "Hook run in article edit mode buffers."
5493 :group 'gnus-article-various
5496 (defvar gnus-article-edit-done-function nil)
5498 (defvar gnus-article-edit-mode-map nil)
5499 (defvar gnus-article-edit-mode nil)
5501 ;; Should we be using derived.el for this?
5502 (unless gnus-article-edit-mode-map
5503 (setq gnus-article-edit-mode-map (make-keymap))
5504 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5506 (gnus-define-keys gnus-article-edit-mode-map
5507 "\C-c?" describe-mode
5508 "\C-c\C-c" gnus-article-edit-done
5509 "\C-c\C-k" gnus-article-edit-exit
5510 "\C-c\C-f\C-t" message-goto-to
5511 "\C-c\C-f\C-o" message-goto-from
5512 "\C-c\C-f\C-b" message-goto-bcc
5513 ;;"\C-c\C-f\C-w" message-goto-fcc
5514 "\C-c\C-f\C-c" message-goto-cc
5515 "\C-c\C-f\C-s" message-goto-subject
5516 "\C-c\C-f\C-r" message-goto-reply-to
5517 "\C-c\C-f\C-n" message-goto-newsgroups
5518 "\C-c\C-f\C-d" message-goto-distribution
5519 "\C-c\C-f\C-f" message-goto-followup-to
5520 "\C-c\C-f\C-m" message-goto-mail-followup-to
5521 "\C-c\C-f\C-k" message-goto-keywords
5522 "\C-c\C-f\C-u" message-goto-summary
5523 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5524 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5525 "\C-c\C-b" message-goto-body
5526 "\C-c\C-i" message-goto-signature
5528 "\C-c\C-t" message-insert-to
5529 "\C-c\C-n" message-insert-newsgroups
5530 "\C-c\C-o" message-sort-headers
5531 "\C-c\C-e" message-elide-region
5532 "\C-c\C-v" message-delete-not-region
5533 "\C-c\C-z" message-kill-to-signature
5534 "\M-\r" message-newline-and-reformat
5535 "\C-c\C-a" mml-attach-file
5536 "\C-a" message-beginning-of-line
5538 "\M-;" comment-region)
5540 (gnus-define-keys (gnus-article-edit-wash-map
5541 "\C-c\C-w" gnus-article-edit-mode-map)
5542 "f" gnus-article-edit-full-stops))
5545 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5547 ["Fetch To" message-insert-to t]
5548 ["Fetch Newsgroups" message-insert-newsgroups t]
5550 ["To" message-goto-to t]
5551 ["From" message-goto-from t]
5552 ["Subject" message-goto-subject t]
5553 ["Cc" message-goto-cc t]
5554 ["Reply-To" message-goto-reply-to t]
5555 ["Summary" message-goto-summary t]
5556 ["Keywords" message-goto-keywords t]
5557 ["Newsgroups" message-goto-newsgroups t]
5558 ["Followup-To" message-goto-followup-to t]
5559 ["Mail-Followup-To" message-goto-mail-followup-to t]
5560 ["Distribution" message-goto-distribution t]
5561 ["Body" message-goto-body t]
5562 ["Signature" message-goto-signature t]))
5564 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5565 "Major mode for editing articles.
5566 This is an extended text-mode.
5568 \\{gnus-article-edit-mode-map}"
5569 (make-local-variable 'gnus-article-edit-done-function)
5570 (make-local-variable 'gnus-prev-winconf)
5571 (set (make-local-variable 'font-lock-defaults)
5572 '(message-font-lock-keywords t))
5573 (set (make-local-variable 'mail-header-separator) "")
5574 (set (make-local-variable 'gnus-article-edit-mode) t)
5575 (easy-menu-add message-mode-field-menu message-mode-map)
5577 (setq buffer-read-only nil)
5578 (buffer-enable-undo)
5581 (defun gnus-article-edit (&optional force)
5582 "Edit the current article.
5583 This will have permanent effect only in mail groups.
5584 If FORCE is non-nil, allow editing of articles even in read-only
5587 (when (and (not force)
5588 (gnus-group-read-only-p))
5589 (error "The current newsgroup does not support article editing"))
5590 (gnus-article-date-original)
5591 (gnus-article-edit-article
5593 `(lambda (no-highlight)
5595 (gnus-summary-edit-article-done
5596 ,(or (mail-header-references gnus-current-headers) "")
5597 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5599 (defun gnus-article-edit-article (start-func exit-func)
5600 "Start editing the contents of the current article buffer."
5601 (let ((winconf (current-window-configuration)))
5602 (set-buffer gnus-article-buffer)
5603 (gnus-article-edit-mode)
5604 (funcall start-func)
5605 (set-buffer-modified-p nil)
5606 (gnus-configure-windows 'edit-article)
5607 (setq gnus-article-edit-done-function exit-func)
5608 (setq gnus-prev-winconf winconf)
5609 (gnus-message 6 "C-c C-c to end edits")))
5611 (defun gnus-article-edit-done (&optional arg)
5612 "Update the article edits and exit."
5614 (let ((func gnus-article-edit-done-function)
5615 (buf (current-buffer))
5616 (start (window-start))
5618 (winconf gnus-prev-winconf))
5619 (widen) ;; Widen it in case that users narrowed the buffer.
5622 ;; The cache and backlog have to be flushed somewhat.
5623 (when gnus-keep-backlog
5624 (gnus-backlog-remove-article
5625 (car gnus-article-current) (cdr gnus-article-current)))
5626 ;; Flush original article as well.
5628 (when (get-buffer gnus-original-article-buffer)
5629 (set-buffer gnus-original-article-buffer)
5630 (setq gnus-original-article nil)))
5631 (when gnus-use-cache
5632 (gnus-cache-update-article
5633 (car gnus-article-current) (cdr gnus-article-current)))
5634 ;; We remove all text props from the article buffer.
5635 (kill-all-local-variables)
5636 (set-text-properties (point-min) (point-max) nil)
5638 (set-window-configuration winconf)
5640 (set-window-start (get-buffer-window buf) start)
5641 (set-window-point (get-buffer-window buf) (point)))
5642 (gnus-summary-show-article))
5644 (defun gnus-article-edit-exit ()
5645 "Exit the article editing without updating."
5647 (when (or (not (buffer-modified-p))
5648 (yes-or-no-p "Article modified; kill anyway? "))
5649 (let ((curbuf (current-buffer))
5651 (window-start (window-start)))
5653 (if (gnus-buffer-live-p gnus-original-article-buffer)
5654 (insert-buffer gnus-original-article-buffer))
5655 (let ((winconf gnus-prev-winconf))
5656 (kill-all-local-variables)
5658 (set-window-configuration winconf)
5659 ;; Tippy-toe some to make sure that point remains where it was.
5660 (save-current-buffer
5662 (set-window-start (get-buffer-window (current-buffer)) window-start)
5664 (gnus-summary-show-article)))
5666 (defun gnus-article-edit-full-stops ()
5667 "Interactively repair spacing at end of sentences."
5670 (goto-char (point-min))
5671 (search-forward-regexp "^$" nil t)
5672 (let ((case-fold-search nil))
5673 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5676 ;;; Article highlights
5679 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5681 ;;; Internal Variables:
5683 (defcustom gnus-button-url-regexp
5684 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5685 "\\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:]]\\)"
5686 "\\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\\)\\)")
5687 "Regular expression that matches URLs."
5688 :group 'gnus-article-buttons
5691 (defcustom gnus-button-valid-fqdn-regexp
5692 message-valid-fqdn-regexp
5693 "Regular expression that matches a valid FQDN."
5694 :group 'gnus-article-buttons
5697 (defcustom gnus-button-man-handler 'manual-entry
5698 "Function to use for displaying man pages.
5699 The function must take at least one argument with a string naming the
5701 :type '(choice (function-item :tag "Man" manual-entry)
5702 (function-item :tag "Woman" woman)
5703 (function :tag "Other"))
5704 :group 'gnus-article-buttons)
5706 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5707 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5708 If the default site is too slow, try to find a CTAN mirror, see
5709 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5710 the variable `gnus-button-handle-ctan'."
5711 :group 'gnus-article-buttons
5712 :link '(custom-manual "(gnus)Group Parameters")
5713 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5714 (const "http://tug.ctan.org/tex-archive/")
5715 (const "http://www.dante.de/CTAN/")
5716 (string :tag "Other")))
5718 (defcustom gnus-button-ctan-handler 'browse-url
5719 "Function to use for displaying CTAN links.
5720 The function must take one argument, the string naming the URL."
5721 :type '(choice (function-item :tag "Browse Url" browse-url)
5722 (function :tag "Other"))
5723 :group 'gnus-article-buttons)
5725 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5726 "Bogus strings removed from CTAN URLs."
5727 :group 'gnus-article-buttons
5728 :type '(choice (const "^/?tex-archive/\\|/")
5729 (regexp :tag "Other")))
5731 (defcustom gnus-button-ctan-directory-regexp
5733 "\\("; Cannot use `\(?: ... \)' (compatibility with Emacs 20).
5734 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5735 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5736 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5738 "Regular expression for ctan directories.
5739 It should match all directories in the top level of `gnus-ctan-url'."
5740 :group 'gnus-article-buttons
5743 (defcustom gnus-button-mid-or-mail-regexp
5744 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
5745 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5746 gnus-button-valid-fqdn-regexp
5748 "Regular expression that matches a message ID or a mail address."
5749 :group 'gnus-article-buttons
5752 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5753 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5754 Strings like this can be either a message ID or a mail address. If it is one
5755 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5756 message ID or a mail address, respectively. If this variable is set to the
5757 symbol `ask', always query the user what do do. If it is a function, this
5758 function will be called with the string as it's only argument. The function
5759 must return `mid', `mail', `invalid' or `ask'."
5760 :group 'gnus-article-buttons
5761 :type '(choice (function-item :tag "Heuristic function"
5762 gnus-button-mid-or-mail-heuristic)
5767 (defcustom gnus-button-mid-or-mail-heuristic-alist
5768 '((-10.0 . ".+\\$.+@")
5771 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5772 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5773 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5774 (-1.0 . "^[^a-z]+@")
5776 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5777 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5778 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5779 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5782 (-1.0 . "^[0-9][0-9]")
5784 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5785 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5786 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5787 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5789 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5790 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5793 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5795 ;; compensation for TDMA dated mail addresses:
5796 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5798 (-20.0 . "\\.fsf@") ;; Gnus
5801 (-20.0 . "_-_") ;; Subject change in thread
5803 (-20.0 . "\\.ln@") ;; leafnode
5804 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5805 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5807 ;; (5.0 . "") ;; $local_part_len <= 7
5808 (10.0 . "^[^0-9]+@")
5809 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5810 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5813 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5815 (0.5 . "^[A-Z][a-z]")
5816 (0.5 . "^[A-Z][a-z][a-z]")
5817 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5818 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5819 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5821 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5822 address. The REGEXP is processed with `case-fold-search' set to nil."
5823 :group 'gnus-article-buttons
5824 :type '(repeat (cons (number :tag "Rate")
5825 (regexp :tag "Regexp"))))
5827 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5828 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5829 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5830 address, `ask' if unsure and `invalid' if the string is invalid."
5831 (let ((case-fold-search nil)
5832 (list gnus-button-mid-or-mail-heuristic-alist)
5833 (result 0) rate regexp lpartlen elem)
5835 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5836 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5837 ;; Certain special cases...
5840 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
5841 "^[0-9]+\\.[0-9]+@compuserve\\|"
5842 "@public\\.gmane\\.org")
5844 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
5845 (setq result 'mail))
5846 (when (string-match "@.*@\\| " mid-or-mail)
5847 (gnus-message 8 "`%s' is invalid." mid-or-mail)
5848 (setq result 'invalid))
5849 ;; Nothing more to do, if result is not a number here...
5850 (when (numberp result)
5852 (setq elem (car list)
5856 (when (string-match regexp mid-or-mail)
5857 (setq result (+ result rate))
5859 9 "`%s' matched `%s', rate `%s', result `%s'."
5860 mid-or-mail regexp rate result)))
5861 (when (<= lpartlen 7)
5862 (setq result (+ result 5.0))
5863 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
5864 mid-or-mail result))
5865 (when (>= lpartlen 12)
5866 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
5868 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
5869 ;; Long local part should contain realname if e-mail address,
5870 ;; too many digits: message-id.
5871 ;; $score -= 5.0 + 0.1 * $local_part_len;
5872 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
5873 (setq result (+ result rate))
5875 9 "Many digits in `%s', rate `%s', result `%s'."
5876 mid-or-mail rate result))
5877 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
5879 ;; Too few vowels [^aeiouy]{4,}.*\@
5880 (setq result (+ result -5.0))
5882 9 "Few vowels in `%s', rate `%s', result `%s'."
5883 mid-or-mail -5.0 result))
5885 (setq result (+ result 5.0))
5887 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
5888 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
5889 ;; Maybe we should make this a customizable alist: (condition . 'result)
5891 ((symbolp result) result)
5892 ;; Now convert number into proper results:
5893 ((< result -10.0) 'mid)
5894 ((> result 10.0) 'mail)
5897 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5898 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
5899 (url-mid (concat "news" ":" mid-or-mail))
5900 (url-mailto (concat "mailto" ":" mid-or-mail)))
5901 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5902 (when (fboundp pref)
5904 ;; get rid of surrounding angles...
5906 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
5907 (if (or (eq 'mid guessed) (eq 'mail guessed))
5911 (save-window-excursion
5912 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5915 (cond ((eq pref 'mid)
5916 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
5917 (gnus-button-handle-news url-mid))
5919 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
5920 (gnus-url-mailto url-mailto))
5921 (t (gnus-message 3 "Invalid string.")))))
5923 (defun gnus-button-handle-custom (url)
5924 "Follow a Custom URL."
5925 (customize-apropos (gnus-url-unhex-string url)))
5927 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5929 ;; FIXME: Maybe we should merge some of the functions that do quite similar
5932 (defun gnus-button-handle-describe-function (url)
5933 "Call `describe-function' when pushing the corresponding URL button."
5936 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5938 (defun gnus-button-handle-describe-variable (url)
5939 "Call `describe-variable' when pushing the corresponding URL button."
5942 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5944 (defun gnus-button-handle-symbol (url)
5945 "Display help on variable or function.
5946 Calls `describe-variable' or `describe-function'."
5947 (let ((sym (intern url)))
5949 ((fboundp sym) (describe-function sym))
5950 ((boundp sym) (describe-variable sym))
5951 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
5953 (defun gnus-button-handle-describe-key (url)
5954 "Call `describe-key' when pushing the corresponding URL button."
5956 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5957 (keys (ignore-errors (eval `(kbd ,key-string)))))
5960 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5962 (defun gnus-button-handle-apropos (url)
5963 "Call `apropos' when pushing the corresponding URL button."
5964 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5966 (defun gnus-button-handle-apropos-command (url)
5967 "Call `apropos' when pushing the corresponding URL button."
5969 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5971 (defun gnus-button-handle-apropos-variable (url)
5972 "Call `apropos' when pushing the corresponding URL button."
5974 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5975 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5977 (defun gnus-button-handle-apropos-documentation (url)
5978 "Call `apropos' when pushing the corresponding URL button."
5980 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
5981 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5983 (defun gnus-button-handle-library (url)
5984 "Call `locate-library' when pushing the corresponding URL button."
5985 (gnus-message 9 "url=`%s'" url)
5986 (let* ((lib (locate-library url))
5987 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
5989 (gnus-message 1 "Cannot locale library `%s'." url)
5990 (find-file-read-only file))))
5992 (defun gnus-button-handle-ctan (url)
5993 "Call `browse-url' when pushing a CTAN URL button."
5995 gnus-button-ctan-handler
5998 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6000 (defcustom gnus-button-tex-level 5
6001 "*Integer that says how many TeX-related buttons Gnus will show.
6002 The higher the number, the more buttons will appear and the more false
6003 positives are possible. Note that you can set this variable local to
6004 specific groups. Setting it higher in TeX groups is probably a good idea.
6005 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6006 how to set variables in specific groups."
6007 :group 'gnus-article-buttons
6008 :link '(custom-manual "(gnus)Group Parameters")
6011 (defcustom gnus-button-man-level 5
6012 "*Integer that says how many man-related buttons Gnus will show.
6013 The higher the number, the more buttons will appear and the more false
6014 positives are possible. Note that you can set this variable local to
6015 specific groups. Setting it higher in Unix groups is probably a good idea.
6016 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6017 how to set variables in specific groups."
6018 :group 'gnus-article-buttons
6019 :link '(custom-manual "(gnus)Group Parameters")
6022 (defcustom gnus-button-emacs-level 5
6023 "*Integer that says how many emacs-related buttons Gnus will show.
6024 The higher the number, the more buttons will appear and the more false
6025 positives are possible. Note that you can set this variable local to
6026 specific groups. Setting it higher in Emacs or Gnus related groups is
6027 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6028 `gnus-parameters' on how to set variables in specific groups."
6029 :group 'gnus-article-buttons
6030 :link '(custom-manual "(gnus)Group Parameters")
6033 (defcustom gnus-button-message-level 5
6034 "*Integer that says how many buttons for news or mail messages will appear.
6035 The higher the number, the more buttons will appear and the more false
6036 positives are possible."
6037 ;; mail addresses, MIDs, URLs for news, ...
6038 :group 'gnus-article-buttons
6041 (defcustom gnus-button-browse-level 5
6042 "*Integer that says how many buttons for browsing will appear.
6043 The higher the number, the more buttons will appear and the more false
6044 positives are possible."
6045 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6046 :group 'gnus-article-buttons
6049 (defcustom gnus-button-alist
6050 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6051 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6052 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6053 gnus-button-handle-news 2)
6054 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6055 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6056 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6057 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6058 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6059 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6060 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6061 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6062 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6063 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6064 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6065 ;; RFC 2368 (The mailto URL scheme)
6066 ("mailto:\\([-a-z.@_+0-9%=?&]+\\)"
6067 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6068 ("\\bmailto:\\([^ \n\t]+\\)"
6069 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6071 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6072 gnus-button-ctan-directory-regexp
6073 "[^][>)!;:,'\n\t ]+\\)")
6074 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6075 ((concat "\\btex-archive/\\("
6076 gnus-button-ctan-directory-regexp
6077 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6078 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6081 gnus-button-ctan-directory-regexp
6082 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6083 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6084 ;; This is info (home-grown style) <info://foo/bar+baz>
6085 ("\\binfo://\\([^'\">\n\t ]+\\)"
6086 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6087 ;; Info GNOME style <info:foo#bar_baz>
6088 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6089 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6090 ;; Info KDE style <info:(foo)bar baz>
6091 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6092 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6093 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6094 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6095 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6096 ;; Info links like `C-h i d m CC Mode RET'
6097 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6099 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6100 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6101 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6102 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6103 ;; Emacs help commands
6104 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6105 ;; regexp doesn't match arguments containing ` '.
6106 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6107 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6108 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6109 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6110 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6111 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6112 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6113 ;; The following entries may lead to many false positives so don't enable
6114 ;; them by default (use a high button level):
6115 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6116 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6117 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6118 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6119 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6120 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6121 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6122 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6123 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6124 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6125 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6126 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6127 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6128 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6129 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6130 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6131 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6132 ;; Unlike the other regexps we really have to require quoting
6133 ;; here to determine where it ends.
6134 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6135 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6136 ("<URL: *\\([^<>]*\\)>"
6137 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6138 ;; RFC 2396 (2.4.3., delims) ...
6139 ("\"URL: *\\([^\"]*\\)\""
6140 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6141 ;; RFC 2396 (2.4.3., delims) ...
6142 ("\"URL: *\\([^\"]*\\)\""
6143 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6145 (gnus-button-url-regexp
6146 0 (>= gnus-button-browse-level 0) browse-url 0)
6148 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6149 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6150 gnus-button-handle-man 1)
6151 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6152 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6153 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6154 gnus-button-handle-man 1)
6155 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6156 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6157 ("\\b\\([a-z][-+_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6158 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6159 ;; MID or mail: To avoid too many false positives we don't try to catch
6160 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6161 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6162 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6163 ;; so that non-ambiguous entries (see above) match first.
6164 (gnus-button-mid-or-mail-regexp
6165 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6166 "*Alist of regexps matching buttons in article bodies.
6168 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6169 REGEXP: is the string (case insensitive) matching text around the button (can
6170 also be Lisp expression evaluating to a string),
6171 BUTTON: is the number of the regexp grouping actually matching the button,
6172 FORM: is a Lisp expression which must eval to true for the button to
6174 CALLBACK: is the function to call when the user push this button, and each
6175 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6177 CALLBACK can also be a variable, in that case the value of that
6178 variable it the real callback function."
6179 :group 'gnus-article-buttons
6180 :type '(repeat (list (choice regexp variable sexp)
6181 (integer :tag "Button")
6183 (function :tag "Callback")
6186 (integer :tag "Regexp group")))))
6188 (defcustom gnus-header-button-alist
6189 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6190 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6191 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6192 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6193 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6194 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6195 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6196 0 (>= gnus-button-browse-level 0) browse-url 0)
6197 ("^Subject:" gnus-button-url-regexp
6198 0 (>= gnus-button-browse-level 0) browse-url 0)
6199 ("^[^:]+:" gnus-button-url-regexp
6200 0 (>= gnus-button-browse-level 0) browse-url 0)
6201 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&]+\\)"
6202 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6203 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6204 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6205 "*Alist of headers and regexps to match buttons in article heads.
6207 This alist is very similar to `gnus-button-alist', except that each
6208 alist has an additional HEADER element first in each entry:
6210 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6212 HEADER is a regexp to match a header. For a fuller explanation, see
6213 `gnus-button-alist'."
6214 :group 'gnus-article-buttons
6215 :group 'gnus-article-headers
6216 :type '(repeat (list (regexp :tag "Header")
6217 (choice regexp variable)
6218 (integer :tag "Button")
6220 (function :tag "Callback")
6223 (integer :tag "Regexp group")))))
6225 (defvar gnus-button-regexp nil)
6226 (defvar gnus-button-marker-list nil)
6227 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6229 (defvar gnus-button-last nil)
6230 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6234 (defun gnus-article-push-button (event)
6235 "Check text under the mouse pointer for a callback function.
6236 If the text under the mouse pointer has a `gnus-callback' property,
6237 call it with the value of the `gnus-data' text property."
6239 (set-buffer (window-buffer (posn-window (event-start event))))
6240 (let* ((pos (posn-point (event-start event)))
6241 (data (get-text-property pos 'gnus-data))
6242 (fun (get-text-property pos 'gnus-callback)))
6245 (funcall fun data))))
6247 (defun gnus-article-press-button ()
6248 "Check text at point for a callback function.
6249 If the text at point has a `gnus-callback' property,
6250 call it with the value of the `gnus-data' text property."
6252 (let ((data (get-text-property (point) 'gnus-data))
6253 (fun (get-text-property (point) 'gnus-callback)))
6255 (funcall fun data))))
6257 (defun gnus-article-highlight (&optional force)
6258 "Highlight current article.
6259 This function calls `gnus-article-highlight-headers',
6260 `gnus-article-highlight-citation',
6261 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6262 do the highlighting. See the documentation for those functions."
6263 (interactive (list 'force))
6264 (gnus-article-highlight-headers)
6265 (gnus-article-highlight-citation force)
6266 (gnus-article-highlight-signature)
6267 (gnus-article-add-buttons force)
6268 (gnus-article-add-buttons-to-head))
6270 (defun gnus-article-highlight-some (&optional force)
6271 "Highlight current article.
6272 This function calls `gnus-article-highlight-headers',
6273 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6274 do the highlighting. See the documentation for those functions."
6275 (interactive (list 'force))
6276 (gnus-article-highlight-headers)
6277 (gnus-article-highlight-signature)
6278 (gnus-article-add-buttons))
6280 (defun gnus-article-highlight-headers ()
6281 "Highlight article headers as specified by `gnus-header-face-alist'."
6284 (set-buffer gnus-article-buffer)
6286 (let ((alist gnus-header-face-alist)
6287 (buffer-read-only nil)
6288 (case-fold-search t)
6289 (inhibit-point-motion-hooks t)
6290 entry regexp header-face field-face from hpoints fpoints)
6291 (article-narrow-to-head)
6292 (while (setq entry (pop alist))
6293 (goto-char (point-min))
6294 (setq regexp (concat "^\\("
6295 (if (string-equal "" (nth 0 entry))
6299 header-face (nth 1 entry)
6300 field-face (nth 2 entry))
6301 (while (and (re-search-forward regexp nil t)
6305 (unless (search-forward ":" nil t)
6307 (when (and header-face
6308 (not (memq (point) hpoints)))
6309 (push (point) hpoints)
6310 (gnus-put-text-property from (point) 'face header-face))
6311 (when (and field-face
6312 (not (memq (setq from (point)) fpoints)))
6314 (if (re-search-forward "^[^ \t]" nil t)
6316 (goto-char (point-max)))
6317 (gnus-put-text-property from (point) 'face field-face))))))))
6319 (defun gnus-article-highlight-signature ()
6320 "Highlight the signature in an article.
6321 It does this by highlighting everything after
6322 `gnus-signature-separator' using `gnus-signature-face'."
6325 (set-buffer gnus-article-buffer)
6326 (let ((buffer-read-only nil)
6327 (inhibit-point-motion-hooks t))
6329 (when (and gnus-signature-face
6330 (gnus-article-narrow-to-signature))
6331 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6332 'face gnus-signature-face)
6334 (gnus-article-search-signature)
6335 (let ((start (match-beginning 0))
6336 (end (set-marker (make-marker) (1+ (match-end 0)))))
6337 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6340 (defun gnus-button-in-region-p (b e prop)
6341 "Say whether PROP exists in the region."
6342 (text-property-not-all b e prop nil))
6344 (defun gnus-article-add-buttons (&optional force)
6345 "Find external references in the article and make buttons of them.
6346 \"External references\" are things like Message-IDs and URLs, as
6347 specified by `gnus-button-alist'."
6348 (interactive (list 'force))
6350 (set-buffer gnus-article-buffer)
6351 (let ((buffer-read-only nil)
6352 (inhibit-point-motion-hooks t)
6353 (case-fold-search t)
6354 (alist gnus-button-alist)
6356 ;; Remove all old markers.
6357 (let (marker entry new-list)
6358 (while (setq marker (pop gnus-button-marker-list))
6359 (if (or (< marker (point-min)) (>= marker (point-max)))
6360 (push marker new-list)
6362 (when (setq entry (gnus-button-entry))
6363 (put-text-property (match-beginning (nth 1 entry))
6364 (match-end (nth 1 entry))
6365 'gnus-callback nil))
6366 (set-marker marker nil)))
6367 (setq gnus-button-marker-list new-list))
6368 ;; We skip the headers.
6371 (while (setq entry (pop alist))
6372 (setq regexp (eval (car entry)))
6374 (while (re-search-forward regexp nil t)
6375 (let* ((start (and entry (match-beginning (nth 1 entry))))
6376 (end (and entry (match-end (nth 1 entry))))
6377 (from (match-beginning 0)))
6378 (when (and (or (eq t (nth 2 entry))
6379 (eval (nth 2 entry)))
6380 (not (gnus-button-in-region-p
6381 start end 'gnus-callback)))
6382 ;; That optional form returned non-nil, so we add the
6384 (gnus-article-add-button
6385 start end 'gnus-button-push
6386 (car (push (set-marker (make-marker) from)
6387 gnus-button-marker-list))))))))))
6389 ;; Add buttons to the head of an article.
6390 (defun gnus-article-add-buttons-to-head ()
6391 "Add buttons to the head of the article."
6394 (set-buffer gnus-article-buffer)
6396 (let ((buffer-read-only nil)
6397 (inhibit-point-motion-hooks t)
6398 (case-fold-search t)
6399 (alist gnus-header-button-alist)
6401 (article-narrow-to-head)
6403 ;; Each alist entry.
6404 (setq entry (car alist)
6406 (goto-char (point-min))
6407 (while (re-search-forward (car entry) nil t)
6408 ;; Each header matching the entry.
6409 (setq beg (match-beginning 0))
6410 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6411 (match-beginning 0))
6414 (while (re-search-forward (eval (nth 1 entry)) end t)
6415 ;; Each match within a header.
6416 (let* ((entry (cdr entry))
6417 (start (match-beginning (nth 1 entry)))
6418 (end (match-end (nth 1 entry)))
6419 (form (nth 2 entry)))
6420 (goto-char (match-end 0))
6422 (gnus-article-add-button
6423 start end (nth 3 entry)
6424 (buffer-substring (match-beginning (nth 4 entry))
6425 (match-end (nth 4 entry)))))))
6426 (goto-char end)))))))
6428 ;;; External functions:
6430 (defun gnus-article-add-button (from to fun &optional data)
6431 "Create a button between FROM and TO with callback FUN and data DATA."
6432 (when gnus-article-button-face
6433 (gnus-overlay-put (gnus-make-overlay from to)
6434 'face gnus-article-button-face))
6435 (gnus-add-text-properties
6437 (nconc (and gnus-article-mouse-face
6438 (list gnus-mouse-face-prop gnus-article-mouse-face))
6439 (list 'gnus-callback fun)
6440 (and data (list 'gnus-data data))))
6441 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6442 :button-keymap gnus-widget-button-keymap))
6444 ;;; Internal functions:
6446 (defun gnus-article-set-globals ()
6448 (set-buffer gnus-summary-buffer)
6449 (gnus-set-global-variables)))
6451 (defun gnus-signature-toggle (end)
6453 (set-buffer gnus-article-buffer)
6454 (let ((buffer-read-only nil)
6455 (inhibit-point-motion-hooks t))
6456 (if (text-property-any end (point-max) 'article-type 'signature)
6458 (gnus-delete-wash-type 'signature)
6459 (gnus-remove-text-properties-when
6460 'article-type 'signature end (point-max)
6461 (cons 'article-type (cons 'signature
6462 gnus-hidden-properties))))
6463 (gnus-add-wash-type 'signature)
6464 (gnus-add-text-properties-when
6465 'article-type nil end (point-max)
6466 (cons 'article-type (cons 'signature
6467 gnus-hidden-properties)))))
6468 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6469 (gnus-set-mode-line 'article))))
6471 (defun gnus-button-entry ()
6472 ;; Return the first entry in `gnus-button-alist' matching this place.
6473 (let ((alist gnus-button-alist)
6476 (setq entry (pop alist))
6477 (if (looking-at (eval (car entry)))
6482 (defun gnus-button-push (marker)
6483 ;; Push button starting at MARKER.
6486 (let* ((entry (gnus-button-entry))
6487 (inhibit-point-motion-hooks t)
6489 (args (mapcar (lambda (group)
6490 (let ((string (match-string group)))
6491 (set-text-properties
6492 0 (length string) nil string)
6499 (fboundp (symbol-value fun)))
6500 (apply (symbol-value fun) args))
6502 (gnus-message 1 "You must define `%S' to use this button"
6503 (cons fun args)))))))
6505 (defun gnus-parse-news-url (url)
6506 (let (scheme server group message-id articles)
6509 (goto-char (point-min))
6510 (when (looking-at "\\([A-Za-z]+\\):")
6511 (setq scheme (match-string 1))
6512 (goto-char (match-end 0)))
6513 (when (looking-at "//\\([^/]+\\)/")
6514 (setq server (match-string 1))
6515 (goto-char (match-end 0)))
6518 ((looking-at "\\(.*@.*\\)")
6519 (setq message-id (match-string 1)))
6520 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6521 (setq group (match-string 1)
6522 articles (split-string (match-string 2) "-")))
6523 ((looking-at "\\([^/]+\\)/?")
6524 (setq group (match-string 1)))
6526 (error "Unknown news URL syntax"))))
6527 (list scheme server group message-id articles)))
6529 (defun gnus-button-handle-news (url)
6531 (destructuring-bind (scheme server group message-id articles)
6532 (gnus-parse-news-url url)
6536 (set-buffer gnus-summary-buffer)
6538 (let ((gnus-refer-article-method (list (list 'nntp server))))
6539 (gnus-summary-refer-article message-id))
6540 (gnus-summary-refer-article message-id))))
6542 (gnus-button-fetch-group url)))))
6544 (defun gnus-button-handle-man (url)
6546 (funcall gnus-button-man-handler url))
6548 (defun gnus-button-handle-info-url (url)
6549 "Fetch an info URL."
6550 (setq url (mm-subst-char-in-string ?+ ?\ url))
6552 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6553 (gnus-info-find-node
6554 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6556 ")" (gnus-url-unhex-string (match-string 2 url)))))
6557 ((string-match "([^)\"]+)[^\"]+" url)
6559 (gnus-replace-in-string
6560 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6561 (gnus-info-find-node url))
6562 (t (error "Can't parse %s" url))))
6564 (defun gnus-button-handle-info-url-gnome (url)
6565 "Fetch GNOME style info URL."
6566 (setq url (mm-subst-char-in-string ?_ ?\ url))
6567 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6568 (gnus-info-find-node
6570 (gnus-url-unhex-string
6571 (match-string 1 url))
6573 (or (gnus-url-unhex-string
6574 (match-string 2 url))
6576 (error "Can't parse %s" url)))
6578 (defun gnus-button-handle-info-url-kde (url)
6579 "Fetch KDE style info URL."
6580 (gnus-info-find-node (gnus-url-unhex-string url)))
6582 (defun gnus-button-handle-info-keystrokes (url)
6583 "Call `info' when pushing the corresponding URL button."
6584 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6589 (defun gnus-button-message-id (message-id)
6592 (set-buffer gnus-summary-buffer)
6593 (gnus-summary-refer-article message-id)))
6595 (defun gnus-button-fetch-group (address)
6596 "Fetch GROUP specified by ADDRESS."
6597 (if (not (string-match "[:/]" address))
6598 ;; This is just a simple group url.
6599 (gnus-group-read-ephemeral-group address gnus-select-method)
6602 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6604 (error "Can't parse %s" address)
6605 (gnus-group-read-ephemeral-group
6606 (match-string 4 address)
6607 `(nntp ,(match-string 1 address)
6608 (nntp-address ,(match-string 1 address))
6609 (nntp-port-number ,(if (match-end 3)
6610 (match-string 3 address)
6613 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6615 (defun gnus-url-parse-query-string (query &optional downcase)
6616 (let (retval pairs cur key val)
6617 (setq pairs (split-string query "&"))
6619 (setq cur (car pairs)
6621 (if (not (string-match "=" cur))
6623 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6624 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6626 (setq key (downcase key)))
6627 (setq cur (assoc key retval))
6629 (setcdr cur (cons val (cdr cur)))
6630 (setq retval (cons (list key val) retval)))))
6633 (defun gnus-url-mailto (url)
6634 ;; Send mail to someone
6635 (when (string-match "mailto:/*\\(.*\\)" url)
6636 (setq url (substring url (match-beginning 1) nil)))
6637 (let (to args subject func)
6638 (setq args (gnus-url-parse-query-string
6639 (if (string-match "^\\?" url)
6641 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6642 (concat "to=" (match-string 1 url) "&"
6643 (match-string 2 url))
6644 (concat "to=" url)))
6646 subject (cdr-safe (assoc "subject" args)))
6649 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6652 (message-position-on-field (caar args)))
6653 (insert (gnus-replace-in-string
6654 (mapconcat 'identity (reverse (cdar args)) ", ")
6656 (setq args (cdr args)))
6659 (message-goto-subject))))
6661 (defun gnus-button-embedded-url (address)
6662 "Activate ADDRESS with `browse-url'."
6663 (browse-url (gnus-strip-whitespace address)))
6665 ;;; Next/prev buttons in the article buffer.
6667 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6668 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6670 (defvar gnus-prev-page-map
6671 (let ((map (make-sparse-keymap)))
6672 (unless (>= emacs-major-version 21)
6673 ;; XEmacs doesn't care.
6674 (set-keymap-parent map gnus-article-mode-map))
6675 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6676 (define-key map "\r" 'gnus-button-prev-page)
6679 (defun gnus-insert-prev-page-button ()
6681 (buffer-read-only nil))
6683 gnus-prev-page-line-format nil
6684 `(keymap ,gnus-prev-page-map
6686 gnus-callback gnus-article-button-prev-page
6687 article-type annotation))
6688 (widget-convert-button
6690 ;; Exclude a newline.
6693 :action 'gnus-button-prev-page
6694 :button-keymap gnus-prev-page-map)))
6696 (defvar gnus-prev-page-map
6697 (let ((map (make-sparse-keymap)))
6698 (unless (>= emacs-major-version 21)
6699 ;; XEmacs doesn't care.
6700 (set-keymap-parent map gnus-article-mode-map))
6701 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6702 (define-key map "\r" 'gnus-button-prev-page)
6705 (defvar gnus-next-page-map
6706 (let ((map (make-sparse-keymap)))
6707 (unless (>= emacs-major-version 21)
6708 ;; XEmacs doesn't care.
6709 (set-keymap-parent map gnus-article-mode-map))
6710 (define-key map gnus-mouse-2 'gnus-button-next-page)
6711 (define-key map "\r" 'gnus-button-next-page)
6714 (defun gnus-button-next-page (&optional args more-args)
6715 "Go to the next page."
6717 (let ((win (selected-window)))
6718 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6719 (gnus-article-next-page)
6720 (select-window win)))
6722 (defun gnus-button-prev-page (&optional args more-args)
6723 "Go to the prev page."
6725 (let ((win (selected-window)))
6726 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6727 (gnus-article-prev-page)
6728 (select-window win)))
6730 (defun gnus-insert-next-page-button ()
6732 (buffer-read-only nil))
6733 (gnus-eval-format gnus-next-page-line-format nil
6734 `(keymap ,gnus-next-page-map
6736 gnus-callback gnus-article-button-next-page
6737 article-type annotation))
6738 (widget-convert-button
6740 ;; Exclude a newline.
6743 :action 'gnus-button-next-page
6744 :button-keymap gnus-next-page-map)))
6746 (defun gnus-article-button-next-page (arg)
6747 "Go to the next page."
6749 (let ((win (selected-window)))
6750 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6751 (gnus-article-next-page)
6752 (select-window win)))
6754 (defun gnus-article-button-prev-page (arg)
6755 "Go to the prev page."
6757 (let ((win (selected-window)))
6758 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6759 (gnus-article-prev-page)
6760 (select-window win)))
6762 (defvar gnus-decode-header-methods
6763 '(mail-decode-encoded-word-region)
6764 "List of methods used to decode headers.
6766 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6767 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6768 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6769 whose names match REGEXP.
6772 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6773 mail-decode-encoded-word-region
6774 (\"chinese\" . rfc1843-decode-region))
6777 (defvar gnus-decode-header-methods-cache nil)
6779 (defun gnus-multi-decode-header (start end)
6780 "Apply the functions from `gnus-encoded-word-methods' that match."
6781 (unless (and gnus-decode-header-methods-cache
6782 (eq gnus-newsgroup-name
6783 (car gnus-decode-header-methods-cache)))
6784 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6787 (nconc gnus-decode-header-methods-cache (list x))
6788 (if (and gnus-newsgroup-name
6789 (string-match (car x) gnus-newsgroup-name))
6790 (nconc gnus-decode-header-methods-cache
6792 gnus-decode-header-methods))
6793 (let ((xlist gnus-decode-header-methods-cache))
6796 (narrow-to-region start end)
6798 (funcall (pop xlist) (point-min) (point-max))))))
6801 ;;; Treatment top-level handling.
6804 (defun gnus-treat-article (condition &optional part-number total-parts type)
6805 (let ((length (- (point-max) (point-min)))
6806 (alist gnus-treatment-function-alist)
6807 (article-goto-body-goes-to-point-min-p t)
6811 (let ((list gnus-article-treat-types))
6813 (when (string-match (pop list) type)
6814 (throw 'found t)))))))
6815 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6817 (gnus-run-hooks 'gnus-part-display-hook)
6818 (dolist (elem alist)
6821 (when (gnus-buffer-live-p gnus-summary-buffer)
6822 (set-buffer gnus-summary-buffer))
6823 (symbol-value (car elem))))
6824 (when (and (or (consp val)
6826 (gnus-treat-predicate val)
6827 (or (not (get (car elem) 'highlight))
6830 (funcall (cadr elem)))))))
6832 ;; Dynamic variables.
6834 (defvar part-number)
6835 (defvar total-parts)
6840 (defun gnus-treat-predicate (val)
6847 (stringp (car val)))
6848 (apply 'gnus-or (mapcar `(lambda (s)
6849 (string-match s ,(or gnus-newsgroup-name "")))
6852 (let ((pred (pop val)))
6855 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6857 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6859 (not (gnus-treat-predicate (car val))))
6861 (equal (car val) type))
6863 (error "%S is not a valid predicate" pred)))))
6869 (eq part-number total-parts))
6873 (error "%S is not a valid value" val))))
6875 (defun gnus-article-encrypt-body (protocol &optional n)
6876 "Encrypt the article body."
6879 (or gnus-article-encrypt-protocol
6880 (completing-read "Encrypt protocol: "
6881 gnus-article-encrypt-protocol-alist
6883 current-prefix-arg))
6884 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6886 (error (format "Can't find the encrypt protocol %s" protocol)))
6887 (if (member gnus-newsgroup-name '("nndraft:delayed"
6890 (error "Can't encrypt the article in group %s"
6891 gnus-newsgroup-name))
6892 (gnus-summary-iterate n
6894 (set-buffer gnus-summary-buffer)
6895 (let ((mail-parse-charset gnus-newsgroup-charset)
6896 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6897 (summary-buffer gnus-summary-buffer)
6899 (gnus-set-global-variables)
6900 (when (gnus-group-read-only-p)
6901 (error "The current newsgroup does not support article encrypt"))
6902 (gnus-summary-show-article t)
6904 (or (mail-header-references gnus-current-headers) ""))
6905 (set-buffer gnus-article-buffer)
6906 (let* ((buffer-read-only nil)
6908 (mapcar (lambda (field)
6909 (and (save-restriction
6910 (message-narrow-to-head)
6911 (goto-char (point-min))
6912 (search-forward field nil t))
6914 (message-narrow-to-field)
6916 (delete-region (point-min) (point-max))
6918 '("Content-Type:" "Content-Transfer-Encoding:"
6919 "Content-Disposition:"))))
6920 (message-narrow-to-head)
6921 (message-remove-header "MIME-Version")
6922 (goto-char (point-max))
6923 (setq point (point))
6924 (insert (apply 'concat headers))
6926 (narrow-to-region point (point-max))
6927 (let ((message-options message-options))
6928 (message-options-set 'message-sender user-mail-address)
6929 (message-options-set 'message-recipients user-mail-address)
6930 (message-options-set 'message-sign-encrypt 'not)
6932 (goto-char (point-min))
6933 (insert "MIME-Version: 1.0\n")
6935 (gnus-summary-edit-article-done
6936 references nil summary-buffer t))
6937 (when gnus-keep-backlog
6938 (gnus-backlog-remove-article
6939 (car gnus-article-current) (cdr gnus-article-current)))
6941 (when (get-buffer gnus-original-article-buffer)
6942 (set-buffer gnus-original-article-buffer)
6943 (setq gnus-original-article nil)))
6944 (when gnus-use-cache
6945 (gnus-cache-update-article
6946 (car gnus-article-current) (cdr gnus-article-current))))))))
6948 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6949 "The following specs can be used:
6950 %t The security MIME type
6953 %D Details if button is pressed")
6955 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6956 "The following specs can be used:
6957 %t The security MIME type
6960 %D Details if button is pressed")
6962 (defvar gnus-mime-security-button-line-format-alist
6963 '((?t gnus-tmp-type ?s)
6964 (?i gnus-tmp-info ?s)
6965 (?d gnus-tmp-details ?s)
6966 (?D gnus-tmp-pressed-details ?s)))
6968 (defvar gnus-mime-security-button-map
6969 (let ((map (make-sparse-keymap)))
6970 (unless (>= (string-to-number emacs-version) 21)
6971 (set-keymap-parent map gnus-article-mode-map))
6972 (define-key map gnus-mouse-2 'gnus-article-push-button)
6973 (define-key map "\r" 'gnus-article-press-button)
6976 (defvar gnus-mime-security-details-buffer nil)
6978 (defvar gnus-mime-security-button-pressed nil)
6980 (defvar gnus-mime-security-show-details-inline t
6981 "If non-nil, show details in the article buffer.")
6983 (defun gnus-mime-security-verify-or-decrypt (handle)
6984 (mm-remove-parts (cdr handle))
6985 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6986 point buffer-read-only)
6988 (goto-char (car region)))
6990 (narrow-to-region (point) (point))
6991 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6992 (let* ((mm-verify-option 'known)
6993 (mm-decrypt-option 'known)
6994 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6995 (unless (eq nparts (cdr handle))
6996 (mm-destroy-parts (cdr handle))
6997 (setcdr handle nparts))))
6998 (setq point (point))
6999 (gnus-mime-display-security handle)
7000 (goto-char (point-max)))
7002 (delete-region (point) (cdr region))
7003 (set-marker (car region) nil)
7004 (set-marker (cdr region) nil))
7007 (defun gnus-mime-security-show-details (handle)
7008 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7010 (gnus-message 5 "No details.")
7011 (if gnus-mime-security-show-details-inline
7012 (let ((gnus-mime-security-button-pressed
7013 (not (get-text-property (point) 'gnus-mime-details)))
7014 (gnus-mime-security-button-line-format
7015 (get-text-property (point) 'gnus-line-format))
7018 (while (eq (get-text-property (point) 'gnus-line-format)
7019 gnus-mime-security-button-line-format)
7023 (narrow-to-region (point) (point))
7024 (gnus-insert-mime-security-button handle))
7025 (delete-region (point)
7026 (or (text-property-not-all
7029 gnus-mime-security-button-line-format)
7032 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7033 (with-current-buffer gnus-mime-security-details-buffer
7036 (setq gnus-mime-security-details-buffer
7037 (gnus-get-buffer-create "*MIME Security Details*")))
7038 (with-current-buffer gnus-mime-security-details-buffer
7040 (goto-char (point-min)))
7041 (pop-to-buffer gnus-mime-security-details-buffer)))))
7043 (defun gnus-mime-security-press-button (handle)
7045 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7046 (gnus-mime-security-show-details handle)
7047 (gnus-mime-security-verify-or-decrypt handle))))
7049 (defun gnus-insert-mime-security-button (handle &optional displayed)
7050 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7053 (or (nth 2 (assoc protocol mm-verify-function-alist))
7054 (nth 2 (assoc protocol mm-decrypt-function-alist))
7056 (if (equal (car handle) "multipart/signed")
7057 " Signed" " Encrypted")
7060 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7063 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7064 gnus-tmp-pressed-details
7066 (setq gnus-tmp-details
7067 (if gnus-tmp-details
7068 (concat "\n" gnus-tmp-details)
7070 (setq gnus-tmp-pressed-details
7071 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7076 gnus-mime-security-button-line-format
7077 gnus-mime-security-button-line-format-alist
7078 `(keymap ,gnus-mime-security-button-map
7079 gnus-callback gnus-mime-security-press-button
7080 gnus-line-format ,gnus-mime-security-button-line-format
7081 gnus-mime-details ,gnus-mime-security-button-pressed
7082 article-type annotation
7085 ;; Exclude a newline.
7088 (widget-convert-button
7091 :action 'gnus-widget-press-button
7092 :button-keymap gnus-mime-security-button-map
7094 (lambda (widget/window &optional overlay pos)
7095 ;; Needed to properly clear the message due to a bug in
7096 ;; wid-edit (XEmacs only).
7097 (when (boundp 'help-echo-owns-message)
7098 (setq help-echo-owns-message t))
7101 (aref gnus-mouse-2 0))))))
7103 (defun gnus-mime-display-security (handle)
7105 (narrow-to-region (point) (point))
7106 (unless (gnus-unbuttonized-mime-type-p (car handle))
7107 (gnus-insert-mime-security-button handle))
7108 (gnus-mime-display-mixed (cdr handle))
7111 (unless (gnus-unbuttonized-mime-type-p (car handle))
7112 (let ((gnus-mime-security-button-line-format
7113 gnus-mime-security-button-end-line-format))
7114 (gnus-insert-mime-security-button handle)))
7115 (mm-set-handle-multipart-parameter
7117 (cons (set-marker (make-marker) (point-min))
7118 (set-marker (make-marker) (point-max))))))
7124 (run-hooks 'gnus-art-load-hook)
7126 ;;; gnus-art.el ends here