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
900 Valid values are nil, t, `head', `last', an integer or a predicate.
901 See Info node `(gnus)Customizing Articles' for details."
902 :group 'gnus-article-treat
903 :link '(custom-manual "(gnus)Customizing Articles")
904 :type gnus-article-treat-custom)
905 (put 'gnus-treat-emphasize 'highlight t)
907 (defcustom gnus-treat-strip-cr nil
908 "Remove carriage returns.
909 Valid values are nil, t, `head', `last', an integer or a predicate.
910 See Info node `(gnus)Customizing Articles' for details."
911 :group 'gnus-article-treat
912 :link '(custom-manual "(gnus)Customizing Articles")
913 :type gnus-article-treat-custom)
915 (defcustom gnus-treat-unsplit-urls nil
916 "Remove newlines from within URLs.
917 Valid values are nil, t, `head', `last', an integer or a predicate.
918 See Info node `(gnus)Customizing Articles' for details."
919 :group 'gnus-article-treat
920 :link '(custom-manual "(gnus)Customizing Articles")
921 :type gnus-article-treat-custom)
923 (defcustom gnus-treat-leading-whitespace nil
924 "Remove leading whitespace in headers.
925 Valid values are nil, t, `head', `last', an integer or a predicate.
926 See Info node `(gnus)Customizing Articles' for details."
927 :group 'gnus-article-treat
928 :link '(custom-manual "(gnus)Customizing Articles")
929 :type gnus-article-treat-custom)
931 (defcustom gnus-treat-hide-headers 'head
933 Valid values are nil, t, `head', `last', an integer or a predicate.
934 See Info node `(gnus)Customizing Articles' for details."
935 :group 'gnus-article-treat
936 :link '(custom-manual "(gnus)Customizing Articles")
937 :type gnus-article-treat-head-custom)
939 (defcustom gnus-treat-hide-boring-headers nil
940 "Hide boring headers.
941 Valid values are nil, t, `head', `last', an integer or a predicate.
942 See Info node `(gnus)Customizing Articles' for details."
943 :group 'gnus-article-treat
944 :link '(custom-manual "(gnus)Customizing Articles")
945 :type gnus-article-treat-head-custom)
947 (defcustom gnus-treat-hide-signature nil
949 Valid values are nil, t, `head', `last', an integer or a predicate.
950 See Info node `(gnus)Customizing Articles' for details."
951 :group 'gnus-article-treat
952 :link '(custom-manual "(gnus)Customizing Articles")
953 :type gnus-article-treat-custom)
955 (defcustom gnus-treat-fill-article nil
957 Valid values are nil, t, `head', `last', an integer or a predicate.
958 See Info node `(gnus)Customizing Articles' for details."
959 :group 'gnus-article-treat
960 :link '(custom-manual "(gnus)Customizing Articles")
961 :type gnus-article-treat-custom)
963 (defcustom gnus-treat-hide-citation nil
965 Valid values are nil, t, `head', `last', an integer or a predicate.
966 See Info node `(gnus)Customizing Articles' for details."
967 :group 'gnus-article-treat
968 :link '(custom-manual "(gnus)Customizing Articles")
969 :type gnus-article-treat-custom)
971 (defcustom gnus-treat-hide-citation-maybe nil
973 Valid values are nil, t, `head', `last', an integer or a predicate.
974 See Info node `(gnus)Customizing Articles' for details."
975 :group 'gnus-article-treat
976 :link '(custom-manual "(gnus)Customizing Articles")
977 :type gnus-article-treat-custom)
979 (defcustom gnus-treat-strip-list-identifiers 'head
980 "Strip list identifiers from `gnus-list-identifiers`.
981 Valid values are nil, t, `head', `last', an integer or a predicate.
982 See Info node `(gnus)Customizing Articles' for details."
984 :group 'gnus-article-treat
985 :link '(custom-manual "(gnus)Customizing Articles")
986 :type gnus-article-treat-custom)
988 (make-obsolete-variable 'gnus-treat-strip-pgp
989 "This option is obsolete in Gnus 5.10.")
991 (defcustom gnus-treat-strip-pem nil
992 "Strip PEM signatures.
993 Valid values are nil, t, `head', `last', an integer or a predicate.
994 See Info node `(gnus)Customizing Articles' for details."
995 :group 'gnus-article-treat
996 :link '(custom-manual "(gnus)Customizing Articles")
997 :type gnus-article-treat-custom)
999 (defcustom gnus-treat-strip-banner t
1000 "Strip banners from articles.
1001 The banner to be stripped is specified in the `banner' group parameter.
1002 Valid values are nil, t, `head', `last', an integer or a predicate.
1003 See Info node `(gnus)Customizing Articles' for details."
1004 :group 'gnus-article-treat
1005 :link '(custom-manual "(gnus)Customizing Articles")
1006 :type gnus-article-treat-custom)
1008 (defcustom gnus-treat-highlight-headers 'head
1009 "Highlight the headers.
1010 Valid values are nil, t, `head', `last', an integer or a predicate.
1011 See Info node `(gnus)Customizing Articles' for details."
1012 :group 'gnus-article-treat
1013 :link '(custom-manual "(gnus)Customizing Articles")
1014 :type gnus-article-treat-head-custom)
1015 (put 'gnus-treat-highlight-headers 'highlight t)
1017 (defcustom gnus-treat-highlight-citation t
1018 "Highlight cited text.
1019 Valid values are nil, t, `head', `last', an integer or a predicate.
1020 See Info node `(gnus)Customizing Articles' for details."
1021 :group 'gnus-article-treat
1022 :link '(custom-manual "(gnus)Customizing Articles")
1023 :type gnus-article-treat-custom)
1024 (put 'gnus-treat-highlight-citation 'highlight t)
1026 (defcustom gnus-treat-date-ut nil
1027 "Display the Date in UT (GMT).
1028 Valid values are nil, t, `head', `last', an integer or a predicate.
1029 See Info node `(gnus)Customizing Articles' for details."
1030 :group 'gnus-article-treat
1031 :link '(custom-manual "(gnus)Customizing Articles")
1032 :type gnus-article-treat-head-custom)
1034 (defcustom gnus-treat-date-local nil
1035 "Display the Date in the local timezone.
1036 Valid values are nil, t, `head', `last', an integer or a predicate.
1037 See Info node `(gnus)Customizing Articles' for details."
1038 :group 'gnus-article-treat
1039 :link '(custom-manual "(gnus)Customizing Articles")
1040 :type gnus-article-treat-head-custom)
1042 (defcustom gnus-treat-date-english nil
1043 "Display the Date in a format that can be read aloud in English.
1044 Valid values are nil, t, `head', `last', an integer or a predicate.
1045 See Info node `(gnus)Customizing Articles' for details."
1046 :group 'gnus-article-treat
1047 :link '(custom-manual "(gnus)Customizing Articles")
1048 :type gnus-article-treat-head-custom)
1050 (defcustom gnus-treat-date-lapsed nil
1051 "Display the Date header in a way that says how much time has elapsed.
1052 Valid values are nil, t, `head', `last', an integer or a predicate.
1053 See Info node `(gnus)Customizing Articles' for details."
1054 :group 'gnus-article-treat
1055 :link '(custom-manual "(gnus)Customizing Articles")
1056 :type gnus-article-treat-head-custom)
1058 (defcustom gnus-treat-date-original nil
1059 "Display the date in the original timezone.
1060 Valid values are nil, t, `head', `last', an integer or a predicate.
1061 See Info node `(gnus)Customizing Articles' for details."
1062 :group 'gnus-article-treat
1063 :link '(custom-manual "(gnus)Customizing Articles")
1064 :type gnus-article-treat-head-custom)
1066 (defcustom gnus-treat-date-iso8601 nil
1067 "Display the date in the ISO8601 format.
1068 Valid values are nil, t, `head', `last', an integer or a predicate.
1069 See Info node `(gnus)Customizing Articles' for details."
1071 :group 'gnus-article-treat
1072 :link '(custom-manual "(gnus)Customizing Articles")
1073 :type gnus-article-treat-head-custom)
1075 (defcustom gnus-treat-date-user-defined nil
1076 "Display the date in a user-defined format.
1077 The format is defined by the `gnus-article-time-format' variable.
1078 Valid values are nil, t, `head', `last', an integer or a predicate.
1079 See Info node `(gnus)Customizing Articles' for details."
1080 :group 'gnus-article-treat
1081 :link '(custom-manual "(gnus)Customizing Articles")
1082 :type gnus-article-treat-head-custom)
1084 (defcustom gnus-treat-strip-headers-in-body t
1085 "Strip the X-No-Archive header line from the beginning of the body.
1086 Valid values are nil, t, `head', `last', an integer or a predicate.
1087 See Info node `(gnus)Customizing Articles' for details."
1089 :group 'gnus-article-treat
1090 :link '(custom-manual "(gnus)Customizing Articles")
1091 :type gnus-article-treat-custom)
1093 (defcustom gnus-treat-strip-trailing-blank-lines nil
1094 "Strip trailing blank lines.
1095 Valid values are nil, t, `head', `last', an integer or a predicate.
1096 See Info node `(gnus)Customizing Articles' for details."
1097 :group 'gnus-article-treat
1098 :link '(custom-manual "(gnus)Customizing Articles")
1099 :type gnus-article-treat-custom)
1101 (defcustom gnus-treat-strip-leading-blank-lines nil
1102 "Strip leading blank lines.
1103 Valid values are nil, t, `head', `last', an integer or a predicate.
1104 See Info node `(gnus)Customizing Articles' for details."
1105 :group 'gnus-article-treat
1106 :link '(custom-manual "(gnus)Customizing Articles")
1107 :type gnus-article-treat-custom)
1109 (defcustom gnus-treat-strip-multiple-blank-lines nil
1110 "Strip multiple blank lines.
1111 Valid values are nil, t, `head', `last', an integer or a predicate.
1112 See Info node `(gnus)Customizing Articles' for details."
1113 :group 'gnus-article-treat
1114 :link '(custom-manual "(gnus)Customizing Articles")
1115 :type gnus-article-treat-custom)
1117 (defcustom gnus-treat-unfold-headers 'head
1118 "Unfold folded header lines.
1119 Valid values are nil, t, `head', `last', an integer or a predicate.
1120 See Info node `(gnus)Customizing Articles' for details."
1121 :group 'gnus-article-treat
1122 :link '(custom-manual "(gnus)Customizing Articles")
1123 :type gnus-article-treat-custom)
1125 (defcustom gnus-treat-fold-headers nil
1127 Valid values are nil, t, `head', `last', an integer or a predicate.
1128 See Info node `(gnus)Customizing Articles' for details."
1129 :group 'gnus-article-treat
1130 :link '(custom-manual "(gnus)Customizing Articles")
1131 :type gnus-article-treat-custom)
1133 (defcustom gnus-treat-fold-newsgroups 'head
1134 "Fold the Newsgroups and Followup-To headers.
1135 Valid values are nil, t, `head', `last', an integer or a predicate.
1136 See Info node `(gnus)Customizing Articles' for details."
1137 :group 'gnus-article-treat
1138 :link '(custom-manual "(gnus)Customizing Articles")
1139 :type gnus-article-treat-custom)
1141 (defcustom gnus-treat-overstrike t
1142 "Treat overstrike highlighting.
1143 Valid values are nil, t, `head', `last', an integer or a predicate.
1144 See Info node `(gnus)Customizing Articles' for details."
1145 :group 'gnus-article-treat
1146 :link '(custom-manual "(gnus)Customizing Articles")
1147 :type gnus-article-treat-custom)
1148 (put 'gnus-treat-overstrike 'highlight t)
1150 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1151 "Treat ANSI SGR control sequences.
1152 Valid values are nil, t, `head', `last', an integer or a predicate.
1153 See Info node `(gnus)Customizing Articles' for details."
1154 :group 'gnus-article-treat
1155 :link '(custom-manual "(gnus)Customizing Articles")
1156 :type gnus-article-treat-custom)
1158 (make-obsolete-variable 'gnus-treat-display-xface
1159 'gnus-treat-display-x-face)
1161 (defcustom gnus-treat-display-x-face
1162 (and (not noninteractive)
1163 (or (and (fboundp 'image-type-available-p)
1164 (image-type-available-p 'xbm)
1165 (string-match "^0x" (shell-command-to-string "uncompface"))
1166 (executable-find "icontopbm"))
1167 (and (featurep 'xemacs)
1170 "Display X-Face headers.
1171 Valid values are nil, t, `head', `last', an integer or a predicate.
1172 See Info node `(gnus)Customizing Articles' and Info node
1173 `(gnus)X-Face' for details."
1174 :group 'gnus-article-treat
1176 :link '(custom-manual "(gnus)Customizing Articles")
1177 :link '(custom-manual "(gnus)X-Face")
1178 :type gnus-article-treat-head-custom
1179 :set (lambda (symbol value)
1182 (cond ((or (boundp symbol) (get symbol 'saved-value))
1184 ((boundp 'gnus-treat-display-xface)
1186 ** gnus-treat-display-xface is an obsolete variable;\
1187 use gnus-treat-display-x-face instead")
1188 (default-value 'gnus-treat-display-xface))
1189 ((get 'gnus-treat-display-xface 'saved-value)
1191 ** gnus-treat-display-xface is an obsolete variable;\
1192 use gnus-treat-display-x-face instead")
1193 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1196 (put 'gnus-treat-display-x-face 'highlight t)
1198 (defcustom gnus-treat-display-face
1199 (and (not noninteractive)
1200 (or (and (fboundp 'image-type-available-p)
1201 (image-type-available-p 'png))
1202 (and (featurep 'xemacs)
1205 "Display Face headers.
1206 Valid values are nil, t, `head', `last', an integer or a predicate.
1207 See Info node `(gnus)Customizing Articles' and Info node
1208 `(gnus)X-Face' for details."
1209 :group 'gnus-article-treat
1211 :link '(custom-manual "(gnus)Customizing Articles")
1212 :link '(custom-manual "(gnus)X-Face")
1213 :type gnus-article-treat-head-custom)
1214 (put 'gnus-treat-display-face 'highlight t)
1216 (defcustom gnus-treat-display-smileys
1217 (if (or (and (featurep 'xemacs)
1219 (and (fboundp 'image-type-available-p)
1220 (image-type-available-p 'pbm)))
1223 Valid values are nil, t, `head', `last', an integer or a predicate.
1224 See Info node `(gnus)Customizing Articles' and Info node
1225 `(gnus)Smileys' for details."
1226 :group 'gnus-article-treat
1228 :link '(custom-manual "(gnus)Customizing Articles")
1229 :link '(custom-manual "(gnus)Smileys")
1230 :type gnus-article-treat-custom)
1231 (put 'gnus-treat-display-smileys 'highlight t)
1233 (defcustom gnus-treat-from-picon
1234 (if (and (gnus-image-type-available-p 'xpm)
1235 (gnus-picons-installed-p))
1237 "Display picons in the From header.
1238 Valid values are nil, t, `head', `last', an integer or a predicate.
1239 See Info node `(gnus)Customizing Articles' and Info node
1240 `(gnus)Picons' for details."
1241 :group 'gnus-article-treat
1243 :link '(custom-manual "(gnus)Customizing Articles")
1244 :link '(custom-manual "(gnus)Picons")
1245 :type gnus-article-treat-head-custom)
1246 (put 'gnus-treat-from-picon 'highlight t)
1248 (defcustom gnus-treat-mail-picon
1249 (if (and (gnus-image-type-available-p 'xpm)
1250 (gnus-picons-installed-p))
1252 "Display picons in To and Cc headers.
1253 Valid values are nil, t, `head', `last', an integer or a predicate.
1254 See Info node `(gnus)Customizing Articles' and Info node
1255 `(gnus)Picons' for details."
1256 :group 'gnus-article-treat
1258 :link '(custom-manual "(gnus)Customizing Articles")
1259 :link '(custom-manual "(gnus)Picons")
1260 :type gnus-article-treat-head-custom)
1261 (put 'gnus-treat-mail-picon 'highlight t)
1263 (defcustom gnus-treat-newsgroups-picon
1264 (if (and (gnus-image-type-available-p 'xpm)
1265 (gnus-picons-installed-p))
1267 "Display picons in the Newsgroups and Followup-To headers.
1268 Valid values are nil, t, `head', `last', an integer or a predicate.
1269 See Info node `(gnus)Customizing Articles' and Info node
1270 `(gnus)Picons' for details."
1271 :group 'gnus-article-treat
1273 :link '(custom-manual "(gnus)Customizing Articles")
1274 :link '(custom-manual "(gnus)Picons")
1275 :type gnus-article-treat-head-custom)
1276 (put 'gnus-treat-newsgroups-picon 'highlight t)
1278 (defcustom gnus-treat-body-boundary
1279 (if (or gnus-treat-newsgroups-picon
1280 gnus-treat-mail-picon
1281 gnus-treat-from-picon)
1283 "Draw a boundary at the end of the headers.
1284 Valid values are nil and `head'.
1285 See Info node `(gnus)Customizing Articles' for details."
1287 :group 'gnus-article-treat
1288 :link '(custom-manual "(gnus)Customizing Articles")
1289 :type gnus-article-treat-head-custom)
1291 (defcustom gnus-treat-capitalize-sentences nil
1292 "Capitalize sentence-starting words.
1293 Valid values are nil, t, `head', `last', an integer or a predicate.
1294 See Info node `(gnus)Customizing Articles' for details."
1296 :group 'gnus-article-treat
1297 :link '(custom-manual "(gnus)Customizing Articles")
1298 :type gnus-article-treat-custom)
1300 (defcustom gnus-treat-wash-html nil
1302 Valid values are nil, t, `head', `last', an integer or a predicate.
1303 See Info node `(gnus)Customizing Articles' for details."
1304 :group 'gnus-article-treat
1305 :link '(custom-manual "(gnus)Customizing Articles")
1306 :type gnus-article-treat-custom)
1308 (defcustom gnus-treat-fill-long-lines nil
1310 Valid values are nil, t, `head', `last', an integer or a predicate.
1311 See Info node `(gnus)Customizing Articles' for details."
1312 :group 'gnus-article-treat
1313 :link '(custom-manual "(gnus)Customizing Articles")
1314 :type gnus-article-treat-custom)
1316 (defcustom gnus-treat-play-sounds nil
1318 Valid values are nil, t, `head', `last', an integer or a predicate.
1319 See Info node `(gnus)Customizing Articles' for details."
1321 :group 'gnus-article-treat
1322 :link '(custom-manual "(gnus)Customizing Articles")
1323 :type gnus-article-treat-custom)
1325 (defcustom gnus-treat-translate nil
1326 "Translate articles from one language to another.
1327 Valid values are nil, t, `head', `last', an integer or a predicate.
1328 See Info node `(gnus)Customizing Articles' for details."
1330 :group 'gnus-article-treat
1331 :link '(custom-manual "(gnus)Customizing Articles")
1332 :type gnus-article-treat-custom)
1334 (defcustom gnus-treat-x-pgp-sig nil
1336 To automatically treat X-PGP-Sig, set it to head.
1337 Valid values are nil, t, `head', `last', an integer or a predicate.
1338 See Info node `(gnus)Customizing Articles' for details."
1339 :group 'gnus-article-treat
1340 :group 'mime-security
1341 :link '(custom-manual "(gnus)Customizing Articles")
1342 :type gnus-article-treat-custom)
1344 (defvar gnus-article-encrypt-protocol-alist
1345 '(("PGP" . mml2015-self-encrypt)))
1347 ;; Set to nil if more than one protocol added to
1348 ;; gnus-article-encrypt-protocol-alist.
1349 (defcustom gnus-article-encrypt-protocol "PGP"
1350 "The protocol used for encrypt articles.
1351 It is a string, such as \"PGP\". If nil, ask user."
1353 :group 'mime-security)
1355 (defvar gnus-article-wash-function nil
1356 "Function used for converting HTML into text.")
1358 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1359 (mm-coding-system-p 'utf-8)
1360 (executable-find idna-program))
1361 "Whether IDNA decoding of headers is used when viewing messages.
1362 This requires GNU Libidn, and by default only enabled if it is found."
1363 :group 'gnus-article-headers
1366 (defcustom gnus-article-over-scroll nil
1367 "If non-nil, allow scrolling the article buffer even when there no more text."
1368 :group 'gnus-article
1371 ;;; Internal variables
1373 (defvar gnus-english-month-names
1374 '("January" "February" "March" "April" "May" "June" "July" "August"
1375 "September" "October" "November" "December"))
1377 (defvar article-goto-body-goes-to-point-min-p nil)
1378 (defvar gnus-article-wash-types nil)
1379 (defvar gnus-article-emphasis-alist nil)
1380 (defvar gnus-article-image-alist nil)
1382 (defvar gnus-article-mime-handle-alist-1 nil)
1383 (defvar gnus-treatment-function-alist
1384 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1385 (gnus-treat-strip-banner gnus-article-strip-banner)
1386 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1387 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1388 (gnus-treat-buttonize gnus-article-add-buttons)
1389 (gnus-treat-fill-article gnus-article-fill-cited-article)
1390 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1391 (gnus-treat-strip-cr gnus-article-remove-cr)
1392 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1393 (gnus-treat-date-ut gnus-article-date-ut)
1394 (gnus-treat-date-local gnus-article-date-local)
1395 (gnus-treat-date-english gnus-article-date-english)
1396 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1397 (gnus-treat-date-original gnus-article-date-original)
1398 (gnus-treat-date-user-defined gnus-article-date-user)
1399 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1400 (gnus-treat-display-x-face gnus-article-display-x-face)
1401 (gnus-treat-display-face gnus-article-display-face)
1402 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1403 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1404 (gnus-treat-hide-signature gnus-article-hide-signature)
1405 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1406 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1407 (gnus-treat-strip-pem gnus-article-hide-pem)
1408 (gnus-treat-from-picon gnus-treat-from-picon)
1409 (gnus-treat-mail-picon gnus-treat-mail-picon)
1410 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1411 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1412 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1413 (gnus-treat-strip-trailing-blank-lines
1414 gnus-article-remove-trailing-blank-lines)
1415 (gnus-treat-strip-leading-blank-lines
1416 gnus-article-strip-leading-blank-lines)
1417 (gnus-treat-strip-multiple-blank-lines
1418 gnus-article-strip-multiple-blank-lines)
1419 (gnus-treat-overstrike gnus-article-treat-overstrike)
1420 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1421 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1422 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1423 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1424 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1425 (gnus-treat-display-smileys gnus-treat-smiley)
1426 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1427 (gnus-treat-wash-html gnus-article-wash-html)
1428 (gnus-treat-emphasize gnus-article-emphasize)
1429 (gnus-treat-hide-citation gnus-article-hide-citation)
1430 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1431 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1432 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1433 (gnus-treat-play-sounds gnus-earcon-display)))
1435 (defvar gnus-article-mime-handle-alist nil)
1436 (defvar article-lapsed-timer nil)
1437 (defvar gnus-article-current-summary nil)
1439 (defvar gnus-article-mode-syntax-table
1440 (let ((table (copy-syntax-table text-mode-syntax-table)))
1441 ;; This causes the citation match run O(2^n).
1442 ;; (modify-syntax-entry ?- "w" table)
1443 (modify-syntax-entry ?> ")<" table)
1444 (modify-syntax-entry ?< "(>" table)
1445 ;; make M-. in article buffers work for `foo' strings
1446 (modify-syntax-entry ?' " " table)
1447 (modify-syntax-entry ?` " " table)
1449 "Syntax table used in article mode buffers.
1450 Initialized from `text-mode-syntax-table.")
1452 (defvar gnus-save-article-buffer nil)
1454 (defvar gnus-article-mode-line-format-alist
1455 (nconc '((?w (gnus-article-wash-status) ?s)
1456 (?m (gnus-article-mime-part-status) ?s))
1457 gnus-summary-mode-line-format-alist))
1459 (defvar gnus-number-of-articles-to-be-saved nil)
1461 (defvar gnus-inhibit-hiding nil)
1463 ;;; Macros for dealing with the article buffer.
1465 (defmacro gnus-with-article-headers (&rest forms)
1467 (set-buffer gnus-article-buffer)
1469 (let ((buffer-read-only nil)
1470 (inhibit-point-motion-hooks t)
1471 (case-fold-search t))
1472 (article-narrow-to-head)
1475 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1476 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1478 (defmacro gnus-with-article-buffer (&rest forms)
1480 (set-buffer gnus-article-buffer)
1481 (let ((buffer-read-only nil))
1484 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1485 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1487 (defun gnus-article-goto-header (header)
1488 "Go to HEADER, which is a regular expression."
1489 (re-search-forward (concat "^\\(" header "\\):") nil t))
1491 (defsubst gnus-article-hide-text (b e props)
1492 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1493 (gnus-add-text-properties-when 'article-type nil b e props)
1494 (when (memq 'intangible props)
1496 (max (1- b) (point-min))
1497 b 'intangible (cddr (memq 'intangible props)))))
1499 (defsubst gnus-article-unhide-text (b e)
1500 "Remove hidden text properties from region between B and E."
1501 (remove-text-properties b e gnus-hidden-properties)
1502 (when (memq 'intangible gnus-hidden-properties)
1503 (put-text-property (max (1- b) (point-min))
1504 b 'intangible nil)))
1506 (defun gnus-article-hide-text-type (b e type)
1507 "Hide text of TYPE between B and E."
1508 (gnus-add-wash-type type)
1509 (gnus-article-hide-text
1510 b e (cons 'article-type (cons type gnus-hidden-properties))))
1512 (defun gnus-article-unhide-text-type (b e type)
1513 "Unhide text of TYPE between B and E."
1514 (gnus-delete-wash-type type)
1515 (remove-text-properties
1516 b e (cons 'article-type (cons type gnus-hidden-properties)))
1517 (when (memq 'intangible gnus-hidden-properties)
1518 (put-text-property (max (1- b) (point-min))
1519 b 'intangible nil)))
1521 (defun gnus-article-hide-text-of-type (type)
1522 "Hide text of TYPE in the current buffer."
1524 (let ((b (point-min))
1526 (while (setq b (text-property-any b e 'article-type type))
1527 (add-text-properties b (incf b) gnus-hidden-properties)))))
1529 (defun gnus-article-delete-text-of-type (type)
1530 "Delete text of TYPE in the current buffer."
1532 (let ((b (point-min)))
1533 (while (setq b (text-property-any b (point-max) 'article-type type))
1535 b (or (text-property-not-all b (point-max) 'article-type type)
1538 (defun gnus-article-delete-invisible-text ()
1539 "Delete all invisible text in the current buffer."
1541 (let ((b (point-min)))
1542 (while (setq b (text-property-any b (point-max) 'invisible t))
1544 b (or (text-property-not-all b (point-max) 'invisible t)
1547 (defun gnus-article-text-type-exists-p (type)
1548 "Say whether any text of type TYPE exists in the buffer."
1549 (text-property-any (point-min) (point-max) 'article-type type))
1551 (defsubst gnus-article-header-rank ()
1552 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1553 (let ((list gnus-sorted-header-list)
1556 (if (looking-at (car list))
1558 (setq list (cdr list))
1562 (defun article-hide-headers (&optional arg delete)
1563 "Hide unwanted headers and possibly sort them as well."
1565 ;; This function might be inhibited.
1566 (unless gnus-inhibit-hiding
1569 (let ((buffer-read-only nil)
1570 (case-fold-search t)
1571 (max (1+ (length gnus-sorted-header-list)))
1572 (ignored (when (not gnus-visible-headers)
1573 (cond ((stringp gnus-ignored-headers)
1574 gnus-ignored-headers)
1575 ((listp gnus-ignored-headers)
1576 (mapconcat 'identity gnus-ignored-headers
1579 (cond ((stringp gnus-visible-headers)
1580 gnus-visible-headers)
1581 ((and gnus-visible-headers
1582 (listp gnus-visible-headers))
1583 (mapconcat 'identity gnus-visible-headers "\\|"))))
1584 (inhibit-point-motion-hooks t)
1586 ;; First we narrow to just the headers.
1587 (article-narrow-to-head)
1588 ;; Hide any "From " lines at the beginning of (mail) articles.
1589 (while (looking-at "From ")
1592 (delete-region (point-min) (point)))
1593 ;; Then treat the rest of the header lines.
1594 ;; Then we use the two regular expressions
1595 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1596 ;; select which header lines is to remain visible in the
1598 (while (re-search-forward "^[^ \t:]*:" nil t)
1600 ;; Mark the rank of the header.
1602 (point) (1+ (point)) 'message-rank
1603 (if (or (and visible (looking-at visible))
1605 (not (looking-at ignored))))
1606 (gnus-article-header-rank)
1609 (message-sort-headers-1)
1610 (when (setq beg (text-property-any
1611 (point-min) (point-max) 'message-rank (+ 2 max)))
1612 ;; We delete the unwanted headers.
1613 (gnus-add-wash-type 'headers)
1614 (add-text-properties (point-min) (+ 5 (point-min))
1615 '(article-type headers dummy-invisible t))
1616 (delete-region beg (point-max))))))))
1618 (defun article-hide-boring-headers (&optional arg)
1619 "Toggle hiding of headers that aren't very interesting.
1620 If given a negative prefix, always show; if given a positive prefix,
1622 (interactive (gnus-article-hidden-arg))
1623 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1624 (not gnus-show-all-headers))
1627 (let ((buffer-read-only nil)
1628 (list gnus-boring-article-headers)
1629 (inhibit-point-motion-hooks t)
1631 (article-narrow-to-head)
1633 (setq elem (pop list))
1634 (goto-char (point-min))
1636 ;; Hide empty headers.
1638 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1640 (gnus-article-hide-text-type
1644 (if (re-search-forward "^[^ \t]" nil t)
1648 ;; Hide boring Newsgroups header.
1649 ((eq elem 'newsgroups)
1650 (when (gnus-string-equal
1651 (gnus-fetch-field "newsgroups")
1652 (gnus-group-real-name
1653 (if (boundp 'gnus-newsgroup-name)
1656 (gnus-article-hide-header "newsgroups")))
1657 ((eq elem 'to-address)
1658 (let ((to (message-fetch-field "to"))
1660 (gnus-parameter-to-address
1661 (if (boundp 'gnus-newsgroup-name)
1662 gnus-newsgroup-name ""))))
1663 (when (and to to-address
1666 ;; only one address in To
1667 (nth 1 (mail-extract-address-components to))
1669 (gnus-article-hide-header "to"))))
1671 (let ((to (message-fetch-field "to"))
1673 (gnus-parameter-to-list
1674 (if (boundp 'gnus-newsgroup-name)
1675 gnus-newsgroup-name ""))))
1676 (when (and to to-list
1679 ;; only one address in To
1680 (nth 1 (mail-extract-address-components to))
1682 (gnus-article-hide-header "to"))))
1684 (let ((cc (message-fetch-field "cc"))
1686 (gnus-parameter-to-list
1687 (if (boundp 'gnus-newsgroup-name)
1688 gnus-newsgroup-name ""))))
1689 (when (and cc to-list
1692 ;; only one address in CC
1693 (nth 1 (mail-extract-address-components cc))
1695 (gnus-article-hide-header "cc"))))
1696 ((eq elem 'followup-to)
1697 (when (gnus-string-equal
1698 (message-fetch-field "followup-to")
1699 (message-fetch-field "newsgroups"))
1700 (gnus-article-hide-header "followup-to")))
1701 ((eq elem 'reply-to)
1702 (if (gnus-group-find-parameter
1703 gnus-newsgroup-name 'broken-reply-to)
1704 (gnus-article-hide-header "reply-to")
1705 (let ((from (message-fetch-field "from"))
1706 (reply-to (message-fetch-field "reply-to")))
1713 (lambda (x) (downcase (cadr x)))
1714 (mail-extract-address-components from t))
1717 (lambda (x) (downcase (cadr x)))
1718 (mail-extract-address-components reply-to t))
1720 (gnus-article-hide-header "reply-to")))))
1722 (let ((date (message-fetch-field "date")))
1724 (< (days-between (current-time-string) date)
1726 (gnus-article-hide-header "date"))))
1728 (let ((to (message-fetch-field "to"))
1729 (cc (message-fetch-field "cc")))
1730 (when (> (length to) 1024)
1731 (gnus-article-hide-header "to"))
1732 (when (> (length cc) 1024)
1733 (gnus-article-hide-header "cc"))))
1737 (goto-char (point-min))
1738 (while (re-search-forward "^to:" nil t)
1739 (setq to-count (1+ to-count)))
1740 (when (> to-count 1)
1741 (while (> to-count 0)
1742 (goto-char (point-min))
1744 (re-search-forward "^to:" nil nil to-count)
1746 (narrow-to-region (point) (point-max))
1747 (gnus-article-hide-header "to"))
1748 (setq to-count (1- to-count))))
1749 (goto-char (point-min))
1750 (while (re-search-forward "^cc:" nil t)
1751 (setq cc-count (1+ cc-count)))
1752 (when (> cc-count 1)
1753 (while (> cc-count 0)
1754 (goto-char (point-min))
1756 (re-search-forward "^cc:" nil nil cc-count)
1758 (narrow-to-region (point) (point-max))
1759 (gnus-article-hide-header "cc"))
1760 (setq cc-count (1- cc-count)))))))))))))
1762 (defun gnus-article-hide-header (header)
1764 (goto-char (point-min))
1765 (when (re-search-forward (concat "^" header ":") nil t)
1766 (gnus-article-hide-text-type
1770 (if (re-search-forward "^[^ \t]" nil t)
1775 (defvar gnus-article-normalized-header-length 40
1776 "Length of normalized headers.")
1778 (defun article-normalize-headers ()
1779 "Make all header lines 40 characters long."
1781 (let ((buffer-read-only nil)
1785 (article-narrow-to-head)
1788 ((< (setq column (- (point-at-eol) (point)))
1789 gnus-article-normalized-header-length)
1791 (insert (make-string
1792 (- gnus-article-normalized-header-length column)
1794 ((> column gnus-article-normalized-header-length)
1795 (gnus-put-text-property
1797 (forward-char gnus-article-normalized-header-length)
1804 (forward-line 1))))))
1806 (defun article-treat-dumbquotes ()
1807 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1808 Note that this function guesses whether a character is a sm*rtq**t* or
1809 not, so it should only be used interactively.
1811 Sm*rtq**t*s are M****s***'s unilateral extension to the
1812 iso-8859-1 character map in an attempt to provide more quoting
1813 characters. If you see something like \\222 or \\264 where
1814 you're expecting some kind of apostrophe or quotation mark, then
1817 (article-translate-strings gnus-article-dumbquotes-map))
1819 (defun article-translate-characters (from to)
1820 "Translate all characters in the body of the article according to FROM and TO.
1821 FROM is a string of characters to translate from; to is a string of
1822 characters to translate to."
1824 (when (article-goto-body)
1825 (let ((buffer-read-only nil)
1826 (x (make-string 225 ?x))
1828 (while (< (incf i) (length x))
1831 (while (< i (length from))
1832 (aset x (aref from i) (aref to i))
1834 (translate-region (point) (point-max) x)))))
1836 (defun article-translate-strings (map)
1837 "Translate all string in the body of the article according to MAP.
1838 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1840 (when (article-goto-body)
1841 (let ((buffer-read-only nil)
1843 (while (setq elem (pop map))
1845 (while (search-forward (car elem) nil t)
1846 (replace-match (cadr elem)))))))))
1848 (defun article-treat-overstrike ()
1849 "Translate overstrikes into bold text."
1852 (when (article-goto-body)
1853 (let ((buffer-read-only nil))
1854 (while (search-forward "\b" nil t)
1855 (let ((next (char-after))
1856 (previous (char-after (- (point) 2))))
1857 ;; We do the boldification/underlining by hiding the
1858 ;; overstrikes and putting the proper text property
1862 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1863 (put-text-property (point) (1+ (point)) 'face 'bold))
1865 (gnus-article-hide-text-type
1866 (1- (point)) (1+ (point)) 'overstrike)
1868 (- (point) 2) (1- (point)) 'face 'underline))
1870 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1872 (point) (1+ (point)) 'face 'underline)))))))))
1874 (defun article-treat-ansi-sequences ()
1875 "Translate ANSI SGR control sequences into overlays or extents."
1878 (when (article-goto-body)
1879 (let ((buffer-read-only nil))
1880 (ansi-color-apply-on-region (point) (point-max))))))
1882 (defun gnus-article-treat-unfold-headers ()
1883 "Unfold folded message headers.
1884 Only the headers that fit into the current window width will be
1887 (gnus-with-article-headers
1891 (mail-header-narrow-to-field)
1892 (let ((header (buffer-string)))
1895 (goto-char (point-min))
1896 (while (re-search-forward "\n[\t ]" nil t)
1897 (replace-match " " t t)))
1898 (setq length (- (point-max) (point-min) 1)))
1899 (when (< length (window-width))
1900 (while (re-search-forward "\n[\t ]" nil t)
1901 (replace-match " " t t)))
1902 (goto-char (point-max)))))))
1904 (defun gnus-article-treat-fold-headers ()
1905 "Fold message headers."
1907 (gnus-with-article-headers
1910 (mail-header-narrow-to-field)
1911 (mail-header-fold-field)
1912 (goto-char (point-max))))))
1914 (defun gnus-treat-smiley ()
1915 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1917 (gnus-with-article-buffer
1918 (if (memq 'smiley gnus-article-wash-types)
1919 (gnus-delete-images 'smiley)
1921 (let ((images (smiley-region (point) (point-max))))
1923 (gnus-add-wash-type 'smiley)
1924 (dolist (image images)
1925 (gnus-add-image 'smiley image)))))))
1927 (defun gnus-article-remove-images ()
1928 "Remove all images from the article buffer."
1930 (gnus-with-article-buffer
1931 (dolist (elem gnus-article-image-alist)
1932 (gnus-delete-images (car elem)))))
1934 (defun gnus-article-treat-fold-newsgroups ()
1935 "Unfold folded message headers.
1936 Only the headers that fit into the current window width will be
1939 (gnus-with-article-headers
1940 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1942 (mail-header-narrow-to-field)
1943 (while (re-search-forward ", *" nil t)
1944 (replace-match ", " t t))
1945 (mail-header-fold-field)
1946 (goto-char (point-max))))))
1948 (defun gnus-article-treat-body-boundary ()
1949 "Place a boundary line at the end of the headers."
1951 (when (and gnus-body-boundary-delimiter
1952 (> (length gnus-body-boundary-delimiter) 0))
1953 (gnus-with-article-headers
1954 (goto-char (point-max))
1955 (let ((start (point)))
1956 (insert "X-Boundary: ")
1957 (gnus-add-text-properties start (point) '(invisible t intangible t))
1959 (while (>= (1- (window-width)) (length str))
1960 (setq str (concat str gnus-body-boundary-delimiter)))
1961 (substring str 0 (1- (window-width))))
1963 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1965 (defun article-fill-long-lines ()
1966 "Fill lines that are wider than the window width."
1969 (let ((buffer-read-only nil)
1970 (width (window-width (get-buffer-window (current-buffer)))))
1973 (let ((adaptive-fill-mode nil)) ;Why? -sm
1976 (when (>= (current-column) (min fill-column width))
1977 (narrow-to-region (min (1+ (point)) (point-max))
1979 (let ((goback (point-marker)))
1980 (fill-paragraph nil)
1981 (goto-char (marker-position goback)))
1983 (forward-line 1)))))))
1985 (defun article-capitalize-sentences ()
1986 "Capitalize the first word in each sentence."
1989 (let ((buffer-read-only nil)
1990 (paragraph-start "^[\n\^L]"))
1994 (forward-sentence)))))
1996 (defun article-remove-cr ()
1997 "Remove trailing CRs and then translate remaining CRs into LFs."
2000 (let ((buffer-read-only nil))
2001 (goto-char (point-min))
2002 (while (re-search-forward "\r+$" nil t)
2003 (replace-match "" t t))
2004 (goto-char (point-min))
2005 (while (search-forward "\r" nil t)
2006 (replace-match "\n" t t)))))
2008 (defun article-remove-trailing-blank-lines ()
2009 "Remove all trailing blank lines from the article."
2012 (let ((buffer-read-only nil))
2013 (goto-char (point-max))
2017 (while (and (not (bobp))
2018 (looking-at "^[ \t]*$")
2019 (not (gnus-annotation-in-region-p
2020 (point) (point-at-eol))))
2025 (defun article-display-face ()
2026 "Display any Face headers in the header."
2028 (let ((wash-face-p buffer-read-only))
2029 (gnus-with-article-headers
2030 ;; When displaying parts, this function can be called several times on
2031 ;; the same article, without any intended toggle semantic (as typing `W
2032 ;; D d' would have). So face deletion must occur only when we come from
2033 ;; an interactive command, that is when the *Article* buffer is
2035 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2036 (gnus-delete-images 'face)
2039 (when (and wash-face-p
2041 (goto-char (point-min))
2042 (not (re-search-forward "^Face:[\t ]*" nil t)))
2043 (gnus-buffer-live-p gnus-original-article-buffer))
2044 (set-buffer gnus-original-article-buffer))
2046 (mail-narrow-to-head)
2047 (while (gnus-article-goto-header "Face")
2048 (push (mail-header-field-value) faces))))
2049 (while (setq face (pop faces))
2050 (let ((png (gnus-convert-face-to-png face))
2053 (setq image (gnus-create-image png 'png t))
2054 (gnus-article-goto-header "from")
2056 (insert "From: [no `from' set]\n")
2058 (gnus-add-wash-type 'face)
2059 (gnus-add-image 'face image)
2060 (gnus-put-image image nil 'face))))))
2063 (defun article-display-x-face (&optional force)
2064 "Look for an X-Face header and display it if present."
2065 (interactive (list 'force))
2066 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2067 (gnus-with-article-headers
2068 ;; Delete the old process, if any.
2069 (when (process-status "article-x-face")
2070 (delete-process "article-x-face"))
2071 ;; See the comment in `article-display-face'.
2072 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2073 ;; We have already displayed X-Faces, so we remove them
2075 (gnus-delete-images 'xface)
2077 (let (x-faces from face)
2079 (when (and wash-face-p
2081 (goto-char (point-min))
2082 (not (re-search-forward
2083 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2084 (gnus-buffer-live-p gnus-original-article-buffer))
2085 ;; If type `W f', use gnus-original-article-buffer,
2086 ;; otherwise use the current buffer because displaying
2087 ;; RFC822 parts calls this function too.
2088 (set-buffer gnus-original-article-buffer))
2090 (mail-narrow-to-head)
2091 (while (gnus-article-goto-header "X-Face")
2092 (push (mail-header-field-value) x-faces))
2093 (setq from (message-fetch-field "from"))))
2094 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2095 ;; single external face.
2096 (when (stringp gnus-article-x-face-command)
2097 (setq x-faces (list (car x-faces))))
2098 (while (and (setq face (pop x-faces))
2099 gnus-article-x-face-command
2101 ;; Check whether this face is censored.
2102 (not gnus-article-x-face-too-ugly)
2103 (and gnus-article-x-face-too-ugly from
2104 (not (string-match gnus-article-x-face-too-ugly
2106 ;; We display the face.
2107 (cond ((stringp gnus-article-x-face-command)
2108 ;; The command is a string, so we interpret the command
2109 ;; as a, well, command, and fork it off.
2110 (let ((process-connection-type nil))
2111 (process-kill-without-query
2113 "article-x-face" nil shell-file-name
2114 shell-command-switch gnus-article-x-face-command))
2117 (process-send-region "article-x-face"
2118 (point-min) (point-max)))
2119 (process-send-eof "article-x-face")))
2120 ((functionp gnus-article-x-face-command)
2121 ;; The command is a lisp function, so we call it.
2122 (funcall gnus-article-x-face-command face))
2124 (error "%s is not a function"
2125 gnus-article-x-face-command)))))))))
2127 (defun article-decode-mime-words ()
2128 "Decode all MIME-encoded words in the article."
2131 (set-buffer gnus-article-buffer)
2132 (let ((inhibit-point-motion-hooks t)
2134 (mail-parse-charset gnus-newsgroup-charset)
2135 (mail-parse-ignored-charsets
2136 (save-excursion (set-buffer gnus-summary-buffer)
2137 gnus-newsgroup-ignored-charsets)))
2138 (mail-decode-encoded-word-region (point-min) (point-max)))))
2140 (defun article-decode-charset (&optional prompt)
2141 "Decode charset-encoded text in the article.
2142 If PROMPT (the prefix), prompt for a coding system to use."
2144 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2146 (mail-parse-charset gnus-newsgroup-charset)
2147 (mail-parse-ignored-charsets
2148 (save-excursion (condition-case nil
2149 (set-buffer gnus-summary-buffer)
2151 gnus-newsgroup-ignored-charsets))
2152 ct cte ctl charset format)
2155 (article-narrow-to-head)
2156 (setq ct (message-fetch-field "Content-Type" t)
2157 cte (message-fetch-field "Content-Transfer-Encoding" t)
2158 ctl (and ct (ignore-errors
2159 (mail-header-parse-content-type ct)))
2162 (mm-read-coding-system "Charset to decode: "))
2164 (mail-content-type-get ctl 'charset)))
2165 format (and ctl (mail-content-type-get ctl 'format)))
2167 (setq cte (mail-header-strip cte)))
2168 (if (and ctl (not (string-match "/" (car ctl))))
2170 (goto-char (point-max)))
2173 (narrow-to-region (point) (point-max))
2174 (when (and (eq mail-parse-charset 'gnus-decoded)
2175 (eq (mm-body-7-or-8) '8bit))
2176 ;; The text code could have been decoded.
2177 (setq charset mail-parse-charset))
2178 (when (and (or (not ctl)
2179 (equal (car ctl) "text/plain"))
2180 (not format)) ;; article with format will decode later.
2182 charset (and cte (intern (downcase
2183 (gnus-strip-whitespace cte))))
2186 (defun article-decode-encoded-words ()
2187 "Remove encoded-word encoding from headers."
2188 (let ((inhibit-point-motion-hooks t)
2189 (mail-parse-charset gnus-newsgroup-charset)
2190 (mail-parse-ignored-charsets
2191 (save-excursion (condition-case nil
2192 (set-buffer gnus-summary-buffer)
2194 gnus-newsgroup-ignored-charsets))
2197 (article-narrow-to-head)
2198 (funcall gnus-decode-header-function (point-min) (point-max)))))
2200 (defun article-decode-group-name ()
2201 "Decode group names in `Newsgroups:'."
2202 (let ((inhibit-point-motion-hooks t)
2204 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2205 (when (and (or gnus-group-name-charset-method-alist
2206 gnus-group-name-charset-group-alist)
2207 (gnus-buffer-live-p gnus-original-article-buffer))
2209 (article-narrow-to-head)
2210 (with-current-buffer gnus-original-article-buffer
2211 (goto-char (point-min)))
2212 (while (re-search-forward
2213 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2214 (replace-match (save-match-data
2215 (gnus-decode-newsgroups
2216 ;; XXX how to use data in article buffer?
2217 (with-current-buffer gnus-original-article-buffer
2219 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2222 gnus-newsgroup-name method))
2224 (goto-char (point-min))
2225 (with-current-buffer gnus-original-article-buffer
2226 (goto-char (point-min)))
2227 (while (re-search-forward
2228 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2229 (replace-match (save-match-data
2230 (gnus-decode-newsgroups
2231 ;; XXX how to use data in article buffer?
2232 (with-current-buffer gnus-original-article-buffer
2234 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2237 gnus-newsgroup-name method))
2240 (autoload 'idna-to-unicode "idna")
2242 (defun article-decode-idna-rhs ()
2243 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2246 (let ((inhibit-point-motion-hooks t)
2248 (article-narrow-to-head)
2249 (goto-char (point-min))
2250 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2252 (when (save-match-data
2253 (and (setq ace (match-string 1))
2255 (and (re-search-backward "^[^ \t]" nil t)
2256 (looking-at "From\\|To\\|Cc")))
2257 (save-excursion (backward-char)
2258 (message-idna-inside-rhs-p))
2259 (setq unicode (idna-to-unicode ace))))
2260 (unless (string= ace unicode)
2261 (replace-match unicode nil nil nil 1)))))))))
2263 (defun article-de-quoted-unreadable (&optional force read-charset)
2264 "Translate a quoted-printable-encoded article.
2265 If FORCE, decode the article whether it is marked as quoted-printable
2267 If READ-CHARSET, ask for a coding system."
2268 (interactive (list 'force current-prefix-arg))
2270 (let ((buffer-read-only nil) type charset)
2271 (if (gnus-buffer-live-p gnus-original-article-buffer)
2272 (with-current-buffer gnus-original-article-buffer
2274 (gnus-fetch-field "content-transfer-encoding"))
2275 (let* ((ct (gnus-fetch-field "content-type"))
2278 (mail-header-parse-content-type ct)))))
2279 (setq charset (and ctl
2280 (mail-content-type-get ctl 'charset)))
2281 (if (stringp charset)
2282 (setq charset (intern (downcase charset)))))))
2284 (setq charset (mm-read-coding-system "Charset: " charset)))
2286 (setq charset gnus-newsgroup-charset))
2288 (and type (let ((case-fold-search t))
2289 (string-match "quoted-printable" type))))
2291 (quoted-printable-decode-region
2292 (point) (point-max) (mm-charset-to-coding-system charset))))))
2294 (defun article-de-base64-unreadable (&optional force read-charset)
2295 "Translate a base64 article.
2296 If FORCE, decode the article whether it is marked as base64 not.
2297 If READ-CHARSET, ask for a coding system."
2298 (interactive (list 'force current-prefix-arg))
2300 (let ((buffer-read-only nil) type charset)
2301 (if (gnus-buffer-live-p gnus-original-article-buffer)
2302 (with-current-buffer gnus-original-article-buffer
2304 (gnus-fetch-field "content-transfer-encoding"))
2305 (let* ((ct (gnus-fetch-field "content-type"))
2308 (mail-header-parse-content-type ct)))))
2309 (setq charset (and ctl
2310 (mail-content-type-get ctl 'charset)))
2311 (if (stringp charset)
2312 (setq charset (intern (downcase charset)))))))
2314 (setq charset (mm-read-coding-system "Charset: " charset)))
2316 (setq charset gnus-newsgroup-charset))
2318 (and type (let ((case-fold-search t))
2319 (string-match "base64" type))))
2322 (narrow-to-region (point) (point-max))
2323 (base64-decode-region (point-min) (point-max))
2324 (mm-decode-coding-region
2325 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2330 (defun article-decode-HZ ()
2331 "Translate a HZ-encoded article."
2335 (let ((buffer-read-only nil))
2336 (rfc1843-decode-region (point-min) (point-max)))))
2338 (defun article-unsplit-urls ()
2339 "Remove the newlines that some other mailers insert into URLs."
2342 (let ((buffer-read-only nil))
2343 (goto-char (point-min))
2344 (while (re-search-forward
2345 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2346 (replace-match "\\1\\3" t)))
2347 (when (interactive-p)
2348 (gnus-treat-article nil))))
2351 (defun article-wash-html (&optional read-charset)
2352 "Format an HTML article.
2353 If READ-CHARSET, ask for a coding system."
2356 (let ((buffer-read-only nil)
2358 (when (gnus-buffer-live-p gnus-original-article-buffer)
2359 (with-current-buffer gnus-original-article-buffer
2360 (let* ((ct (gnus-fetch-field "content-type"))
2363 (mail-header-parse-content-type ct)))))
2364 (setq charset (and ctl
2365 (mail-content-type-get ctl 'charset)))
2366 (when (stringp charset)
2367 (setq charset (intern (downcase charset)))))))
2369 (setq charset (mm-read-coding-system "Charset: " charset)))
2371 (setq charset gnus-newsgroup-charset))
2373 (save-window-excursion
2375 (narrow-to-region (point) (point-max))
2376 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2377 (entry (assq func mm-text-html-washer-alist)))
2379 (setq func (cdr entry)))
2384 (apply (car func) (cdr func))))))))))
2386 (defun gnus-article-wash-html-with-w3 ()
2387 "Wash the current buffer with w3."
2389 (let ((w3-strict-width (window-width))
2390 (url-standalone-mode t)
2391 (url-gateway-unplugged t)
2392 (w3-honor-stylesheets nil))
2394 (w3-region (point-min) (point-max))
2397 (defun gnus-article-wash-html-with-w3m ()
2398 "Wash the current buffer with emacs-w3m."
2401 (narrow-to-region (point) (point-max))
2402 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2405 w3m-force-redisplay)
2406 (w3m-region (point-min) (point-max)))
2407 (when (and mm-inline-text-html-with-w3m-keymap
2408 (boundp 'w3m-minor-mode-map)
2410 (add-text-properties
2411 (point-min) (point-max)
2412 (list 'keymap w3m-minor-mode-map
2413 ;; Put the mark meaning this part was rendered by emacs-w3m.
2414 'mm-inline-text-html-with-w3m t)))))
2416 (defun article-hide-list-identifiers ()
2417 "Remove list identifies from the Subject header.
2418 The `gnus-list-identifiers' variable specifies what to do."
2420 (let ((inhibit-point-motion-hooks t)
2421 (regexp (if (consp gnus-list-identifiers)
2422 (mapconcat 'identity gnus-list-identifiers " *\\|")
2423 gnus-list-identifiers))
2428 (article-narrow-to-head)
2429 (goto-char (point-min))
2430 (while (re-search-forward
2431 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2433 (delete-region (match-beginning 2) (match-end 0))
2434 (beginning-of-line))
2435 (when (re-search-forward
2436 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2437 (delete-region (match-beginning 1) (match-end 1))))))))
2439 (defun article-hide-pem (&optional arg)
2440 "Toggle hiding of any PEM headers and signatures in the current article.
2441 If given a negative prefix, always show; if given a positive prefix,
2443 (interactive (gnus-article-hidden-arg))
2444 (unless (gnus-article-check-hidden-text 'pem arg)
2446 (let (buffer-read-only end)
2447 (goto-char (point-min))
2448 ;; Hide the horrendously ugly "header".
2449 (when (and (search-forward
2450 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2452 (setq end (1+ (match-beginning 0))))
2453 (gnus-add-wash-type 'pem)
2454 (gnus-article-hide-text-type
2456 (if (search-forward "\n\n" nil t)
2460 ;; Hide the trailer as well
2461 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2463 (gnus-article-hide-text-type
2464 (match-beginning 0) (match-end 0) 'pem)))))))
2466 (defun article-strip-banner ()
2467 "Strip the banners specified by the `banner' group parameter and by
2468 `gnus-article-address-banner-alist'."
2472 (let ((inhibit-point-motion-hooks t))
2473 (when (gnus-parameter-banner gnus-newsgroup-name)
2474 (article-really-strip-banner
2475 (gnus-parameter-banner gnus-newsgroup-name)))
2476 (when gnus-article-address-banner-alist
2477 (article-really-strip-banner
2478 (let ((from (save-restriction
2480 (article-narrow-to-head)
2481 (mail-fetch-field "from"))))
2484 (caar (mail-header-parse-addresses from))))
2486 (dolist (pair gnus-article-address-banner-alist)
2487 (when (string-match (car pair) from)
2488 (throw 'found (cdr pair)))))))))))))
2490 (defun article-really-strip-banner (banner)
2491 "Strip the banner specified by the argument."
2494 (let ((inhibit-point-motion-hooks t)
2495 (gnus-signature-limit nil)
2499 ((eq banner 'signature)
2500 (when (gnus-article-narrow-to-signature)
2503 (delete-region (point) (point-max))))
2505 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2506 (while (re-search-forward banner nil t)
2507 (delete-region (match-beginning 0) (match-end 0)))))
2509 (while (re-search-forward banner nil t)
2510 (delete-region (match-beginning 0) (match-end 0)))))))))
2512 (defun article-babel ()
2513 "Translate article using an online translation service."
2517 (set-buffer gnus-article-buffer)
2518 (when (article-goto-body)
2519 (let* ((buffer-read-only nil)
2522 (orig (buffer-substring start end))
2523 (trans (babel-as-string orig)))
2525 (narrow-to-region start end)
2526 (delete-region start end)
2529 (defun article-hide-signature (&optional arg)
2530 "Hide the signature in the current article.
2531 If given a negative prefix, always show; if given a positive prefix,
2533 (interactive (gnus-article-hidden-arg))
2534 (unless (gnus-article-check-hidden-text 'signature arg)
2537 (let ((buffer-read-only nil))
2538 (when (gnus-article-narrow-to-signature)
2539 (gnus-article-hide-text-type
2540 (point-min) (point-max) 'signature))))))
2541 (gnus-set-mode-line 'article))
2543 (defun article-strip-headers-in-body ()
2544 "Strip offensive headers from bodies."
2548 (let ((case-fold-search t))
2549 (when (looking-at "x-no-archive:")
2550 (gnus-delete-line)))))
2552 (defun article-strip-leading-blank-lines ()
2553 "Remove all blank lines from the beginning of the article."
2556 (let ((inhibit-point-motion-hooks t)
2558 (when (article-goto-body)
2559 (while (and (not (eobp))
2560 (looking-at "[ \t]*$"))
2561 (gnus-delete-line))))))
2563 (defun article-narrow-to-head ()
2564 "Narrow the buffer to the head of the message.
2565 Point is left at the beginning of the narrowed-to region."
2567 (goto-char (point-min))
2568 (if (search-forward "\n\n" nil 1)
2571 (goto-char (point-min)))
2573 (defun article-goto-body ()
2574 "Place point at the start of the body."
2575 (goto-char (point-min))
2577 ;; This variable is only bound when dealing with separate
2579 (article-goto-body-goes-to-point-min-p
2581 ((search-forward "\n\n" nil t)
2584 (goto-char (point-max))
2587 (defun article-strip-multiple-blank-lines ()
2588 "Replace consecutive blank lines with one empty line."
2591 (let ((inhibit-point-motion-hooks t)
2593 ;; First make all blank lines empty.
2595 (while (re-search-forward "^[ \t]+$" nil t)
2596 (unless (gnus-annotation-in-region-p
2597 (match-beginning 0) (match-end 0))
2598 (replace-match "" nil t)))
2599 ;; Then replace multiple empty lines with a single empty line.
2601 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2602 (unless (gnus-annotation-in-region-p
2603 (match-beginning 0) (match-end 0))
2604 (delete-region (match-beginning 1) (match-end 1)))))))
2606 (defun article-strip-leading-space ()
2607 "Remove all white space from the beginning of the lines in the article."
2610 (let ((inhibit-point-motion-hooks t)
2613 (while (re-search-forward "^[ \t]+" nil t)
2614 (replace-match "" t t)))))
2616 (defun article-strip-trailing-space ()
2617 "Remove all white space from the end of the lines in the article."
2620 (let ((inhibit-point-motion-hooks t)
2623 (while (re-search-forward "[ \t]+$" nil t)
2624 (replace-match "" t t)))))
2626 (defun article-strip-blank-lines ()
2627 "Strip leading, trailing and multiple blank lines."
2629 (article-strip-leading-blank-lines)
2630 (article-remove-trailing-blank-lines)
2631 (article-strip-multiple-blank-lines))
2633 (defun article-strip-all-blank-lines ()
2634 "Strip all blank lines."
2637 (let ((inhibit-point-motion-hooks t)
2640 (while (re-search-forward "^[ \t]*\n" nil t)
2641 (replace-match "" t t)))))
2643 (defun gnus-article-narrow-to-signature ()
2644 "Narrow to the signature; return t if a signature is found, else nil."
2645 (let ((inhibit-point-motion-hooks t))
2646 (when (gnus-article-search-signature)
2648 ;; Check whether we have some limits to what we consider
2649 ;; to be a signature.
2650 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2651 (list gnus-signature-limit)))
2653 (while (setq limit (pop limits))
2654 (if (or (and (integerp limit)
2655 (< (- (point-max) (point)) limit))
2657 (< (count-lines (point) (point-max)) limit))
2658 (and (functionp limit)
2660 (and (stringp limit)
2661 (not (re-search-forward limit nil t))))
2662 () ; This limit did not succeed.
2666 (narrow-to-region (point) (point-max))
2669 (defun gnus-article-search-signature ()
2670 "Search the current buffer for the signature separator.
2671 Put point at the beginning of the signature separator."
2672 (let ((cur (point)))
2673 (goto-char (point-max))
2674 (if (if (stringp gnus-signature-separator)
2675 (re-search-backward gnus-signature-separator nil t)
2676 (let ((seps gnus-signature-separator))
2678 (not (re-search-backward (car seps) nil t)))
2685 (defun gnus-article-hidden-arg ()
2686 "Return the current prefix arg as a number, or 0 if no prefix."
2687 (list (if current-prefix-arg
2688 (prefix-numeric-value current-prefix-arg)
2691 (defun gnus-article-check-hidden-text (type arg)
2692 "Return nil if hiding is necessary.
2693 Arg can be nil or a number. nil and positive means hide, negative
2694 means show, 0 means toggle."
2697 (let ((hide (gnus-article-hidden-text-p type)))
2703 (gnus-article-show-hidden-text type)
2706 (if (eq hide 'hidden)
2708 (gnus-article-show-hidden-text type)
2712 (defun gnus-article-hidden-text-p (type)
2713 "Say whether the current buffer contains hidden text of type TYPE."
2714 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2716 (not (get-text-property pos 'invisible))
2717 (not (get-text-property pos 'dummy-invisible)))
2719 (text-property-any (1+ pos) (point-max) 'article-type type)))
2724 (defun gnus-article-show-hidden-text (type &optional dummy)
2725 "Show all hidden text of type TYPE.
2726 Originally it is hide instead of DUMMY."
2727 (let ((buffer-read-only nil)
2728 (inhibit-point-motion-hooks t))
2729 (gnus-remove-text-properties-when
2731 (point-min) (point-max)
2732 (cons 'article-type (cons type
2733 gnus-hidden-properties)))
2734 (gnus-delete-wash-type type)))
2736 (defconst article-time-units
2737 `((year . ,(* 365.25 24 60 60))
2738 (week . ,(* 7 24 60 60))
2739 (day . ,(* 24 60 60))
2743 "Mapping from time units to seconds.")
2745 (defun gnus-article-forward-header ()
2746 "Move point to the start of the next header.
2747 If the current header is a continuation header, this can be several
2752 (if (looking-at "[ \t]+[^ \t]")
2756 (defun article-date-ut (&optional type highlight header)
2757 "Convert DATE date to universal time in the current article.
2758 If TYPE is `local', convert to local time; if it is `lapsed', output
2759 how much time has lapsed since DATE. For `lapsed', the value of
2760 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2761 should replace the \"Date:\" one, or should be added below it."
2762 (interactive (list 'ut t))
2763 (let* ((header (or header
2764 (message-fetch-field "date")
2766 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2769 ((not gnus-article-date-lapsed-new-header)
2775 (date (if (vectorp header) (mail-header-date header)
2777 (inhibit-point-motion-hooks t)
2782 (article-narrow-to-head)
2783 (when (re-search-forward tdate-regexp nil t)
2784 (setq bface (get-text-property (point-at-bol) 'face)
2785 date (or (get-text-property (point-at-bol)
2788 eface (get-text-property (1- (point-at-eol)) 'face))
2790 (when (and date (not (string= date "")))
2791 (goto-char (point-min))
2792 (let ((buffer-read-only nil))
2793 ;; Delete any old Date headers.
2794 (while (re-search-forward date-regexp nil t)
2796 (delete-region (progn (beginning-of-line) (point))
2797 (progn (gnus-article-forward-header)
2799 (delete-region (progn (beginning-of-line) (point))
2800 (progn (gnus-article-forward-header)
2803 (setq pos (point))))
2804 (when (and (not pos)
2805 (re-search-forward tdate-regexp nil t))
2809 (insert (article-make-date-line date (or type 'ut)))
2815 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2816 (put-text-property (match-beginning 1) (1+ (match-end 1))
2817 'original-date date)
2818 (put-text-property (match-beginning 1) (1+ (match-end 1))
2820 (put-text-property (match-beginning 2) (match-end 2)
2823 (defun article-make-date-line (date type)
2824 "Return a DATE line of TYPE."
2825 (unless (memq type '(local ut original user iso8601 lapsed english))
2826 (error "Unknown conversion type: %s" type))
2828 (let ((time (date-to-time date)))
2830 ;; Convert to the local timezone.
2832 (let ((tz (car (current-time-zone time))))
2833 (format "Date: %s %s%02d%02d" (current-time-string time)
2834 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2835 (/ (% (abs tz) 3600) 60))))
2836 ;; Convert to Universal Time.
2839 (current-time-string
2840 (let* ((e (parse-time-string date))
2841 (tm (apply 'encode-time e))
2843 (ls (- (cadr tm) (car (current-time-zone time)))))
2844 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2845 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2848 ;; Get the original date from the article.
2849 ((eq type 'original)
2850 (concat "Date: " (if (string-match "\n+$" date)
2851 (substring date 0 (match-beginning 0))
2853 ;; Let the user define the format.
2855 (let ((format (or (condition-case nil
2856 (with-current-buffer gnus-summary-buffer
2857 gnus-article-time-format)
2859 gnus-article-time-format)))
2860 (if (functionp format)
2861 (funcall format time)
2862 (concat "Date: " (format-time-string format time)))))
2865 (let ((tz (car (current-time-zone time))))
2868 (format-time-string "%Y%m%dT%H%M%S" time)
2869 (format "%s%02d%02d"
2870 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2871 (/ (% (abs tz) 3600) 60)))))
2872 ;; Do an X-Sent lapsed format.
2874 ;; If the date is seriously mangled, the timezone functions are
2875 ;; liable to bug out, so we ignore all errors.
2876 (let* ((now (current-time))
2877 (real-time (subtract-time now time))
2878 (real-sec (and real-time
2879 (+ (* (float (car real-time)) 65536)
2881 (sec (and real-time (abs real-sec)))
2891 ;; This is a bit convoluted, but basically we go
2892 ;; through the time units for years, weeks, etc,
2893 ;; and divide things to see whether that results
2894 ;; in positive answers.
2897 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2898 ;; The (remaining) seconds are too few to
2899 ;; be divided into this time unit.
2901 ;; It's big enough, so we output it.
2902 (setq sec (- sec (* num (cdr unit))))
2904 (concat (if prev ", " "") (int-to-string
2906 " " (symbol-name (car unit))
2907 (if (> num 1) "s" ""))
2909 article-time-units "")
2910 ;; If dates are odd, then it might appear like the
2911 ;; article was sent in the future.
2914 " in the future"))))))
2915 ;; Display the date in proper English
2917 (let ((dtime (decode-time time)))
2920 (number-to-string (nth 3 dtime))
2921 (let ((digit (% (nth 3 dtime) 10)))
2923 ((memq (nth 3 dtime) '(11 12 13)) "th")
2929 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2931 (number-to-string (nth 5 dtime))
2933 (format "%02d" (nth 2 dtime))
2935 (format "%02d" (nth 1 dtime)))))))
2937 (format "Date: %s (from Gnus)" date))))
2939 (defun article-date-local (&optional highlight)
2940 "Convert the current article date to the local timezone."
2941 (interactive (list t))
2942 (article-date-ut 'local highlight))
2944 (defun article-date-english (&optional highlight)
2945 "Convert the current article date to something that is proper English."
2946 (interactive (list t))
2947 (article-date-ut 'english highlight))
2949 (defun article-date-original (&optional highlight)
2950 "Convert the current article date to what it was originally.
2951 This is only useful if you have used some other date conversion
2952 function and want to see what the date was before converting."
2953 (interactive (list t))
2954 (article-date-ut 'original highlight))
2956 (defun article-date-lapsed (&optional highlight)
2957 "Convert the current article date to time lapsed since it was sent."
2958 (interactive (list t))
2959 (article-date-ut 'lapsed highlight))
2961 (defun article-update-date-lapsed ()
2962 "Function to be run from a timer to update the lapsed time line."
2963 (let (deactivate-mark)
2968 (set-buffer (window-buffer w))
2969 (when (eq major-mode 'gnus-article-mode)
2970 (let ((mark (point-marker)))
2971 (goto-char (point-min))
2972 (when (re-search-forward "^X-Sent:" nil t)
2973 (article-date-lapsed t))
2974 (goto-char (marker-position mark))
2975 (move-marker mark nil))))
2978 (defun gnus-start-date-timer (&optional n)
2979 "Start a timer to update the X-Sent header in the article buffers.
2980 The numerical prefix says how frequently (in seconds) the function
2985 (gnus-stop-date-timer)
2986 (setq article-lapsed-timer
2987 (run-at-time 1 n 'article-update-date-lapsed)))
2989 (defun gnus-stop-date-timer ()
2990 "Stop the X-Sent timer."
2992 (when article-lapsed-timer
2993 (nnheader-cancel-timer article-lapsed-timer)
2994 (setq article-lapsed-timer nil)))
2996 (defun article-date-user (&optional highlight)
2997 "Convert the current article date to the user-defined format.
2998 This format is defined by the `gnus-article-time-format' variable."
2999 (interactive (list t))
3000 (article-date-ut 'user highlight))
3002 (defun article-date-iso8601 (&optional highlight)
3003 "Convert the current article date to ISO8601."
3004 (interactive (list t))
3005 (article-date-ut 'iso8601 highlight))
3007 ;; (defun article-show-all ()
3008 ;; "Show all hidden text in the article buffer."
3011 ;; (let ((buffer-read-only nil))
3012 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3014 (defun article-remove-leading-whitespace ()
3015 "Remove excessive whitespace from all headers."
3019 (let ((buffer-read-only nil))
3020 (article-narrow-to-head)
3021 (goto-char (point-min))
3022 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3023 (delete-region (match-beginning 1) (match-end 1)))))))
3025 (defun article-emphasize (&optional arg)
3026 "Emphasize text according to `gnus-emphasis-alist'."
3027 (interactive (gnus-article-hidden-arg))
3028 (unless (gnus-article-check-hidden-text 'emphasis arg)
3032 (with-current-buffer gnus-summary-buffer
3033 gnus-article-emphasis-alist)
3035 gnus-emphasis-alist))
3036 (buffer-read-only nil)
3037 (props (append '(article-type emphasis)
3038 gnus-hidden-properties))
3039 regexp elem beg invisible visible face)
3042 (while (setq elem (pop alist))
3044 (setq regexp (car elem)
3045 invisible (nth 1 elem)
3046 visible (nth 2 elem)
3048 (while (re-search-forward regexp nil t)
3049 (when (and (match-beginning visible) (match-beginning invisible))
3050 (gnus-article-hide-text
3051 (match-beginning invisible) (match-end invisible) props)
3052 (gnus-article-unhide-text-type
3053 (match-beginning visible) (match-end visible) 'emphasis)
3054 (gnus-put-overlay-excluding-newlines
3055 (match-beginning visible) (match-end visible) 'face face)
3056 (gnus-add-wash-type 'emphasis)
3057 (goto-char (match-end invisible)))))))))
3059 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3060 "Setup newsgroup emphasis alist."
3061 (unless gnus-article-emphasis-alist
3062 (let ((name (and gnus-newsgroup-name
3063 (gnus-group-real-name gnus-newsgroup-name))))
3064 (make-local-variable 'gnus-article-emphasis-alist)
3065 (setq gnus-article-emphasis-alist
3067 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3068 (while (setq elem (pop alist))
3069 (when (and name (string-match (car elem) name))
3071 highlight (copy-sequence (cdr elem)))))
3073 (copy-sequence highlight-words)
3074 (if gnus-newsgroup-name
3075 (copy-sequence (gnus-group-find-parameter
3076 gnus-newsgroup-name 'highlight-words t)))
3077 gnus-emphasis-alist)))))
3080 (defvar gnus-summary-article-menu)
3081 (defvar gnus-summary-post-menu))
3083 ;;; Saving functions.
3085 (defun gnus-article-save (save-buffer file &optional num)
3086 "Save the currently selected article."
3087 (unless gnus-save-all-headers
3088 ;; Remove headers according to `gnus-saved-headers'.
3089 (let ((gnus-visible-headers
3090 (or gnus-saved-headers gnus-visible-headers))
3091 (gnus-article-buffer save-buffer))
3093 (set-buffer save-buffer)
3094 (article-hide-headers 1 t))))
3095 (save-window-excursion
3096 (if (not gnus-default-article-saver)
3097 (error "No default saver is defined")
3098 ;; !!! Magic! The saving functions all save
3099 ;; `gnus-save-article-buffer' (or so they think), but we
3100 ;; bind that variable to our save-buffer.
3101 (set-buffer gnus-article-buffer)
3102 (let* ((gnus-save-article-buffer save-buffer)
3105 ((not gnus-prompt-before-saving) 'default)
3106 ((eq gnus-prompt-before-saving 'always) nil)
3108 (gnus-number-of-articles-to-be-saved
3109 (when (eq gnus-prompt-before-saving t)
3111 (set-buffer gnus-article-current-summary)
3112 (funcall gnus-default-article-saver filename)))))
3114 (defun gnus-read-save-file-name (prompt &optional filename
3115 function group headers variable)
3117 (funcall function group headers (symbol-value variable)))
3122 ((eq filename 'default)
3128 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3131 (if (and gnus-number-of-articles-to-be-saved
3132 (> gnus-number-of-articles-to-be-saved 1))
3133 (format "these %d articles"
3134 gnus-number-of-articles-to-be-saved)
3137 ;; Let the split methods have their say.
3139 ;; No split name was found.
3142 (concat prompt " (default "
3143 (file-name-nondirectory default-name) ") ")
3144 (file-name-directory default-name)
3146 ;; A single group name is returned.
3147 ((stringp split-name)
3149 (funcall function split-name headers
3150 (symbol-value variable)))
3152 (concat prompt " (default "
3153 (file-name-nondirectory default-name) ") ")
3154 (file-name-directory default-name)
3156 ;; A single split name was found
3157 ((= 1 (length split-name))
3158 (let* ((name (expand-file-name
3160 gnus-article-save-directory))
3161 (dir (cond ((file-directory-p name)
3162 (file-name-as-directory name))
3163 ((file-exists-p name) name)
3164 (t gnus-article-save-directory))))
3166 (concat prompt " (default " name ") ")
3168 ;; A list of splits was found.
3170 (setq split-name (nreverse split-name))
3172 (let ((file-name-history
3173 (nconc split-name file-name-history)))
3177 (concat prompt " (`M-p' for defaults) ")
3178 gnus-article-save-directory
3180 gnus-article-save-directory)))
3181 (car (push result file-name-history)))))))
3182 ;; Create the directory.
3183 (gnus-make-directory (file-name-directory file))
3184 ;; If we have read a directory, we append the default file name.
3185 (when (file-directory-p file)
3186 (setq file (expand-file-name (file-name-nondirectory
3188 (file-name-as-directory file))))
3189 ;; Possibly translate some characters.
3190 (nnheader-translate-file-chars file))))))
3191 (gnus-make-directory (file-name-directory result))
3192 (set variable result)))
3194 (defun gnus-article-archive-name (group)
3195 "Return the first instance of an \"Archive-name\" in the current buffer."
3196 (let ((case-fold-search t))
3197 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3198 (nnheader-concat gnus-article-save-directory
3199 (match-string 1)))))
3201 (defun gnus-article-nndoc-name (group)
3202 "If GROUP is an nndoc group, return the name of the parent group."
3203 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3204 (gnus-group-get-parameter group 'save-article-group)))
3206 (defun gnus-summary-save-in-rmail (&optional filename)
3207 "Append this article to Rmail file.
3208 Optional argument FILENAME specifies file name.
3209 Directory to save to is default to `gnus-article-save-directory'."
3210 (setq filename (gnus-read-save-file-name
3211 "Save %s in rmail file:" filename
3212 gnus-rmail-save-name gnus-newsgroup-name
3213 gnus-current-headers 'gnus-newsgroup-last-rmail))
3214 (gnus-eval-in-buffer-window gnus-save-article-buffer
3218 (gnus-output-to-rmail filename))))
3221 (defun gnus-summary-save-in-mail (&optional filename)
3222 "Append this article to Unix mail file.
3223 Optional argument FILENAME specifies file name.
3224 Directory to save to is default to `gnus-article-save-directory'."
3225 (setq filename (gnus-read-save-file-name
3226 "Save %s in Unix mail file:" filename
3227 gnus-mail-save-name gnus-newsgroup-name
3228 gnus-current-headers 'gnus-newsgroup-last-mail))
3229 (gnus-eval-in-buffer-window gnus-save-article-buffer
3233 (if (and (file-readable-p filename)
3234 (file-regular-p filename)
3235 (mail-file-babyl-p filename))
3236 (rmail-output-to-rmail-file filename t)
3237 (gnus-output-to-mail filename)))))
3240 (defun gnus-summary-save-in-file (&optional filename overwrite)
3241 "Append this article to file.
3242 Optional argument FILENAME specifies file name.
3243 Directory to save to is default to `gnus-article-save-directory'."
3244 (setq filename (gnus-read-save-file-name
3245 "Save %s in file:" filename
3246 gnus-file-save-name gnus-newsgroup-name
3247 gnus-current-headers 'gnus-newsgroup-last-file))
3248 (gnus-eval-in-buffer-window gnus-save-article-buffer
3252 (when (and overwrite
3253 (file-exists-p filename))
3254 (delete-file filename))
3255 (gnus-output-to-file filename))))
3258 (defun gnus-summary-write-to-file (&optional filename)
3259 "Write this article to a file, overwriting it if the file exists.
3260 Optional argument FILENAME specifies file name.
3261 The directory to save in defaults to `gnus-article-save-directory'."
3262 (gnus-summary-save-in-file nil t))
3264 (defun gnus-summary-save-body-in-file (&optional filename)
3265 "Append this article body to a file.
3266 Optional argument FILENAME specifies file name.
3267 The directory to save in defaults to `gnus-article-save-directory'."
3268 (setq filename (gnus-read-save-file-name
3269 "Save %s body in file:" filename
3270 gnus-file-save-name gnus-newsgroup-name
3271 gnus-current-headers 'gnus-newsgroup-last-file))
3272 (gnus-eval-in-buffer-window gnus-save-article-buffer
3276 (when (article-goto-body)
3277 (narrow-to-region (point) (point-max)))
3278 (gnus-output-to-file filename))))
3281 (defun gnus-summary-save-in-pipe (&optional command)
3282 "Pipe this article to subprocess."
3284 (cond ((and (eq command 'default)
3285 gnus-last-shell-command)
3286 gnus-last-shell-command)
3291 "Shell command on %s: "
3292 (if (and gnus-number-of-articles-to-be-saved
3293 (> gnus-number-of-articles-to-be-saved 1))
3294 (format "these %d articles"
3295 gnus-number-of-articles-to-be-saved)
3297 gnus-last-shell-command))))
3298 (when (string-equal command "")
3299 (if gnus-last-shell-command
3300 (setq command gnus-last-shell-command)
3301 (error "A command is required")))
3302 (gnus-eval-in-buffer-window gnus-article-buffer
3305 (shell-command-on-region (point-min) (point-max) command nil)))
3306 (setq gnus-last-shell-command command))
3308 (defun gnus-summary-pipe-to-muttprint (&optional command)
3309 "Pipe this article to muttprint."
3310 (setq command (read-string
3311 "Print using command: " gnus-summary-muttprint-program
3312 nil gnus-summary-muttprint-program))
3313 (gnus-summary-save-in-pipe command))
3315 ;;; Article file names when saving.
3317 (defun gnus-capitalize-newsgroup (newsgroup)
3318 "Capitalize NEWSGROUP name."
3319 (when (not (zerop (length newsgroup)))
3320 (concat (char-to-string (upcase (aref newsgroup 0)))
3321 (substring newsgroup 1))))
3323 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3324 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3325 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3326 Otherwise, it is like ~/News/news/group/num."
3329 (concat (if (gnus-use-long-file-name 'not-save)
3330 (gnus-capitalize-newsgroup newsgroup)
3331 (gnus-newsgroup-directory-form newsgroup))
3332 "/" (int-to-string (mail-header-number headers)))
3333 gnus-article-save-directory)))
3335 (string-equal (file-name-directory default)
3336 (file-name-directory last-file))
3337 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3339 (or last-file default))))
3341 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3342 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3343 If variable `gnus-use-long-file-name' is non-nil, it is
3344 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3347 (concat (if (gnus-use-long-file-name 'not-save)
3349 (gnus-newsgroup-directory-form newsgroup))
3350 "/" (int-to-string (mail-header-number headers)))
3351 gnus-article-save-directory)))
3353 (string-equal (file-name-directory default)
3354 (file-name-directory last-file))
3355 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3357 (or last-file default))))
3359 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3360 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3361 If variable `gnus-use-long-file-name' is non-nil, it is
3362 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3365 (if (gnus-use-long-file-name 'not-save)
3368 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3370 gnus-article-save-directory)))
3372 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3373 "Generate file name from sender."
3374 (let ((from (mail-header-from headers)))
3376 (if (and from (string-match "\\([^ <]+\\)@" from))
3377 (match-string 1 from)
3379 gnus-article-save-directory)))
3381 (defun article-verify-x-pgp-sig ()
3384 (if (gnus-buffer-live-p gnus-original-article-buffer)
3385 (let ((sig (with-current-buffer gnus-original-article-buffer
3386 (gnus-fetch-field "X-PGP-Sig")))
3390 (mml2015-clear-verify-function))
3392 (insert-buffer-substring gnus-original-article-buffer)
3393 (setq items (split-string sig))
3394 (message-narrow-to-head)
3395 (let ((inhibit-point-motion-hooks t)
3396 (case-fold-search t))
3397 ;; Don't verify multiple headers.
3398 (setq headers (mapconcat (lambda (header)
3400 (mail-fetch-field header)
3402 (split-string (nth 1 items) ",") "")))
3403 (delete-region (point-min) (point-max))
3404 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3405 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3410 (if (looking-at "^-")
3413 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3414 (insert "Version: " (car items) "\n\n")
3415 (insert (mapconcat 'identity (cddr items) "\n"))
3416 (insert "\n-----END PGP SIGNATURE-----\n")
3417 (let ((mm-security-handle (list (format "multipart/signed"))))
3418 (mml2015-clean-buffer)
3419 (let ((coding-system-for-write (or gnus-newsgroup-charset
3421 (funcall (mml2015-clear-verify-function)))
3423 (or (mm-handle-multipart-ctl-parameter
3424 mm-security-handle 'gnus-details)
3425 (mm-handle-multipart-ctl-parameter
3426 mm-security-handle 'gnus-info)))))
3428 (let (buffer-read-only bface eface)
3430 (message-narrow-to-head)
3431 (goto-char (point-max))
3433 (setq bface (get-text-property (point-at-bol) 'face)
3434 eface (get-text-property (1- (point-at-eol)) 'face))
3435 (message-remove-header "X-Gnus-PGP-Verify")
3436 (if (re-search-forward "^X-PGP-Sig:" nil t)
3438 (goto-char (point-max)))
3439 (narrow-to-region (point) (point))
3440 (insert "X-Gnus-PGP-Verify: " info "\n")
3441 (goto-char (point-min))
3444 (if (not (looking-at "^[ \t]"))
3448 (goto-char (point-min))
3449 (when (looking-at "\\([^:]+\\): *")
3450 (put-text-property (match-beginning 1) (1+ (match-end 1))
3452 (put-text-property (match-end 0) (point-max)
3453 'face eface)))))))))
3455 (defun article-verify-cancel-lock ()
3456 "Verify Cancel-Lock header."
3458 (if (gnus-buffer-live-p gnus-original-article-buffer)
3459 (canlock-verify gnus-original-article-buffer)))
3466 (setq afunc (car func)
3469 gfunc (intern (format "gnus-%s" func))))
3471 (when (fboundp afunc)
3472 `(lambda (&optional interactive &rest args)
3473 ,(documentation afunc t)
3474 (interactive (list t))
3476 (set-buffer gnus-article-buffer)
3478 (call-interactively ',afunc)
3479 (apply ',afunc args))))))))
3480 '(article-hide-headers
3481 article-verify-x-pgp-sig
3482 article-verify-cancel-lock
3483 article-hide-boring-headers
3484 article-treat-overstrike
3485 article-treat-ansi-sequences
3486 article-fill-long-lines
3487 article-capitalize-sentences
3489 article-remove-leading-whitespace
3490 article-display-x-face
3491 article-display-face
3492 article-de-quoted-unreadable
3493 article-de-base64-unreadable
3496 article-unsplit-urls
3497 article-hide-list-identifiers
3498 article-strip-banner
3501 article-hide-signature
3502 article-strip-headers-in-body
3503 article-remove-trailing-blank-lines
3504 article-strip-leading-blank-lines
3505 article-strip-multiple-blank-lines
3506 article-strip-leading-space
3507 article-strip-trailing-space
3508 article-strip-blank-lines
3509 article-strip-all-blank-lines
3511 article-date-english
3512 article-date-iso8601
3513 article-date-original
3515 article-decode-mime-words
3516 article-decode-charset
3517 article-decode-encoded-words
3521 article-treat-dumbquotes
3522 article-normalize-headers
3523 ;; (article-show-all . gnus-article-show-all-headers)
3527 ;;; Gnus article mode
3530 (put 'gnus-article-mode 'mode-class 'special)
3532 (set-keymap-parent gnus-article-mode-map widget-keymap)
3534 (gnus-define-keys gnus-article-mode-map
3535 " " gnus-article-goto-next-page
3536 "\177" gnus-article-goto-prev-page
3537 [delete] gnus-article-goto-prev-page
3538 [backspace] gnus-article-goto-prev-page
3539 "\C-c^" gnus-article-refer-article
3540 "h" gnus-article-show-summary
3541 "s" gnus-article-show-summary
3542 "\C-c\C-m" gnus-article-mail
3543 "?" gnus-article-describe-briefly
3544 "e" gnus-summary-edit-article
3545 "<" beginning-of-buffer
3547 "\C-c\C-i" gnus-info-find-node
3549 "R" gnus-article-reply-with-original
3550 "F" gnus-article-followup-with-original
3551 "\C-hk" gnus-article-describe-key
3552 "\C-hc" gnus-article-describe-key-briefly
3554 "\C-d" gnus-article-read-summary-keys
3555 "\M-*" gnus-article-read-summary-keys
3556 "\M-#" gnus-article-read-summary-keys
3557 "\M-^" gnus-article-read-summary-keys
3558 "\M-g" gnus-article-read-summary-keys)
3560 (substitute-key-definition
3561 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3563 (defun gnus-article-make-menu-bar ()
3564 (unless (boundp 'gnus-article-commands-menu)
3565 (gnus-summary-make-menu-bar))
3566 (gnus-turn-off-edit-menu 'article)
3567 (unless (boundp 'gnus-article-article-menu)
3569 gnus-article-article-menu gnus-article-mode-map ""
3571 ["Scroll forwards" gnus-article-goto-next-page t]
3572 ["Scroll backwards" gnus-article-goto-prev-page t]
3573 ["Show summary" gnus-article-show-summary t]
3574 ["Fetch Message-ID at point" gnus-article-refer-article t]
3575 ["Mail to address at point" gnus-article-mail t]
3576 ["Send a bug report" gnus-bug t]))
3579 gnus-article-treatment-menu gnus-article-mode-map ""
3580 ;; Fixme: this should use :active (and maybe :visible).
3582 ["Hide headers" gnus-article-hide-headers t]
3583 ["Hide signature" gnus-article-hide-signature t]
3584 ["Hide citation" gnus-article-hide-citation t]
3585 ["Treat overstrike" gnus-article-treat-overstrike t]
3586 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3587 ["Remove carriage return" gnus-article-remove-cr t]
3588 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3589 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3590 ["Remove base64" gnus-article-de-base64-unreadable t]
3591 ["Treat html" gnus-article-wash-html t]
3592 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3593 ["Decode HZ" gnus-article-decode-HZ t]))
3595 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3597 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3599 (gnus-run-hooks 'gnus-article-menu-hook)))
3601 (defun gnus-article-mode ()
3602 "Major mode for displaying an article.
3604 All normal editing commands are switched off.
3606 The following commands are available in addition to all summary mode
3608 \\<gnus-article-mode-map>
3609 \\[gnus-article-next-page]\t Scroll the article one page forwards
3610 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3611 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3612 \\[gnus-article-show-summary]\t Display the summary buffer
3613 \\[gnus-article-mail]\t Send a reply to the address near point
3614 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3615 \\[gnus-info-find-node]\t Go to the Gnus info node"
3617 (gnus-simplify-mode-line)
3618 (setq mode-name "Article")
3619 (setq major-mode 'gnus-article-mode)
3620 (make-local-variable 'minor-mode-alist)
3621 (use-local-map gnus-article-mode-map)
3622 (when (gnus-visual-p 'article-menu 'menu)
3623 (gnus-article-make-menu-bar)
3624 (when gnus-summary-tool-bar-map
3625 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3626 (gnus-update-format-specifications nil 'article-mode)
3627 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3628 (set (make-local-variable 'gnus-page-broken) nil)
3629 (make-local-variable 'gnus-button-marker-list)
3630 (make-local-variable 'gnus-article-current-summary)
3631 (make-local-variable 'gnus-article-mime-handles)
3632 (make-local-variable 'gnus-article-decoded-p)
3633 (make-local-variable 'gnus-article-mime-handle-alist)
3634 (make-local-variable 'gnus-article-wash-types)
3635 (make-local-variable 'gnus-article-image-alist)
3636 (make-local-variable 'gnus-article-charset)
3637 (make-local-variable 'gnus-article-ignored-charsets)
3638 (gnus-set-default-directory)
3639 (buffer-disable-undo)
3640 (setq buffer-read-only t)
3641 (set-syntax-table gnus-article-mode-syntax-table)
3642 (mm-enable-multibyte)
3643 (gnus-run-hooks 'gnus-article-mode-hook))
3645 (defun gnus-article-setup-buffer ()
3646 "Initialize the article buffer."
3647 (let* ((name (if gnus-single-article-buffer "*Article*"
3648 (concat "*Article " gnus-newsgroup-name "*")))
3650 (progn (string-match "\\*Article" name)
3651 (concat " *Original Article"
3652 (substring name (match-end 0))))))
3653 (setq gnus-article-buffer name)
3654 (setq gnus-original-article-buffer original)
3655 (setq gnus-article-mime-handle-alist nil)
3656 ;; This might be a variable local to the summary buffer.
3657 (unless gnus-single-article-buffer
3659 (set-buffer gnus-summary-buffer)
3660 (setq gnus-article-buffer name)
3661 (setq gnus-original-article-buffer original)
3662 (gnus-set-global-variables)))
3663 (gnus-article-setup-highlight-words)
3664 ;; Init original article buffer.
3666 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3667 (mm-enable-multibyte)
3668 (setq major-mode 'gnus-original-article-mode)
3669 (make-local-variable 'gnus-original-article))
3670 (if (get-buffer name)
3673 (when (and gnus-article-edit-mode
3676 (y-or-n-p "Article mode edit in progress; discard? ")))
3677 (error "Action aborted"))
3678 (set (make-local-variable 'gnus-article-edit-mode) nil)
3679 (when gnus-article-mime-handles
3680 (mm-destroy-parts gnus-article-mime-handles)
3681 (setq gnus-article-mime-handles nil))
3682 ;; Set it to nil in article-buffer!
3683 (setq gnus-article-mime-handle-alist nil)
3684 (buffer-disable-undo)
3685 (setq buffer-read-only t)
3686 ;; This list just keeps growing if we don't reset it.
3687 (setq gnus-button-marker-list nil)
3688 (unless (eq major-mode 'gnus-article-mode)
3689 (gnus-article-mode))
3692 (set-buffer (gnus-get-buffer-create name))
3694 (make-local-variable 'gnus-summary-buffer)
3695 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3696 (current-buffer)))))
3698 ;; Set article window start at LINE, where LINE is the number of lines
3699 ;; from the head of the article.
3700 (defun gnus-article-set-window-start (&optional line)
3702 (gnus-get-buffer-window gnus-article-buffer t)
3704 (set-buffer gnus-article-buffer)
3705 (goto-char (point-min))
3708 (gnus-message 6 "Moved to bookmark")
3709 (search-forward "\n\n" nil t)
3713 (defun gnus-article-prepare (article &optional all-headers header)
3714 "Prepare ARTICLE in article mode buffer.
3715 ARTICLE should either be an article number or a Message-ID.
3716 If ARTICLE is an id, HEADER should be the article headers.
3717 If ALL-HEADERS is non-nil, no headers are hidden."
3719 ;; Make sure we start in a summary buffer.
3720 (unless (eq major-mode 'gnus-summary-mode)
3721 (set-buffer gnus-summary-buffer))
3722 (setq gnus-summary-buffer (current-buffer))
3723 (let* ((gnus-article (if header (mail-header-number header) article))
3724 (summary-buffer (current-buffer))
3725 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3726 (group gnus-newsgroup-name)
3729 (gnus-article-setup-buffer)
3730 (set-buffer gnus-article-buffer)
3731 ;; Deactivate active regions.
3732 (when (and (boundp 'transient-mark-mode)
3733 transient-mark-mode)
3734 (setq mark-active nil))
3735 (if (not (setq result (let ((buffer-read-only nil))
3736 (gnus-request-article-this-buffer
3738 ;; There is no such article.
3740 (when (and (numberp article)
3741 (not (memq article gnus-newsgroup-sparse)))
3742 (setq gnus-article-current
3743 (cons gnus-newsgroup-name article))
3744 (set-buffer gnus-summary-buffer)
3745 (setq gnus-current-article article)
3746 (if (and (memq article gnus-newsgroup-undownloaded)
3747 (not (gnus-online (gnus-find-method-for-group
3748 gnus-newsgroup-name))))
3750 (gnus-summary-set-agent-mark article)
3751 (message "Message marked for downloading"))
3752 (gnus-summary-mark-article article gnus-canceled-mark)
3753 (unless (memq article gnus-newsgroup-sparse)
3754 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3755 (if (or (eq result 'pseudo)
3756 (eq result 'nneething))
3759 (set-buffer summary-buffer)
3760 (push article gnus-newsgroup-history)
3761 (setq gnus-last-article gnus-current-article
3762 gnus-current-article 0
3763 gnus-current-headers nil
3764 gnus-article-current nil)
3765 (if (eq result 'nneething)
3766 (gnus-configure-windows 'summary)
3767 (gnus-configure-windows 'article))
3768 (gnus-set-global-variables))
3769 (let ((gnus-article-mime-handle-alist-1
3770 gnus-article-mime-handle-alist))
3771 (gnus-set-mode-line 'article)))
3772 ;; The result from the `request' was an actual article -
3773 ;; or at least some text that is now displayed in the
3775 (when (and (numberp article)
3776 (not (eq article gnus-current-article)))
3777 ;; Seems like a new article has been selected.
3778 ;; `gnus-current-article' must be an article number.
3780 (set-buffer summary-buffer)
3781 (push article gnus-newsgroup-history)
3782 (setq gnus-last-article gnus-current-article
3783 gnus-current-article article
3784 gnus-current-headers
3785 (gnus-summary-article-header gnus-current-article)
3786 gnus-article-current
3787 (cons gnus-newsgroup-name gnus-current-article))
3788 (unless (vectorp gnus-current-headers)
3789 (setq gnus-current-headers nil))
3790 (gnus-summary-goto-subject gnus-current-article)
3791 (when (gnus-summary-show-thread)
3792 ;; If the summary buffer really was folded, the
3793 ;; previous goto may not actually have gone to
3794 ;; the right article, but the thread root instead.
3796 (gnus-summary-goto-subject gnus-current-article))
3797 (gnus-run-hooks 'gnus-mark-article-hook)
3798 (gnus-set-mode-line 'summary)
3799 (when (gnus-visual-p 'article-highlight 'highlight)
3800 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3801 ;; Set the global newsgroup variables here.
3802 (gnus-set-global-variables)
3803 (setq gnus-have-all-headers
3804 (or all-headers gnus-show-all-headers))))
3806 (gnus-configure-windows 'article))
3807 (when (or (numberp article)
3809 (gnus-article-prepare-display)
3811 (goto-char (point-min))
3812 (when gnus-break-pages
3813 (gnus-narrow-to-page)))
3814 (let ((gnus-article-mime-handle-alist-1
3815 gnus-article-mime-handle-alist))
3816 (gnus-set-mode-line 'article))
3820 (set-window-point (get-buffer-window (current-buffer)) (point))
3821 (gnus-configure-windows 'article)
3825 (defun gnus-article-prepare-display ()
3826 "Make the current buffer look like a nice article."
3827 ;; Hooks for getting information from the article.
3828 ;; This hook must be called before being narrowed.
3829 (let ((gnus-article-buffer (current-buffer))
3831 (unless (eq major-mode 'gnus-article-mode)
3832 (gnus-article-mode))
3833 (setq buffer-read-only nil
3834 gnus-article-wash-types nil
3835 gnus-article-image-alist nil)
3836 (gnus-run-hooks 'gnus-tmp-internal-hook)
3837 (when gnus-display-mime-function
3838 (funcall gnus-display-mime-function))
3839 (gnus-run-hooks 'gnus-article-prepare-hook)))
3842 ;;; Gnus MIME viewing functions
3845 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3846 "Format of the MIME buttons.
3848 Valid specifiers include:
3850 %T MIME type, along with additional info
3851 %n The `name' parameter
3852 %d The description, if any
3853 %l The length of the encoded part
3854 %p The part identifier number
3855 %e Dots if the part isn't displayed
3857 General format specifiers can also be used. See Info node
3858 `(gnus)Formatting Variables'.")
3860 (defvar gnus-mime-button-line-format-alist
3861 '((?t gnus-tmp-type ?s)
3862 (?T gnus-tmp-type-long ?s)
3863 (?n gnus-tmp-name ?s)
3864 (?d gnus-tmp-description ?s)
3866 (?l gnus-tmp-length ?d)
3867 (?e gnus-tmp-dots ?s)))
3869 (defvar gnus-mime-button-commands
3870 '((gnus-article-press-button "\r" "Toggle Display")
3871 (gnus-mime-view-part "v" "View Interactively...")
3872 (gnus-mime-view-part-as-type "t" "View As Type...")
3873 (gnus-mime-view-part-as-charset "C" "View As charset...")
3874 (gnus-mime-save-part "o" "Save...")
3875 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3876 (gnus-mime-delete-part "d" "Delete part")
3877 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3878 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3879 (gnus-mime-view-part-internally "E" "View Internally")
3880 (gnus-mime-view-part-externally "e" "View Externally")
3881 (gnus-mime-print-part "p" "Print")
3882 (gnus-mime-pipe-part "|" "Pipe To Command...")
3883 (gnus-mime-action-on-part "." "Take action on the part...")))
3885 (defun gnus-article-mime-part-status ()
3886 (if gnus-article-mime-handle-alist-1
3887 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3889 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3892 (defvar gnus-mime-button-map
3893 (let ((map (make-sparse-keymap)))
3894 (define-key map gnus-mouse-2 'gnus-article-push-button)
3895 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3896 (dolist (c gnus-mime-button-commands)
3897 (define-key map (cadr c) (car c)))
3901 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
3903 ,@(mapcar (lambda (c)
3904 (vector (caddr c) (car c) :enable t))
3905 gnus-mime-button-commands)))
3907 (defun gnus-mime-button-menu (event prefix)
3908 "Construct a context-sensitive menu of MIME commands."
3909 (interactive "e\nP")
3910 (save-window-excursion
3911 (let ((pos (event-start event)))
3912 (select-window (posn-window pos))
3913 (goto-char (posn-point pos))
3914 (gnus-article-check-buffer)
3915 (popup-menu gnus-mime-button-menu nil prefix))))
3917 (defun gnus-mime-view-all-parts (&optional handles)
3918 "View all the MIME parts."
3920 (save-current-buffer
3921 (set-buffer gnus-article-buffer)
3922 (let ((handles (or handles gnus-article-mime-handles))
3923 (mail-parse-charset gnus-newsgroup-charset)
3924 (mail-parse-ignored-charsets
3925 (with-current-buffer gnus-summary-buffer
3926 gnus-newsgroup-ignored-charsets)))
3928 (mm-remove-parts handles)
3929 (goto-char (point-min))
3930 (or (search-forward "\n\n") (goto-char (point-max)))
3931 (let (buffer-read-only)
3932 (delete-region (point) (point-max))
3933 (mm-display-parts handles))))))
3935 (defun gnus-mime-save-part-and-strip ()
3936 "Save the MIME part under point then replace it with an external body."
3938 (gnus-article-check-buffer)
3939 (let* ((data (get-text-property (point) 'gnus-data))
3941 (handles gnus-article-mime-handles))
3942 (if (mm-multiple-handles gnus-article-mime-handles)
3943 (error "This function is not implemented"))
3944 (setq file (and data (mm-save-part data)))
3946 (with-current-buffer (mm-handle-buffer data)
3948 (insert "Content-Type: " (mm-handle-media-type data))
3949 (mml-insert-parameter-string (cdr (mm-handle-type data))
3952 (insert "Content-ID: " (message-make-message-id) "\n")
3953 (insert "Content-Transfer-Encoding: binary\n")
3956 (cdr (mm-make-handle nil
3957 `("message/external-body"
3958 (access-type . "LOCAL-FILE")
3960 (set-buffer gnus-summary-buffer)
3961 (gnus-article-edit-article
3964 (let ((mail-parse-charset (or gnus-article-charset
3965 ',gnus-newsgroup-charset))
3966 (mail-parse-ignored-charsets
3967 (or gnus-article-ignored-charsets
3968 ',gnus-newsgroup-ignored-charsets))
3969 (mbl mml-buffer-list))
3970 (setq mml-buffer-list nil)
3971 (insert-buffer gnus-original-article-buffer)
3972 (mime-to-mml ',handles)
3973 (setq gnus-article-mime-handles nil)
3974 (let ((mbl1 mml-buffer-list))
3975 (setq mml-buffer-list mbl)
3976 (set (make-local-variable 'mml-buffer-list) mbl1))
3977 (gnus-make-local-hook 'kill-buffer-hook)
3978 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3979 `(lambda (no-highlight)
3980 (let ((mail-parse-charset (or gnus-article-charset
3981 ',gnus-newsgroup-charset))
3982 (message-options message-options)
3983 (message-options-set-recipient)
3984 (mail-parse-ignored-charsets
3985 (or gnus-article-ignored-charsets
3986 ',gnus-newsgroup-ignored-charsets)))
3988 (mml-destroy-buffers)
3989 (remove-hook 'kill-buffer-hook
3990 'mml-destroy-buffers t)
3991 (kill-local-variable 'mml-buffer-list))
3992 (gnus-summary-edit-article-done
3993 ,(or (mail-header-references gnus-current-headers) "")
3994 ,(gnus-group-read-only-p)
3995 ,gnus-summary-buffer no-highlight))))))
3997 (defun gnus-mime-delete-part ()
3998 "Delete the MIME part under point.
3999 Replace it with some information about the removed part."
4001 (gnus-article-check-buffer)
4002 (unless (and gnus-novice-user
4003 (not (gnus-yes-or-no-p
4004 "Really delete attachment forever? ")))
4005 (let* ((data (get-text-property (point) 'gnus-data))
4006 (handles gnus-article-mime-handles)
4010 (mail-decode-encoded-word-string (or (mm-handle-description data)
4013 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4015 (type (mm-handle-media-type data)))
4016 (if (mm-multiple-handles gnus-article-mime-handles)
4017 (error "This function is not implemented"))
4018 (with-current-buffer (mm-handle-buffer data)
4019 (let ((bsize (format "%s" (buffer-size))))
4024 "| The following attachment has been deleted:\n"
4026 "| Type: " type "\n"
4027 "| Filename: " filename "\n"
4028 "| Size (encoded): " bsize " Byte\n"
4029 "| Description: " description "\n"
4032 (cdr (mm-make-handle
4033 nil `("text/plain") nil nil
4035 (format "Deleted attachment (%s bytes)" bsize))))))
4036 (set-buffer gnus-summary-buffer)
4037 ;; FIXME: maybe some of the following code (borrowed from
4038 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4039 (gnus-article-edit-article
4042 (let ((mail-parse-charset (or gnus-article-charset
4043 ',gnus-newsgroup-charset))
4044 (mail-parse-ignored-charsets
4045 (or gnus-article-ignored-charsets
4046 ',gnus-newsgroup-ignored-charsets))
4047 (mbl mml-buffer-list))
4048 (setq mml-buffer-list nil)
4049 (insert-buffer gnus-original-article-buffer)
4050 (mime-to-mml ',handles)
4051 (setq gnus-article-mime-handles nil)
4052 (let ((mbl1 mml-buffer-list))
4053 (setq mml-buffer-list mbl)
4054 (set (make-local-variable 'mml-buffer-list) mbl1))
4055 (gnus-make-local-hook 'kill-buffer-hook)
4056 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4057 `(lambda (no-highlight)
4058 (let ((mail-parse-charset (or gnus-article-charset
4059 ',gnus-newsgroup-charset))
4060 (message-options message-options)
4061 (message-options-set-recipient)
4062 (mail-parse-ignored-charsets
4063 (or gnus-article-ignored-charsets
4064 ',gnus-newsgroup-ignored-charsets)))
4066 (mml-destroy-buffers)
4067 (remove-hook 'kill-buffer-hook
4068 'mml-destroy-buffers t)
4069 (kill-local-variable 'mml-buffer-list))
4070 (gnus-summary-edit-article-done
4071 ,(or (mail-header-references gnus-current-headers) "")
4072 ,(gnus-group-read-only-p)
4073 ,gnus-summary-buffer no-highlight)))))
4074 ;; Not in `gnus-mime-save-part-and-strip':
4075 (gnus-article-edit-done)
4076 (gnus-summary-expand-window)
4077 (gnus-summary-show-article))
4079 (defun gnus-mime-save-part ()
4080 "Save the MIME part under point."
4082 (gnus-article-check-buffer)
4083 (let ((data (get-text-property (point) 'gnus-data)))
4085 (mm-save-part data))))
4087 (defun gnus-mime-pipe-part ()
4088 "Pipe the MIME part under point to a process."
4090 (gnus-article-check-buffer)
4091 (let ((data (get-text-property (point) 'gnus-data)))
4093 (mm-pipe-part data))))
4095 (defun gnus-mime-view-part ()
4096 "Interactively choose a viewing method for the MIME part under point."
4098 (gnus-article-check-buffer)
4099 (let ((data (get-text-property (point) 'gnus-data)))
4101 (setq gnus-article-mime-handles
4103 gnus-article-mime-handles (setq data (copy-sequence data))))
4104 (mm-interactively-view-part data))))
4106 (defun gnus-mime-view-part-as-type-internal ()
4107 (gnus-article-check-buffer)
4108 (let* ((name (mail-content-type-get
4109 (mm-handle-type (get-text-property (point) 'gnus-data))
4111 (def-type (and name (mm-default-file-encoding name))))
4112 (and def-type (cons def-type 0))))
4114 (defun gnus-mime-view-part-as-type (&optional mime-type)
4115 "Choose a MIME media type, and view the part as such."
4118 (setq mime-type (completing-read
4119 "View as MIME type: "
4120 (mapcar #'list (mailcap-mime-types))
4122 (gnus-mime-view-part-as-type-internal))))
4123 (gnus-article-check-buffer)
4124 (let ((handle (get-text-property (point) 'gnus-data)))
4127 (mm-make-handle (mm-handle-buffer handle)
4128 (cons mime-type (cdr (mm-handle-type handle)))
4129 (mm-handle-encoding handle)
4130 (mm-handle-undisplayer handle)
4131 (mm-handle-disposition handle)
4132 (mm-handle-description handle)
4134 (mm-handle-id handle)))
4135 (setq gnus-article-mime-handles
4136 (mm-merge-handles gnus-article-mime-handles handle))
4137 (gnus-mm-display-part handle))))
4140 (require 'jka-compr))
4142 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4143 ;; emacs can do that itself.
4145 (defun gnus-mime-jka-compr-maybe-uncompress ()
4146 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4147 The uncompress method used is derived from `buffer-file-name'."
4148 (when (and (fboundp 'jka-compr-installed-p)
4149 (jka-compr-installed-p))
4150 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4152 (let ((basename (file-name-nondirectory buffer-file-name))
4153 (args (jka-compr-info-uncompress-args info))
4154 (prog (jka-compr-info-uncompress-program info))
4155 (message (jka-compr-info-uncompress-message info))
4156 (err-file (jka-compr-make-temp-name)))
4158 (message "%s %s..." message basename))
4160 (unless (memq (apply 'call-process-region
4161 (point-min) (point-max)
4163 t (list t err-file) nil
4165 jka-compr-acceptable-retval-list)
4166 (jka-compr-error prog args basename message err-file))
4167 (jka-compr-delete-temp-file err-file)))))))
4169 (defun gnus-mime-copy-part (&optional handle)
4170 "Put the MIME part under point into a new buffer.
4171 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4174 (gnus-article-check-buffer)
4175 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4176 (contents (and handle (mm-get-part handle)))
4178 (file-name-nondirectory
4180 (mail-content-type-get (mm-handle-type handle) 'name)
4181 (mail-content-type-get (mm-handle-disposition handle)
4184 (buffer (and base (generate-new-buffer base))))
4186 (switch-to-buffer buffer)
4188 ;; We do it this way to make `normal-mode' set the appropriate mode.
4191 (setq buffer-file-name (expand-file-name base))
4192 (gnus-mime-jka-compr-maybe-uncompress)
4194 (setq buffer-file-name nil))
4195 (goto-char (point-min)))))
4197 (defun gnus-mime-print-part (&optional handle filename)
4198 "Print the MIME part under point."
4199 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4200 (gnus-article-check-buffer)
4201 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4202 (contents (and handle (mm-get-part handle)))
4203 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4204 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4209 (mm-save-part-to-file handle file)
4210 (call-process shell-file-name nil
4211 (generate-new-buffer " *mm*")
4213 shell-command-switch
4215 printer file (mm-handle-type handle))))
4219 (gnus-print-buffer))
4220 (ps-despool filename)))))
4222 (defun gnus-mime-inline-part (&optional handle arg)
4223 "Insert the MIME part under point into the current buffer."
4224 (interactive (list nil current-prefix-arg))
4225 (gnus-article-check-buffer)
4226 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4231 (if (and (not arg) (mm-handle-undisplayer handle))
4232 (mm-remove-part handle)
4233 (setq contents (mm-get-part handle))
4236 (setq charset (or (mail-content-type-get
4237 (mm-handle-type handle) 'charset)
4238 gnus-newsgroup-charset)))
4240 (if (mm-handle-undisplayer handle)
4241 (mm-remove-part handle))
4244 gnus-summary-show-article-charset-alist))
4245 (mm-read-coding-system "Charset: ")))))
4247 (mm-insert-inline handle
4249 (setq charset (mm-charset-to-coding-system
4251 (not (eq charset 'ascii)))
4252 (mm-decode-coding-string contents charset)
4256 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4257 "Insert the MIME part under point into the current buffer using the
4259 (interactive (list nil current-prefix-arg))
4260 (gnus-article-check-buffer)
4261 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4266 (if (mm-handle-undisplayer handle)
4267 (mm-remove-part handle))
4268 (let ((gnus-newsgroup-charset
4270 gnus-summary-show-article-charset-alist))
4271 (mm-read-coding-system "Charset: ")))
4272 (gnus-newsgroup-ignored-charsets 'gnus-all))
4273 (gnus-article-press-button)))))
4275 (defun gnus-mime-view-part-externally (&optional handle)
4276 "View the MIME part under point with an external viewer."
4278 (gnus-article-check-buffer)
4279 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4280 (mm-user-display-methods nil)
4281 (mm-inlined-types nil)
4282 (mail-parse-charset gnus-newsgroup-charset)
4283 (mail-parse-ignored-charsets
4284 (save-excursion (set-buffer gnus-summary-buffer)
4285 gnus-newsgroup-ignored-charsets)))
4287 (if (mm-handle-undisplayer handle)
4288 (mm-remove-part handle)
4289 (mm-display-part handle)))))
4291 (defun gnus-mime-view-part-internally (&optional handle)
4292 "View the MIME part under point with an internal viewer.
4293 If no internal viewer is available, use an external viewer."
4295 (gnus-article-check-buffer)
4296 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4297 (mm-inlined-types '(".*"))
4298 (mm-inline-large-images t)
4299 (mail-parse-charset gnus-newsgroup-charset)
4300 (mail-parse-ignored-charsets
4301 (save-excursion (set-buffer gnus-summary-buffer)
4302 gnus-newsgroup-ignored-charsets))
4305 (if (mm-handle-undisplayer handle)
4306 (mm-remove-part handle)
4307 (mm-display-part handle)))))
4309 (defun gnus-mime-action-on-part (&optional action)
4310 "Do something with the MIME attachment at \(point\)."
4312 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4313 (gnus-article-check-buffer)
4314 (let ((action-pair (assoc action gnus-mime-action-alist)))
4316 (funcall (cdr action-pair)))))
4318 (defun gnus-article-part-wrapper (n function)
4319 (save-current-buffer
4320 (set-buffer gnus-article-buffer)
4321 (when (> n (length gnus-article-mime-handle-alist))
4322 (error "No such part"))
4323 (gnus-article-goto-part n)
4324 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4325 (funcall function handle))))
4327 (defun gnus-article-pipe-part (n)
4328 "Pipe MIME part N, which is the numerical prefix."
4330 (gnus-article-part-wrapper n 'mm-pipe-part))
4332 (defun gnus-article-save-part (n)
4333 "Save MIME part N, which is the numerical prefix."
4335 (gnus-article-part-wrapper n 'mm-save-part))
4337 (defun gnus-article-interactively-view-part (n)
4338 "View MIME part N interactively, which is the numerical prefix."
4340 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4342 (defun gnus-article-copy-part (n)
4343 "Copy MIME part N, which is the numerical prefix."
4345 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4347 (defun gnus-article-view-part-as-charset (n)
4348 "View MIME part N using a specified charset.
4349 N is the numerical prefix."
4351 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4353 (defun gnus-article-view-part-externally (n)
4354 "View MIME part N externally, which is the numerical prefix."
4356 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4358 (defun gnus-article-inline-part (n)
4359 "Inline MIME part N, which is the numerical prefix."
4361 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4363 (defun gnus-article-mime-match-handle-first (condition)
4365 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4366 (while (setq ihandle (pop alist))
4368 ((functionp condition)
4369 (funcall condition (cdr ihandle)))
4370 ((eq condition 'undisplayed)
4371 (not (or (mm-handle-undisplayer (cdr ihandle))
4372 (equal (mm-handle-media-type (cdr ihandle))
4373 "multipart/alternative"))))
4374 ((eq condition 'undisplayed-alternative)
4375 (not (mm-handle-undisplayer (cdr ihandle))))
4377 (gnus-article-goto-part (car ihandle))
4378 (or (not n) (< (car ihandle) n)))
4379 (setq n (car ihandle))))
4383 (defun gnus-article-view-part (&optional n)
4384 "View MIME part N, which is the numerical prefix."
4386 (save-current-buffer
4387 (set-buffer gnus-article-buffer)
4388 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4389 gnus-article-mime-match-handle-function)))
4390 (when (> n (length gnus-article-mime-handle-alist))
4391 (error "No such part"))
4392 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4393 (when (gnus-article-goto-part n)
4394 (if (equal (car handle) "multipart/alternative")
4395 (gnus-article-press-button)
4396 (when (eq (gnus-mm-display-part handle) 'internal)
4397 (gnus-set-window-start)))))))
4399 (defsubst gnus-article-mime-total-parts ()
4400 (if (bufferp (car gnus-article-mime-handles))
4402 (1- (length gnus-article-mime-handles))))
4404 (defun gnus-mm-display-part (handle)
4405 "Display HANDLE and fix MIME button."
4406 (let ((id (get-text-property (point) 'gnus-part))
4411 (let ((window (selected-window))
4412 (mail-parse-charset gnus-newsgroup-charset)
4413 (mail-parse-ignored-charsets
4414 (if (gnus-buffer-live-p gnus-summary-buffer)
4416 (set-buffer gnus-summary-buffer)
4417 gnus-newsgroup-ignored-charsets)
4421 (let ((win (gnus-get-buffer-window (current-buffer) t))
4424 (select-window win))
4427 (if (mm-handle-displayed-p handle)
4428 ;; This will remove the part.
4429 (mm-display-part handle)
4431 (narrow-to-region (point)
4432 (if (eobp) (point) (1+ (point))))
4433 (mm-display-part handle)
4434 ;; We narrow to the part itself and
4435 ;; then call the treatment functions.
4436 (goto-char (point-min))
4438 (narrow-to-region (point) (point-max))
4441 (gnus-article-mime-total-parts)
4442 (mm-handle-media-type handle)))))
4443 (if (window-live-p window)
4444 (select-window window)))))
4447 (gnus-insert-mime-button
4448 handle id (list (mm-handle-displayed-p handle)))
4449 (goto-char point))))
4451 (defun gnus-article-goto-part (n)
4452 "Go to MIME part N."
4453 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4455 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4456 (let ((gnus-tmp-name
4457 (or (mail-content-type-get (mm-handle-type handle) 'name)
4458 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4459 (mail-content-type-get (mm-handle-type handle) 'url)
4461 (gnus-tmp-type (mm-handle-media-type handle))
4462 (gnus-tmp-description
4463 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4466 (if (if displayed (car displayed)
4467 (mm-handle-displayed-p handle))
4469 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4471 gnus-tmp-type-long b e)
4472 (when (string-match ".*/" gnus-tmp-name)
4473 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4474 (setq gnus-tmp-type-long (concat gnus-tmp-type
4475 (and (not (equal gnus-tmp-name ""))
4476 (concat "; " gnus-tmp-name))))
4477 (unless (equal gnus-tmp-description "")
4478 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4483 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4484 `(keymap ,gnus-mime-button-map
4485 gnus-callback gnus-mm-display-part
4486 gnus-part ,gnus-tmp-id
4487 article-type annotation
4490 ;; Exclude a newline.
4493 (widget-convert-button
4496 :action 'gnus-widget-press-button
4497 :button-keymap gnus-mime-button-map
4499 (lambda (widget/window &optional overlay pos)
4500 ;; Needed to properly clear the message due to a bug in
4501 ;; wid-edit (XEmacs only).
4502 (if (boundp 'help-echo-owns-message)
4503 (setq help-echo-owns-message t))
4505 "%S: %s the MIME part; %S: more options"
4506 (aref gnus-mouse-2 0)
4507 ;; XEmacs will get a single widget arg; Emacs 21 will get
4508 ;; window, overlay, position.
4509 (if (mm-handle-displayed-p
4511 (with-current-buffer (gnus-overlay-buffer overlay)
4512 (widget-get (widget-at (gnus-overlay-start overlay))
4514 (widget-get widget/window :mime-handle)))
4516 (aref gnus-down-mouse-3 0))))))
4518 (defun gnus-widget-press-button (elems el)
4519 (goto-char (widget-get elems :from))
4520 (gnus-article-press-button))
4522 (defvar gnus-displaying-mime nil)
4524 (defun gnus-display-mime (&optional ihandles)
4525 "Display the MIME parts."
4527 (save-selected-window
4528 (let ((window (get-buffer-window gnus-article-buffer))
4531 (select-window window)
4532 ;; We have to do this since selecting the window
4533 ;; may change the point. So we set the window point.
4534 (set-window-point window point)))
4535 (let* ((handles (or ihandles
4536 (mm-dissect-buffer nil gnus-article-loose-mime)
4537 (and gnus-article-emulate-mime
4539 buffer-read-only handle name type b e display)
4540 (when (and (not ihandles)
4541 (not gnus-displaying-mime))
4542 ;; Top-level call; we clean up.
4543 (when gnus-article-mime-handles
4544 (mm-destroy-parts gnus-article-mime-handles)
4545 (setq gnus-article-mime-handle-alist nil));; A trick.
4546 (setq gnus-article-mime-handles handles)
4547 ;; We allow users to glean info from the handles.
4548 (when gnus-article-mime-part-function
4549 (gnus-mime-part-function handles)))
4551 (or (not (stringp (car handles)))
4554 (when (and (not ihandles)
4555 (not gnus-displaying-mime))
4556 ;; Clean up for mime parts.
4558 (delete-region (point) (point-max)))
4559 (let ((gnus-displaying-mime t))
4560 (gnus-mime-display-part handles)))
4563 (narrow-to-region (point) (point-max))
4564 (gnus-treat-article nil 1 1)
4567 ;; Highlight the headers.
4571 (narrow-to-region (point-min) (point))
4572 (gnus-treat-article 'head))))))))
4574 (defcustom gnus-mime-display-multipart-as-mixed nil
4575 "Display \"multipart\" parts as \"multipart/mixed\".
4577 If t, it overrides nil values of
4578 `gnus-mime-display-multipart-alternative-as-mixed' and
4579 `gnus-mime-display-multipart-related-as-mixed'."
4580 :group 'gnus-article-mime
4583 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4584 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4585 :group 'gnus-article-mime
4588 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4589 "Display \"multipart/related\" parts as \"multipart/mixed\".
4591 If displaying \"text/html\" is discouraged \(see
4592 `mm-discouraged-alternatives'\) images or other material inside a
4593 \"multipart/related\" part might be overlooked when this variable is nil."
4594 :group 'gnus-article-mime
4597 (defun gnus-mime-display-part (handle)
4600 ((not (stringp (car handle)))
4601 (gnus-mime-display-single handle))
4602 ;; User-defined multipart
4603 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4604 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4606 ;; multipart/alternative
4607 ((and (equal (car handle) "multipart/alternative")
4608 (not (or gnus-mime-display-multipart-as-mixed
4609 gnus-mime-display-multipart-alternative-as-mixed)))
4610 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4611 (push (cons id handle) gnus-article-mime-handle-alist)
4612 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4613 ;; multipart/related
4614 ((and (equal (car handle) "multipart/related")
4615 (not (or gnus-mime-display-multipart-as-mixed
4616 gnus-mime-display-multipart-related-as-mixed)))
4617 ;;;!!!We should find the start part, but we just default
4618 ;;;!!!to the first part.
4619 ;;(gnus-mime-display-part (cadr handle))
4620 ;;;!!! Most multipart/related is an HTML message plus images.
4621 ;;;!!! Unfortunately we are unable to let W3 display those
4622 ;;;!!! included images, so we just display it as a mixed multipart.
4623 ;;(gnus-mime-display-mixed (cdr handle))
4624 ;;;!!! No, w3 can display everything just fine.
4625 (gnus-mime-display-part (cadr handle)))
4626 ((equal (car handle) "multipart/signed")
4627 (gnus-add-wash-type 'signed)
4628 (gnus-mime-display-security handle))
4629 ((equal (car handle) "multipart/encrypted")
4630 (gnus-add-wash-type 'encrypted)
4631 (gnus-mime-display-security handle))
4632 ;; Other multiparts are handled like multipart/mixed.
4634 (gnus-mime-display-mixed (cdr handle)))))
4636 (defun gnus-mime-part-function (handles)
4637 (if (stringp (car handles))
4638 (mapcar 'gnus-mime-part-function (cdr handles))
4639 (funcall gnus-article-mime-part-function handles)))
4641 (defun gnus-mime-display-mixed (handles)
4642 (mapcar 'gnus-mime-display-part handles))
4644 (defun gnus-mime-display-single (handle)
4645 (let ((type (mm-handle-media-type handle))
4646 (ignored gnus-ignored-mime-types)
4653 (when (string-match (pop ignored) type)
4654 (throw 'ignored nil)))
4655 (if (and (setq not-attachment
4656 (and (not (mm-inline-override-p handle))
4657 (or (not (mm-handle-disposition handle))
4658 (equal (car (mm-handle-disposition handle))
4660 (mm-attachment-override-p handle))))
4661 (mm-automatic-display-p handle)
4663 (mm-inlinable-p handle)
4664 (mm-inlined-p handle))
4665 (mm-automatic-external-display-p type)))
4667 (when (equal (mm-handle-media-supertype handle) "text")
4669 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4671 (push (cons id handle) gnus-article-mime-handle-alist)
4672 (when (or (not display)
4673 (not (gnus-unbuttonized-mime-type-p type)))
4674 ;(gnus-article-insert-newline)
4675 (gnus-insert-mime-button
4676 handle id (list (or display (and not-attachment text))))
4677 (gnus-article-insert-newline)
4678 ;(gnus-article-insert-newline)
4679 ;; Remember modify the number of forward lines.
4687 (let ((mail-parse-charset gnus-newsgroup-charset)
4688 (mail-parse-ignored-charsets
4689 (save-excursion (condition-case ()
4690 (set-buffer gnus-summary-buffer)
4692 gnus-newsgroup-ignored-charsets)))
4693 (mm-display-part handle t))
4694 (goto-char (point-max)))
4695 ((and text not-attachment)
4699 (gnus-article-insert-newline)
4700 (mm-insert-inline handle (mm-get-part handle))
4701 (goto-char (point-max))))
4705 (narrow-to-region beg (point))
4708 (gnus-article-mime-total-parts)
4709 (mm-handle-media-type handle)))))))))
4711 (defun gnus-unbuttonized-mime-type-p (type)
4712 "Say whether TYPE is to be unbuttonized."
4713 (unless gnus-inhibit-mime-unbuttonizing
4715 (let ((types gnus-unbuttonized-mime-types))
4717 (when (string-match (pop types) type)
4718 (throw 'found t)))))
4720 (let ((types gnus-buttonized-mime-types))
4722 (when (string-match (pop types) type)
4723 (throw 'found t)))))))))
4725 (defun gnus-article-insert-newline ()
4726 "Insert a newline, but mark it as undeletable."
4727 (gnus-put-text-property
4728 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4730 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4731 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4734 handle buffer-read-only from props begend not-pref)
4735 (save-window-excursion
4738 (narrow-to-region (car ibegend)
4741 (goto-char (car ibegend))
4744 (delete-region (point-min) (point-max))
4745 (mm-remove-parts handles))
4746 (setq begend (list (point-marker)))
4748 (unless (setq not-pref (cadr (member preferred ihandles)))
4749 (setq not-pref (car ihandles)))
4752 (not (gnus-unbuttonized-mime-type-p
4753 "multipart/alternative")))
4754 (gnus-add-text-properties
4757 (insert (format "%d. " id))
4761 (unless ,(not ibegend)
4762 (setq gnus-article-mime-handle-alist
4763 ',gnus-article-mime-handle-alist))
4764 (gnus-mime-display-alternative
4765 ',ihandles ',not-pref ',begend ,id))
4766 keymap ,gnus-mime-button-map
4767 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4768 face ,gnus-article-button-face
4771 (widget-convert-button 'link from (point)
4772 :action 'gnus-widget-press-button
4773 :button-keymap gnus-widget-button-keymap)
4775 (while (setq handle (pop handles))
4776 (gnus-add-text-properties
4779 (insert (format "(%c) %-18s"
4780 (if (equal handle preferred) ?* ? )
4781 (mm-handle-media-type handle)))
4785 (unless ,(not ibegend)
4786 (setq gnus-article-mime-handle-alist
4787 ',gnus-article-mime-handle-alist))
4788 (gnus-mime-display-alternative
4789 ',ihandles ',handle ',begend ,id))
4790 keymap ,gnus-mime-button-map
4791 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4792 face ,gnus-article-button-face
4795 (widget-convert-button 'link from (point)
4796 :action 'gnus-widget-press-button
4797 :button-keymap gnus-widget-button-keymap)
4801 (if (stringp (car preferred))
4802 (gnus-display-mime preferred)
4803 (let ((mail-parse-charset gnus-newsgroup-charset)
4804 (mail-parse-ignored-charsets
4805 (save-excursion (set-buffer gnus-summary-buffer)
4806 gnus-newsgroup-ignored-charsets)))
4807 (mm-display-part preferred)
4811 (narrow-to-region (car begend) (point-max))
4813 nil (length gnus-article-mime-handle-alist)
4814 (gnus-article-mime-total-parts)
4815 (mm-handle-media-type handle))))))
4816 (goto-char (point-max))
4817 (setcdr begend (point-marker)))))
4819 (goto-char point))))
4821 (defconst gnus-article-wash-status-strings
4822 (let ((alist '((cite "c" "Possible hidden citation text"
4823 " " "All citation text visible")
4824 (headers "h" "Hidden headers"
4825 " " "All headers visible.")
4826 (pgp "p" "Encrypted or signed message status hidden"
4827 " " "No hidden encryption nor digital signature status")
4828 (signature "s" "Signature has been hidden"
4829 " " "Signature is visible")
4830 (overstrike "o" "Overstrike (^H) characters applied"
4831 " " "No overstrike characters applied")
4832 (emphasis "e" "/*_Emphasis_*/ characters applied"
4833 " " "No /*_emphasis_*/ characters applied")))
4835 (dolist (entry alist result)
4836 (let ((key (nth 0 entry))
4837 (on (copy-sequence (nth 1 entry)))
4838 (on-help (nth 2 entry))
4839 (off (copy-sequence (nth 3 entry)))
4840 (off-help (nth 4 entry)))
4841 (put-text-property 0 1 'help-echo on-help on)
4842 (put-text-property 0 1 'help-echo off-help off)
4843 (push (list key on off) result))))
4844 "Alist of strings describing wash status in the mode line.
4845 Each entry has the form (KEY ON OF), where the KEY is a symbol
4846 representing the particular washing function, ON is the string to use
4847 in the article mode line when the washing function is active, and OFF
4848 is the string to use when it is inactive.")
4850 (defun gnus-article-wash-status-entry (key value)
4851 (let ((entry (assoc key gnus-article-wash-status-strings)))
4852 (if value (nth 1 entry) (nth 2 entry))))
4854 (defun gnus-article-wash-status ()
4855 "Return a string which display status of article washing."
4857 (set-buffer gnus-article-buffer)
4858 (let ((cite (memq 'cite gnus-article-wash-types))
4859 (headers (memq 'headers gnus-article-wash-types))
4860 (boring (memq 'boring-headers gnus-article-wash-types))
4861 (pgp (memq 'pgp gnus-article-wash-types))
4862 (pem (memq 'pem gnus-article-wash-types))
4863 (signed (memq 'signed gnus-article-wash-types))
4864 (encrypted (memq 'encrypted gnus-article-wash-types))
4865 (signature (memq 'signature gnus-article-wash-types))
4866 (overstrike (memq 'overstrike gnus-article-wash-types))
4867 (emphasis (memq 'emphasis gnus-article-wash-types)))
4869 (gnus-article-wash-status-entry 'cite cite)
4870 (gnus-article-wash-status-entry 'headers (or headers boring))
4871 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4872 (gnus-article-wash-status-entry 'signature signature)
4873 (gnus-article-wash-status-entry 'overstrike overstrike)
4874 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4876 (defun gnus-add-wash-type (type)
4877 "Add a washing of TYPE to the current status."
4878 (add-to-list 'gnus-article-wash-types type))
4880 (defun gnus-delete-wash-type (type)
4881 "Add a washing of TYPE to the current status."
4882 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4884 (defun gnus-add-image (category image)
4885 "Add IMAGE of CATEGORY to the list of displayed images."
4886 (let ((entry (assq category gnus-article-image-alist)))
4888 (setq entry (list category))
4889 (push entry gnus-article-image-alist))
4890 (nconc entry (list image))))
4892 (defun gnus-delete-images (category)
4893 "Delete all images in CATEGORY."
4894 (let ((entry (assq category gnus-article-image-alist)))
4895 (dolist (image (cdr entry))
4896 (gnus-remove-image image category))
4897 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4898 (gnus-delete-wash-type category)))
4900 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4902 (defun gnus-article-maybe-hide-headers ()
4903 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4904 Provided for backwards compatibility."
4905 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4906 (not (save-excursion (set-buffer gnus-summary-buffer)
4907 gnus-have-all-headers)))
4908 (not gnus-inhibit-hiding))
4909 (gnus-article-hide-headers)))
4913 (defun gnus-output-to-file (file-name)
4914 "Append the current article to a file named FILE-NAME."
4915 (let ((artbuf (current-buffer)))
4917 (insert-buffer-substring artbuf)
4918 ;; Append newline at end of the buffer as separator, and then
4920 (goto-char (point-max))
4922 (let ((file-name-coding-system nnmail-pathname-coding-system))
4923 (mm-append-to-file (point-min) (point-max) file-name))
4926 (defun gnus-narrow-to-page (&optional arg)
4927 "Narrow the article buffer to a page.
4928 If given a numerical ARG, move forward ARG pages."
4930 (setq arg (if arg (prefix-numeric-value arg) 0))
4932 (set-buffer gnus-article-buffer)
4933 (goto-char (point-min))
4935 ;; Remove any old next/prev buttons.
4936 (when (gnus-visual-p 'page-marker)
4937 (let ((buffer-read-only nil))
4938 (gnus-remove-text-with-property 'gnus-prev)
4939 (gnus-remove-text-with-property 'gnus-next)))
4942 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4944 (re-search-forward page-delimiter nil 'move arg)))
4945 (goto-char (match-end 0))
4947 (goto-char (point-min))
4948 (setq gnus-page-broken
4949 (and (re-search-forward page-delimiter nil t) t))))
4950 (when gnus-page-broken
4953 (if (re-search-forward page-delimiter nil 'move)
4956 (when (and (gnus-visual-p 'page-marker)
4957 (not (= (point-min) 1)))
4959 (goto-char (point-min))
4960 (gnus-insert-prev-page-button)))
4961 (when (and (gnus-visual-p 'page-marker)
4962 (< (+ (point-max) 2) (buffer-size)))
4964 (goto-char (point-max))
4965 (gnus-insert-next-page-button))))))
4967 ;; Article mode commands
4969 (defun gnus-article-goto-next-page ()
4970 "Show the next page of the article."
4972 (when (gnus-article-next-page)
4973 (goto-char (point-min))
4974 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4977 (defun gnus-article-goto-prev-page ()
4978 "Show the previous page of the article."
4981 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4982 (gnus-article-prev-page nil)))
4984 ;; This is cleaner but currently breaks `gnus-pick-mode':
4986 ;; (defun gnus-article-goto-next-page ()
4987 ;; "Show the next page of the article."
4989 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
4990 ;; (gnus-summary-next-page)))
4992 ;; (defun gnus-article-goto-prev-page ()
4993 ;; "Show the next page of the article."
4995 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
4996 ;; (gnus-summary-prev-page)))
4998 (defun gnus-article-next-page (&optional lines)
4999 "Show the next page of the current article.
5000 If end of article, return non-nil. Otherwise return nil.
5001 Argument LINES specifies lines to be scrolled up."
5003 (move-to-window-line -1)
5006 (and (pos-visible-in-window-p) ;Not continuation line.
5007 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5008 ;; Nothing in this page.
5009 (if (or (not gnus-page-broken)
5013 (eobp)))) ;Real end-of-buffer?
5015 (when gnus-article-over-scroll
5016 (gnus-article-next-page-1 lines))
5018 (gnus-narrow-to-page 1) ;Go to next page.
5020 ;; More in this page.
5021 (gnus-article-next-page-1 lines)
5024 (defun gnus-article-next-page-1 (lines)
5025 (let ((scroll-in-place nil))
5029 ;; Long lines may cause an end-of-buffer error.
5030 (goto-char (point-max)))))
5031 (move-to-window-line 0))
5033 (defun gnus-article-prev-page (&optional lines)
5034 "Show previous page of current article.
5035 Argument LINES specifies lines to be scrolled down."
5037 (move-to-window-line 0)
5038 (if (and gnus-page-broken
5040 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5042 (gnus-narrow-to-page -1) ;Go to previous page.
5043 (goto-char (point-max))
5045 (let ((scroll-in-place nil))
5049 (beginning-of-buffer
5050 (goto-char (point-min))))
5051 (move-to-window-line 0)))))
5053 (defun gnus-article-only-boring-p ()
5054 "Decide whether there is only boring text remaining in the article.
5055 Something \"interesting\" is a word of at least two letters that does
5056 not have a face in `gnus-article-boring-faces'."
5057 (when (and gnus-article-skip-boring
5058 (boundp 'gnus-article-boring-faces)
5059 (symbol-value 'gnus-article-boring-faces))
5062 (while (re-search-forward "\\b\\w\\w" nil t)
5064 (when (not (gnus-intersection
5065 (gnus-faces-at (point))
5066 (symbol-value 'gnus-article-boring-faces)))
5067 (throw 'only-boring nil)))
5068 (throw 'only-boring t)))))
5070 (defun gnus-article-refer-article ()
5071 "Read article specified by message-id around point."
5074 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5075 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5076 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5077 (let ((msg-id (concat "<" (match-string 0) ">")))
5078 (set-buffer gnus-summary-buffer)
5079 (gnus-summary-refer-article msg-id))
5080 (error "No references around point"))))
5082 (defun gnus-article-show-summary ()
5083 "Reconfigure windows to show summary buffer."
5085 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5086 (error "There is no summary buffer for this article buffer")
5087 (gnus-article-set-globals)
5088 (gnus-configure-windows 'article)
5089 (gnus-summary-goto-subject gnus-current-article)
5090 (gnus-summary-position-point)))
5092 (defun gnus-article-describe-briefly ()
5093 "Describe article mode commands briefly."
5095 (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")))
5097 (defun gnus-article-summary-command ()
5098 "Execute the last keystroke in the summary buffer."
5100 (let ((obuf (current-buffer))
5101 (owin (current-window-configuration))
5103 (switch-to-buffer gnus-article-current-summary 'norecord)
5104 (setq func (lookup-key (current-local-map) (this-command-keys)))
5105 (call-interactively func)
5107 (set-window-configuration owin)
5108 (set-window-point (get-buffer-window (current-buffer)) (point))))
5110 (defun gnus-article-summary-command-nosave ()
5111 "Execute the last keystroke in the summary buffer."
5114 (pop-to-buffer gnus-article-current-summary 'norecord)
5115 (setq func (lookup-key (current-local-map) (this-command-keys)))
5116 (call-interactively func)))
5118 (defun gnus-article-check-buffer ()
5119 "Beep if not in an article buffer."
5120 (unless (equal major-mode 'gnus-article-mode)
5121 (error "Command invoked outside of a Gnus article buffer")))
5123 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5124 "Read a summary buffer key sequence and execute it from the article buffer."
5126 (gnus-article-check-buffer)
5128 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5129 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5130 "=" "^" "\M-^" "|"))
5136 '("n" "Gn" "p" "Gp"))
5139 (set-buffer gnus-article-current-summary)
5140 (let (gnus-pick-mode)
5141 (push (or key last-command-event) unread-command-events)
5142 (setq keys (if (featurep 'xemacs)
5143 (events-to-keys (read-key-sequence nil))
5144 (read-key-sequence nil)))))
5148 (if (or (member keys nosaves)
5149 (member keys nosave-but-article)
5150 (member keys nosave-in-article))
5152 (save-window-excursion
5153 (pop-to-buffer gnus-article-current-summary 'norecord)
5154 ;; We disable the pick minor mode commands.
5155 (let (gnus-pick-mode)
5156 (setq func (lookup-key (current-local-map) keys))))
5160 (unless (member keys nosave-in-article)
5161 (set-buffer gnus-article-current-summary))
5162 (call-interactively func)
5163 (setq new-sum-point (point)))
5164 (when (member keys nosave-but-article)
5165 (pop-to-buffer gnus-article-buffer 'norecord)))
5166 ;; These commands should restore window configuration.
5167 (let ((obuf (current-buffer))
5168 (owin (current-window-configuration))
5170 (summary gnus-article-current-summary)
5171 func in-buffer selected)
5172 (if not-restore-window
5173 (pop-to-buffer summary 'norecord)
5174 (switch-to-buffer summary 'norecord))
5175 (setq in-buffer (current-buffer))
5176 ;; We disable the pick minor mode commands.
5177 (if (and (setq func (let (gnus-pick-mode)
5178 (lookup-key (current-local-map) keys)))
5181 (call-interactively func)
5182 (setq new-sum-point (point))
5183 (when (eq in-buffer (current-buffer))
5184 (setq selected (gnus-summary-select-article))
5186 (unless not-restore-window
5187 (set-window-configuration owin))
5188 (when (eq selected 'old)
5190 (set-window-start (get-buffer-window (current-buffer))
5192 (set-window-point (get-buffer-window (current-buffer))
5194 (let ((win (get-buffer-window gnus-article-current-summary)))
5196 (set-window-point win new-sum-point)))) )
5197 (switch-to-buffer gnus-article-buffer)
5200 (defun gnus-article-describe-key (key)
5201 "Display documentation of the function invoked by KEY. KEY is a string."
5202 (interactive "kDescribe key: ")
5203 (gnus-article-check-buffer)
5204 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5206 (set-buffer gnus-article-current-summary)
5207 (let (gnus-pick-mode)
5208 (if (featurep 'xemacs)
5210 (push (elt key 0) unread-command-events)
5211 (setq key (events-to-keys
5212 (read-key-sequence "Describe key: "))))
5213 (setq unread-command-events
5215 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5216 (string-to-list key)))
5217 (setq key (read-key-sequence "Describe key: "))))
5219 (describe-key key)))
5221 (defun gnus-article-describe-key-briefly (key &optional insert)
5222 "Display documentation of the function invoked by KEY. KEY is a string."
5223 (interactive "kDescribe key: \nP")
5224 (gnus-article-check-buffer)
5225 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5227 (set-buffer gnus-article-current-summary)
5228 (let (gnus-pick-mode)
5229 (if (featurep 'xemacs)
5231 (push (elt key 0) unread-command-events)
5232 (setq key (events-to-keys
5233 (read-key-sequence "Describe key: "))))
5234 (setq unread-command-events
5236 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5237 (string-to-list key)))
5238 (setq key (read-key-sequence "Describe key: "))))
5239 (describe-key-briefly key insert))
5240 (describe-key-briefly key insert)))
5242 (defun gnus-article-reply-with-original (&optional wide)
5243 "Start composing a reply mail to the current message.
5244 The text in the region will be yanked. If the region isn't active,
5245 the entire article will be yanked."
5247 (let ((article (cdr gnus-article-current))
5249 (if (not (gnus-mark-active-p))
5250 (with-current-buffer gnus-summary-buffer
5251 (gnus-summary-reply (list (list article)) wide))
5252 (setq contents (buffer-substring (point) (mark t)))
5253 ;; Deactivate active regions.
5254 (when (and (boundp 'transient-mark-mode)
5255 transient-mark-mode)
5256 (setq mark-active nil))
5257 (with-current-buffer gnus-summary-buffer
5259 (list (list article contents)) wide)))))
5261 (defun gnus-article-followup-with-original ()
5262 "Compose a followup to the current article.
5263 The text in the region will be yanked. If the region isn't active,
5264 the entire article will be yanked."
5266 (let ((article (cdr gnus-article-current))
5268 (if (not (gnus-mark-active-p))
5269 (with-current-buffer gnus-summary-buffer
5270 (gnus-summary-followup (list (list article))))
5271 (setq contents (buffer-substring (point) (mark t)))
5272 ;; Deactivate active regions.
5273 (when (and (boundp 'transient-mark-mode)
5274 transient-mark-mode)
5275 (setq mark-active nil))
5276 (with-current-buffer gnus-summary-buffer
5277 (gnus-summary-followup
5278 (list (list article contents)))))))
5280 (defun gnus-article-hide (&optional arg force)
5281 "Hide all the gruft in the current article.
5282 This means that signatures, cited text and (some) headers will be
5284 If given a prefix, show the hidden text instead."
5285 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5286 (gnus-article-hide-headers arg)
5287 (gnus-article-hide-list-identifiers arg)
5288 (gnus-article-hide-citation-maybe arg force)
5289 (gnus-article-hide-signature arg))
5291 (defun gnus-article-maybe-highlight ()
5292 "Do some article highlighting if article highlighting is requested."
5293 (when (gnus-visual-p 'article-highlight 'highlight)
5294 (gnus-article-highlight-some)))
5296 (defun gnus-check-group-server ()
5297 ;; Make sure the connection to the server is alive.
5298 (unless (gnus-server-opened
5299 (gnus-find-method-for-group gnus-newsgroup-name))
5300 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5301 (gnus-request-group gnus-newsgroup-name t)))
5304 (autoload 'nneething-get-file-name "nneething"))
5306 (defun gnus-request-article-this-buffer (article group)
5307 "Get an article and insert it into this buffer."
5308 (let (do-update-line sparse-header)
5312 (gnus-kill-all-overlays)
5313 (setq group (or group gnus-newsgroup-name))
5315 ;; Using `gnus-request-article' directly will insert the article into
5316 ;; `nntp-server-buffer' - so we'll save some time by not having to
5317 ;; copy it from the server buffer into the article buffer.
5319 ;; We only request an article by message-id when we do not have the
5320 ;; headers for it, so we'll have to get those.
5321 (when (stringp article)
5322 (gnus-read-header article))
5324 ;; If the article number is negative, that means that this article
5325 ;; doesn't belong in this newsgroup (possibly), so we find its
5326 ;; message-id and request it by id instead of number.
5327 (when (and (numberp article)
5329 (get-buffer gnus-summary-buffer)
5330 (gnus-buffer-exists-p gnus-summary-buffer))
5332 (set-buffer gnus-summary-buffer)
5333 (let ((header (gnus-summary-article-header article)))
5336 ((memq article gnus-newsgroup-sparse)
5337 ;; This is a sparse gap article.
5338 (setq do-update-line article)
5339 (setq article (mail-header-id header))
5340 (setq sparse-header (gnus-read-header article))
5341 (setq gnus-newsgroup-sparse
5342 (delq article gnus-newsgroup-sparse)))
5344 ;; It's a real article.
5345 (setq article (mail-header-id header)))
5347 ;; It is an extracted pseudo-article.
5348 (setq article 'pseudo)
5349 (gnus-request-pseudo-article header))))
5351 (let ((method (gnus-find-method-for-group
5352 gnus-newsgroup-name)))
5353 (when (and (eq (car method) 'nneething)
5355 (let ((dir (nneething-get-file-name
5356 (mail-header-id header))))
5357 (when (and (stringp dir)
5358 (file-directory-p dir))
5359 (setq article 'nneething)
5360 (gnus-group-enter-directory dir))))))))
5363 ;; Refuse to select canceled articles.
5364 ((and (numberp article)
5366 (get-buffer gnus-summary-buffer)
5367 (gnus-buffer-exists-p gnus-summary-buffer)
5368 (eq (cdr (save-excursion
5369 (set-buffer gnus-summary-buffer)
5370 (assq article gnus-newsgroup-reads)))
5371 gnus-canceled-mark))
5373 ;; We first check `gnus-original-article-buffer'.
5374 ((and (get-buffer gnus-original-article-buffer)
5377 (set-buffer gnus-original-article-buffer)
5378 (and (equal (car gnus-original-article) group)
5379 (eq (cdr gnus-original-article) article))))
5380 (insert-buffer-substring gnus-original-article-buffer)
5382 ;; Check the backlog.
5383 ((and gnus-keep-backlog
5384 (gnus-backlog-request-article group article (current-buffer)))
5386 ;; Check asynchronous pre-fetch.
5387 ((gnus-async-request-fetched-article group article (current-buffer))
5388 (gnus-async-prefetch-next group article gnus-summary-buffer)
5389 (when (and (numberp article) gnus-keep-backlog)
5390 (gnus-backlog-enter-article group article (current-buffer)))
5393 ((and gnus-use-cache
5395 (gnus-cache-request-article article group))
5397 ;; Check the agent cache.
5398 ((gnus-agent-request-article article group)
5400 ;; Get the article and put into the article buffer.
5401 ((or (stringp article)
5403 (let ((gnus-override-method gnus-override-method)
5404 (methods (and (stringp article)
5405 gnus-refer-article-method))
5406 (backend (car (gnus-find-method-for-group
5407 gnus-newsgroup-name)))
5409 (buffer-read-only nil))
5410 (if (or (not (listp methods))
5411 (and (symbolp (car methods))
5412 (assq (car methods) nnoo-definition-alist)))
5413 (setq methods (list methods)))
5414 (when (and (null gnus-override-method)
5416 (setq gnus-override-method (pop methods)))
5418 (when (eq gnus-override-method 'current)
5419 (setq gnus-override-method
5420 (with-current-buffer gnus-summary-buffer
5421 gnus-current-select-method)))
5423 (gnus-kill-all-overlays)
5424 (let ((gnus-newsgroup-name group))
5425 (gnus-check-group-server))
5427 ((gnus-request-article article group (current-buffer))
5428 (when (numberp article)
5429 (gnus-async-prefetch-next group article
5430 gnus-summary-buffer)
5431 (when gnus-keep-backlog
5432 (gnus-backlog-enter-article
5433 group article (current-buffer))))
5434 (setq result 'article))
5436 (setq gnus-override-method (pop methods)))
5437 ((not (string-match "^400 "
5438 (nnheader-get-report backend)))
5439 ;; If we get 400 server disconnect, reconnect and
5440 ;; retry; otherwise, assume the article has expired.
5441 (setq result 'done))))
5442 (and (eq result 'article) 'article)))
5446 ;; Associate this article with the current summary buffer.
5447 (setq gnus-article-current-summary gnus-summary-buffer)
5449 ;; Take the article from the original article buffer
5450 ;; and place it in the buffer it's supposed to be in.
5451 (when (and (get-buffer gnus-article-buffer)
5452 (equal (buffer-name (current-buffer))
5453 (buffer-name (get-buffer gnus-article-buffer))))
5455 (if (get-buffer gnus-original-article-buffer)
5456 (set-buffer gnus-original-article-buffer)
5457 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5458 (buffer-disable-undo)
5459 (setq major-mode 'gnus-original-article-mode)
5460 (setq buffer-read-only t))
5461 (let (buffer-read-only)
5463 (insert-buffer-substring gnus-article-buffer))
5464 (setq gnus-original-article (cons group article)))
5467 (run-hooks 'gnus-article-decode-hook)
5468 ;; Mark article as decoded or not.
5469 (setq gnus-article-decoded-p gnus-article-decode-hook))
5471 ;; Update sparse articles.
5472 (when (and do-update-line
5473 (or (numberp article)
5475 (let ((buf (current-buffer)))
5476 (set-buffer gnus-summary-buffer)
5477 (gnus-summary-update-article do-update-line sparse-header)
5478 (gnus-summary-goto-subject do-update-line nil t)
5479 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5481 (set-buffer buf))))))
5487 (defcustom gnus-article-edit-mode-hook nil
5488 "Hook run in article edit mode buffers."
5489 :group 'gnus-article-various
5492 (defvar gnus-article-edit-done-function nil)
5494 (defvar gnus-article-edit-mode-map nil)
5495 (defvar gnus-article-edit-mode nil)
5497 ;; Should we be using derived.el for this?
5498 (unless gnus-article-edit-mode-map
5499 (setq gnus-article-edit-mode-map (make-keymap))
5500 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5502 (gnus-define-keys gnus-article-edit-mode-map
5503 "\C-c?" describe-mode
5504 "\C-c\C-c" gnus-article-edit-done
5505 "\C-c\C-k" gnus-article-edit-exit
5506 "\C-c\C-f\C-t" message-goto-to
5507 "\C-c\C-f\C-o" message-goto-from
5508 "\C-c\C-f\C-b" message-goto-bcc
5509 ;;"\C-c\C-f\C-w" message-goto-fcc
5510 "\C-c\C-f\C-c" message-goto-cc
5511 "\C-c\C-f\C-s" message-goto-subject
5512 "\C-c\C-f\C-r" message-goto-reply-to
5513 "\C-c\C-f\C-n" message-goto-newsgroups
5514 "\C-c\C-f\C-d" message-goto-distribution
5515 "\C-c\C-f\C-f" message-goto-followup-to
5516 "\C-c\C-f\C-m" message-goto-mail-followup-to
5517 "\C-c\C-f\C-k" message-goto-keywords
5518 "\C-c\C-f\C-u" message-goto-summary
5519 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5520 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5521 "\C-c\C-b" message-goto-body
5522 "\C-c\C-i" message-goto-signature
5524 "\C-c\C-t" message-insert-to
5525 "\C-c\C-n" message-insert-newsgroups
5526 "\C-c\C-o" message-sort-headers
5527 "\C-c\C-e" message-elide-region
5528 "\C-c\C-v" message-delete-not-region
5529 "\C-c\C-z" message-kill-to-signature
5530 "\M-\r" message-newline-and-reformat
5531 "\C-c\C-a" mml-attach-file
5532 "\C-a" message-beginning-of-line
5534 "\M-;" comment-region)
5536 (gnus-define-keys (gnus-article-edit-wash-map
5537 "\C-c\C-w" gnus-article-edit-mode-map)
5538 "f" gnus-article-edit-full-stops))
5541 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5543 ["Fetch To" message-insert-to t]
5544 ["Fetch Newsgroups" message-insert-newsgroups t]
5546 ["To" message-goto-to t]
5547 ["From" message-goto-from t]
5548 ["Subject" message-goto-subject t]
5549 ["Cc" message-goto-cc t]
5550 ["Reply-To" message-goto-reply-to t]
5551 ["Summary" message-goto-summary t]
5552 ["Keywords" message-goto-keywords t]
5553 ["Newsgroups" message-goto-newsgroups t]
5554 ["Followup-To" message-goto-followup-to t]
5555 ["Mail-Followup-To" message-goto-mail-followup-to t]
5556 ["Distribution" message-goto-distribution t]
5557 ["Body" message-goto-body t]
5558 ["Signature" message-goto-signature t]))
5560 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5561 "Major mode for editing articles.
5562 This is an extended text-mode.
5564 \\{gnus-article-edit-mode-map}"
5565 (make-local-variable 'gnus-article-edit-done-function)
5566 (make-local-variable 'gnus-prev-winconf)
5567 (set (make-local-variable 'font-lock-defaults)
5568 '(message-font-lock-keywords t))
5569 (set (make-local-variable 'mail-header-separator) "")
5570 (set (make-local-variable 'gnus-article-edit-mode) t)
5571 (easy-menu-add message-mode-field-menu message-mode-map)
5573 (setq buffer-read-only nil)
5574 (buffer-enable-undo)
5577 (defun gnus-article-edit (&optional force)
5578 "Edit the current article.
5579 This will have permanent effect only in mail groups.
5580 If FORCE is non-nil, allow editing of articles even in read-only
5583 (when (and (not force)
5584 (gnus-group-read-only-p))
5585 (error "The current newsgroup does not support article editing"))
5586 (gnus-article-date-original)
5587 (gnus-article-edit-article
5589 `(lambda (no-highlight)
5591 (gnus-summary-edit-article-done
5592 ,(or (mail-header-references gnus-current-headers) "")
5593 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5595 (defun gnus-article-edit-article (start-func exit-func)
5596 "Start editing the contents of the current article buffer."
5597 (let ((winconf (current-window-configuration)))
5598 (set-buffer gnus-article-buffer)
5599 (gnus-article-edit-mode)
5600 (funcall start-func)
5601 (set-buffer-modified-p nil)
5602 (gnus-configure-windows 'edit-article)
5603 (setq gnus-article-edit-done-function exit-func)
5604 (setq gnus-prev-winconf winconf)
5605 (gnus-message 6 "C-c C-c to end edits")))
5607 (defun gnus-article-edit-done (&optional arg)
5608 "Update the article edits and exit."
5610 (let ((func gnus-article-edit-done-function)
5611 (buf (current-buffer))
5612 (start (window-start))
5614 (winconf gnus-prev-winconf))
5615 (widen) ;; Widen it in case that users narrowed the buffer.
5618 ;; The cache and backlog have to be flushed somewhat.
5619 (when gnus-keep-backlog
5620 (gnus-backlog-remove-article
5621 (car gnus-article-current) (cdr gnus-article-current)))
5622 ;; Flush original article as well.
5624 (when (get-buffer gnus-original-article-buffer)
5625 (set-buffer gnus-original-article-buffer)
5626 (setq gnus-original-article nil)))
5627 (when gnus-use-cache
5628 (gnus-cache-update-article
5629 (car gnus-article-current) (cdr gnus-article-current)))
5630 ;; We remove all text props from the article buffer.
5631 (kill-all-local-variables)
5632 (set-text-properties (point-min) (point-max) nil)
5634 (set-window-configuration winconf)
5636 (set-window-start (get-buffer-window buf) start)
5637 (set-window-point (get-buffer-window buf) (point)))
5638 (gnus-summary-show-article))
5640 (defun gnus-article-edit-exit ()
5641 "Exit the article editing without updating."
5643 (when (or (not (buffer-modified-p))
5644 (yes-or-no-p "Article modified; kill anyway? "))
5645 (let ((curbuf (current-buffer))
5647 (window-start (window-start)))
5649 (if (gnus-buffer-live-p gnus-original-article-buffer)
5650 (insert-buffer gnus-original-article-buffer))
5651 (let ((winconf gnus-prev-winconf))
5652 (kill-all-local-variables)
5654 (set-window-configuration winconf)
5655 ;; Tippy-toe some to make sure that point remains where it was.
5656 (save-current-buffer
5658 (set-window-start (get-buffer-window (current-buffer)) window-start)
5660 (gnus-summary-show-article)))
5662 (defun gnus-article-edit-full-stops ()
5663 "Interactively repair spacing at end of sentences."
5666 (goto-char (point-min))
5667 (search-forward-regexp "^$" nil t)
5668 (let ((case-fold-search nil))
5669 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5672 ;;; Article highlights
5675 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5677 ;;; Internal Variables:
5679 (defcustom gnus-button-url-regexp
5680 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5681 "\\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:]]\\)"
5682 "\\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\\)\\)")
5683 "Regular expression that matches URLs."
5684 :group 'gnus-article-buttons
5687 (defcustom gnus-button-valid-fqdn-regexp
5688 message-valid-fqdn-regexp
5689 "Regular expression that matches a valid FQDN."
5690 :group 'gnus-article-buttons
5693 (defcustom gnus-button-man-handler 'manual-entry
5694 "Function to use for displaying man pages.
5695 The function must take at least one argument with a string naming the
5697 :type '(choice (function-item :tag "Man" manual-entry)
5698 (function-item :tag "Woman" woman)
5699 (function :tag "Other"))
5700 :group 'gnus-article-buttons)
5702 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5703 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5704 If the default site is too slow, try to find a CTAN mirror, see
5705 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5706 the variable `gnus-button-handle-ctan'."
5707 :group 'gnus-article-buttons
5708 :link '(custom-manual "(gnus)Group Parameters")
5709 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5710 (const "http://tug.ctan.org/tex-archive/")
5711 (const "http://www.dante.de/CTAN/")
5712 (string :tag "Other")))
5714 (defcustom gnus-button-ctan-handler 'browse-url
5715 "Function to use for displaying CTAN links.
5716 The function must take one argument, the string naming the URL."
5717 :type '(choice (function-item :tag "Browse Url" browse-url)
5718 (function :tag "Other"))
5719 :group 'gnus-article-buttons)
5721 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5722 "Bogus strings removed from CTAN URLs."
5723 :group 'gnus-article-buttons
5724 :type '(choice (const "^/?tex-archive/\\|/")
5725 (regexp :tag "Other")))
5727 (defcustom gnus-button-ctan-directory-regexp
5730 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5731 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5732 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5734 "Regular expression for ctan directories.
5735 It should match all directories in the top level of `gnus-ctan-url'."
5736 :group 'gnus-article-buttons
5739 (defcustom gnus-button-mid-or-mail-regexp
5740 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
5741 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5742 gnus-button-valid-fqdn-regexp
5744 "Regular expression that matches a message ID or a mail address."
5745 :group 'gnus-article-buttons
5748 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5749 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5750 Strings like this can be either a message ID or a mail address. If it is one
5751 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5752 message ID or a mail address, respectively. If this variable is set to the
5753 symbol `ask', always query the user what do do. If it is a function, this
5754 function will be called with the string as it's only argument. The function
5755 must return `mid', `mail', `invalid' or `ask'."
5756 :group 'gnus-article-buttons
5757 :type '(choice (function-item :tag "Heuristic function"
5758 gnus-button-mid-or-mail-heuristic)
5763 (defcustom gnus-button-mid-or-mail-heuristic-alist
5764 '((-10.0 . ".+\\$.+@")
5767 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5768 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5769 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5770 (-1.0 . "^[^a-z]+@")
5772 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5773 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5774 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5775 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5778 (-1.0 . "^[0-9][0-9]")
5780 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5781 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5782 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5783 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5785 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5786 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5789 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5791 ;; compensation for TDMA dated mail addresses:
5792 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5794 (-20.0 . "\\.fsf@") ;; Gnus
5797 (-20.0 . "_-_") ;; Subject change in thread
5799 (-20.0 . "\\.ln@") ;; leafnode
5800 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5801 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5803 ;; (5.0 . "") ;; $local_part_len <= 7
5804 (10.0 . "^[^0-9]+@")
5805 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5806 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5809 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5811 (0.5 . "^[A-Z][a-z]")
5812 (0.5 . "^[A-Z][a-z][a-z]")
5813 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5814 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5815 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5817 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5818 address. The REGEXP is processed with `case-fold-search' set to nil."
5819 :group 'gnus-article-buttons
5820 :type '(repeat (cons (number :tag "Rate")
5821 (regexp :tag "Regexp"))))
5823 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5824 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5825 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5826 address, `ask' if unsure and `invalid' if the string is invalid."
5827 (let ((case-fold-search nil)
5828 (list gnus-button-mid-or-mail-heuristic-alist)
5829 (result 0) rate regexp lpartlen elem)
5831 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5832 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5833 ;; Certain special cases...
5836 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
5837 "^[0-9]+\\.[0-9]+@compuserve\\|"
5838 "@public\\.gmane\\.org")
5840 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
5841 (setq result 'mail))
5842 (when (string-match "@.*@\\| " mid-or-mail)
5843 (gnus-message 8 "`%s' is invalid." mid-or-mail)
5844 (setq result 'invalid))
5845 ;; Nothing more to do, if result is not a number here...
5846 (when (numberp result)
5848 (setq elem (car list)
5852 (when (string-match regexp mid-or-mail)
5853 (setq result (+ result rate))
5855 9 "`%s' matched `%s', rate `%s', result `%s'."
5856 mid-or-mail regexp rate result)))
5857 (when (<= lpartlen 7)
5858 (setq result (+ result 5.0))
5859 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
5860 mid-or-mail result))
5861 (when (>= lpartlen 12)
5862 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
5864 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
5865 ;; Long local part should contain realname if e-mail address,
5866 ;; too many digits: message-id.
5867 ;; $score -= 5.0 + 0.1 * $local_part_len;
5868 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
5869 (setq result (+ result rate))
5871 9 "Many digits in `%s', rate `%s', result `%s'."
5872 mid-or-mail rate result))
5873 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
5875 ;; Too few vowels [^aeiouy]{4,}.*\@
5876 (setq result (+ result -5.0))
5878 9 "Few vowels in `%s', rate `%s', result `%s'."
5879 mid-or-mail -5.0 result))
5881 (setq result (+ result 5.0))
5883 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
5884 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
5885 ;; Maybe we should make this a customizable alist: (condition . 'result)
5887 ((symbolp result) result)
5888 ;; Now convert number into proper results:
5889 ((< result -10.0) 'mid)
5890 ((> result 10.0) 'mail)
5893 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5894 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
5895 (url-mid (concat "news" ":" mid-or-mail))
5896 (url-mailto (concat "mailto" ":" mid-or-mail)))
5897 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5898 (when (fboundp pref)
5900 ;; get rid of surrounding angles...
5902 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
5903 (if (or (eq 'mid guessed) (eq 'mail guessed))
5907 (save-window-excursion
5908 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5911 (cond ((eq pref 'mid)
5912 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
5913 (gnus-button-handle-news url-mid))
5915 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
5916 (gnus-url-mailto url-mailto))
5917 (t (gnus-message 3 "Invalid string.")))))
5919 (defun gnus-button-handle-custom (url)
5920 "Follow a Custom URL."
5921 (customize-apropos (gnus-url-unhex-string url)))
5923 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5925 ;; FIXME: Maybe we should merge some of the functions that do quite similar
5928 (defun gnus-button-handle-describe-function (url)
5929 "Call `describe-function' when pushing the corresponding URL button."
5932 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5934 (defun gnus-button-handle-describe-variable (url)
5935 "Call `describe-variable' when pushing the corresponding URL button."
5938 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5940 (defun gnus-button-handle-symbol (url)
5941 "Display help on variable or function.
5942 Calls `describe-variable' or `describe-function'."
5943 (let ((sym (intern url)))
5945 ((fboundp sym) (describe-function sym))
5946 ((boundp sym) (describe-variable sym))
5947 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
5949 (defun gnus-button-handle-describe-key (url)
5950 "Call `describe-key' when pushing the corresponding URL button."
5952 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5953 (keys (ignore-errors (eval `(kbd ,key-string)))))
5956 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5958 (defun gnus-button-handle-apropos (url)
5959 "Call `apropos' when pushing the corresponding URL button."
5960 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5962 (defun gnus-button-handle-apropos-command (url)
5963 "Call `apropos' when pushing the corresponding URL button."
5965 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5967 (defun gnus-button-handle-apropos-variable (url)
5968 "Call `apropos' when pushing the corresponding URL button."
5970 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5971 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5973 (defun gnus-button-handle-apropos-documentation (url)
5974 "Call `apropos' when pushing the corresponding URL button."
5976 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
5977 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5979 (defun gnus-button-handle-library (url)
5980 "Call `locate-library' when pushing the corresponding URL button."
5981 (gnus-message 9 "url=`%s'" url)
5982 (let* ((lib (locate-library url))
5983 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
5985 (gnus-message 1 "Cannot locale library `%s'." url)
5986 (find-file-read-only file))))
5988 (defun gnus-button-handle-ctan (url)
5989 "Call `browse-url' when pushing a CTAN URL button."
5991 gnus-button-ctan-handler
5994 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
5996 (defcustom gnus-button-tex-level 5
5997 "*Integer that says how many TeX-related buttons Gnus will show.
5998 The higher the number, the more buttons will appear and the more false
5999 positives are possible. Note that you can set this variable local to
6000 specific groups. Setting it higher in TeX groups is probably a good idea.
6001 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6002 how to set variables in specific groups."
6003 :group 'gnus-article-buttons
6004 :link '(custom-manual "(gnus)Group Parameters")
6007 (defcustom gnus-button-man-level 5
6008 "*Integer that says how many man-related buttons Gnus will show.
6009 The higher the number, the more buttons will appear and the more false
6010 positives are possible. Note that you can set this variable local to
6011 specific groups. Setting it higher in Unix groups is probably a good idea.
6012 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6013 how to set variables in specific groups."
6014 :group 'gnus-article-buttons
6015 :link '(custom-manual "(gnus)Group Parameters")
6018 (defcustom gnus-button-emacs-level 5
6019 "*Integer that says how many emacs-related buttons Gnus will show.
6020 The higher the number, the more buttons will appear and the more false
6021 positives are possible. Note that you can set this variable local to
6022 specific groups. Setting it higher in Emacs or Gnus related groups is
6023 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6024 `gnus-parameters' on how to set variables in specific groups."
6025 :group 'gnus-article-buttons
6026 :link '(custom-manual "(gnus)Group Parameters")
6029 (defcustom gnus-button-message-level 5
6030 "*Integer that says how many buttons for news or mail messages will appear.
6031 The higher the number, the more buttons will appear and the more false
6032 positives are possible."
6033 ;; mail addresses, MIDs, URLs for news, ...
6034 :group 'gnus-article-buttons
6037 (defcustom gnus-button-browse-level 5
6038 "*Integer that says how many buttons for browsing will appear.
6039 The higher the number, the more buttons will appear and the more false
6040 positives are possible."
6041 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6042 :group 'gnus-article-buttons
6045 (defcustom gnus-button-alist
6046 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6047 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6048 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6049 gnus-button-handle-news 2)
6050 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6051 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6052 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6053 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6054 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6055 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6056 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6057 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6058 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6059 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6060 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6061 ;; RFC 2368 (The mailto URL scheme)
6062 ("mailto:\\([-a-z.@_+0-9%=?&]+\\)"
6063 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6064 ("\\bmailto:\\([^ \n\t]+\\)"
6065 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6067 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6068 gnus-button-ctan-directory-regexp
6069 "[^][>)!;:,'\n\t ]+\\)")
6070 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6071 ((concat "\\btex-archive/\\("
6072 gnus-button-ctan-directory-regexp
6073 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6074 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6077 gnus-button-ctan-directory-regexp
6078 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6079 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6080 ;; This is info (home-grown style) <info://foo/bar+baz>
6081 ("\\binfo://\\([^'\">\n\t ]+\\)"
6082 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6083 ;; Info GNOME style <info:foo#bar_baz>
6084 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6085 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6086 ;; Info KDE style <info:(foo)bar baz>
6087 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6088 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6089 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6090 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6091 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6092 ;; Info links like `C-h i d m CC Mode RET'
6093 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6095 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6096 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6097 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6098 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6099 ;; Emacs help commands
6100 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6101 ;; regexp doesn't match arguments containing ` '.
6102 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6103 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6104 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6105 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6106 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6107 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6108 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6109 ;; The following entries may lead to many false positives so don't enable
6110 ;; them by default (use a high button level):
6111 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6112 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6113 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6114 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6115 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6116 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6117 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6118 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6119 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6120 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6121 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6122 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6123 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6124 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6125 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6126 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6127 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6128 ;; Unlike the other regexps we really have to require quoting
6129 ;; here to determine where it ends.
6130 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6131 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6132 ("<URL: *\\([^<>]*\\)>"
6133 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6134 ;; RFC 2396 (2.4.3., delims) ...
6135 ("\"URL: *\\([^\"]*\\)\""
6136 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6137 ;; RFC 2396 (2.4.3., delims) ...
6138 ("\"URL: *\\([^\"]*\\)\""
6139 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6141 (gnus-button-url-regexp
6142 0 (>= gnus-button-browse-level 0) browse-url 0)
6144 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6145 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6146 gnus-button-handle-man 1)
6147 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6148 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6149 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6150 gnus-button-handle-man 1)
6151 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6152 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6153 ("\\b\\([a-z][-+_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6154 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6155 ;; MID or mail: To avoid too many false positives we don't try to catch
6156 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6157 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6158 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6159 ;; so that non-ambiguous entries (see above) match first.
6160 (gnus-button-mid-or-mail-regexp
6161 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6162 "*Alist of regexps matching buttons in article bodies.
6164 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6165 REGEXP: is the string (case insensitive) matching text around the button (can
6166 also be Lisp expression evaluating to a string),
6167 BUTTON: is the number of the regexp grouping actually matching the button,
6168 FORM: is a Lisp expression which must eval to true for the button to
6170 CALLBACK: is the function to call when the user push this button, and each
6171 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6173 CALLBACK can also be a variable, in that case the value of that
6174 variable it the real callback function."
6175 :group 'gnus-article-buttons
6176 :type '(repeat (list (choice regexp variable sexp)
6177 (integer :tag "Button")
6179 (function :tag "Callback")
6182 (integer :tag "Regexp group")))))
6184 (defcustom gnus-header-button-alist
6185 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6186 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6187 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6188 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6189 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6190 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6191 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6192 0 (>= gnus-button-browse-level 0) browse-url 0)
6193 ("^Subject:" gnus-button-url-regexp
6194 0 (>= gnus-button-browse-level 0) browse-url 0)
6195 ("^[^:]+:" gnus-button-url-regexp
6196 0 (>= gnus-button-browse-level 0) browse-url 0)
6197 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&]+\\)"
6198 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6199 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6200 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6201 "*Alist of headers and regexps to match buttons in article heads.
6203 This alist is very similar to `gnus-button-alist', except that each
6204 alist has an additional HEADER element first in each entry:
6206 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6208 HEADER is a regexp to match a header. For a fuller explanation, see
6209 `gnus-button-alist'."
6210 :group 'gnus-article-buttons
6211 :group 'gnus-article-headers
6212 :type '(repeat (list (regexp :tag "Header")
6213 (choice regexp variable)
6214 (integer :tag "Button")
6216 (function :tag "Callback")
6219 (integer :tag "Regexp group")))))
6221 (defvar gnus-button-regexp nil)
6222 (defvar gnus-button-marker-list nil)
6223 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6225 (defvar gnus-button-last nil)
6226 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6230 (defun gnus-article-push-button (event)
6231 "Check text under the mouse pointer for a callback function.
6232 If the text under the mouse pointer has a `gnus-callback' property,
6233 call it with the value of the `gnus-data' text property."
6235 (set-buffer (window-buffer (posn-window (event-start event))))
6236 (let* ((pos (posn-point (event-start event)))
6237 (data (get-text-property pos 'gnus-data))
6238 (fun (get-text-property pos 'gnus-callback)))
6241 (funcall fun data))))
6243 (defun gnus-article-press-button ()
6244 "Check text at point for a callback function.
6245 If the text at point has a `gnus-callback' property,
6246 call it with the value of the `gnus-data' text property."
6248 (let ((data (get-text-property (point) 'gnus-data))
6249 (fun (get-text-property (point) 'gnus-callback)))
6251 (funcall fun data))))
6253 (defun gnus-article-highlight (&optional force)
6254 "Highlight current article.
6255 This function calls `gnus-article-highlight-headers',
6256 `gnus-article-highlight-citation',
6257 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6258 do the highlighting. See the documentation for those functions."
6259 (interactive (list 'force))
6260 (gnus-article-highlight-headers)
6261 (gnus-article-highlight-citation force)
6262 (gnus-article-highlight-signature)
6263 (gnus-article-add-buttons force)
6264 (gnus-article-add-buttons-to-head))
6266 (defun gnus-article-highlight-some (&optional force)
6267 "Highlight current article.
6268 This function calls `gnus-article-highlight-headers',
6269 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6270 do the highlighting. See the documentation for those functions."
6271 (interactive (list 'force))
6272 (gnus-article-highlight-headers)
6273 (gnus-article-highlight-signature)
6274 (gnus-article-add-buttons))
6276 (defun gnus-article-highlight-headers ()
6277 "Highlight article headers as specified by `gnus-header-face-alist'."
6280 (set-buffer gnus-article-buffer)
6282 (let ((alist gnus-header-face-alist)
6283 (buffer-read-only nil)
6284 (case-fold-search t)
6285 (inhibit-point-motion-hooks t)
6286 entry regexp header-face field-face from hpoints fpoints)
6287 (article-narrow-to-head)
6288 (while (setq entry (pop alist))
6289 (goto-char (point-min))
6290 (setq regexp (concat "^\\("
6291 (if (string-equal "" (nth 0 entry))
6295 header-face (nth 1 entry)
6296 field-face (nth 2 entry))
6297 (while (and (re-search-forward regexp nil t)
6301 (unless (search-forward ":" nil t)
6303 (when (and header-face
6304 (not (memq (point) hpoints)))
6305 (push (point) hpoints)
6306 (gnus-put-text-property from (point) 'face header-face))
6307 (when (and field-face
6308 (not (memq (setq from (point)) fpoints)))
6310 (if (re-search-forward "^[^ \t]" nil t)
6312 (goto-char (point-max)))
6313 (gnus-put-text-property from (point) 'face field-face))))))))
6315 (defun gnus-article-highlight-signature ()
6316 "Highlight the signature in an article.
6317 It does this by highlighting everything after
6318 `gnus-signature-separator' using `gnus-signature-face'."
6321 (set-buffer gnus-article-buffer)
6322 (let ((buffer-read-only nil)
6323 (inhibit-point-motion-hooks t))
6325 (when (and gnus-signature-face
6326 (gnus-article-narrow-to-signature))
6327 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6328 'face gnus-signature-face)
6330 (gnus-article-search-signature)
6331 (let ((start (match-beginning 0))
6332 (end (set-marker (make-marker) (1+ (match-end 0)))))
6333 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6336 (defun gnus-button-in-region-p (b e prop)
6337 "Say whether PROP exists in the region."
6338 (text-property-not-all b e prop nil))
6340 (defun gnus-article-add-buttons (&optional force)
6341 "Find external references in the article and make buttons of them.
6342 \"External references\" are things like Message-IDs and URLs, as
6343 specified by `gnus-button-alist'."
6344 (interactive (list 'force))
6346 (set-buffer gnus-article-buffer)
6347 (let ((buffer-read-only nil)
6348 (inhibit-point-motion-hooks t)
6349 (case-fold-search t)
6350 (alist gnus-button-alist)
6352 ;; Remove all old markers.
6353 (let (marker entry new-list)
6354 (while (setq marker (pop gnus-button-marker-list))
6355 (if (or (< marker (point-min)) (>= marker (point-max)))
6356 (push marker new-list)
6358 (when (setq entry (gnus-button-entry))
6359 (put-text-property (match-beginning (nth 1 entry))
6360 (match-end (nth 1 entry))
6361 'gnus-callback nil))
6362 (set-marker marker nil)))
6363 (setq gnus-button-marker-list new-list))
6364 ;; We skip the headers.
6367 (while (setq entry (pop alist))
6368 (setq regexp (eval (car entry)))
6370 (while (re-search-forward regexp nil t)
6371 (let* ((start (and entry (match-beginning (nth 1 entry))))
6372 (end (and entry (match-end (nth 1 entry))))
6373 (from (match-beginning 0)))
6374 (when (and (or (eq t (nth 2 entry))
6375 (eval (nth 2 entry)))
6376 (not (gnus-button-in-region-p
6377 start end 'gnus-callback)))
6378 ;; That optional form returned non-nil, so we add the
6380 (gnus-article-add-button
6381 start end 'gnus-button-push
6382 (car (push (set-marker (make-marker) from)
6383 gnus-button-marker-list))))))))))
6385 ;; Add buttons to the head of an article.
6386 (defun gnus-article-add-buttons-to-head ()
6387 "Add buttons to the head of the article."
6390 (set-buffer gnus-article-buffer)
6392 (let ((buffer-read-only nil)
6393 (inhibit-point-motion-hooks t)
6394 (case-fold-search t)
6395 (alist gnus-header-button-alist)
6397 (article-narrow-to-head)
6399 ;; Each alist entry.
6400 (setq entry (car alist)
6402 (goto-char (point-min))
6403 (while (re-search-forward (car entry) nil t)
6404 ;; Each header matching the entry.
6405 (setq beg (match-beginning 0))
6406 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6407 (match-beginning 0))
6410 (while (re-search-forward (eval (nth 1 entry)) end t)
6411 ;; Each match within a header.
6412 (let* ((entry (cdr entry))
6413 (start (match-beginning (nth 1 entry)))
6414 (end (match-end (nth 1 entry)))
6415 (form (nth 2 entry)))
6416 (goto-char (match-end 0))
6418 (gnus-article-add-button
6419 start end (nth 3 entry)
6420 (buffer-substring (match-beginning (nth 4 entry))
6421 (match-end (nth 4 entry)))))))
6422 (goto-char end)))))))
6424 ;;; External functions:
6426 (defun gnus-article-add-button (from to fun &optional data)
6427 "Create a button between FROM and TO with callback FUN and data DATA."
6428 (when gnus-article-button-face
6429 (gnus-overlay-put (gnus-make-overlay from to)
6430 'face gnus-article-button-face))
6431 (gnus-add-text-properties
6433 (nconc (and gnus-article-mouse-face
6434 (list gnus-mouse-face-prop gnus-article-mouse-face))
6435 (list 'gnus-callback fun)
6436 (and data (list 'gnus-data data))))
6437 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6438 :button-keymap gnus-widget-button-keymap))
6440 ;;; Internal functions:
6442 (defun gnus-article-set-globals ()
6444 (set-buffer gnus-summary-buffer)
6445 (gnus-set-global-variables)))
6447 (defun gnus-signature-toggle (end)
6449 (set-buffer gnus-article-buffer)
6450 (let ((buffer-read-only nil)
6451 (inhibit-point-motion-hooks t))
6452 (if (text-property-any end (point-max) 'article-type 'signature)
6454 (gnus-delete-wash-type 'signature)
6455 (gnus-remove-text-properties-when
6456 'article-type 'signature end (point-max)
6457 (cons 'article-type (cons 'signature
6458 gnus-hidden-properties))))
6459 (gnus-add-wash-type 'signature)
6460 (gnus-add-text-properties-when
6461 'article-type nil end (point-max)
6462 (cons 'article-type (cons 'signature
6463 gnus-hidden-properties)))))
6464 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6465 (gnus-set-mode-line 'article))))
6467 (defun gnus-button-entry ()
6468 ;; Return the first entry in `gnus-button-alist' matching this place.
6469 (let ((alist gnus-button-alist)
6472 (setq entry (pop alist))
6473 (if (looking-at (eval (car entry)))
6478 (defun gnus-button-push (marker)
6479 ;; Push button starting at MARKER.
6482 (let* ((entry (gnus-button-entry))
6483 (inhibit-point-motion-hooks t)
6485 (args (mapcar (lambda (group)
6486 (let ((string (match-string group)))
6487 (set-text-properties
6488 0 (length string) nil string)
6495 (fboundp (symbol-value fun)))
6496 (apply (symbol-value fun) args))
6498 (gnus-message 1 "You must define `%S' to use this button"
6499 (cons fun args)))))))
6501 (defun gnus-parse-news-url (url)
6502 (let (scheme server group message-id articles)
6505 (goto-char (point-min))
6506 (when (looking-at "\\([A-Za-z]+\\):")
6507 (setq scheme (match-string 1))
6508 (goto-char (match-end 0)))
6509 (when (looking-at "//\\([^/]+\\)/")
6510 (setq server (match-string 1))
6511 (goto-char (match-end 0)))
6514 ((looking-at "\\(.*@.*\\)")
6515 (setq message-id (match-string 1)))
6516 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6517 (setq group (match-string 1)
6518 articles (split-string (match-string 2) "-")))
6519 ((looking-at "\\([^/]+\\)/?")
6520 (setq group (match-string 1)))
6522 (error "Unknown news URL syntax"))))
6523 (list scheme server group message-id articles)))
6525 (defun gnus-button-handle-news (url)
6527 (destructuring-bind (scheme server group message-id articles)
6528 (gnus-parse-news-url url)
6532 (set-buffer gnus-summary-buffer)
6534 (let ((gnus-refer-article-method (list (list 'nntp server))))
6535 (gnus-summary-refer-article message-id))
6536 (gnus-summary-refer-article message-id))))
6538 (gnus-button-fetch-group url)))))
6540 (defun gnus-button-handle-man (url)
6542 (funcall gnus-button-man-handler url))
6544 (defun gnus-button-handle-info-url (url)
6545 "Fetch an info URL."
6546 (setq url (mm-subst-char-in-string ?+ ?\ url))
6548 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6549 (gnus-info-find-node
6550 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6552 ")" (gnus-url-unhex-string (match-string 2 url)))))
6553 ((string-match "([^)\"]+)[^\"]+" url)
6555 (gnus-replace-in-string
6556 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6557 (gnus-info-find-node url))
6558 (t (error "Can't parse %s" url))))
6560 (defun gnus-button-handle-info-url-gnome (url)
6561 "Fetch GNOME style info URL."
6562 (setq url (mm-subst-char-in-string ?_ ?\ url))
6563 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6564 (gnus-info-find-node
6566 (gnus-url-unhex-string
6567 (match-string 1 url))
6569 (or (gnus-url-unhex-string
6570 (match-string 2 url))
6572 (error "Can't parse %s" url)))
6574 (defun gnus-button-handle-info-url-kde (url)
6575 "Fetch KDE style info URL."
6576 (gnus-info-find-node (gnus-url-unhex-string url)))
6578 (defun gnus-button-handle-info-keystrokes (url)
6579 "Call `info' when pushing the corresponding URL button."
6580 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6585 (defun gnus-button-message-id (message-id)
6588 (set-buffer gnus-summary-buffer)
6589 (gnus-summary-refer-article message-id)))
6591 (defun gnus-button-fetch-group (address)
6592 "Fetch GROUP specified by ADDRESS."
6593 (if (not (string-match "[:/]" address))
6594 ;; This is just a simple group url.
6595 (gnus-group-read-ephemeral-group address gnus-select-method)
6598 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6600 (error "Can't parse %s" address)
6601 (gnus-group-read-ephemeral-group
6602 (match-string 4 address)
6603 `(nntp ,(match-string 1 address)
6604 (nntp-address ,(match-string 1 address))
6605 (nntp-port-number ,(if (match-end 3)
6606 (match-string 3 address)
6609 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6611 (defun gnus-url-parse-query-string (query &optional downcase)
6612 (let (retval pairs cur key val)
6613 (setq pairs (split-string query "&"))
6615 (setq cur (car pairs)
6617 (if (not (string-match "=" cur))
6619 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6620 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6622 (setq key (downcase key)))
6623 (setq cur (assoc key retval))
6625 (setcdr cur (cons val (cdr cur)))
6626 (setq retval (cons (list key val) retval)))))
6629 (defun gnus-url-mailto (url)
6630 ;; Send mail to someone
6631 (when (string-match "mailto:/*\\(.*\\)" url)
6632 (setq url (substring url (match-beginning 1) nil)))
6633 (let (to args subject func)
6634 (setq args (gnus-url-parse-query-string
6635 (if (string-match "^\\?" url)
6637 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6638 (concat "to=" (match-string 1 url) "&"
6639 (match-string 2 url))
6640 (concat "to=" url)))
6642 subject (cdr-safe (assoc "subject" args)))
6645 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6648 (message-position-on-field (caar args)))
6649 (insert (gnus-replace-in-string
6650 (mapconcat 'identity (reverse (cdar args)) ", ")
6652 (setq args (cdr args)))
6655 (message-goto-subject))))
6657 (defun gnus-button-embedded-url (address)
6658 "Activate ADDRESS with `browse-url'."
6659 (browse-url (gnus-strip-whitespace address)))
6661 ;;; Next/prev buttons in the article buffer.
6663 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6664 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6666 (defvar gnus-prev-page-map
6667 (let ((map (make-sparse-keymap)))
6668 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6669 (define-key map "\r" 'gnus-button-prev-page)
6672 (defvar gnus-next-page-map
6673 (let ((map (make-sparse-keymap)))
6674 (define-key map gnus-mouse-2 'gnus-button-next-page)
6675 (define-key map "\r" 'gnus-button-next-page)
6678 (defun gnus-insert-prev-page-button ()
6680 (buffer-read-only nil))
6682 gnus-prev-page-line-format nil
6683 `(keymap ,gnus-prev-page-map
6685 gnus-callback gnus-article-button-prev-page
6686 article-type annotation))
6687 (widget-convert-button
6689 ;; Exclude a newline.
6692 :action 'gnus-button-prev-page
6693 :button-keymap gnus-prev-page-map)))
6695 (defun gnus-button-next-page (&optional args more-args)
6696 "Go to the next page."
6698 (let ((win (selected-window)))
6699 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6700 (gnus-article-next-page)
6701 (select-window win)))
6703 (defun gnus-button-prev-page (&optional args more-args)
6704 "Go to the prev page."
6706 (let ((win (selected-window)))
6707 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6708 (gnus-article-prev-page)
6709 (select-window win)))
6711 (defun gnus-insert-next-page-button ()
6713 (buffer-read-only nil))
6714 (gnus-eval-format gnus-next-page-line-format nil
6715 `(keymap ,gnus-next-page-map
6717 gnus-callback gnus-article-button-next-page
6718 article-type annotation))
6719 (widget-convert-button
6721 ;; Exclude a newline.
6724 :action 'gnus-button-next-page
6725 :button-keymap gnus-next-page-map)))
6727 (defun gnus-article-button-next-page (arg)
6728 "Go to the next page."
6730 (let ((win (selected-window)))
6731 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6732 (gnus-article-next-page)
6733 (select-window win)))
6735 (defun gnus-article-button-prev-page (arg)
6736 "Go to the prev page."
6738 (let ((win (selected-window)))
6739 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6740 (gnus-article-prev-page)
6741 (select-window win)))
6743 (defvar gnus-decode-header-methods
6744 '(mail-decode-encoded-word-region)
6745 "List of methods used to decode headers.
6747 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6748 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6749 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6750 whose names match REGEXP.
6753 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6754 mail-decode-encoded-word-region
6755 (\"chinese\" . rfc1843-decode-region))
6758 (defvar gnus-decode-header-methods-cache nil)
6760 (defun gnus-multi-decode-header (start end)
6761 "Apply the functions from `gnus-encoded-word-methods' that match."
6762 (unless (and gnus-decode-header-methods-cache
6763 (eq gnus-newsgroup-name
6764 (car gnus-decode-header-methods-cache)))
6765 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6768 (nconc gnus-decode-header-methods-cache (list x))
6769 (if (and gnus-newsgroup-name
6770 (string-match (car x) gnus-newsgroup-name))
6771 (nconc gnus-decode-header-methods-cache
6773 gnus-decode-header-methods))
6774 (let ((xlist gnus-decode-header-methods-cache))
6777 (narrow-to-region start end)
6779 (funcall (pop xlist) (point-min) (point-max))))))
6782 ;;; Treatment top-level handling.
6785 (defun gnus-treat-article (condition &optional part-number total-parts type)
6786 (let ((length (- (point-max) (point-min)))
6787 (alist gnus-treatment-function-alist)
6788 (article-goto-body-goes-to-point-min-p t)
6792 (let ((list gnus-article-treat-types))
6794 (when (string-match (pop list) type)
6795 (throw 'found t)))))))
6796 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6798 (gnus-run-hooks 'gnus-part-display-hook)
6799 (dolist (elem alist)
6802 (when (gnus-buffer-live-p gnus-summary-buffer)
6803 (set-buffer gnus-summary-buffer))
6804 (symbol-value (car elem))))
6805 (when (and (or (consp val)
6807 (gnus-treat-predicate val)
6808 (or (not (get (car elem) 'highlight))
6811 (funcall (cadr elem)))))))
6813 ;; Dynamic variables.
6815 (defvar part-number)
6816 (defvar total-parts)
6821 (defun gnus-treat-predicate (val)
6828 (stringp (car val)))
6829 (apply 'gnus-or (mapcar `(lambda (s)
6830 (string-match s ,(or gnus-newsgroup-name "")))
6833 (let ((pred (pop val)))
6836 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6838 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6840 (not (gnus-treat-predicate (car val))))
6842 (equal (car val) type))
6844 (error "%S is not a valid predicate" pred)))))
6850 (eq part-number total-parts))
6854 (error "%S is not a valid value" val))))
6856 (defun gnus-article-encrypt-body (protocol &optional n)
6857 "Encrypt the article body."
6860 (or gnus-article-encrypt-protocol
6861 (completing-read "Encrypt protocol: "
6862 gnus-article-encrypt-protocol-alist
6864 current-prefix-arg))
6865 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6867 (error (format "Can't find the encrypt protocol %s" protocol)))
6868 (if (member gnus-newsgroup-name '("nndraft:delayed"
6871 (error "Can't encrypt the article in group %s"
6872 gnus-newsgroup-name))
6873 (gnus-summary-iterate n
6875 (set-buffer gnus-summary-buffer)
6876 (let ((mail-parse-charset gnus-newsgroup-charset)
6877 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6878 (summary-buffer gnus-summary-buffer)
6880 (gnus-set-global-variables)
6881 (when (gnus-group-read-only-p)
6882 (error "The current newsgroup does not support article encrypt"))
6883 (gnus-summary-show-article t)
6885 (or (mail-header-references gnus-current-headers) ""))
6886 (set-buffer gnus-article-buffer)
6887 (let* ((buffer-read-only nil)
6889 (mapcar (lambda (field)
6890 (and (save-restriction
6891 (message-narrow-to-head)
6892 (goto-char (point-min))
6893 (search-forward field nil t))
6895 (message-narrow-to-field)
6897 (delete-region (point-min) (point-max))
6899 '("Content-Type:" "Content-Transfer-Encoding:"
6900 "Content-Disposition:"))))
6901 (message-narrow-to-head)
6902 (message-remove-header "MIME-Version")
6903 (goto-char (point-max))
6904 (setq point (point))
6905 (insert (apply 'concat headers))
6907 (narrow-to-region point (point-max))
6908 (let ((message-options message-options))
6909 (message-options-set 'message-sender user-mail-address)
6910 (message-options-set 'message-recipients user-mail-address)
6911 (message-options-set 'message-sign-encrypt 'not)
6913 (goto-char (point-min))
6914 (insert "MIME-Version: 1.0\n")
6916 (gnus-summary-edit-article-done
6917 references nil summary-buffer t))
6918 (when gnus-keep-backlog
6919 (gnus-backlog-remove-article
6920 (car gnus-article-current) (cdr gnus-article-current)))
6922 (when (get-buffer gnus-original-article-buffer)
6923 (set-buffer gnus-original-article-buffer)
6924 (setq gnus-original-article nil)))
6925 (when gnus-use-cache
6926 (gnus-cache-update-article
6927 (car gnus-article-current) (cdr gnus-article-current))))))))
6929 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6930 "The following specs can be used:
6931 %t The security MIME type
6934 %D Details if button is pressed")
6936 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6937 "The following specs can be used:
6938 %t The security MIME type
6941 %D Details if button is pressed")
6943 (defvar gnus-mime-security-button-line-format-alist
6944 '((?t gnus-tmp-type ?s)
6945 (?i gnus-tmp-info ?s)
6946 (?d gnus-tmp-details ?s)
6947 (?D gnus-tmp-pressed-details ?s)))
6949 (defvar gnus-mime-security-button-map
6950 (let ((map (make-sparse-keymap)))
6951 (define-key map gnus-mouse-2 'gnus-article-push-button)
6952 (define-key map "\r" 'gnus-article-press-button)
6955 (defvar gnus-mime-security-details-buffer nil)
6957 (defvar gnus-mime-security-button-pressed nil)
6959 (defvar gnus-mime-security-show-details-inline t
6960 "If non-nil, show details in the article buffer.")
6962 (defun gnus-mime-security-verify-or-decrypt (handle)
6963 (mm-remove-parts (cdr handle))
6964 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6965 point buffer-read-only)
6967 (goto-char (car region)))
6969 (narrow-to-region (point) (point))
6970 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6971 (let* ((mm-verify-option 'known)
6972 (mm-decrypt-option 'known)
6973 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6974 (unless (eq nparts (cdr handle))
6975 (mm-destroy-parts (cdr handle))
6976 (setcdr handle nparts))))
6977 (setq point (point))
6978 (gnus-mime-display-security handle)
6979 (goto-char (point-max)))
6981 (delete-region (point) (cdr region))
6982 (set-marker (car region) nil)
6983 (set-marker (cdr region) nil))
6986 (defun gnus-mime-security-show-details (handle)
6987 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6989 (gnus-message 5 "No details.")
6990 (if gnus-mime-security-show-details-inline
6991 (let ((gnus-mime-security-button-pressed
6992 (not (get-text-property (point) 'gnus-mime-details)))
6993 (gnus-mime-security-button-line-format
6994 (get-text-property (point) 'gnus-line-format))
6997 (while (eq (get-text-property (point) 'gnus-line-format)
6998 gnus-mime-security-button-line-format)
7002 (narrow-to-region (point) (point))
7003 (gnus-insert-mime-security-button handle))
7004 (delete-region (point)
7005 (or (text-property-not-all
7008 gnus-mime-security-button-line-format)
7011 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7012 (with-current-buffer gnus-mime-security-details-buffer
7015 (setq gnus-mime-security-details-buffer
7016 (gnus-get-buffer-create "*MIME Security Details*")))
7017 (with-current-buffer gnus-mime-security-details-buffer
7019 (goto-char (point-min)))
7020 (pop-to-buffer gnus-mime-security-details-buffer)))))
7022 (defun gnus-mime-security-press-button (handle)
7024 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7025 (gnus-mime-security-show-details handle)
7026 (gnus-mime-security-verify-or-decrypt handle))))
7028 (defun gnus-insert-mime-security-button (handle &optional displayed)
7029 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7032 (or (nth 2 (assoc protocol mm-verify-function-alist))
7033 (nth 2 (assoc protocol mm-decrypt-function-alist))
7035 (if (equal (car handle) "multipart/signed")
7036 " Signed" " Encrypted")
7039 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7042 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7043 gnus-tmp-pressed-details
7045 (setq gnus-tmp-details
7046 (if gnus-tmp-details
7047 (concat "\n" gnus-tmp-details)
7049 (setq gnus-tmp-pressed-details
7050 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7055 gnus-mime-security-button-line-format
7056 gnus-mime-security-button-line-format-alist
7057 `(keymap ,gnus-mime-security-button-map
7058 gnus-callback gnus-mime-security-press-button
7059 gnus-line-format ,gnus-mime-security-button-line-format
7060 gnus-mime-details ,gnus-mime-security-button-pressed
7061 article-type annotation
7064 ;; Exclude a newline.
7067 (widget-convert-button
7070 :action 'gnus-widget-press-button
7071 :button-keymap gnus-mime-security-button-map
7073 (lambda (widget/window &optional overlay pos)
7074 ;; Needed to properly clear the message due to a bug in
7075 ;; wid-edit (XEmacs only).
7076 (when (boundp 'help-echo-owns-message)
7077 (setq help-echo-owns-message t))
7080 (aref gnus-mouse-2 0))))))
7082 (defun gnus-mime-display-security (handle)
7084 (narrow-to-region (point) (point))
7085 (unless (gnus-unbuttonized-mime-type-p (car handle))
7086 (gnus-insert-mime-security-button handle))
7087 (gnus-mime-display-mixed (cdr handle))
7090 (unless (gnus-unbuttonized-mime-type-p (car handle))
7091 (let ((gnus-mime-security-button-line-format
7092 gnus-mime-security-button-end-line-format))
7093 (gnus-insert-mime-security-button handle)))
7094 (mm-set-handle-multipart-parameter
7096 (cons (set-marker (make-marker) (point-min))
7097 (set-marker (make-marker) (point-max))))))
7103 (run-hooks 'gnus-art-load-hook)
7105 ;;; gnus-art.el ends here