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
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 (if (memq 'face gnus-article-wash-types)
1981 (gnus-delete-images 'face)
1984 (set-buffer gnus-original-article-buffer)
1986 (mail-narrow-to-head)
1987 (while (gnus-article-goto-header "Face")
1988 (push (mail-header-field-value) faces))))
1989 (while (setq face (pop faces))
1990 (let ((png (gnus-convert-face-to-png face))
1993 (setq image (gnus-create-image png 'png t))
1994 (gnus-article-goto-header "from")
1996 (insert "From: [no `from' set]\n")
1998 (gnus-add-wash-type 'face)
1999 (gnus-add-image 'face image)
2000 (gnus-put-image image))))))
2003 (defun article-display-x-face (&optional force)
2004 "Look for an X-Face header and display it if present."
2005 (interactive (list 'force))
2006 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2007 (gnus-with-article-headers
2008 ;; Delete the old process, if any.
2009 (when (process-status "article-x-face")
2010 (delete-process "article-x-face"))
2011 (if (memq 'xface gnus-article-wash-types)
2012 ;; We have already displayed X-Faces, so we remove them
2014 (gnus-delete-images 'xface)
2016 (let (x-faces from face)
2018 (when (and wash-face-p
2020 (goto-char (point-min))
2021 (not (re-search-forward
2022 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2023 (gnus-buffer-live-p gnus-original-article-buffer))
2024 ;; If type `W f', use gnus-original-article-buffer,
2025 ;; otherwise use the current buffer because displaying
2026 ;; RFC822 parts calls this function too.
2027 (set-buffer gnus-original-article-buffer))
2029 (mail-narrow-to-head)
2030 (while (gnus-article-goto-header "X-Face")
2031 (push (mail-header-field-value) x-faces))
2032 (setq from (message-fetch-field "from"))))
2033 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2034 ;; single external face.
2035 (when (stringp gnus-article-x-face-command)
2036 (setq x-faces (list (car x-faces))))
2037 (while (and (setq face (pop x-faces))
2038 gnus-article-x-face-command
2040 ;; Check whether this face is censored.
2041 (not gnus-article-x-face-too-ugly)
2042 (and gnus-article-x-face-too-ugly from
2043 (not (string-match gnus-article-x-face-too-ugly
2045 ;; We display the face.
2046 (if (symbolp gnus-article-x-face-command)
2047 ;; The command is a lisp function, so we call it.
2048 (if (functionp gnus-article-x-face-command)
2049 (funcall gnus-article-x-face-command face)
2050 (error "%s is not a function" gnus-article-x-face-command))
2051 ;; The command is a string, so we interpret the command
2052 ;; as a, well, command, and fork it off.
2053 (let ((process-connection-type nil))
2054 (process-kill-without-query
2056 "article-x-face" nil shell-file-name shell-command-switch
2057 gnus-article-x-face-command))
2060 (process-send-region "article-x-face"
2061 (point-min) (point-max)))
2062 (process-send-eof "article-x-face")))))))))
2064 (defun article-decode-mime-words ()
2065 "Decode all MIME-encoded words in the article."
2068 (set-buffer gnus-article-buffer)
2069 (let ((inhibit-point-motion-hooks t)
2071 (mail-parse-charset gnus-newsgroup-charset)
2072 (mail-parse-ignored-charsets
2073 (save-excursion (set-buffer gnus-summary-buffer)
2074 gnus-newsgroup-ignored-charsets)))
2075 (mail-decode-encoded-word-region (point-min) (point-max)))))
2077 (defun article-decode-charset (&optional prompt)
2078 "Decode charset-encoded text in the article.
2079 If PROMPT (the prefix), prompt for a coding system to use."
2081 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2083 (mail-parse-charset gnus-newsgroup-charset)
2084 (mail-parse-ignored-charsets
2085 (save-excursion (condition-case nil
2086 (set-buffer gnus-summary-buffer)
2088 gnus-newsgroup-ignored-charsets))
2089 ct cte ctl charset format)
2092 (article-narrow-to-head)
2093 (setq ct (message-fetch-field "Content-Type" t)
2094 cte (message-fetch-field "Content-Transfer-Encoding" t)
2095 ctl (and ct (ignore-errors
2096 (mail-header-parse-content-type ct)))
2099 (mm-read-coding-system "Charset to decode: "))
2101 (mail-content-type-get ctl 'charset)))
2102 format (and ctl (mail-content-type-get ctl 'format)))
2104 (setq cte (mail-header-strip cte)))
2105 (if (and ctl (not (string-match "/" (car ctl))))
2107 (goto-char (point-max)))
2110 (narrow-to-region (point) (point-max))
2111 (when (and (eq mail-parse-charset 'gnus-decoded)
2112 (eq (mm-body-7-or-8) '8bit))
2113 ;; The text code could have been decoded.
2114 (setq charset mail-parse-charset))
2115 (when (and (or (not ctl)
2116 (equal (car ctl) "text/plain"))
2117 (not format)) ;; article with format will decode later.
2119 charset (and cte (intern (downcase
2120 (gnus-strip-whitespace cte))))
2123 (defun article-decode-encoded-words ()
2124 "Remove encoded-word encoding from headers."
2125 (let ((inhibit-point-motion-hooks t)
2126 (mail-parse-charset gnus-newsgroup-charset)
2127 (mail-parse-ignored-charsets
2128 (save-excursion (condition-case nil
2129 (set-buffer gnus-summary-buffer)
2131 gnus-newsgroup-ignored-charsets))
2134 (article-narrow-to-head)
2135 (funcall gnus-decode-header-function (point-min) (point-max)))))
2137 (defun article-decode-group-name ()
2138 "Decode group names in `Newsgroups:'."
2139 (let ((inhibit-point-motion-hooks t)
2141 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2142 (when (and (or gnus-group-name-charset-method-alist
2143 gnus-group-name-charset-group-alist)
2144 (gnus-buffer-live-p gnus-original-article-buffer))
2146 (article-narrow-to-head)
2147 (with-current-buffer gnus-original-article-buffer
2148 (goto-char (point-min)))
2149 (while (re-search-forward
2150 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2151 (replace-match (save-match-data
2152 (gnus-decode-newsgroups
2153 ;; XXX how to use data in article buffer?
2154 (with-current-buffer gnus-original-article-buffer
2156 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2159 gnus-newsgroup-name method))
2161 (goto-char (point-min))
2162 (with-current-buffer gnus-original-article-buffer
2163 (goto-char (point-min)))
2164 (while (re-search-forward
2165 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2166 (replace-match (save-match-data
2167 (gnus-decode-newsgroups
2168 ;; XXX how to use data in article buffer?
2169 (with-current-buffer gnus-original-article-buffer
2171 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2174 gnus-newsgroup-name method))
2177 (autoload 'idna-to-unicode "idna")
2179 (defun article-decode-idna-rhs ()
2180 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2183 (let ((inhibit-point-motion-hooks t)
2185 (article-narrow-to-head)
2186 (goto-char (point-min))
2187 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2189 (when (save-match-data
2190 (and (setq ace (match-string 1))
2192 (and (re-search-backward "^[^ \t]" nil t)
2193 (looking-at "From\\|To\\|Cc")))
2194 (save-excursion (backward-char)
2195 (message-idna-inside-rhs-p))
2196 (setq unicode (idna-to-unicode ace))))
2197 (unless (string= ace unicode)
2198 (replace-match unicode nil nil nil 1)))))))))
2200 (defun article-de-quoted-unreadable (&optional force read-charset)
2201 "Translate a quoted-printable-encoded article.
2202 If FORCE, decode the article whether it is marked as quoted-printable
2204 If READ-CHARSET, ask for a coding system."
2205 (interactive (list 'force current-prefix-arg))
2207 (let ((buffer-read-only nil) type charset)
2208 (if (gnus-buffer-live-p gnus-original-article-buffer)
2209 (with-current-buffer gnus-original-article-buffer
2211 (gnus-fetch-field "content-transfer-encoding"))
2212 (let* ((ct (gnus-fetch-field "content-type"))
2215 (mail-header-parse-content-type ct)))))
2216 (setq charset (and ctl
2217 (mail-content-type-get ctl 'charset)))
2218 (if (stringp charset)
2219 (setq charset (intern (downcase charset)))))))
2221 (setq charset (mm-read-coding-system "Charset: " charset)))
2223 (setq charset gnus-newsgroup-charset))
2225 (and type (let ((case-fold-search t))
2226 (string-match "quoted-printable" type))))
2228 (quoted-printable-decode-region
2229 (point) (point-max) (mm-charset-to-coding-system charset))))))
2231 (defun article-de-base64-unreadable (&optional force read-charset)
2232 "Translate a base64 article.
2233 If FORCE, decode the article whether it is marked as base64 not.
2234 If READ-CHARSET, ask for a coding system."
2235 (interactive (list 'force current-prefix-arg))
2237 (let ((buffer-read-only nil) type charset)
2238 (if (gnus-buffer-live-p gnus-original-article-buffer)
2239 (with-current-buffer gnus-original-article-buffer
2241 (gnus-fetch-field "content-transfer-encoding"))
2242 (let* ((ct (gnus-fetch-field "content-type"))
2245 (mail-header-parse-content-type ct)))))
2246 (setq charset (and ctl
2247 (mail-content-type-get ctl 'charset)))
2248 (if (stringp charset)
2249 (setq charset (intern (downcase charset)))))))
2251 (setq charset (mm-read-coding-system "Charset: " charset)))
2253 (setq charset gnus-newsgroup-charset))
2255 (and type (let ((case-fold-search t))
2256 (string-match "base64" type))))
2259 (narrow-to-region (point) (point-max))
2260 (base64-decode-region (point-min) (point-max))
2261 (mm-decode-coding-region
2262 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2267 (defun article-decode-HZ ()
2268 "Translate a HZ-encoded article."
2272 (let ((buffer-read-only nil))
2273 (rfc1843-decode-region (point-min) (point-max)))))
2275 (defun article-unsplit-urls ()
2276 "Remove the newlines that some other mailers insert into URLs."
2279 (let ((buffer-read-only nil))
2280 (goto-char (point-min))
2281 (while (re-search-forward
2282 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2283 (replace-match "\\1\\3" t)))
2284 (when (interactive-p)
2285 (gnus-treat-article nil))))
2288 (defun article-wash-html (&optional read-charset)
2289 "Format an HTML article.
2290 If READ-CHARSET, ask for a coding system."
2293 (let ((buffer-read-only nil)
2295 (when (gnus-buffer-live-p gnus-original-article-buffer)
2296 (with-current-buffer gnus-original-article-buffer
2297 (let* ((ct (gnus-fetch-field "content-type"))
2300 (mail-header-parse-content-type ct)))))
2301 (setq charset (and ctl
2302 (mail-content-type-get ctl 'charset)))
2303 (when (stringp charset)
2304 (setq charset (intern (downcase charset)))))))
2306 (setq charset (mm-read-coding-system "Charset: " charset)))
2308 (setq charset gnus-newsgroup-charset))
2310 (save-window-excursion
2312 (narrow-to-region (point) (point-max))
2313 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2314 (entry (assq func mm-text-html-washer-alist)))
2316 (setq func (cdr entry)))
2321 (apply (car func) (cdr func))))))))))
2323 (defun gnus-article-wash-html-with-w3 ()
2324 "Wash the current buffer with w3."
2326 (let ((w3-strict-width (window-width))
2327 (url-standalone-mode t)
2328 (url-gateway-unplugged t)
2329 (w3-honor-stylesheets nil))
2331 (w3-region (point-min) (point-max))
2334 (defun gnus-article-wash-html-with-w3m ()
2335 "Wash the current buffer with emacs-w3m."
2338 (narrow-to-region (point) (point-max))
2339 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2342 w3m-force-redisplay)
2343 (w3m-region (point-min) (point-max)))
2344 (when mm-inline-text-html-with-w3m-keymap
2345 (add-text-properties
2346 (point-min) (point-max)
2347 (nconc (mm-w3m-local-map-property)
2348 '(mm-inline-text-html-with-w3m t))))))
2350 (defun article-hide-list-identifiers ()
2351 "Remove list identifies from the Subject header.
2352 The `gnus-list-identifiers' variable specifies what to do."
2354 (let ((inhibit-point-motion-hooks t)
2355 (regexp (if (consp gnus-list-identifiers)
2356 (mapconcat 'identity gnus-list-identifiers " *\\|")
2357 gnus-list-identifiers))
2362 (article-narrow-to-head)
2363 (goto-char (point-min))
2364 (while (re-search-forward
2365 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2367 (delete-region (match-beginning 2) (match-end 0))
2368 (beginning-of-line))
2369 (when (re-search-forward
2370 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2371 (delete-region (match-beginning 1) (match-end 1))))))))
2373 (defun article-hide-pem (&optional arg)
2374 "Toggle hiding of any PEM headers and signatures in the current article.
2375 If given a negative prefix, always show; if given a positive prefix,
2377 (interactive (gnus-article-hidden-arg))
2378 (unless (gnus-article-check-hidden-text 'pem arg)
2380 (let (buffer-read-only end)
2381 (goto-char (point-min))
2382 ;; Hide the horrendously ugly "header".
2383 (when (and (search-forward
2384 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2386 (setq end (1+ (match-beginning 0))))
2387 (gnus-add-wash-type 'pem)
2388 (gnus-article-hide-text-type
2390 (if (search-forward "\n\n" nil t)
2394 ;; Hide the trailer as well
2395 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2397 (gnus-article-hide-text-type
2398 (match-beginning 0) (match-end 0) 'pem)))))))
2400 (defun article-strip-banner ()
2401 "Strip the banners specified by the `banner' group parameter and by
2402 `gnus-article-address-banner-alist'."
2406 (let ((inhibit-point-motion-hooks t))
2407 (when (gnus-parameter-banner gnus-newsgroup-name)
2408 (article-really-strip-banner
2409 (gnus-parameter-banner gnus-newsgroup-name)))
2410 (when gnus-article-address-banner-alist
2411 (article-really-strip-banner
2412 (let ((from (save-restriction
2414 (article-narrow-to-head)
2415 (mail-fetch-field "from"))))
2418 (caar (mail-header-parse-addresses from))))
2420 (dolist (pair gnus-article-address-banner-alist)
2421 (when (string-match (car pair) from)
2422 (throw 'found (cdr pair)))))))))))))
2424 (defun article-really-strip-banner (banner)
2425 "Strip the banner specified by the argument."
2428 (let ((inhibit-point-motion-hooks t)
2429 (gnus-signature-limit nil)
2433 ((eq banner 'signature)
2434 (when (gnus-article-narrow-to-signature)
2437 (delete-region (point) (point-max))))
2439 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2440 (while (re-search-forward banner nil t)
2441 (delete-region (match-beginning 0) (match-end 0)))))
2443 (while (re-search-forward banner nil t)
2444 (delete-region (match-beginning 0) (match-end 0)))))))))
2446 (defun article-babel ()
2447 "Translate article using an online translation service."
2451 (set-buffer gnus-article-buffer)
2452 (when (article-goto-body)
2453 (let* ((buffer-read-only nil)
2456 (orig (buffer-substring start end))
2457 (trans (babel-as-string orig)))
2459 (narrow-to-region start end)
2460 (delete-region start end)
2463 (defun article-hide-signature (&optional arg)
2464 "Hide the signature in the current article.
2465 If given a negative prefix, always show; if given a positive prefix,
2467 (interactive (gnus-article-hidden-arg))
2468 (unless (gnus-article-check-hidden-text 'signature arg)
2471 (let ((buffer-read-only nil))
2472 (when (gnus-article-narrow-to-signature)
2473 (gnus-article-hide-text-type
2474 (point-min) (point-max) 'signature))))))
2475 (gnus-set-mode-line 'article))
2477 (defun article-strip-headers-in-body ()
2478 "Strip offensive headers from bodies."
2482 (let ((case-fold-search t))
2483 (when (looking-at "x-no-archive:")
2484 (gnus-delete-line)))))
2486 (defun article-strip-leading-blank-lines ()
2487 "Remove all blank lines from the beginning of the article."
2490 (let ((inhibit-point-motion-hooks t)
2492 (when (article-goto-body)
2493 (while (and (not (eobp))
2494 (looking-at "[ \t]*$"))
2495 (gnus-delete-line))))))
2497 (defun article-narrow-to-head ()
2498 "Narrow the buffer to the head of the message.
2499 Point is left at the beginning of the narrowed-to region."
2501 (goto-char (point-min))
2502 (if (search-forward "\n\n" nil 1)
2505 (goto-char (point-min)))
2507 (defun article-goto-body ()
2508 "Place point at the start of the body."
2509 (goto-char (point-min))
2511 ;; This variable is only bound when dealing with separate
2513 (article-goto-body-goes-to-point-min-p
2515 ((search-forward "\n\n" nil t)
2518 (goto-char (point-max))
2521 (defun article-strip-multiple-blank-lines ()
2522 "Replace consecutive blank lines with one empty line."
2525 (let ((inhibit-point-motion-hooks t)
2527 ;; First make all blank lines empty.
2529 (while (re-search-forward "^[ \t]+$" nil t)
2530 (unless (gnus-annotation-in-region-p
2531 (match-beginning 0) (match-end 0))
2532 (replace-match "" nil t)))
2533 ;; Then replace multiple empty lines with a single empty line.
2535 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2536 (unless (gnus-annotation-in-region-p
2537 (match-beginning 0) (match-end 0))
2538 (delete-region (match-beginning 1) (match-end 1)))))))
2540 (defun article-strip-leading-space ()
2541 "Remove all white space from the beginning of the lines in the article."
2544 (let ((inhibit-point-motion-hooks t)
2547 (while (re-search-forward "^[ \t]+" nil t)
2548 (replace-match "" t t)))))
2550 (defun article-strip-trailing-space ()
2551 "Remove all white space from the end of the lines in the article."
2554 (let ((inhibit-point-motion-hooks t)
2557 (while (re-search-forward "[ \t]+$" nil t)
2558 (replace-match "" t t)))))
2560 (defun article-strip-blank-lines ()
2561 "Strip leading, trailing and multiple blank lines."
2563 (article-strip-leading-blank-lines)
2564 (article-remove-trailing-blank-lines)
2565 (article-strip-multiple-blank-lines))
2567 (defun article-strip-all-blank-lines ()
2568 "Strip all blank lines."
2571 (let ((inhibit-point-motion-hooks t)
2574 (while (re-search-forward "^[ \t]*\n" nil t)
2575 (replace-match "" t t)))))
2577 (defun gnus-article-narrow-to-signature ()
2578 "Narrow to the signature; return t if a signature is found, else nil."
2579 (let ((inhibit-point-motion-hooks t))
2580 (when (gnus-article-search-signature)
2582 ;; Check whether we have some limits to what we consider
2583 ;; to be a signature.
2584 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2585 (list gnus-signature-limit)))
2587 (while (setq limit (pop limits))
2588 (if (or (and (integerp limit)
2589 (< (- (point-max) (point)) limit))
2591 (< (count-lines (point) (point-max)) limit))
2592 (and (functionp limit)
2594 (and (stringp limit)
2595 (not (re-search-forward limit nil t))))
2596 () ; This limit did not succeed.
2600 (narrow-to-region (point) (point-max))
2603 (defun gnus-article-search-signature ()
2604 "Search the current buffer for the signature separator.
2605 Put point at the beginning of the signature separator."
2606 (let ((cur (point)))
2607 (goto-char (point-max))
2608 (if (if (stringp gnus-signature-separator)
2609 (re-search-backward gnus-signature-separator nil t)
2610 (let ((seps gnus-signature-separator))
2612 (not (re-search-backward (car seps) nil t)))
2619 (defun gnus-article-hidden-arg ()
2620 "Return the current prefix arg as a number, or 0 if no prefix."
2621 (list (if current-prefix-arg
2622 (prefix-numeric-value current-prefix-arg)
2625 (defun gnus-article-check-hidden-text (type arg)
2626 "Return nil if hiding is necessary.
2627 Arg can be nil or a number. nil and positive means hide, negative
2628 means show, 0 means toggle."
2631 (let ((hide (gnus-article-hidden-text-p type)))
2637 (gnus-article-show-hidden-text type)
2640 (if (eq hide 'hidden)
2642 (gnus-article-show-hidden-text type)
2646 (defun gnus-article-hidden-text-p (type)
2647 "Say whether the current buffer contains hidden text of type TYPE."
2648 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2650 (not (get-text-property pos 'invisible))
2651 (not (get-text-property pos 'dummy-invisible)))
2653 (text-property-any (1+ pos) (point-max) 'article-type type)))
2658 (defun gnus-article-show-hidden-text (type &optional dummy)
2659 "Show all hidden text of type TYPE.
2660 Originally it is hide instead of DUMMY."
2661 (let ((buffer-read-only nil)
2662 (inhibit-point-motion-hooks t))
2663 (gnus-remove-text-properties-when
2665 (point-min) (point-max)
2666 (cons 'article-type (cons type
2667 gnus-hidden-properties)))
2668 (gnus-delete-wash-type type)))
2670 (defconst article-time-units
2671 `((year . ,(* 365.25 24 60 60))
2672 (week . ,(* 7 24 60 60))
2673 (day . ,(* 24 60 60))
2677 "Mapping from time units to seconds.")
2679 (defun gnus-article-forward-header ()
2680 "Move point to the start of the next header.
2681 If the current header is a continuation header, this can be several
2686 (if (looking-at "[ \t]+[^ \t]")
2690 (defun article-date-ut (&optional type highlight header)
2691 "Convert DATE date to universal time in the current article.
2692 If TYPE is `local', convert to local time; if it is `lapsed', output
2693 how much time has lapsed since DATE. For `lapsed', the value of
2694 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2695 should replace the \"Date:\" one, or should be added below it."
2696 (interactive (list 'ut t))
2697 (let* ((header (or header
2698 (message-fetch-field "date")
2700 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2703 ((not gnus-article-date-lapsed-new-header)
2709 (date (if (vectorp header) (mail-header-date header)
2711 (inhibit-point-motion-hooks t)
2716 (article-narrow-to-head)
2717 (when (re-search-forward tdate-regexp nil t)
2718 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2719 date (or (get-text-property (gnus-point-at-bol)
2722 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2724 (when (and date (not (string= date "")))
2725 (goto-char (point-min))
2726 (let ((buffer-read-only nil))
2727 ;; Delete any old Date headers.
2728 (while (re-search-forward date-regexp nil t)
2730 (delete-region (progn (beginning-of-line) (point))
2731 (progn (gnus-article-forward-header)
2733 (delete-region (progn (beginning-of-line) (point))
2734 (progn (gnus-article-forward-header)
2737 (setq pos (point))))
2738 (when (and (not pos)
2739 (re-search-forward tdate-regexp nil t))
2743 (insert (article-make-date-line date (or type 'ut)))
2749 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2750 (put-text-property (match-beginning 1) (1+ (match-end 1))
2751 'original-date date)
2752 (put-text-property (match-beginning 1) (1+ (match-end 1))
2754 (put-text-property (match-beginning 2) (match-end 2)
2757 (defun article-make-date-line (date type)
2758 "Return a DATE line of TYPE."
2759 (unless (memq type '(local ut original user iso8601 lapsed english))
2760 (error "Unknown conversion type: %s" type))
2762 (let ((time (date-to-time date)))
2764 ;; Convert to the local timezone.
2766 (let ((tz (car (current-time-zone time))))
2767 (format "Date: %s %s%02d%02d" (current-time-string time)
2768 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2769 (/ (% (abs tz) 3600) 60))))
2770 ;; Convert to Universal Time.
2773 (current-time-string
2774 (let* ((e (parse-time-string date))
2775 (tm (apply 'encode-time e))
2777 (ls (- (cadr tm) (car (current-time-zone time)))))
2778 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2779 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2782 ;; Get the original date from the article.
2783 ((eq type 'original)
2784 (concat "Date: " (if (string-match "\n+$" date)
2785 (substring date 0 (match-beginning 0))
2787 ;; Let the user define the format.
2789 (let ((format (or (condition-case nil
2790 (with-current-buffer gnus-summary-buffer
2791 gnus-article-time-format)
2793 gnus-article-time-format)))
2794 (if (functionp format)
2795 (funcall format time)
2796 (concat "Date: " (format-time-string format time)))))
2799 (let ((tz (car (current-time-zone time))))
2802 (format-time-string "%Y%m%dT%H%M%S" time)
2803 (format "%s%02d%02d"
2804 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2805 (/ (% (abs tz) 3600) 60)))))
2806 ;; Do an X-Sent lapsed format.
2808 ;; If the date is seriously mangled, the timezone functions are
2809 ;; liable to bug out, so we ignore all errors.
2810 (let* ((now (current-time))
2811 (real-time (subtract-time now time))
2812 (real-sec (and real-time
2813 (+ (* (float (car real-time)) 65536)
2815 (sec (and real-time (abs real-sec)))
2825 ;; This is a bit convoluted, but basically we go
2826 ;; through the time units for years, weeks, etc,
2827 ;; and divide things to see whether that results
2828 ;; in positive answers.
2831 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2832 ;; The (remaining) seconds are too few to
2833 ;; be divided into this time unit.
2835 ;; It's big enough, so we output it.
2836 (setq sec (- sec (* num (cdr unit))))
2838 (concat (if prev ", " "") (int-to-string
2840 " " (symbol-name (car unit))
2841 (if (> num 1) "s" ""))
2843 article-time-units "")
2844 ;; If dates are odd, then it might appear like the
2845 ;; article was sent in the future.
2848 " in the future"))))))
2849 ;; Display the date in proper English
2851 (let ((dtime (decode-time time)))
2854 (number-to-string (nth 3 dtime))
2855 (let ((digit (% (nth 3 dtime) 10)))
2857 ((memq (nth 3 dtime) '(11 12 13)) "th")
2863 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2865 (number-to-string (nth 5 dtime))
2867 (format "%02d" (nth 2 dtime))
2869 (format "%02d" (nth 1 dtime)))))))
2871 (format "Date: %s (from Gnus)" date))))
2873 (defun article-date-local (&optional highlight)
2874 "Convert the current article date to the local timezone."
2875 (interactive (list t))
2876 (article-date-ut 'local highlight))
2878 (defun article-date-english (&optional highlight)
2879 "Convert the current article date to something that is proper English."
2880 (interactive (list t))
2881 (article-date-ut 'english highlight))
2883 (defun article-date-original (&optional highlight)
2884 "Convert the current article date to what it was originally.
2885 This is only useful if you have used some other date conversion
2886 function and want to see what the date was before converting."
2887 (interactive (list t))
2888 (article-date-ut 'original highlight))
2890 (defun article-date-lapsed (&optional highlight)
2891 "Convert the current article date to time lapsed since it was sent."
2892 (interactive (list t))
2893 (article-date-ut 'lapsed highlight))
2895 (defun article-update-date-lapsed ()
2896 "Function to be run from a timer to update the lapsed time line."
2897 (let (deactivate-mark)
2902 (set-buffer (window-buffer w))
2903 (when (eq major-mode 'gnus-article-mode)
2904 (goto-char (point-min))
2905 (when (re-search-forward "^X-Sent:" nil t)
2906 (article-date-lapsed t))))
2909 (defun gnus-start-date-timer (&optional n)
2910 "Start a timer to update the X-Sent header in the article buffers.
2911 The numerical prefix says how frequently (in seconds) the function
2916 (gnus-stop-date-timer)
2917 (setq article-lapsed-timer
2918 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2920 (defun gnus-stop-date-timer ()
2921 "Stop the X-Sent timer."
2923 (when article-lapsed-timer
2924 (nnheader-cancel-timer article-lapsed-timer)
2925 (setq article-lapsed-timer nil)))
2927 (defun article-date-user (&optional highlight)
2928 "Convert the current article date to the user-defined format.
2929 This format is defined by the `gnus-article-time-format' variable."
2930 (interactive (list t))
2931 (article-date-ut 'user highlight))
2933 (defun article-date-iso8601 (&optional highlight)
2934 "Convert the current article date to ISO8601."
2935 (interactive (list t))
2936 (article-date-ut 'iso8601 highlight))
2938 ;; (defun article-show-all ()
2939 ;; "Show all hidden text in the article buffer."
2942 ;; (let ((buffer-read-only nil))
2943 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2945 (defun article-remove-leading-whitespace ()
2946 "Remove excessive whitespace from all headers."
2950 (let ((buffer-read-only nil))
2951 (article-narrow-to-head)
2952 (goto-char (point-min))
2953 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2954 (delete-region (match-beginning 1) (match-end 1)))))))
2956 (defun article-emphasize (&optional arg)
2957 "Emphasize text according to `gnus-emphasis-alist'."
2958 (interactive (gnus-article-hidden-arg))
2959 (unless (gnus-article-check-hidden-text 'emphasis arg)
2963 (with-current-buffer gnus-summary-buffer
2964 gnus-article-emphasis-alist)
2966 gnus-emphasis-alist))
2967 (buffer-read-only nil)
2968 (props (append '(article-type emphasis)
2969 gnus-hidden-properties))
2970 regexp elem beg invisible visible face)
2973 (while (setq elem (pop alist))
2975 (setq regexp (car elem)
2976 invisible (nth 1 elem)
2977 visible (nth 2 elem)
2979 (while (re-search-forward regexp nil t)
2980 (when (and (match-beginning visible) (match-beginning invisible))
2981 (gnus-article-hide-text
2982 (match-beginning invisible) (match-end invisible) props)
2983 (gnus-article-unhide-text-type
2984 (match-beginning visible) (match-end visible) 'emphasis)
2985 (gnus-put-overlay-excluding-newlines
2986 (match-beginning visible) (match-end visible) 'face face)
2987 (gnus-add-wash-type 'emphasis)
2988 (goto-char (match-end invisible)))))))))
2990 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2991 "Setup newsgroup emphasis alist."
2992 (unless gnus-article-emphasis-alist
2993 (let ((name (and gnus-newsgroup-name
2994 (gnus-group-real-name gnus-newsgroup-name))))
2995 (make-local-variable 'gnus-article-emphasis-alist)
2996 (setq gnus-article-emphasis-alist
2998 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2999 (while (setq elem (pop alist))
3000 (when (and name (string-match (car elem) name))
3002 highlight (copy-sequence (cdr elem)))))
3004 (copy-sequence highlight-words)
3005 (if gnus-newsgroup-name
3006 (copy-sequence (gnus-group-find-parameter
3007 gnus-newsgroup-name 'highlight-words t)))
3008 gnus-emphasis-alist)))))
3011 (defvar gnus-summary-article-menu)
3012 (defvar gnus-summary-post-menu))
3014 ;;; Saving functions.
3016 (defun gnus-article-save (save-buffer file &optional num)
3017 "Save the currently selected article."
3018 (unless gnus-save-all-headers
3019 ;; Remove headers according to `gnus-saved-headers'.
3020 (let ((gnus-visible-headers
3021 (or gnus-saved-headers gnus-visible-headers))
3022 (gnus-article-buffer save-buffer))
3024 (set-buffer save-buffer)
3025 (article-hide-headers 1 t))))
3026 (save-window-excursion
3027 (if (not gnus-default-article-saver)
3028 (error "No default saver is defined")
3029 ;; !!! Magic! The saving functions all save
3030 ;; `gnus-save-article-buffer' (or so they think), but we
3031 ;; bind that variable to our save-buffer.
3032 (set-buffer gnus-article-buffer)
3033 (let* ((gnus-save-article-buffer save-buffer)
3036 ((not gnus-prompt-before-saving) 'default)
3037 ((eq gnus-prompt-before-saving 'always) nil)
3039 (gnus-number-of-articles-to-be-saved
3040 (when (eq gnus-prompt-before-saving t)
3042 (set-buffer gnus-article-current-summary)
3043 (funcall gnus-default-article-saver filename)))))
3045 (defun gnus-read-save-file-name (prompt &optional filename
3046 function group headers variable)
3048 (funcall function group headers (symbol-value variable)))
3053 ((eq filename 'default)
3059 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3062 (if (and gnus-number-of-articles-to-be-saved
3063 (> gnus-number-of-articles-to-be-saved 1))
3064 (format "these %d articles"
3065 gnus-number-of-articles-to-be-saved)
3068 ;; Let the split methods have their say.
3070 ;; No split name was found.
3073 (concat prompt " (default "
3074 (file-name-nondirectory default-name) ") ")
3075 (file-name-directory default-name)
3077 ;; A single group name is returned.
3078 ((stringp split-name)
3080 (funcall function split-name headers
3081 (symbol-value variable)))
3083 (concat prompt " (default "
3084 (file-name-nondirectory default-name) ") ")
3085 (file-name-directory default-name)
3087 ;; A single split name was found
3088 ((= 1 (length split-name))
3089 (let* ((name (expand-file-name
3091 gnus-article-save-directory))
3092 (dir (cond ((file-directory-p name)
3093 (file-name-as-directory name))
3094 ((file-exists-p name) name)
3095 (t gnus-article-save-directory))))
3097 (concat prompt " (default " name ") ")
3099 ;; A list of splits was found.
3101 (setq split-name (nreverse split-name))
3103 (let ((file-name-history
3104 (nconc split-name file-name-history)))
3108 (concat prompt " (`M-p' for defaults) ")
3109 gnus-article-save-directory
3111 gnus-article-save-directory)))
3112 (car (push result file-name-history)))))))
3113 ;; Create the directory.
3114 (gnus-make-directory (file-name-directory file))
3115 ;; If we have read a directory, we append the default file name.
3116 (when (file-directory-p file)
3117 (setq file (expand-file-name (file-name-nondirectory
3119 (file-name-as-directory file))))
3120 ;; Possibly translate some characters.
3121 (nnheader-translate-file-chars file))))))
3122 (gnus-make-directory (file-name-directory result))
3123 (set variable result)))
3125 (defun gnus-article-archive-name (group)
3126 "Return the first instance of an \"Archive-name\" in the current buffer."
3127 (let ((case-fold-search t))
3128 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3129 (nnheader-concat gnus-article-save-directory
3130 (match-string 1)))))
3132 (defun gnus-article-nndoc-name (group)
3133 "If GROUP is an nndoc group, return the name of the parent group."
3134 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3135 (gnus-group-get-parameter group 'save-article-group)))
3137 (defun gnus-summary-save-in-rmail (&optional filename)
3138 "Append this article to Rmail file.
3139 Optional argument FILENAME specifies file name.
3140 Directory to save to is default to `gnus-article-save-directory'."
3141 (setq filename (gnus-read-save-file-name
3142 "Save %s in rmail file:" filename
3143 gnus-rmail-save-name gnus-newsgroup-name
3144 gnus-current-headers 'gnus-newsgroup-last-rmail))
3145 (gnus-eval-in-buffer-window gnus-save-article-buffer
3149 (gnus-output-to-rmail filename))))
3152 (defun gnus-summary-save-in-mail (&optional filename)
3153 "Append this article to Unix mail file.
3154 Optional argument FILENAME specifies file name.
3155 Directory to save to is default to `gnus-article-save-directory'."
3156 (setq filename (gnus-read-save-file-name
3157 "Save %s in Unix mail file:" filename
3158 gnus-mail-save-name gnus-newsgroup-name
3159 gnus-current-headers 'gnus-newsgroup-last-mail))
3160 (gnus-eval-in-buffer-window gnus-save-article-buffer
3164 (if (and (file-readable-p filename)
3165 (file-regular-p filename)
3166 (mail-file-babyl-p filename))
3167 (rmail-output-to-rmail-file filename t)
3168 (gnus-output-to-mail filename)))))
3171 (defun gnus-summary-save-in-file (&optional filename overwrite)
3172 "Append this article to file.
3173 Optional argument FILENAME specifies file name.
3174 Directory to save to is default to `gnus-article-save-directory'."
3175 (setq filename (gnus-read-save-file-name
3176 "Save %s in file:" filename
3177 gnus-file-save-name gnus-newsgroup-name
3178 gnus-current-headers 'gnus-newsgroup-last-file))
3179 (gnus-eval-in-buffer-window gnus-save-article-buffer
3183 (when (and overwrite
3184 (file-exists-p filename))
3185 (delete-file filename))
3186 (gnus-output-to-file filename))))
3189 (defun gnus-summary-write-to-file (&optional filename)
3190 "Write this article to a file, overwriting it if the file exists.
3191 Optional argument FILENAME specifies file name.
3192 The directory to save in defaults to `gnus-article-save-directory'."
3193 (gnus-summary-save-in-file nil t))
3195 (defun gnus-summary-save-body-in-file (&optional filename)
3196 "Append this article body to a file.
3197 Optional argument FILENAME specifies file name.
3198 The directory to save in defaults to `gnus-article-save-directory'."
3199 (setq filename (gnus-read-save-file-name
3200 "Save %s body in file:" filename
3201 gnus-file-save-name gnus-newsgroup-name
3202 gnus-current-headers 'gnus-newsgroup-last-file))
3203 (gnus-eval-in-buffer-window gnus-save-article-buffer
3207 (when (article-goto-body)
3208 (narrow-to-region (point) (point-max)))
3209 (gnus-output-to-file filename))))
3212 (defun gnus-summary-save-in-pipe (&optional command)
3213 "Pipe this article to subprocess."
3215 (cond ((and (eq command 'default)
3216 gnus-last-shell-command)
3217 gnus-last-shell-command)
3222 "Shell command on %s: "
3223 (if (and gnus-number-of-articles-to-be-saved
3224 (> gnus-number-of-articles-to-be-saved 1))
3225 (format "these %d articles"
3226 gnus-number-of-articles-to-be-saved)
3228 gnus-last-shell-command))))
3229 (when (string-equal command "")
3230 (if gnus-last-shell-command
3231 (setq command gnus-last-shell-command)
3232 (error "A command is required")))
3233 (gnus-eval-in-buffer-window gnus-article-buffer
3236 (shell-command-on-region (point-min) (point-max) command nil)))
3237 (setq gnus-last-shell-command command))
3239 (defmacro gnus-read-string (prompt &optional initial-contents history
3241 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3242 (if (and (featurep 'xemacs)
3243 (< emacs-minor-version 2))
3244 `(read-string ,prompt ,initial-contents ,history)
3245 `(read-string ,prompt ,initial-contents ,history ,default-value)))
3247 (defun gnus-summary-pipe-to-muttprint (&optional command)
3248 "Pipe this article to muttprint."
3249 (setq command (gnus-read-string
3250 "Print using command: " gnus-summary-muttprint-program
3251 nil gnus-summary-muttprint-program))
3252 (gnus-summary-save-in-pipe command))
3254 ;;; Article file names when saving.
3256 (defun gnus-capitalize-newsgroup (newsgroup)
3257 "Capitalize NEWSGROUP name."
3258 (when (not (zerop (length newsgroup)))
3259 (concat (char-to-string (upcase (aref newsgroup 0)))
3260 (substring newsgroup 1))))
3262 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3263 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3264 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3265 Otherwise, it is like ~/News/news/group/num."
3268 (concat (if (gnus-use-long-file-name 'not-save)
3269 (gnus-capitalize-newsgroup newsgroup)
3270 (gnus-newsgroup-directory-form newsgroup))
3271 "/" (int-to-string (mail-header-number headers)))
3272 gnus-article-save-directory)))
3274 (string-equal (file-name-directory default)
3275 (file-name-directory last-file))
3276 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3278 (or last-file default))))
3280 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3281 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3282 If variable `gnus-use-long-file-name' is non-nil, it is
3283 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3286 (concat (if (gnus-use-long-file-name 'not-save)
3288 (gnus-newsgroup-directory-form newsgroup))
3289 "/" (int-to-string (mail-header-number headers)))
3290 gnus-article-save-directory)))
3292 (string-equal (file-name-directory default)
3293 (file-name-directory last-file))
3294 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3296 (or last-file default))))
3298 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3299 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3300 If variable `gnus-use-long-file-name' is non-nil, it is
3301 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3304 (if (gnus-use-long-file-name 'not-save)
3307 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3309 gnus-article-save-directory)))
3311 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3312 "Generate file name from sender."
3313 (let ((from (mail-header-from headers)))
3315 (if (and from (string-match "\\([^ <]+\\)@" from))
3316 (match-string 1 from)
3318 gnus-article-save-directory)))
3320 (defun article-verify-x-pgp-sig ()
3323 (if (gnus-buffer-live-p gnus-original-article-buffer)
3324 (let ((sig (with-current-buffer gnus-original-article-buffer
3325 (gnus-fetch-field "X-PGP-Sig")))
3329 (mml2015-clear-verify-function))
3331 (insert-buffer-substring gnus-original-article-buffer)
3332 (setq items (split-string sig))
3333 (message-narrow-to-head)
3334 (let ((inhibit-point-motion-hooks t)
3335 (case-fold-search t))
3336 ;; Don't verify multiple headers.
3337 (setq headers (mapconcat (lambda (header)
3339 (mail-fetch-field header)
3341 (split-string (nth 1 items) ",") "")))
3342 (delete-region (point-min) (point-max))
3343 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3344 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3349 (if (looking-at "^-")
3352 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3353 (insert "Version: " (car items) "\n\n")
3354 (insert (mapconcat 'identity (cddr items) "\n"))
3355 (insert "\n-----END PGP SIGNATURE-----\n")
3356 (let ((mm-security-handle (list (format "multipart/signed"))))
3357 (mml2015-clean-buffer)
3358 (let ((coding-system-for-write (or gnus-newsgroup-charset
3360 (funcall (mml2015-clear-verify-function)))
3362 (or (mm-handle-multipart-ctl-parameter
3363 mm-security-handle 'gnus-details)
3364 (mm-handle-multipart-ctl-parameter
3365 mm-security-handle 'gnus-info)))))
3367 (let (buffer-read-only bface eface)
3369 (message-narrow-to-head)
3370 (goto-char (point-max))
3372 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3373 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3374 (message-remove-header "X-Gnus-PGP-Verify")
3375 (if (re-search-forward "^X-PGP-Sig:" nil t)
3377 (goto-char (point-max)))
3378 (narrow-to-region (point) (point))
3379 (insert "X-Gnus-PGP-Verify: " info "\n")
3380 (goto-char (point-min))
3383 (if (not (looking-at "^[ \t]"))
3387 (goto-char (point-min))
3388 (when (looking-at "\\([^:]+\\): *")
3389 (put-text-property (match-beginning 1) (1+ (match-end 1))
3391 (put-text-property (match-end 0) (point-max)
3392 'face eface)))))))))
3394 (defun article-verify-cancel-lock ()
3395 "Verify Cancel-Lock header."
3397 (if (gnus-buffer-live-p gnus-original-article-buffer)
3398 (canlock-verify gnus-original-article-buffer)))
3405 (setq afunc (car func)
3408 gfunc (intern (format "gnus-%s" func))))
3410 (when (fboundp afunc)
3411 `(lambda (&optional interactive &rest args)
3412 ,(documentation afunc t)
3413 (interactive (list t))
3415 (set-buffer gnus-article-buffer)
3417 (call-interactively ',afunc)
3418 (apply ',afunc args))))))))
3419 '(article-hide-headers
3420 article-verify-x-pgp-sig
3421 article-verify-cancel-lock
3422 article-hide-boring-headers
3423 article-treat-overstrike
3424 article-fill-long-lines
3425 article-capitalize-sentences
3427 article-remove-leading-whitespace
3428 article-display-x-face
3429 article-display-face
3430 article-de-quoted-unreadable
3431 article-de-base64-unreadable
3434 article-unsplit-urls
3435 article-hide-list-identifiers
3436 article-strip-banner
3439 article-hide-signature
3440 article-strip-headers-in-body
3441 article-remove-trailing-blank-lines
3442 article-strip-leading-blank-lines
3443 article-strip-multiple-blank-lines
3444 article-strip-leading-space
3445 article-strip-trailing-space
3446 article-strip-blank-lines
3447 article-strip-all-blank-lines
3449 article-date-english
3450 article-date-iso8601
3451 article-date-original
3453 article-decode-mime-words
3454 article-decode-charset
3455 article-decode-encoded-words
3459 article-treat-dumbquotes
3460 article-normalize-headers
3461 ;; (article-show-all . gnus-article-show-all-headers)
3465 ;;; Gnus article mode
3468 (put 'gnus-article-mode 'mode-class 'special)
3470 (set-keymap-parent gnus-article-mode-map widget-keymap)
3472 (gnus-define-keys gnus-article-mode-map
3473 " " gnus-article-goto-next-page
3474 "\177" gnus-article-goto-prev-page
3475 [delete] gnus-article-goto-prev-page
3476 [backspace] gnus-article-goto-prev-page
3477 "\C-c^" gnus-article-refer-article
3478 "h" gnus-article-show-summary
3479 "s" gnus-article-show-summary
3480 "\C-c\C-m" gnus-article-mail
3481 "?" gnus-article-describe-briefly
3482 "e" gnus-summary-edit-article
3483 "<" beginning-of-buffer
3485 "\C-c\C-i" gnus-info-find-node
3487 "R" gnus-article-reply-with-original
3488 "F" gnus-article-followup-with-original
3489 "\C-hk" gnus-article-describe-key
3490 "\C-hc" gnus-article-describe-key-briefly
3492 "\C-d" gnus-article-read-summary-keys
3493 "\M-*" gnus-article-read-summary-keys
3494 "\M-#" gnus-article-read-summary-keys
3495 "\M-^" gnus-article-read-summary-keys
3496 "\M-g" gnus-article-read-summary-keys)
3498 (substitute-key-definition
3499 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3501 (defun gnus-article-make-menu-bar ()
3502 (unless (boundp 'gnus-article-commands-menu)
3503 (gnus-summary-make-menu-bar))
3504 (gnus-turn-off-edit-menu 'article)
3505 (unless (boundp 'gnus-article-article-menu)
3507 gnus-article-article-menu gnus-article-mode-map ""
3509 ["Scroll forwards" gnus-article-goto-next-page t]
3510 ["Scroll backwards" gnus-article-goto-prev-page t]
3511 ["Show summary" gnus-article-show-summary t]
3512 ["Fetch Message-ID at point" gnus-article-refer-article t]
3513 ["Mail to address at point" gnus-article-mail t]
3514 ["Send a bug report" gnus-bug t]))
3517 gnus-article-treatment-menu gnus-article-mode-map ""
3518 ;; Fixme: this should use :active (and maybe :visible).
3520 ["Hide headers" gnus-article-hide-headers t]
3521 ["Hide signature" gnus-article-hide-signature t]
3522 ["Hide citation" gnus-article-hide-citation t]
3523 ["Treat overstrike" gnus-article-treat-overstrike t]
3524 ["Remove carriage return" gnus-article-remove-cr t]
3525 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3526 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3527 ["Remove base64" gnus-article-de-base64-unreadable t]
3528 ["Treat html" gnus-article-wash-html t]
3529 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3530 ["Decode HZ" gnus-article-decode-HZ t]))
3532 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3534 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3536 (gnus-run-hooks 'gnus-article-menu-hook)))
3538 (defun gnus-article-mode ()
3539 "Major mode for displaying an article.
3541 All normal editing commands are switched off.
3543 The following commands are available in addition to all summary mode
3545 \\<gnus-article-mode-map>
3546 \\[gnus-article-next-page]\t Scroll the article one page forwards
3547 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3548 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3549 \\[gnus-article-show-summary]\t Display the summary buffer
3550 \\[gnus-article-mail]\t Send a reply to the address near point
3551 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3552 \\[gnus-info-find-node]\t Go to the Gnus info node"
3554 (gnus-simplify-mode-line)
3555 (setq mode-name "Article")
3556 (setq major-mode 'gnus-article-mode)
3557 (make-local-variable 'minor-mode-alist)
3558 (use-local-map gnus-article-mode-map)
3559 (when (gnus-visual-p 'article-menu 'menu)
3560 (gnus-article-make-menu-bar)
3561 (when gnus-summary-tool-bar-map
3562 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3563 (gnus-update-format-specifications nil 'article-mode)
3564 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3565 (make-local-variable 'gnus-page-broken)
3566 (make-local-variable 'gnus-button-marker-list)
3567 (make-local-variable 'gnus-article-current-summary)
3568 (make-local-variable 'gnus-article-mime-handles)
3569 (make-local-variable 'gnus-article-decoded-p)
3570 (make-local-variable 'gnus-article-mime-handle-alist)
3571 (make-local-variable 'gnus-article-wash-types)
3572 (make-local-variable 'gnus-article-image-alist)
3573 (make-local-variable 'gnus-article-charset)
3574 (make-local-variable 'gnus-article-ignored-charsets)
3575 (gnus-set-default-directory)
3576 (buffer-disable-undo)
3577 (setq buffer-read-only t)
3578 (set-syntax-table gnus-article-mode-syntax-table)
3579 (mm-enable-multibyte)
3580 (gnus-run-hooks 'gnus-article-mode-hook))
3582 (defun gnus-article-setup-buffer ()
3583 "Initialize the article buffer."
3584 (let* ((name (if gnus-single-article-buffer "*Article*"
3585 (concat "*Article " gnus-newsgroup-name "*")))
3587 (progn (string-match "\\*Article" name)
3588 (concat " *Original Article"
3589 (substring name (match-end 0))))))
3590 (setq gnus-article-buffer name)
3591 (setq gnus-original-article-buffer original)
3592 (setq gnus-article-mime-handle-alist nil)
3593 ;; This might be a variable local to the summary buffer.
3594 (unless gnus-single-article-buffer
3596 (set-buffer gnus-summary-buffer)
3597 (setq gnus-article-buffer name)
3598 (setq gnus-original-article-buffer original)
3599 (gnus-set-global-variables)))
3600 (gnus-article-setup-highlight-words)
3601 ;; Init original article buffer.
3603 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3604 (mm-enable-multibyte)
3605 (setq major-mode 'gnus-original-article-mode)
3606 (make-local-variable 'gnus-original-article))
3607 (if (get-buffer name)
3610 (when (and gnus-article-edit-mode
3613 (y-or-n-p "Article mode edit in progress; discard? ")))
3614 (error "Action aborted"))
3615 (set (make-local-variable 'gnus-article-edit-mode) nil)
3616 (when gnus-article-mime-handles
3617 (mm-destroy-parts gnus-article-mime-handles)
3618 (setq gnus-article-mime-handles nil))
3619 ;; Set it to nil in article-buffer!
3620 (setq gnus-article-mime-handle-alist nil)
3621 (buffer-disable-undo)
3622 (setq buffer-read-only t)
3623 ;; This list just keeps growing if we don't reset it.
3624 (setq gnus-button-marker-list nil)
3625 (unless (eq major-mode 'gnus-article-mode)
3626 (gnus-article-mode))
3629 (set-buffer (gnus-get-buffer-create name))
3631 (make-local-variable 'gnus-summary-buffer)
3632 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3633 (current-buffer)))))
3635 ;; Set article window start at LINE, where LINE is the number of lines
3636 ;; from the head of the article.
3637 (defun gnus-article-set-window-start (&optional line)
3639 (gnus-get-buffer-window gnus-article-buffer t)
3641 (set-buffer gnus-article-buffer)
3642 (goto-char (point-min))
3645 (gnus-message 6 "Moved to bookmark")
3646 (search-forward "\n\n" nil t)
3650 (defun gnus-article-prepare (article &optional all-headers header)
3651 "Prepare ARTICLE in article mode buffer.
3652 ARTICLE should either be an article number or a Message-ID.
3653 If ARTICLE is an id, HEADER should be the article headers.
3654 If ALL-HEADERS is non-nil, no headers are hidden."
3656 ;; Make sure we start in a summary buffer.
3657 (unless (eq major-mode 'gnus-summary-mode)
3658 (set-buffer gnus-summary-buffer))
3659 (setq gnus-summary-buffer (current-buffer))
3660 (let* ((gnus-article (if header (mail-header-number header) article))
3661 (summary-buffer (current-buffer))
3662 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3663 (group gnus-newsgroup-name)
3666 (gnus-article-setup-buffer)
3667 (set-buffer gnus-article-buffer)
3668 ;; Deactivate active regions.
3669 (when (and (boundp 'transient-mark-mode)
3670 transient-mark-mode)
3671 (setq mark-active nil))
3672 (if (not (setq result (let ((buffer-read-only nil))
3673 (gnus-request-article-this-buffer
3675 ;; There is no such article.
3677 (when (and (numberp article)
3678 (not (memq article gnus-newsgroup-sparse)))
3679 (setq gnus-article-current
3680 (cons gnus-newsgroup-name article))
3681 (set-buffer gnus-summary-buffer)
3682 (setq gnus-current-article article)
3683 (if (and (memq article gnus-newsgroup-undownloaded)
3684 (not (gnus-online (gnus-find-method-for-group
3685 gnus-newsgroup-name))))
3687 (gnus-summary-set-agent-mark article)
3688 (message "Message marked for downloading"))
3689 (gnus-summary-mark-article article gnus-canceled-mark)
3690 (unless (memq article gnus-newsgroup-sparse)
3691 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3692 (if (or (eq result 'pseudo)
3693 (eq result 'nneething))
3696 (set-buffer summary-buffer)
3697 (push article gnus-newsgroup-history)
3698 (setq gnus-last-article gnus-current-article
3699 gnus-current-article 0
3700 gnus-current-headers nil
3701 gnus-article-current nil)
3702 (if (eq result 'nneething)
3703 (gnus-configure-windows 'summary)
3704 (gnus-configure-windows 'article))
3705 (gnus-set-global-variables))
3706 (let ((gnus-article-mime-handle-alist-1
3707 gnus-article-mime-handle-alist))
3708 (gnus-set-mode-line 'article)))
3709 ;; The result from the `request' was an actual article -
3710 ;; or at least some text that is now displayed in the
3712 (when (and (numberp article)
3713 (not (eq article gnus-current-article)))
3714 ;; Seems like a new article has been selected.
3715 ;; `gnus-current-article' must be an article number.
3717 (set-buffer summary-buffer)
3718 (push article gnus-newsgroup-history)
3719 (setq gnus-last-article gnus-current-article
3720 gnus-current-article article
3721 gnus-current-headers
3722 (gnus-summary-article-header gnus-current-article)
3723 gnus-article-current
3724 (cons gnus-newsgroup-name gnus-current-article))
3725 (unless (vectorp gnus-current-headers)
3726 (setq gnus-current-headers nil))
3727 (gnus-summary-goto-subject gnus-current-article)
3728 (when (gnus-summary-show-thread)
3729 ;; If the summary buffer really was folded, the
3730 ;; previous goto may not actually have gone to
3731 ;; the right article, but the thread root instead.
3733 (gnus-summary-goto-subject gnus-current-article))
3734 (gnus-run-hooks 'gnus-mark-article-hook)
3735 (gnus-set-mode-line 'summary)
3736 (when (gnus-visual-p 'article-highlight 'highlight)
3737 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3738 ;; Set the global newsgroup variables here.
3739 (gnus-set-global-variables)
3740 (setq gnus-have-all-headers
3741 (or all-headers gnus-show-all-headers))))
3743 (gnus-configure-windows 'article))
3744 (when (or (numberp article)
3746 (gnus-article-prepare-display)
3748 (goto-char (point-min))
3749 (setq gnus-page-broken
3750 (when gnus-break-pages
3751 (gnus-narrow-to-page)
3753 (let ((gnus-article-mime-handle-alist-1
3754 gnus-article-mime-handle-alist))
3755 (gnus-set-mode-line 'article))
3759 (set-window-point (get-buffer-window (current-buffer)) (point))
3760 (gnus-configure-windows 'article)
3764 (defun gnus-article-prepare-display ()
3765 "Make the current buffer look like a nice article."
3766 ;; Hooks for getting information from the article.
3767 ;; This hook must be called before being narrowed.
3768 (let ((gnus-article-buffer (current-buffer))
3770 (unless (eq major-mode 'gnus-article-mode)
3771 (gnus-article-mode))
3772 (setq buffer-read-only nil
3773 gnus-article-wash-types nil
3774 gnus-article-image-alist nil)
3775 (gnus-run-hooks 'gnus-tmp-internal-hook)
3776 (when gnus-display-mime-function
3777 (funcall gnus-display-mime-function))
3778 (gnus-run-hooks 'gnus-article-prepare-hook)))
3781 ;;; Gnus MIME viewing functions
3784 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3785 "Format of the MIME buttons.
3787 Valid specifiers include:
3789 %T MIME type, along with additional info
3790 %n The `name' parameter
3791 %d The description, if any
3792 %l The length of the encoded part
3793 %p The part identifier number
3794 %e Dots if the part isn't displayed
3796 General format specifiers can also be used. See Info node
3797 `(gnus)Formatting Variables'.")
3799 (defvar gnus-mime-button-line-format-alist
3800 '((?t gnus-tmp-type ?s)
3801 (?T gnus-tmp-type-long ?s)
3802 (?n gnus-tmp-name ?s)
3803 (?d gnus-tmp-description ?s)
3805 (?l gnus-tmp-length ?d)
3806 (?e gnus-tmp-dots ?s)))
3808 (defvar gnus-mime-button-commands
3809 '((gnus-article-press-button "\r" "Toggle Display")
3810 (gnus-mime-view-part "v" "View Interactively...")
3811 (gnus-mime-view-part-as-type "t" "View As Type...")
3812 (gnus-mime-view-part-as-charset "C" "View As charset...")
3813 (gnus-mime-save-part "o" "Save...")
3814 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3815 (gnus-mime-delete-part "d" "Delete part")
3816 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3817 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3818 (gnus-mime-view-part-internally "E" "View Internally")
3819 (gnus-mime-view-part-externally "e" "View Externally")
3820 (gnus-mime-print-part "p" "Print")
3821 (gnus-mime-pipe-part "|" "Pipe To Command...")
3822 (gnus-mime-action-on-part "." "Take action on the part...")))
3824 (defun gnus-article-mime-part-status ()
3825 (if gnus-article-mime-handle-alist-1
3826 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3828 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3831 (defvar gnus-mime-button-map
3832 (let ((map (make-sparse-keymap)))
3833 (unless (>= (string-to-number emacs-version) 21)
3834 ;; XEmacs doesn't care.
3835 (set-keymap-parent map gnus-article-mode-map))
3836 (define-key map gnus-mouse-2 'gnus-article-push-button)
3837 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3838 (dolist (c gnus-mime-button-commands)
3839 (define-key map (cadr c) (car c)))
3843 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
3845 ,@(mapcar (lambda (c)
3846 (vector (caddr c) (car c) :enable t))
3847 gnus-mime-button-commands)))
3850 (define-compiler-macro popup-menu (&whole form
3851 menu &optional position prefix)
3852 (if (and (fboundp 'popup-menu)
3853 (not (memq 'popup-menu (assoc "lmenu" load-history))))
3855 ;; Gnus is probably running under Emacs 20.
3856 `(let* ((menu (cdr ,menu))
3857 (response (x-popup-menu
3859 (cons "" (mapcar (lambda (c)
3860 (cons (caddr c) (car c)))
3863 (call-interactively (nth 3 (assq response menu))))))))
3865 (defun gnus-mime-button-menu (event prefix)
3866 "Construct a context-sensitive menu of MIME commands."
3867 (interactive "e\nP")
3868 (save-window-excursion
3869 (let ((pos (event-start event)))
3870 (select-window (posn-window pos))
3871 (goto-char (posn-point pos))
3872 (gnus-article-check-buffer)
3873 (popup-menu gnus-mime-button-menu nil prefix))))
3875 (defun gnus-mime-view-all-parts (&optional handles)
3876 "View all the MIME parts."
3878 (save-current-buffer
3879 (set-buffer gnus-article-buffer)
3880 (let ((handles (or handles gnus-article-mime-handles))
3881 (mail-parse-charset gnus-newsgroup-charset)
3882 (mail-parse-ignored-charsets
3883 (with-current-buffer gnus-summary-buffer
3884 gnus-newsgroup-ignored-charsets)))
3886 (mm-remove-parts handles)
3887 (goto-char (point-min))
3888 (or (search-forward "\n\n") (goto-char (point-max)))
3889 (let (buffer-read-only)
3890 (delete-region (point) (point-max))
3891 (mm-display-parts handles))))))
3893 (defun gnus-mime-save-part-and-strip ()
3894 "Save the MIME part under point then replace it with an external body."
3896 (gnus-article-check-buffer)
3897 (let* ((data (get-text-property (point) 'gnus-data))
3899 (handles gnus-article-mime-handles))
3900 (if (mm-multiple-handles gnus-article-mime-handles)
3901 (error "This function is not implemented"))
3902 (setq file (and data (mm-save-part data)))
3904 (with-current-buffer (mm-handle-buffer data)
3906 (insert "Content-Type: " (mm-handle-media-type data))
3907 (mml-insert-parameter-string (cdr (mm-handle-type data))
3910 (insert "Content-ID: " (message-make-message-id) "\n")
3911 (insert "Content-Transfer-Encoding: binary\n")
3914 (cdr (mm-make-handle nil
3915 `("message/external-body"
3916 (access-type . "LOCAL-FILE")
3918 (set-buffer gnus-summary-buffer)
3919 (gnus-article-edit-article
3922 (let ((mail-parse-charset (or gnus-article-charset
3923 ',gnus-newsgroup-charset))
3924 (mail-parse-ignored-charsets
3925 (or gnus-article-ignored-charsets
3926 ',gnus-newsgroup-ignored-charsets))
3927 (mbl mml-buffer-list))
3928 (setq mml-buffer-list nil)
3929 (insert-buffer gnus-original-article-buffer)
3930 (mime-to-mml ',handles)
3931 (setq gnus-article-mime-handles nil)
3932 (let ((mbl1 mml-buffer-list))
3933 (setq mml-buffer-list mbl)
3934 (set (make-local-variable 'mml-buffer-list) mbl1))
3935 (gnus-make-local-hook 'kill-buffer-hook)
3936 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3937 `(lambda (no-highlight)
3938 (let ((mail-parse-charset (or gnus-article-charset
3939 ',gnus-newsgroup-charset))
3940 (message-options message-options)
3941 (message-options-set-recipient)
3942 (mail-parse-ignored-charsets
3943 (or gnus-article-ignored-charsets
3944 ',gnus-newsgroup-ignored-charsets)))
3946 (mml-destroy-buffers)
3947 (remove-hook 'kill-buffer-hook
3948 'mml-destroy-buffers t)
3949 (kill-local-variable 'mml-buffer-list))
3950 (gnus-summary-edit-article-done
3951 ,(or (mail-header-references gnus-current-headers) "")
3952 ,(gnus-group-read-only-p)
3953 ,gnus-summary-buffer no-highlight))))))
3955 (defun gnus-mime-delete-part ()
3956 "Delete the MIME part under point.
3957 Replace it with some information about the removed part."
3959 (gnus-article-check-buffer)
3960 (unless (and gnus-novice-user
3961 (not (gnus-yes-or-no-p
3962 "Really delete attachment forever? ")))
3963 (let* ((data (get-text-property (point) 'gnus-data))
3964 (handles gnus-article-mime-handles)
3968 (mail-decode-encoded-word-string (or (mm-handle-description data)
3971 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
3973 (type (mm-handle-media-type data)))
3974 (if (mm-multiple-handles gnus-article-mime-handles)
3975 (error "This function is not implemented"))
3976 (with-current-buffer (mm-handle-buffer data)
3977 (let ((bsize (format "%s" (buffer-size))))
3981 "<#part type=text/plain nofile=yes disposition=attachment"
3982 " description=\"Deleted attachment (" bsize " Byte)\">"
3984 "| The following attachment has been deleted:\n"
3986 "| Type: " type "\n"
3987 "| Filename: " filename "\n"
3988 "| Size (encoded): " bsize " Byte\n"
3989 "| Description: " description "\n"
3993 (cdr (mm-make-handle nil `("text/plain"))))))
3994 (set-buffer gnus-summary-buffer)
3995 ;; FIXME: maybe some of the following code (borrowed from
3996 ;; `gnus-mime-save-part-and-strip') isn't necessary?
3997 (gnus-article-edit-article
4000 (let ((mail-parse-charset (or gnus-article-charset
4001 ',gnus-newsgroup-charset))
4002 (mail-parse-ignored-charsets
4003 (or gnus-article-ignored-charsets
4004 ',gnus-newsgroup-ignored-charsets))
4005 (mbl mml-buffer-list))
4006 (setq mml-buffer-list nil)
4007 (insert-buffer gnus-original-article-buffer)
4008 (mime-to-mml ',handles)
4009 (setq gnus-article-mime-handles nil)
4010 (let ((mbl1 mml-buffer-list))
4011 (setq mml-buffer-list mbl)
4012 (set (make-local-variable 'mml-buffer-list) mbl1))
4013 (gnus-make-local-hook 'kill-buffer-hook)
4014 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4015 `(lambda (no-highlight)
4016 (let ((mail-parse-charset (or gnus-article-charset
4017 ',gnus-newsgroup-charset))
4018 (message-options message-options)
4019 (message-options-set-recipient)
4020 (mail-parse-ignored-charsets
4021 (or gnus-article-ignored-charsets
4022 ',gnus-newsgroup-ignored-charsets)))
4024 (mml-destroy-buffers)
4025 (remove-hook 'kill-buffer-hook
4026 'mml-destroy-buffers t)
4027 (kill-local-variable 'mml-buffer-list))
4028 (gnus-summary-edit-article-done
4029 ,(or (mail-header-references gnus-current-headers) "")
4030 ,(gnus-group-read-only-p)
4031 ,gnus-summary-buffer no-highlight)))))
4032 ;; Not in `gnus-mime-save-part-and-strip':
4033 (gnus-article-edit-done)
4034 (gnus-summary-expand-window)
4035 (gnus-summary-show-article))
4037 (defun gnus-mime-save-part ()
4038 "Save the MIME part under point."
4040 (gnus-article-check-buffer)
4041 (let ((data (get-text-property (point) 'gnus-data)))
4043 (mm-save-part data))))
4045 (defun gnus-mime-pipe-part ()
4046 "Pipe the MIME part under point to a process."
4048 (gnus-article-check-buffer)
4049 (let ((data (get-text-property (point) 'gnus-data)))
4051 (mm-pipe-part data))))
4053 (defun gnus-mime-view-part ()
4054 "Interactively choose a viewing method for the MIME part under point."
4056 (gnus-article-check-buffer)
4057 (let ((data (get-text-property (point) 'gnus-data)))
4059 (setq gnus-article-mime-handles
4061 gnus-article-mime-handles (setq data (copy-sequence data))))
4062 (mm-interactively-view-part data))))
4064 (defun gnus-mime-view-part-as-type-internal ()
4065 (gnus-article-check-buffer)
4066 (let* ((name (mail-content-type-get
4067 (mm-handle-type (get-text-property (point) 'gnus-data))
4069 (def-type (and name (mm-default-file-encoding name))))
4070 (and def-type (cons def-type 0))))
4072 (defun gnus-mime-view-part-as-type (&optional mime-type)
4073 "Choose a MIME media type, and view the part as such."
4076 (setq mime-type (completing-read
4077 "View as MIME type: "
4078 (mapcar #'list (mailcap-mime-types))
4080 (gnus-mime-view-part-as-type-internal))))
4081 (gnus-article-check-buffer)
4082 (let ((handle (get-text-property (point) 'gnus-data)))
4085 (mm-make-handle (mm-handle-buffer handle)
4086 (cons mime-type (cdr (mm-handle-type handle)))
4087 (mm-handle-encoding handle)
4088 (mm-handle-undisplayer handle)
4089 (mm-handle-disposition handle)
4090 (mm-handle-description handle)
4092 (mm-handle-id handle)))
4093 (setq gnus-article-mime-handles
4094 (mm-merge-handles gnus-article-mime-handles handle))
4095 (gnus-mm-display-part handle))))
4098 (require 'jka-compr))
4100 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4101 ;; emacs can do that itself.
4103 (defun gnus-mime-jka-compr-maybe-uncompress ()
4104 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4105 The uncompress method used is derived from `buffer-file-name'."
4106 (when (and (fboundp 'jka-compr-installed-p)
4107 (jka-compr-installed-p))
4108 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4110 (let ((basename (file-name-nondirectory buffer-file-name))
4111 (args (jka-compr-info-uncompress-args info))
4112 (prog (jka-compr-info-uncompress-program info))
4113 (message (jka-compr-info-uncompress-message info))
4114 (err-file (jka-compr-make-temp-name)))
4116 (message "%s %s..." message basename))
4118 (unless (memq (apply 'call-process-region
4119 (point-min) (point-max)
4121 t (list t err-file) nil
4123 jka-compr-acceptable-retval-list)
4124 (jka-compr-error prog args basename message err-file))
4125 (jka-compr-delete-temp-file err-file)))))))
4127 (defun gnus-mime-copy-part (&optional handle)
4128 "Put the MIME part under point into a new buffer.
4129 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4132 (gnus-article-check-buffer)
4133 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4134 (contents (and handle (mm-get-part handle)))
4136 (file-name-nondirectory
4138 (mail-content-type-get (mm-handle-type handle) 'name)
4139 (mail-content-type-get (mm-handle-disposition handle)
4142 (buffer (and base (generate-new-buffer base))))
4144 (switch-to-buffer buffer)
4146 ;; We do it this way to make `normal-mode' set the appropriate mode.
4149 (setq buffer-file-name (expand-file-name base))
4150 (gnus-mime-jka-compr-maybe-uncompress)
4152 (setq buffer-file-name nil))
4153 (goto-char (point-min)))))
4155 (defun gnus-mime-print-part (&optional handle filename)
4156 "Print the MIME part under point."
4157 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4158 (gnus-article-check-buffer)
4159 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4160 (contents (and handle (mm-get-part handle)))
4161 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4162 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4167 (mm-save-part-to-file handle file)
4168 (call-process shell-file-name nil
4169 (generate-new-buffer " *mm*")
4171 shell-command-switch
4173 printer file (mm-handle-type handle))))
4177 (gnus-print-buffer))
4178 (ps-despool filename)))))
4180 (defun gnus-mime-inline-part (&optional handle arg)
4181 "Insert the MIME part under point into the current buffer."
4182 (interactive (list nil current-prefix-arg))
4183 (gnus-article-check-buffer)
4184 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4189 (if (and (not arg) (mm-handle-undisplayer handle))
4190 (mm-remove-part handle)
4191 (setq contents (mm-get-part handle))
4194 (setq charset (or (mail-content-type-get
4195 (mm-handle-type handle) 'charset)
4196 gnus-newsgroup-charset)))
4198 (if (mm-handle-undisplayer handle)
4199 (mm-remove-part handle))
4202 gnus-summary-show-article-charset-alist))
4203 (mm-read-coding-system "Charset: ")))))
4205 (mm-insert-inline handle
4207 (setq charset (mm-charset-to-coding-system
4209 (not (eq charset 'ascii)))
4210 (mm-decode-coding-string contents charset)
4214 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4215 "Insert the MIME part under point into the current buffer using the
4217 (interactive (list nil current-prefix-arg))
4218 (gnus-article-check-buffer)
4219 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4224 (if (mm-handle-undisplayer handle)
4225 (mm-remove-part handle))
4226 (let ((gnus-newsgroup-charset
4228 gnus-summary-show-article-charset-alist))
4229 (mm-read-coding-system "Charset: ")))
4230 (gnus-newsgroup-ignored-charsets 'gnus-all))
4231 (gnus-article-press-button)))))
4233 (defun gnus-mime-view-part-externally (&optional handle)
4234 "View the MIME part under point with an external viewer."
4236 (gnus-article-check-buffer)
4237 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4238 (mm-user-display-methods nil)
4239 (mm-inlined-types nil)
4240 (mail-parse-charset gnus-newsgroup-charset)
4241 (mail-parse-ignored-charsets
4242 (save-excursion (set-buffer gnus-summary-buffer)
4243 gnus-newsgroup-ignored-charsets)))
4245 (if (mm-handle-undisplayer handle)
4246 (mm-remove-part handle)
4247 (mm-display-part handle)))))
4249 (defun gnus-mime-view-part-internally (&optional handle)
4250 "View the MIME part under point with an internal viewer.
4251 If no internal viewer is available, use an external viewer."
4253 (gnus-article-check-buffer)
4254 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4255 (mm-inlined-types '(".*"))
4256 (mm-inline-large-images t)
4257 (mail-parse-charset gnus-newsgroup-charset)
4258 (mail-parse-ignored-charsets
4259 (save-excursion (set-buffer gnus-summary-buffer)
4260 gnus-newsgroup-ignored-charsets))
4263 (if (mm-handle-undisplayer handle)
4264 (mm-remove-part handle)
4265 (mm-display-part handle)))))
4267 (defun gnus-mime-action-on-part (&optional action)
4268 "Do something with the MIME attachment at \(point\)."
4270 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4271 (gnus-article-check-buffer)
4272 (let ((action-pair (assoc action gnus-mime-action-alist)))
4274 (funcall (cdr action-pair)))))
4276 (defun gnus-article-part-wrapper (n function)
4277 (save-current-buffer
4278 (set-buffer gnus-article-buffer)
4279 (when (> n (length gnus-article-mime-handle-alist))
4280 (error "No such part"))
4281 (gnus-article-goto-part n)
4282 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4283 (funcall function handle))))
4285 (defun gnus-article-pipe-part (n)
4286 "Pipe MIME part N, which is the numerical prefix."
4288 (gnus-article-part-wrapper n 'mm-pipe-part))
4290 (defun gnus-article-save-part (n)
4291 "Save MIME part N, which is the numerical prefix."
4293 (gnus-article-part-wrapper n 'mm-save-part))
4295 (defun gnus-article-interactively-view-part (n)
4296 "View MIME part N interactively, which is the numerical prefix."
4298 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4300 (defun gnus-article-copy-part (n)
4301 "Copy MIME part N, which is the numerical prefix."
4303 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4305 (defun gnus-article-view-part-as-charset (n)
4306 "Copy MIME part N, which is the numerical prefix."
4308 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4310 (defun gnus-article-view-part-externally (n)
4311 "View MIME part N externally, which is the numerical prefix."
4313 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4315 (defun gnus-article-inline-part (n)
4316 "Inline MIME part N, which is the numerical prefix."
4318 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4320 (defun gnus-article-mime-match-handle-first (condition)
4322 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4323 (while (setq ihandle (pop alist))
4325 ((functionp condition)
4326 (funcall condition (cdr ihandle)))
4327 ((eq condition 'undisplayed)
4328 (not (or (mm-handle-undisplayer (cdr ihandle))
4329 (equal (mm-handle-media-type (cdr ihandle))
4330 "multipart/alternative"))))
4331 ((eq condition 'undisplayed-alternative)
4332 (not (mm-handle-undisplayer (cdr ihandle))))
4334 (gnus-article-goto-part (car ihandle))
4335 (or (not n) (< (car ihandle) n)))
4336 (setq n (car ihandle))))
4340 (defun gnus-article-view-part (&optional n)
4341 "View MIME part N, which is the numerical prefix."
4343 (save-current-buffer
4344 (set-buffer gnus-article-buffer)
4345 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4346 gnus-article-mime-match-handle-function)))
4347 (when (> n (length gnus-article-mime-handle-alist))
4348 (error "No such part"))
4349 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4350 (when (gnus-article-goto-part n)
4351 (if (equal (car handle) "multipart/alternative")
4352 (gnus-article-press-button)
4353 (when (eq (gnus-mm-display-part handle) 'internal)
4354 (gnus-set-window-start)))))))
4356 (defsubst gnus-article-mime-total-parts ()
4357 (if (bufferp (car gnus-article-mime-handles))
4359 (1- (length gnus-article-mime-handles))))
4361 (defun gnus-mm-display-part (handle)
4362 "Display HANDLE and fix MIME button."
4363 (let ((id (get-text-property (point) 'gnus-part))
4368 (let ((window (selected-window))
4369 (mail-parse-charset gnus-newsgroup-charset)
4370 (mail-parse-ignored-charsets
4371 (if (gnus-buffer-live-p gnus-summary-buffer)
4373 (set-buffer gnus-summary-buffer)
4374 gnus-newsgroup-ignored-charsets)
4378 (let ((win (gnus-get-buffer-window (current-buffer) t))
4381 (select-window win))
4384 (if (mm-handle-displayed-p handle)
4385 ;; This will remove the part.
4386 (mm-display-part handle)
4388 (narrow-to-region (point)
4389 (if (eobp) (point) (1+ (point))))
4390 (mm-display-part handle)
4391 ;; We narrow to the part itself and
4392 ;; then call the treatment functions.
4393 (goto-char (point-min))
4395 (narrow-to-region (point) (point-max))
4398 (gnus-article-mime-total-parts)
4399 (mm-handle-media-type handle)))))
4400 (if (window-live-p window)
4401 (select-window window)))))
4404 (gnus-insert-mime-button
4405 handle id (list (mm-handle-displayed-p handle)))
4406 (goto-char point))))
4408 (defun gnus-article-goto-part (n)
4409 "Go to MIME part N."
4410 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4412 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4413 (let ((gnus-tmp-name
4414 (or (mail-content-type-get (mm-handle-type handle) 'name)
4415 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4416 (mail-content-type-get (mm-handle-type handle) 'url)
4418 (gnus-tmp-type (mm-handle-media-type handle))
4419 (gnus-tmp-description
4420 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4423 (if (if displayed (car displayed)
4424 (mm-handle-displayed-p handle))
4426 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4428 gnus-tmp-type-long b e)
4429 (when (string-match ".*/" gnus-tmp-name)
4430 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4431 (setq gnus-tmp-type-long (concat gnus-tmp-type
4432 (and (not (equal gnus-tmp-name ""))
4433 (concat "; " gnus-tmp-name))))
4434 (unless (equal gnus-tmp-description "")
4435 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4440 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4441 `(,@(gnus-local-map-property gnus-mime-button-map)
4442 gnus-callback gnus-mm-display-part
4443 gnus-part ,gnus-tmp-id
4444 article-type annotation
4447 ;; Exclude a newline.
4450 (widget-convert-button
4453 :action 'gnus-widget-press-button
4454 :button-keymap gnus-mime-button-map
4456 (lambda (widget/window &optional overlay pos)
4457 ;; Needed to properly clear the message due to a bug in
4458 ;; wid-edit (XEmacs only).
4459 (if (boundp 'help-echo-owns-message)
4460 (setq help-echo-owns-message t))
4462 "%S: %s the MIME part; %S: more options"
4463 (aref gnus-mouse-2 0)
4464 ;; XEmacs will get a single widget arg; Emacs 21 will get
4465 ;; window, overlay, position.
4466 (if (mm-handle-displayed-p
4468 (with-current-buffer (gnus-overlay-buffer overlay)
4469 (widget-get (widget-at (gnus-overlay-start overlay))
4471 (widget-get widget/window :mime-handle)))
4473 (aref gnus-down-mouse-3 0))))))
4475 (defun gnus-widget-press-button (elems el)
4476 (goto-char (widget-get elems :from))
4477 (gnus-article-press-button))
4479 (defvar gnus-displaying-mime nil)
4481 (defun gnus-display-mime (&optional ihandles)
4482 "Display the MIME parts."
4484 (save-selected-window
4485 (let ((window (get-buffer-window gnus-article-buffer))
4488 (select-window window)
4489 ;; We have to do this since selecting the window
4490 ;; may change the point. So we set the window point.
4491 (set-window-point window point)))
4492 (let* ((handles (or ihandles
4493 (mm-dissect-buffer nil gnus-article-loose-mime)
4494 (and gnus-article-emulate-mime
4496 buffer-read-only handle name type b e display)
4497 (when (and (not ihandles)
4498 (not gnus-displaying-mime))
4499 ;; Top-level call; we clean up.
4500 (when gnus-article-mime-handles
4501 (mm-destroy-parts gnus-article-mime-handles)
4502 (setq gnus-article-mime-handle-alist nil));; A trick.
4503 (setq gnus-article-mime-handles handles)
4504 ;; We allow users to glean info from the handles.
4505 (when gnus-article-mime-part-function
4506 (gnus-mime-part-function handles)))
4508 (or (not (stringp (car handles)))
4511 (when (and (not ihandles)
4512 (not gnus-displaying-mime))
4513 ;; Clean up for mime parts.
4515 (delete-region (point) (point-max)))
4516 (let ((gnus-displaying-mime t))
4517 (gnus-mime-display-part handles)))
4520 (narrow-to-region (point) (point-max))
4521 (gnus-treat-article nil 1 1)
4524 ;; Highlight the headers.
4528 (narrow-to-region (point-min) (point))
4529 (gnus-treat-article 'head))))))))
4531 (defcustom gnus-mime-display-multipart-as-mixed nil
4532 "Display \"multipart\" parts as \"multipart/mixed\".
4534 If t, it overrides nil values of
4535 `gnus-mime-display-multipart-alternative-as-mixed' and
4536 `gnus-mime-display-multipart-related-as-mixed'."
4537 :group 'gnus-article-mime
4540 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4541 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4542 :group 'gnus-article-mime
4545 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4546 "Display \"multipart/related\" parts as \"multipart/mixed\".
4548 If displaying \"text/html\" is discouraged \(see
4549 `mm-discouraged-alternatives'\) images or other material inside a
4550 \"multipart/related\" part might be overlooked when this variable is nil."
4551 :group 'gnus-article-mime
4554 (defun gnus-mime-display-part (handle)
4557 ((not (stringp (car handle)))
4558 (gnus-mime-display-single handle))
4559 ;; User-defined multipart
4560 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4561 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4563 ;; multipart/alternative
4564 ((and (equal (car handle) "multipart/alternative")
4565 (not (or gnus-mime-display-multipart-as-mixed
4566 gnus-mime-display-multipart-alternative-as-mixed)))
4567 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4568 (push (cons id handle) gnus-article-mime-handle-alist)
4569 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4570 ;; multipart/related
4571 ((and (equal (car handle) "multipart/related")
4572 (not (or gnus-mime-display-multipart-as-mixed
4573 gnus-mime-display-multipart-related-as-mixed)))
4574 ;;;!!!We should find the start part, but we just default
4575 ;;;!!!to the first part.
4576 ;;(gnus-mime-display-part (cadr handle))
4577 ;;;!!! Most multipart/related is an HTML message plus images.
4578 ;;;!!! Unfortunately we are unable to let W3 display those
4579 ;;;!!! included images, so we just display it as a mixed multipart.
4580 ;;(gnus-mime-display-mixed (cdr handle))
4581 ;;;!!! No, w3 can display everything just fine.
4582 (gnus-mime-display-part (cadr handle)))
4583 ((equal (car handle) "multipart/signed")
4584 (gnus-add-wash-type 'signed)
4585 (gnus-mime-display-security handle))
4586 ((equal (car handle) "multipart/encrypted")
4587 (gnus-add-wash-type 'encrypted)
4588 (gnus-mime-display-security handle))
4589 ;; Other multiparts are handled like multipart/mixed.
4591 (gnus-mime-display-mixed (cdr handle)))))
4593 (defun gnus-mime-part-function (handles)
4594 (if (stringp (car handles))
4595 (mapcar 'gnus-mime-part-function (cdr handles))
4596 (funcall gnus-article-mime-part-function handles)))
4598 (defun gnus-mime-display-mixed (handles)
4599 (mapcar 'gnus-mime-display-part handles))
4601 (defun gnus-mime-display-single (handle)
4602 (let ((type (mm-handle-media-type handle))
4603 (ignored gnus-ignored-mime-types)
4610 (when (string-match (pop ignored) type)
4611 (throw 'ignored nil)))
4612 (if (and (setq not-attachment
4613 (and (not (mm-inline-override-p handle))
4614 (or (not (mm-handle-disposition handle))
4615 (equal (car (mm-handle-disposition handle))
4617 (mm-attachment-override-p handle))))
4618 (mm-automatic-display-p handle)
4620 (mm-inlinable-p handle)
4621 (mm-inlined-p handle))
4622 (mm-automatic-external-display-p type)))
4624 (when (equal (mm-handle-media-supertype handle) "text")
4626 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4628 (push (cons id handle) gnus-article-mime-handle-alist)
4629 (when (or (not display)
4630 (not (gnus-unbuttonized-mime-type-p type)))
4631 ;(gnus-article-insert-newline)
4632 (gnus-insert-mime-button
4633 handle id (list (or display (and not-attachment text))))
4634 (gnus-article-insert-newline)
4635 ;(gnus-article-insert-newline)
4636 ;; Remember modify the number of forward lines.
4644 (let ((mail-parse-charset gnus-newsgroup-charset)
4645 (mail-parse-ignored-charsets
4646 (save-excursion (condition-case ()
4647 (set-buffer gnus-summary-buffer)
4649 gnus-newsgroup-ignored-charsets)))
4650 (mm-display-part handle t))
4651 (goto-char (point-max)))
4652 ((and text not-attachment)
4656 (gnus-article-insert-newline)
4657 (mm-insert-inline handle (mm-get-part handle))
4658 (goto-char (point-max))))
4662 (narrow-to-region beg (point))
4665 (gnus-article-mime-total-parts)
4666 (mm-handle-media-type handle)))))))))
4668 (defun gnus-unbuttonized-mime-type-p (type)
4669 "Say whether TYPE is to be unbuttonized."
4670 (unless gnus-inhibit-mime-unbuttonizing
4672 (let ((types gnus-unbuttonized-mime-types))
4674 (when (string-match (pop types) type)
4675 (throw 'found t)))))
4677 (let ((types gnus-buttonized-mime-types))
4679 (when (string-match (pop types) type)
4680 (throw 'found t)))))))))
4682 (defun gnus-article-insert-newline ()
4683 "Insert a newline, but mark it as undeletable."
4684 (gnus-put-text-property
4685 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4687 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4688 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4691 handle buffer-read-only from props begend not-pref)
4692 (save-window-excursion
4695 (narrow-to-region (car ibegend)
4698 (goto-char (car ibegend))
4701 (delete-region (point-min) (point-max))
4702 (mm-remove-parts handles))
4703 (setq begend (list (point-marker)))
4705 (unless (setq not-pref (cadr (member preferred ihandles)))
4706 (setq not-pref (car ihandles)))
4709 (not (gnus-unbuttonized-mime-type-p
4710 "multipart/alternative")))
4711 (gnus-add-text-properties
4714 (insert (format "%d. " id))
4718 (unless ,(not ibegend)
4719 (setq gnus-article-mime-handle-alist
4720 ',gnus-article-mime-handle-alist))
4721 (gnus-mime-display-alternative
4722 ',ihandles ',not-pref ',begend ,id))
4723 ,@(gnus-local-map-property gnus-mime-button-map)
4724 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4725 face ,gnus-article-button-face
4728 (widget-convert-button 'link from (point)
4729 :action 'gnus-widget-press-button
4730 :button-keymap gnus-widget-button-keymap)
4732 (while (setq handle (pop handles))
4733 (gnus-add-text-properties
4736 (insert (format "(%c) %-18s"
4737 (if (equal handle preferred) ?* ? )
4738 (mm-handle-media-type handle)))
4742 (unless ,(not ibegend)
4743 (setq gnus-article-mime-handle-alist
4744 ',gnus-article-mime-handle-alist))
4745 (gnus-mime-display-alternative
4746 ',ihandles ',handle ',begend ,id))
4747 ,@(gnus-local-map-property gnus-mime-button-map)
4748 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4749 face ,gnus-article-button-face
4752 (widget-convert-button 'link from (point)
4753 :action 'gnus-widget-press-button
4754 :button-keymap gnus-widget-button-keymap)
4758 (if (stringp (car preferred))
4759 (gnus-display-mime preferred)
4760 (let ((mail-parse-charset gnus-newsgroup-charset)
4761 (mail-parse-ignored-charsets
4762 (save-excursion (set-buffer gnus-summary-buffer)
4763 gnus-newsgroup-ignored-charsets)))
4764 (mm-display-part preferred)
4768 (narrow-to-region (car begend) (point-max))
4770 nil (length gnus-article-mime-handle-alist)
4771 (gnus-article-mime-total-parts)
4772 (mm-handle-media-type handle))))))
4773 (goto-char (point-max))
4774 (setcdr begend (point-marker)))))
4776 (goto-char point))))
4778 (defconst gnus-article-wash-status-strings
4779 (let ((alist '((cite "c" "Possible hidden citation text"
4780 " " "All citation text visible")
4781 (headers "h" "Hidden headers"
4782 " " "All headers visible.")
4783 (pgp "p" "Encrypted or signed message status hidden"
4784 " " "No hidden encryption nor digital signature status")
4785 (signature "s" "Signature has been hidden"
4786 " " "Signature is visible")
4787 (overstrike "o" "Overstrike (^H) characters applied"
4788 " " "No overstrike characters applied")
4789 (emphasis "e" "/*_Emphasis_*/ characters applied"
4790 " " "No /*_emphasis_*/ characters applied")))
4792 (dolist (entry alist result)
4793 (let ((key (nth 0 entry))
4794 (on (copy-sequence (nth 1 entry)))
4795 (on-help (nth 2 entry))
4796 (off (copy-sequence (nth 3 entry)))
4797 (off-help (nth 4 entry)))
4798 (put-text-property 0 1 'help-echo on-help on)
4799 (put-text-property 0 1 'help-echo off-help off)
4800 (push (list key on off) result))))
4801 "Alist of strings describing wash status in the mode line.
4802 Each entry has the form (KEY ON OF), where the KEY is a symbol
4803 representing the particular washing function, ON is the string to use
4804 in the article mode line when the washing function is active, and OFF
4805 is the string to use when it is inactive.")
4807 (defun gnus-article-wash-status-entry (key value)
4808 (let ((entry (assoc key gnus-article-wash-status-strings)))
4809 (if value (nth 1 entry) (nth 2 entry))))
4811 (defun gnus-article-wash-status ()
4812 "Return a string which display status of article washing."
4814 (set-buffer gnus-article-buffer)
4815 (let ((cite (memq 'cite gnus-article-wash-types))
4816 (headers (memq 'headers gnus-article-wash-types))
4817 (boring (memq 'boring-headers gnus-article-wash-types))
4818 (pgp (memq 'pgp gnus-article-wash-types))
4819 (pem (memq 'pem gnus-article-wash-types))
4820 (signed (memq 'signed gnus-article-wash-types))
4821 (encrypted (memq 'encrypted gnus-article-wash-types))
4822 (signature (memq 'signature gnus-article-wash-types))
4823 (overstrike (memq 'overstrike gnus-article-wash-types))
4824 (emphasis (memq 'emphasis gnus-article-wash-types)))
4826 (gnus-article-wash-status-entry 'cite cite)
4827 (gnus-article-wash-status-entry 'headers (or headers boring))
4828 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4829 (gnus-article-wash-status-entry 'signature signature)
4830 (gnus-article-wash-status-entry 'overstrike overstrike)
4831 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4833 (defun gnus-add-wash-type (type)
4834 "Add a washing of TYPE to the current status."
4835 (add-to-list 'gnus-article-wash-types type))
4837 (defun gnus-delete-wash-type (type)
4838 "Add a washing of TYPE to the current status."
4839 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4841 (defun gnus-add-image (category image)
4842 "Add IMAGE of CATEGORY to the list of displayed images."
4843 (let ((entry (assq category gnus-article-image-alist)))
4845 (setq entry (list category))
4846 (push entry gnus-article-image-alist))
4847 (nconc entry (list image))))
4849 (defun gnus-delete-images (category)
4850 "Delete all images in CATEGORY."
4851 (let ((entry (assq category gnus-article-image-alist)))
4852 (dolist (image (cdr entry))
4853 (gnus-remove-image image))
4854 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4855 (gnus-delete-wash-type category)))
4857 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4859 (defun gnus-article-maybe-hide-headers ()
4860 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4861 Provided for backwards compatibility."
4862 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4863 (not (save-excursion (set-buffer gnus-summary-buffer)
4864 gnus-have-all-headers)))
4865 (not gnus-inhibit-hiding))
4866 (gnus-article-hide-headers)))
4870 (defun gnus-output-to-file (file-name)
4871 "Append the current article to a file named FILE-NAME."
4872 (let ((artbuf (current-buffer)))
4874 (insert-buffer-substring artbuf)
4875 ;; Append newline at end of the buffer as separator, and then
4877 (goto-char (point-max))
4879 (let ((file-name-coding-system nnmail-pathname-coding-system))
4880 (mm-append-to-file (point-min) (point-max) file-name))
4883 (defun gnus-narrow-to-page (&optional arg)
4884 "Narrow the article buffer to a page.
4885 If given a numerical ARG, move forward ARG pages."
4887 (setq arg (if arg (prefix-numeric-value arg) 0))
4889 (set-buffer gnus-article-buffer)
4890 (goto-char (point-min))
4892 ;; Remove any old next/prev buttons.
4893 (when (gnus-visual-p 'page-marker)
4894 (let ((buffer-read-only nil))
4895 (gnus-remove-text-with-property 'gnus-prev)
4896 (gnus-remove-text-with-property 'gnus-next)))
4899 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4901 (re-search-forward page-delimiter nil 'move arg)))
4902 (goto-char (match-end 0)))
4905 (if (re-search-forward page-delimiter nil 'move)
4908 (when (and (gnus-visual-p 'page-marker)
4909 (not (= (point-min) 1)))
4911 (goto-char (point-min))
4912 (gnus-insert-prev-page-button)))
4913 (when (and (gnus-visual-p 'page-marker)
4914 (< (+ (point-max) 2) (buffer-size)))
4916 (goto-char (point-max))
4917 (gnus-insert-next-page-button)))))
4919 ;; Article mode commands
4921 (defun gnus-article-goto-next-page ()
4922 "Show the next page of the article."
4924 (when (gnus-article-next-page)
4925 (goto-char (point-min))
4926 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4929 (defun gnus-article-goto-prev-page ()
4930 "Show the next page of the article."
4933 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4934 (gnus-article-prev-page nil)))
4936 ;; This is cleaner but currently breaks `gnus-pick-mode':
4938 ;; (defun gnus-article-goto-next-page ()
4939 ;; "Show the next page of the article."
4941 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
4942 ;; (gnus-summary-next-page)))
4944 ;; (defun gnus-article-goto-prev-page ()
4945 ;; "Show the next page of the article."
4947 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
4948 ;; (gnus-summary-prev-page)))
4950 (defun gnus-article-next-page (&optional lines)
4951 "Show the next page of the current article.
4952 If end of article, return non-nil. Otherwise return nil.
4953 Argument LINES specifies lines to be scrolled up."
4955 (move-to-window-line -1)
4958 (and (pos-visible-in-window-p) ;Not continuation line.
4959 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
4960 ;; Nothing in this page.
4961 (if (or (not gnus-page-broken)
4964 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4966 (when gnus-article-over-scroll
4967 (gnus-article-next-page-1 lines))
4969 (gnus-narrow-to-page 1) ;Go to next page.
4971 ;; More in this page.
4972 (gnus-article-next-page-1 lines)
4975 (defun gnus-article-next-page-1 (lines)
4976 (let ((scroll-in-place nil))
4980 ;; Long lines may cause an end-of-buffer error.
4981 (goto-char (point-max)))))
4982 (move-to-window-line 0))
4984 (defun gnus-article-prev-page (&optional lines)
4985 "Show previous page of current article.
4986 Argument LINES specifies lines to be scrolled down."
4988 (move-to-window-line 0)
4989 (if (and gnus-page-broken
4991 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4993 (gnus-narrow-to-page -1) ;Go to previous page.
4994 (goto-char (point-max))
4996 (let ((scroll-in-place nil))
5000 (beginning-of-buffer
5001 (goto-char (point-min))))
5002 (move-to-window-line 0)))))
5004 (defun gnus-article-only-boring-p ()
5005 "Decide whether there is only boring text remaining in the article.
5006 Something \"interesting\" is a word of at least two letters that does
5007 not have a face in `gnus-article-boring-faces'."
5008 (when (and gnus-article-skip-boring
5009 (boundp 'gnus-article-boring-faces)
5010 (symbol-value 'gnus-article-boring-faces))
5013 (while (re-search-forward "\\b\\w\\w" nil t)
5015 (when (not (gnus-intersection
5016 (gnus-faces-at (point))
5017 (symbol-value 'gnus-article-boring-faces)))
5018 (throw 'only-boring nil)))
5019 (throw 'only-boring t)))))
5021 (defun gnus-article-refer-article ()
5022 "Read article specified by message-id around point."
5025 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5026 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5027 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5028 (let ((msg-id (concat "<" (match-string 0) ">")))
5029 (set-buffer gnus-summary-buffer)
5030 (gnus-summary-refer-article msg-id))
5031 (error "No references around point"))))
5033 (defun gnus-article-show-summary ()
5034 "Reconfigure windows to show summary buffer."
5036 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5037 (error "There is no summary buffer for this article buffer")
5038 (gnus-article-set-globals)
5039 (gnus-configure-windows 'article)
5040 (gnus-summary-goto-subject gnus-current-article)
5041 (gnus-summary-position-point)))
5043 (defun gnus-article-describe-briefly ()
5044 "Describe article mode commands briefly."
5046 (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")))
5048 (defun gnus-article-summary-command ()
5049 "Execute the last keystroke in the summary buffer."
5051 (let ((obuf (current-buffer))
5052 (owin (current-window-configuration))
5054 (switch-to-buffer gnus-article-current-summary 'norecord)
5055 (setq func (lookup-key (current-local-map) (this-command-keys)))
5056 (call-interactively func)
5058 (set-window-configuration owin)
5059 (set-window-point (get-buffer-window (current-buffer)) (point))))
5061 (defun gnus-article-summary-command-nosave ()
5062 "Execute the last keystroke in the summary buffer."
5065 (pop-to-buffer gnus-article-current-summary 'norecord)
5066 (setq func (lookup-key (current-local-map) (this-command-keys)))
5067 (call-interactively func)))
5069 (defun gnus-article-check-buffer ()
5070 "Beep if not in an article buffer."
5071 (unless (equal major-mode 'gnus-article-mode)
5072 (error "Command invoked outside of a Gnus article buffer")))
5074 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5075 "Read a summary buffer key sequence and execute it from the article buffer."
5077 (gnus-article-check-buffer)
5079 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5080 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5081 "=" "^" "\M-^" "|"))
5087 '("n" "Gn" "p" "Gp"))
5090 (set-buffer gnus-article-current-summary)
5091 (let (gnus-pick-mode)
5092 (push (or key last-command-event) unread-command-events)
5093 (setq keys (if (featurep 'xemacs)
5094 (events-to-keys (read-key-sequence nil))
5095 (read-key-sequence nil)))))
5099 (if (or (member keys nosaves)
5100 (member keys nosave-but-article)
5101 (member keys nosave-in-article))
5103 (save-window-excursion
5104 (pop-to-buffer gnus-article-current-summary 'norecord)
5105 ;; We disable the pick minor mode commands.
5106 (let (gnus-pick-mode)
5107 (setq func (lookup-key (current-local-map) keys))))
5111 (unless (member keys nosave-in-article)
5112 (set-buffer gnus-article-current-summary))
5113 (call-interactively func)
5114 (setq new-sum-point (point)))
5115 (when (member keys nosave-but-article)
5116 (pop-to-buffer gnus-article-buffer 'norecord)))
5117 ;; These commands should restore window configuration.
5118 (let ((obuf (current-buffer))
5119 (owin (current-window-configuration))
5121 (summary gnus-article-current-summary)
5122 func in-buffer selected)
5123 (if not-restore-window
5124 (pop-to-buffer summary 'norecord)
5125 (switch-to-buffer summary 'norecord))
5126 (setq in-buffer (current-buffer))
5127 ;; We disable the pick minor mode commands.
5128 (if (and (setq func (let (gnus-pick-mode)
5129 (lookup-key (current-local-map) keys)))
5132 (call-interactively func)
5133 (setq new-sum-point (point))
5134 (when (eq in-buffer (current-buffer))
5135 (setq selected (gnus-summary-select-article))
5137 (unless not-restore-window
5138 (set-window-configuration owin))
5139 (when (eq selected 'old)
5141 (set-window-start (get-buffer-window (current-buffer))
5143 (set-window-point (get-buffer-window (current-buffer))
5145 (let ((win (get-buffer-window gnus-article-current-summary)))
5147 (set-window-point win new-sum-point)))) )
5148 (switch-to-buffer gnus-article-buffer)
5151 (defun gnus-article-describe-key (key)
5152 "Display documentation of the function invoked by KEY. KEY is a string."
5153 (interactive "kDescribe key: ")
5154 (gnus-article-check-buffer)
5155 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5157 (set-buffer gnus-article-current-summary)
5158 (let (gnus-pick-mode)
5159 (if (featurep 'xemacs)
5161 (push (elt key 0) unread-command-events)
5162 (setq key (events-to-keys
5163 (read-key-sequence "Describe key: "))))
5164 (setq unread-command-events
5166 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5167 (string-to-list key)))
5168 (setq key (read-key-sequence "Describe key: "))))
5170 (describe-key key)))
5172 (defun gnus-article-describe-key-briefly (key &optional insert)
5173 "Display documentation of the function invoked by KEY. KEY is a string."
5174 (interactive "kDescribe key: \nP")
5175 (gnus-article-check-buffer)
5176 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5178 (set-buffer gnus-article-current-summary)
5179 (let (gnus-pick-mode)
5180 (if (featurep 'xemacs)
5182 (push (elt key 0) unread-command-events)
5183 (setq key (events-to-keys
5184 (read-key-sequence "Describe key: "))))
5185 (setq unread-command-events
5187 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5188 (string-to-list key)))
5189 (setq key (read-key-sequence "Describe key: "))))
5190 (describe-key-briefly key insert))
5191 (describe-key-briefly key insert)))
5193 (defun gnus-article-reply-with-original (&optional wide)
5194 "Start composing a reply mail to the current message.
5195 The text in the region will be yanked. If the region isn't active,
5196 the entire article will be yanked."
5198 (let ((article (cdr gnus-article-current))
5200 (if (not (gnus-mark-active-p))
5201 (with-current-buffer gnus-summary-buffer
5202 (gnus-summary-reply (list (list article)) wide))
5203 (setq contents (buffer-substring (point) (mark t)))
5204 ;; Deactivate active regions.
5205 (when (and (boundp 'transient-mark-mode)
5206 transient-mark-mode)
5207 (setq mark-active nil))
5208 (with-current-buffer gnus-summary-buffer
5210 (list (list article contents)) wide)))))
5212 (defun gnus-article-followup-with-original ()
5213 "Compose a followup to the current article.
5214 The text in the region will be yanked. If the region isn't active,
5215 the entire article will be yanked."
5217 (let ((article (cdr gnus-article-current))
5219 (if (not (gnus-mark-active-p))
5220 (with-current-buffer gnus-summary-buffer
5221 (gnus-summary-followup (list (list article))))
5222 (setq contents (buffer-substring (point) (mark t)))
5223 ;; Deactivate active regions.
5224 (when (and (boundp 'transient-mark-mode)
5225 transient-mark-mode)
5226 (setq mark-active nil))
5227 (with-current-buffer gnus-summary-buffer
5228 (gnus-summary-followup
5229 (list (list article contents)))))))
5231 (defun gnus-article-hide (&optional arg force)
5232 "Hide all the gruft in the current article.
5233 This means that signatures, cited text and (some) headers will be
5235 If given a prefix, show the hidden text instead."
5236 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5237 (gnus-article-hide-headers arg)
5238 (gnus-article-hide-list-identifiers arg)
5239 (gnus-article-hide-citation-maybe arg force)
5240 (gnus-article-hide-signature arg))
5242 (defun gnus-article-maybe-highlight ()
5243 "Do some article highlighting if article highlighting is requested."
5244 (when (gnus-visual-p 'article-highlight 'highlight)
5245 (gnus-article-highlight-some)))
5247 (defun gnus-check-group-server ()
5248 ;; Make sure the connection to the server is alive.
5249 (unless (gnus-server-opened
5250 (gnus-find-method-for-group gnus-newsgroup-name))
5251 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5252 (gnus-request-group gnus-newsgroup-name t)))
5255 (autoload 'nneething-get-file-name "nneething"))
5257 (defun gnus-request-article-this-buffer (article group)
5258 "Get an article and insert it into this buffer."
5259 (let (do-update-line sparse-header)
5263 (gnus-kill-all-overlays)
5264 (setq group (or group gnus-newsgroup-name))
5266 ;; Using `gnus-request-article' directly will insert the article into
5267 ;; `nntp-server-buffer' - so we'll save some time by not having to
5268 ;; copy it from the server buffer into the article buffer.
5270 ;; We only request an article by message-id when we do not have the
5271 ;; headers for it, so we'll have to get those.
5272 (when (stringp article)
5273 (gnus-read-header article))
5275 ;; If the article number is negative, that means that this article
5276 ;; doesn't belong in this newsgroup (possibly), so we find its
5277 ;; message-id and request it by id instead of number.
5278 (when (and (numberp article)
5280 (get-buffer gnus-summary-buffer)
5281 (gnus-buffer-exists-p gnus-summary-buffer))
5283 (set-buffer gnus-summary-buffer)
5284 (let ((header (gnus-summary-article-header article)))
5287 ((memq article gnus-newsgroup-sparse)
5288 ;; This is a sparse gap article.
5289 (setq do-update-line article)
5290 (setq article (mail-header-id header))
5291 (setq sparse-header (gnus-read-header article))
5292 (setq gnus-newsgroup-sparse
5293 (delq article gnus-newsgroup-sparse)))
5295 ;; It's a real article.
5296 (setq article (mail-header-id header)))
5298 ;; It is an extracted pseudo-article.
5299 (setq article 'pseudo)
5300 (gnus-request-pseudo-article header))))
5302 (let ((method (gnus-find-method-for-group
5303 gnus-newsgroup-name)))
5304 (when (and (eq (car method) 'nneething)
5306 (let ((dir (nneething-get-file-name
5307 (mail-header-id header))))
5308 (when (and (stringp dir)
5309 (file-directory-p dir))
5310 (setq article 'nneething)
5311 (gnus-group-enter-directory dir))))))))
5314 ;; Refuse to select canceled articles.
5315 ((and (numberp article)
5317 (get-buffer gnus-summary-buffer)
5318 (gnus-buffer-exists-p gnus-summary-buffer)
5319 (eq (cdr (save-excursion
5320 (set-buffer gnus-summary-buffer)
5321 (assq article gnus-newsgroup-reads)))
5322 gnus-canceled-mark))
5324 ;; We first check `gnus-original-article-buffer'.
5325 ((and (get-buffer gnus-original-article-buffer)
5328 (set-buffer gnus-original-article-buffer)
5329 (and (equal (car gnus-original-article) group)
5330 (eq (cdr gnus-original-article) article))))
5331 (insert-buffer-substring gnus-original-article-buffer)
5333 ;; Check the backlog.
5334 ((and gnus-keep-backlog
5335 (gnus-backlog-request-article group article (current-buffer)))
5337 ;; Check asynchronous pre-fetch.
5338 ((gnus-async-request-fetched-article group article (current-buffer))
5339 (gnus-async-prefetch-next group article gnus-summary-buffer)
5340 (when (and (numberp article) gnus-keep-backlog)
5341 (gnus-backlog-enter-article group article (current-buffer)))
5344 ((and gnus-use-cache
5346 (gnus-cache-request-article article group))
5348 ;; Check the agent cache.
5349 ((gnus-agent-request-article article group)
5351 ;; Get the article and put into the article buffer.
5352 ((or (stringp article)
5354 (let ((gnus-override-method gnus-override-method)
5355 (methods (and (stringp article)
5356 gnus-refer-article-method))
5357 (backend (car (gnus-find-method-for-group
5358 gnus-newsgroup-name)))
5360 (buffer-read-only nil))
5361 (if (or (not (listp methods))
5362 (and (symbolp (car methods))
5363 (assq (car methods) nnoo-definition-alist)))
5364 (setq methods (list methods)))
5365 (when (and (null gnus-override-method)
5367 (setq gnus-override-method (pop methods)))
5369 (when (eq gnus-override-method 'current)
5370 (setq gnus-override-method
5371 (with-current-buffer gnus-summary-buffer
5372 gnus-current-select-method)))
5374 (gnus-kill-all-overlays)
5375 (let ((gnus-newsgroup-name group))
5376 (gnus-check-group-server))
5378 ((gnus-request-article article group (current-buffer))
5379 (when (numberp article)
5380 (gnus-async-prefetch-next group article
5381 gnus-summary-buffer)
5382 (when gnus-keep-backlog
5383 (gnus-backlog-enter-article
5384 group article (current-buffer))))
5385 (setq result 'article))
5387 (setq gnus-override-method (pop methods)))
5388 ((not (string-match "^400 "
5389 (nnheader-get-report backend)))
5390 ;; If we get 400 server disconnect, reconnect and
5391 ;; retry; otherwise, assume the article has expired.
5392 (setq result 'done))))
5393 (and (eq result 'article) 'article)))
5397 ;; Associate this article with the current summary buffer.
5398 (setq gnus-article-current-summary gnus-summary-buffer)
5400 ;; Take the article from the original article buffer
5401 ;; and place it in the buffer it's supposed to be in.
5402 (when (and (get-buffer gnus-article-buffer)
5403 (equal (buffer-name (current-buffer))
5404 (buffer-name (get-buffer gnus-article-buffer))))
5406 (if (get-buffer gnus-original-article-buffer)
5407 (set-buffer gnus-original-article-buffer)
5408 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5409 (buffer-disable-undo)
5410 (setq major-mode 'gnus-original-article-mode)
5411 (setq buffer-read-only t))
5412 (let (buffer-read-only)
5414 (insert-buffer-substring gnus-article-buffer))
5415 (setq gnus-original-article (cons group article)))
5418 (run-hooks 'gnus-article-decode-hook)
5419 ;; Mark article as decoded or not.
5420 (setq gnus-article-decoded-p gnus-article-decode-hook))
5422 ;; Update sparse articles.
5423 (when (and do-update-line
5424 (or (numberp article)
5426 (let ((buf (current-buffer)))
5427 (set-buffer gnus-summary-buffer)
5428 (gnus-summary-update-article do-update-line sparse-header)
5429 (gnus-summary-goto-subject do-update-line nil t)
5430 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5432 (set-buffer buf))))))
5438 (defcustom gnus-article-edit-mode-hook nil
5439 "Hook run in article edit mode buffers."
5440 :group 'gnus-article-various
5443 (defvar gnus-article-edit-done-function nil)
5445 (defvar gnus-article-edit-mode-map nil)
5446 (defvar gnus-article-edit-mode nil)
5448 ;; Should we be using derived.el for this?
5449 (unless gnus-article-edit-mode-map
5450 (setq gnus-article-edit-mode-map (make-keymap))
5451 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5453 (gnus-define-keys gnus-article-edit-mode-map
5454 "\C-c?" describe-mode
5455 "\C-c\C-c" gnus-article-edit-done
5456 "\C-c\C-k" gnus-article-edit-exit
5457 "\C-c\C-f\C-t" message-goto-to
5458 "\C-c\C-f\C-o" message-goto-from
5459 "\C-c\C-f\C-b" message-goto-bcc
5460 ;;"\C-c\C-f\C-w" message-goto-fcc
5461 "\C-c\C-f\C-c" message-goto-cc
5462 "\C-c\C-f\C-s" message-goto-subject
5463 "\C-c\C-f\C-r" message-goto-reply-to
5464 "\C-c\C-f\C-n" message-goto-newsgroups
5465 "\C-c\C-f\C-d" message-goto-distribution
5466 "\C-c\C-f\C-f" message-goto-followup-to
5467 "\C-c\C-f\C-m" message-goto-mail-followup-to
5468 "\C-c\C-f\C-k" message-goto-keywords
5469 "\C-c\C-f\C-u" message-goto-summary
5470 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5471 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5472 "\C-c\C-b" message-goto-body
5473 "\C-c\C-i" message-goto-signature
5475 "\C-c\C-t" message-insert-to
5476 "\C-c\C-n" message-insert-newsgroups
5477 "\C-c\C-o" message-sort-headers
5478 "\C-c\C-e" message-elide-region
5479 "\C-c\C-v" message-delete-not-region
5480 "\C-c\C-z" message-kill-to-signature
5481 "\M-\r" message-newline-and-reformat
5482 "\C-c\C-a" mml-attach-file
5483 "\C-a" message-beginning-of-line
5485 "\M-;" comment-region)
5487 (gnus-define-keys (gnus-article-edit-wash-map
5488 "\C-c\C-w" gnus-article-edit-mode-map)
5489 "f" gnus-article-edit-full-stops))
5492 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5494 ["Fetch To" message-insert-to t]
5495 ["Fetch Newsgroups" message-insert-newsgroups t]
5497 ["To" message-goto-to t]
5498 ["From" message-goto-from t]
5499 ["Subject" message-goto-subject t]
5500 ["Cc" message-goto-cc t]
5501 ["Reply-To" message-goto-reply-to t]
5502 ["Summary" message-goto-summary t]
5503 ["Keywords" message-goto-keywords t]
5504 ["Newsgroups" message-goto-newsgroups t]
5505 ["Followup-To" message-goto-followup-to t]
5506 ["Mail-Followup-To" message-goto-mail-followup-to t]
5507 ["Distribution" message-goto-distribution t]
5508 ["Body" message-goto-body t]
5509 ["Signature" message-goto-signature t]))
5511 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5512 "Major mode for editing articles.
5513 This is an extended text-mode.
5515 \\{gnus-article-edit-mode-map}"
5516 (make-local-variable 'gnus-article-edit-done-function)
5517 (make-local-variable 'gnus-prev-winconf)
5518 (set (make-local-variable 'font-lock-defaults)
5519 '(message-font-lock-keywords t))
5520 (set (make-local-variable 'mail-header-separator) "")
5521 (set (make-local-variable 'gnus-article-edit-mode) t)
5522 (easy-menu-add message-mode-field-menu message-mode-map)
5524 (setq buffer-read-only nil)
5525 (buffer-enable-undo)
5528 (defun gnus-article-edit (&optional force)
5529 "Edit the current article.
5530 This will have permanent effect only in mail groups.
5531 If FORCE is non-nil, allow editing of articles even in read-only
5534 (when (and (not force)
5535 (gnus-group-read-only-p))
5536 (error "The current newsgroup does not support article editing"))
5537 (gnus-article-date-original)
5538 (gnus-article-edit-article
5540 `(lambda (no-highlight)
5542 (gnus-summary-edit-article-done
5543 ,(or (mail-header-references gnus-current-headers) "")
5544 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5546 (defun gnus-article-edit-article (start-func exit-func)
5547 "Start editing the contents of the current article buffer."
5548 (let ((winconf (current-window-configuration)))
5549 (set-buffer gnus-article-buffer)
5550 (gnus-article-edit-mode)
5551 (funcall start-func)
5552 (set-buffer-modified-p nil)
5553 (gnus-configure-windows 'edit-article)
5554 (setq gnus-article-edit-done-function exit-func)
5555 (setq gnus-prev-winconf winconf)
5556 (gnus-message 6 "C-c C-c to end edits")))
5558 (defun gnus-article-edit-done (&optional arg)
5559 "Update the article edits and exit."
5561 (let ((func gnus-article-edit-done-function)
5562 (buf (current-buffer))
5563 (start (window-start))
5565 (winconf gnus-prev-winconf))
5566 (widen) ;; Widen it in case that users narrowed the buffer.
5569 ;; The cache and backlog have to be flushed somewhat.
5570 (when gnus-keep-backlog
5571 (gnus-backlog-remove-article
5572 (car gnus-article-current) (cdr gnus-article-current)))
5573 ;; Flush original article as well.
5575 (when (get-buffer gnus-original-article-buffer)
5576 (set-buffer gnus-original-article-buffer)
5577 (setq gnus-original-article nil)))
5578 (when gnus-use-cache
5579 (gnus-cache-update-article
5580 (car gnus-article-current) (cdr gnus-article-current)))
5581 ;; We remove all text props from the article buffer.
5582 (kill-all-local-variables)
5583 (gnus-set-text-properties (point-min) (point-max) nil)
5585 (set-window-configuration winconf)
5587 (set-window-start (get-buffer-window buf) start)
5588 (set-window-point (get-buffer-window buf) (point))))
5590 (defun gnus-article-edit-exit ()
5591 "Exit the article editing without updating."
5593 (when (or (not (buffer-modified-p))
5594 (yes-or-no-p "Article modified; kill anyway? "))
5595 (let ((curbuf (current-buffer))
5597 (window-start (window-start)))
5599 (if (gnus-buffer-live-p gnus-original-article-buffer)
5600 (insert-buffer gnus-original-article-buffer))
5601 (let ((winconf gnus-prev-winconf))
5602 (kill-all-local-variables)
5604 (set-window-configuration winconf)
5605 ;; Tippy-toe some to make sure that point remains where it was.
5606 (save-current-buffer
5608 (set-window-start (get-buffer-window (current-buffer)) window-start)
5611 (defun gnus-article-edit-full-stops ()
5612 "Interactively repair spacing at end of sentences."
5615 (goto-char (point-min))
5616 (search-forward-regexp "^$" nil t)
5617 (let ((case-fold-search nil))
5618 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5621 ;;; Article highlights
5624 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5626 ;;; Internal Variables:
5628 (defcustom gnus-button-url-regexp
5629 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5630 "\\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:]]\\)"
5631 "\\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\\)\\)")
5632 "Regular expression that matches URLs."
5633 :group 'gnus-article-buttons
5636 (defcustom gnus-button-valid-fqdn-regexp
5637 message-valid-fqdn-regexp
5638 "Regular expression that matches a valid FQDN."
5639 :group 'gnus-article-buttons
5642 (defcustom gnus-button-man-handler 'manual-entry
5643 "Function to use for displaying man pages.
5644 The function must take at least one argument with a string naming the
5646 :type '(choice (function-item :tag "Man" manual-entry)
5647 (function-item :tag "Woman" woman)
5648 (function :tag "Other"))
5649 :group 'gnus-article-buttons)
5651 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5652 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5653 If the default site is too slow, try to find a CTAN mirror, see
5654 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5655 the variable `gnus-button-handle-ctan'."
5656 :group 'gnus-article-buttons
5657 :link '(custom-manual "(gnus)Group Parameters")
5658 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5659 (const "http://tug.ctan.org/tex-archive/")
5660 (const "http://www.dante.de/CTAN/")
5661 (string :tag "Other")))
5663 (defcustom gnus-button-ctan-handler 'browse-url
5664 "Function to use for displaying CTAN links.
5665 The function must take one argument, the string naming the URL."
5666 :type '(choice (function-item :tag "Browse Url" browse-url)
5667 (function :tag "Other"))
5668 :group 'gnus-article-buttons)
5670 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5671 "Bogus strings removed from CTAN URLs."
5672 :group 'gnus-article-buttons
5673 :type '(choice (const "^/?tex-archive/\\|/")
5674 (regexp :tag "Other")))
5676 (defcustom gnus-button-ctan-directory-regexp
5678 "\\("; Cannot use `\(?: ... \)' (compatibility with Emacs 20).
5679 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5680 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5681 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5683 "Regular expression for ctan directories.
5684 It should match all directories in the top level of `gnus-ctan-url'."
5685 :group 'gnus-article-buttons
5688 (defcustom gnus-button-mid-or-mail-regexp
5689 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
5690 gnus-button-valid-fqdn-regexp
5692 "Regular expression that matches a message ID or a mail address."
5693 :group 'gnus-article-buttons
5696 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5697 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5698 Strings like this can be either a message ID or a mail address. If it is one
5699 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5700 message ID or a mail address, respectively. If this variable is set to the
5701 symbol `ask', always query the user what do do. If it is a function, this
5702 function will be called with the string as it's only argument. The function
5703 must return `mid', `mail', `invalid' or `ask'."
5704 :group 'gnus-article-buttons
5705 :type '(choice (function-item :tag "Heuristic function"
5706 gnus-button-mid-or-mail-heuristic)
5711 (defcustom gnus-button-mid-or-mail-heuristic-alist
5712 '((-10.0 . ".+\\$.+@")
5715 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5716 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5717 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5718 (-1.0 . "^[^a-z]+@")
5720 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5721 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5722 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5723 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5726 (-1.0 . "^[0-9][0-9]")
5728 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5729 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5730 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5731 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5733 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5734 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5737 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5739 ;; compensation for TDMA dated mail addresses:
5740 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5742 (-20.0 . "\\.fsf@") ;; Gnus
5745 (-20.0 . "_-_") ;; Subject change in thread
5747 (-20.0 . "\\.ln@") ;; leafnode
5748 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5749 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5751 ;; (5.0 . "") ;; $local_part_len <= 7
5752 (10.0 . "^[^0-9]+@")
5753 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5754 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5757 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5759 (0.5 . "^[A-Z][a-z]")
5760 (0.5 . "^[A-Z][a-z][a-z]")
5761 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5762 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5763 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5765 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5766 address. The REGEXP is processed with `case-fold-search' set to nil."
5767 :group 'gnus-article-buttons
5768 :type '(repeat (cons (number :tag "Rate")
5769 (regexp :tag "Regexp"))))
5771 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5772 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5773 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5774 address, `ask' if unsure and `invalid' if the string is invalid."
5775 (let ((case-fold-search nil)
5776 (list gnus-button-mid-or-mail-heuristic-alist)
5777 (result 0) rate regexp lpartlen elem)
5779 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5780 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5781 ;; Certain special cases...
5784 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$" "\\|"
5785 "^[0-9]+\.[0-9]+\@compuserve")
5787 (gnus-message 8 "`%s' is a known mail address.")
5788 (setq result 'mail))
5789 (when (string-match "@.*@\\| " mid-or-mail)
5790 (gnus-message 8 "`%s' is invalid.")
5791 (setq result 'invalid))
5792 ;; Nothing more to do, if result is not a number here...
5793 (when (numberp result)
5795 (setq elem (car list)
5799 (when (string-match regexp mid-or-mail)
5800 (setq result (+ result rate))
5802 9 "`%s' matched `%s', rate `%s', result `%s'."
5803 mid-or-mail regexp rate result)))
5804 (when (<= lpartlen 7)
5805 (setq result (+ result 5.0))
5806 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
5807 mid-or-mail result))
5808 (when (>= lpartlen 12)
5809 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
5811 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
5812 ;; Long local part should contain realname if e-mail address,
5813 ;; too many digits: message-id.
5814 ;; $score -= 5.0 + 0.1 * $local_part_len;
5815 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
5816 (setq result (+ result rate))
5818 9 "Many digits in `%s', rate `%s', result `%s'."
5819 mid-or-mail rate result))
5820 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
5822 ;; Too few vowels [^aeiouy]{4,}.*\@
5823 (setq result (+ result -5.0))
5825 9 "Few vowels in `%s', rate `%s', result `%s'."
5826 mid-or-mail -5.0 result))
5828 (setq result (+ result 5.0))
5830 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
5831 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
5833 ;; Maybe we should make this a customizable alist: (condition . 'result)
5834 ((< result -10.0) 'mid)
5835 ((> result 10.0) 'mail)
5838 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5839 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
5840 (url-mid (concat "news" ":" mid-or-mail))
5841 (url-mailto (concat "mailto" ":" mid-or-mail)))
5842 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5843 (when (fboundp pref)
5845 ;; get rid of surrounding angles...
5847 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
5848 (if (or (eq 'mid guessed) (eq 'mail guessed))
5852 (save-window-excursion
5853 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5856 (cond ((eq pref 'mid)
5857 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
5858 (gnus-button-handle-news url-mid))
5860 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
5861 (gnus-url-mailto url-mailto))
5862 (t (gnus-message 3 "Invalid string.")))))
5864 (defun gnus-button-handle-custom (url)
5865 "Follow a Custom URL."
5866 (customize-apropos (gnus-url-unhex-string url)))
5868 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5870 ;; FIXME: Maybe we should merge some of the functions that do quite similar
5873 (defun gnus-button-handle-describe-function (url)
5874 "Call `describe-function' when pushing the corresponding URL button."
5877 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5879 (defun gnus-button-handle-describe-variable (url)
5880 "Call `describe-variable' when pushing the corresponding URL button."
5883 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5885 (defun gnus-button-handle-symbol (url)
5886 "Display help on variable or function.
5887 Calls `describe-variable' or `describe-function'."
5888 (let ((sym (intern url)))
5890 ((fboundp sym) (describe-function sym))
5891 ((boundp sym) (describe-variable sym))
5892 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
5894 (defun gnus-button-handle-describe-key (url)
5895 "Call `describe-key' when pushing the corresponding URL button."
5897 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5898 (keys (ignore-errors (eval `(kbd ,key-string)))))
5901 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5903 (defun gnus-button-handle-apropos (url)
5904 "Call `apropos' when pushing the corresponding URL button."
5905 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5907 (defun gnus-button-handle-apropos-command (url)
5908 "Call `apropos' when pushing the corresponding URL button."
5910 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5912 (defun gnus-button-handle-apropos-variable (url)
5913 "Call `apropos' when pushing the corresponding URL button."
5915 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5916 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5918 (defun gnus-button-handle-apropos-documentation (url)
5919 "Call `apropos' when pushing the corresponding URL button."
5921 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
5922 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5924 (defun gnus-button-handle-library (url)
5925 "Call `locate-library' when pushing the corresponding URL button."
5926 (gnus-message 9 "url=`%s'" url)
5927 (let* ((lib (locate-library url))
5928 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
5930 (gnus-message 1 "Cannot locale library `%s'." url)
5931 (find-file-read-only file))))
5933 (defun gnus-button-handle-ctan (url)
5934 "Call `browse-url' when pushing a CTAN URL button."
5936 gnus-button-ctan-handler
5939 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
5941 (defcustom gnus-button-tex-level 5
5942 "*Integer that says how many TeX-related buttons Gnus will show.
5943 The higher the number, the more buttons will appear and the more false
5944 positives are possible. Note that you can set this variable local to
5945 specifific groups. Setting it higher in TeX groups is probably a good idea.
5946 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5947 how to set variables in specific groups."
5948 :group 'gnus-article-buttons
5949 :link '(custom-manual "(gnus)Group Parameters")
5952 (defcustom gnus-button-man-level 5
5953 "*Integer that says how many man-related buttons Gnus will show.
5954 The higher the number, the more buttons will appear and the more false
5955 positives are possible. Note that you can set this variable local to
5956 specifific groups. Setting it higher in Unix groups is probably a good idea.
5957 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5958 how to set variables in specific groups."
5959 :group 'gnus-article-buttons
5960 :link '(custom-manual "(gnus)Group Parameters")
5963 (defcustom gnus-button-emacs-level 5
5964 "*Integer that says how many emacs-related buttons Gnus will show.
5965 The higher the number, the more buttons will appear and the more false
5966 positives are possible. Note that you can set this variable local to
5967 specifific groups. Setting it higher in Emacs or Gnus related groups is
5968 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
5969 `gnus-parameters' on how to set variables in specific groups."
5970 :group 'gnus-article-buttons
5971 :link '(custom-manual "(gnus)Group Parameters")
5974 (defcustom gnus-button-message-level 5
5975 "*Integer that says how many buttons for news or mail messages will appear.
5976 The higher the number, the more buttons will appear and the more false
5977 positives are possible."
5978 ;; mail addresses, MIDs, URLs for news, ...
5979 :group 'gnus-article-buttons
5982 (defcustom gnus-button-browse-level 5
5983 "*Integer that says how many buttons for browsing will appear.
5984 The higher the number, the more buttons will appear and the more false
5985 positives are possible."
5986 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
5987 :group 'gnus-article-buttons
5990 (defcustom gnus-button-alist
5991 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5992 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
5993 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5994 gnus-button-handle-news 2)
5995 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5996 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
5997 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
5998 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
5999 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6000 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6001 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6002 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6003 ("mailto:\\([-a-z.@_+0-9%=?]+\\)"
6004 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6005 ("\\bmailto:\\([^ \n\t]+\\)"
6006 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6008 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6009 gnus-button-ctan-directory-regexp
6010 "[^][>)!;:,'\n\t ]+\\)")
6011 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6012 ((concat "\\btex-archive/\\("
6013 gnus-button-ctan-directory-regexp
6014 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6015 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6018 gnus-button-ctan-directory-regexp
6019 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6020 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6022 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)"
6023 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6024 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6025 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6026 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6027 ;; Info links like `C-h i d m CC Mode RET'
6028 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6030 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6031 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6032 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6033 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6034 ;; Emacs help commands
6035 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6036 ;; regexp doesn't match arguments containing ` '.
6037 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6038 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6039 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6040 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6041 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6042 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6043 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6044 ;; The following entries may lead to many false positives so don't enable
6045 ;; them by default (use a high button level):
6046 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6047 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6048 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6049 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6050 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6051 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6052 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6053 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6054 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6055 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6056 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6057 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6058 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6059 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6060 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6061 ;; Unlike the other regexps we really have to require quoting
6062 ;; here to determine where it ends.
6063 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6064 ;; This is how URLs _should_ be embedded in text (RFC 1738)...
6065 ("<URL: *\\([^<>]*\\)>"
6066 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6068 (gnus-button-url-regexp
6069 0 (>= gnus-button-browse-level 0) browse-url 0)
6071 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6072 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6073 gnus-button-handle-man 1)
6074 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6075 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6076 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6077 gnus-button-handle-man 1)
6078 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6079 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6080 ("\\b\\([a-z][-_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6081 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6082 ;; MID or mail: To avoid too many false positives we don't try to catch
6083 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6084 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6085 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6086 ;; so that non-ambiguous entries (see above) match first.
6087 (gnus-button-mid-or-mail-regexp
6088 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6089 "*Alist of regexps matching buttons in article bodies.
6091 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6092 REGEXP: is the string (case insensitive) matching text around the button (can
6093 also be lisp expression evaluating to a string),
6094 BUTTON: is the number of the regexp grouping actually matching the button,
6095 FORM: is a lisp expression which must eval to true for the button to
6097 CALLBACK: is the function to call when the user push this button, and each
6098 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6100 CALLBACK can also be a variable, in that case the value of that
6101 variable it the real callback function."
6102 :group 'gnus-article-buttons
6103 :type '(repeat (list (choice regexp variable)
6104 (integer :tag "Button")
6106 (function :tag "Callback")
6109 (integer :tag "Regexp group")))))
6111 (defcustom gnus-header-button-alist
6112 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
6113 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6114 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6115 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6116 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6117 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6118 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6119 0 (>= gnus-button-browse-level 0) browse-url 0)
6120 ("^Subject:" gnus-button-url-regexp
6121 0 (>= gnus-button-browse-level 0) browse-url 0)
6122 ("^[^:]+:" gnus-button-url-regexp
6123 0 (>= gnus-button-browse-level 0) browse-url 0)
6124 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)"
6125 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6126 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6127 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6128 "*Alist of headers and regexps to match buttons in article heads.
6130 This alist is very similar to `gnus-button-alist', except that each
6131 alist has an additional HEADER element first in each entry:
6133 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6135 HEADER is a regexp to match a header. For a fuller explanation, see
6136 `gnus-button-alist'."
6137 :group 'gnus-article-buttons
6138 :group 'gnus-article-headers
6139 :type '(repeat (list (regexp :tag "Header")
6141 (integer :tag "Button")
6143 (function :tag "Callback")
6146 (integer :tag "Regexp group")))))
6148 (defvar gnus-button-regexp nil)
6149 (defvar gnus-button-marker-list nil)
6150 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6152 (defvar gnus-button-last nil)
6153 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6157 (defun gnus-article-push-button (event)
6158 "Check text under the mouse pointer for a callback function.
6159 If the text under the mouse pointer has a `gnus-callback' property,
6160 call it with the value of the `gnus-data' text property."
6162 (set-buffer (window-buffer (posn-window (event-start event))))
6163 (let* ((pos (posn-point (event-start event)))
6164 (data (get-text-property pos 'gnus-data))
6165 (fun (get-text-property pos 'gnus-callback)))
6168 (funcall fun data))))
6170 (defun gnus-article-press-button ()
6171 "Check text at point for a callback function.
6172 If the text at point has a `gnus-callback' property,
6173 call it with the value of the `gnus-data' text property."
6175 (let ((data (get-text-property (point) 'gnus-data))
6176 (fun (get-text-property (point) 'gnus-callback)))
6178 (funcall fun data))))
6180 (defun gnus-article-highlight (&optional force)
6181 "Highlight current article.
6182 This function calls `gnus-article-highlight-headers',
6183 `gnus-article-highlight-citation',
6184 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6185 do the highlighting. See the documentation for those functions."
6186 (interactive (list 'force))
6187 (gnus-article-highlight-headers)
6188 (gnus-article-highlight-citation force)
6189 (gnus-article-highlight-signature)
6190 (gnus-article-add-buttons force)
6191 (gnus-article-add-buttons-to-head))
6193 (defun gnus-article-highlight-some (&optional force)
6194 "Highlight current article.
6195 This function calls `gnus-article-highlight-headers',
6196 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6197 do the highlighting. See the documentation for those functions."
6198 (interactive (list 'force))
6199 (gnus-article-highlight-headers)
6200 (gnus-article-highlight-signature)
6201 (gnus-article-add-buttons))
6203 (defun gnus-article-highlight-headers ()
6204 "Highlight article headers as specified by `gnus-header-face-alist'."
6207 (set-buffer gnus-article-buffer)
6209 (let ((alist gnus-header-face-alist)
6210 (buffer-read-only nil)
6211 (case-fold-search t)
6212 (inhibit-point-motion-hooks t)
6213 entry regexp header-face field-face from hpoints fpoints)
6214 (article-narrow-to-head)
6215 (while (setq entry (pop alist))
6216 (goto-char (point-min))
6217 (setq regexp (concat "^\\("
6218 (if (string-equal "" (nth 0 entry))
6222 header-face (nth 1 entry)
6223 field-face (nth 2 entry))
6224 (while (and (re-search-forward regexp nil t)
6228 (unless (search-forward ":" nil t)
6230 (when (and header-face
6231 (not (memq (point) hpoints)))
6232 (push (point) hpoints)
6233 (gnus-put-text-property from (point) 'face header-face))
6234 (when (and field-face
6235 (not (memq (setq from (point)) fpoints)))
6237 (if (re-search-forward "^[^ \t]" nil t)
6239 (goto-char (point-max)))
6240 (gnus-put-text-property from (point) 'face field-face))))))))
6242 (defun gnus-article-highlight-signature ()
6243 "Highlight the signature in an article.
6244 It does this by highlighting everything after
6245 `gnus-signature-separator' using `gnus-signature-face'."
6248 (set-buffer gnus-article-buffer)
6249 (let ((buffer-read-only nil)
6250 (inhibit-point-motion-hooks t))
6252 (when (and gnus-signature-face
6253 (gnus-article-narrow-to-signature))
6254 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6255 'face gnus-signature-face)
6257 (gnus-article-search-signature)
6258 (let ((start (match-beginning 0))
6259 (end (set-marker (make-marker) (1+ (match-end 0)))))
6260 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6263 (defun gnus-button-in-region-p (b e prop)
6264 "Say whether PROP exists in the region."
6265 (text-property-not-all b e prop nil))
6267 (defun gnus-article-add-buttons (&optional force)
6268 "Find external references in the article and make buttons of them.
6269 \"External references\" are things like Message-IDs and URLs, as
6270 specified by `gnus-button-alist'."
6271 (interactive (list 'force))
6273 (set-buffer gnus-article-buffer)
6274 (let ((buffer-read-only nil)
6275 (inhibit-point-motion-hooks t)
6276 (case-fold-search t)
6277 (alist gnus-button-alist)
6279 ;; Remove all old markers.
6280 (let (marker entry new-list)
6281 (while (setq marker (pop gnus-button-marker-list))
6282 (if (or (< marker (point-min)) (>= marker (point-max)))
6283 (push marker new-list)
6285 (when (setq entry (gnus-button-entry))
6286 (put-text-property (match-beginning (nth 1 entry))
6287 (match-end (nth 1 entry))
6288 'gnus-callback nil))
6289 (set-marker marker nil)))
6290 (setq gnus-button-marker-list new-list))
6291 ;; We skip the headers.
6294 (while (setq entry (pop alist))
6295 (setq regexp (eval (car entry)))
6297 (while (re-search-forward regexp nil t)
6298 (let* ((start (and entry (match-beginning (nth 1 entry))))
6299 (end (and entry (match-end (nth 1 entry))))
6300 (from (match-beginning 0)))
6301 (when (and (or (eq t (nth 2 entry))
6302 (eval (nth 2 entry)))
6303 (not (gnus-button-in-region-p
6304 start end 'gnus-callback)))
6305 ;; That optional form returned non-nil, so we add the
6307 (gnus-article-add-button
6308 start end 'gnus-button-push
6309 (car (push (set-marker (make-marker) from)
6310 gnus-button-marker-list))))))))))
6312 ;; Add buttons to the head of an article.
6313 (defun gnus-article-add-buttons-to-head ()
6314 "Add buttons to the head of the article."
6317 (set-buffer gnus-article-buffer)
6319 (let ((buffer-read-only nil)
6320 (inhibit-point-motion-hooks t)
6321 (case-fold-search t)
6322 (alist gnus-header-button-alist)
6324 (article-narrow-to-head)
6326 ;; Each alist entry.
6327 (setq entry (car alist)
6329 (goto-char (point-min))
6330 (while (re-search-forward (car entry) nil t)
6331 ;; Each header matching the entry.
6332 (setq beg (match-beginning 0))
6333 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6334 (match-beginning 0))
6337 (while (re-search-forward (eval (nth 1 entry)) end t)
6338 ;; Each match within a header.
6339 (let* ((entry (cdr entry))
6340 (start (match-beginning (nth 1 entry)))
6341 (end (match-end (nth 1 entry)))
6342 (form (nth 2 entry)))
6343 (goto-char (match-end 0))
6345 (gnus-article-add-button
6346 start end (nth 3 entry)
6347 (buffer-substring (match-beginning (nth 4 entry))
6348 (match-end (nth 4 entry)))))))
6349 (goto-char end)))))))
6351 ;;; External functions:
6353 (defun gnus-article-add-button (from to fun &optional data)
6354 "Create a button between FROM and TO with callback FUN and data DATA."
6355 (when gnus-article-button-face
6356 (gnus-overlay-put (gnus-make-overlay from to)
6357 'face gnus-article-button-face))
6358 (gnus-add-text-properties
6360 (nconc (and gnus-article-mouse-face
6361 (list gnus-mouse-face-prop gnus-article-mouse-face))
6362 (list 'gnus-callback fun)
6363 (and data (list 'gnus-data data))))
6364 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6365 :button-keymap gnus-widget-button-keymap))
6367 ;;; Internal functions:
6369 (defun gnus-article-set-globals ()
6371 (set-buffer gnus-summary-buffer)
6372 (gnus-set-global-variables)))
6374 (defun gnus-signature-toggle (end)
6376 (set-buffer gnus-article-buffer)
6377 (let ((buffer-read-only nil)
6378 (inhibit-point-motion-hooks t))
6379 (if (text-property-any end (point-max) 'article-type 'signature)
6381 (gnus-delete-wash-type 'signature)
6382 (gnus-remove-text-properties-when
6383 'article-type 'signature end (point-max)
6384 (cons 'article-type (cons 'signature
6385 gnus-hidden-properties))))
6386 (gnus-add-wash-type 'signature)
6387 (gnus-add-text-properties-when
6388 'article-type nil end (point-max)
6389 (cons 'article-type (cons 'signature
6390 gnus-hidden-properties)))))
6391 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6392 (gnus-set-mode-line 'article))))
6394 (defun gnus-button-entry ()
6395 ;; Return the first entry in `gnus-button-alist' matching this place.
6396 (let ((alist gnus-button-alist)
6399 (setq entry (pop alist))
6400 (if (looking-at (eval (car entry)))
6405 (defun gnus-button-push (marker)
6406 ;; Push button starting at MARKER.
6409 (let* ((entry (gnus-button-entry))
6410 (inhibit-point-motion-hooks t)
6412 (args (mapcar (lambda (group)
6413 (let ((string (match-string group)))
6414 (gnus-set-text-properties
6415 0 (length string) nil string)
6422 (fboundp (symbol-value fun)))
6423 (apply (symbol-value fun) args))
6425 (gnus-message 1 "You must define `%S' to use this button"
6426 (cons fun args)))))))
6428 (defun gnus-parse-news-url (url)
6429 (let (scheme server group message-id articles)
6432 (goto-char (point-min))
6433 (when (looking-at "\\([A-Za-z]+\\):")
6434 (setq scheme (match-string 1))
6435 (goto-char (match-end 0)))
6436 (when (looking-at "//\\([^/]+\\)/")
6437 (setq server (match-string 1))
6438 (goto-char (match-end 0)))
6441 ((looking-at "\\(.*@.*\\)")
6442 (setq message-id (match-string 1)))
6443 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6444 (setq group (match-string 1)
6445 articles (split-string (match-string 2) "-")))
6446 ((looking-at "\\([^/]+\\)/?")
6447 (setq group (match-string 1)))
6449 (error "Unknown news URL syntax"))))
6450 (list scheme server group message-id articles)))
6452 (defun gnus-button-handle-news (url)
6454 (destructuring-bind (scheme server group message-id articles)
6455 (gnus-parse-news-url url)
6459 (set-buffer gnus-summary-buffer)
6461 (let ((gnus-refer-article-method (list (list 'nntp server))))
6462 (gnus-summary-refer-article message-id))
6463 (gnus-summary-refer-article message-id))))
6465 (gnus-button-fetch-group url)))))
6467 (defun gnus-button-handle-man (url)
6469 (funcall gnus-button-man-handler url))
6471 (defun gnus-button-handle-info-url (url)
6472 "Fetch an info URL."
6474 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6475 (gnus-info-find-node
6476 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6478 ")" (gnus-url-unhex-string (match-string 2 url)))))
6479 ((string-match "([^)\"]+)[^\"]+" url)
6481 (gnus-replace-in-string
6482 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6483 (gnus-info-find-node url))
6484 (t (error "Can't parse %s" url))))
6486 (defun gnus-button-handle-info-keystrokes (url)
6487 "Call `info' when pushing the corresponding URL button."
6488 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6493 (defun gnus-button-message-id (message-id)
6496 (set-buffer gnus-summary-buffer)
6497 (gnus-summary-refer-article message-id)))
6499 (defun gnus-button-fetch-group (address)
6500 "Fetch GROUP specified by ADDRESS."
6501 (if (not (string-match "[:/]" address))
6502 ;; This is just a simple group url.
6503 (gnus-group-read-ephemeral-group address gnus-select-method)
6506 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6508 (error "Can't parse %s" address)
6509 (gnus-group-read-ephemeral-group
6510 (match-string 4 address)
6511 `(nntp ,(match-string 1 address)
6512 (nntp-address ,(match-string 1 address))
6513 (nntp-port-number ,(if (match-end 3)
6514 (match-string 3 address)
6517 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6519 (defun gnus-url-parse-query-string (query &optional downcase)
6520 (let (retval pairs cur key val)
6521 (setq pairs (split-string query "&"))
6523 (setq cur (car pairs)
6525 (if (not (string-match "=" cur))
6527 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6528 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6530 (setq key (downcase key)))
6531 (setq cur (assoc key retval))
6533 (setcdr cur (cons val (cdr cur)))
6534 (setq retval (cons (list key val) retval)))))
6537 (defun gnus-url-mailto (url)
6538 ;; Send mail to someone
6539 (when (string-match "mailto:/*\\(.*\\)" url)
6540 (setq url (substring url (match-beginning 1) nil)))
6541 (let (to args subject func)
6542 (if (string-match (regexp-quote "?") url)
6543 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6544 args (gnus-url-parse-query-string
6545 (substring url (match-end 0) nil) t))
6546 (setq to (gnus-url-unhex-string url)))
6547 (setq args (cons (list "to" to) args)
6548 subject (cdr-safe (assoc "subject" args)))
6551 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6554 (message-position-on-field (caar args)))
6555 (insert (mapconcat 'identity (cdar args) ", "))
6556 (setq args (cdr args)))
6559 (message-goto-subject))))
6561 (defun gnus-button-embedded-url (address)
6562 "Activate ADDRESS with `browse-url'."
6563 (browse-url (gnus-strip-whitespace address)))
6565 ;;; Next/prev buttons in the article buffer.
6567 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6568 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6570 (defvar gnus-prev-page-map
6571 (let ((map (make-sparse-keymap)))
6572 (unless (>= emacs-major-version 21)
6573 ;; XEmacs doesn't care.
6574 (set-keymap-parent map gnus-article-mode-map))
6575 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6576 (define-key map "\r" 'gnus-button-prev-page)
6579 (defun gnus-insert-prev-page-button ()
6581 (buffer-read-only nil))
6583 gnus-prev-page-line-format nil
6584 `(,@(gnus-local-map-property gnus-prev-page-map)
6586 gnus-callback gnus-article-button-prev-page
6587 article-type annotation))
6588 (widget-convert-button
6590 ;; Exclude a newline.
6593 :action 'gnus-button-prev-page
6594 :button-keymap gnus-prev-page-map)))
6596 (defvar gnus-prev-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-prev-page)
6602 (define-key map "\r" 'gnus-button-prev-page)
6605 (defvar gnus-next-page-map
6606 (let ((map (make-sparse-keymap)))
6607 (unless (>= emacs-major-version 21)
6608 ;; XEmacs doesn't care.
6609 (set-keymap-parent map gnus-article-mode-map))
6610 (define-key map gnus-mouse-2 'gnus-button-next-page)
6611 (define-key map "\r" 'gnus-button-next-page)
6614 (defun gnus-button-next-page (&optional args more-args)
6615 "Go to the next page."
6617 (let ((win (selected-window)))
6618 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6619 (gnus-article-next-page)
6620 (select-window win)))
6622 (defun gnus-button-prev-page (&optional args more-args)
6623 "Go to the prev page."
6625 (let ((win (selected-window)))
6626 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6627 (gnus-article-prev-page)
6628 (select-window win)))
6630 (defun gnus-insert-next-page-button ()
6632 (buffer-read-only nil))
6633 (gnus-eval-format gnus-next-page-line-format nil
6634 `(,@(gnus-local-map-property gnus-next-page-map)
6636 gnus-callback gnus-article-button-next-page
6637 article-type annotation))
6638 (widget-convert-button
6640 ;; Exclude a newline.
6643 :action 'gnus-button-next-page
6644 :button-keymap gnus-next-page-map)))
6646 (defun gnus-article-button-next-page (arg)
6647 "Go to the next page."
6649 (let ((win (selected-window)))
6650 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6651 (gnus-article-next-page)
6652 (select-window win)))
6654 (defun gnus-article-button-prev-page (arg)
6655 "Go to the prev page."
6657 (let ((win (selected-window)))
6658 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6659 (gnus-article-prev-page)
6660 (select-window win)))
6662 (defvar gnus-decode-header-methods
6663 '(mail-decode-encoded-word-region)
6664 "List of methods used to decode headers.
6666 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6667 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6668 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6669 whose names match REGEXP.
6672 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6673 mail-decode-encoded-word-region
6674 (\"chinese\" . rfc1843-decode-region))
6677 (defvar gnus-decode-header-methods-cache nil)
6679 (defun gnus-multi-decode-header (start end)
6680 "Apply the functions from `gnus-encoded-word-methods' that match."
6681 (unless (and gnus-decode-header-methods-cache
6682 (eq gnus-newsgroup-name
6683 (car gnus-decode-header-methods-cache)))
6684 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6687 (nconc gnus-decode-header-methods-cache (list x))
6688 (if (and gnus-newsgroup-name
6689 (string-match (car x) gnus-newsgroup-name))
6690 (nconc gnus-decode-header-methods-cache
6692 gnus-decode-header-methods))
6693 (let ((xlist gnus-decode-header-methods-cache))
6696 (narrow-to-region start end)
6698 (funcall (pop xlist) (point-min) (point-max))))))
6701 ;;; Treatment top-level handling.
6704 (defun gnus-treat-article (condition &optional part-number total-parts type)
6705 (let ((length (- (point-max) (point-min)))
6706 (alist gnus-treatment-function-alist)
6707 (article-goto-body-goes-to-point-min-p t)
6711 (let ((list gnus-article-treat-types))
6713 (when (string-match (pop list) type)
6714 (throw 'found t)))))))
6715 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6717 (gnus-run-hooks 'gnus-part-display-hook)
6718 (dolist (elem alist)
6721 (when (gnus-buffer-live-p gnus-summary-buffer)
6722 (set-buffer gnus-summary-buffer))
6723 (symbol-value (car elem))))
6724 (when (and (or (consp val)
6726 (gnus-treat-predicate val)
6727 (or (not (get (car elem) 'highlight))
6730 (funcall (cadr elem)))))))
6732 ;; Dynamic variables.
6734 (defvar part-number)
6735 (defvar total-parts)
6740 (defun gnus-treat-predicate (val)
6747 (stringp (car val)))
6748 (apply 'gnus-or (mapcar `(lambda (s)
6749 (string-match s ,(or gnus-newsgroup-name "")))
6752 (let ((pred (pop val)))
6755 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6757 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6759 (not (gnus-treat-predicate (car val))))
6761 (equal (car val) type))
6763 (error "%S is not a valid predicate" pred)))))
6769 (eq part-number total-parts))
6773 (error "%S is not a valid value" val))))
6775 (defun gnus-article-encrypt-body (protocol &optional n)
6776 "Encrypt the article body."
6779 (or gnus-article-encrypt-protocol
6780 (completing-read "Encrypt protocol: "
6781 gnus-article-encrypt-protocol-alist
6783 current-prefix-arg))
6784 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6786 (error (format "Can't find the encrypt protocol %s" protocol)))
6787 (if (member gnus-newsgroup-name '("nndraft:delayed"
6790 (error "Can't encrypt the article in group %s"
6791 gnus-newsgroup-name))
6792 (gnus-summary-iterate n
6794 (set-buffer gnus-summary-buffer)
6795 (let ((mail-parse-charset gnus-newsgroup-charset)
6796 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6797 (summary-buffer gnus-summary-buffer)
6799 (gnus-set-global-variables)
6800 (when (gnus-group-read-only-p)
6801 (error "The current newsgroup does not support article encrypt"))
6802 (gnus-summary-show-article t)
6804 (or (mail-header-references gnus-current-headers) ""))
6805 (set-buffer gnus-article-buffer)
6806 (let* ((buffer-read-only nil)
6808 (mapcar (lambda (field)
6809 (and (save-restriction
6810 (message-narrow-to-head)
6811 (goto-char (point-min))
6812 (search-forward field nil t))
6814 (message-narrow-to-field)
6816 (delete-region (point-min) (point-max))
6818 '("Content-Type:" "Content-Transfer-Encoding:"
6819 "Content-Disposition:"))))
6820 (message-narrow-to-head)
6821 (message-remove-header "MIME-Version")
6822 (goto-char (point-max))
6823 (setq point (point))
6824 (insert (apply 'concat headers))
6826 (narrow-to-region point (point-max))
6827 (let ((message-options message-options))
6828 (message-options-set 'message-sender user-mail-address)
6829 (message-options-set 'message-recipients user-mail-address)
6830 (message-options-set 'message-sign-encrypt 'not)
6832 (goto-char (point-min))
6833 (insert "MIME-Version: 1.0\n")
6835 (gnus-summary-edit-article-done
6836 references nil summary-buffer t))
6837 (when gnus-keep-backlog
6838 (gnus-backlog-remove-article
6839 (car gnus-article-current) (cdr gnus-article-current)))
6841 (when (get-buffer gnus-original-article-buffer)
6842 (set-buffer gnus-original-article-buffer)
6843 (setq gnus-original-article nil)))
6844 (when gnus-use-cache
6845 (gnus-cache-update-article
6846 (car gnus-article-current) (cdr gnus-article-current))))))))
6848 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6849 "The following specs can be used:
6850 %t The security MIME type
6853 %D Details if button is pressed")
6855 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6856 "The following specs can be used:
6857 %t The security MIME type
6860 %D Details if button is pressed")
6862 (defvar gnus-mime-security-button-line-format-alist
6863 '((?t gnus-tmp-type ?s)
6864 (?i gnus-tmp-info ?s)
6865 (?d gnus-tmp-details ?s)
6866 (?D gnus-tmp-pressed-details ?s)))
6868 (defvar gnus-mime-security-button-map
6869 (let ((map (make-sparse-keymap)))
6870 (unless (>= (string-to-number emacs-version) 21)
6871 (set-keymap-parent map gnus-article-mode-map))
6872 (define-key map gnus-mouse-2 'gnus-article-push-button)
6873 (define-key map "\r" 'gnus-article-press-button)
6876 (defvar gnus-mime-security-details-buffer nil)
6878 (defvar gnus-mime-security-button-pressed nil)
6880 (defvar gnus-mime-security-show-details-inline t
6881 "If non-nil, show details in the article buffer.")
6883 (defun gnus-mime-security-verify-or-decrypt (handle)
6884 (mm-remove-parts (cdr handle))
6885 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6886 point buffer-read-only)
6888 (goto-char (car region)))
6890 (narrow-to-region (point) (point))
6891 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6892 (let* ((mm-verify-option 'known)
6893 (mm-decrypt-option 'known)
6894 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6895 (unless (eq nparts (cdr handle))
6896 (mm-destroy-parts (cdr handle))
6897 (setcdr handle nparts))))
6898 (setq point (point))
6899 (gnus-mime-display-security handle)
6900 (goto-char (point-max)))
6902 (delete-region (point) (cdr region))
6903 (set-marker (car region) nil)
6904 (set-marker (cdr region) nil))
6907 (defun gnus-mime-security-show-details (handle)
6908 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6910 (gnus-message 5 "No details.")
6911 (if gnus-mime-security-show-details-inline
6912 (let ((gnus-mime-security-button-pressed
6913 (not (get-text-property (point) 'gnus-mime-details)))
6914 (gnus-mime-security-button-line-format
6915 (get-text-property (point) 'gnus-line-format))
6918 (while (eq (get-text-property (point) 'gnus-line-format)
6919 gnus-mime-security-button-line-format)
6923 (narrow-to-region (point) (point))
6924 (gnus-insert-mime-security-button handle))
6925 (delete-region (point)
6926 (or (text-property-not-all
6929 gnus-mime-security-button-line-format)
6932 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6933 (with-current-buffer gnus-mime-security-details-buffer
6936 (setq gnus-mime-security-details-buffer
6937 (gnus-get-buffer-create "*MIME Security Details*")))
6938 (with-current-buffer gnus-mime-security-details-buffer
6940 (goto-char (point-min)))
6941 (pop-to-buffer gnus-mime-security-details-buffer)))))
6943 (defun gnus-mime-security-press-button (handle)
6945 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6946 (gnus-mime-security-show-details handle)
6947 (gnus-mime-security-verify-or-decrypt handle))))
6949 (defun gnus-insert-mime-security-button (handle &optional displayed)
6950 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6953 (or (nth 2 (assoc protocol mm-verify-function-alist))
6954 (nth 2 (assoc protocol mm-decrypt-function-alist))
6956 (if (equal (car handle) "multipart/signed")
6957 " Signed" " Encrypted")
6960 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6963 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6964 gnus-tmp-pressed-details
6966 (setq gnus-tmp-details
6967 (if gnus-tmp-details
6968 (concat "\n" gnus-tmp-details)
6970 (setq gnus-tmp-pressed-details
6971 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6976 gnus-mime-security-button-line-format
6977 gnus-mime-security-button-line-format-alist
6978 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6979 gnus-callback gnus-mime-security-press-button
6980 gnus-line-format ,gnus-mime-security-button-line-format
6981 gnus-mime-details ,gnus-mime-security-button-pressed
6982 article-type annotation
6985 ;; Exclude a newline.
6988 (widget-convert-button
6991 :action 'gnus-widget-press-button
6992 :button-keymap gnus-mime-security-button-map
6994 (lambda (widget/window &optional overlay pos)
6995 ;; Needed to properly clear the message due to a bug in
6996 ;; wid-edit (XEmacs only).
6997 (when (boundp 'help-echo-owns-message)
6998 (setq help-echo-owns-message t))
7001 (aref gnus-mouse-2 0))))))
7003 (defun gnus-mime-display-security (handle)
7005 (narrow-to-region (point) (point))
7006 (unless (gnus-unbuttonized-mime-type-p (car handle))
7007 (gnus-insert-mime-security-button handle))
7008 (gnus-mime-display-mixed (cdr handle))
7011 (unless (gnus-unbuttonized-mime-type-p (car handle))
7012 (let ((gnus-mime-security-button-line-format
7013 gnus-mime-security-button-end-line-format))
7014 (gnus-insert-mime-security-button handle)))
7015 (mm-set-handle-multipart-parameter
7017 (cons (set-marker (make-marker) (point-min))
7018 (set-marker (make-marker) (point-max))))))
7024 (run-hooks 'gnus-art-load-hook)
7026 ;;; gnus-art.el ends here