1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
46 (autoload 'gnus-msg-mail "gnus-msg" nil t)
47 (autoload 'gnus-button-mailto "gnus-msg")
48 (autoload 'gnus-button-reply "gnus-msg" nil t)
50 (defgroup gnus-article nil
52 :link '(custom-manual "(gnus)The Article Buffer")
55 (defgroup gnus-article-treat nil
56 "Treating article parts."
57 :link '(custom-manual "(gnus)Article Hiding")
60 (defgroup gnus-article-hiding nil
61 "Hiding article parts."
62 :link '(custom-manual "(gnus)Article Hiding")
65 (defgroup gnus-article-highlight nil
66 "Article highlighting."
67 :link '(custom-manual "(gnus)Article Highlighting")
71 (defgroup gnus-article-signature nil
73 :link '(custom-manual "(gnus)Article Signature")
76 (defgroup gnus-article-headers nil
78 :link '(custom-manual "(gnus)Hiding Headers")
81 (defgroup gnus-article-washing nil
82 "Special commands on articles."
83 :link '(custom-manual "(gnus)Article Washing")
86 (defgroup gnus-article-emphasis nil
87 "Fontisizing articles."
88 :link '(custom-manual "(gnus)Article Fontisizing")
91 (defgroup gnus-article-saving nil
93 :link '(custom-manual "(gnus)Saving Articles")
96 (defgroup gnus-article-mime nil
97 "Worshiping the MIME wonder."
98 :link '(custom-manual "(gnus)Using MIME")
101 (defgroup gnus-article-buttons nil
102 "Pushable buttons in the article buffer."
103 :link '(custom-manual "(gnus)Article Buttons")
104 :group 'gnus-article)
106 (defgroup gnus-article-various nil
107 "Other article options."
108 :link '(custom-manual "(gnus)Misc Article")
109 :group 'gnus-article)
111 (defcustom gnus-ignored-headers
114 (concat "^" header ":"))
115 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
116 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
117 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
118 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
119 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
120 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
121 "X-Attribution" "X-Originating-IP" "Delivered-To"
122 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
123 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
124 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
125 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
126 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
127 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
128 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
129 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
130 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
131 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
132 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
133 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
134 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
135 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
136 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
137 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
138 "List-[A-Za-z]+" "X-Listprocessor-Version"
139 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
140 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
141 "X-Received" "Content-length" "X-precedence"
142 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
143 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
144 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
145 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
146 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
147 "X-Content-length" "X-Posting-Agent" "Original-Received"
148 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
149 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
150 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
151 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
152 "X-Abuse-and-DMCA-Info" "X-Postfilter"))
153 "*All headers that start with this regexp will be hidden.
154 This variable can also be a list of regexps of headers to be ignored.
155 If `gnus-visible-headers' is non-nil, this variable will be ignored."
156 :type '(choice :custom-show nil
159 :group 'gnus-article-hiding)
161 (defcustom gnus-visible-headers
162 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
163 "*All headers that do not match this regexp will be hidden.
164 This variable can also be a list of regexp of headers to remain visible.
165 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
166 :type '(repeat :value-to-internal (lambda (widget value)
167 (custom-split-regexp-maybe value))
168 :match (lambda (widget value)
170 (widget-editable-list-match widget value)))
172 :group 'gnus-article-hiding)
174 (defcustom gnus-sorted-header-list
175 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
176 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
177 "*This variable is a list of regular expressions.
178 If it is non-nil, headers that match the regular expressions will
179 be placed first in the article buffer in the sequence specified by
181 :type '(repeat regexp)
182 :group 'gnus-article-hiding)
184 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
185 "Headers that are only to be displayed if they have interesting data.
186 Possible values in this list are:
188 'empty Headers with no content.
189 'newsgroups Newsgroup identical to Gnus group.
190 'to-address To identical to To-address.
191 'to-list To identical to To-list.
192 'cc-list CC identical to To-list.
193 'followup-to Followup-to identical to Newsgroups.
194 'reply-to Reply-to identical to From.
195 'date Date less than four days old.
196 'long-to To and/or Cc longer than 1024 characters.
197 'many-to Multiple To and/or Cc."
198 :type '(set (const :tag "Headers with no content." empty)
199 (const :tag "Newsgroups identical to Gnus group." newsgroups)
200 (const :tag "To identical to To-address." to-address)
201 (const :tag "To identical to To-list." to-list)
202 (const :tag "CC identical to To-list." cc-list)
203 (const :tag "Followup-to identical to Newsgroups." followup-to)
204 (const :tag "Reply-to identical to From." reply-to)
205 (const :tag "Date less than four days old." date)
206 (const :tag "To and/or Cc longer than 1024 characters." long-to)
207 (const :tag "Multiple To and/or Cc headers." many-to))
208 :group 'gnus-article-hiding)
210 (defcustom gnus-article-skip-boring nil
211 "Skip over text that is not worth reading.
212 By default, if you set this t, then Gnus will display citations and
213 signatures, but will never scroll down to show you a page consisting
214 only of boring text. Boring text is controlled by
215 `gnus-article-boring-faces'."
217 :group 'gnus-article-hiding)
219 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
220 "Regexp matching signature separator.
221 This can also be a list of regexps. In that case, it will be checked
222 from head to tail looking for a separator. Searches will be done from
223 the end of the buffer."
224 :type '(repeat string)
225 :group 'gnus-article-signature)
227 (defcustom gnus-signature-limit nil
228 "Provide a limit to what is considered a signature.
229 If it is a number, no signature may not be longer (in characters) than
230 that number. If it is a floating point number, no signature may be
231 longer (in lines) than that number. If it is a function, the function
232 will be called without any parameters, and if it returns nil, there is
233 no signature in the buffer. If it is a string, it will be used as a
234 regexp. If it matches, the text in question is not a signature."
235 :type '(choice (integer :value 200)
237 (function :value fun)
238 (regexp :value ".*"))
239 :group 'gnus-article-signature)
241 (defcustom gnus-hidden-properties '(invisible t intangible t)
242 "Property list to use for hiding text."
244 :group 'gnus-article-hiding)
246 ;; Fixme: This isn't the right thing for mixed graphical and and
247 ;; non-graphical frames in a session.
248 (defcustom gnus-article-x-face-command
249 (if (featurep 'xemacs)
250 (if (or (gnus-image-type-available-p 'xface)
251 (gnus-image-type-available-p 'pbm))
252 'gnus-display-x-face-in-from
253 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
254 (if (gnus-image-type-available-p 'pbm)
255 'gnus-display-x-face-in-from
256 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
258 "*String or function to be executed to display an X-Face header.
259 If it is a string, the command will be executed in a sub-shell
260 asynchronously. The compressed face will be piped to this command."
261 :type `(choice string
262 (function-item gnus-display-x-face-in-from)
266 :group 'gnus-article-washing)
268 (defcustom gnus-article-x-face-too-ugly nil
269 "Regexp matching posters whose face shouldn't be shown automatically."
270 :type '(choice regexp (const nil))
271 :group 'gnus-article-washing)
273 (defcustom gnus-article-banner-alist nil
274 "Banner alist for stripping.
276 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
278 :type '(repeat (cons symbol regexp))
279 :group 'gnus-article-washing)
281 (gnus-define-group-parameter
284 "Alist of regexps (to match group names) and banner."
285 :variable-group gnus-article-washing
287 '(choice :tag "Banner"
289 (const :tag "Remove signature" signature)
290 (symbol :tag "Item in `gnus-article-banner-alist'" none)
292 (const :tag "None" nil))
294 "If non-nil, specify how to remove `banners' from articles.
296 Symbol `signature' means to remove signatures delimited by
297 `gnus-signature-separator'. Any other symbol is used to look up a
298 regular expression to match the banner in `gnus-article-banner-alist'.
299 A string is used as a regular expression to match the banner
302 (defcustom gnus-article-address-banner-alist nil
303 "Alist of mail addresses and banners.
304 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
305 to match a mail address in the From: header, BANNER is one of a symbol
306 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
307 If ADDRESS matches author's mail address, it will remove things like
308 advertisements. For example:
310 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
314 (regexp :tag "Address")
315 (choice :tag "Banner" :value nil
316 (const :tag "Remove signature" signature)
317 (symbol :tag "Item in `gnus-article-banner-alist'" none)
319 (const :tag "None" nil))))
320 :group 'gnus-article-washing)
322 (defcustom gnus-emphasis-alist
324 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
329 ("_/" "/_" underline-italic)
330 ("_\\*" "\\*_" underline-bold)
331 ("\\*/" "/\\*" bold-italic)
332 ("_\\*/" "/\\*_" underline-bold-italic))))
336 (format format (car spec) (cadr spec))
337 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
339 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
340 2 3 gnus-emphasis-strikethru)
341 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
342 2 3 gnus-emphasis-underline)))
343 "*Alist that says how to fontify certain phrases.
344 Each item looks like this:
346 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
348 The first element is a regular expression to be matched. The second
349 is a number that says what regular expression grouping used to find
350 the entire emphasized word. The third is a number that says what
351 regexp grouping should be displayed and highlighted. The fourth
352 is the face used for highlighting."
353 :type '(repeat (list :value ("" 0 0 default)
355 (integer :tag "Match group")
356 (integer :tag "Emphasize group")
358 :group 'gnus-article-emphasis)
360 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
361 "A regexp to describe whitespace which should not be emphasized.
362 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
363 The former avoids underlining of leading and trailing whitespace,
364 and the latter avoids underlining any whitespace at all."
366 :group 'gnus-article-emphasis
369 (defface gnus-emphasis-bold '((t (:bold t)))
370 "Face used for displaying strong emphasized text (*word*)."
371 :group 'gnus-article-emphasis)
373 (defface gnus-emphasis-italic '((t (:italic t)))
374 "Face used for displaying italic emphasized text (/word/)."
375 :group 'gnus-article-emphasis)
377 (defface gnus-emphasis-underline '((t (:underline t)))
378 "Face used for displaying underlined emphasized text (_word_)."
379 :group 'gnus-article-emphasis)
381 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
382 "Face used for displaying underlined bold emphasized text (_*word*_)."
383 :group 'gnus-article-emphasis)
385 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
386 "Face used for displaying underlined italic emphasized text (_/word/_)."
387 :group 'gnus-article-emphasis)
389 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
390 "Face used for displaying bold italic emphasized text (/*word*/)."
391 :group 'gnus-article-emphasis)
393 (defface gnus-emphasis-underline-bold-italic
394 '((t (:bold t :italic t :underline t)))
395 "Face used for displaying underlined bold italic emphasized text.
396 Example: (_/*word*/_)."
397 :group 'gnus-article-emphasis)
399 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
400 "Face used for displaying strike-through text (-word-)."
401 :group 'gnus-article-emphasis)
403 (defface gnus-emphasis-highlight-words
404 '((t (:background "black" :foreground "yellow")))
405 "Face used for displaying highlighted words."
406 :group 'gnus-article-emphasis)
408 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
409 "Format for display of Date headers in article bodies.
410 See `format-time-string' for the possible values.
412 The variable can also be function, which should return a complete Date
413 header. The function is called with one argument, the time, which can
414 be fed to `format-time-string'."
415 :type '(choice string symbol)
416 :link '(custom-manual "(gnus)Article Date")
417 :group 'gnus-article-washing)
420 (autoload 'mail-extract-address-components "mail-extr"))
422 (defcustom gnus-save-all-headers t
423 "*If non-nil, don't remove any headers before saving."
424 :group 'gnus-article-saving
427 (defcustom gnus-prompt-before-saving 'always
428 "*This variable says how much prompting is to be done when saving articles.
429 If it is nil, no prompting will be done, and the articles will be
430 saved to the default files. If this variable is `always', each and
431 every article that is saved will be preceded by a prompt, even when
432 saving large batches of articles. If this variable is neither nil not
433 `always', there the user will be prompted once for a file name for
434 each invocation of the saving commands."
435 :group 'gnus-article-saving
436 :type '(choice (item always)
437 (item :tag "never" nil)
438 (sexp :tag "once" :format "%t\n" :value t)))
440 (defcustom gnus-saved-headers gnus-visible-headers
441 "Headers to keep if `gnus-save-all-headers' is nil.
442 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
443 If that variable is nil, however, all headers that match this regexp
444 will be kept while the rest will be deleted before saving."
445 :group 'gnus-article-saving
448 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
449 "A function to save articles in your favourite format.
450 The function must be interactively callable (in other words, it must
451 be an Emacs command).
453 Gnus provides the following functions:
455 * gnus-summary-save-in-rmail (Rmail format)
456 * gnus-summary-save-in-mail (Unix mail format)
457 * gnus-summary-save-in-folder (MH folder)
458 * gnus-summary-save-in-file (article format)
459 * gnus-summary-save-body-in-file (article body)
460 * gnus-summary-save-in-vm (use VM's folder format)
461 * gnus-summary-write-to-file (article format -- overwrite)."
462 :group 'gnus-article-saving
463 :type '(radio (function-item gnus-summary-save-in-rmail)
464 (function-item gnus-summary-save-in-mail)
465 (function-item gnus-summary-save-in-folder)
466 (function-item gnus-summary-save-in-file)
467 (function-item gnus-summary-save-body-in-file)
468 (function-item gnus-summary-save-in-vm)
469 (function-item gnus-summary-write-to-file)))
471 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
472 "A function generating a file name to save articles in Rmail format.
473 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
474 :group 'gnus-article-saving
477 (defcustom gnus-mail-save-name 'gnus-plain-save-name
478 "A function generating a file name to save articles in Unix mail format.
479 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
480 :group 'gnus-article-saving
483 (defcustom gnus-folder-save-name 'gnus-folder-save-name
484 "A function generating a file name to save articles in MH folder.
485 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
486 :group 'gnus-article-saving
489 (defcustom gnus-file-save-name 'gnus-numeric-save-name
490 "A function generating a file name to save articles in article format.
491 The function is called with NEWSGROUP, HEADERS, and optional
493 :group 'gnus-article-saving
496 (defcustom gnus-split-methods
497 '((gnus-article-archive-name)
498 (gnus-article-nndoc-name))
499 "*Variable used to suggest where articles are to be saved.
500 For instance, if you would like to save articles related to Gnus in
501 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
502 you could set this variable to something like:
504 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
505 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
507 This variable is an alist where the where the key is the match and the
508 value is a list of possible files to save in if the match is non-nil.
510 If the match is a string, it is used as a regexp match on the
511 article. If the match is a symbol, that symbol will be funcalled
512 from the buffer of the article to be saved with the newsgroup as the
513 parameter. If it is a list, it will be evaled in the same buffer.
515 If this form or function returns a string, this string will be used as
516 a possible file name; and if it returns a non-nil list, that list will
517 be used as possible file names."
518 :group 'gnus-article-saving
519 :type '(repeat (choice (list :value (fun) function)
520 (cons :value ("" "") regexp (repeat string))
523 (defcustom gnus-page-delimiter "^\^L"
524 "*Regexp describing what to use as article page delimiters.
525 The default value is \"^\^L\", which is a form linefeed at the
526 beginning of a line."
528 :group 'gnus-article-various)
530 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
531 "*The format specification for the article mode line.
532 See `gnus-summary-mode-line-format' for a closer description.
534 The following additional specs are available:
536 %w The article washing status.
537 %m The number of MIME parts in the article."
539 :group 'gnus-article-various)
541 (defcustom gnus-article-mode-hook nil
542 "*A hook for Gnus article mode."
544 :group 'gnus-article-various)
546 (when (featurep 'xemacs)
547 ;; Extracted from gnus-xmas-define in order to preserve user settings
548 (when (fboundp 'turn-off-scroll-in-place)
549 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
550 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
551 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
553 (defcustom gnus-article-menu-hook nil
554 "*Hook run after the creation of the article mode menu."
556 :group 'gnus-article-various)
558 (defcustom gnus-article-prepare-hook nil
559 "*A hook called after an article has been prepared in the article buffer."
561 :group 'gnus-article-various)
563 (make-obsolete-variable 'gnus-article-hide-pgp-hook
564 "This variable is obsolete in Gnus 5.10.")
566 (defcustom gnus-article-button-face 'bold
567 "Face used for highlighting buttons in the article buffer.
569 An article button is a piece of text that you can activate by pressing
570 `RET' or `mouse-2' above it."
572 :group 'gnus-article-buttons)
574 (defcustom gnus-article-mouse-face 'highlight
575 "Face used for mouse highlighting in the article buffer.
577 Article buttons will be displayed in this face when the cursor is
580 :group 'gnus-article-buttons)
582 (defcustom gnus-signature-face 'gnus-signature-face
583 "Face used for highlighting a signature in the article buffer.
584 Obsolete; use the face `gnus-signature-face' for customizations instead."
586 :group 'gnus-article-highlight
587 :group 'gnus-article-signature)
589 (defface gnus-signature-face
592 "Face used for highlighting a signature in the article buffer."
593 :group 'gnus-article-highlight
594 :group 'gnus-article-signature)
596 (defface gnus-header-from-face
599 (:foreground "spring green"))
602 (:foreground "red3"))
605 "Face used for displaying from headers."
606 :group 'gnus-article-headers
607 :group 'gnus-article-highlight)
609 (defface gnus-header-subject-face
612 (:foreground "SeaGreen3"))
615 (:foreground "red4"))
617 (:bold t :italic t)))
618 "Face used for displaying subject headers."
619 :group 'gnus-article-headers
620 :group 'gnus-article-highlight)
622 (defface gnus-header-newsgroups-face
625 (:foreground "yellow" :italic t))
628 (:foreground "MidnightBlue" :italic t))
631 "Face used for displaying newsgroups headers."
632 :group 'gnus-article-headers
633 :group 'gnus-article-highlight)
635 (defface gnus-header-name-face
638 (:foreground "SeaGreen"))
641 (:foreground "maroon"))
644 "Face used for displaying header names."
645 :group 'gnus-article-headers
646 :group 'gnus-article-highlight)
648 (defface gnus-header-content-face
651 (:foreground "forest green" :italic t))
654 (:foreground "indianred4" :italic t))
656 (:italic t))) "Face used for displaying header content."
657 :group 'gnus-article-headers
658 :group 'gnus-article-highlight)
660 (defcustom gnus-header-face-alist
661 '(("From" nil gnus-header-from-face)
662 ("Subject" nil gnus-header-subject-face)
663 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
664 ("" gnus-header-name-face gnus-header-content-face))
665 "*Controls highlighting of article header.
667 An alist of the form (HEADER NAME CONTENT).
669 HEADER is a regular expression which should match the name of an
670 header header and NAME and CONTENT are either face names or nil.
672 The name of each header field will be displayed using the face
673 specified by the first element in the list where HEADER match the
674 header name and NAME is non-nil. Similarly, the content will be
675 displayed by the first non-nil matching CONTENT face."
676 :group 'gnus-article-headers
677 :group 'gnus-article-highlight
678 :type '(repeat (list (regexp :tag "Header")
680 (item :tag "skip" nil)
681 (face :value default))
682 (choice :tag "Content"
683 (item :tag "skip" nil)
684 (face :value default)))))
686 (defcustom gnus-article-decode-hook
687 '(article-decode-charset article-decode-encoded-words
688 article-decode-group-name article-decode-idna-rhs)
689 "*Hook run to decode charsets in articles."
690 :group 'gnus-article-headers
693 (defcustom gnus-display-mime-function 'gnus-display-mime
694 "Function to display MIME articles."
695 :group 'gnus-article-mime
698 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
699 "Function used to decode headers.")
701 (defvar gnus-article-dumbquotes-map
721 "Table for MS-to-Latin1 translation.")
723 (defcustom gnus-ignored-mime-types nil
724 "List of MIME types that should be ignored by Gnus."
726 :group 'gnus-article-mime
727 :type '(repeat regexp))
729 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
730 "List of MIME types that should not be given buttons when rendered inline.
731 See also `gnus-buttonized-mime-types' which may override this variable.
732 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
734 :group 'gnus-article-mime
735 :type '(repeat regexp))
737 (defcustom gnus-buttonized-mime-types nil
738 "List of MIME types that should be given buttons when rendered inline.
739 If set, this variable overrides `gnus-unbuttonized-mime-types'.
740 To see e.g. security buttons you could set this to
741 `(\"multipart/signed\")'.
742 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
744 :group 'gnus-article-mime
745 :type '(repeat regexp))
747 (defcustom gnus-inhibit-mime-unbuttonizing nil
748 "If non-nil, all MIME parts get buttons.
749 When nil (the default value), then some MIME parts do not get buttons,
750 as described by the variables `gnus-buttonized-mime-types' and
751 `gnus-unbuttonized-mime-types'."
755 (defcustom gnus-body-boundary-delimiter "_"
756 "String used to delimit header and body.
757 This variable is used by `gnus-article-treat-body-boundary' which can
758 be controlled by `gnus-treat-body-boundary'."
759 :group 'gnus-article-various
760 :type '(choice (item :tag "None" :value nil)
763 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
764 "Defines the location of the faces database.
765 For information on obtaining this database of pretty pictures, please
766 see http://www.cs.indiana.edu/picons/ftp/index.html"
767 :type '(repeat directory)
768 :link '(url-link :tag "download"
769 "http://www.cs.indiana.edu/picons/ftp/index.html")
770 :link '(custom-manual "(gnus)Picons")
773 (defun gnus-picons-installed-p ()
774 "Say whether picons are installed on your machine."
775 (let ((installed nil))
776 (dolist (database gnus-picon-databases)
777 (when (file-exists-p database)
781 (defcustom gnus-article-mime-part-function nil
782 "Function called with a MIME handle as the argument.
783 This is meant for people who want to do something automatic based
784 on parts -- for instance, adding Vcard info to a database."
785 :group 'gnus-article-mime
788 (defcustom gnus-mime-multipart-functions nil
789 "An alist of MIME types to functions to display them."
791 :group 'gnus-article-mime
794 (defcustom gnus-article-date-lapsed-new-header nil
795 "Whether the X-Sent and Date headers can coexist.
796 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
797 either replace the old \"Date:\" header (if this variable is nil), or
798 be added below it (otherwise)."
800 :group 'gnus-article-headers
803 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
804 "Function called with a MIME handle as the argument.
805 This is meant for people who want to view first matched part.
806 For `undisplayed-alternative' (default), the first undisplayed
807 part or alternative part is used. For `undisplayed', the first
808 undisplayed part is used. For a function, the first part which
809 the function return t is used. For nil, the first part is
812 :group 'gnus-article-mime
814 (item :tag "first" :value nil)
815 (item :tag "undisplayed" :value undisplayed)
816 (item :tag "undisplayed or alternative"
817 :value undisplayed-alternative)
820 (defcustom gnus-mime-action-alist
821 '(("save to file" . gnus-mime-save-part)
822 ("save and strip" . gnus-mime-save-part-and-strip)
823 ("delete part" . gnus-mime-delete-part)
824 ("display as text" . gnus-mime-inline-part)
825 ("view the part" . gnus-mime-view-part)
826 ("pipe to command" . gnus-mime-pipe-part)
827 ("toggle display" . gnus-article-press-button)
828 ("toggle display" . gnus-article-view-part-as-charset)
829 ("view as type" . gnus-mime-view-part-as-type)
830 ("view internally" . gnus-mime-view-part-internally)
831 ("view externally" . gnus-mime-view-part-externally))
832 "An alist of actions that run on the MIME attachment."
833 :group 'gnus-article-mime
834 :type '(repeat (cons (string :tag "name")
838 ;;; The treatment variables
841 (defvar gnus-part-display-hook nil
842 "Hook called on parts that are to receive treatment.")
844 (defvar gnus-article-treat-custom
845 '(choice (const :tag "Off" nil)
847 (const :tag "Header" head)
848 (const :tag "Last" last)
849 (integer :tag "Less")
850 (repeat :tag "Groups" regexp)
851 (sexp :tag "Predicate")))
853 (defvar gnus-article-treat-head-custom
854 '(choice (const :tag "Off" nil)
855 (const :tag "Header" head)))
857 (defvar gnus-article-treat-types '("text/plain")
860 (defvar gnus-inhibit-treatment nil
861 "Whether to inhibit treatment.")
863 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
864 "Highlight the signature.
865 Valid values are nil, t, `head', `last', an integer or a predicate.
866 See Info node `(gnus)Customizing Articles'."
867 :group 'gnus-article-treat
868 :link '(custom-manual "(gnus)Customizing Articles")
869 :type gnus-article-treat-custom)
870 (put 'gnus-treat-highlight-signature 'highlight t)
872 (defcustom gnus-treat-buttonize 100000
874 Valid values are nil, t, `head', `last', an integer or a predicate.
875 See Info node `(gnus)Customizing Articles'."
876 :group 'gnus-article-treat
877 :link '(custom-manual "(gnus)Customizing Articles")
878 :type gnus-article-treat-custom)
879 (put 'gnus-treat-buttonize 'highlight t)
881 (defcustom gnus-treat-buttonize-head 'head
882 "Add buttons to the head.
883 Valid values are nil, t, `head', `last', an integer or a predicate.
884 See Info node `(gnus)Customizing Articles' for details."
885 :group 'gnus-article-treat
886 :link '(custom-manual "(gnus)Customizing Articles")
887 :type gnus-article-treat-head-custom)
888 (put 'gnus-treat-buttonize-head 'highlight t)
890 (defcustom gnus-treat-emphasize
891 (and (or window-system
893 (>= (string-to-number emacs-version) 21))
896 Valid values are nil, t, `head', `last', an integer or a predicate.
897 See Info node `(gnus)Customizing Articles' for details."
898 :group 'gnus-article-treat
899 :link '(custom-manual "(gnus)Customizing Articles")
900 :type gnus-article-treat-custom)
901 (put 'gnus-treat-emphasize 'highlight t)
903 (defcustom gnus-treat-strip-cr nil
904 "Remove carriage returns.
905 Valid values are nil, t, `head', `last', an integer or a predicate.
906 See Info node `(gnus)Customizing Articles' for details."
907 :group 'gnus-article-treat
908 :link '(custom-manual "(gnus)Customizing Articles")
909 :type gnus-article-treat-custom)
911 (defcustom gnus-treat-unsplit-urls nil
912 "Remove newlines from within URLs.
913 Valid values are nil, t, `head', `last', an integer or a predicate.
914 See Info node `(gnus)Customizing Articles' for details."
915 :group 'gnus-article-treat
916 :link '(custom-manual "(gnus)Customizing Articles")
917 :type gnus-article-treat-custom)
919 (defcustom gnus-treat-leading-whitespace nil
920 "Remove leading whitespace in headers.
921 Valid values are nil, t, `head', `last', an integer or a predicate.
922 See Info node `(gnus)Customizing Articles' for details."
923 :group 'gnus-article-treat
924 :link '(custom-manual "(gnus)Customizing Articles")
925 :type gnus-article-treat-custom)
927 (defcustom gnus-treat-hide-headers 'head
929 Valid values are nil, t, `head', `last', an integer or a predicate.
930 See Info node `(gnus)Customizing Articles' for details."
931 :group 'gnus-article-treat
932 :link '(custom-manual "(gnus)Customizing Articles")
933 :type gnus-article-treat-head-custom)
935 (defcustom gnus-treat-hide-boring-headers nil
936 "Hide boring headers.
937 Valid values are nil, t, `head', `last', an integer or a predicate.
938 See Info node `(gnus)Customizing Articles' for details."
939 :group 'gnus-article-treat
940 :link '(custom-manual "(gnus)Customizing Articles")
941 :type gnus-article-treat-head-custom)
943 (defcustom gnus-treat-hide-signature nil
945 Valid values are nil, t, `head', `last', an integer or a predicate.
946 See Info node `(gnus)Customizing Articles' for details."
947 :group 'gnus-article-treat
948 :link '(custom-manual "(gnus)Customizing Articles")
949 :type gnus-article-treat-custom)
951 (defcustom gnus-treat-fill-article nil
953 Valid values are nil, t, `head', `last', an integer or a predicate.
954 See Info node `(gnus)Customizing Articles' for details."
955 :group 'gnus-article-treat
956 :link '(custom-manual "(gnus)Customizing Articles")
957 :type gnus-article-treat-custom)
959 (defcustom gnus-treat-hide-citation nil
961 Valid values are nil, t, `head', `last', an integer or a predicate.
962 See Info node `(gnus)Customizing Articles' for details."
963 :group 'gnus-article-treat
964 :link '(custom-manual "(gnus)Customizing Articles")
965 :type gnus-article-treat-custom)
967 (defcustom gnus-treat-hide-citation-maybe nil
969 Valid values are nil, t, `head', `last', an integer or a predicate.
970 See Info node `(gnus)Customizing Articles' for details."
971 :group 'gnus-article-treat
972 :link '(custom-manual "(gnus)Customizing Articles")
973 :type gnus-article-treat-custom)
975 (defcustom gnus-treat-strip-list-identifiers 'head
976 "Strip list identifiers from `gnus-list-identifiers`.
977 Valid values are nil, t, `head', `last', an integer or a predicate.
978 See Info node `(gnus)Customizing Articles' for details."
980 :group 'gnus-article-treat
981 :link '(custom-manual "(gnus)Customizing Articles")
982 :type gnus-article-treat-custom)
984 (make-obsolete-variable 'gnus-treat-strip-pgp
985 "This option is obsolete in Gnus 5.10.")
987 (defcustom gnus-treat-strip-pem nil
988 "Strip PEM signatures.
989 Valid values are nil, t, `head', `last', an integer or a predicate.
990 See Info node `(gnus)Customizing Articles' for details."
991 :group 'gnus-article-treat
992 :link '(custom-manual "(gnus)Customizing Articles")
993 :type gnus-article-treat-custom)
995 (defcustom gnus-treat-strip-banner t
996 "Strip banners from articles.
997 The banner to be stripped is specified in the `banner' group parameter.
998 Valid values are nil, t, `head', `last', an integer or a predicate.
999 See Info node `(gnus)Customizing Articles' for details."
1000 :group 'gnus-article-treat
1001 :link '(custom-manual "(gnus)Customizing Articles")
1002 :type gnus-article-treat-custom)
1004 (defcustom gnus-treat-highlight-headers 'head
1005 "Highlight the headers.
1006 Valid values are nil, t, `head', `last', an integer or a predicate.
1007 See Info node `(gnus)Customizing Articles' for details."
1008 :group 'gnus-article-treat
1009 :link '(custom-manual "(gnus)Customizing Articles")
1010 :type gnus-article-treat-head-custom)
1011 (put 'gnus-treat-highlight-headers 'highlight t)
1013 (defcustom gnus-treat-highlight-citation t
1014 "Highlight cited text.
1015 Valid values are nil, t, `head', `last', an integer or a predicate.
1016 See Info node `(gnus)Customizing Articles' for details."
1017 :group 'gnus-article-treat
1018 :link '(custom-manual "(gnus)Customizing Articles")
1019 :type gnus-article-treat-custom)
1020 (put 'gnus-treat-highlight-citation 'highlight t)
1022 (defcustom gnus-treat-date-ut nil
1023 "Display the Date in UT (GMT).
1024 Valid values are nil, t, `head', `last', an integer or a predicate.
1025 See Info node `(gnus)Customizing Articles' for details."
1026 :group 'gnus-article-treat
1027 :link '(custom-manual "(gnus)Customizing Articles")
1028 :type gnus-article-treat-head-custom)
1030 (defcustom gnus-treat-date-local nil
1031 "Display the Date in the local timezone.
1032 Valid values are nil, t, `head', `last', an integer or a predicate.
1033 See Info node `(gnus)Customizing Articles' for details."
1034 :group 'gnus-article-treat
1035 :link '(custom-manual "(gnus)Customizing Articles")
1036 :type gnus-article-treat-head-custom)
1038 (defcustom gnus-treat-date-english nil
1039 "Display the Date in a format that can be read aloud in English.
1040 Valid values are nil, t, `head', `last', an integer or a predicate.
1041 See Info node `(gnus)Customizing Articles' for details."
1042 :group 'gnus-article-treat
1043 :link '(custom-manual "(gnus)Customizing Articles")
1044 :type gnus-article-treat-head-custom)
1046 (defcustom gnus-treat-date-lapsed nil
1047 "Display the Date header in a way that says how much time has elapsed.
1048 Valid values are nil, t, `head', `last', an integer or a predicate.
1049 See Info node `(gnus)Customizing Articles' for details."
1050 :group 'gnus-article-treat
1051 :link '(custom-manual "(gnus)Customizing Articles")
1052 :type gnus-article-treat-head-custom)
1054 (defcustom gnus-treat-date-original nil
1055 "Display the date in the original timezone.
1056 Valid values are nil, t, `head', `last', an integer or a predicate.
1057 See Info node `(gnus)Customizing Articles' for details."
1058 :group 'gnus-article-treat
1059 :link '(custom-manual "(gnus)Customizing Articles")
1060 :type gnus-article-treat-head-custom)
1062 (defcustom gnus-treat-date-iso8601 nil
1063 "Display the date in the ISO8601 format.
1064 Valid values are nil, t, `head', `last', an integer or a predicate.
1065 See Info node `(gnus)Customizing Articles' for details."
1067 :group 'gnus-article-treat
1068 :link '(custom-manual "(gnus)Customizing Articles")
1069 :type gnus-article-treat-head-custom)
1071 (defcustom gnus-treat-date-user-defined nil
1072 "Display the date in a user-defined format.
1073 The format is defined by the `gnus-article-time-format' variable.
1074 Valid values are nil, t, `head', `last', an integer or a predicate.
1075 See Info node `(gnus)Customizing Articles' for details."
1076 :group 'gnus-article-treat
1077 :link '(custom-manual "(gnus)Customizing Articles")
1078 :type gnus-article-treat-head-custom)
1080 (defcustom gnus-treat-strip-headers-in-body t
1081 "Strip the X-No-Archive header line from the beginning of the body.
1082 Valid values are nil, t, `head', `last', an integer or a predicate.
1083 See Info node `(gnus)Customizing Articles' for details."
1085 :group 'gnus-article-treat
1086 :link '(custom-manual "(gnus)Customizing Articles")
1087 :type gnus-article-treat-custom)
1089 (defcustom gnus-treat-strip-trailing-blank-lines nil
1090 "Strip trailing blank lines.
1091 Valid values are nil, t, `head', `last', an integer or a predicate.
1092 See Info node `(gnus)Customizing Articles' for details."
1093 :group 'gnus-article-treat
1094 :link '(custom-manual "(gnus)Customizing Articles")
1095 :type gnus-article-treat-custom)
1097 (defcustom gnus-treat-strip-leading-blank-lines nil
1098 "Strip leading blank lines.
1099 Valid values are nil, t, `head', `last', an integer or a predicate.
1100 See Info node `(gnus)Customizing Articles' for details."
1101 :group 'gnus-article-treat
1102 :link '(custom-manual "(gnus)Customizing Articles")
1103 :type gnus-article-treat-custom)
1105 (defcustom gnus-treat-strip-multiple-blank-lines nil
1106 "Strip multiple blank lines.
1107 Valid values are nil, t, `head', `last', an integer or a predicate.
1108 See Info node `(gnus)Customizing Articles' for details."
1109 :group 'gnus-article-treat
1110 :link '(custom-manual "(gnus)Customizing Articles")
1111 :type gnus-article-treat-custom)
1113 (defcustom gnus-treat-unfold-headers 'head
1114 "Unfold folded header lines.
1115 Valid values are nil, t, `head', `last', an integer or a predicate.
1116 See Info node `(gnus)Customizing Articles' for details."
1117 :group 'gnus-article-treat
1118 :link '(custom-manual "(gnus)Customizing Articles")
1119 :type gnus-article-treat-custom)
1121 (defcustom gnus-treat-fold-headers nil
1123 Valid values are nil, t, `head', `last', an integer or a predicate.
1124 See Info node `(gnus)Customizing Articles' for details."
1125 :group 'gnus-article-treat
1126 :link '(custom-manual "(gnus)Customizing Articles")
1127 :type gnus-article-treat-custom)
1129 (defcustom gnus-treat-fold-newsgroups 'head
1130 "Fold the Newsgroups and Followup-To headers.
1131 Valid values are nil, t, `head', `last', an integer or a predicate.
1132 See Info node `(gnus)Customizing Articles' for details."
1133 :group 'gnus-article-treat
1134 :link '(custom-manual "(gnus)Customizing Articles")
1135 :type gnus-article-treat-custom)
1137 (defcustom gnus-treat-overstrike t
1138 "Treat overstrike highlighting.
1139 Valid values are nil, t, `head', `last', an integer or a predicate.
1140 See Info node `(gnus)Customizing Articles' for details."
1141 :group 'gnus-article-treat
1142 :link '(custom-manual "(gnus)Customizing Articles")
1143 :type gnus-article-treat-custom)
1144 (put 'gnus-treat-overstrike 'highlight t)
1146 (defcustom gnus-treat-display-xface
1147 (and (not noninteractive)
1148 (or (and (fboundp 'image-type-available-p)
1149 (image-type-available-p 'xbm)
1150 (string-match "^0x" (shell-command-to-string "uncompface"))
1151 (executable-find "icontopbm"))
1152 (and (featurep 'xemacs)
1155 "Display X-Face headers.
1156 Valid values are nil, t, `head', `last', an integer or a predicate.
1157 See Info node `(gnus)Customizing Articles' and Info node
1158 `(gnus)X-Face' for details."
1159 :group 'gnus-article-treat
1161 :link '(custom-manual "(gnus)Customizing Articles")
1162 :link '(custom-manual "(gnus)X-Face")
1163 :type gnus-article-treat-head-custom)
1164 (put 'gnus-treat-display-xface 'highlight t)
1166 (defcustom gnus-treat-display-face
1167 (and (not noninteractive)
1168 (or (and (fboundp 'image-type-available-p)
1169 (image-type-available-p 'png))
1170 (and (featurep 'xemacs)
1173 "Display Face headers.
1174 Valid values are nil, t, `head', `last', an integer or a predicate.
1175 See Info node `(gnus)Customizing Articles' and Info node
1176 `(gnus)X-Face' for details."
1177 :group 'gnus-article-treat
1179 :link '(custom-manual "(gnus)Customizing Articles")
1180 :link '(custom-manual "(gnus)X-Face")
1181 :type gnus-article-treat-head-custom)
1182 (put 'gnus-treat-display-xface 'highlight t)
1184 (defcustom gnus-treat-display-smileys
1185 (if (or (and (featurep 'xemacs)
1187 (and (fboundp 'image-type-available-p)
1188 (image-type-available-p 'pbm)))
1191 Valid values are nil, t, `head', `last', an integer or a predicate.
1192 See Info node `(gnus)Customizing Articles' and Info node
1193 `(gnus)Smileys' for details."
1194 :group 'gnus-article-treat
1196 :link '(custom-manual "(gnus)Customizing Articles")
1197 :link '(custom-manual "(gnus)Smileys")
1198 :type gnus-article-treat-custom)
1199 (put 'gnus-treat-display-smileys 'highlight t)
1201 (defcustom gnus-treat-from-picon
1202 (if (and (gnus-image-type-available-p 'xpm)
1203 (gnus-picons-installed-p))
1205 "Display picons in the From header.
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)Picons' for details."
1209 :group 'gnus-article-treat
1211 :link '(custom-manual "(gnus)Customizing Articles")
1212 :link '(custom-manual "(gnus)Picons")
1213 :type gnus-article-treat-head-custom)
1214 (put 'gnus-treat-from-picon 'highlight t)
1216 (defcustom gnus-treat-mail-picon
1217 (if (and (gnus-image-type-available-p 'xpm)
1218 (gnus-picons-installed-p))
1220 "Display picons in To and Cc headers.
1221 Valid values are nil, t, `head', `last', an integer or a predicate.
1222 See Info node `(gnus)Customizing Articles' and Info node
1223 `(gnus)Picons' for details."
1224 :group 'gnus-article-treat
1226 :link '(custom-manual "(gnus)Customizing Articles")
1227 :link '(custom-manual "(gnus)Picons")
1228 :type gnus-article-treat-head-custom)
1229 (put 'gnus-treat-mail-picon 'highlight t)
1231 (defcustom gnus-treat-newsgroups-picon
1232 (if (and (gnus-image-type-available-p 'xpm)
1233 (gnus-picons-installed-p))
1235 "Display picons in the Newsgroups and Followup-To headers.
1236 Valid values are nil, t, `head', `last', an integer or a predicate.
1237 See Info node `(gnus)Customizing Articles' and Info node
1238 `(gnus)Picons' for details."
1239 :group 'gnus-article-treat
1241 :link '(custom-manual "(gnus)Customizing Articles")
1242 :link '(custom-manual "(gnus)Picons")
1243 :type gnus-article-treat-head-custom)
1244 (put 'gnus-treat-newsgroups-picon 'highlight t)
1246 (defcustom gnus-treat-body-boundary
1247 (if (or gnus-treat-newsgroups-picon
1248 gnus-treat-mail-picon
1249 gnus-treat-from-picon)
1251 "Draw a boundary at the end of the headers.
1252 Valid values are nil, t, `head', `last', an integer or a predicate.
1253 See Info node `(gnus)Customizing Articles' for details."
1255 :group 'gnus-article-treat
1256 :link '(custom-manual "(gnus)Customizing Articles")
1257 :type gnus-article-treat-custom)
1259 (defcustom gnus-treat-capitalize-sentences nil
1260 "Capitalize sentence-starting words.
1261 Valid values are nil, t, `head', `last', an integer or a predicate.
1262 See Info node `(gnus)Customizing Articles' for details."
1264 :group 'gnus-article-treat
1265 :link '(custom-manual "(gnus)Customizing Articles")
1266 :type gnus-article-treat-custom)
1268 (defcustom gnus-treat-wash-html nil
1270 Valid values are nil, t, `head', `last', an integer or a predicate.
1271 See Info node `(gnus)Customizing Articles' for details."
1272 :group 'gnus-article-treat
1273 :link '(custom-manual "(gnus)Customizing Articles")
1274 :type gnus-article-treat-custom)
1276 (defcustom gnus-treat-fill-long-lines nil
1278 Valid values are nil, t, `head', `last', an integer or a predicate.
1279 See Info node `(gnus)Customizing Articles' for details."
1280 :group 'gnus-article-treat
1281 :link '(custom-manual "(gnus)Customizing Articles")
1282 :type gnus-article-treat-custom)
1284 (defcustom gnus-treat-play-sounds nil
1286 Valid values are nil, t, `head', `last', an integer or a predicate.
1287 See Info node `(gnus)Customizing Articles' for details."
1289 :group 'gnus-article-treat
1290 :link '(custom-manual "(gnus)Customizing Articles")
1291 :type gnus-article-treat-custom)
1293 (defcustom gnus-treat-translate nil
1294 "Translate articles from one language to another.
1295 Valid values are nil, t, `head', `last', an integer or a predicate.
1296 See Info node `(gnus)Customizing Articles' for details."
1298 :group 'gnus-article-treat
1299 :link '(custom-manual "(gnus)Customizing Articles")
1300 :type gnus-article-treat-custom)
1302 (defcustom gnus-treat-x-pgp-sig nil
1304 To automatically treat X-PGP-Sig, set it to head.
1305 Valid values are nil, t, `head', `last', an integer or a predicate.
1306 See Info node `(gnus)Customizing Articles' for details."
1307 :group 'gnus-article-treat
1308 :group 'mime-security
1309 :link '(custom-manual "(gnus)Customizing Articles")
1310 :type gnus-article-treat-custom)
1312 (defvar gnus-article-encrypt-protocol-alist
1313 '(("PGP" . mml2015-self-encrypt)))
1315 ;; Set to nil if more than one protocol added to
1316 ;; gnus-article-encrypt-protocol-alist.
1317 (defcustom gnus-article-encrypt-protocol "PGP"
1318 "The protocol used for encrypt articles.
1319 It is a string, such as \"PGP\". If nil, ask user."
1321 :group 'mime-security)
1323 (defvar gnus-article-wash-function nil
1324 "Function used for converting HTML into text.")
1326 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1327 (mm-coding-system-p 'utf-8)
1328 (executable-find idna-program))
1329 "Whether IDNA decoding of headers is used when viewing messages.
1330 This requires GNU Libidn, and by default only enabled if it is found."
1331 :group 'gnus-article-headers
1334 (defcustom gnus-article-over-scroll nil
1335 "If non-nil, allow scrolling the article buffer even when there no more text."
1336 :group 'gnus-article
1339 ;;; Internal variables
1341 (defvar gnus-english-month-names
1342 '("January" "February" "March" "April" "May" "June" "July" "August"
1343 "September" "October" "November" "December"))
1345 (defvar article-goto-body-goes-to-point-min-p nil)
1346 (defvar gnus-article-wash-types nil)
1347 (defvar gnus-article-emphasis-alist nil)
1348 (defvar gnus-article-image-alist nil)
1350 (defvar gnus-article-mime-handle-alist-1 nil)
1351 (defvar gnus-treatment-function-alist
1352 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1353 (gnus-treat-strip-banner gnus-article-strip-banner)
1354 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1355 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1356 (gnus-treat-buttonize gnus-article-add-buttons)
1357 (gnus-treat-fill-article gnus-article-fill-cited-article)
1358 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1359 (gnus-treat-strip-cr gnus-article-remove-cr)
1360 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1361 (gnus-treat-date-ut gnus-article-date-ut)
1362 (gnus-treat-date-local gnus-article-date-local)
1363 (gnus-treat-date-english gnus-article-date-english)
1364 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1365 (gnus-treat-date-original gnus-article-date-original)
1366 (gnus-treat-date-user-defined gnus-article-date-user)
1367 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1368 (gnus-treat-display-xface gnus-article-display-x-face)
1369 (gnus-treat-display-face gnus-article-display-face)
1370 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1371 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1372 (gnus-treat-hide-signature gnus-article-hide-signature)
1373 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1374 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1375 (gnus-treat-strip-pem gnus-article-hide-pem)
1376 (gnus-treat-from-picon gnus-treat-from-picon)
1377 (gnus-treat-mail-picon gnus-treat-mail-picon)
1378 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1379 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1380 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1381 (gnus-treat-strip-trailing-blank-lines
1382 gnus-article-remove-trailing-blank-lines)
1383 (gnus-treat-strip-leading-blank-lines
1384 gnus-article-strip-leading-blank-lines)
1385 (gnus-treat-strip-multiple-blank-lines
1386 gnus-article-strip-multiple-blank-lines)
1387 (gnus-treat-overstrike gnus-article-treat-overstrike)
1388 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1389 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1390 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1391 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1392 (gnus-treat-display-smileys gnus-treat-smiley)
1393 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1394 (gnus-treat-wash-html gnus-article-wash-html)
1395 (gnus-treat-emphasize gnus-article-emphasize)
1396 (gnus-treat-hide-citation gnus-article-hide-citation)
1397 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1398 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1399 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1400 (gnus-treat-play-sounds gnus-earcon-display)))
1402 (defvar gnus-article-mime-handle-alist nil)
1403 (defvar article-lapsed-timer nil)
1404 (defvar gnus-article-current-summary nil)
1406 (defvar gnus-article-mode-syntax-table
1407 (let ((table (copy-syntax-table text-mode-syntax-table)))
1408 ;; This causes the citation match run O(2^n).
1409 ;; (modify-syntax-entry ?- "w" table)
1410 (modify-syntax-entry ?> ")<" table)
1411 (modify-syntax-entry ?< "(>" table)
1412 ;; make M-. in article buffers work for `foo' strings
1413 (modify-syntax-entry ?' " " table)
1414 (modify-syntax-entry ?` " " table)
1416 "Syntax table used in article mode buffers.
1417 Initialized from `text-mode-syntax-table.")
1419 (defvar gnus-save-article-buffer nil)
1421 (defvar gnus-article-mode-line-format-alist
1422 (nconc '((?w (gnus-article-wash-status) ?s)
1423 (?m (gnus-article-mime-part-status) ?s))
1424 gnus-summary-mode-line-format-alist))
1426 (defvar gnus-number-of-articles-to-be-saved nil)
1428 (defvar gnus-inhibit-hiding nil)
1430 ;;; Macros for dealing with the article buffer.
1432 (defmacro gnus-with-article-headers (&rest forms)
1434 (set-buffer gnus-article-buffer)
1436 (let ((buffer-read-only nil)
1437 (inhibit-point-motion-hooks t)
1438 (case-fold-search t))
1439 (article-narrow-to-head)
1442 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1443 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1445 (defmacro gnus-with-article-buffer (&rest forms)
1447 (set-buffer gnus-article-buffer)
1448 (let ((buffer-read-only nil))
1451 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1452 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1454 (defun gnus-article-goto-header (header)
1455 "Go to HEADER, which is a regular expression."
1456 (re-search-forward (concat "^\\(" header "\\):") nil t))
1458 (defsubst gnus-article-hide-text (b e props)
1459 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1460 (gnus-add-text-properties-when 'article-type nil b e props)
1461 (when (memq 'intangible props)
1463 (max (1- b) (point-min))
1464 b 'intangible (cddr (memq 'intangible props)))))
1466 (defsubst gnus-article-unhide-text (b e)
1467 "Remove hidden text properties from region between B and E."
1468 (remove-text-properties b e gnus-hidden-properties)
1469 (when (memq 'intangible gnus-hidden-properties)
1470 (put-text-property (max (1- b) (point-min))
1471 b 'intangible nil)))
1473 (defun gnus-article-hide-text-type (b e type)
1474 "Hide text of TYPE between B and E."
1475 (gnus-add-wash-type type)
1476 (gnus-article-hide-text
1477 b e (cons 'article-type (cons type gnus-hidden-properties))))
1479 (defun gnus-article-unhide-text-type (b e type)
1480 "Unhide text of TYPE between B and E."
1481 (gnus-delete-wash-type type)
1482 (remove-text-properties
1483 b e (cons 'article-type (cons type gnus-hidden-properties)))
1484 (when (memq 'intangible gnus-hidden-properties)
1485 (put-text-property (max (1- b) (point-min))
1486 b 'intangible nil)))
1488 (defun gnus-article-hide-text-of-type (type)
1489 "Hide text of TYPE in the current buffer."
1491 (let ((b (point-min))
1493 (while (setq b (text-property-any b e 'article-type type))
1494 (add-text-properties b (incf b) gnus-hidden-properties)))))
1496 (defun gnus-article-delete-text-of-type (type)
1497 "Delete text of TYPE in the current buffer."
1499 (let ((b (point-min)))
1500 (while (setq b (text-property-any b (point-max) 'article-type type))
1502 b (or (text-property-not-all b (point-max) 'article-type type)
1505 (defun gnus-article-delete-invisible-text ()
1506 "Delete all invisible text in the current buffer."
1508 (let ((b (point-min)))
1509 (while (setq b (text-property-any b (point-max) 'invisible t))
1511 b (or (text-property-not-all b (point-max) 'invisible t)
1514 (defun gnus-article-text-type-exists-p (type)
1515 "Say whether any text of type TYPE exists in the buffer."
1516 (text-property-any (point-min) (point-max) 'article-type type))
1518 (defsubst gnus-article-header-rank ()
1519 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1520 (let ((list gnus-sorted-header-list)
1523 (if (looking-at (car list))
1525 (setq list (cdr list))
1529 (defun article-hide-headers (&optional arg delete)
1530 "Hide unwanted headers and possibly sort them as well."
1532 ;; This function might be inhibited.
1533 (unless gnus-inhibit-hiding
1536 (let ((buffer-read-only nil)
1537 (case-fold-search t)
1538 (max (1+ (length gnus-sorted-header-list)))
1539 (ignored (when (not gnus-visible-headers)
1540 (cond ((stringp gnus-ignored-headers)
1541 gnus-ignored-headers)
1542 ((listp gnus-ignored-headers)
1543 (mapconcat 'identity gnus-ignored-headers
1546 (cond ((stringp gnus-visible-headers)
1547 gnus-visible-headers)
1548 ((and gnus-visible-headers
1549 (listp gnus-visible-headers))
1550 (mapconcat 'identity gnus-visible-headers "\\|"))))
1551 (inhibit-point-motion-hooks t)
1553 ;; First we narrow to just the headers.
1554 (article-narrow-to-head)
1555 ;; Hide any "From " lines at the beginning of (mail) articles.
1556 (while (looking-at "From ")
1559 (delete-region (point-min) (point)))
1560 ;; Then treat the rest of the header lines.
1561 ;; Then we use the two regular expressions
1562 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1563 ;; select which header lines is to remain visible in the
1565 (while (re-search-forward "^[^ \t:]*:" nil t)
1567 ;; Mark the rank of the header.
1569 (point) (1+ (point)) 'message-rank
1570 (if (or (and visible (looking-at visible))
1572 (not (looking-at ignored))))
1573 (gnus-article-header-rank)
1576 (message-sort-headers-1)
1577 (when (setq beg (text-property-any
1578 (point-min) (point-max) 'message-rank (+ 2 max)))
1579 ;; We delete the unwanted headers.
1580 (gnus-add-wash-type 'headers)
1581 (add-text-properties (point-min) (+ 5 (point-min))
1582 '(article-type headers dummy-invisible t))
1583 (delete-region beg (point-max))))))))
1585 (defun article-hide-boring-headers (&optional arg)
1586 "Toggle hiding of headers that aren't very interesting.
1587 If given a negative prefix, always show; if given a positive prefix,
1589 (interactive (gnus-article-hidden-arg))
1590 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1591 (not gnus-show-all-headers))
1594 (let ((buffer-read-only nil)
1595 (list gnus-boring-article-headers)
1596 (inhibit-point-motion-hooks t)
1598 (article-narrow-to-head)
1600 (setq elem (pop list))
1601 (goto-char (point-min))
1603 ;; Hide empty headers.
1605 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1607 (gnus-article-hide-text-type
1611 (if (re-search-forward "^[^ \t]" nil t)
1615 ;; Hide boring Newsgroups header.
1616 ((eq elem 'newsgroups)
1617 (when (gnus-string-equal
1618 (gnus-fetch-field "newsgroups")
1619 (gnus-group-real-name
1620 (if (boundp 'gnus-newsgroup-name)
1623 (gnus-article-hide-header "newsgroups")))
1624 ((eq elem 'to-address)
1625 (let ((to (message-fetch-field "to"))
1627 (gnus-parameter-to-address
1628 (if (boundp 'gnus-newsgroup-name)
1629 gnus-newsgroup-name ""))))
1630 (when (and to to-address
1633 ;; only one address in To
1634 (nth 1 (mail-extract-address-components to))
1636 (gnus-article-hide-header "to"))))
1638 (let ((to (message-fetch-field "to"))
1640 (gnus-parameter-to-list
1641 (if (boundp 'gnus-newsgroup-name)
1642 gnus-newsgroup-name ""))))
1643 (when (and to to-list
1646 ;; only one address in To
1647 (nth 1 (mail-extract-address-components to))
1649 (gnus-article-hide-header "to"))))
1651 (let ((cc (message-fetch-field "cc"))
1653 (gnus-parameter-to-list
1654 (if (boundp 'gnus-newsgroup-name)
1655 gnus-newsgroup-name ""))))
1656 (when (and cc to-list
1659 ;; only one address in CC
1660 (nth 1 (mail-extract-address-components cc))
1662 (gnus-article-hide-header "cc"))))
1663 ((eq elem 'followup-to)
1664 (when (gnus-string-equal
1665 (message-fetch-field "followup-to")
1666 (message-fetch-field "newsgroups"))
1667 (gnus-article-hide-header "followup-to")))
1668 ((eq elem 'reply-to)
1669 (if (gnus-group-find-parameter
1670 gnus-newsgroup-name 'broken-reply-to)
1671 (gnus-article-hide-header "reply-to")
1672 (let ((from (message-fetch-field "from"))
1673 (reply-to (message-fetch-field "reply-to")))
1678 (nth 1 (mail-extract-address-components from))
1679 (nth 1 (mail-extract-address-components reply-to)))))
1680 (gnus-article-hide-header "reply-to")))))
1682 (let ((date (message-fetch-field "date")))
1684 (< (days-between (current-time-string) date)
1686 (gnus-article-hide-header "date"))))
1688 (let ((to (message-fetch-field "to"))
1689 (cc (message-fetch-field "cc")))
1690 (when (> (length to) 1024)
1691 (gnus-article-hide-header "to"))
1692 (when (> (length cc) 1024)
1693 (gnus-article-hide-header "cc"))))
1697 (goto-char (point-min))
1698 (while (re-search-forward "^to:" nil t)
1699 (setq to-count (1+ to-count)))
1700 (when (> to-count 1)
1701 (while (> to-count 0)
1702 (goto-char (point-min))
1704 (re-search-forward "^to:" nil nil to-count)
1706 (narrow-to-region (point) (point-max))
1707 (gnus-article-hide-header "to"))
1708 (setq to-count (1- to-count))))
1709 (goto-char (point-min))
1710 (while (re-search-forward "^cc:" nil t)
1711 (setq cc-count (1+ cc-count)))
1712 (when (> cc-count 1)
1713 (while (> cc-count 0)
1714 (goto-char (point-min))
1716 (re-search-forward "^cc:" nil nil cc-count)
1718 (narrow-to-region (point) (point-max))
1719 (gnus-article-hide-header "cc"))
1720 (setq cc-count (1- cc-count)))))))))))))
1722 (defun gnus-article-hide-header (header)
1724 (goto-char (point-min))
1725 (when (re-search-forward (concat "^" header ":") nil t)
1726 (gnus-article-hide-text-type
1730 (if (re-search-forward "^[^ \t]" nil t)
1735 (defvar gnus-article-normalized-header-length 40
1736 "Length of normalized headers.")
1738 (defun article-normalize-headers ()
1739 "Make all header lines 40 characters long."
1741 (let ((buffer-read-only nil)
1745 (article-narrow-to-head)
1748 ((< (setq column (- (gnus-point-at-eol) (point)))
1749 gnus-article-normalized-header-length)
1751 (insert (make-string
1752 (- gnus-article-normalized-header-length column)
1754 ((> column gnus-article-normalized-header-length)
1755 (gnus-put-text-property
1757 (forward-char gnus-article-normalized-header-length)
1764 (forward-line 1))))))
1766 (defun article-treat-dumbquotes ()
1767 "Translate M****s*** sm*rtq**t*s into proper text.
1768 Note that this function guesses whether a character is a sm*rtq**t* or
1769 not, so it should only be used interactively.
1771 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1772 in an attempt to provide more quoting characters. If you see
1773 something like \\222 or \\264 where you're expecting some kind of
1774 apostrophe or quotation mark, then try this wash."
1776 (article-translate-strings gnus-article-dumbquotes-map))
1778 (defun article-translate-characters (from to)
1779 "Translate all characters in the body of the article according to FROM and TO.
1780 FROM is a string of characters to translate from; to is a string of
1781 characters to translate to."
1783 (when (article-goto-body)
1784 (let ((buffer-read-only nil)
1785 (x (make-string 225 ?x))
1787 (while (< (incf i) (length x))
1790 (while (< i (length from))
1791 (aset x (aref from i) (aref to i))
1793 (translate-region (point) (point-max) x)))))
1795 (defun article-translate-strings (map)
1796 "Translate all string in the body of the article according to MAP.
1797 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1799 (when (article-goto-body)
1800 (let ((buffer-read-only nil)
1802 (while (setq elem (pop map))
1804 (while (search-forward (car elem) nil t)
1805 (replace-match (cadr elem)))))))))
1807 (defun article-treat-overstrike ()
1808 "Translate overstrikes into bold text."
1811 (when (article-goto-body)
1812 (let ((buffer-read-only nil))
1813 (while (search-forward "\b" nil t)
1814 (let ((next (char-after))
1815 (previous (char-after (- (point) 2))))
1816 ;; We do the boldification/underlining by hiding the
1817 ;; overstrikes and putting the proper text property
1821 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1822 (put-text-property (point) (1+ (point)) 'face 'bold))
1824 (gnus-article-hide-text-type
1825 (1- (point)) (1+ (point)) 'overstrike)
1827 (- (point) 2) (1- (point)) 'face 'underline))
1829 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1831 (point) (1+ (point)) 'face 'underline)))))))))
1833 (defun gnus-article-treat-unfold-headers ()
1834 "Unfold folded message headers.
1835 Only the headers that fit into the current window width will be
1838 (gnus-with-article-headers
1842 (mail-header-narrow-to-field)
1843 (let ((header (buffer-string)))
1846 (goto-char (point-min))
1847 (while (re-search-forward "\n[\t ]" nil t)
1848 (replace-match " " t t)))
1849 (setq length (- (point-max) (point-min) 1)))
1850 (when (< length (window-width))
1851 (while (re-search-forward "\n[\t ]" nil t)
1852 (replace-match " " t t)))
1853 (goto-char (point-max)))))))
1855 (defun gnus-article-treat-fold-headers ()
1856 "Fold message headers."
1858 (gnus-with-article-headers
1861 (mail-header-narrow-to-field)
1862 (mail-header-fold-field)
1863 (goto-char (point-max))))))
1865 (defun gnus-treat-smiley ()
1866 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1868 (gnus-with-article-buffer
1869 (if (memq 'smiley gnus-article-wash-types)
1870 (gnus-delete-images 'smiley)
1872 (let ((images (smiley-region (point) (point-max))))
1874 (gnus-add-wash-type 'smiley)
1875 (dolist (image images)
1876 (gnus-add-image 'smiley image)))))))
1878 (defun gnus-article-remove-images ()
1879 "Remove all images from the article buffer."
1881 (gnus-with-article-buffer
1882 (dolist (elem gnus-article-image-alist)
1883 (gnus-delete-images (car elem)))))
1885 (defun gnus-article-treat-fold-newsgroups ()
1886 "Unfold folded message headers.
1887 Only the headers that fit into the current window width will be
1890 (gnus-with-article-headers
1891 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1893 (mail-header-narrow-to-field)
1894 (while (re-search-forward ", *" nil t)
1895 (replace-match ", " t t))
1896 (mail-header-fold-field)
1897 (goto-char (point-max))))))
1899 (defun gnus-article-treat-body-boundary ()
1900 "Place a boundary line at the end of the headers."
1902 (when (and gnus-body-boundary-delimiter
1903 (> (length gnus-body-boundary-delimiter) 0))
1904 (gnus-with-article-headers
1905 (goto-char (point-max))
1906 (let ((start (point)))
1907 (insert "X-Boundary: ")
1908 (gnus-add-text-properties start (point) '(invisible t intangible t))
1910 (while (>= (1- (window-width)) (length str))
1911 (setq str (concat str gnus-body-boundary-delimiter)))
1912 (substring str 0 (1- (window-width))))
1914 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1916 (defun article-fill-long-lines ()
1917 "Fill lines that are wider than the window width."
1920 (let ((buffer-read-only nil)
1921 (width (window-width (get-buffer-window (current-buffer)))))
1924 (let ((adaptive-fill-mode nil)) ;Why? -sm
1927 (when (>= (current-column) (min fill-column width))
1928 (narrow-to-region (min (1+ (point)) (point-max))
1929 (gnus-point-at-bol))
1930 (let ((goback (point-marker)))
1931 (fill-paragraph nil)
1932 (goto-char (marker-position goback)))
1934 (forward-line 1)))))))
1936 (defun article-capitalize-sentences ()
1937 "Capitalize the first word in each sentence."
1940 (let ((buffer-read-only nil)
1941 (paragraph-start "^[\n\^L]"))
1945 (forward-sentence)))))
1947 (defun article-remove-cr ()
1948 "Remove trailing CRs and then translate remaining CRs into LFs."
1951 (let ((buffer-read-only nil))
1952 (goto-char (point-min))
1953 (while (re-search-forward "\r+$" nil t)
1954 (replace-match "" t t))
1955 (goto-char (point-min))
1956 (while (search-forward "\r" nil t)
1957 (replace-match "\n" t t)))))
1959 (defun article-remove-trailing-blank-lines ()
1960 "Remove all trailing blank lines from the article."
1963 (let ((buffer-read-only nil))
1964 (goto-char (point-max))
1968 (while (and (not (bobp))
1969 (looking-at "^[ \t]*$")
1970 (not (gnus-annotation-in-region-p
1971 (point) (gnus-point-at-eol))))
1976 (defun article-display-face ()
1977 "Display any Face headers in the header."
1979 (gnus-with-article-headers
1980 (let ((face (message-fetch-field "face")))
1982 (let ((png (gnus-convert-face-to-png face))
1985 (setq image (gnus-create-image png 'png t))
1986 (gnus-article-goto-header "from")
1988 (insert "From: [no `from' set]\n")
1990 (gnus-add-wash-type 'face)
1991 (gnus-add-image 'face image)
1992 (gnus-put-image image)))))))
1994 (defun article-display-x-face (&optional force)
1995 "Look for an X-Face header and display it if present."
1996 (interactive (list 'force))
1997 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1998 (gnus-with-article-headers
1999 ;; Delete the old process, if any.
2000 (when (process-status "article-x-face")
2001 (delete-process "article-x-face"))
2002 (if (memq 'xface gnus-article-wash-types)
2003 ;; We have already displayed X-Faces, so we remove them
2005 (gnus-delete-images 'xface)
2007 (let (x-faces from face)
2009 (when (and wash-face-p
2011 (goto-char (point-min))
2012 (not (re-search-forward
2013 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2014 (gnus-buffer-live-p gnus-original-article-buffer))
2015 ;; If type `W f', use gnus-original-article-buffer,
2016 ;; otherwise use the current buffer because displaying
2017 ;; RFC822 parts calls this function too.
2018 (set-buffer gnus-original-article-buffer))
2020 (mail-narrow-to-head)
2021 (while (gnus-article-goto-header "X-Face")
2022 (push (mail-header-field-value) x-faces))
2023 (setq from (message-fetch-field "from"))))
2024 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2025 ;; single external face.
2026 (when (stringp gnus-article-x-face-command)
2027 (setq x-faces (list (car x-faces))))
2028 (while (and (setq face (pop x-faces))
2029 gnus-article-x-face-command
2031 ;; Check whether this face is censored.
2032 (not gnus-article-x-face-too-ugly)
2033 (and gnus-article-x-face-too-ugly from
2034 (not (string-match gnus-article-x-face-too-ugly
2036 ;; We display the face.
2037 (if (symbolp gnus-article-x-face-command)
2038 ;; The command is a lisp function, so we call it.
2039 (if (functionp gnus-article-x-face-command)
2040 (funcall gnus-article-x-face-command face)
2041 (error "%s is not a function" gnus-article-x-face-command))
2042 ;; The command is a string, so we interpret the command
2043 ;; as a, well, command, and fork it off.
2044 (let ((process-connection-type nil))
2045 (process-kill-without-query
2047 "article-x-face" nil shell-file-name shell-command-switch
2048 gnus-article-x-face-command))
2051 (process-send-region "article-x-face"
2052 (point-min) (point-max)))
2053 (process-send-eof "article-x-face")))))))))
2055 (defun article-decode-mime-words ()
2056 "Decode all MIME-encoded words in the article."
2059 (set-buffer gnus-article-buffer)
2060 (let ((inhibit-point-motion-hooks t)
2062 (mail-parse-charset gnus-newsgroup-charset)
2063 (mail-parse-ignored-charsets
2064 (save-excursion (set-buffer gnus-summary-buffer)
2065 gnus-newsgroup-ignored-charsets)))
2066 (mail-decode-encoded-word-region (point-min) (point-max)))))
2068 (defun article-decode-charset (&optional prompt)
2069 "Decode charset-encoded text in the article.
2070 If PROMPT (the prefix), prompt for a coding system to use."
2072 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2074 (mail-parse-charset gnus-newsgroup-charset)
2075 (mail-parse-ignored-charsets
2076 (save-excursion (condition-case nil
2077 (set-buffer gnus-summary-buffer)
2079 gnus-newsgroup-ignored-charsets))
2080 ct cte ctl charset format)
2083 (article-narrow-to-head)
2084 (setq ct (message-fetch-field "Content-Type" t)
2085 cte (message-fetch-field "Content-Transfer-Encoding" t)
2086 ctl (and ct (ignore-errors
2087 (mail-header-parse-content-type ct)))
2090 (mm-read-coding-system "Charset to decode: "))
2092 (mail-content-type-get ctl 'charset)))
2093 format (and ctl (mail-content-type-get ctl 'format)))
2095 (setq cte (mail-header-strip cte)))
2096 (if (and ctl (not (string-match "/" (car ctl))))
2098 (goto-char (point-max)))
2101 (narrow-to-region (point) (point-max))
2102 (when (and (eq mail-parse-charset 'gnus-decoded)
2103 (eq (mm-body-7-or-8) '8bit))
2104 ;; The text code could have been decoded.
2105 (setq charset mail-parse-charset))
2106 (when (and (or (not ctl)
2107 (equal (car ctl) "text/plain"))
2108 (not format)) ;; article with format will decode later.
2110 charset (and cte (intern (downcase
2111 (gnus-strip-whitespace cte))))
2114 (defun article-decode-encoded-words ()
2115 "Remove encoded-word encoding from headers."
2116 (let ((inhibit-point-motion-hooks t)
2117 (mail-parse-charset gnus-newsgroup-charset)
2118 (mail-parse-ignored-charsets
2119 (save-excursion (condition-case nil
2120 (set-buffer gnus-summary-buffer)
2122 gnus-newsgroup-ignored-charsets))
2125 (article-narrow-to-head)
2126 (funcall gnus-decode-header-function (point-min) (point-max)))))
2128 (defun article-decode-group-name ()
2129 "Decode group names in `Newsgroups:'."
2130 (let ((inhibit-point-motion-hooks t)
2132 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2133 (when (and (or gnus-group-name-charset-method-alist
2134 gnus-group-name-charset-group-alist)
2135 (gnus-buffer-live-p gnus-original-article-buffer))
2137 (article-narrow-to-head)
2138 (with-current-buffer gnus-original-article-buffer
2139 (goto-char (point-min)))
2140 (while (re-search-forward
2141 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2142 (replace-match (save-match-data
2143 (gnus-decode-newsgroups
2144 ;; XXX how to use data in article buffer?
2145 (with-current-buffer gnus-original-article-buffer
2147 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2150 gnus-newsgroup-name method))
2152 (goto-char (point-min))
2153 (with-current-buffer gnus-original-article-buffer
2154 (goto-char (point-min)))
2155 (while (re-search-forward
2156 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2157 (replace-match (save-match-data
2158 (gnus-decode-newsgroups
2159 ;; XXX how to use data in article buffer?
2160 (with-current-buffer gnus-original-article-buffer
2162 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2165 gnus-newsgroup-name method))
2168 (autoload 'idna-to-unicode "idna")
2170 (defun article-decode-idna-rhs ()
2171 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2174 (let ((inhibit-point-motion-hooks t)
2176 (article-narrow-to-head)
2177 (goto-char (point-min))
2178 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2180 (when (save-match-data
2181 (and (setq ace (match-string 1))
2183 (and (re-search-backward "^[^ \t]" nil t)
2184 (looking-at "From\\|To\\|Cc")))
2185 (save-excursion (backward-char)
2186 (message-idna-inside-rhs-p))
2187 (setq unicode (idna-to-unicode ace))))
2188 (unless (string= ace unicode)
2189 (replace-match unicode nil nil nil 1)))))))))
2191 (defun article-de-quoted-unreadable (&optional force read-charset)
2192 "Translate a quoted-printable-encoded article.
2193 If FORCE, decode the article whether it is marked as quoted-printable
2195 If READ-CHARSET, ask for a coding system."
2196 (interactive (list 'force current-prefix-arg))
2198 (let ((buffer-read-only nil) type charset)
2199 (if (gnus-buffer-live-p gnus-original-article-buffer)
2200 (with-current-buffer gnus-original-article-buffer
2202 (gnus-fetch-field "content-transfer-encoding"))
2203 (let* ((ct (gnus-fetch-field "content-type"))
2206 (mail-header-parse-content-type ct)))))
2207 (setq charset (and ctl
2208 (mail-content-type-get ctl 'charset)))
2209 (if (stringp charset)
2210 (setq charset (intern (downcase charset)))))))
2212 (setq charset (mm-read-coding-system "Charset: " charset)))
2214 (setq charset gnus-newsgroup-charset))
2216 (and type (let ((case-fold-search t))
2217 (string-match "quoted-printable" type))))
2219 (quoted-printable-decode-region
2220 (point) (point-max) (mm-charset-to-coding-system charset))))))
2222 (defun article-de-base64-unreadable (&optional force read-charset)
2223 "Translate a base64 article.
2224 If FORCE, decode the article whether it is marked as base64 not.
2225 If READ-CHARSET, ask for a coding system."
2226 (interactive (list 'force current-prefix-arg))
2228 (let ((buffer-read-only nil) type charset)
2229 (if (gnus-buffer-live-p gnus-original-article-buffer)
2230 (with-current-buffer gnus-original-article-buffer
2232 (gnus-fetch-field "content-transfer-encoding"))
2233 (let* ((ct (gnus-fetch-field "content-type"))
2236 (mail-header-parse-content-type ct)))))
2237 (setq charset (and ctl
2238 (mail-content-type-get ctl 'charset)))
2239 (if (stringp charset)
2240 (setq charset (intern (downcase charset)))))))
2242 (setq charset (mm-read-coding-system "Charset: " charset)))
2244 (setq charset gnus-newsgroup-charset))
2246 (and type (let ((case-fold-search t))
2247 (string-match "base64" type))))
2250 (narrow-to-region (point) (point-max))
2251 (base64-decode-region (point-min) (point-max))
2252 (mm-decode-coding-region
2253 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2258 (defun article-decode-HZ ()
2259 "Translate a HZ-encoded article."
2263 (let ((buffer-read-only nil))
2264 (rfc1843-decode-region (point-min) (point-max)))))
2266 (defun article-unsplit-urls ()
2267 "Remove the newlines that some other mailers insert into URLs."
2270 (let ((buffer-read-only nil))
2271 (goto-char (point-min))
2272 (while (re-search-forward
2273 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2274 (replace-match "\\1\\3" t)))
2275 (when (and gnus-display-mime-function (interactive-p))
2276 (funcall gnus-display-mime-function))))
2279 (defun article-wash-html (&optional read-charset)
2280 "Format an HTML article.
2281 If READ-CHARSET, ask for a coding system."
2284 (let ((buffer-read-only nil)
2286 (when (gnus-buffer-live-p gnus-original-article-buffer)
2287 (with-current-buffer gnus-original-article-buffer
2288 (let* ((ct (gnus-fetch-field "content-type"))
2291 (mail-header-parse-content-type ct)))))
2292 (setq charset (and ctl
2293 (mail-content-type-get ctl 'charset)))
2294 (when (stringp charset)
2295 (setq charset (intern (downcase charset)))))))
2297 (setq charset (mm-read-coding-system "Charset: " charset)))
2299 (setq charset gnus-newsgroup-charset))
2301 (save-window-excursion
2303 (narrow-to-region (point) (point-max))
2304 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2305 (entry (assq func mm-text-html-washer-alist)))
2307 (setq func (cdr entry)))
2312 (apply (car func) (cdr func))))))))))
2314 (defun gnus-article-wash-html-with-w3 ()
2315 "Wash the current buffer with w3."
2317 (let ((w3-strict-width (window-width))
2318 (url-standalone-mode t)
2319 (url-gateway-unplugged t)
2320 (w3-honor-stylesheets nil))
2322 (w3-region (point-min) (point-max))
2325 (defun gnus-article-wash-html-with-w3m ()
2326 "Wash the current buffer with emacs-w3m."
2329 (narrow-to-region (point) (point-max))
2330 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2333 w3m-force-redisplay)
2334 (w3m-region (point-min) (point-max)))
2335 (when mm-inline-text-html-with-w3m-keymap
2336 (add-text-properties
2337 (point-min) (point-max)
2338 (nconc (mm-w3m-local-map-property)
2339 '(mm-inline-text-html-with-w3m t))))))
2341 (defun article-hide-list-identifiers ()
2342 "Remove list identifies from the Subject header.
2343 The `gnus-list-identifiers' variable specifies what to do."
2345 (let ((inhibit-point-motion-hooks t)
2346 (regexp (if (consp gnus-list-identifiers)
2347 (mapconcat 'identity gnus-list-identifiers " *\\|")
2348 gnus-list-identifiers))
2353 (article-narrow-to-head)
2354 (goto-char (point-min))
2355 (while (re-search-forward
2356 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2358 (delete-region (match-beginning 2) (match-end 0))
2359 (beginning-of-line))
2360 (when (re-search-forward
2361 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2362 (delete-region (match-beginning 1) (match-end 1))))))))
2364 (defun article-hide-pem (&optional arg)
2365 "Toggle hiding of any PEM headers and signatures in the current article.
2366 If given a negative prefix, always show; if given a positive prefix,
2368 (interactive (gnus-article-hidden-arg))
2369 (unless (gnus-article-check-hidden-text 'pem arg)
2371 (let (buffer-read-only end)
2372 (goto-char (point-min))
2373 ;; Hide the horrendously ugly "header".
2374 (when (and (search-forward
2375 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2377 (setq end (1+ (match-beginning 0))))
2378 (gnus-add-wash-type 'pem)
2379 (gnus-article-hide-text-type
2381 (if (search-forward "\n\n" nil t)
2385 ;; Hide the trailer as well
2386 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2388 (gnus-article-hide-text-type
2389 (match-beginning 0) (match-end 0) 'pem)))))))
2391 (defun article-strip-banner ()
2392 "Strip the banners specified by the `banner' group parameter and by
2393 `gnus-article-address-banner-alist'."
2397 (let ((inhibit-point-motion-hooks t))
2398 (when (gnus-parameter-banner gnus-newsgroup-name)
2399 (article-really-strip-banner
2400 (gnus-parameter-banner gnus-newsgroup-name)))
2401 (when gnus-article-address-banner-alist
2402 (article-really-strip-banner
2403 (let ((from (save-restriction
2405 (article-narrow-to-head)
2406 (mail-fetch-field "from"))))
2409 (caar (mail-header-parse-addresses from))))
2411 (dolist (pair gnus-article-address-banner-alist)
2412 (when (string-match (car pair) from)
2413 (throw 'found (cdr pair)))))))))))))
2415 (defun article-really-strip-banner (banner)
2416 "Strip the banner specified by the argument."
2419 (let ((inhibit-point-motion-hooks t)
2420 (gnus-signature-limit nil)
2424 ((eq banner 'signature)
2425 (when (gnus-article-narrow-to-signature)
2428 (delete-region (point) (point-max))))
2430 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2431 (while (re-search-forward banner nil t)
2432 (delete-region (match-beginning 0) (match-end 0)))))
2434 (while (re-search-forward banner nil t)
2435 (delete-region (match-beginning 0) (match-end 0)))))))))
2437 (defun article-babel ()
2438 "Translate article using an online translation service."
2442 (set-buffer gnus-article-buffer)
2443 (when (article-goto-body)
2444 (let* ((buffer-read-only nil)
2447 (orig (buffer-substring start end))
2448 (trans (babel-as-string orig)))
2450 (narrow-to-region start end)
2451 (delete-region start end)
2454 (defun article-hide-signature (&optional arg)
2455 "Hide the signature in the current article.
2456 If given a negative prefix, always show; if given a positive prefix,
2458 (interactive (gnus-article-hidden-arg))
2459 (unless (gnus-article-check-hidden-text 'signature arg)
2462 (let ((buffer-read-only nil))
2463 (when (gnus-article-narrow-to-signature)
2464 (gnus-article-hide-text-type
2465 (point-min) (point-max) 'signature))))))
2466 (gnus-set-mode-line 'article))
2468 (defun article-strip-headers-in-body ()
2469 "Strip offensive headers from bodies."
2473 (let ((case-fold-search t))
2474 (when (looking-at "x-no-archive:")
2475 (gnus-delete-line)))))
2477 (defun article-strip-leading-blank-lines ()
2478 "Remove all blank lines from the beginning of the article."
2481 (let ((inhibit-point-motion-hooks t)
2483 (when (article-goto-body)
2484 (while (and (not (eobp))
2485 (looking-at "[ \t]*$"))
2486 (gnus-delete-line))))))
2488 (defun article-narrow-to-head ()
2489 "Narrow the buffer to the head of the message.
2490 Point is left at the beginning of the narrowed-to region."
2492 (goto-char (point-min))
2493 (if (search-forward "\n\n" nil 1)
2496 (goto-char (point-min)))
2498 (defun article-goto-body ()
2499 "Place point at the start of the body."
2500 (goto-char (point-min))
2502 ;; This variable is only bound when dealing with separate
2504 (article-goto-body-goes-to-point-min-p
2506 ((search-forward "\n\n" nil t)
2509 (goto-char (point-max))
2512 (defun article-strip-multiple-blank-lines ()
2513 "Replace consecutive blank lines with one empty line."
2516 (let ((inhibit-point-motion-hooks t)
2518 ;; First make all blank lines empty.
2520 (while (re-search-forward "^[ \t]+$" nil t)
2521 (unless (gnus-annotation-in-region-p
2522 (match-beginning 0) (match-end 0))
2523 (replace-match "" nil t)))
2524 ;; Then replace multiple empty lines with a single empty line.
2526 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2527 (unless (gnus-annotation-in-region-p
2528 (match-beginning 0) (match-end 0))
2529 (delete-region (match-beginning 1) (match-end 1)))))))
2531 (defun article-strip-leading-space ()
2532 "Remove all white space from the beginning of the lines in the article."
2535 (let ((inhibit-point-motion-hooks t)
2538 (while (re-search-forward "^[ \t]+" nil t)
2539 (replace-match "" t t)))))
2541 (defun article-strip-trailing-space ()
2542 "Remove all white space from the end of the lines in the article."
2545 (let ((inhibit-point-motion-hooks t)
2548 (while (re-search-forward "[ \t]+$" nil t)
2549 (replace-match "" t t)))))
2551 (defun article-strip-blank-lines ()
2552 "Strip leading, trailing and multiple blank lines."
2554 (article-strip-leading-blank-lines)
2555 (article-remove-trailing-blank-lines)
2556 (article-strip-multiple-blank-lines))
2558 (defun article-strip-all-blank-lines ()
2559 "Strip all blank lines."
2562 (let ((inhibit-point-motion-hooks t)
2565 (while (re-search-forward "^[ \t]*\n" nil t)
2566 (replace-match "" t t)))))
2568 (defun gnus-article-narrow-to-signature ()
2569 "Narrow to the signature; return t if a signature is found, else nil."
2570 (let ((inhibit-point-motion-hooks t))
2571 (when (gnus-article-search-signature)
2573 ;; Check whether we have some limits to what we consider
2574 ;; to be a signature.
2575 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2576 (list gnus-signature-limit)))
2578 (while (setq limit (pop limits))
2579 (if (or (and (integerp limit)
2580 (< (- (point-max) (point)) limit))
2582 (< (count-lines (point) (point-max)) limit))
2583 (and (functionp limit)
2585 (and (stringp limit)
2586 (not (re-search-forward limit nil t))))
2587 () ; This limit did not succeed.
2591 (narrow-to-region (point) (point-max))
2594 (defun gnus-article-search-signature ()
2595 "Search the current buffer for the signature separator.
2596 Put point at the beginning of the signature separator."
2597 (let ((cur (point)))
2598 (goto-char (point-max))
2599 (if (if (stringp gnus-signature-separator)
2600 (re-search-backward gnus-signature-separator nil t)
2601 (let ((seps gnus-signature-separator))
2603 (not (re-search-backward (car seps) nil t)))
2610 (defun gnus-article-hidden-arg ()
2611 "Return the current prefix arg as a number, or 0 if no prefix."
2612 (list (if current-prefix-arg
2613 (prefix-numeric-value current-prefix-arg)
2616 (defun gnus-article-check-hidden-text (type arg)
2617 "Return nil if hiding is necessary.
2618 Arg can be nil or a number. nil and positive means hide, negative
2619 means show, 0 means toggle."
2622 (let ((hide (gnus-article-hidden-text-p type)))
2628 (gnus-article-show-hidden-text type)
2631 (if (eq hide 'hidden)
2633 (gnus-article-show-hidden-text type)
2637 (defun gnus-article-hidden-text-p (type)
2638 "Say whether the current buffer contains hidden text of type TYPE."
2639 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2641 (not (get-text-property pos 'invisible))
2642 (not (get-text-property pos 'dummy-invisible)))
2644 (text-property-any (1+ pos) (point-max) 'article-type type)))
2649 (defun gnus-article-show-hidden-text (type &optional dummy)
2650 "Show all hidden text of type TYPE.
2651 Originally it is hide instead of DUMMY."
2652 (let ((buffer-read-only nil)
2653 (inhibit-point-motion-hooks t))
2654 (gnus-remove-text-properties-when
2656 (point-min) (point-max)
2657 (cons 'article-type (cons type
2658 gnus-hidden-properties)))
2659 (gnus-delete-wash-type type)))
2661 (defconst article-time-units
2662 `((year . ,(* 365.25 24 60 60))
2663 (week . ,(* 7 24 60 60))
2664 (day . ,(* 24 60 60))
2668 "Mapping from time units to seconds.")
2670 (defun gnus-article-forward-header ()
2671 "Move point to the start of the next header.
2672 If the current header is a continuation header, this can be several
2677 (if (looking-at "[ \t]+[^ \t]")
2681 (defun article-date-ut (&optional type highlight header)
2682 "Convert DATE date to universal time in the current article.
2683 If TYPE is `local', convert to local time; if it is `lapsed', output
2684 how much time has lapsed since DATE. For `lapsed', the value of
2685 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2686 should replace the \"Date:\" one, or should be added below it."
2687 (interactive (list 'ut t))
2688 (let* ((header (or header
2689 (message-fetch-field "date")
2691 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2694 ((not gnus-article-date-lapsed-new-header)
2700 (date (if (vectorp header) (mail-header-date header)
2702 (inhibit-point-motion-hooks t)
2707 (article-narrow-to-head)
2708 (when (re-search-forward tdate-regexp nil t)
2709 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2710 date (or (get-text-property (gnus-point-at-bol)
2713 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2715 (when (and date (not (string= date "")))
2716 (goto-char (point-min))
2717 (let ((buffer-read-only nil))
2718 ;; Delete any old Date headers.
2719 (while (re-search-forward date-regexp nil t)
2721 (delete-region (progn (beginning-of-line) (point))
2722 (progn (gnus-article-forward-header)
2724 (delete-region (progn (beginning-of-line) (point))
2725 (progn (gnus-article-forward-header)
2728 (setq pos (point))))
2729 (when (and (not pos)
2730 (re-search-forward tdate-regexp nil t))
2734 (insert (article-make-date-line date (or type 'ut)))
2740 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2741 (put-text-property (match-beginning 1) (1+ (match-end 1))
2742 'original-date date)
2743 (put-text-property (match-beginning 1) (1+ (match-end 1))
2745 (put-text-property (match-beginning 2) (match-end 2)
2748 (defun article-make-date-line (date type)
2749 "Return a DATE line of TYPE."
2750 (unless (memq type '(local ut original user iso8601 lapsed english))
2751 (error "Unknown conversion type: %s" type))
2753 (let ((time (date-to-time date)))
2755 ;; Convert to the local timezone.
2757 (let ((tz (car (current-time-zone time))))
2758 (format "Date: %s %s%02d%02d" (current-time-string time)
2759 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2760 (/ (% (abs tz) 3600) 60))))
2761 ;; Convert to Universal Time.
2764 (current-time-string
2765 (let* ((e (parse-time-string date))
2766 (tm (apply 'encode-time e))
2768 (ls (- (cadr tm) (car (current-time-zone time)))))
2769 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2770 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2773 ;; Get the original date from the article.
2774 ((eq type 'original)
2775 (concat "Date: " (if (string-match "\n+$" date)
2776 (substring date 0 (match-beginning 0))
2778 ;; Let the user define the format.
2780 (let ((format (or (condition-case nil
2781 (with-current-buffer gnus-summary-buffer
2782 gnus-article-time-format)
2784 gnus-article-time-format)))
2785 (if (functionp format)
2786 (funcall format time)
2787 (concat "Date: " (format-time-string format time)))))
2790 (let ((tz (car (current-time-zone time))))
2793 (format-time-string "%Y%m%dT%H%M%S" time)
2794 (format "%s%02d%02d"
2795 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2796 (/ (% (abs tz) 3600) 60)))))
2797 ;; Do an X-Sent lapsed format.
2799 ;; If the date is seriously mangled, the timezone functions are
2800 ;; liable to bug out, so we ignore all errors.
2801 (let* ((now (current-time))
2802 (real-time (subtract-time now time))
2803 (real-sec (and real-time
2804 (+ (* (float (car real-time)) 65536)
2806 (sec (and real-time (abs real-sec)))
2816 ;; This is a bit convoluted, but basically we go
2817 ;; through the time units for years, weeks, etc,
2818 ;; and divide things to see whether that results
2819 ;; in positive answers.
2822 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2823 ;; The (remaining) seconds are too few to
2824 ;; be divided into this time unit.
2826 ;; It's big enough, so we output it.
2827 (setq sec (- sec (* num (cdr unit))))
2829 (concat (if prev ", " "") (int-to-string
2831 " " (symbol-name (car unit))
2832 (if (> num 1) "s" ""))
2834 article-time-units "")
2835 ;; If dates are odd, then it might appear like the
2836 ;; article was sent in the future.
2839 " in the future"))))))
2840 ;; Display the date in proper English
2842 (let ((dtime (decode-time time)))
2845 (number-to-string (nth 3 dtime))
2846 (let ((digit (% (nth 3 dtime) 10)))
2848 ((memq (nth 3 dtime) '(11 12 13)) "th")
2854 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2856 (number-to-string (nth 5 dtime))
2858 (format "%02d" (nth 2 dtime))
2860 (format "%02d" (nth 1 dtime)))))))
2862 (format "Date: %s (from Gnus)" date))))
2864 (defun article-date-local (&optional highlight)
2865 "Convert the current article date to the local timezone."
2866 (interactive (list t))
2867 (article-date-ut 'local highlight))
2869 (defun article-date-english (&optional highlight)
2870 "Convert the current article date to something that is proper English."
2871 (interactive (list t))
2872 (article-date-ut 'english highlight))
2874 (defun article-date-original (&optional highlight)
2875 "Convert the current article date to what it was originally.
2876 This is only useful if you have used some other date conversion
2877 function and want to see what the date was before converting."
2878 (interactive (list t))
2879 (article-date-ut 'original highlight))
2881 (defun article-date-lapsed (&optional highlight)
2882 "Convert the current article date to time lapsed since it was sent."
2883 (interactive (list t))
2884 (article-date-ut 'lapsed highlight))
2886 (defun article-update-date-lapsed ()
2887 "Function to be run from a timer to update the lapsed time line."
2888 (let (deactivate-mark)
2893 (set-buffer (window-buffer w))
2894 (when (eq major-mode 'gnus-article-mode)
2895 (goto-char (point-min))
2896 (when (re-search-forward "^X-Sent:" nil t)
2897 (article-date-lapsed t))))
2900 (defun gnus-start-date-timer (&optional n)
2901 "Start a timer to update the X-Sent header in the article buffers.
2902 The numerical prefix says how frequently (in seconds) the function
2907 (gnus-stop-date-timer)
2908 (setq article-lapsed-timer
2909 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2911 (defun gnus-stop-date-timer ()
2912 "Stop the X-Sent timer."
2914 (when article-lapsed-timer
2915 (nnheader-cancel-timer article-lapsed-timer)
2916 (setq article-lapsed-timer nil)))
2918 (defun article-date-user (&optional highlight)
2919 "Convert the current article date to the user-defined format.
2920 This format is defined by the `gnus-article-time-format' variable."
2921 (interactive (list t))
2922 (article-date-ut 'user highlight))
2924 (defun article-date-iso8601 (&optional highlight)
2925 "Convert the current article date to ISO8601."
2926 (interactive (list t))
2927 (article-date-ut 'iso8601 highlight))
2929 ;; (defun article-show-all ()
2930 ;; "Show all hidden text in the article buffer."
2933 ;; (let ((buffer-read-only nil))
2934 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2936 (defun article-remove-leading-whitespace ()
2937 "Remove excessive whitespace from all headers."
2941 (let ((buffer-read-only nil))
2942 (article-narrow-to-head)
2943 (goto-char (point-min))
2944 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2945 (delete-region (match-beginning 1) (match-end 1)))))))
2947 (defun article-emphasize (&optional arg)
2948 "Emphasize text according to `gnus-emphasis-alist'."
2949 (interactive (gnus-article-hidden-arg))
2950 (unless (gnus-article-check-hidden-text 'emphasis arg)
2954 (with-current-buffer gnus-summary-buffer
2955 gnus-article-emphasis-alist)
2957 gnus-emphasis-alist))
2958 (buffer-read-only nil)
2959 (props (append '(article-type emphasis)
2960 gnus-hidden-properties))
2961 regexp elem beg invisible visible face)
2964 (while (setq elem (pop alist))
2966 (setq regexp (car elem)
2967 invisible (nth 1 elem)
2968 visible (nth 2 elem)
2970 (while (re-search-forward regexp nil t)
2971 (when (and (match-beginning visible) (match-beginning invisible))
2972 (gnus-article-hide-text
2973 (match-beginning invisible) (match-end invisible) props)
2974 (gnus-article-unhide-text-type
2975 (match-beginning visible) (match-end visible) 'emphasis)
2976 (gnus-put-overlay-excluding-newlines
2977 (match-beginning visible) (match-end visible) 'face face)
2978 (gnus-add-wash-type 'emphasis)
2979 (goto-char (match-end invisible)))))))))
2981 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2982 "Setup newsgroup emphasis alist."
2983 (unless gnus-article-emphasis-alist
2984 (let ((name (and gnus-newsgroup-name
2985 (gnus-group-real-name gnus-newsgroup-name))))
2986 (make-local-variable 'gnus-article-emphasis-alist)
2987 (setq gnus-article-emphasis-alist
2989 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2990 (while (setq elem (pop alist))
2991 (when (and name (string-match (car elem) name))
2993 highlight (copy-sequence (cdr elem)))))
2995 (copy-sequence highlight-words)
2996 (if gnus-newsgroup-name
2997 (copy-sequence (gnus-group-find-parameter
2998 gnus-newsgroup-name 'highlight-words t)))
2999 gnus-emphasis-alist)))))
3002 (defvar gnus-summary-article-menu)
3003 (defvar gnus-summary-post-menu))
3005 ;;; Saving functions.
3007 (defun gnus-article-save (save-buffer file &optional num)
3008 "Save the currently selected article."
3009 (unless gnus-save-all-headers
3010 ;; Remove headers according to `gnus-saved-headers'.
3011 (let ((gnus-visible-headers
3012 (or gnus-saved-headers gnus-visible-headers))
3013 (gnus-article-buffer save-buffer))
3015 (set-buffer save-buffer)
3016 (article-hide-headers 1 t))))
3017 (save-window-excursion
3018 (if (not gnus-default-article-saver)
3019 (error "No default saver is defined")
3020 ;; !!! Magic! The saving functions all save
3021 ;; `gnus-save-article-buffer' (or so they think), but we
3022 ;; bind that variable to our save-buffer.
3023 (set-buffer gnus-article-buffer)
3024 (let* ((gnus-save-article-buffer save-buffer)
3027 ((not gnus-prompt-before-saving) 'default)
3028 ((eq gnus-prompt-before-saving 'always) nil)
3030 (gnus-number-of-articles-to-be-saved
3031 (when (eq gnus-prompt-before-saving t)
3033 (set-buffer gnus-article-current-summary)
3034 (funcall gnus-default-article-saver filename)))))
3036 (defun gnus-read-save-file-name (prompt &optional filename
3037 function group headers variable)
3039 (funcall function group headers (symbol-value variable)))
3044 ((eq filename 'default)
3050 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3053 (if (and gnus-number-of-articles-to-be-saved
3054 (> gnus-number-of-articles-to-be-saved 1))
3055 (format "these %d articles"
3056 gnus-number-of-articles-to-be-saved)
3059 ;; Let the split methods have their say.
3061 ;; No split name was found.
3064 (concat prompt " (default "
3065 (file-name-nondirectory default-name) ") ")
3066 (file-name-directory default-name)
3068 ;; A single group name is returned.
3069 ((stringp split-name)
3071 (funcall function split-name headers
3072 (symbol-value variable)))
3074 (concat prompt " (default "
3075 (file-name-nondirectory default-name) ") ")
3076 (file-name-directory default-name)
3078 ;; A single split name was found
3079 ((= 1 (length split-name))
3080 (let* ((name (expand-file-name
3082 gnus-article-save-directory))
3083 (dir (cond ((file-directory-p name)
3084 (file-name-as-directory name))
3085 ((file-exists-p name) name)
3086 (t gnus-article-save-directory))))
3088 (concat prompt " (default " name ") ")
3090 ;; A list of splits was found.
3092 (setq split-name (nreverse split-name))
3094 (let ((file-name-history
3095 (nconc split-name file-name-history)))
3099 (concat prompt " (`M-p' for defaults) ")
3100 gnus-article-save-directory
3102 gnus-article-save-directory)))
3103 (car (push result file-name-history)))))))
3104 ;; Create the directory.
3105 (gnus-make-directory (file-name-directory file))
3106 ;; If we have read a directory, we append the default file name.
3107 (when (file-directory-p file)
3108 (setq file (expand-file-name (file-name-nondirectory
3110 (file-name-as-directory file))))
3111 ;; Possibly translate some characters.
3112 (nnheader-translate-file-chars file))))))
3113 (gnus-make-directory (file-name-directory result))
3114 (set variable result)))
3116 (defun gnus-article-archive-name (group)
3117 "Return the first instance of an \"Archive-name\" in the current buffer."
3118 (let ((case-fold-search t))
3119 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3120 (nnheader-concat gnus-article-save-directory
3121 (match-string 1)))))
3123 (defun gnus-article-nndoc-name (group)
3124 "If GROUP is an nndoc group, return the name of the parent group."
3125 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3126 (gnus-group-get-parameter group 'save-article-group)))
3128 (defun gnus-summary-save-in-rmail (&optional filename)
3129 "Append this article to Rmail file.
3130 Optional argument FILENAME specifies file name.
3131 Directory to save to is default to `gnus-article-save-directory'."
3132 (setq filename (gnus-read-save-file-name
3133 "Save %s in rmail file:" filename
3134 gnus-rmail-save-name gnus-newsgroup-name
3135 gnus-current-headers 'gnus-newsgroup-last-rmail))
3136 (gnus-eval-in-buffer-window gnus-save-article-buffer
3140 (gnus-output-to-rmail filename))))
3143 (defun gnus-summary-save-in-mail (&optional filename)
3144 "Append this article to Unix mail file.
3145 Optional argument FILENAME specifies file name.
3146 Directory to save to is default to `gnus-article-save-directory'."
3147 (setq filename (gnus-read-save-file-name
3148 "Save %s in Unix mail file:" filename
3149 gnus-mail-save-name gnus-newsgroup-name
3150 gnus-current-headers 'gnus-newsgroup-last-mail))
3151 (gnus-eval-in-buffer-window gnus-save-article-buffer
3155 (if (and (file-readable-p filename)
3156 (file-regular-p filename)
3157 (mail-file-babyl-p filename))
3158 (rmail-output-to-rmail-file filename t)
3159 (gnus-output-to-mail filename)))))
3162 (defun gnus-summary-save-in-file (&optional filename overwrite)
3163 "Append this article to file.
3164 Optional argument FILENAME specifies file name.
3165 Directory to save to is default to `gnus-article-save-directory'."
3166 (setq filename (gnus-read-save-file-name
3167 "Save %s in file:" filename
3168 gnus-file-save-name gnus-newsgroup-name
3169 gnus-current-headers 'gnus-newsgroup-last-file))
3170 (gnus-eval-in-buffer-window gnus-save-article-buffer
3174 (when (and overwrite
3175 (file-exists-p filename))
3176 (delete-file filename))
3177 (gnus-output-to-file filename))))
3180 (defun gnus-summary-write-to-file (&optional filename)
3181 "Write this article to a file, overwriting it if the file exists.
3182 Optional argument FILENAME specifies file name.
3183 The directory to save in defaults to `gnus-article-save-directory'."
3184 (gnus-summary-save-in-file nil t))
3186 (defun gnus-summary-save-body-in-file (&optional filename)
3187 "Append this article body to a file.
3188 Optional argument FILENAME specifies file name.
3189 The directory to save in defaults to `gnus-article-save-directory'."
3190 (setq filename (gnus-read-save-file-name
3191 "Save %s body in file:" filename
3192 gnus-file-save-name gnus-newsgroup-name
3193 gnus-current-headers 'gnus-newsgroup-last-file))
3194 (gnus-eval-in-buffer-window gnus-save-article-buffer
3198 (when (article-goto-body)
3199 (narrow-to-region (point) (point-max)))
3200 (gnus-output-to-file filename))))
3203 (defun gnus-summary-save-in-pipe (&optional command)
3204 "Pipe this article to subprocess."
3206 (cond ((and (eq command 'default)
3207 gnus-last-shell-command)
3208 gnus-last-shell-command)
3213 "Shell command on %s: "
3214 (if (and gnus-number-of-articles-to-be-saved
3215 (> gnus-number-of-articles-to-be-saved 1))
3216 (format "these %d articles"
3217 gnus-number-of-articles-to-be-saved)
3219 gnus-last-shell-command))))
3220 (when (string-equal command "")
3221 (if gnus-last-shell-command
3222 (setq command gnus-last-shell-command)
3223 (error "A command is required")))
3224 (gnus-eval-in-buffer-window gnus-article-buffer
3227 (shell-command-on-region (point-min) (point-max) command nil)))
3228 (setq gnus-last-shell-command command))
3230 (defmacro gnus-read-string (prompt &optional initial-contents history
3232 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3233 (if (and (featurep 'xemacs)
3234 (< emacs-minor-version 2))
3235 `(read-string ,prompt ,initial-contents ,history)
3236 `(read-string ,prompt ,initial-contents ,history ,default-value)))
3238 (defun gnus-summary-pipe-to-muttprint (&optional command)
3239 "Pipe this article to muttprint."
3240 (setq command (gnus-read-string
3241 "Print using command: " gnus-summary-muttprint-program
3242 nil gnus-summary-muttprint-program))
3243 (gnus-summary-save-in-pipe command))
3245 ;;; Article file names when saving.
3247 (defun gnus-capitalize-newsgroup (newsgroup)
3248 "Capitalize NEWSGROUP name."
3249 (when (not (zerop (length newsgroup)))
3250 (concat (char-to-string (upcase (aref newsgroup 0)))
3251 (substring newsgroup 1))))
3253 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3254 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3255 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3256 Otherwise, it is like ~/News/news/group/num."
3259 (concat (if (gnus-use-long-file-name 'not-save)
3260 (gnus-capitalize-newsgroup newsgroup)
3261 (gnus-newsgroup-directory-form newsgroup))
3262 "/" (int-to-string (mail-header-number headers)))
3263 gnus-article-save-directory)))
3265 (string-equal (file-name-directory default)
3266 (file-name-directory last-file))
3267 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3269 (or last-file default))))
3271 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3272 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3273 If variable `gnus-use-long-file-name' is non-nil, it is
3274 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3277 (concat (if (gnus-use-long-file-name 'not-save)
3279 (gnus-newsgroup-directory-form newsgroup))
3280 "/" (int-to-string (mail-header-number headers)))
3281 gnus-article-save-directory)))
3283 (string-equal (file-name-directory default)
3284 (file-name-directory last-file))
3285 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3287 (or last-file default))))
3289 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3290 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3291 If variable `gnus-use-long-file-name' is non-nil, it is
3292 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3295 (if (gnus-use-long-file-name 'not-save)
3298 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3300 gnus-article-save-directory)))
3302 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3303 "Generate file name from sender."
3304 (let ((from (mail-header-from headers)))
3306 (if (and from (string-match "\\([^ <]+\\)@" from))
3307 (match-string 1 from)
3309 gnus-article-save-directory)))
3311 (defun article-verify-x-pgp-sig ()
3314 (if (gnus-buffer-live-p gnus-original-article-buffer)
3315 (let ((sig (with-current-buffer gnus-original-article-buffer
3316 (gnus-fetch-field "X-PGP-Sig")))
3320 (mml2015-clear-verify-function))
3322 (insert-buffer-substring gnus-original-article-buffer)
3323 (setq items (split-string sig))
3324 (message-narrow-to-head)
3325 (let ((inhibit-point-motion-hooks t)
3326 (case-fold-search t))
3327 ;; Don't verify multiple headers.
3328 (setq headers (mapconcat (lambda (header)
3330 (mail-fetch-field header)
3332 (split-string (nth 1 items) ",") "")))
3333 (delete-region (point-min) (point-max))
3334 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3335 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3340 (if (looking-at "^-")
3343 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3344 (insert "Version: " (car items) "\n\n")
3345 (insert (mapconcat 'identity (cddr items) "\n"))
3346 (insert "\n-----END PGP SIGNATURE-----\n")
3347 (let ((mm-security-handle (list (format "multipart/signed"))))
3348 (mml2015-clean-buffer)
3349 (let ((coding-system-for-write (or gnus-newsgroup-charset
3351 (funcall (mml2015-clear-verify-function)))
3353 (or (mm-handle-multipart-ctl-parameter
3354 mm-security-handle 'gnus-details)
3355 (mm-handle-multipart-ctl-parameter
3356 mm-security-handle 'gnus-info)))))
3358 (let (buffer-read-only bface eface)
3360 (message-narrow-to-head)
3361 (goto-char (point-max))
3363 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3364 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3365 (message-remove-header "X-Gnus-PGP-Verify")
3366 (if (re-search-forward "^X-PGP-Sig:" nil t)
3368 (goto-char (point-max)))
3369 (narrow-to-region (point) (point))
3370 (insert "X-Gnus-PGP-Verify: " info "\n")
3371 (goto-char (point-min))
3374 (if (not (looking-at "^[ \t]"))
3378 (goto-char (point-min))
3379 (when (looking-at "\\([^:]+\\): *")
3380 (put-text-property (match-beginning 1) (1+ (match-end 1))
3382 (put-text-property (match-end 0) (point-max)
3383 'face eface)))))))))
3385 (defun article-verify-cancel-lock ()
3386 "Verify Cancel-Lock header."
3388 (if (gnus-buffer-live-p gnus-original-article-buffer)
3389 (canlock-verify gnus-original-article-buffer)))
3396 (setq afunc (car func)
3399 gfunc (intern (format "gnus-%s" func))))
3401 (when (fboundp afunc)
3402 `(lambda (&optional interactive &rest args)
3403 ,(documentation afunc t)
3404 (interactive (list t))
3406 (set-buffer gnus-article-buffer)
3408 (call-interactively ',afunc)
3409 (apply ',afunc args))))))))
3410 '(article-hide-headers
3411 article-verify-x-pgp-sig
3412 article-verify-cancel-lock
3413 article-hide-boring-headers
3414 article-treat-overstrike
3415 article-fill-long-lines
3416 article-capitalize-sentences
3418 article-remove-leading-whitespace
3419 article-display-x-face
3420 article-display-face
3421 article-de-quoted-unreadable
3422 article-de-base64-unreadable
3425 article-unsplit-urls
3426 article-hide-list-identifiers
3427 article-strip-banner
3430 article-hide-signature
3431 article-strip-headers-in-body
3432 article-remove-trailing-blank-lines
3433 article-strip-leading-blank-lines
3434 article-strip-multiple-blank-lines
3435 article-strip-leading-space
3436 article-strip-trailing-space
3437 article-strip-blank-lines
3438 article-strip-all-blank-lines
3440 article-date-english
3441 article-date-iso8601
3442 article-date-original
3444 article-decode-mime-words
3445 article-decode-charset
3446 article-decode-encoded-words
3450 article-treat-dumbquotes
3451 article-normalize-headers
3452 ;; (article-show-all . gnus-article-show-all-headers)
3456 ;;; Gnus article mode
3459 (put 'gnus-article-mode 'mode-class 'special)
3461 (set-keymap-parent gnus-article-mode-map widget-keymap)
3463 (gnus-define-keys gnus-article-mode-map
3464 " " gnus-article-goto-next-page
3465 "\177" gnus-article-goto-prev-page
3466 [delete] gnus-article-goto-prev-page
3467 [backspace] gnus-article-goto-prev-page
3468 "\C-c^" gnus-article-refer-article
3469 "h" gnus-article-show-summary
3470 "s" gnus-article-show-summary
3471 "\C-c\C-m" gnus-article-mail
3472 "?" gnus-article-describe-briefly
3473 "e" gnus-summary-edit-article
3474 "<" beginning-of-buffer
3476 "\C-c\C-i" gnus-info-find-node
3478 "R" gnus-article-reply-with-original
3479 "F" gnus-article-followup-with-original
3480 "\C-hk" gnus-article-describe-key
3481 "\C-hc" gnus-article-describe-key-briefly
3483 "\C-d" gnus-article-read-summary-keys
3484 "\M-*" gnus-article-read-summary-keys
3485 "\M-#" gnus-article-read-summary-keys
3486 "\M-^" gnus-article-read-summary-keys
3487 "\M-g" gnus-article-read-summary-keys)
3489 (substitute-key-definition
3490 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3492 (defun gnus-article-make-menu-bar ()
3493 (unless (boundp 'gnus-article-commands-menu)
3494 (gnus-summary-make-menu-bar))
3495 (gnus-turn-off-edit-menu 'article)
3496 (unless (boundp 'gnus-article-article-menu)
3498 gnus-article-article-menu gnus-article-mode-map ""
3500 ["Scroll forwards" gnus-article-goto-next-page t]
3501 ["Scroll backwards" gnus-article-goto-prev-page t]
3502 ["Show summary" gnus-article-show-summary t]
3503 ["Fetch Message-ID at point" gnus-article-refer-article t]
3504 ["Mail to address at point" gnus-article-mail t]
3505 ["Send a bug report" gnus-bug t]))
3508 gnus-article-treatment-menu gnus-article-mode-map ""
3509 ;; Fixme: this should use :active (and maybe :visible).
3511 ["Hide headers" gnus-article-hide-headers t]
3512 ["Hide signature" gnus-article-hide-signature t]
3513 ["Hide citation" gnus-article-hide-citation t]
3514 ["Treat overstrike" gnus-article-treat-overstrike t]
3515 ["Remove carriage return" gnus-article-remove-cr t]
3516 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3517 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3518 ["Remove base64" gnus-article-de-base64-unreadable t]
3519 ["Treat html" gnus-article-wash-html t]
3520 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3521 ["Decode HZ" gnus-article-decode-HZ t]))
3523 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3525 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3527 (gnus-run-hooks 'gnus-article-menu-hook)))
3529 (defun gnus-article-mode ()
3530 "Major mode for displaying an article.
3532 All normal editing commands are switched off.
3534 The following commands are available in addition to all summary mode
3536 \\<gnus-article-mode-map>
3537 \\[gnus-article-next-page]\t Scroll the article one page forwards
3538 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3539 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3540 \\[gnus-article-show-summary]\t Display the summary buffer
3541 \\[gnus-article-mail]\t Send a reply to the address near point
3542 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3543 \\[gnus-info-find-node]\t Go to the Gnus info node"
3545 (gnus-simplify-mode-line)
3546 (setq mode-name "Article")
3547 (setq major-mode 'gnus-article-mode)
3548 (make-local-variable 'minor-mode-alist)
3549 (use-local-map gnus-article-mode-map)
3550 (when (gnus-visual-p 'article-menu 'menu)
3551 (gnus-article-make-menu-bar)
3552 (when gnus-summary-tool-bar-map
3553 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3554 (gnus-update-format-specifications nil 'article-mode)
3555 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3556 (make-local-variable 'gnus-page-broken)
3557 (make-local-variable 'gnus-button-marker-list)
3558 (make-local-variable 'gnus-article-current-summary)
3559 (make-local-variable 'gnus-article-mime-handles)
3560 (make-local-variable 'gnus-article-decoded-p)
3561 (make-local-variable 'gnus-article-mime-handle-alist)
3562 (make-local-variable 'gnus-article-wash-types)
3563 (make-local-variable 'gnus-article-image-alist)
3564 (make-local-variable 'gnus-article-charset)
3565 (make-local-variable 'gnus-article-ignored-charsets)
3566 (gnus-set-default-directory)
3567 (buffer-disable-undo)
3568 (setq buffer-read-only t)
3569 (set-syntax-table gnus-article-mode-syntax-table)
3570 (mm-enable-multibyte)
3571 (gnus-run-hooks 'gnus-article-mode-hook))
3573 (defun gnus-article-setup-buffer ()
3574 "Initialize the article buffer."
3575 (let* ((name (if gnus-single-article-buffer "*Article*"
3576 (concat "*Article " gnus-newsgroup-name "*")))
3578 (progn (string-match "\\*Article" name)
3579 (concat " *Original Article"
3580 (substring name (match-end 0))))))
3581 (setq gnus-article-buffer name)
3582 (setq gnus-original-article-buffer original)
3583 (setq gnus-article-mime-handle-alist nil)
3584 ;; This might be a variable local to the summary buffer.
3585 (unless gnus-single-article-buffer
3587 (set-buffer gnus-summary-buffer)
3588 (setq gnus-article-buffer name)
3589 (setq gnus-original-article-buffer original)
3590 (gnus-set-global-variables)))
3591 (gnus-article-setup-highlight-words)
3592 ;; Init original article buffer.
3594 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3595 (mm-enable-multibyte)
3596 (setq major-mode 'gnus-original-article-mode)
3597 (make-local-variable 'gnus-original-article))
3598 (if (get-buffer name)
3601 (when (and gnus-article-edit-mode
3604 (y-or-n-p "Article mode edit in progress; discard? ")))
3605 (error "Action aborted"))
3606 (set (make-local-variable 'gnus-article-edit-mode) nil)
3607 (when gnus-article-mime-handles
3608 (mm-destroy-parts gnus-article-mime-handles)
3609 (setq gnus-article-mime-handles nil))
3610 ;; Set it to nil in article-buffer!
3611 (setq gnus-article-mime-handle-alist nil)
3612 (buffer-disable-undo)
3613 (setq buffer-read-only t)
3614 ;; This list just keeps growing if we don't reset it.
3615 (setq gnus-button-marker-list nil)
3616 (unless (eq major-mode 'gnus-article-mode)
3617 (gnus-article-mode))
3620 (set-buffer (gnus-get-buffer-create name))
3622 (make-local-variable 'gnus-summary-buffer)
3623 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3624 (current-buffer)))))
3626 ;; Set article window start at LINE, where LINE is the number of lines
3627 ;; from the head of the article.
3628 (defun gnus-article-set-window-start (&optional line)
3630 (gnus-get-buffer-window gnus-article-buffer t)
3632 (set-buffer gnus-article-buffer)
3633 (goto-char (point-min))
3636 (gnus-message 6 "Moved to bookmark")
3637 (search-forward "\n\n" nil t)
3641 (defun gnus-article-prepare (article &optional all-headers header)
3642 "Prepare ARTICLE in article mode buffer.
3643 ARTICLE should either be an article number or a Message-ID.
3644 If ARTICLE is an id, HEADER should be the article headers.
3645 If ALL-HEADERS is non-nil, no headers are hidden."
3647 ;; Make sure we start in a summary buffer.
3648 (unless (eq major-mode 'gnus-summary-mode)
3649 (set-buffer gnus-summary-buffer))
3650 (setq gnus-summary-buffer (current-buffer))
3651 (let* ((gnus-article (if header (mail-header-number header) article))
3652 (summary-buffer (current-buffer))
3653 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3654 (group gnus-newsgroup-name)
3657 (gnus-article-setup-buffer)
3658 (set-buffer gnus-article-buffer)
3659 ;; Deactivate active regions.
3660 (when (and (boundp 'transient-mark-mode)
3661 transient-mark-mode)
3662 (setq mark-active nil))
3663 (if (not (setq result (let ((buffer-read-only nil))
3664 (gnus-request-article-this-buffer
3666 ;; There is no such article.
3668 (when (and (numberp article)
3669 (not (memq article gnus-newsgroup-sparse)))
3670 (setq gnus-article-current
3671 (cons gnus-newsgroup-name article))
3672 (set-buffer gnus-summary-buffer)
3673 (setq gnus-current-article article)
3674 (if (and (memq article gnus-newsgroup-undownloaded)
3675 (not (gnus-online (gnus-find-method-for-group
3676 gnus-newsgroup-name))))
3678 (gnus-summary-set-agent-mark article)
3679 (message "Message marked for downloading"))
3680 (gnus-summary-mark-article article gnus-canceled-mark)
3681 (unless (memq article gnus-newsgroup-sparse)
3682 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3683 (if (or (eq result 'pseudo)
3684 (eq result 'nneething))
3687 (set-buffer summary-buffer)
3688 (push article gnus-newsgroup-history)
3689 (setq gnus-last-article gnus-current-article
3690 gnus-current-article 0
3691 gnus-current-headers nil
3692 gnus-article-current nil)
3693 (if (eq result 'nneething)
3694 (gnus-configure-windows 'summary)
3695 (gnus-configure-windows 'article))
3696 (gnus-set-global-variables))
3697 (let ((gnus-article-mime-handle-alist-1
3698 gnus-article-mime-handle-alist))
3699 (gnus-set-mode-line 'article)))
3700 ;; The result from the `request' was an actual article -
3701 ;; or at least some text that is now displayed in the
3703 (when (and (numberp article)
3704 (not (eq article gnus-current-article)))
3705 ;; Seems like a new article has been selected.
3706 ;; `gnus-current-article' must be an article number.
3708 (set-buffer summary-buffer)
3709 (push article gnus-newsgroup-history)
3710 (setq gnus-last-article gnus-current-article
3711 gnus-current-article article
3712 gnus-current-headers
3713 (gnus-summary-article-header gnus-current-article)
3714 gnus-article-current
3715 (cons gnus-newsgroup-name gnus-current-article))
3716 (unless (vectorp gnus-current-headers)
3717 (setq gnus-current-headers nil))
3718 (gnus-summary-goto-subject gnus-current-article)
3719 (when (gnus-summary-show-thread)
3720 ;; If the summary buffer really was folded, the
3721 ;; previous goto may not actually have gone to
3722 ;; the right article, but the thread root instead.
3724 (gnus-summary-goto-subject gnus-current-article))
3725 (gnus-run-hooks 'gnus-mark-article-hook)
3726 (gnus-set-mode-line 'summary)
3727 (when (gnus-visual-p 'article-highlight 'highlight)
3728 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3729 ;; Set the global newsgroup variables here.
3730 (gnus-set-global-variables)
3731 (setq gnus-have-all-headers
3732 (or all-headers gnus-show-all-headers))))
3734 (gnus-configure-windows 'article))
3735 (when (or (numberp article)
3737 (gnus-article-prepare-display)
3739 (goto-char (point-min))
3740 (setq gnus-page-broken
3741 (when gnus-break-pages
3742 (gnus-narrow-to-page)
3744 (let ((gnus-article-mime-handle-alist-1
3745 gnus-article-mime-handle-alist))
3746 (gnus-set-mode-line 'article))
3750 (set-window-point (get-buffer-window (current-buffer)) (point))
3751 (gnus-configure-windows 'article)
3755 (defun gnus-article-prepare-display ()
3756 "Make the current buffer look like a nice article."
3757 ;; Hooks for getting information from the article.
3758 ;; This hook must be called before being narrowed.
3759 (let ((gnus-article-buffer (current-buffer))
3761 (unless (eq major-mode 'gnus-article-mode)
3762 (gnus-article-mode))
3763 (setq buffer-read-only nil
3764 gnus-article-wash-types nil
3765 gnus-article-image-alist nil)
3766 (gnus-run-hooks 'gnus-tmp-internal-hook)
3767 (when gnus-display-mime-function
3768 (funcall gnus-display-mime-function))
3769 (gnus-run-hooks 'gnus-article-prepare-hook)))
3772 ;;; Gnus MIME viewing functions
3775 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3776 "Format of the MIME buttons.
3778 Valid specifiers include:
3780 %T MIME type, along with additional info
3781 %n The `name' parameter
3782 %d The description, if any
3783 %l The length of the encoded part
3784 %p The part identifier number
3785 %e Dots if the part isn't displayed
3787 General format specifiers can also be used. See Info node
3788 `(gnus)Formatting Variables'.")
3790 (defvar gnus-mime-button-line-format-alist
3791 '((?t gnus-tmp-type ?s)
3792 (?T gnus-tmp-type-long ?s)
3793 (?n gnus-tmp-name ?s)
3794 (?d gnus-tmp-description ?s)
3796 (?l gnus-tmp-length ?d)
3797 (?e gnus-tmp-dots ?s)))
3799 (defvar gnus-mime-button-commands
3800 '((gnus-article-press-button "\r" "Toggle Display")
3801 (gnus-mime-view-part "v" "View Interactively...")
3802 (gnus-mime-view-part-as-type "t" "View As Type...")
3803 (gnus-mime-view-part-as-charset "C" "View As charset...")
3804 (gnus-mime-save-part "o" "Save...")
3805 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3806 (gnus-mime-delete-part "d" "Delete part")
3807 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3808 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3809 (gnus-mime-view-part-internally "E" "View Internally")
3810 (gnus-mime-view-part-externally "e" "View Externally")
3811 (gnus-mime-print-part "p" "Print")
3812 (gnus-mime-pipe-part "|" "Pipe To Command...")
3813 (gnus-mime-action-on-part "." "Take action on the part...")))
3815 (defun gnus-article-mime-part-status ()
3816 (if gnus-article-mime-handle-alist-1
3817 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3819 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3822 (defvar gnus-mime-button-map
3823 (let ((map (make-sparse-keymap)))
3824 (unless (>= (string-to-number emacs-version) 21)
3825 ;; XEmacs doesn't care.
3826 (set-keymap-parent map gnus-article-mode-map))
3827 (define-key map gnus-mouse-2 'gnus-article-push-button)
3828 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3829 (dolist (c gnus-mime-button-commands)
3830 (define-key map (cadr c) (car c)))
3834 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
3836 ,@(mapcar (lambda (c)
3837 (vector (caddr c) (car c) :enable t))
3838 gnus-mime-button-commands)))
3841 (define-compiler-macro popup-menu (&whole form
3842 menu &optional position prefix)
3843 (if (and (fboundp 'popup-menu)
3844 (not (memq 'popup-menu (assoc "lmenu" load-history))))
3846 ;; Gnus is probably running under Emacs 20.
3847 `(let* ((menu (cdr ,menu))
3848 (response (x-popup-menu
3850 (cons "" (mapcar (lambda (c)
3851 (cons (caddr c) (car c)))
3854 (call-interactively (nth 3 (assq response menu))))))))
3856 (defun gnus-mime-button-menu (event prefix)
3857 "Construct a context-sensitive menu of MIME commands."
3858 (interactive "e\nP")
3859 (save-window-excursion
3860 (let ((pos (event-start event)))
3861 (select-window (posn-window pos))
3862 (goto-char (posn-point pos))
3863 (gnus-article-check-buffer)
3864 (popup-menu gnus-mime-button-menu nil prefix))))
3866 (defun gnus-mime-view-all-parts (&optional handles)
3867 "View all the MIME parts."
3869 (save-current-buffer
3870 (set-buffer gnus-article-buffer)
3871 (let ((handles (or handles gnus-article-mime-handles))
3872 (mail-parse-charset gnus-newsgroup-charset)
3873 (mail-parse-ignored-charsets
3874 (with-current-buffer gnus-summary-buffer
3875 gnus-newsgroup-ignored-charsets)))
3877 (mm-remove-parts handles)
3878 (goto-char (point-min))
3879 (or (search-forward "\n\n") (goto-char (point-max)))
3880 (let (buffer-read-only)
3881 (delete-region (point) (point-max))
3882 (mm-display-parts handles))))))
3884 (defun gnus-mime-save-part-and-strip ()
3885 "Save the MIME part under point then replace it with an external body."
3887 (gnus-article-check-buffer)
3888 (let* ((data (get-text-property (point) 'gnus-data))
3890 (handles gnus-article-mime-handles))
3891 (if (mm-multiple-handles gnus-article-mime-handles)
3892 (error "This function is not implemented"))
3893 (setq file (and data (mm-save-part data)))
3895 (with-current-buffer (mm-handle-buffer data)
3897 (insert "Content-Type: " (mm-handle-media-type data))
3898 (mml-insert-parameter-string (cdr (mm-handle-type data))
3901 (insert "Content-ID: " (message-make-message-id) "\n")
3902 (insert "Content-Transfer-Encoding: binary\n")
3905 (cdr (mm-make-handle nil
3906 `("message/external-body"
3907 (access-type . "LOCAL-FILE")
3909 (set-buffer gnus-summary-buffer)
3910 (gnus-article-edit-article
3913 (let ((mail-parse-charset (or gnus-article-charset
3914 ',gnus-newsgroup-charset))
3915 (mail-parse-ignored-charsets
3916 (or gnus-article-ignored-charsets
3917 ',gnus-newsgroup-ignored-charsets))
3918 (mbl mml-buffer-list))
3919 (setq mml-buffer-list nil)
3920 (insert-buffer gnus-original-article-buffer)
3921 (mime-to-mml ',handles)
3922 (setq gnus-article-mime-handles nil)
3923 (let ((mbl1 mml-buffer-list))
3924 (setq mml-buffer-list mbl)
3925 (set (make-local-variable 'mml-buffer-list) mbl1))
3926 (gnus-make-local-hook 'kill-buffer-hook)
3927 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3928 `(lambda (no-highlight)
3929 (let ((mail-parse-charset (or gnus-article-charset
3930 ',gnus-newsgroup-charset))
3931 (message-options message-options)
3932 (message-options-set-recipient)
3933 (mail-parse-ignored-charsets
3934 (or gnus-article-ignored-charsets
3935 ',gnus-newsgroup-ignored-charsets)))
3937 (mml-destroy-buffers)
3938 (remove-hook 'kill-buffer-hook
3939 'mml-destroy-buffers t)
3940 (kill-local-variable 'mml-buffer-list))
3941 (gnus-summary-edit-article-done
3942 ,(or (mail-header-references gnus-current-headers) "")
3943 ,(gnus-group-read-only-p)
3944 ,gnus-summary-buffer no-highlight))))))
3946 (defun gnus-mime-delete-part ()
3947 "Delete the MIME part under point.
3948 Replace it with some information about the removed part."
3950 (gnus-article-check-buffer)
3951 (unless (and gnus-novice-user
3952 (not (gnus-yes-or-no-p
3953 "Really delete attachment forever? ")))
3954 (let* ((data (get-text-property (point) 'gnus-data))
3955 (handles gnus-article-mime-handles)
3959 (mail-decode-encoded-word-string (or (mm-handle-description data)
3962 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
3964 (type (mm-handle-media-type data)))
3965 (if (mm-multiple-handles gnus-article-mime-handles)
3966 (error "This function is not implemented"))
3967 (with-current-buffer (mm-handle-buffer data)
3968 (let ((bsize (format "%s" (buffer-size))))
3972 "<#part type=text/plain nofile=yes disposition=attachment"
3973 " description=\"Deleted attachment (" bsize " Byte)\">"
3975 "| The following attachment has been deleted:\n"
3977 "| Type: " type "\n"
3978 "| Filename: " filename "\n"
3979 "| Size (encoded): " bsize " Byte\n"
3980 "| Description: " description "\n"
3984 (cdr (mm-make-handle nil `("text/plain"))))))
3985 (set-buffer gnus-summary-buffer)
3986 ;; FIXME: maybe some of the following code (borrowed from
3987 ;; `gnus-mime-save-part-and-strip') isn't necessary?
3988 (gnus-article-edit-article
3991 (let ((mail-parse-charset (or gnus-article-charset
3992 ',gnus-newsgroup-charset))
3993 (mail-parse-ignored-charsets
3994 (or gnus-article-ignored-charsets
3995 ',gnus-newsgroup-ignored-charsets))
3996 (mbl mml-buffer-list))
3997 (setq mml-buffer-list nil)
3998 (insert-buffer gnus-original-article-buffer)
3999 (mime-to-mml ',handles)
4000 (setq gnus-article-mime-handles nil)
4001 (let ((mbl1 mml-buffer-list))
4002 (setq mml-buffer-list mbl)
4003 (set (make-local-variable 'mml-buffer-list) mbl1))
4004 (gnus-make-local-hook 'kill-buffer-hook)
4005 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4006 `(lambda (no-highlight)
4007 (let ((mail-parse-charset (or gnus-article-charset
4008 ',gnus-newsgroup-charset))
4009 (message-options message-options)
4010 (message-options-set-recipient)
4011 (mail-parse-ignored-charsets
4012 (or gnus-article-ignored-charsets
4013 ',gnus-newsgroup-ignored-charsets)))
4015 (mml-destroy-buffers)
4016 (remove-hook 'kill-buffer-hook
4017 'mml-destroy-buffers t)
4018 (kill-local-variable 'mml-buffer-list))
4019 (gnus-summary-edit-article-done
4020 ,(or (mail-header-references gnus-current-headers) "")
4021 ,(gnus-group-read-only-p)
4022 ,gnus-summary-buffer no-highlight)))))
4023 ;; Not in `gnus-mime-save-part-and-strip':
4024 (gnus-article-edit-done)
4025 (gnus-summary-expand-window)
4026 (gnus-summary-show-article))
4028 (defun gnus-mime-save-part ()
4029 "Save the MIME part under point."
4031 (gnus-article-check-buffer)
4032 (let ((data (get-text-property (point) 'gnus-data)))
4034 (mm-save-part data))))
4036 (defun gnus-mime-pipe-part ()
4037 "Pipe the MIME part under point to a process."
4039 (gnus-article-check-buffer)
4040 (let ((data (get-text-property (point) 'gnus-data)))
4042 (mm-pipe-part data))))
4044 (defun gnus-mime-view-part ()
4045 "Interactively choose a viewing method for the MIME part under point."
4047 (gnus-article-check-buffer)
4048 (let ((data (get-text-property (point) 'gnus-data)))
4050 (setq gnus-article-mime-handles
4052 gnus-article-mime-handles (setq data (copy-sequence data))))
4053 (mm-interactively-view-part data))))
4055 (defun gnus-mime-view-part-as-type-internal ()
4056 (gnus-article-check-buffer)
4057 (let* ((name (mail-content-type-get
4058 (mm-handle-type (get-text-property (point) 'gnus-data))
4060 (def-type (and name (mm-default-file-encoding name))))
4061 (and def-type (cons def-type 0))))
4063 (defun gnus-mime-view-part-as-type (&optional mime-type)
4064 "Choose a MIME media type, and view the part as such."
4067 (setq mime-type (completing-read
4068 "View as MIME type: "
4069 (mapcar #'list (mailcap-mime-types))
4071 (gnus-mime-view-part-as-type-internal))))
4072 (gnus-article-check-buffer)
4073 (let ((handle (get-text-property (point) 'gnus-data)))
4076 (mm-make-handle (mm-handle-buffer handle)
4077 (cons mime-type (cdr (mm-handle-type handle)))
4078 (mm-handle-encoding handle)
4079 (mm-handle-undisplayer handle)
4080 (mm-handle-disposition handle)
4081 (mm-handle-description handle)
4083 (mm-handle-id handle)))
4084 (setq gnus-article-mime-handles
4085 (mm-merge-handles gnus-article-mime-handles handle))
4086 (gnus-mm-display-part handle))))
4089 (require 'jka-compr))
4091 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4092 ;; emacs can do that itself.
4094 (defun gnus-mime-jka-compr-maybe-uncompress ()
4095 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4096 The uncompress method used is derived from `buffer-file-name'."
4097 (when (and (fboundp 'jka-compr-installed-p)
4098 (jka-compr-installed-p))
4099 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4101 (let ((basename (file-name-nondirectory buffer-file-name))
4102 (args (jka-compr-info-uncompress-args info))
4103 (prog (jka-compr-info-uncompress-program info))
4104 (message (jka-compr-info-uncompress-message info))
4105 (err-file (jka-compr-make-temp-name)))
4107 (message "%s %s..." message basename))
4109 (unless (memq (apply 'call-process-region
4110 (point-min) (point-max)
4112 t (list t err-file) nil
4114 jka-compr-acceptable-retval-list)
4115 (jka-compr-error prog args basename message err-file))
4116 (jka-compr-delete-temp-file err-file)))))))
4118 (defun gnus-mime-copy-part (&optional handle)
4119 "Put the MIME part under point into a new buffer.
4120 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4123 (gnus-article-check-buffer)
4124 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4125 (contents (and handle (mm-get-part handle)))
4127 (file-name-nondirectory
4129 (mail-content-type-get (mm-handle-type handle) 'name)
4130 (mail-content-type-get (mm-handle-disposition handle)
4133 (buffer (and base (generate-new-buffer base))))
4135 (switch-to-buffer buffer)
4137 ;; We do it this way to make `normal-mode' set the appropriate mode.
4140 (setq buffer-file-name (expand-file-name base))
4141 (gnus-mime-jka-compr-maybe-uncompress)
4143 (setq buffer-file-name nil))
4144 (goto-char (point-min)))))
4146 (defun gnus-mime-print-part (&optional handle filename)
4147 "Print the MIME part under point."
4148 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4149 (gnus-article-check-buffer)
4150 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4151 (contents (and handle (mm-get-part handle)))
4152 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4153 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4158 (mm-save-part-to-file handle file)
4159 (call-process shell-file-name nil
4160 (generate-new-buffer " *mm*")
4162 shell-command-switch
4164 printer file (mm-handle-type handle))))
4168 (gnus-print-buffer))
4169 (ps-despool filename)))))
4171 (defun gnus-mime-inline-part (&optional handle arg)
4172 "Insert the MIME part under point into the current buffer."
4173 (interactive (list nil current-prefix-arg))
4174 (gnus-article-check-buffer)
4175 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4180 (if (and (not arg) (mm-handle-undisplayer handle))
4181 (mm-remove-part handle)
4182 (setq contents (mm-get-part handle))
4185 (setq charset (or (mail-content-type-get
4186 (mm-handle-type handle) 'charset)
4187 gnus-newsgroup-charset)))
4189 (if (mm-handle-undisplayer handle)
4190 (mm-remove-part handle))
4193 gnus-summary-show-article-charset-alist))
4194 (mm-read-coding-system "Charset: ")))))
4196 (mm-insert-inline handle
4198 (setq charset (mm-charset-to-coding-system
4200 (not (eq charset 'ascii)))
4201 (mm-decode-coding-string contents charset)
4205 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4206 "Insert the MIME part under point into the current buffer using the
4208 (interactive (list nil current-prefix-arg))
4209 (gnus-article-check-buffer)
4210 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4215 (if (mm-handle-undisplayer handle)
4216 (mm-remove-part handle))
4217 (let ((gnus-newsgroup-charset
4219 gnus-summary-show-article-charset-alist))
4220 (mm-read-coding-system "Charset: ")))
4221 (gnus-newsgroup-ignored-charsets 'gnus-all))
4222 (gnus-article-press-button)))))
4224 (defun gnus-mime-view-part-externally (&optional handle)
4225 "View the MIME part under point with an external viewer."
4227 (gnus-article-check-buffer)
4228 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4229 (mm-user-display-methods nil)
4230 (mm-inlined-types nil)
4231 (mail-parse-charset gnus-newsgroup-charset)
4232 (mail-parse-ignored-charsets
4233 (save-excursion (set-buffer gnus-summary-buffer)
4234 gnus-newsgroup-ignored-charsets)))
4236 (if (mm-handle-undisplayer handle)
4237 (mm-remove-part handle)
4238 (mm-display-part handle)))))
4240 (defun gnus-mime-view-part-internally (&optional handle)
4241 "View the MIME part under point with an internal viewer.
4242 If no internal viewer is available, use an external viewer."
4244 (gnus-article-check-buffer)
4245 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4246 (mm-inlined-types '(".*"))
4247 (mm-inline-large-images t)
4248 (mail-parse-charset gnus-newsgroup-charset)
4249 (mail-parse-ignored-charsets
4250 (save-excursion (set-buffer gnus-summary-buffer)
4251 gnus-newsgroup-ignored-charsets))
4254 (if (mm-handle-undisplayer handle)
4255 (mm-remove-part handle)
4256 (mm-display-part handle)))))
4258 (defun gnus-mime-action-on-part (&optional action)
4259 "Do something with the MIME attachment at \(point\)."
4261 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4262 (gnus-article-check-buffer)
4263 (let ((action-pair (assoc action gnus-mime-action-alist)))
4265 (funcall (cdr action-pair)))))
4267 (defun gnus-article-part-wrapper (n function)
4268 (save-current-buffer
4269 (set-buffer gnus-article-buffer)
4270 (when (> n (length gnus-article-mime-handle-alist))
4271 (error "No such part"))
4272 (gnus-article-goto-part n)
4273 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4274 (funcall function handle))))
4276 (defun gnus-article-pipe-part (n)
4277 "Pipe MIME part N, which is the numerical prefix."
4279 (gnus-article-part-wrapper n 'mm-pipe-part))
4281 (defun gnus-article-save-part (n)
4282 "Save MIME part N, which is the numerical prefix."
4284 (gnus-article-part-wrapper n 'mm-save-part))
4286 (defun gnus-article-interactively-view-part (n)
4287 "View MIME part N interactively, which is the numerical prefix."
4289 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4291 (defun gnus-article-copy-part (n)
4292 "Copy MIME part N, which is the numerical prefix."
4294 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4296 (defun gnus-article-view-part-as-charset (n)
4297 "Copy MIME part N, which is the numerical prefix."
4299 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4301 (defun gnus-article-view-part-externally (n)
4302 "View MIME part N externally, which is the numerical prefix."
4304 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4306 (defun gnus-article-inline-part (n)
4307 "Inline MIME part N, which is the numerical prefix."
4309 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4311 (defun gnus-article-mime-match-handle-first (condition)
4313 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4314 (while (setq ihandle (pop alist))
4316 ((functionp condition)
4317 (funcall condition (cdr ihandle)))
4318 ((eq condition 'undisplayed)
4319 (not (or (mm-handle-undisplayer (cdr ihandle))
4320 (equal (mm-handle-media-type (cdr ihandle))
4321 "multipart/alternative"))))
4322 ((eq condition 'undisplayed-alternative)
4323 (not (mm-handle-undisplayer (cdr ihandle))))
4325 (gnus-article-goto-part (car ihandle))
4326 (or (not n) (< (car ihandle) n)))
4327 (setq n (car ihandle))))
4331 (defun gnus-article-view-part (&optional n)
4332 "View MIME part N, which is the numerical prefix."
4334 (save-current-buffer
4335 (set-buffer gnus-article-buffer)
4336 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4337 gnus-article-mime-match-handle-function)))
4338 (when (> n (length gnus-article-mime-handle-alist))
4339 (error "No such part"))
4340 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4341 (when (gnus-article-goto-part n)
4342 (if (equal (car handle) "multipart/alternative")
4343 (gnus-article-press-button)
4344 (when (eq (gnus-mm-display-part handle) 'internal)
4345 (gnus-set-window-start)))))))
4347 (defsubst gnus-article-mime-total-parts ()
4348 (if (bufferp (car gnus-article-mime-handles))
4350 (1- (length gnus-article-mime-handles))))
4352 (defun gnus-mm-display-part (handle)
4353 "Display HANDLE and fix MIME button."
4354 (let ((id (get-text-property (point) 'gnus-part))
4359 (let ((window (selected-window))
4360 (mail-parse-charset gnus-newsgroup-charset)
4361 (mail-parse-ignored-charsets
4362 (if (gnus-buffer-live-p gnus-summary-buffer)
4364 (set-buffer gnus-summary-buffer)
4365 gnus-newsgroup-ignored-charsets)
4369 (let ((win (gnus-get-buffer-window (current-buffer) t))
4372 (select-window win))
4375 (if (mm-handle-displayed-p handle)
4376 ;; This will remove the part.
4377 (mm-display-part handle)
4379 (narrow-to-region (point)
4380 (if (eobp) (point) (1+ (point))))
4381 (mm-display-part handle)
4382 ;; We narrow to the part itself and
4383 ;; then call the treatment functions.
4384 (goto-char (point-min))
4386 (narrow-to-region (point) (point-max))
4389 (gnus-article-mime-total-parts)
4390 (mm-handle-media-type handle)))))
4391 (if (window-live-p window)
4392 (select-window window)))))
4395 (gnus-insert-mime-button
4396 handle id (list (mm-handle-displayed-p handle)))
4397 (goto-char point))))
4399 (defun gnus-article-goto-part (n)
4400 "Go to MIME part N."
4401 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4403 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4404 (let ((gnus-tmp-name
4405 (or (mail-content-type-get (mm-handle-type handle) 'name)
4406 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4407 (mail-content-type-get (mm-handle-type handle) 'url)
4409 (gnus-tmp-type (mm-handle-media-type handle))
4410 (gnus-tmp-description
4411 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4414 (if (if displayed (car displayed)
4415 (mm-handle-displayed-p handle))
4417 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4419 gnus-tmp-type-long b e)
4420 (when (string-match ".*/" gnus-tmp-name)
4421 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4422 (setq gnus-tmp-type-long (concat gnus-tmp-type
4423 (and (not (equal gnus-tmp-name ""))
4424 (concat "; " gnus-tmp-name))))
4425 (unless (equal gnus-tmp-description "")
4426 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4431 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4432 `(,@(gnus-local-map-property gnus-mime-button-map)
4433 gnus-callback gnus-mm-display-part
4434 gnus-part ,gnus-tmp-id
4435 article-type annotation
4438 ;; Exclude a newline.
4441 (widget-convert-button
4444 :action 'gnus-widget-press-button
4445 :button-keymap gnus-mime-button-map
4447 (lambda (widget/window &optional overlay pos)
4448 ;; Needed to properly clear the message due to a bug in
4449 ;; wid-edit (XEmacs only).
4450 (if (boundp 'help-echo-owns-message)
4451 (setq help-echo-owns-message t))
4453 "%S: %s the MIME part; %S: more options"
4454 (aref gnus-mouse-2 0)
4455 ;; XEmacs will get a single widget arg; Emacs 21 will get
4456 ;; window, overlay, position.
4457 (if (mm-handle-displayed-p
4459 (with-current-buffer (gnus-overlay-buffer overlay)
4460 (widget-get (widget-at (gnus-overlay-start overlay))
4462 (widget-get widget/window :mime-handle)))
4464 (aref gnus-down-mouse-3 0))))))
4466 (defun gnus-widget-press-button (elems el)
4467 (goto-char (widget-get elems :from))
4468 (gnus-article-press-button))
4470 (defvar gnus-displaying-mime nil)
4472 (defun gnus-display-mime (&optional ihandles)
4473 "Display the MIME parts."
4475 (save-selected-window
4476 (let ((window (get-buffer-window gnus-article-buffer))
4479 (select-window window)
4480 ;; We have to do this since selecting the window
4481 ;; may change the point. So we set the window point.
4482 (set-window-point window point)))
4483 (let* ((handles (or ihandles
4484 (mm-dissect-buffer nil gnus-article-loose-mime)
4485 (and gnus-article-emulate-mime
4487 buffer-read-only handle name type b e display)
4488 (when (and (not ihandles)
4489 (not gnus-displaying-mime))
4490 ;; Top-level call; we clean up.
4491 (when gnus-article-mime-handles
4492 (mm-destroy-parts gnus-article-mime-handles)
4493 (setq gnus-article-mime-handle-alist nil));; A trick.
4494 (setq gnus-article-mime-handles handles)
4495 ;; We allow users to glean info from the handles.
4496 (when gnus-article-mime-part-function
4497 (gnus-mime-part-function handles)))
4499 (or (not (stringp (car handles)))
4502 (when (and (not ihandles)
4503 (not gnus-displaying-mime))
4504 ;; Clean up for mime parts.
4506 (delete-region (point) (point-max)))
4507 (let ((gnus-displaying-mime t))
4508 (gnus-mime-display-part handles)))
4511 (narrow-to-region (point) (point-max))
4512 (gnus-treat-article nil 1 1)
4515 ;; Highlight the headers.
4519 (narrow-to-region (point-min) (point))
4520 (gnus-treat-article 'head))))))))
4522 (defcustom gnus-mime-display-multipart-as-mixed nil
4523 "Display \"multipart\" parts as \"multipart/mixed\".
4525 If t, it overrides nil values of
4526 `gnus-mime-display-multipart-alternative-as-mixed' and
4527 `gnus-mime-display-multipart-related-as-mixed'."
4528 :group 'gnus-article-mime
4531 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4532 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4533 :group 'gnus-article-mime
4536 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4537 "Display \"multipart/related\" parts as \"multipart/mixed\".
4539 If displaying \"text/html\" is discouraged \(see
4540 `mm-discouraged-alternatives'\) images or other material inside a
4541 \"multipart/related\" part might be overlooked when this variable is nil."
4542 :group 'gnus-article-mime
4545 (defun gnus-mime-display-part (handle)
4548 ((not (stringp (car handle)))
4549 (gnus-mime-display-single handle))
4550 ;; User-defined multipart
4551 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4552 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4554 ;; multipart/alternative
4555 ((and (equal (car handle) "multipart/alternative")
4556 (not (or gnus-mime-display-multipart-as-mixed
4557 gnus-mime-display-multipart-alternative-as-mixed)))
4558 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4559 (push (cons id handle) gnus-article-mime-handle-alist)
4560 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4561 ;; multipart/related
4562 ((and (equal (car handle) "multipart/related")
4563 (not (or gnus-mime-display-multipart-as-mixed
4564 gnus-mime-display-multipart-related-as-mixed)))
4565 ;;;!!!We should find the start part, but we just default
4566 ;;;!!!to the first part.
4567 ;;(gnus-mime-display-part (cadr handle))
4568 ;;;!!! Most multipart/related is an HTML message plus images.
4569 ;;;!!! Unfortunately we are unable to let W3 display those
4570 ;;;!!! included images, so we just display it as a mixed multipart.
4571 ;;(gnus-mime-display-mixed (cdr handle))
4572 ;;;!!! No, w3 can display everything just fine.
4573 (gnus-mime-display-part (cadr handle)))
4574 ((equal (car handle) "multipart/signed")
4575 (gnus-add-wash-type 'signed)
4576 (gnus-mime-display-security handle))
4577 ((equal (car handle) "multipart/encrypted")
4578 (gnus-add-wash-type 'encrypted)
4579 (gnus-mime-display-security handle))
4580 ;; Other multiparts are handled like multipart/mixed.
4582 (gnus-mime-display-mixed (cdr handle)))))
4584 (defun gnus-mime-part-function (handles)
4585 (if (stringp (car handles))
4586 (mapcar 'gnus-mime-part-function (cdr handles))
4587 (funcall gnus-article-mime-part-function handles)))
4589 (defun gnus-mime-display-mixed (handles)
4590 (mapcar 'gnus-mime-display-part handles))
4592 (defun gnus-mime-display-single (handle)
4593 (let ((type (mm-handle-media-type handle))
4594 (ignored gnus-ignored-mime-types)
4601 (when (string-match (pop ignored) type)
4602 (throw 'ignored nil)))
4603 (if (and (setq not-attachment
4604 (and (not (mm-inline-override-p handle))
4605 (or (not (mm-handle-disposition handle))
4606 (equal (car (mm-handle-disposition handle))
4608 (mm-attachment-override-p handle))))
4609 (mm-automatic-display-p handle)
4611 (mm-inlinable-p handle)
4612 (mm-inlined-p handle))
4613 (mm-automatic-external-display-p type)))
4615 (when (equal (mm-handle-media-supertype handle) "text")
4617 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4619 (push (cons id handle) gnus-article-mime-handle-alist)
4620 (when (or (not display)
4621 (not (gnus-unbuttonized-mime-type-p type)))
4622 ;(gnus-article-insert-newline)
4623 (gnus-insert-mime-button
4624 handle id (list (or display (and not-attachment text))))
4625 (gnus-article-insert-newline)
4626 ;(gnus-article-insert-newline)
4627 ;; Remember modify the number of forward lines.
4635 (let ((mail-parse-charset gnus-newsgroup-charset)
4636 (mail-parse-ignored-charsets
4637 (save-excursion (condition-case ()
4638 (set-buffer gnus-summary-buffer)
4640 gnus-newsgroup-ignored-charsets)))
4641 (mm-display-part handle t))
4642 (goto-char (point-max)))
4643 ((and text not-attachment)
4647 (gnus-article-insert-newline)
4648 (mm-insert-inline handle (mm-get-part handle))
4649 (goto-char (point-max))))
4653 (narrow-to-region beg (point))
4656 (gnus-article-mime-total-parts)
4657 (mm-handle-media-type handle)))))))))
4659 (defun gnus-unbuttonized-mime-type-p (type)
4660 "Say whether TYPE is to be unbuttonized."
4661 (unless gnus-inhibit-mime-unbuttonizing
4663 (let ((types gnus-unbuttonized-mime-types))
4665 (when (string-match (pop types) type)
4666 (throw 'found t)))))
4668 (let ((types gnus-buttonized-mime-types))
4670 (when (string-match (pop types) type)
4671 (throw 'found t)))))))))
4673 (defun gnus-article-insert-newline ()
4674 "Insert a newline, but mark it as undeletable."
4675 (gnus-put-text-property
4676 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4678 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4679 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4682 handle buffer-read-only from props begend not-pref)
4683 (save-window-excursion
4686 (narrow-to-region (car ibegend)
4689 (goto-char (car ibegend))
4692 (delete-region (point-min) (point-max))
4693 (mm-remove-parts handles))
4694 (setq begend (list (point-marker)))
4696 (unless (setq not-pref (cadr (member preferred ihandles)))
4697 (setq not-pref (car ihandles)))
4700 (not (gnus-unbuttonized-mime-type-p
4701 "multipart/alternative")))
4702 (gnus-add-text-properties
4705 (insert (format "%d. " id))
4709 (unless ,(not ibegend)
4710 (setq gnus-article-mime-handle-alist
4711 ',gnus-article-mime-handle-alist))
4712 (gnus-mime-display-alternative
4713 ',ihandles ',not-pref ',begend ,id))
4714 ,@(gnus-local-map-property gnus-mime-button-map)
4715 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4716 face ,gnus-article-button-face
4719 (widget-convert-button 'link from (point)
4720 :action 'gnus-widget-press-button
4721 :button-keymap gnus-widget-button-keymap)
4723 (while (setq handle (pop handles))
4724 (gnus-add-text-properties
4727 (insert (format "(%c) %-18s"
4728 (if (equal handle preferred) ?* ? )
4729 (mm-handle-media-type handle)))
4733 (unless ,(not ibegend)
4734 (setq gnus-article-mime-handle-alist
4735 ',gnus-article-mime-handle-alist))
4736 (gnus-mime-display-alternative
4737 ',ihandles ',handle ',begend ,id))
4738 ,@(gnus-local-map-property gnus-mime-button-map)
4739 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4740 face ,gnus-article-button-face
4743 (widget-convert-button 'link from (point)
4744 :action 'gnus-widget-press-button
4745 :button-keymap gnus-widget-button-keymap)
4749 (if (stringp (car preferred))
4750 (gnus-display-mime preferred)
4751 (let ((mail-parse-charset gnus-newsgroup-charset)
4752 (mail-parse-ignored-charsets
4753 (save-excursion (set-buffer gnus-summary-buffer)
4754 gnus-newsgroup-ignored-charsets)))
4755 (mm-display-part preferred)
4759 (narrow-to-region (car begend) (point-max))
4761 nil (length gnus-article-mime-handle-alist)
4762 (gnus-article-mime-total-parts)
4763 (mm-handle-media-type handle))))))
4764 (goto-char (point-max))
4765 (setcdr begend (point-marker)))))
4767 (goto-char point))))
4769 (defconst gnus-article-wash-status-strings
4770 (let ((alist '((cite "c" "Possible hidden citation text"
4771 " " "All citation text visible")
4772 (headers "h" "Hidden headers"
4773 " " "All headers visible.")
4774 (pgp "p" "Encrypted or signed message status hidden"
4775 " " "No hidden encryption nor digital signature status")
4776 (signature "s" "Signature has been hidden"
4777 " " "Signature is visible")
4778 (overstrike "o" "Overstrike (^H) characters applied"
4779 " " "No overstrike characters applied")
4780 (emphasis "e" "/*_Emphasis_*/ characters applied"
4781 " " "No /*_emphasis_*/ characters applied")))
4783 (dolist (entry alist result)
4784 (let ((key (nth 0 entry))
4785 (on (copy-sequence (nth 1 entry)))
4786 (on-help (nth 2 entry))
4787 (off (copy-sequence (nth 3 entry)))
4788 (off-help (nth 4 entry)))
4789 (put-text-property 0 1 'help-echo on-help on)
4790 (put-text-property 0 1 'help-echo off-help off)
4791 (push (list key on off) result))))
4792 "Alist of strings describing wash status in the mode line.
4793 Each entry has the form (KEY ON OF), where the KEY is a symbol
4794 representing the particular washing function, ON is the string to use
4795 in the article mode line when the washing function is active, and OFF
4796 is the string to use when it is inactive.")
4798 (defun gnus-article-wash-status-entry (key value)
4799 (let ((entry (assoc key gnus-article-wash-status-strings)))
4800 (if value (nth 1 entry) (nth 2 entry))))
4802 (defun gnus-article-wash-status ()
4803 "Return a string which display status of article washing."
4805 (set-buffer gnus-article-buffer)
4806 (let ((cite (memq 'cite gnus-article-wash-types))
4807 (headers (memq 'headers gnus-article-wash-types))
4808 (boring (memq 'boring-headers gnus-article-wash-types))
4809 (pgp (memq 'pgp gnus-article-wash-types))
4810 (pem (memq 'pem gnus-article-wash-types))
4811 (signed (memq 'signed gnus-article-wash-types))
4812 (encrypted (memq 'encrypted gnus-article-wash-types))
4813 (signature (memq 'signature gnus-article-wash-types))
4814 (overstrike (memq 'overstrike gnus-article-wash-types))
4815 (emphasis (memq 'emphasis gnus-article-wash-types)))
4817 (gnus-article-wash-status-entry 'cite cite)
4818 (gnus-article-wash-status-entry 'headers (or headers boring))
4819 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4820 (gnus-article-wash-status-entry 'signature signature)
4821 (gnus-article-wash-status-entry 'overstrike overstrike)
4822 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4824 (defun gnus-add-wash-type (type)
4825 "Add a washing of TYPE to the current status."
4826 (add-to-list 'gnus-article-wash-types type))
4828 (defun gnus-delete-wash-type (type)
4829 "Add a washing of TYPE to the current status."
4830 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4832 (defun gnus-add-image (category image)
4833 "Add IMAGE of CATEGORY to the list of displayed images."
4834 (let ((entry (assq category gnus-article-image-alist)))
4836 (setq entry (list category))
4837 (push entry gnus-article-image-alist))
4838 (nconc entry (list image))))
4840 (defun gnus-delete-images (category)
4841 "Delete all images in CATEGORY."
4842 (let ((entry (assq category gnus-article-image-alist)))
4843 (dolist (image (cdr entry))
4844 (gnus-remove-image image))
4845 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4846 (gnus-delete-wash-type category)))
4848 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4850 (defun gnus-article-maybe-hide-headers ()
4851 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4852 Provided for backwards compatibility."
4853 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4854 (not (save-excursion (set-buffer gnus-summary-buffer)
4855 gnus-have-all-headers)))
4856 (not gnus-inhibit-hiding))
4857 (gnus-article-hide-headers)))
4861 (defun gnus-output-to-file (file-name)
4862 "Append the current article to a file named FILE-NAME."
4863 (let ((artbuf (current-buffer)))
4865 (insert-buffer-substring artbuf)
4866 ;; Append newline at end of the buffer as separator, and then
4868 (goto-char (point-max))
4870 (let ((file-name-coding-system nnmail-pathname-coding-system))
4871 (mm-append-to-file (point-min) (point-max) file-name))
4874 (defun gnus-narrow-to-page (&optional arg)
4875 "Narrow the article buffer to a page.
4876 If given a numerical ARG, move forward ARG pages."
4878 (setq arg (if arg (prefix-numeric-value arg) 0))
4880 (set-buffer gnus-article-buffer)
4881 (goto-char (point-min))
4883 ;; Remove any old next/prev buttons.
4884 (when (gnus-visual-p 'page-marker)
4885 (let ((buffer-read-only nil))
4886 (gnus-remove-text-with-property 'gnus-prev)
4887 (gnus-remove-text-with-property 'gnus-next)))
4890 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4892 (re-search-forward page-delimiter nil 'move arg)))
4893 (goto-char (match-end 0)))
4896 (if (re-search-forward page-delimiter nil 'move)
4899 (when (and (gnus-visual-p 'page-marker)
4900 (not (= (point-min) 1)))
4902 (goto-char (point-min))
4903 (gnus-insert-prev-page-button)))
4904 (when (and (gnus-visual-p 'page-marker)
4905 (< (+ (point-max) 2) (buffer-size)))
4907 (goto-char (point-max))
4908 (gnus-insert-next-page-button)))))
4910 ;; Article mode commands
4912 (defun gnus-article-goto-next-page ()
4913 "Show the next page of the article."
4915 (when (gnus-article-next-page)
4916 (goto-char (point-min))
4917 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4920 (defun gnus-article-goto-prev-page ()
4921 "Show the next page of the article."
4924 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4925 (gnus-article-prev-page nil)))
4927 ;; This is cleaner but currently breaks `gnus-pick-mode':
4929 ;; (defun gnus-article-goto-next-page ()
4930 ;; "Show the next page of the article."
4932 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
4933 ;; (gnus-summary-next-page)))
4935 ;; (defun gnus-article-goto-prev-page ()
4936 ;; "Show the next page of the article."
4938 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
4939 ;; (gnus-summary-prev-page)))
4941 (defun gnus-article-next-page (&optional lines)
4942 "Show the next page of the current article.
4943 If end of article, return non-nil. Otherwise return nil.
4944 Argument LINES specifies lines to be scrolled up."
4946 (move-to-window-line -1)
4949 (and (pos-visible-in-window-p) ;Not continuation line.
4950 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
4951 ;; Nothing in this page.
4952 (if (or (not gnus-page-broken)
4955 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4957 (when gnus-article-over-scroll
4958 (gnus-article-next-page-1 lines))
4960 (gnus-narrow-to-page 1) ;Go to next page.
4962 ;; More in this page.
4963 (gnus-article-next-page-1 lines)
4966 (defun gnus-article-next-page-1 (lines)
4967 (let ((scroll-in-place nil))
4971 ;; Long lines may cause an end-of-buffer error.
4972 (goto-char (point-max)))))
4973 (move-to-window-line 0))
4975 (defun gnus-article-prev-page (&optional lines)
4976 "Show previous page of current article.
4977 Argument LINES specifies lines to be scrolled down."
4979 (move-to-window-line 0)
4980 (if (and gnus-page-broken
4982 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4984 (gnus-narrow-to-page -1) ;Go to previous page.
4985 (goto-char (point-max))
4987 (let ((scroll-in-place nil))
4991 (beginning-of-buffer
4992 (goto-char (point-min))))
4993 (move-to-window-line 0)))))
4995 (defun gnus-article-only-boring-p ()
4996 "Decide whether there is only boring text remaining in the article.
4997 Something \"interesting\" is a word of at least two letters that does
4998 not have a face in `gnus-article-boring-faces'."
4999 (when (and gnus-article-skip-boring
5000 (boundp 'gnus-article-boring-faces)
5001 (symbol-value 'gnus-article-boring-faces))
5004 (while (re-search-forward "\\b\\w\\w" nil t)
5006 (when (not (gnus-intersection
5007 (gnus-faces-at (point))
5008 (symbol-value 'gnus-article-boring-faces)))
5009 (throw 'only-boring nil)))
5010 (throw 'only-boring t)))))
5012 (defun gnus-article-refer-article ()
5013 "Read article specified by message-id around point."
5016 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5017 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5018 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5019 (let ((msg-id (concat "<" (match-string 0) ">")))
5020 (set-buffer gnus-summary-buffer)
5021 (gnus-summary-refer-article msg-id))
5022 (error "No references around point"))))
5024 (defun gnus-article-show-summary ()
5025 "Reconfigure windows to show summary buffer."
5027 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5028 (error "There is no summary buffer for this article buffer")
5029 (gnus-article-set-globals)
5030 (gnus-configure-windows 'article)
5031 (gnus-summary-goto-subject gnus-current-article)
5032 (gnus-summary-position-point)))
5034 (defun gnus-article-describe-briefly ()
5035 "Describe article mode commands briefly."
5037 (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")))
5039 (defun gnus-article-summary-command ()
5040 "Execute the last keystroke in the summary buffer."
5042 (let ((obuf (current-buffer))
5043 (owin (current-window-configuration))
5045 (switch-to-buffer gnus-article-current-summary 'norecord)
5046 (setq func (lookup-key (current-local-map) (this-command-keys)))
5047 (call-interactively func)
5049 (set-window-configuration owin)
5050 (set-window-point (get-buffer-window (current-buffer)) (point))))
5052 (defun gnus-article-summary-command-nosave ()
5053 "Execute the last keystroke in the summary buffer."
5056 (pop-to-buffer gnus-article-current-summary 'norecord)
5057 (setq func (lookup-key (current-local-map) (this-command-keys)))
5058 (call-interactively func)))
5060 (defun gnus-article-check-buffer ()
5061 "Beep if not in an article buffer."
5062 (unless (equal major-mode 'gnus-article-mode)
5063 (error "Command invoked outside of a Gnus article buffer")))
5065 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5066 "Read a summary buffer key sequence and execute it from the article buffer."
5068 (gnus-article-check-buffer)
5070 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5071 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5072 "=" "^" "\M-^" "|"))
5078 '("n" "Gn" "p" "Gp"))
5081 (set-buffer gnus-article-current-summary)
5082 (let (gnus-pick-mode)
5083 (push (or key last-command-event) unread-command-events)
5084 (setq keys (if (featurep 'xemacs)
5085 (events-to-keys (read-key-sequence nil))
5086 (read-key-sequence nil)))))
5090 (if (or (member keys nosaves)
5091 (member keys nosave-but-article)
5092 (member keys nosave-in-article))
5094 (save-window-excursion
5095 (pop-to-buffer gnus-article-current-summary 'norecord)
5096 ;; We disable the pick minor mode commands.
5097 (let (gnus-pick-mode)
5098 (setq func (lookup-key (current-local-map) keys))))
5102 (unless (member keys nosave-in-article)
5103 (set-buffer gnus-article-current-summary))
5104 (call-interactively func)
5105 (setq new-sum-point (point)))
5106 (when (member keys nosave-but-article)
5107 (pop-to-buffer gnus-article-buffer 'norecord)))
5108 ;; These commands should restore window configuration.
5109 (let ((obuf (current-buffer))
5110 (owin (current-window-configuration))
5112 (summary gnus-article-current-summary)
5113 func in-buffer selected)
5114 (if not-restore-window
5115 (pop-to-buffer summary 'norecord)
5116 (switch-to-buffer summary 'norecord))
5117 (setq in-buffer (current-buffer))
5118 ;; We disable the pick minor mode commands.
5119 (if (and (setq func (let (gnus-pick-mode)
5120 (lookup-key (current-local-map) keys)))
5123 (call-interactively func)
5124 (setq new-sum-point (point))
5125 (when (eq in-buffer (current-buffer))
5126 (setq selected (gnus-summary-select-article))
5128 (unless not-restore-window
5129 (set-window-configuration owin))
5130 (when (eq selected 'old)
5132 (set-window-start (get-buffer-window (current-buffer))
5134 (set-window-point (get-buffer-window (current-buffer))
5136 (let ((win (get-buffer-window gnus-article-current-summary)))
5138 (set-window-point win new-sum-point)))) )
5139 (switch-to-buffer gnus-article-buffer)
5142 (defun gnus-article-describe-key (key)
5143 "Display documentation of the function invoked by KEY. KEY is a string."
5144 (interactive "kDescribe key: ")
5145 (gnus-article-check-buffer)
5146 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5148 (set-buffer gnus-article-current-summary)
5149 (let (gnus-pick-mode)
5150 (if (featurep 'xemacs)
5152 (push (elt key 0) unread-command-events)
5153 (setq key (events-to-keys
5154 (read-key-sequence "Describe key: "))))
5155 (setq unread-command-events
5157 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5158 (string-to-list key)))
5159 (setq key (read-key-sequence "Describe key: "))))
5161 (describe-key key)))
5163 (defun gnus-article-describe-key-briefly (key &optional insert)
5164 "Display documentation of the function invoked by KEY. KEY is a string."
5165 (interactive "kDescribe key: \nP")
5166 (gnus-article-check-buffer)
5167 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5169 (set-buffer gnus-article-current-summary)
5170 (let (gnus-pick-mode)
5171 (if (featurep 'xemacs)
5173 (push (elt key 0) unread-command-events)
5174 (setq key (events-to-keys
5175 (read-key-sequence "Describe key: "))))
5176 (setq unread-command-events
5178 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5179 (string-to-list key)))
5180 (setq key (read-key-sequence "Describe key: "))))
5181 (describe-key-briefly key insert))
5182 (describe-key-briefly key insert)))
5184 (defun gnus-article-reply-with-original (&optional wide)
5185 "Start composing a reply mail to the current message.
5186 The text in the region will be yanked. If the region isn't active,
5187 the entire article will be yanked."
5189 (let ((article (cdr gnus-article-current))
5191 (if (not (gnus-mark-active-p))
5192 (with-current-buffer gnus-summary-buffer
5193 (gnus-summary-reply (list (list article)) wide))
5194 (setq contents (buffer-substring (point) (mark t)))
5195 ;; Deactivate active regions.
5196 (when (and (boundp 'transient-mark-mode)
5197 transient-mark-mode)
5198 (setq mark-active nil))
5199 (with-current-buffer gnus-summary-buffer
5201 (list (list article contents)) wide)))))
5203 (defun gnus-article-followup-with-original ()
5204 "Compose a followup to the current article.
5205 The text in the region will be yanked. If the region isn't active,
5206 the entire article will be yanked."
5208 (let ((article (cdr gnus-article-current))
5210 (if (not (gnus-mark-active-p))
5211 (with-current-buffer gnus-summary-buffer
5212 (gnus-summary-followup (list (list article))))
5213 (setq contents (buffer-substring (point) (mark t)))
5214 ;; Deactivate active regions.
5215 (when (and (boundp 'transient-mark-mode)
5216 transient-mark-mode)
5217 (setq mark-active nil))
5218 (with-current-buffer gnus-summary-buffer
5219 (gnus-summary-followup
5220 (list (list article contents)))))))
5222 (defun gnus-article-hide (&optional arg force)
5223 "Hide all the gruft in the current article.
5224 This means that signatures, cited text and (some) headers will be
5226 If given a prefix, show the hidden text instead."
5227 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5228 (gnus-article-hide-headers arg)
5229 (gnus-article-hide-list-identifiers arg)
5230 (gnus-article-hide-citation-maybe arg force)
5231 (gnus-article-hide-signature arg))
5233 (defun gnus-article-maybe-highlight ()
5234 "Do some article highlighting if article highlighting is requested."
5235 (when (gnus-visual-p 'article-highlight 'highlight)
5236 (gnus-article-highlight-some)))
5238 (defun gnus-check-group-server ()
5239 ;; Make sure the connection to the server is alive.
5240 (unless (gnus-server-opened
5241 (gnus-find-method-for-group gnus-newsgroup-name))
5242 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5243 (gnus-request-group gnus-newsgroup-name t)))
5246 (autoload 'nneething-get-file-name "nneething"))
5248 (defun gnus-request-article-this-buffer (article group)
5249 "Get an article and insert it into this buffer."
5250 (let (do-update-line sparse-header)
5254 (gnus-kill-all-overlays)
5255 (setq group (or group gnus-newsgroup-name))
5257 ;; Using `gnus-request-article' directly will insert the article into
5258 ;; `nntp-server-buffer' - so we'll save some time by not having to
5259 ;; copy it from the server buffer into the article buffer.
5261 ;; We only request an article by message-id when we do not have the
5262 ;; headers for it, so we'll have to get those.
5263 (when (stringp article)
5264 (gnus-read-header article))
5266 ;; If the article number is negative, that means that this article
5267 ;; doesn't belong in this newsgroup (possibly), so we find its
5268 ;; message-id and request it by id instead of number.
5269 (when (and (numberp article)
5271 (get-buffer gnus-summary-buffer)
5272 (gnus-buffer-exists-p gnus-summary-buffer))
5274 (set-buffer gnus-summary-buffer)
5275 (let ((header (gnus-summary-article-header article)))
5278 ((memq article gnus-newsgroup-sparse)
5279 ;; This is a sparse gap article.
5280 (setq do-update-line article)
5281 (setq article (mail-header-id header))
5282 (setq sparse-header (gnus-read-header article))
5283 (setq gnus-newsgroup-sparse
5284 (delq article gnus-newsgroup-sparse)))
5286 ;; It's a real article.
5287 (setq article (mail-header-id header)))
5289 ;; It is an extracted pseudo-article.
5290 (setq article 'pseudo)
5291 (gnus-request-pseudo-article header))))
5293 (let ((method (gnus-find-method-for-group
5294 gnus-newsgroup-name)))
5295 (when (and (eq (car method) 'nneething)
5297 (let ((dir (nneething-get-file-name
5298 (mail-header-id header))))
5299 (when (and (stringp dir)
5300 (file-directory-p dir))
5301 (setq article 'nneething)
5302 (gnus-group-enter-directory dir))))))))
5305 ;; Refuse to select canceled articles.
5306 ((and (numberp article)
5308 (get-buffer gnus-summary-buffer)
5309 (gnus-buffer-exists-p gnus-summary-buffer)
5310 (eq (cdr (save-excursion
5311 (set-buffer gnus-summary-buffer)
5312 (assq article gnus-newsgroup-reads)))
5313 gnus-canceled-mark))
5315 ;; We first check `gnus-original-article-buffer'.
5316 ((and (get-buffer gnus-original-article-buffer)
5319 (set-buffer gnus-original-article-buffer)
5320 (and (equal (car gnus-original-article) group)
5321 (eq (cdr gnus-original-article) article))))
5322 (insert-buffer-substring gnus-original-article-buffer)
5324 ;; Check the backlog.
5325 ((and gnus-keep-backlog
5326 (gnus-backlog-request-article group article (current-buffer)))
5328 ;; Check asynchronous pre-fetch.
5329 ((gnus-async-request-fetched-article group article (current-buffer))
5330 (gnus-async-prefetch-next group article gnus-summary-buffer)
5331 (when (and (numberp article) gnus-keep-backlog)
5332 (gnus-backlog-enter-article group article (current-buffer)))
5335 ((and gnus-use-cache
5337 (gnus-cache-request-article article group))
5339 ;; Check the agent cache.
5340 ((gnus-agent-request-article article group)
5342 ;; Get the article and put into the article buffer.
5343 ((or (stringp article)
5345 (let ((gnus-override-method gnus-override-method)
5346 (methods (and (stringp article)
5347 gnus-refer-article-method))
5348 (backend (car (gnus-find-method-for-group
5349 gnus-newsgroup-name)))
5351 (buffer-read-only nil))
5352 (if (or (not (listp methods))
5353 (and (symbolp (car methods))
5354 (assq (car methods) nnoo-definition-alist)))
5355 (setq methods (list methods)))
5356 (when (and (null gnus-override-method)
5358 (setq gnus-override-method (pop methods)))
5360 (when (eq gnus-override-method 'current)
5361 (setq gnus-override-method
5362 (with-current-buffer gnus-summary-buffer
5363 gnus-current-select-method)))
5365 (gnus-kill-all-overlays)
5366 (let ((gnus-newsgroup-name group))
5367 (gnus-check-group-server))
5369 ((gnus-request-article article group (current-buffer))
5370 (when (numberp article)
5371 (gnus-async-prefetch-next group article
5372 gnus-summary-buffer)
5373 (when gnus-keep-backlog
5374 (gnus-backlog-enter-article
5375 group article (current-buffer))))
5376 (setq result 'article))
5378 (setq gnus-override-method (pop methods)))
5379 ((not (string-match "^400 "
5380 (nnheader-get-report backend)))
5381 ;; If we get 400 server disconnect, reconnect and
5382 ;; retry; otherwise, assume the article has expired.
5383 (setq result 'done))))
5384 (and (eq result 'article) 'article)))
5388 ;; Associate this article with the current summary buffer.
5389 (setq gnus-article-current-summary gnus-summary-buffer)
5391 ;; Take the article from the original article buffer
5392 ;; and place it in the buffer it's supposed to be in.
5393 (when (and (get-buffer gnus-article-buffer)
5394 (equal (buffer-name (current-buffer))
5395 (buffer-name (get-buffer gnus-article-buffer))))
5397 (if (get-buffer gnus-original-article-buffer)
5398 (set-buffer gnus-original-article-buffer)
5399 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5400 (buffer-disable-undo)
5401 (setq major-mode 'gnus-original-article-mode)
5402 (setq buffer-read-only t))
5403 (let (buffer-read-only)
5405 (insert-buffer-substring gnus-article-buffer))
5406 (setq gnus-original-article (cons group article)))
5409 (run-hooks 'gnus-article-decode-hook)
5410 ;; Mark article as decoded or not.
5411 (setq gnus-article-decoded-p gnus-article-decode-hook))
5413 ;; Update sparse articles.
5414 (when (and do-update-line
5415 (or (numberp article)
5417 (let ((buf (current-buffer)))
5418 (set-buffer gnus-summary-buffer)
5419 (gnus-summary-update-article do-update-line sparse-header)
5420 (gnus-summary-goto-subject do-update-line nil t)
5421 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5423 (set-buffer buf))))))
5429 (defcustom gnus-article-edit-mode-hook nil
5430 "Hook run in article edit mode buffers."
5431 :group 'gnus-article-various
5434 (defvar gnus-article-edit-done-function nil)
5436 (defvar gnus-article-edit-mode-map nil)
5437 (defvar gnus-article-edit-mode nil)
5439 ;; Should we be using derived.el for this?
5440 (unless gnus-article-edit-mode-map
5441 (setq gnus-article-edit-mode-map (make-keymap))
5442 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5444 (gnus-define-keys gnus-article-edit-mode-map
5445 "\C-c?" describe-mode
5446 "\C-c\C-c" gnus-article-edit-done
5447 "\C-c\C-k" gnus-article-edit-exit
5448 "\C-c\C-f\C-t" message-goto-to
5449 "\C-c\C-f\C-o" message-goto-from
5450 "\C-c\C-f\C-b" message-goto-bcc
5451 ;;"\C-c\C-f\C-w" message-goto-fcc
5452 "\C-c\C-f\C-c" message-goto-cc
5453 "\C-c\C-f\C-s" message-goto-subject
5454 "\C-c\C-f\C-r" message-goto-reply-to
5455 "\C-c\C-f\C-n" message-goto-newsgroups
5456 "\C-c\C-f\C-d" message-goto-distribution
5457 "\C-c\C-f\C-f" message-goto-followup-to
5458 "\C-c\C-f\C-m" message-goto-mail-followup-to
5459 "\C-c\C-f\C-k" message-goto-keywords
5460 "\C-c\C-f\C-u" message-goto-summary
5461 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5462 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5463 "\C-c\C-b" message-goto-body
5464 "\C-c\C-i" message-goto-signature
5466 "\C-c\C-t" message-insert-to
5467 "\C-c\C-n" message-insert-newsgroups
5468 "\C-c\C-o" message-sort-headers
5469 "\C-c\C-e" message-elide-region
5470 "\C-c\C-v" message-delete-not-region
5471 "\C-c\C-z" message-kill-to-signature
5472 "\M-\r" message-newline-and-reformat
5473 "\C-c\C-a" mml-attach-file
5474 "\C-a" message-beginning-of-line
5476 "\M-;" comment-region)
5478 (gnus-define-keys (gnus-article-edit-wash-map
5479 "\C-c\C-w" gnus-article-edit-mode-map)
5480 "f" gnus-article-edit-full-stops))
5483 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5485 ["Fetch To" message-insert-to t]
5486 ["Fetch Newsgroups" message-insert-newsgroups t]
5488 ["To" message-goto-to t]
5489 ["From" message-goto-from t]
5490 ["Subject" message-goto-subject t]
5491 ["Cc" message-goto-cc t]
5492 ["Reply-To" message-goto-reply-to t]
5493 ["Summary" message-goto-summary t]
5494 ["Keywords" message-goto-keywords t]
5495 ["Newsgroups" message-goto-newsgroups t]
5496 ["Followup-To" message-goto-followup-to t]
5497 ["Mail-Followup-To" message-goto-mail-followup-to t]
5498 ["Distribution" message-goto-distribution t]
5499 ["Body" message-goto-body t]
5500 ["Signature" message-goto-signature t]))
5502 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5503 "Major mode for editing articles.
5504 This is an extended text-mode.
5506 \\{gnus-article-edit-mode-map}"
5507 (make-local-variable 'gnus-article-edit-done-function)
5508 (make-local-variable 'gnus-prev-winconf)
5509 (set (make-local-variable 'font-lock-defaults)
5510 '(message-font-lock-keywords t))
5511 (set (make-local-variable 'mail-header-separator) "")
5512 (set (make-local-variable 'gnus-article-edit-mode) t)
5513 (easy-menu-add message-mode-field-menu message-mode-map)
5515 (setq buffer-read-only nil)
5516 (buffer-enable-undo)
5519 (defun gnus-article-edit (&optional force)
5520 "Edit the current article.
5521 This will have permanent effect only in mail groups.
5522 If FORCE is non-nil, allow editing of articles even in read-only
5525 (when (and (not force)
5526 (gnus-group-read-only-p))
5527 (error "The current newsgroup does not support article editing"))
5528 (gnus-article-date-original)
5529 (gnus-article-edit-article
5531 `(lambda (no-highlight)
5533 (gnus-summary-edit-article-done
5534 ,(or (mail-header-references gnus-current-headers) "")
5535 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5537 (defun gnus-article-edit-article (start-func exit-func)
5538 "Start editing the contents of the current article buffer."
5539 (let ((winconf (current-window-configuration)))
5540 (set-buffer gnus-article-buffer)
5541 (gnus-article-edit-mode)
5542 (funcall start-func)
5543 (set-buffer-modified-p nil)
5544 (gnus-configure-windows 'edit-article)
5545 (setq gnus-article-edit-done-function exit-func)
5546 (setq gnus-prev-winconf winconf)
5547 (gnus-message 6 "C-c C-c to end edits")))
5549 (defun gnus-article-edit-done (&optional arg)
5550 "Update the article edits and exit."
5552 (let ((func gnus-article-edit-done-function)
5553 (buf (current-buffer))
5554 (start (window-start))
5556 (winconf gnus-prev-winconf))
5557 (widen) ;; Widen it in case that users narrowed the buffer.
5560 ;; The cache and backlog have to be flushed somewhat.
5561 (when gnus-keep-backlog
5562 (gnus-backlog-remove-article
5563 (car gnus-article-current) (cdr gnus-article-current)))
5564 ;; Flush original article as well.
5566 (when (get-buffer gnus-original-article-buffer)
5567 (set-buffer gnus-original-article-buffer)
5568 (setq gnus-original-article nil)))
5569 (when gnus-use-cache
5570 (gnus-cache-update-article
5571 (car gnus-article-current) (cdr gnus-article-current)))
5572 ;; We remove all text props from the article buffer.
5573 (kill-all-local-variables)
5574 (gnus-set-text-properties (point-min) (point-max) nil)
5576 (set-window-configuration winconf)
5578 (set-window-start (get-buffer-window buf) start)
5579 (set-window-point (get-buffer-window buf) (point))))
5581 (defun gnus-article-edit-exit ()
5582 "Exit the article editing without updating."
5584 (when (or (not (buffer-modified-p))
5585 (yes-or-no-p "Article modified; kill anyway? "))
5586 (let ((curbuf (current-buffer))
5588 (window-start (window-start)))
5590 (if (gnus-buffer-live-p gnus-original-article-buffer)
5591 (insert-buffer gnus-original-article-buffer))
5592 (let ((winconf gnus-prev-winconf))
5593 (kill-all-local-variables)
5595 (set-window-configuration winconf)
5596 ;; Tippy-toe some to make sure that point remains where it was.
5597 (save-current-buffer
5599 (set-window-start (get-buffer-window (current-buffer)) window-start)
5602 (defun gnus-article-edit-full-stops ()
5603 "Interactively repair spacing at end of sentences."
5606 (goto-char (point-min))
5607 (search-forward-regexp "^$" nil t)
5608 (let ((case-fold-search nil))
5609 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5612 ;;; Article highlights
5615 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5617 ;;; Internal Variables:
5619 (defcustom gnus-button-url-regexp
5620 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5621 "\\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:]]\\)"
5622 "\\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\\)\\)")
5623 "Regular expression that matches URLs."
5624 :group 'gnus-article-buttons
5627 (defcustom gnus-button-valid-fqdn-regexp
5628 message-valid-fqdn-regexp
5629 "Regular expression that matches a valid FQDN."
5630 :group 'gnus-article-buttons
5633 (defcustom gnus-button-man-handler 'manual-entry
5634 "Function to use for displaying man pages.
5635 The function must take at least one argument with a string naming the
5637 :type '(choice (function-item :tag "Man" manual-entry)
5638 (function-item :tag "Woman" woman)
5639 (function :tag "Other"))
5640 :group 'gnus-article-buttons)
5642 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5643 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5644 If the default site is too slow, try to find a CTAN mirror, see
5645 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5646 the variable `gnus-button-handle-ctan'."
5647 :group 'gnus-article-buttons
5648 :link '(custom-manual "(gnus)Group Parameters")
5649 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5650 (const "http://tug.ctan.org/tex-archive/")
5651 (const "http://www.dante.de/CTAN/")
5652 (string :tag "Other")))
5654 (defcustom gnus-button-ctan-handler 'browse-url
5655 "Function to use for displaying CTAN links.
5656 The function must take one argument, the string naming the URL."
5657 :type '(choice (function-item :tag "Browse Url" browse-url)
5658 (function :tag "Other"))
5659 :group 'gnus-article-buttons)
5661 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5662 "Bogus strings removed from CTAN URLs."
5663 :group 'gnus-article-buttons
5664 :type '(choice (const "^/?tex-archive/\\|/")
5665 (regexp :tag "Other")))
5667 (defcustom gnus-button-ctan-directory-regexp
5669 "\\("; Cannot use `\(?: ... \)' (compatibility with Emacs 20).
5670 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5671 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5672 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5674 "Regular expression for ctan directories.
5675 It should match all directories in the top level of `gnus-ctan-url'."
5676 :group 'gnus-article-buttons
5679 (defcustom gnus-button-mid-or-mail-regexp
5680 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
5681 gnus-button-valid-fqdn-regexp
5683 "Regular expression that matches a message ID or a mail address."
5684 :group 'gnus-article-buttons
5687 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5688 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5689 Strings like this can be either a message ID or a mail address. If it is one
5690 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5691 message ID or a mail address, respectively. If this variable is set to the
5692 symbol `ask', always query the user what do do. If it is a function, this
5693 function will be called with the string as it's only argument. The function
5694 must return `mid', `mail', `invalid' or `ask'."
5695 :group 'gnus-article-buttons
5696 :type '(choice (function-item :tag "Heuristic function"
5697 gnus-button-mid-or-mail-heuristic)
5702 (defcustom gnus-button-mid-or-mail-heuristic-alist
5703 '((-10.0 . ".+\\$.+@")
5706 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5707 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5708 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5709 (-1.0 . "^[^a-z]+@")
5711 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5712 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5713 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5714 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5717 (-1.0 . "^[0-9][0-9]")
5719 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5720 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5721 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5722 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5724 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5725 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5728 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5730 ;; compensation for TDMA dated mail addresses:
5731 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5733 (-20.0 . "\\.fsf@") ;; Gnus
5736 (-20.0 . "_-_") ;; Subject change in thread
5738 (-20.0 . "\\.ln@") ;; leafnode
5739 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5740 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5742 ;; (5.0 . "") ;; $local_part_len <= 7
5743 (10.0 . "^[^0-9]+@")
5744 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5745 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5748 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5750 (0.5 . "^[A-Z][a-z]")
5751 (0.5 . "^[A-Z][a-z][a-z]")
5752 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5753 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5754 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5756 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5757 address. The REGEXP is processed with `case-fold-search' set to nil."
5758 :group 'gnus-article-buttons
5759 :type '(repeat (cons (number :tag "Rate")
5760 (regexp :tag "Regexp"))))
5762 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5763 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5764 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5765 address, `ask' if unsure and `invalid' if the string is invalid."
5766 (let ((case-fold-search nil)
5767 (list gnus-button-mid-or-mail-heuristic-alist)
5768 (result 0) rate regexp lpartlen elem)
5770 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5771 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5772 ;; Certain special cases...
5775 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$" "\\|"
5776 "^[0-9]+\.[0-9]+\@compuserve")
5778 (gnus-message 8 "`%s' is a known mail address.")
5779 (setq result 'mail))
5780 (when (string-match "@.*@\\| " mid-or-mail)
5781 (gnus-message 8 "`%s' is invalid.")
5782 (setq result 'invalid))
5783 ;; Nothing more to do, if result is not a number here...
5784 (when (numberp result)
5786 (setq elem (car list)
5790 (when (string-match regexp mid-or-mail)
5791 (setq result (+ result rate))
5793 9 "`%s' matched `%s', rate `%s', result `%s'."
5794 mid-or-mail regexp rate result)))
5795 (when (<= lpartlen 7)
5796 (setq result (+ result 5.0))
5797 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
5798 mid-or-mail result))
5799 (when (>= lpartlen 12)
5800 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
5802 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
5803 ;; Long local part should contain realname if e-mail address,
5804 ;; too many digits: message-id.
5805 ;; $score -= 5.0 + 0.1 * $local_part_len;
5806 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
5807 (setq result (+ result rate))
5809 9 "Many digits in `%s', rate `%s', result `%s'."
5810 mid-or-mail rate result))
5811 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
5813 ;; Too few vowels [^aeiouy]{4,}.*\@
5814 (setq result (+ result -5.0))
5816 9 "Few vowels in `%s', rate `%s', result `%s'."
5817 mid-or-mail -5.0 result))
5819 (setq result (+ result 5.0))
5821 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
5822 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
5824 ;; Maybe we should make this a customizable alist: (condition . 'result)
5825 ((< result -10.0) 'mid)
5826 ((> result 10.0) 'mail)
5829 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5830 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
5831 (url-mid (concat "news" ":" mid-or-mail))
5832 (url-mailto (concat "mailto" ":" mid-or-mail)))
5833 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5834 (when (fboundp pref)
5836 ;; get rid of surrounding angles...
5838 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
5839 (if (or (eq 'mid guessed) (eq 'mail guessed))
5843 (save-window-excursion
5844 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5847 (cond ((eq pref 'mid)
5848 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
5849 (gnus-button-handle-news url-mid))
5851 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
5852 (gnus-url-mailto url-mailto))
5853 (t (gnus-message 3 "Invalid string.")))))
5855 (defun gnus-button-handle-custom (url)
5856 "Follow a Custom URL."
5857 (customize-apropos (gnus-url-unhex-string url)))
5859 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5861 ;; FIXME: Maybe we should merge some of the functions that do quite similar
5864 (defun gnus-button-handle-describe-function (url)
5865 "Call `describe-function' when pushing the corresponding URL button."
5868 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5870 (defun gnus-button-handle-describe-variable (url)
5871 "Call `describe-variable' when pushing the corresponding URL button."
5874 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5876 (defun gnus-button-handle-symbol (url)
5877 "Display help on variable or function.
5878 Calls `describe-variable' or `describe-function'."
5879 (let ((sym (intern url)))
5881 ((fboundp sym) (describe-function sym))
5882 ((boundp sym) (describe-variable sym))
5883 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
5885 (defun gnus-button-handle-describe-key (url)
5886 "Call `describe-key' when pushing the corresponding URL button."
5888 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5889 (keys (ignore-errors (eval `(kbd ,key-string)))))
5892 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5894 (defun gnus-button-handle-apropos (url)
5895 "Call `apropos' when pushing the corresponding URL button."
5896 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5898 (defun gnus-button-handle-apropos-command (url)
5899 "Call `apropos' when pushing the corresponding URL button."
5901 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5903 (defun gnus-button-handle-apropos-variable (url)
5904 "Call `apropos' when pushing the corresponding URL button."
5906 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5907 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5909 (defun gnus-button-handle-apropos-documentation (url)
5910 "Call `apropos' when pushing the corresponding URL button."
5912 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
5913 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5915 (defun gnus-button-handle-library (url)
5916 "Call `locate-library' when pushing the corresponding URL button."
5917 (gnus-message 9 "url=`%s'" url)
5918 (let* ((lib (locate-library url))
5919 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
5921 (gnus-message 1 "Cannot locale library `%s'." url)
5922 (find-file-read-only file))))
5924 (defun gnus-button-handle-ctan (url)
5925 "Call `browse-url' when pushing a CTAN URL button."
5927 gnus-button-ctan-handler
5930 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
5932 (defcustom gnus-button-tex-level 5
5933 "*Integer that says how many TeX-related buttons Gnus will show.
5934 The higher the number, the more buttons will appear and the more false
5935 positives are possible. Note that you can set this variable local to
5936 specifific groups. Setting it higher in TeX groups is probably a good idea.
5937 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5938 how to set variables in specific groups."
5939 :group 'gnus-article-buttons
5940 :link '(custom-manual "(gnus)Group Parameters")
5943 (defcustom gnus-button-man-level 5
5944 "*Integer that says how many man-related buttons Gnus will show.
5945 The higher the number, the more buttons will appear and the more false
5946 positives are possible. Note that you can set this variable local to
5947 specifific groups. Setting it higher in Unix groups is probably a good idea.
5948 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5949 how to set variables in specific groups."
5950 :group 'gnus-article-buttons
5951 :link '(custom-manual "(gnus)Group Parameters")
5954 (defcustom gnus-button-emacs-level 5
5955 "*Integer that says how many emacs-related buttons Gnus will show.
5956 The higher the number, the more buttons will appear and the more false
5957 positives are possible. Note that you can set this variable local to
5958 specifific groups. Setting it higher in Emacs or Gnus related groups is
5959 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
5960 `gnus-parameters' on how to set variables in specific groups."
5961 :group 'gnus-article-buttons
5962 :link '(custom-manual "(gnus)Group Parameters")
5965 (defcustom gnus-button-message-level 5
5966 "*Integer that says how many buttons for news or mail messages will appear.
5967 The higher the number, the more buttons will appear and the more false
5968 positives are possible."
5969 ;; mail addresses, MIDs, URLs for news, ...
5970 :group 'gnus-article-buttons
5973 (defcustom gnus-button-browse-level 5
5974 "*Integer that says how many buttons for browsing will appear.
5975 The higher the number, the more buttons will appear and the more false
5976 positives are possible."
5977 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
5978 :group 'gnus-article-buttons
5981 (defcustom gnus-button-alist
5982 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5983 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
5984 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5985 gnus-button-handle-news 2)
5986 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5987 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
5988 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
5989 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
5990 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
5991 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
5992 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
5993 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
5994 ("mailto:\\([-a-z.@_+0-9%=?]+\\)"
5995 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
5996 ("\\bmailto:\\([^ \n\t]+\\)"
5997 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
5999 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6000 gnus-button-ctan-directory-regexp
6001 "[^][>)!;:,'\n\t ]+\\)")
6002 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6003 ((concat "\\btex-archive/\\("
6004 gnus-button-ctan-directory-regexp
6005 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6006 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6009 gnus-button-ctan-directory-regexp
6010 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6011 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6013 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)"
6014 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6015 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6016 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6017 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6018 ;; Info links like `C-h i d m CC Mode RET'
6019 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6021 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6022 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6023 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6024 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6025 ;; Emacs help commands
6026 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6027 ;; regexp doesn't match arguments containing ` '.
6028 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6029 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6030 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6031 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6032 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6033 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6034 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6035 ;; The following entries may lead to many false positives so don't enable
6036 ;; them by default (use a high button level):
6037 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6038 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6039 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6040 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6041 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6042 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6043 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6044 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6045 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6046 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6047 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6048 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6049 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6050 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6051 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6052 ;; Unlike the other regexps we really have to require quoting
6053 ;; here to determine where it ends.
6054 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6055 ;; This is how URLs _should_ be embedded in text (RFC 1738)...
6056 ("<URL: *\\([^<>]*\\)>"
6057 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6059 (gnus-button-url-regexp
6060 0 (>= gnus-button-browse-level 0) browse-url 0)
6062 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6063 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6064 gnus-button-handle-man 1)
6065 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6066 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6067 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6068 gnus-button-handle-man 1)
6069 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6070 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6071 ("\\b\\([a-z][-_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6072 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6073 ;; MID or mail: To avoid too many false positives we don't try to catch
6074 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6075 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6076 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6077 ;; so that non-ambiguous entries (see above) match first.
6078 (gnus-button-mid-or-mail-regexp
6079 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6080 "*Alist of regexps matching buttons in article bodies.
6082 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6083 REGEXP: is the string (case insensitive) matching text around the button (can
6084 also be lisp expression evaluating to a string),
6085 BUTTON: is the number of the regexp grouping actually matching the button,
6086 FORM: is a lisp expression which must eval to true for the button to
6088 CALLBACK: is the function to call when the user push this button, and each
6089 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6091 CALLBACK can also be a variable, in that case the value of that
6092 variable it the real callback function."
6093 :group 'gnus-article-buttons
6094 :type '(repeat (list (choice regexp variable)
6095 (integer :tag "Button")
6097 (function :tag "Callback")
6100 (integer :tag "Regexp group")))))
6102 (defcustom gnus-header-button-alist
6103 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
6104 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6105 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6106 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6107 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6108 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6109 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6110 0 (>= gnus-button-browse-level 0) browse-url 0)
6111 ("^Subject:" gnus-button-url-regexp
6112 0 (>= gnus-button-browse-level 0) browse-url 0)
6113 ("^[^:]+:" gnus-button-url-regexp
6114 0 (>= gnus-button-browse-level 0) browse-url 0)
6115 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)"
6116 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6117 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6118 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6119 "*Alist of headers and regexps to match buttons in article heads.
6121 This alist is very similar to `gnus-button-alist', except that each
6122 alist has an additional HEADER element first in each entry:
6124 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6126 HEADER is a regexp to match a header. For a fuller explanation, see
6127 `gnus-button-alist'."
6128 :group 'gnus-article-buttons
6129 :group 'gnus-article-headers
6130 :type '(repeat (list (regexp :tag "Header")
6132 (integer :tag "Button")
6134 (function :tag "Callback")
6137 (integer :tag "Regexp group")))))
6139 (defvar gnus-button-regexp nil)
6140 (defvar gnus-button-marker-list nil)
6141 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6143 (defvar gnus-button-last nil)
6144 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6148 (defun gnus-article-push-button (event)
6149 "Check text under the mouse pointer for a callback function.
6150 If the text under the mouse pointer has a `gnus-callback' property,
6151 call it with the value of the `gnus-data' text property."
6153 (set-buffer (window-buffer (posn-window (event-start event))))
6154 (let* ((pos (posn-point (event-start event)))
6155 (data (get-text-property pos 'gnus-data))
6156 (fun (get-text-property pos 'gnus-callback)))
6159 (funcall fun data))))
6161 (defun gnus-article-press-button ()
6162 "Check text at point for a callback function.
6163 If the text at point has a `gnus-callback' property,
6164 call it with the value of the `gnus-data' text property."
6166 (let ((data (get-text-property (point) 'gnus-data))
6167 (fun (get-text-property (point) 'gnus-callback)))
6169 (funcall fun data))))
6171 (defun gnus-article-highlight (&optional force)
6172 "Highlight current article.
6173 This function calls `gnus-article-highlight-headers',
6174 `gnus-article-highlight-citation',
6175 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6176 do the highlighting. See the documentation for those functions."
6177 (interactive (list 'force))
6178 (gnus-article-highlight-headers)
6179 (gnus-article-highlight-citation force)
6180 (gnus-article-highlight-signature)
6181 (gnus-article-add-buttons force)
6182 (gnus-article-add-buttons-to-head))
6184 (defun gnus-article-highlight-some (&optional force)
6185 "Highlight current article.
6186 This function calls `gnus-article-highlight-headers',
6187 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6188 do the highlighting. See the documentation for those functions."
6189 (interactive (list 'force))
6190 (gnus-article-highlight-headers)
6191 (gnus-article-highlight-signature)
6192 (gnus-article-add-buttons))
6194 (defun gnus-article-highlight-headers ()
6195 "Highlight article headers as specified by `gnus-header-face-alist'."
6198 (set-buffer gnus-article-buffer)
6200 (let ((alist gnus-header-face-alist)
6201 (buffer-read-only nil)
6202 (case-fold-search t)
6203 (inhibit-point-motion-hooks t)
6204 entry regexp header-face field-face from hpoints fpoints)
6205 (article-narrow-to-head)
6206 (while (setq entry (pop alist))
6207 (goto-char (point-min))
6208 (setq regexp (concat "^\\("
6209 (if (string-equal "" (nth 0 entry))
6213 header-face (nth 1 entry)
6214 field-face (nth 2 entry))
6215 (while (and (re-search-forward regexp nil t)
6219 (unless (search-forward ":" nil t)
6221 (when (and header-face
6222 (not (memq (point) hpoints)))
6223 (push (point) hpoints)
6224 (gnus-put-text-property from (point) 'face header-face))
6225 (when (and field-face
6226 (not (memq (setq from (point)) fpoints)))
6228 (if (re-search-forward "^[^ \t]" nil t)
6230 (goto-char (point-max)))
6231 (gnus-put-text-property from (point) 'face field-face))))))))
6233 (defun gnus-article-highlight-signature ()
6234 "Highlight the signature in an article.
6235 It does this by highlighting everything after
6236 `gnus-signature-separator' using `gnus-signature-face'."
6239 (set-buffer gnus-article-buffer)
6240 (let ((buffer-read-only nil)
6241 (inhibit-point-motion-hooks t))
6243 (when (and gnus-signature-face
6244 (gnus-article-narrow-to-signature))
6245 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6246 'face gnus-signature-face)
6248 (gnus-article-search-signature)
6249 (let ((start (match-beginning 0))
6250 (end (set-marker (make-marker) (1+ (match-end 0)))))
6251 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6254 (defun gnus-button-in-region-p (b e prop)
6255 "Say whether PROP exists in the region."
6256 (text-property-not-all b e prop nil))
6258 (defun gnus-article-add-buttons (&optional force)
6259 "Find external references in the article and make buttons of them.
6260 \"External references\" are things like Message-IDs and URLs, as
6261 specified by `gnus-button-alist'."
6262 (interactive (list 'force))
6264 (set-buffer gnus-article-buffer)
6265 (let ((buffer-read-only nil)
6266 (inhibit-point-motion-hooks t)
6267 (case-fold-search t)
6268 (alist gnus-button-alist)
6270 ;; Remove all old markers.
6271 (let (marker entry new-list)
6272 (while (setq marker (pop gnus-button-marker-list))
6273 (if (or (< marker (point-min)) (>= marker (point-max)))
6274 (push marker new-list)
6276 (when (setq entry (gnus-button-entry))
6277 (put-text-property (match-beginning (nth 1 entry))
6278 (match-end (nth 1 entry))
6279 'gnus-callback nil))
6280 (set-marker marker nil)))
6281 (setq gnus-button-marker-list new-list))
6282 ;; We skip the headers.
6285 (while (setq entry (pop alist))
6286 (setq regexp (eval (car entry)))
6288 (while (re-search-forward regexp nil t)
6289 (let* ((start (and entry (match-beginning (nth 1 entry))))
6290 (end (and entry (match-end (nth 1 entry))))
6291 (from (match-beginning 0)))
6292 (when (and (or (eq t (nth 2 entry))
6293 (eval (nth 2 entry)))
6294 (not (gnus-button-in-region-p
6295 start end 'gnus-callback)))
6296 ;; That optional form returned non-nil, so we add the
6298 (gnus-article-add-button
6299 start end 'gnus-button-push
6300 (car (push (set-marker (make-marker) from)
6301 gnus-button-marker-list))))))))))
6303 ;; Add buttons to the head of an article.
6304 (defun gnus-article-add-buttons-to-head ()
6305 "Add buttons to the head of the article."
6308 (set-buffer gnus-article-buffer)
6310 (let ((buffer-read-only nil)
6311 (inhibit-point-motion-hooks t)
6312 (case-fold-search t)
6313 (alist gnus-header-button-alist)
6315 (article-narrow-to-head)
6317 ;; Each alist entry.
6318 (setq entry (car alist)
6320 (goto-char (point-min))
6321 (while (re-search-forward (car entry) nil t)
6322 ;; Each header matching the entry.
6323 (setq beg (match-beginning 0))
6324 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6325 (match-beginning 0))
6328 (while (re-search-forward (eval (nth 1 entry)) end t)
6329 ;; Each match within a header.
6330 (let* ((entry (cdr entry))
6331 (start (match-beginning (nth 1 entry)))
6332 (end (match-end (nth 1 entry)))
6333 (form (nth 2 entry)))
6334 (goto-char (match-end 0))
6336 (gnus-article-add-button
6337 start end (nth 3 entry)
6338 (buffer-substring (match-beginning (nth 4 entry))
6339 (match-end (nth 4 entry)))))))
6340 (goto-char end)))))))
6342 ;;; External functions:
6344 (defun gnus-article-add-button (from to fun &optional data)
6345 "Create a button between FROM and TO with callback FUN and data DATA."
6346 (when gnus-article-button-face
6347 (gnus-overlay-put (gnus-make-overlay from to)
6348 'face gnus-article-button-face))
6349 (gnus-add-text-properties
6351 (nconc (and gnus-article-mouse-face
6352 (list gnus-mouse-face-prop gnus-article-mouse-face))
6353 (list 'gnus-callback fun)
6354 (and data (list 'gnus-data data))))
6355 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6356 :button-keymap gnus-widget-button-keymap))
6358 ;;; Internal functions:
6360 (defun gnus-article-set-globals ()
6362 (set-buffer gnus-summary-buffer)
6363 (gnus-set-global-variables)))
6365 (defun gnus-signature-toggle (end)
6367 (set-buffer gnus-article-buffer)
6368 (let ((buffer-read-only nil)
6369 (inhibit-point-motion-hooks t))
6370 (if (text-property-any end (point-max) 'article-type 'signature)
6372 (gnus-delete-wash-type 'signature)
6373 (gnus-remove-text-properties-when
6374 'article-type 'signature end (point-max)
6375 (cons 'article-type (cons 'signature
6376 gnus-hidden-properties))))
6377 (gnus-add-wash-type 'signature)
6378 (gnus-add-text-properties-when
6379 'article-type nil end (point-max)
6380 (cons 'article-type (cons 'signature
6381 gnus-hidden-properties)))))
6382 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6383 (gnus-set-mode-line 'article))))
6385 (defun gnus-button-entry ()
6386 ;; Return the first entry in `gnus-button-alist' matching this place.
6387 (let ((alist gnus-button-alist)
6390 (setq entry (pop alist))
6391 (if (looking-at (eval (car entry)))
6396 (defun gnus-button-push (marker)
6397 ;; Push button starting at MARKER.
6400 (let* ((entry (gnus-button-entry))
6401 (inhibit-point-motion-hooks t)
6403 (args (mapcar (lambda (group)
6404 (let ((string (match-string group)))
6405 (gnus-set-text-properties
6406 0 (length string) nil string)
6413 (fboundp (symbol-value fun)))
6414 (apply (symbol-value fun) args))
6416 (gnus-message 1 "You must define `%S' to use this button"
6417 (cons fun args)))))))
6419 (defun gnus-parse-news-url (url)
6420 (let (scheme server group message-id articles)
6423 (goto-char (point-min))
6424 (when (looking-at "\\([A-Za-z]+\\):")
6425 (setq scheme (match-string 1))
6426 (goto-char (match-end 0)))
6427 (when (looking-at "//\\([^/]+\\)/")
6428 (setq server (match-string 1))
6429 (goto-char (match-end 0)))
6432 ((looking-at "\\(.*@.*\\)")
6433 (setq message-id (match-string 1)))
6434 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6435 (setq group (match-string 1)
6436 articles (split-string (match-string 2) "-")))
6437 ((looking-at "\\([^/]+\\)/?")
6438 (setq group (match-string 1)))
6440 (error "Unknown news URL syntax"))))
6441 (list scheme server group message-id articles)))
6443 (defun gnus-button-handle-news (url)
6445 (destructuring-bind (scheme server group message-id articles)
6446 (gnus-parse-news-url url)
6450 (set-buffer gnus-summary-buffer)
6452 (let ((gnus-refer-article-method (list (list 'nntp server))))
6453 (gnus-summary-refer-article message-id))
6454 (gnus-summary-refer-article message-id))))
6456 (gnus-button-fetch-group url)))))
6458 (defun gnus-button-handle-man (url)
6460 (funcall gnus-button-man-handler url))
6462 (defun gnus-button-handle-info-url (url)
6463 "Fetch an info URL."
6465 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6466 (gnus-info-find-node
6467 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6469 ")" (gnus-url-unhex-string (match-string 2 url)))))
6470 ((string-match "([^)\"]+)[^\"]+" url)
6472 (gnus-replace-in-string
6473 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6474 (gnus-info-find-node url))
6475 (t (error "Can't parse %s" url))))
6477 (defun gnus-button-handle-info-keystrokes (url)
6478 "Call `info' when pushing the corresponding URL button."
6479 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6484 (defun gnus-button-message-id (message-id)
6487 (set-buffer gnus-summary-buffer)
6488 (gnus-summary-refer-article message-id)))
6490 (defun gnus-button-fetch-group (address)
6491 "Fetch GROUP specified by ADDRESS."
6492 (if (not (string-match "[:/]" address))
6493 ;; This is just a simple group url.
6494 (gnus-group-read-ephemeral-group address gnus-select-method)
6497 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6499 (error "Can't parse %s" address)
6500 (gnus-group-read-ephemeral-group
6501 (match-string 4 address)
6502 `(nntp ,(match-string 1 address)
6503 (nntp-address ,(match-string 1 address))
6504 (nntp-port-number ,(if (match-end 3)
6505 (match-string 3 address)
6508 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6510 (defun gnus-url-parse-query-string (query &optional downcase)
6511 (let (retval pairs cur key val)
6512 (setq pairs (split-string query "&"))
6514 (setq cur (car pairs)
6516 (if (not (string-match "=" cur))
6518 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6519 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6521 (setq key (downcase key)))
6522 (setq cur (assoc key retval))
6524 (setcdr cur (cons val (cdr cur)))
6525 (setq retval (cons (list key val) retval)))))
6528 (defun gnus-url-mailto (url)
6529 ;; Send mail to someone
6530 (when (string-match "mailto:/*\\(.*\\)" url)
6531 (setq url (substring url (match-beginning 1) nil)))
6532 (let (to args subject func)
6533 (if (string-match (regexp-quote "?") url)
6534 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6535 args (gnus-url-parse-query-string
6536 (substring url (match-end 0) nil) t))
6537 (setq to (gnus-url-unhex-string url)))
6538 (setq args (cons (list "to" to) args)
6539 subject (cdr-safe (assoc "subject" args)))
6542 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6545 (message-position-on-field (caar args)))
6546 (insert (mapconcat 'identity (cdar args) ", "))
6547 (setq args (cdr args)))
6550 (message-goto-subject))))
6552 (defun gnus-button-embedded-url (address)
6553 "Activate ADDRESS with `browse-url'."
6554 (browse-url (gnus-strip-whitespace address)))
6556 ;;; Next/prev buttons in the article buffer.
6558 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6559 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6561 (defvar gnus-prev-page-map
6562 (let ((map (make-sparse-keymap)))
6563 (unless (>= emacs-major-version 21)
6564 ;; XEmacs doesn't care.
6565 (set-keymap-parent map gnus-article-mode-map))
6566 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6567 (define-key map "\r" 'gnus-button-prev-page)
6570 (defun gnus-insert-prev-page-button ()
6572 (buffer-read-only nil))
6574 gnus-prev-page-line-format nil
6575 `(,@(gnus-local-map-property gnus-prev-page-map)
6577 gnus-callback gnus-article-button-prev-page
6578 article-type annotation))
6579 (widget-convert-button
6581 ;; Exclude a newline.
6584 :action 'gnus-button-prev-page
6585 :button-keymap gnus-prev-page-map)))
6587 (defvar gnus-prev-page-map
6588 (let ((map (make-sparse-keymap)))
6589 (unless (>= emacs-major-version 21)
6590 ;; XEmacs doesn't care.
6591 (set-keymap-parent map gnus-article-mode-map))
6592 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6593 (define-key map "\r" 'gnus-button-prev-page)
6596 (defvar gnus-next-page-map
6597 (let ((map (make-sparse-keymap)))
6598 (unless (>= emacs-major-version 21)
6599 ;; XEmacs doesn't care.
6600 (set-keymap-parent map gnus-article-mode-map))
6601 (define-key map gnus-mouse-2 'gnus-button-next-page)
6602 (define-key map "\r" 'gnus-button-next-page)
6605 (defun gnus-button-next-page (&optional args more-args)
6606 "Go to the next page."
6608 (let ((win (selected-window)))
6609 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6610 (gnus-article-next-page)
6611 (select-window win)))
6613 (defun gnus-button-prev-page (&optional args more-args)
6614 "Go to the prev page."
6616 (let ((win (selected-window)))
6617 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6618 (gnus-article-prev-page)
6619 (select-window win)))
6621 (defun gnus-insert-next-page-button ()
6623 (buffer-read-only nil))
6624 (gnus-eval-format gnus-next-page-line-format nil
6625 `(,@(gnus-local-map-property gnus-next-page-map)
6627 gnus-callback gnus-article-button-next-page
6628 article-type annotation))
6629 (widget-convert-button
6631 ;; Exclude a newline.
6634 :action 'gnus-button-next-page
6635 :button-keymap gnus-next-page-map)))
6637 (defun gnus-article-button-next-page (arg)
6638 "Go to the next page."
6640 (let ((win (selected-window)))
6641 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6642 (gnus-article-next-page)
6643 (select-window win)))
6645 (defun gnus-article-button-prev-page (arg)
6646 "Go to the prev page."
6648 (let ((win (selected-window)))
6649 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6650 (gnus-article-prev-page)
6651 (select-window win)))
6653 (defvar gnus-decode-header-methods
6654 '(mail-decode-encoded-word-region)
6655 "List of methods used to decode headers.
6657 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6658 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6659 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6660 whose names match REGEXP.
6663 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6664 mail-decode-encoded-word-region
6665 (\"chinese\" . rfc1843-decode-region))
6668 (defvar gnus-decode-header-methods-cache nil)
6670 (defun gnus-multi-decode-header (start end)
6671 "Apply the functions from `gnus-encoded-word-methods' that match."
6672 (unless (and gnus-decode-header-methods-cache
6673 (eq gnus-newsgroup-name
6674 (car gnus-decode-header-methods-cache)))
6675 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6678 (nconc gnus-decode-header-methods-cache (list x))
6679 (if (and gnus-newsgroup-name
6680 (string-match (car x) gnus-newsgroup-name))
6681 (nconc gnus-decode-header-methods-cache
6683 gnus-decode-header-methods))
6684 (let ((xlist gnus-decode-header-methods-cache))
6687 (narrow-to-region start end)
6689 (funcall (pop xlist) (point-min) (point-max))))))
6692 ;;; Treatment top-level handling.
6695 (defun gnus-treat-article (condition &optional part-number total-parts type)
6696 (let ((length (- (point-max) (point-min)))
6697 (alist gnus-treatment-function-alist)
6698 (article-goto-body-goes-to-point-min-p t)
6702 (let ((list gnus-article-treat-types))
6704 (when (string-match (pop list) type)
6705 (throw 'found t)))))))
6706 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6708 (gnus-run-hooks 'gnus-part-display-hook)
6709 (dolist (elem alist)
6712 (when (gnus-buffer-live-p gnus-summary-buffer)
6713 (set-buffer gnus-summary-buffer))
6714 (symbol-value (car elem))))
6715 (when (and (or (consp val)
6717 (gnus-treat-predicate val)
6718 (or (not (get (car elem) 'highlight))
6721 (funcall (cadr elem)))))))
6723 ;; Dynamic variables.
6725 (defvar part-number)
6726 (defvar total-parts)
6731 (defun gnus-treat-predicate (val)
6738 (stringp (car val)))
6739 (apply 'gnus-or (mapcar `(lambda (s)
6740 (string-match s ,(or gnus-newsgroup-name "")))
6743 (let ((pred (pop val)))
6746 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6748 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6750 (not (gnus-treat-predicate (car val))))
6752 (equal (car val) type))
6754 (error "%S is not a valid predicate" pred)))))
6760 (eq part-number total-parts))
6764 (error "%S is not a valid value" val))))
6766 (defun gnus-article-encrypt-body (protocol &optional n)
6767 "Encrypt the article body."
6770 (or gnus-article-encrypt-protocol
6771 (completing-read "Encrypt protocol: "
6772 gnus-article-encrypt-protocol-alist
6774 current-prefix-arg))
6775 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6777 (error (format "Can't find the encrypt protocol %s" protocol)))
6778 (if (member gnus-newsgroup-name '("nndraft:delayed"
6781 (error "Can't encrypt the article in group %s"
6782 gnus-newsgroup-name))
6783 (gnus-summary-iterate n
6785 (set-buffer gnus-summary-buffer)
6786 (let ((mail-parse-charset gnus-newsgroup-charset)
6787 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6788 (summary-buffer gnus-summary-buffer)
6790 (gnus-set-global-variables)
6791 (when (gnus-group-read-only-p)
6792 (error "The current newsgroup does not support article encrypt"))
6793 (gnus-summary-show-article t)
6795 (or (mail-header-references gnus-current-headers) ""))
6796 (set-buffer gnus-article-buffer)
6797 (let* ((buffer-read-only nil)
6799 (mapcar (lambda (field)
6800 (and (save-restriction
6801 (message-narrow-to-head)
6802 (goto-char (point-min))
6803 (search-forward field nil t))
6805 (message-narrow-to-field)
6807 (delete-region (point-min) (point-max))
6809 '("Content-Type:" "Content-Transfer-Encoding:"
6810 "Content-Disposition:"))))
6811 (message-narrow-to-head)
6812 (message-remove-header "MIME-Version")
6813 (goto-char (point-max))
6814 (setq point (point))
6815 (insert (apply 'concat headers))
6817 (narrow-to-region point (point-max))
6818 (let ((message-options message-options))
6819 (message-options-set 'message-sender user-mail-address)
6820 (message-options-set 'message-recipients user-mail-address)
6821 (message-options-set 'message-sign-encrypt 'not)
6823 (goto-char (point-min))
6824 (insert "MIME-Version: 1.0\n")
6826 (gnus-summary-edit-article-done
6827 references nil summary-buffer t))
6828 (when gnus-keep-backlog
6829 (gnus-backlog-remove-article
6830 (car gnus-article-current) (cdr gnus-article-current)))
6832 (when (get-buffer gnus-original-article-buffer)
6833 (set-buffer gnus-original-article-buffer)
6834 (setq gnus-original-article nil)))
6835 (when gnus-use-cache
6836 (gnus-cache-update-article
6837 (car gnus-article-current) (cdr gnus-article-current))))))))
6839 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6840 "The following specs can be used:
6841 %t The security MIME type
6844 %D Details if button is pressed")
6846 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6847 "The following specs can be used:
6848 %t The security MIME type
6851 %D Details if button is pressed")
6853 (defvar gnus-mime-security-button-line-format-alist
6854 '((?t gnus-tmp-type ?s)
6855 (?i gnus-tmp-info ?s)
6856 (?d gnus-tmp-details ?s)
6857 (?D gnus-tmp-pressed-details ?s)))
6859 (defvar gnus-mime-security-button-map
6860 (let ((map (make-sparse-keymap)))
6861 (unless (>= (string-to-number emacs-version) 21)
6862 (set-keymap-parent map gnus-article-mode-map))
6863 (define-key map gnus-mouse-2 'gnus-article-push-button)
6864 (define-key map "\r" 'gnus-article-press-button)
6867 (defvar gnus-mime-security-details-buffer nil)
6869 (defvar gnus-mime-security-button-pressed nil)
6871 (defvar gnus-mime-security-show-details-inline t
6872 "If non-nil, show details in the article buffer.")
6874 (defun gnus-mime-security-verify-or-decrypt (handle)
6875 (mm-remove-parts (cdr handle))
6876 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6877 point buffer-read-only)
6879 (goto-char (car region)))
6881 (narrow-to-region (point) (point))
6882 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6883 (let* ((mm-verify-option 'known)
6884 (mm-decrypt-option 'known)
6885 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6886 (unless (eq nparts (cdr handle))
6887 (mm-destroy-parts (cdr handle))
6888 (setcdr handle nparts))))
6889 (setq point (point))
6890 (gnus-mime-display-security handle)
6891 (goto-char (point-max)))
6893 (delete-region (point) (cdr region))
6894 (set-marker (car region) nil)
6895 (set-marker (cdr region) nil))
6898 (defun gnus-mime-security-show-details (handle)
6899 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6901 (gnus-message 5 "No details.")
6902 (if gnus-mime-security-show-details-inline
6903 (let ((gnus-mime-security-button-pressed
6904 (not (get-text-property (point) 'gnus-mime-details)))
6905 (gnus-mime-security-button-line-format
6906 (get-text-property (point) 'gnus-line-format))
6909 (while (eq (get-text-property (point) 'gnus-line-format)
6910 gnus-mime-security-button-line-format)
6914 (narrow-to-region (point) (point))
6915 (gnus-insert-mime-security-button handle))
6916 (delete-region (point)
6917 (or (text-property-not-all
6920 gnus-mime-security-button-line-format)
6923 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6924 (with-current-buffer gnus-mime-security-details-buffer
6927 (setq gnus-mime-security-details-buffer
6928 (gnus-get-buffer-create "*MIME Security Details*")))
6929 (with-current-buffer gnus-mime-security-details-buffer
6931 (goto-char (point-min)))
6932 (pop-to-buffer gnus-mime-security-details-buffer)))))
6934 (defun gnus-mime-security-press-button (handle)
6936 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6937 (gnus-mime-security-show-details handle)
6938 (gnus-mime-security-verify-or-decrypt handle))))
6940 (defun gnus-insert-mime-security-button (handle &optional displayed)
6941 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6944 (or (nth 2 (assoc protocol mm-verify-function-alist))
6945 (nth 2 (assoc protocol mm-decrypt-function-alist))
6947 (if (equal (car handle) "multipart/signed")
6948 " Signed" " Encrypted")
6951 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6954 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6955 gnus-tmp-pressed-details
6957 (setq gnus-tmp-details
6958 (if gnus-tmp-details
6959 (concat "\n" gnus-tmp-details)
6961 (setq gnus-tmp-pressed-details
6962 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6967 gnus-mime-security-button-line-format
6968 gnus-mime-security-button-line-format-alist
6969 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6970 gnus-callback gnus-mime-security-press-button
6971 gnus-line-format ,gnus-mime-security-button-line-format
6972 gnus-mime-details ,gnus-mime-security-button-pressed
6973 article-type annotation
6976 ;; Exclude a newline.
6979 (widget-convert-button
6982 :action 'gnus-widget-press-button
6983 :button-keymap gnus-mime-security-button-map
6985 (lambda (widget/window &optional overlay pos)
6986 ;; Needed to properly clear the message due to a bug in
6987 ;; wid-edit (XEmacs only).
6988 (when (boundp 'help-echo-owns-message)
6989 (setq help-echo-owns-message t))
6992 (aref gnus-mouse-2 0))))))
6994 (defun gnus-mime-display-security (handle)
6996 (narrow-to-region (point) (point))
6997 (unless (gnus-unbuttonized-mime-type-p (car handle))
6998 (gnus-insert-mime-security-button handle))
6999 (gnus-mime-display-mixed (cdr handle))
7002 (unless (gnus-unbuttonized-mime-type-p (car handle))
7003 (let ((gnus-mime-security-button-line-format
7004 gnus-mime-security-button-end-line-format))
7005 (gnus-insert-mime-security-button handle)))
7006 (mm-set-handle-multipart-parameter
7008 (cons (set-marker (make-marker) (point-min))
7009 (set-marker (make-marker) (point-max))))))
7015 (run-hooks 'gnus-art-load-hook)
7017 ;;; gnus-art.el ends here