1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
46 (autoload 'gnus-msg-mail "gnus-msg" nil t)
47 (autoload 'gnus-button-mailto "gnus-msg")
48 (autoload 'gnus-button-reply "gnus-msg" nil t)
50 (defgroup gnus-article nil
52 :link '(custom-manual "(gnus)The Article Buffer")
55 (defgroup gnus-article-treat nil
56 "Treating article parts."
57 :link '(custom-manual "(gnus)Article Hiding")
60 (defgroup gnus-article-hiding nil
61 "Hiding article parts."
62 :link '(custom-manual "(gnus)Article Hiding")
65 (defgroup gnus-article-highlight nil
66 "Article highlighting."
67 :link '(custom-manual "(gnus)Article Highlighting")
71 (defgroup gnus-article-signature nil
73 :link '(custom-manual "(gnus)Article Signature")
76 (defgroup gnus-article-headers nil
78 :link '(custom-manual "(gnus)Hiding Headers")
81 (defgroup gnus-article-washing nil
82 "Special commands on articles."
83 :link '(custom-manual "(gnus)Article Washing")
86 (defgroup gnus-article-emphasis nil
87 "Fontisizing articles."
88 :link '(custom-manual "(gnus)Article Fontisizing")
91 (defgroup gnus-article-saving nil
93 :link '(custom-manual "(gnus)Saving Articles")
96 (defgroup gnus-article-mime nil
97 "Worshiping the MIME wonder."
98 :link '(custom-manual "(gnus)Using MIME")
101 (defgroup gnus-article-buttons nil
102 "Pushable buttons in the article buffer."
103 :link '(custom-manual "(gnus)Article Buttons")
104 :group 'gnus-article)
106 (defgroup gnus-article-various nil
107 "Other article options."
108 :link '(custom-manual "(gnus)Misc Article")
109 :group 'gnus-article)
111 (defcustom gnus-ignored-headers
114 (concat "^" header ":"))
115 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
116 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
117 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
118 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
119 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
120 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
121 "X-Attribution" "X-Originating-IP" "Delivered-To"
122 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
123 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
124 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
125 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
126 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
127 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
128 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
129 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
130 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
131 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
132 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
133 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
134 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
135 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
136 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
137 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
138 "List-[A-Za-z]+" "X-Listprocessor-Version"
139 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
140 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
141 "X-Received" "Content-length" "X-precedence"
142 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
143 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
144 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
145 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
146 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
147 "X-Content-length" "X-Posting-Agent" "Original-Received"
148 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
149 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
150 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
151 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
152 "X-Abuse-and-DMCA-Info" "X-Postfilter"))
153 "*All headers that start with this regexp will be hidden.
154 This variable can also be a list of regexps of headers to be ignored.
155 If `gnus-visible-headers' is non-nil, this variable will be ignored."
156 :type '(choice :custom-show nil
159 :group 'gnus-article-hiding)
161 (defcustom gnus-visible-headers
162 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
163 "*All headers that do not match this regexp will be hidden.
164 This variable can also be a list of regexp of headers to remain visible.
165 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
166 :type '(repeat :value-to-internal (lambda (widget value)
167 (custom-split-regexp-maybe value))
168 :match (lambda (widget value)
170 (widget-editable-list-match widget value)))
172 :group 'gnus-article-hiding)
174 (defcustom gnus-sorted-header-list
175 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
176 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
177 "*This variable is a list of regular expressions.
178 If it is non-nil, headers that match the regular expressions will
179 be placed first in the article buffer in the sequence specified by
181 :type '(repeat regexp)
182 :group 'gnus-article-hiding)
184 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
185 "Headers that are only to be displayed if they have interesting data.
186 Possible values in this list are:
188 'empty Headers with no content.
189 'newsgroups Newsgroup identical to Gnus group.
190 'to-address To identical to To-address.
191 'to-list To identical to To-list.
192 'cc-list CC identical to To-list.
193 'followup-to Followup-to identical to Newsgroups.
194 'reply-to Reply-to identical to From.
195 'date Date less than four days old.
196 'long-to To and/or Cc longer than 1024 characters.
197 'many-to Multiple To and/or Cc."
198 :type '(set (const :tag "Headers with no content." empty)
199 (const :tag "Newsgroups identical to Gnus group." newsgroups)
200 (const :tag "To identical to To-address." to-address)
201 (const :tag "To identical to To-list." to-list)
202 (const :tag "CC identical to To-list." cc-list)
203 (const :tag "Followup-to identical to Newsgroups." followup-to)
204 (const :tag "Reply-to identical to From." reply-to)
205 (const :tag "Date less than four days old." date)
206 (const :tag "To and/or Cc longer than 1024 characters." long-to)
207 (const :tag "Multiple To and/or Cc headers." many-to))
208 :group 'gnus-article-hiding)
210 (defcustom gnus-article-skip-boring nil
211 "Skip over text that is not worth reading.
212 By default, if you set this t, then Gnus will display citations and
213 signatures, but will never scroll down to show you a page consisting
214 only of boring text. Boring text is controlled by
215 `gnus-article-boring-faces'."
217 :group 'gnus-article-hiding)
219 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
220 "Regexp matching signature separator.
221 This can also be a list of regexps. In that case, it will be checked
222 from head to tail looking for a separator. Searches will be done from
223 the end of the buffer."
224 :type '(repeat string)
225 :group 'gnus-article-signature)
227 (defcustom gnus-signature-limit nil
228 "Provide a limit to what is considered a signature.
229 If it is a number, no signature may not be longer (in characters) than
230 that number. If it is a floating point number, no signature may be
231 longer (in lines) than that number. If it is a function, the function
232 will be called without any parameters, and if it returns nil, there is
233 no signature in the buffer. If it is a string, it will be used as a
234 regexp. If it matches, the text in question is not a signature."
235 :type '(choice (integer :value 200)
237 (function :value fun)
238 (regexp :value ".*"))
239 :group 'gnus-article-signature)
241 (defcustom gnus-hidden-properties '(invisible t intangible t)
242 "Property list to use for hiding text."
244 :group 'gnus-article-hiding)
246 ;; Fixme: This isn't the right thing for mixed graphical and and
247 ;; non-graphical frames in a session.
248 (defcustom gnus-article-x-face-command
249 (if (featurep 'xemacs)
250 (if (or (gnus-image-type-available-p 'xface)
251 (gnus-image-type-available-p 'pbm))
252 'gnus-display-x-face-in-from
253 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
254 (if (gnus-image-type-available-p 'pbm)
255 'gnus-display-x-face-in-from
256 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
258 "*String or function to be executed to display an X-Face header.
259 If it is a string, the command will be executed in a sub-shell
260 asynchronously. The compressed face will be piped to this command."
261 :type `(choice string
262 (function-item gnus-display-x-face-in-from)
266 :group 'gnus-article-washing)
268 (defcustom gnus-article-x-face-too-ugly nil
269 "Regexp matching posters whose face shouldn't be shown automatically."
270 :type '(choice regexp (const nil))
271 :group 'gnus-article-washing)
273 (defcustom gnus-article-banner-alist nil
274 "Banner alist for stripping.
276 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
278 :type '(repeat (cons symbol regexp))
279 :group 'gnus-article-washing)
281 (gnus-define-group-parameter
284 "Alist of regexps (to match group names) and banner."
285 :variable-group gnus-article-washing
287 '(choice :tag "Banner"
289 (const :tag "Remove signature" signature)
290 (symbol :tag "Item in `gnus-article-banner-alist'" none)
292 (const :tag "None" nil))
294 "If non-nil, specify how to remove `banners' from articles.
296 Symbol `signature' means to remove signatures delimited by
297 `gnus-signature-separator'. Any other symbol is used to look up a
298 regular expression to match the banner in `gnus-article-banner-alist'.
299 A string is used as a regular expression to match the banner
302 (defcustom gnus-article-address-banner-alist nil
303 "Alist of mail addresses and banners.
304 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
305 to match a mail address in the From: header, BANNER is one of a symbol
306 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
307 If ADDRESS matches author's mail address, it will remove things like
308 advertisements. For example:
310 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
314 (regexp :tag "Address")
315 (choice :tag "Banner" :value nil
316 (const :tag "Remove signature" signature)
317 (symbol :tag "Item in `gnus-article-banner-alist'" none)
319 (const :tag "None" nil))))
320 :group 'gnus-article-washing)
322 (defcustom gnus-emphasis-alist
324 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
329 ("_/" "/_" underline-italic)
330 ("_\\*" "\\*_" underline-bold)
331 ("\\*/" "/\\*" bold-italic)
332 ("_\\*/" "/\\*_" underline-bold-italic))))
336 (format format (car spec) (cadr spec))
337 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
339 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
340 2 3 gnus-emphasis-strikethru)
341 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
342 2 3 gnus-emphasis-underline)))
343 "*Alist that says how to fontify certain phrases.
344 Each item looks like this:
346 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
348 The first element is a regular expression to be matched. The second
349 is a number that says what regular expression grouping used to find
350 the entire emphasized word. The third is a number that says what
351 regexp grouping should be displayed and highlighted. The fourth
352 is the face used for highlighting."
353 :type '(repeat (list :value ("" 0 0 default)
355 (integer :tag "Match group")
356 (integer :tag "Emphasize group")
358 :group 'gnus-article-emphasis)
360 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
361 "A regexp to describe whitespace which should not be emphasized.
362 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
363 The former avoids underlining of leading and trailing whitespace,
364 and the latter avoids underlining any whitespace at all."
366 :group 'gnus-article-emphasis
369 (defface gnus-emphasis-bold '((t (:bold t)))
370 "Face used for displaying strong emphasized text (*word*)."
371 :group 'gnus-article-emphasis)
373 (defface gnus-emphasis-italic '((t (:italic t)))
374 "Face used for displaying italic emphasized text (/word/)."
375 :group 'gnus-article-emphasis)
377 (defface gnus-emphasis-underline '((t (:underline t)))
378 "Face used for displaying underlined emphasized text (_word_)."
379 :group 'gnus-article-emphasis)
381 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
382 "Face used for displaying underlined bold emphasized text (_*word*_)."
383 :group 'gnus-article-emphasis)
385 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
386 "Face used for displaying underlined italic emphasized text (_/word/_)."
387 :group 'gnus-article-emphasis)
389 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
390 "Face used for displaying bold italic emphasized text (/*word*/)."
391 :group 'gnus-article-emphasis)
393 (defface gnus-emphasis-underline-bold-italic
394 '((t (:bold t :italic t :underline t)))
395 "Face used for displaying underlined bold italic emphasized text.
396 Example: (_/*word*/_)."
397 :group 'gnus-article-emphasis)
399 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
400 "Face used for displaying strike-through text (-word-)."
401 :group 'gnus-article-emphasis)
403 (defface gnus-emphasis-highlight-words
404 '((t (:background "black" :foreground "yellow")))
405 "Face used for displaying highlighted words."
406 :group 'gnus-article-emphasis)
408 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
409 "Format for display of Date headers in article bodies.
410 See `format-time-string' for the possible values.
412 The variable can also be function, which should return a complete Date
413 header. The function is called with one argument, the time, which can
414 be fed to `format-time-string'."
415 :type '(choice string symbol)
416 :link '(custom-manual "(gnus)Article Date")
417 :group 'gnus-article-washing)
420 (autoload 'mail-extract-address-components "mail-extr"))
422 (defcustom gnus-save-all-headers t
423 "*If non-nil, don't remove any headers before saving."
424 :group 'gnus-article-saving
427 (defcustom gnus-prompt-before-saving 'always
428 "*This variable says how much prompting is to be done when saving articles.
429 If it is nil, no prompting will be done, and the articles will be
430 saved to the default files. If this variable is `always', each and
431 every article that is saved will be preceded by a prompt, even when
432 saving large batches of articles. If this variable is neither nil not
433 `always', there the user will be prompted once for a file name for
434 each invocation of the saving commands."
435 :group 'gnus-article-saving
436 :type '(choice (item always)
437 (item :tag "never" nil)
438 (sexp :tag "once" :format "%t\n" :value t)))
440 (defcustom gnus-saved-headers gnus-visible-headers
441 "Headers to keep if `gnus-save-all-headers' is nil.
442 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
443 If that variable is nil, however, all headers that match this regexp
444 will be kept while the rest will be deleted before saving."
445 :group 'gnus-article-saving
448 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
449 "A function to save articles in your favourite format.
450 The function must be interactively callable (in other words, it must
451 be an Emacs command).
453 Gnus provides the following functions:
455 * gnus-summary-save-in-rmail (Rmail format)
456 * gnus-summary-save-in-mail (Unix mail format)
457 * gnus-summary-save-in-folder (MH folder)
458 * gnus-summary-save-in-file (article format)
459 * gnus-summary-save-body-in-file (article body)
460 * gnus-summary-save-in-vm (use VM's folder format)
461 * gnus-summary-write-to-file (article format -- overwrite)."
462 :group 'gnus-article-saving
463 :type '(radio (function-item gnus-summary-save-in-rmail)
464 (function-item gnus-summary-save-in-mail)
465 (function-item gnus-summary-save-in-folder)
466 (function-item gnus-summary-save-in-file)
467 (function-item gnus-summary-save-body-in-file)
468 (function-item gnus-summary-save-in-vm)
469 (function-item gnus-summary-write-to-file)))
471 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
472 "A function generating a file name to save articles in Rmail format.
473 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
474 :group 'gnus-article-saving
477 (defcustom gnus-mail-save-name 'gnus-plain-save-name
478 "A function generating a file name to save articles in Unix mail format.
479 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
480 :group 'gnus-article-saving
483 (defcustom gnus-folder-save-name 'gnus-folder-save-name
484 "A function generating a file name to save articles in MH folder.
485 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
486 :group 'gnus-article-saving
489 (defcustom gnus-file-save-name 'gnus-numeric-save-name
490 "A function generating a file name to save articles in article format.
491 The function is called with NEWSGROUP, HEADERS, and optional
493 :group 'gnus-article-saving
496 (defcustom gnus-split-methods
497 '((gnus-article-archive-name)
498 (gnus-article-nndoc-name))
499 "*Variable used to suggest where articles are to be saved.
500 For instance, if you would like to save articles related to Gnus in
501 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
502 you could set this variable to something like:
504 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
505 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
507 This variable is an alist where the where the key is the match and the
508 value is a list of possible files to save in if the match is non-nil.
510 If the match is a string, it is used as a regexp match on the
511 article. If the match is a symbol, that symbol will be funcalled
512 from the buffer of the article to be saved with the newsgroup as the
513 parameter. If it is a list, it will be evaled in the same buffer.
515 If this form or function returns a string, this string will be used as
516 a possible file name; and if it returns a non-nil list, that list will
517 be used as possible file names."
518 :group 'gnus-article-saving
519 :type '(repeat (choice (list :value (fun) function)
520 (cons :value ("" "") regexp (repeat string))
523 (defcustom gnus-page-delimiter "^\^L"
524 "*Regexp describing what to use as article page delimiters.
525 The default value is \"^\^L\", which is a form linefeed at the
526 beginning of a line."
528 :group 'gnus-article-various)
530 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
531 "*The format specification for the article mode line.
532 See `gnus-summary-mode-line-format' for a closer description.
534 The following additional specs are available:
536 %w The article washing status.
537 %m The number of MIME parts in the article."
539 :group 'gnus-article-various)
541 (defcustom gnus-article-mode-hook nil
542 "*A hook for Gnus article mode."
544 :group 'gnus-article-various)
546 (when (featurep 'xemacs)
547 ;; Extracted from gnus-xmas-define in order to preserve user settings
548 (when (fboundp 'turn-off-scroll-in-place)
549 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
550 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
551 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
553 (defcustom gnus-article-menu-hook nil
554 "*Hook run after the creation of the article mode menu."
556 :group 'gnus-article-various)
558 (defcustom gnus-article-prepare-hook nil
559 "*A hook called after an article has been prepared in the article buffer."
561 :group 'gnus-article-various)
563 (defvar gnus-article-hide-pgp-hook nil)
564 (make-obsolete-variable 'gnus-article-hide-pgp-hook
565 "This variable is obsolete in Gnus 5.10.")
567 (defcustom gnus-article-button-face 'bold
568 "Face used for highlighting buttons in the article buffer.
570 An article button is a piece of text that you can activate by pressing
571 `RET' or `mouse-2' above it."
573 :group 'gnus-article-buttons)
575 (defcustom gnus-article-mouse-face 'highlight
576 "Face used for mouse highlighting in the article buffer.
578 Article buttons will be displayed in this face when the cursor is
581 :group 'gnus-article-buttons)
583 (defcustom gnus-signature-face 'gnus-signature-face
584 "Face used for highlighting a signature in the article buffer.
585 Obsolete; use the face `gnus-signature-face' for customizations instead."
587 :group 'gnus-article-highlight
588 :group 'gnus-article-signature)
590 (defface gnus-signature-face
593 "Face used for highlighting a signature in the article buffer."
594 :group 'gnus-article-highlight
595 :group 'gnus-article-signature)
597 (defface gnus-header-from-face
600 (:foreground "spring green"))
603 (:foreground "red3"))
606 "Face used for displaying from headers."
607 :group 'gnus-article-headers
608 :group 'gnus-article-highlight)
610 (defface gnus-header-subject-face
613 (:foreground "SeaGreen3"))
616 (:foreground "red4"))
618 (:bold t :italic t)))
619 "Face used for displaying subject headers."
620 :group 'gnus-article-headers
621 :group 'gnus-article-highlight)
623 (defface gnus-header-newsgroups-face
626 (:foreground "yellow" :italic t))
629 (:foreground "MidnightBlue" :italic t))
632 "Face used for displaying newsgroups headers."
633 :group 'gnus-article-headers
634 :group 'gnus-article-highlight)
636 (defface gnus-header-name-face
639 (:foreground "SeaGreen"))
642 (:foreground "maroon"))
645 "Face used for displaying header names."
646 :group 'gnus-article-headers
647 :group 'gnus-article-highlight)
649 (defface gnus-header-content-face
652 (:foreground "forest green" :italic t))
655 (:foreground "indianred4" :italic t))
657 (:italic t))) "Face used for displaying header content."
658 :group 'gnus-article-headers
659 :group 'gnus-article-highlight)
661 (defcustom gnus-header-face-alist
662 '(("From" nil gnus-header-from-face)
663 ("Subject" nil gnus-header-subject-face)
664 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
665 ("" gnus-header-name-face gnus-header-content-face))
666 "*Controls highlighting of article header.
668 An alist of the form (HEADER NAME CONTENT).
670 HEADER is a regular expression which should match the name of an
671 header header and NAME and CONTENT are either face names or nil.
673 The name of each header field will be displayed using the face
674 specified by the first element in the list where HEADER match the
675 header name and NAME is non-nil. Similarly, the content will be
676 displayed by the first non-nil matching CONTENT face."
677 :group 'gnus-article-headers
678 :group 'gnus-article-highlight
679 :type '(repeat (list (regexp :tag "Header")
681 (item :tag "skip" nil)
682 (face :value default))
683 (choice :tag "Content"
684 (item :tag "skip" nil)
685 (face :value default)))))
687 (defcustom gnus-article-decode-hook
688 '(article-decode-charset article-decode-encoded-words
689 article-decode-group-name article-decode-idna-rhs)
690 "*Hook run to decode charsets in articles."
691 :group 'gnus-article-headers
694 (defcustom gnus-display-mime-function 'gnus-display-mime
695 "Function to display MIME articles."
696 :group 'gnus-article-mime
699 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
700 "Function used to decode headers.")
702 (defvar gnus-article-dumbquotes-map
722 "Table for MS-to-Latin1 translation.")
724 (defcustom gnus-ignored-mime-types nil
725 "List of MIME types that should be ignored by Gnus."
727 :group 'gnus-article-mime
728 :type '(repeat regexp))
730 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
731 "List of MIME types that should not be given buttons when rendered inline.
732 See also `gnus-buttonized-mime-types' which may override this variable.
733 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
735 :group 'gnus-article-mime
736 :type '(repeat regexp))
738 (defcustom gnus-buttonized-mime-types nil
739 "List of MIME types that should be given buttons when rendered inline.
740 If set, this variable overrides `gnus-unbuttonized-mime-types'.
741 To see e.g. security buttons you could set this to
742 `(\"multipart/signed\")'.
743 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
745 :group 'gnus-article-mime
746 :type '(repeat regexp))
748 (defcustom gnus-inhibit-mime-unbuttonizing nil
749 "If non-nil, all MIME parts get buttons.
750 When nil (the default value), then some MIME parts do not get buttons,
751 as described by the variables `gnus-buttonized-mime-types' and
752 `gnus-unbuttonized-mime-types'."
756 (defcustom gnus-body-boundary-delimiter "_"
757 "String used to delimit header and body.
758 This variable is used by `gnus-article-treat-body-boundary' which can
759 be controlled by `gnus-treat-body-boundary'."
760 :group 'gnus-article-various
761 :type '(choice (item :tag "None" :value nil)
764 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
765 "Defines the location of the faces database.
766 For information on obtaining this database of pretty pictures, please
767 see http://www.cs.indiana.edu/picons/ftp/index.html"
768 :type '(repeat directory)
769 :link '(url-link :tag "download"
770 "http://www.cs.indiana.edu/picons/ftp/index.html")
771 :link '(custom-manual "(gnus)Picons")
774 (defun gnus-picons-installed-p ()
775 "Say whether picons are installed on your machine."
776 (let ((installed nil))
777 (dolist (database gnus-picon-databases)
778 (when (file-exists-p database)
782 (defcustom gnus-article-mime-part-function nil
783 "Function called with a MIME handle as the argument.
784 This is meant for people who want to do something automatic based
785 on parts -- for instance, adding Vcard info to a database."
786 :group 'gnus-article-mime
789 (defcustom gnus-mime-multipart-functions nil
790 "An alist of MIME types to functions to display them."
792 :group 'gnus-article-mime
795 (defcustom gnus-article-date-lapsed-new-header nil
796 "Whether the X-Sent and Date headers can coexist.
797 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
798 either replace the old \"Date:\" header (if this variable is nil), or
799 be added below it (otherwise)."
801 :group 'gnus-article-headers
804 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
805 "Function called with a MIME handle as the argument.
806 This is meant for people who want to view first matched part.
807 For `undisplayed-alternative' (default), the first undisplayed
808 part or alternative part is used. For `undisplayed', the first
809 undisplayed part is used. For a function, the first part which
810 the function return t is used. For nil, the first part is
813 :group 'gnus-article-mime
815 (item :tag "first" :value nil)
816 (item :tag "undisplayed" :value undisplayed)
817 (item :tag "undisplayed or alternative"
818 :value undisplayed-alternative)
821 (defcustom gnus-mime-action-alist
822 '(("save to file" . gnus-mime-save-part)
823 ("save and strip" . gnus-mime-save-part-and-strip)
824 ("delete part" . gnus-mime-delete-part)
825 ("display as text" . gnus-mime-inline-part)
826 ("view the part" . gnus-mime-view-part)
827 ("pipe to command" . gnus-mime-pipe-part)
828 ("toggle display" . gnus-article-press-button)
829 ("toggle display" . gnus-article-view-part-as-charset)
830 ("view as type" . gnus-mime-view-part-as-type)
831 ("view internally" . gnus-mime-view-part-internally)
832 ("view externally" . gnus-mime-view-part-externally))
833 "An alist of actions that run on the MIME attachment."
834 :group 'gnus-article-mime
835 :type '(repeat (cons (string :tag "name")
839 ;;; The treatment variables
842 (defvar gnus-part-display-hook nil
843 "Hook called on parts that are to receive treatment.")
845 (defvar gnus-article-treat-custom
846 '(choice (const :tag "Off" nil)
848 (const :tag "Header" head)
849 (const :tag "Last" last)
850 (integer :tag "Less")
851 (repeat :tag "Groups" regexp)
852 (sexp :tag "Predicate")))
854 (defvar gnus-article-treat-head-custom
855 '(choice (const :tag "Off" nil)
856 (const :tag "Header" head)))
858 (defvar gnus-article-treat-types '("text/plain")
861 (defvar gnus-inhibit-treatment nil
862 "Whether to inhibit treatment.")
864 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
865 "Highlight the signature.
866 Valid values are nil, t, `head', `last', an integer or a predicate.
867 See Info node `(gnus)Customizing Articles'."
868 :group 'gnus-article-treat
869 :link '(custom-manual "(gnus)Customizing Articles")
870 :type gnus-article-treat-custom)
871 (put 'gnus-treat-highlight-signature 'highlight t)
873 (defcustom gnus-treat-buttonize 100000
875 Valid values are nil, t, `head', `last', an integer or a predicate.
876 See Info node `(gnus)Customizing Articles'."
877 :group 'gnus-article-treat
878 :link '(custom-manual "(gnus)Customizing Articles")
879 :type gnus-article-treat-custom)
880 (put 'gnus-treat-buttonize 'highlight t)
882 (defcustom gnus-treat-buttonize-head 'head
883 "Add buttons to the head.
884 Valid values are nil, t, `head', `last', an integer or a predicate.
885 See Info node `(gnus)Customizing Articles' for details."
886 :group 'gnus-article-treat
887 :link '(custom-manual "(gnus)Customizing Articles")
888 :type gnus-article-treat-head-custom)
889 (put 'gnus-treat-buttonize-head 'highlight t)
891 (defcustom gnus-treat-emphasize
892 (and (or window-system
894 (>= (string-to-number emacs-version) 21))
897 Valid values are nil, t, `head', `last', an integer or a predicate.
898 See Info node `(gnus)Customizing Articles' for details."
899 :group 'gnus-article-treat
900 :link '(custom-manual "(gnus)Customizing Articles")
901 :type gnus-article-treat-custom)
902 (put 'gnus-treat-emphasize 'highlight t)
904 (defcustom gnus-treat-strip-cr nil
905 "Remove carriage returns.
906 Valid values are nil, t, `head', `last', an integer or a predicate.
907 See Info node `(gnus)Customizing Articles' for details."
908 :group 'gnus-article-treat
909 :link '(custom-manual "(gnus)Customizing Articles")
910 :type gnus-article-treat-custom)
912 (defcustom gnus-treat-unsplit-urls nil
913 "Remove newlines from within URLs.
914 Valid values are nil, t, `head', `last', an integer or a predicate.
915 See Info node `(gnus)Customizing Articles' for details."
916 :group 'gnus-article-treat
917 :link '(custom-manual "(gnus)Customizing Articles")
918 :type gnus-article-treat-custom)
920 (defcustom gnus-treat-leading-whitespace nil
921 "Remove leading whitespace in headers.
922 Valid values are nil, t, `head', `last', an integer or a predicate.
923 See Info node `(gnus)Customizing Articles' for details."
924 :group 'gnus-article-treat
925 :link '(custom-manual "(gnus)Customizing Articles")
926 :type gnus-article-treat-custom)
928 (defcustom gnus-treat-hide-headers 'head
930 Valid values are nil, t, `head', `last', an integer or a predicate.
931 See Info node `(gnus)Customizing Articles' for details."
932 :group 'gnus-article-treat
933 :link '(custom-manual "(gnus)Customizing Articles")
934 :type gnus-article-treat-head-custom)
936 (defcustom gnus-treat-hide-boring-headers nil
937 "Hide boring headers.
938 Valid values are nil, t, `head', `last', an integer or a predicate.
939 See Info node `(gnus)Customizing Articles' for details."
940 :group 'gnus-article-treat
941 :link '(custom-manual "(gnus)Customizing Articles")
942 :type gnus-article-treat-head-custom)
944 (defcustom gnus-treat-hide-signature nil
946 Valid values are nil, t, `head', `last', an integer or a predicate.
947 See Info node `(gnus)Customizing Articles' for details."
948 :group 'gnus-article-treat
949 :link '(custom-manual "(gnus)Customizing Articles")
950 :type gnus-article-treat-custom)
952 (defcustom gnus-treat-fill-article nil
954 Valid values are nil, t, `head', `last', an integer or a predicate.
955 See Info node `(gnus)Customizing Articles' for details."
956 :group 'gnus-article-treat
957 :link '(custom-manual "(gnus)Customizing Articles")
958 :type gnus-article-treat-custom)
960 (defcustom gnus-treat-hide-citation nil
962 Valid values are nil, t, `head', `last', an integer or a predicate.
963 See Info node `(gnus)Customizing Articles' for details."
964 :group 'gnus-article-treat
965 :link '(custom-manual "(gnus)Customizing Articles")
966 :type gnus-article-treat-custom)
968 (defcustom gnus-treat-hide-citation-maybe nil
970 Valid values are nil, t, `head', `last', an integer or a predicate.
971 See Info node `(gnus)Customizing Articles' for details."
972 :group 'gnus-article-treat
973 :link '(custom-manual "(gnus)Customizing Articles")
974 :type gnus-article-treat-custom)
976 (defcustom gnus-treat-strip-list-identifiers 'head
977 "Strip list identifiers from `gnus-list-identifiers`.
978 Valid values are nil, t, `head', `last', an integer or a predicate.
979 See Info node `(gnus)Customizing Articles' for details."
981 :group 'gnus-article-treat
982 :link '(custom-manual "(gnus)Customizing Articles")
983 :type gnus-article-treat-custom)
985 (make-obsolete-variable 'gnus-treat-strip-pgp
986 "This option is obsolete in Gnus 5.10.")
988 (defcustom gnus-treat-strip-pem nil
989 "Strip PEM signatures.
990 Valid values are nil, t, `head', `last', an integer or a predicate.
991 See Info node `(gnus)Customizing Articles' for details."
992 :group 'gnus-article-treat
993 :link '(custom-manual "(gnus)Customizing Articles")
994 :type gnus-article-treat-custom)
996 (defcustom gnus-treat-strip-banner t
997 "Strip banners from articles.
998 The banner to be stripped is specified in the `banner' group parameter.
999 Valid values are nil, t, `head', `last', an integer or a predicate.
1000 See Info node `(gnus)Customizing Articles' for details."
1001 :group 'gnus-article-treat
1002 :link '(custom-manual "(gnus)Customizing Articles")
1003 :type gnus-article-treat-custom)
1005 (defcustom gnus-treat-highlight-headers 'head
1006 "Highlight the headers.
1007 Valid values are nil, t, `head', `last', an integer or a predicate.
1008 See Info node `(gnus)Customizing Articles' for details."
1009 :group 'gnus-article-treat
1010 :link '(custom-manual "(gnus)Customizing Articles")
1011 :type gnus-article-treat-head-custom)
1012 (put 'gnus-treat-highlight-headers 'highlight t)
1014 (defcustom gnus-treat-highlight-citation t
1015 "Highlight cited text.
1016 Valid values are nil, t, `head', `last', an integer or a predicate.
1017 See Info node `(gnus)Customizing Articles' for details."
1018 :group 'gnus-article-treat
1019 :link '(custom-manual "(gnus)Customizing Articles")
1020 :type gnus-article-treat-custom)
1021 (put 'gnus-treat-highlight-citation 'highlight t)
1023 (defcustom gnus-treat-date-ut nil
1024 "Display the Date in UT (GMT).
1025 Valid values are nil, t, `head', `last', an integer or a predicate.
1026 See Info node `(gnus)Customizing Articles' for details."
1027 :group 'gnus-article-treat
1028 :link '(custom-manual "(gnus)Customizing Articles")
1029 :type gnus-article-treat-head-custom)
1031 (defcustom gnus-treat-date-local nil
1032 "Display the Date in the local timezone.
1033 Valid values are nil, t, `head', `last', an integer or a predicate.
1034 See Info node `(gnus)Customizing Articles' for details."
1035 :group 'gnus-article-treat
1036 :link '(custom-manual "(gnus)Customizing Articles")
1037 :type gnus-article-treat-head-custom)
1039 (defcustom gnus-treat-date-english nil
1040 "Display the Date in a format that can be read aloud in English.
1041 Valid values are nil, t, `head', `last', an integer or a predicate.
1042 See Info node `(gnus)Customizing Articles' for details."
1043 :group 'gnus-article-treat
1044 :link '(custom-manual "(gnus)Customizing Articles")
1045 :type gnus-article-treat-head-custom)
1047 (defcustom gnus-treat-date-lapsed nil
1048 "Display the Date header in a way that says how much time has elapsed.
1049 Valid values are nil, t, `head', `last', an integer or a predicate.
1050 See Info node `(gnus)Customizing Articles' for details."
1051 :group 'gnus-article-treat
1052 :link '(custom-manual "(gnus)Customizing Articles")
1053 :type gnus-article-treat-head-custom)
1055 (defcustom gnus-treat-date-original nil
1056 "Display the date in the original timezone.
1057 Valid values are nil, t, `head', `last', an integer or a predicate.
1058 See Info node `(gnus)Customizing Articles' for details."
1059 :group 'gnus-article-treat
1060 :link '(custom-manual "(gnus)Customizing Articles")
1061 :type gnus-article-treat-head-custom)
1063 (defcustom gnus-treat-date-iso8601 nil
1064 "Display the date in the ISO8601 format.
1065 Valid values are nil, t, `head', `last', an integer or a predicate.
1066 See Info node `(gnus)Customizing Articles' for details."
1068 :group 'gnus-article-treat
1069 :link '(custom-manual "(gnus)Customizing Articles")
1070 :type gnus-article-treat-head-custom)
1072 (defcustom gnus-treat-date-user-defined nil
1073 "Display the date in a user-defined format.
1074 The format is defined by the `gnus-article-time-format' variable.
1075 Valid values are nil, t, `head', `last', an integer or a predicate.
1076 See Info node `(gnus)Customizing Articles' for details."
1077 :group 'gnus-article-treat
1078 :link '(custom-manual "(gnus)Customizing Articles")
1079 :type gnus-article-treat-head-custom)
1081 (defcustom gnus-treat-strip-headers-in-body t
1082 "Strip the X-No-Archive header line from the beginning of the body.
1083 Valid values are nil, t, `head', `last', an integer or a predicate.
1084 See Info node `(gnus)Customizing Articles' for details."
1086 :group 'gnus-article-treat
1087 :link '(custom-manual "(gnus)Customizing Articles")
1088 :type gnus-article-treat-custom)
1090 (defcustom gnus-treat-strip-trailing-blank-lines nil
1091 "Strip trailing blank lines.
1092 Valid values are nil, t, `head', `last', an integer or a predicate.
1093 See Info node `(gnus)Customizing Articles' for details."
1094 :group 'gnus-article-treat
1095 :link '(custom-manual "(gnus)Customizing Articles")
1096 :type gnus-article-treat-custom)
1098 (defcustom gnus-treat-strip-leading-blank-lines nil
1099 "Strip leading blank lines.
1100 Valid values are nil, t, `head', `last', an integer or a predicate.
1101 See Info node `(gnus)Customizing Articles' for details."
1102 :group 'gnus-article-treat
1103 :link '(custom-manual "(gnus)Customizing Articles")
1104 :type gnus-article-treat-custom)
1106 (defcustom gnus-treat-strip-multiple-blank-lines nil
1107 "Strip multiple blank lines.
1108 Valid values are nil, t, `head', `last', an integer or a predicate.
1109 See Info node `(gnus)Customizing Articles' for details."
1110 :group 'gnus-article-treat
1111 :link '(custom-manual "(gnus)Customizing Articles")
1112 :type gnus-article-treat-custom)
1114 (defcustom gnus-treat-unfold-headers 'head
1115 "Unfold folded header lines.
1116 Valid values are nil, t, `head', `last', an integer or a predicate.
1117 See Info node `(gnus)Customizing Articles' for details."
1118 :group 'gnus-article-treat
1119 :link '(custom-manual "(gnus)Customizing Articles")
1120 :type gnus-article-treat-custom)
1122 (defcustom gnus-treat-fold-headers nil
1124 Valid values are nil, t, `head', `last', an integer or a predicate.
1125 See Info node `(gnus)Customizing Articles' for details."
1126 :group 'gnus-article-treat
1127 :link '(custom-manual "(gnus)Customizing Articles")
1128 :type gnus-article-treat-custom)
1130 (defcustom gnus-treat-fold-newsgroups 'head
1131 "Fold the Newsgroups and Followup-To headers.
1132 Valid values are nil, t, `head', `last', an integer or a predicate.
1133 See Info node `(gnus)Customizing Articles' for details."
1134 :group 'gnus-article-treat
1135 :link '(custom-manual "(gnus)Customizing Articles")
1136 :type gnus-article-treat-custom)
1138 (defcustom gnus-treat-overstrike t
1139 "Treat overstrike highlighting.
1140 Valid values are nil, t, `head', `last', an integer or a predicate.
1141 See Info node `(gnus)Customizing Articles' for details."
1142 :group 'gnus-article-treat
1143 :link '(custom-manual "(gnus)Customizing Articles")
1144 :type gnus-article-treat-custom)
1145 (put 'gnus-treat-overstrike 'highlight t)
1147 (defcustom gnus-treat-display-xface
1148 (and (not noninteractive)
1149 (or (and (fboundp 'image-type-available-p)
1150 (image-type-available-p 'xbm)
1151 (string-match "^0x" (shell-command-to-string "uncompface"))
1152 (executable-find "icontopbm"))
1153 (and (featurep 'xemacs)
1156 "Display X-Face headers.
1157 Valid values are nil, t, `head', `last', an integer or a predicate.
1158 See Info node `(gnus)Customizing Articles' and Info node
1159 `(gnus)X-Face' for details."
1160 :group 'gnus-article-treat
1162 :link '(custom-manual "(gnus)Customizing Articles")
1163 :link '(custom-manual "(gnus)X-Face")
1164 :type gnus-article-treat-head-custom)
1165 (put 'gnus-treat-display-xface 'highlight t)
1167 (defcustom gnus-treat-display-face
1168 (and (not noninteractive)
1169 (or (and (fboundp 'image-type-available-p)
1170 (image-type-available-p 'png))
1171 (and (featurep 'xemacs)
1174 "Display Face headers.
1175 Valid values are nil, t, `head', `last', an integer or a predicate.
1176 See Info node `(gnus)Customizing Articles' and Info node
1177 `(gnus)X-Face' for details."
1178 :group 'gnus-article-treat
1180 :link '(custom-manual "(gnus)Customizing Articles")
1181 :link '(custom-manual "(gnus)X-Face")
1182 :type gnus-article-treat-head-custom)
1183 (put 'gnus-treat-display-xface 'highlight t)
1185 (defcustom gnus-treat-display-smileys
1186 (if (or (and (featurep 'xemacs)
1188 (and (fboundp 'image-type-available-p)
1189 (image-type-available-p 'pbm)))
1192 Valid values are nil, t, `head', `last', an integer or a predicate.
1193 See Info node `(gnus)Customizing Articles' and Info node
1194 `(gnus)Smileys' for details."
1195 :group 'gnus-article-treat
1197 :link '(custom-manual "(gnus)Customizing Articles")
1198 :link '(custom-manual "(gnus)Smileys")
1199 :type gnus-article-treat-custom)
1200 (put 'gnus-treat-display-smileys 'highlight t)
1202 (defcustom gnus-treat-from-picon
1203 (if (and (gnus-image-type-available-p 'xpm)
1204 (gnus-picons-installed-p))
1206 "Display picons in the From header.
1207 Valid values are nil, t, `head', `last', an integer or a predicate.
1208 See Info node `(gnus)Customizing Articles' and Info node
1209 `(gnus)Picons' for details."
1210 :group 'gnus-article-treat
1212 :link '(custom-manual "(gnus)Customizing Articles")
1213 :link '(custom-manual "(gnus)Picons")
1214 :type gnus-article-treat-head-custom)
1215 (put 'gnus-treat-from-picon 'highlight t)
1217 (defcustom gnus-treat-mail-picon
1218 (if (and (gnus-image-type-available-p 'xpm)
1219 (gnus-picons-installed-p))
1221 "Display picons in To and Cc headers.
1222 Valid values are nil, t, `head', `last', an integer or a predicate.
1223 See Info node `(gnus)Customizing Articles' and Info node
1224 `(gnus)Picons' for details."
1225 :group 'gnus-article-treat
1227 :link '(custom-manual "(gnus)Customizing Articles")
1228 :link '(custom-manual "(gnus)Picons")
1229 :type gnus-article-treat-head-custom)
1230 (put 'gnus-treat-mail-picon 'highlight t)
1232 (defcustom gnus-treat-newsgroups-picon
1233 (if (and (gnus-image-type-available-p 'xpm)
1234 (gnus-picons-installed-p))
1236 "Display picons in the Newsgroups and Followup-To headers.
1237 Valid values are nil, t, `head', `last', an integer or a predicate.
1238 See Info node `(gnus)Customizing Articles' and Info node
1239 `(gnus)Picons' for details."
1240 :group 'gnus-article-treat
1242 :link '(custom-manual "(gnus)Customizing Articles")
1243 :link '(custom-manual "(gnus)Picons")
1244 :type gnus-article-treat-head-custom)
1245 (put 'gnus-treat-newsgroups-picon 'highlight t)
1247 (defcustom gnus-treat-body-boundary
1248 (if (or gnus-treat-newsgroups-picon
1249 gnus-treat-mail-picon
1250 gnus-treat-from-picon)
1252 "Draw a boundary at the end of the headers.
1253 Valid values are nil, t, `head', `last', an integer or a predicate.
1254 See Info node `(gnus)Customizing Articles' for details."
1256 :group 'gnus-article-treat
1257 :link '(custom-manual "(gnus)Customizing Articles")
1258 :type gnus-article-treat-custom)
1260 (defcustom gnus-treat-capitalize-sentences nil
1261 "Capitalize sentence-starting words.
1262 Valid values are nil, t, `head', `last', an integer or a predicate.
1263 See Info node `(gnus)Customizing Articles' for details."
1265 :group 'gnus-article-treat
1266 :link '(custom-manual "(gnus)Customizing Articles")
1267 :type gnus-article-treat-custom)
1269 (defcustom gnus-treat-wash-html nil
1271 Valid values are nil, t, `head', `last', an integer or a predicate.
1272 See Info node `(gnus)Customizing Articles' for details."
1273 :group 'gnus-article-treat
1274 :link '(custom-manual "(gnus)Customizing Articles")
1275 :type gnus-article-treat-custom)
1277 (defcustom gnus-treat-fill-long-lines nil
1279 Valid values are nil, t, `head', `last', an integer or a predicate.
1280 See Info node `(gnus)Customizing Articles' for details."
1281 :group 'gnus-article-treat
1282 :link '(custom-manual "(gnus)Customizing Articles")
1283 :type gnus-article-treat-custom)
1285 (defcustom gnus-treat-play-sounds nil
1287 Valid values are nil, t, `head', `last', an integer or a predicate.
1288 See Info node `(gnus)Customizing Articles' for details."
1290 :group 'gnus-article-treat
1291 :link '(custom-manual "(gnus)Customizing Articles")
1292 :type gnus-article-treat-custom)
1294 (defcustom gnus-treat-translate nil
1295 "Translate articles from one language to another.
1296 Valid values are nil, t, `head', `last', an integer or a predicate.
1297 See Info node `(gnus)Customizing Articles' for details."
1299 :group 'gnus-article-treat
1300 :link '(custom-manual "(gnus)Customizing Articles")
1301 :type gnus-article-treat-custom)
1303 (defcustom gnus-treat-x-pgp-sig nil
1305 To automatically treat X-PGP-Sig, set it to head.
1306 Valid values are nil, t, `head', `last', an integer or a predicate.
1307 See Info node `(gnus)Customizing Articles' for details."
1308 :group 'gnus-article-treat
1309 :group 'mime-security
1310 :link '(custom-manual "(gnus)Customizing Articles")
1311 :type gnus-article-treat-custom)
1313 (defvar gnus-article-encrypt-protocol-alist
1314 '(("PGP" . mml2015-self-encrypt)))
1316 ;; Set to nil if more than one protocol added to
1317 ;; gnus-article-encrypt-protocol-alist.
1318 (defcustom gnus-article-encrypt-protocol "PGP"
1319 "The protocol used for encrypt articles.
1320 It is a string, such as \"PGP\". If nil, ask user."
1322 :group 'mime-security)
1324 (defvar gnus-article-wash-function nil
1325 "Function used for converting HTML into text.")
1327 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1328 (fboundp 'coding-system-p)
1329 (coding-system-p 'utf-8))
1330 "Whether IDNA decoding of headers is used when viewing messages.
1331 This requires GNU Libidn, and by default only enabled if it is found."
1332 :group 'gnus-article-headers
1335 (defcustom gnus-article-over-scroll nil
1336 "If non-nil, allow scrolling the article buffer even when there no more text."
1337 :group 'gnus-article
1340 ;;; Internal variables
1342 (defvar gnus-english-month-names
1343 '("January" "February" "March" "April" "May" "June" "July" "August"
1344 "September" "October" "November" "December"))
1346 (defvar article-goto-body-goes-to-point-min-p nil)
1347 (defvar gnus-article-wash-types nil)
1348 (defvar gnus-article-emphasis-alist nil)
1349 (defvar gnus-article-image-alist nil)
1351 (defvar gnus-article-mime-handle-alist-1 nil)
1352 (defvar gnus-treatment-function-alist
1353 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1354 (gnus-treat-strip-banner gnus-article-strip-banner)
1355 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1356 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1357 (gnus-treat-buttonize gnus-article-add-buttons)
1358 (gnus-treat-fill-article gnus-article-fill-cited-article)
1359 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1360 (gnus-treat-strip-cr gnus-article-remove-cr)
1361 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1362 (gnus-treat-date-ut gnus-article-date-ut)
1363 (gnus-treat-date-local gnus-article-date-local)
1364 (gnus-treat-date-english gnus-article-date-english)
1365 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1366 (gnus-treat-date-original gnus-article-date-original)
1367 (gnus-treat-date-user-defined gnus-article-date-user)
1368 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1369 (gnus-treat-display-xface gnus-article-display-x-face)
1370 (gnus-treat-display-face gnus-article-display-face)
1371 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1372 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1373 (gnus-treat-hide-signature gnus-article-hide-signature)
1374 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1375 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1376 (gnus-treat-strip-pem gnus-article-hide-pem)
1377 (gnus-treat-from-picon gnus-treat-from-picon)
1378 (gnus-treat-mail-picon gnus-treat-mail-picon)
1379 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1380 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1381 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1382 (gnus-treat-strip-trailing-blank-lines
1383 gnus-article-remove-trailing-blank-lines)
1384 (gnus-treat-strip-leading-blank-lines
1385 gnus-article-strip-leading-blank-lines)
1386 (gnus-treat-strip-multiple-blank-lines
1387 gnus-article-strip-multiple-blank-lines)
1388 (gnus-treat-overstrike gnus-article-treat-overstrike)
1389 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1390 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1391 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1392 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1393 (gnus-treat-display-smileys gnus-treat-smiley)
1394 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1395 (gnus-treat-wash-html gnus-article-wash-html)
1396 (gnus-treat-emphasize gnus-article-emphasize)
1397 (gnus-treat-hide-citation gnus-article-hide-citation)
1398 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1399 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1400 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1401 (gnus-treat-play-sounds gnus-earcon-display)))
1403 (defvar gnus-article-mime-handle-alist nil)
1404 (defvar article-lapsed-timer nil)
1405 (defvar gnus-article-current-summary nil)
1407 (defvar gnus-article-mode-syntax-table
1408 (let ((table (copy-syntax-table text-mode-syntax-table)))
1409 ;; This causes the citation match run O(2^n).
1410 ;; (modify-syntax-entry ?- "w" table)
1411 (modify-syntax-entry ?> ")<" table)
1412 (modify-syntax-entry ?< "(>" table)
1413 ;; make M-. in article buffers work for `foo' strings
1414 (modify-syntax-entry ?' " " table)
1415 (modify-syntax-entry ?` " " table)
1417 "Syntax table used in article mode buffers.
1418 Initialized from `text-mode-syntax-table.")
1420 (defvar gnus-save-article-buffer nil)
1422 (defvar gnus-article-mode-line-format-alist
1423 (nconc '((?w (gnus-article-wash-status) ?s)
1424 (?m (gnus-article-mime-part-status) ?s))
1425 gnus-summary-mode-line-format-alist))
1427 (defvar gnus-number-of-articles-to-be-saved nil)
1429 (defvar gnus-inhibit-hiding nil)
1431 ;;; Macros for dealing with the article buffer.
1433 (defmacro gnus-with-article-headers (&rest forms)
1435 (set-buffer gnus-article-buffer)
1437 (let ((buffer-read-only nil)
1438 (inhibit-point-motion-hooks t)
1439 (case-fold-search t))
1440 (article-narrow-to-head)
1443 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1444 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1446 (defmacro gnus-with-article-buffer (&rest forms)
1448 (set-buffer gnus-article-buffer)
1449 (let ((buffer-read-only nil))
1452 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1453 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1455 (defun gnus-article-goto-header (header)
1456 "Go to HEADER, which is a regular expression."
1457 (re-search-forward (concat "^\\(" header "\\):") nil t))
1459 (defsubst gnus-article-hide-text (b e props)
1460 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1461 (gnus-add-text-properties-when 'article-type nil b e props)
1462 (when (memq 'intangible props)
1464 (max (1- b) (point-min))
1465 b 'intangible (cddr (memq 'intangible props)))))
1467 (defsubst gnus-article-unhide-text (b e)
1468 "Remove hidden text properties from region between B and E."
1469 (remove-text-properties b e gnus-hidden-properties)
1470 (when (memq 'intangible gnus-hidden-properties)
1471 (put-text-property (max (1- b) (point-min))
1472 b 'intangible nil)))
1474 (defun gnus-article-hide-text-type (b e type)
1475 "Hide text of TYPE between B and E."
1476 (gnus-add-wash-type type)
1477 (gnus-article-hide-text
1478 b e (cons 'article-type (cons type gnus-hidden-properties))))
1480 (defun gnus-article-unhide-text-type (b e type)
1481 "Unhide text of TYPE between B and E."
1482 (gnus-delete-wash-type type)
1483 (remove-text-properties
1484 b e (cons 'article-type (cons type gnus-hidden-properties)))
1485 (when (memq 'intangible gnus-hidden-properties)
1486 (put-text-property (max (1- b) (point-min))
1487 b 'intangible nil)))
1489 (defun gnus-article-hide-text-of-type (type)
1490 "Hide text of TYPE in the current buffer."
1492 (let ((b (point-min))
1494 (while (setq b (text-property-any b e 'article-type type))
1495 (add-text-properties b (incf b) gnus-hidden-properties)))))
1497 (defun gnus-article-delete-text-of-type (type)
1498 "Delete text of TYPE in the current buffer."
1500 (let ((b (point-min)))
1501 (while (setq b (text-property-any b (point-max) 'article-type type))
1503 b (or (text-property-not-all b (point-max) 'article-type type)
1506 (defun gnus-article-delete-invisible-text ()
1507 "Delete all invisible text in the current buffer."
1509 (let ((b (point-min)))
1510 (while (setq b (text-property-any b (point-max) 'invisible t))
1512 b (or (text-property-not-all b (point-max) 'invisible t)
1515 (defun gnus-article-text-type-exists-p (type)
1516 "Say whether any text of type TYPE exists in the buffer."
1517 (text-property-any (point-min) (point-max) 'article-type type))
1519 (defsubst gnus-article-header-rank ()
1520 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1521 (let ((list gnus-sorted-header-list)
1524 (if (looking-at (car list))
1526 (setq list (cdr list))
1530 (defun article-hide-headers (&optional arg delete)
1531 "Hide unwanted headers and possibly sort them as well."
1533 ;; This function might be inhibited.
1534 (unless gnus-inhibit-hiding
1537 (let ((buffer-read-only nil)
1538 (case-fold-search t)
1539 (max (1+ (length gnus-sorted-header-list)))
1540 (ignored (when (not gnus-visible-headers)
1541 (cond ((stringp gnus-ignored-headers)
1542 gnus-ignored-headers)
1543 ((listp gnus-ignored-headers)
1544 (mapconcat 'identity gnus-ignored-headers
1547 (cond ((stringp gnus-visible-headers)
1548 gnus-visible-headers)
1549 ((and gnus-visible-headers
1550 (listp gnus-visible-headers))
1551 (mapconcat 'identity gnus-visible-headers "\\|"))))
1552 (inhibit-point-motion-hooks t)
1554 ;; First we narrow to just the headers.
1555 (article-narrow-to-head)
1556 ;; Hide any "From " lines at the beginning of (mail) articles.
1557 (while (looking-at "From ")
1560 (delete-region (point-min) (point)))
1561 ;; Then treat the rest of the header lines.
1562 ;; Then we use the two regular expressions
1563 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1564 ;; select which header lines is to remain visible in the
1566 (while (re-search-forward "^[^ \t:]*:" nil t)
1568 ;; Mark the rank of the header.
1570 (point) (1+ (point)) 'message-rank
1571 (if (or (and visible (looking-at visible))
1573 (not (looking-at ignored))))
1574 (gnus-article-header-rank)
1577 (message-sort-headers-1)
1578 (when (setq beg (text-property-any
1579 (point-min) (point-max) 'message-rank (+ 2 max)))
1580 ;; We delete the unwanted headers.
1581 (gnus-add-wash-type 'headers)
1582 (add-text-properties (point-min) (+ 5 (point-min))
1583 '(article-type headers dummy-invisible t))
1584 (delete-region beg (point-max))))))))
1586 (defun article-hide-boring-headers (&optional arg)
1587 "Toggle hiding of headers that aren't very interesting.
1588 If given a negative prefix, always show; if given a positive prefix,
1590 (interactive (gnus-article-hidden-arg))
1591 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1592 (not gnus-show-all-headers))
1595 (let ((buffer-read-only nil)
1596 (list gnus-boring-article-headers)
1597 (inhibit-point-motion-hooks t)
1599 (article-narrow-to-head)
1601 (setq elem (pop list))
1602 (goto-char (point-min))
1604 ;; Hide empty headers.
1606 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1608 (gnus-article-hide-text-type
1612 (if (re-search-forward "^[^ \t]" nil t)
1616 ;; Hide boring Newsgroups header.
1617 ((eq elem 'newsgroups)
1618 (when (gnus-string-equal
1619 (gnus-fetch-field "newsgroups")
1620 (gnus-group-real-name
1621 (if (boundp 'gnus-newsgroup-name)
1624 (gnus-article-hide-header "newsgroups")))
1625 ((eq elem 'to-address)
1626 (let ((to (message-fetch-field "to"))
1628 (gnus-parameter-to-address
1629 (if (boundp 'gnus-newsgroup-name)
1630 gnus-newsgroup-name ""))))
1631 (when (and to to-address
1634 ;; only one address in To
1635 (nth 1 (mail-extract-address-components to))
1637 (gnus-article-hide-header "to"))))
1639 (let ((to (message-fetch-field "to"))
1641 (gnus-parameter-to-list
1642 (if (boundp 'gnus-newsgroup-name)
1643 gnus-newsgroup-name ""))))
1644 (when (and to to-list
1647 ;; only one address in To
1648 (nth 1 (mail-extract-address-components to))
1650 (gnus-article-hide-header "to"))))
1652 (let ((cc (message-fetch-field "cc"))
1654 (gnus-parameter-to-list
1655 (if (boundp 'gnus-newsgroup-name)
1656 gnus-newsgroup-name ""))))
1657 (when (and cc to-list
1660 ;; only one address in CC
1661 (nth 1 (mail-extract-address-components cc))
1663 (gnus-article-hide-header "cc"))))
1664 ((eq elem 'followup-to)
1665 (when (gnus-string-equal
1666 (message-fetch-field "followup-to")
1667 (message-fetch-field "newsgroups"))
1668 (gnus-article-hide-header "followup-to")))
1669 ((eq elem 'reply-to)
1670 (let ((from (message-fetch-field "from"))
1671 (reply-to (message-fetch-field "reply-to")))
1676 (nth 1 (mail-extract-address-components from))
1677 (nth 1 (mail-extract-address-components reply-to)))))
1678 (gnus-article-hide-header "reply-to"))))
1680 (let ((date (message-fetch-field "date")))
1682 (< (days-between (current-time-string) date)
1684 (gnus-article-hide-header "date"))))
1686 (let ((to (message-fetch-field "to"))
1687 (cc (message-fetch-field "cc")))
1688 (when (> (length to) 1024)
1689 (gnus-article-hide-header "to"))
1690 (when (> (length cc) 1024)
1691 (gnus-article-hide-header "cc"))))
1695 (goto-char (point-min))
1696 (while (re-search-forward "^to:" nil t)
1697 (setq to-count (1+ to-count)))
1698 (when (> to-count 1)
1699 (while (> to-count 0)
1700 (goto-char (point-min))
1702 (re-search-forward "^to:" nil nil to-count)
1704 (narrow-to-region (point) (point-max))
1705 (gnus-article-hide-header "to"))
1706 (setq to-count (1- to-count))))
1707 (goto-char (point-min))
1708 (while (re-search-forward "^cc:" nil t)
1709 (setq cc-count (1+ cc-count)))
1710 (when (> cc-count 1)
1711 (while (> cc-count 0)
1712 (goto-char (point-min))
1714 (re-search-forward "^cc:" nil nil cc-count)
1716 (narrow-to-region (point) (point-max))
1717 (gnus-article-hide-header "cc"))
1718 (setq cc-count (1- cc-count)))))))))))))
1720 (defun gnus-article-hide-header (header)
1722 (goto-char (point-min))
1723 (when (re-search-forward (concat "^" header ":") nil t)
1724 (gnus-article-hide-text-type
1728 (if (re-search-forward "^[^ \t]" nil t)
1733 (defvar gnus-article-normalized-header-length 40
1734 "Length of normalized headers.")
1736 (defun article-normalize-headers ()
1737 "Make all header lines 40 characters long."
1739 (let ((buffer-read-only nil)
1743 (article-narrow-to-head)
1746 ((< (setq column (- (gnus-point-at-eol) (point)))
1747 gnus-article-normalized-header-length)
1749 (insert (make-string
1750 (- gnus-article-normalized-header-length column)
1752 ((> column gnus-article-normalized-header-length)
1753 (gnus-put-text-property
1755 (forward-char gnus-article-normalized-header-length)
1762 (forward-line 1))))))
1764 (defun article-treat-dumbquotes ()
1765 "Translate M****s*** sm*rtq**t*s into proper text.
1766 Note that this function guesses whether a character is a sm*rtq**t* or
1767 not, so it should only be used interactively.
1769 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1770 in an attempt to provide more quoting characters. If you see
1771 something like \\222 or \\264 where you're expecting some kind of
1772 apostrophe or quotation mark, then try this wash."
1774 (article-translate-strings gnus-article-dumbquotes-map))
1776 (defun article-translate-characters (from to)
1777 "Translate all characters in the body of the article according to FROM and TO.
1778 FROM is a string of characters to translate from; to is a string of
1779 characters to translate to."
1781 (when (article-goto-body)
1782 (let ((buffer-read-only nil)
1783 (x (make-string 225 ?x))
1785 (while (< (incf i) (length x))
1788 (while (< i (length from))
1789 (aset x (aref from i) (aref to i))
1791 (translate-region (point) (point-max) x)))))
1793 (defun article-translate-strings (map)
1794 "Translate all string in the body of the article according to MAP.
1795 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1797 (when (article-goto-body)
1798 (let ((buffer-read-only nil)
1800 (while (setq elem (pop map))
1802 (while (search-forward (car elem) nil t)
1803 (replace-match (cadr elem)))))))))
1805 (defun article-treat-overstrike ()
1806 "Translate overstrikes into bold text."
1809 (when (article-goto-body)
1810 (let ((buffer-read-only nil))
1811 (while (search-forward "\b" nil t)
1812 (let ((next (char-after))
1813 (previous (char-after (- (point) 2))))
1814 ;; We do the boldification/underlining by hiding the
1815 ;; overstrikes and putting the proper text property
1819 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1820 (put-text-property (point) (1+ (point)) 'face 'bold))
1822 (gnus-article-hide-text-type
1823 (1- (point)) (1+ (point)) 'overstrike)
1825 (- (point) 2) (1- (point)) 'face 'underline))
1827 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1829 (point) (1+ (point)) 'face 'underline)))))))))
1831 (defun gnus-article-treat-unfold-headers ()
1832 "Unfold folded message headers.
1833 Only the headers that fit into the current window width will be
1836 (gnus-with-article-headers
1840 (mail-header-narrow-to-field)
1841 (let ((header (buffer-string)))
1844 (goto-char (point-min))
1845 (while (re-search-forward "\n[\t ]" nil t)
1846 (replace-match " " t t)))
1847 (setq length (- (point-max) (point-min) 1)))
1848 (when (< length (window-width))
1849 (while (re-search-forward "\n[\t ]" nil t)
1850 (replace-match " " t t)))
1851 (goto-char (point-max)))))))
1853 (defun gnus-article-treat-fold-headers ()
1854 "Fold message headers."
1856 (gnus-with-article-headers
1859 (mail-header-narrow-to-field)
1860 (mail-header-fold-field)
1861 (goto-char (point-max))))))
1863 (defun gnus-treat-smiley ()
1864 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1866 (gnus-with-article-buffer
1867 (if (memq 'smiley gnus-article-wash-types)
1868 (gnus-delete-images 'smiley)
1870 (let ((images (smiley-region (point) (point-max))))
1872 (gnus-add-wash-type 'smiley)
1873 (dolist (image images)
1874 (gnus-add-image 'smiley image)))))))
1876 (defun gnus-article-remove-images ()
1877 "Remove all images from the article buffer."
1879 (gnus-with-article-buffer
1880 (dolist (elem gnus-article-image-alist)
1881 (gnus-delete-images (car elem)))))
1883 (defun gnus-article-treat-fold-newsgroups ()
1884 "Unfold folded message headers.
1885 Only the headers that fit into the current window width will be
1888 (gnus-with-article-headers
1889 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1891 (mail-header-narrow-to-field)
1892 (while (re-search-forward ", *" nil t)
1893 (replace-match ", " t t))
1894 (mail-header-fold-field)
1895 (goto-char (point-max))))))
1897 (defun gnus-article-treat-body-boundary ()
1898 "Place a boundary line at the end of the headers."
1900 (when (and gnus-body-boundary-delimiter
1901 (> (length gnus-body-boundary-delimiter) 0))
1902 (gnus-with-article-headers
1903 (goto-char (point-max))
1904 (let ((start (point)))
1905 (insert "X-Boundary: ")
1906 (gnus-add-text-properties start (point) '(invisible t intangible t))
1908 (while (>= (1- (window-width)) (length str))
1909 (setq str (concat str gnus-body-boundary-delimiter)))
1910 (substring str 0 (1- (window-width))))
1912 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1914 (defun article-fill-long-lines ()
1915 "Fill lines that are wider than the window width."
1918 (let ((buffer-read-only nil)
1919 (width (window-width (get-buffer-window (current-buffer)))))
1922 (let ((adaptive-fill-mode nil)) ;Why? -sm
1925 (when (>= (current-column) (min fill-column width))
1926 (narrow-to-region (min (1+ (point)) (point-max)) (gnus-point-at-bol))
1927 (let ((goback (point-marker)))
1928 (fill-paragraph nil)
1929 (goto-char (marker-position goback)))
1931 (forward-line 1)))))))
1933 (defun article-capitalize-sentences ()
1934 "Capitalize the first word in each sentence."
1937 (let ((buffer-read-only nil)
1938 (paragraph-start "^[\n\^L]"))
1942 (forward-sentence)))))
1944 (defun article-remove-cr ()
1945 "Remove trailing CRs and then translate remaining CRs into LFs."
1948 (let ((buffer-read-only nil))
1949 (goto-char (point-min))
1950 (while (re-search-forward "\r+$" nil t)
1951 (replace-match "" t t))
1952 (goto-char (point-min))
1953 (while (search-forward "\r" nil t)
1954 (replace-match "\n" t t)))))
1956 (defun article-remove-trailing-blank-lines ()
1957 "Remove all trailing blank lines from the article."
1960 (let ((buffer-read-only nil))
1961 (goto-char (point-max))
1965 (while (and (not (bobp))
1966 (looking-at "^[ \t]*$")
1967 (not (gnus-annotation-in-region-p
1968 (point) (gnus-point-at-eol))))
1973 (defun article-display-face ()
1974 "Display any Face headers in the header."
1976 (gnus-with-article-headers
1977 (let ((face (message-fetch-field "face")))
1979 (let ((png (gnus-convert-face-to-png face))
1982 (setq image (gnus-create-image png 'png t))
1983 (gnus-article-goto-header "from")
1985 (insert "From: [no `from' set]\n")
1987 (gnus-add-wash-type 'face)
1988 (gnus-add-image 'face image)
1989 (gnus-put-image image)))))))
1991 (defun article-display-x-face (&optional force)
1992 "Look for an X-Face header and display it if present."
1993 (interactive (list 'force))
1994 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1995 (gnus-with-article-headers
1996 ;; Delete the old process, if any.
1997 (when (process-status "article-x-face")
1998 (delete-process "article-x-face"))
1999 (if (memq 'xface gnus-article-wash-types)
2000 ;; We have already displayed X-Faces, so we remove them
2002 (gnus-delete-images 'xface)
2004 (let (x-faces from face)
2006 (when (and wash-face-p
2008 (goto-char (point-min))
2009 (not (re-search-forward
2010 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2011 (gnus-buffer-live-p gnus-original-article-buffer))
2012 ;; If type `W f', use gnus-original-article-buffer,
2013 ;; otherwise use the current buffer because displaying
2014 ;; RFC822 parts calls this function too.
2015 (set-buffer gnus-original-article-buffer))
2017 (mail-narrow-to-head)
2018 (while (gnus-article-goto-header "X-Face")
2019 (push (mail-header-field-value) x-faces))
2020 (setq from (message-fetch-field "from"))))
2021 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2022 ;; single external face.
2023 (when (stringp gnus-article-x-face-command)
2024 (setq x-faces (list (car x-faces))))
2025 (while (and (setq face (pop x-faces))
2026 gnus-article-x-face-command
2028 ;; Check whether this face is censored.
2029 (not gnus-article-x-face-too-ugly)
2030 (and gnus-article-x-face-too-ugly from
2031 (not (string-match gnus-article-x-face-too-ugly
2033 ;; We display the face.
2034 (if (symbolp gnus-article-x-face-command)
2035 ;; The command is a lisp function, so we call it.
2036 (if (gnus-functionp gnus-article-x-face-command)
2037 (funcall gnus-article-x-face-command face)
2038 (error "%s is not a function" gnus-article-x-face-command))
2039 ;; The command is a string, so we interpret the command
2040 ;; as a, well, command, and fork it off.
2041 (let ((process-connection-type nil))
2042 (process-kill-without-query
2044 "article-x-face" nil shell-file-name shell-command-switch
2045 gnus-article-x-face-command))
2048 (process-send-region "article-x-face"
2049 (point-min) (point-max)))
2050 (process-send-eof "article-x-face")))))))))
2052 (defun article-decode-mime-words ()
2053 "Decode all MIME-encoded words in the article."
2056 (set-buffer gnus-article-buffer)
2057 (let ((inhibit-point-motion-hooks t)
2059 (mail-parse-charset gnus-newsgroup-charset)
2060 (mail-parse-ignored-charsets
2061 (save-excursion (set-buffer gnus-summary-buffer)
2062 gnus-newsgroup-ignored-charsets)))
2063 (mail-decode-encoded-word-region (point-min) (point-max)))))
2065 (defun article-decode-charset (&optional prompt)
2066 "Decode charset-encoded text in the article.
2067 If PROMPT (the prefix), prompt for a coding system to use."
2069 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2071 (mail-parse-charset gnus-newsgroup-charset)
2072 (mail-parse-ignored-charsets
2073 (save-excursion (condition-case nil
2074 (set-buffer gnus-summary-buffer)
2076 gnus-newsgroup-ignored-charsets))
2077 ct cte ctl charset format)
2080 (article-narrow-to-head)
2081 (setq ct (message-fetch-field "Content-Type" t)
2082 cte (message-fetch-field "Content-Transfer-Encoding" t)
2083 ctl (and ct (ignore-errors
2084 (mail-header-parse-content-type ct)))
2087 (mm-read-coding-system "Charset to decode: "))
2089 (mail-content-type-get ctl 'charset)))
2090 format (and ctl (mail-content-type-get ctl 'format)))
2092 (setq cte (mail-header-strip cte)))
2093 (if (and ctl (not (string-match "/" (car ctl))))
2095 (goto-char (point-max)))
2098 (narrow-to-region (point) (point-max))
2099 (when (and (eq mail-parse-charset 'gnus-decoded)
2100 (eq (mm-body-7-or-8) '8bit))
2101 ;; The text code could have been decoded.
2102 (setq charset mail-parse-charset))
2103 (when (and (or (not ctl)
2104 (equal (car ctl) "text/plain"))
2105 (not format)) ;; article with format will decode later.
2107 charset (and cte (intern (downcase
2108 (gnus-strip-whitespace cte))))
2109 (car ctl) prompt))))))
2111 (defun article-decode-encoded-words ()
2112 "Remove encoded-word encoding from headers."
2113 (let ((inhibit-point-motion-hooks t)
2114 (mail-parse-charset gnus-newsgroup-charset)
2115 (mail-parse-ignored-charsets
2116 (save-excursion (condition-case nil
2117 (set-buffer gnus-summary-buffer)
2119 gnus-newsgroup-ignored-charsets))
2122 (article-narrow-to-head)
2123 (funcall gnus-decode-header-function (point-min) (point-max)))))
2125 (defun article-decode-group-name ()
2126 "Decode group names in `Newsgroups:'."
2127 (let ((inhibit-point-motion-hooks t)
2129 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2130 (when (and (or gnus-group-name-charset-method-alist
2131 gnus-group-name-charset-group-alist)
2132 (gnus-buffer-live-p gnus-original-article-buffer))
2134 (article-narrow-to-head)
2135 (with-current-buffer gnus-original-article-buffer
2136 (goto-char (point-min)))
2137 (while (re-search-forward "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2139 (replace-match (save-match-data
2140 (gnus-decode-newsgroups
2141 ;; XXX how to use data in article buffer?
2142 (with-current-buffer gnus-original-article-buffer
2144 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2147 gnus-newsgroup-name method))
2149 (goto-char (point-min))
2150 (with-current-buffer gnus-original-article-buffer
2151 (goto-char (point-min)))
2152 (while (re-search-forward "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2154 (replace-match (save-match-data
2155 (gnus-decode-newsgroups
2156 ;; XXX how to use data in article buffer?
2157 (with-current-buffer gnus-original-article-buffer
2159 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2162 gnus-newsgroup-name method))
2165 (autoload 'idna-to-unicode "idna")
2167 (defun article-decode-idna-rhs ()
2168 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2171 (let ((inhibit-point-motion-hooks t)
2173 (article-narrow-to-head)
2174 (goto-char (point-min))
2175 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2177 (when (save-match-data
2178 (and (setq ace (match-string 1))
2180 (and (re-search-backward "^[^ \t]" nil t)
2181 (looking-at "From\\|To\\|Cc")))
2182 (save-excursion (backward-char)
2183 (message-idna-inside-rhs-p))
2184 (setq unicode (idna-to-unicode ace))))
2185 (unless (string= ace unicode)
2186 (replace-match unicode nil nil nil 1)))))))))
2188 (defun article-de-quoted-unreadable (&optional force read-charset)
2189 "Translate a quoted-printable-encoded article.
2190 If FORCE, decode the article whether it is marked as quoted-printable
2192 If READ-CHARSET, ask for a coding system."
2193 (interactive (list 'force current-prefix-arg))
2195 (let ((buffer-read-only nil) type charset)
2196 (if (gnus-buffer-live-p gnus-original-article-buffer)
2197 (with-current-buffer gnus-original-article-buffer
2199 (gnus-fetch-field "content-transfer-encoding"))
2200 (let* ((ct (gnus-fetch-field "content-type"))
2203 (mail-header-parse-content-type ct)))))
2204 (setq charset (and ctl
2205 (mail-content-type-get ctl 'charset)))
2206 (if (stringp charset)
2207 (setq charset (intern (downcase charset)))))))
2209 (setq charset (mm-read-coding-system "Charset: " charset)))
2211 (setq charset gnus-newsgroup-charset))
2213 (and type (let ((case-fold-search t))
2214 (string-match "quoted-printable" type))))
2216 (quoted-printable-decode-region
2217 (point) (point-max) (mm-charset-to-coding-system charset))))))
2219 (defun article-de-base64-unreadable (&optional force read-charset)
2220 "Translate a base64 article.
2221 If FORCE, decode the article whether it is marked as base64 not.
2222 If READ-CHARSET, ask for a coding system."
2223 (interactive (list 'force current-prefix-arg))
2225 (let ((buffer-read-only nil) type charset)
2226 (if (gnus-buffer-live-p gnus-original-article-buffer)
2227 (with-current-buffer gnus-original-article-buffer
2229 (gnus-fetch-field "content-transfer-encoding"))
2230 (let* ((ct (gnus-fetch-field "content-type"))
2233 (mail-header-parse-content-type ct)))))
2234 (setq charset (and ctl
2235 (mail-content-type-get ctl 'charset)))
2236 (if (stringp charset)
2237 (setq charset (intern (downcase charset)))))))
2239 (setq charset (mm-read-coding-system "Charset: " charset)))
2241 (setq charset gnus-newsgroup-charset))
2243 (and type (let ((case-fold-search t))
2244 (string-match "base64" type))))
2247 (narrow-to-region (point) (point-max))
2248 (base64-decode-region (point-min) (point-max))
2249 (mm-decode-coding-region
2250 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2255 (defun article-decode-HZ ()
2256 "Translate a HZ-encoded article."
2260 (let ((buffer-read-only nil))
2261 (rfc1843-decode-region (point-min) (point-max)))))
2263 (defun article-unsplit-urls ()
2264 "Remove the newlines that some other mailers insert into URLs."
2267 (let ((buffer-read-only nil))
2268 (goto-char (point-min))
2269 (while (re-search-forward
2270 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2271 (replace-match "\\1\\3" t)))
2272 (when (and gnus-display-mime-function (interactive-p))
2273 (funcall gnus-display-mime-function))))
2276 (defun article-wash-html (&optional read-charset)
2277 "Format an HTML article.
2278 If READ-CHARSET, ask for a coding system."
2281 (let ((buffer-read-only nil)
2283 (when (gnus-buffer-live-p gnus-original-article-buffer)
2284 (with-current-buffer gnus-original-article-buffer
2285 (let* ((ct (gnus-fetch-field "content-type"))
2288 (mail-header-parse-content-type ct)))))
2289 (setq charset (and ctl
2290 (mail-content-type-get ctl 'charset)))
2291 (when (stringp charset)
2292 (setq charset (intern (downcase charset)))))))
2294 (setq charset (mm-read-coding-system "Charset: " charset)))
2296 (setq charset gnus-newsgroup-charset))
2298 (save-window-excursion
2300 (narrow-to-region (point) (point-max))
2301 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2302 (entry (assq func mm-text-html-washer-alist)))
2304 (setq func (cdr entry)))
2306 ((gnus-functionp func)
2309 (apply (car func) (cdr func))))))))))
2311 (defun gnus-article-wash-html-with-w3 ()
2312 "Wash the current buffer with w3."
2314 (let ((w3-strict-width (window-width))
2315 (url-standalone-mode t)
2316 (url-gateway-unplugged t)
2317 (w3-honor-stylesheets nil))
2319 (w3-region (point-min) (point-max))
2322 (defun gnus-article-wash-html-with-w3m ()
2323 "Wash the current buffer with emacs-w3m."
2326 (narrow-to-region (point) (point-max))
2327 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2330 w3m-force-redisplay)
2331 (w3m-region (point-min) (point-max)))
2332 (when mm-inline-text-html-with-w3m-keymap
2333 (add-text-properties
2334 (point-min) (point-max)
2335 (nconc (mm-w3m-local-map-property)
2336 '(mm-inline-text-html-with-w3m t))))))
2338 (defun article-hide-list-identifiers ()
2339 "Remove list identifies from the Subject header.
2340 The `gnus-list-identifiers' variable specifies what to do."
2342 (let ((inhibit-point-motion-hooks t)
2343 (regexp (if (consp gnus-list-identifiers)
2344 (mapconcat 'identity gnus-list-identifiers " *\\|")
2345 gnus-list-identifiers))
2350 (article-narrow-to-head)
2351 (goto-char (point-min))
2352 (while (re-search-forward
2353 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2355 (delete-region (match-beginning 2) (match-end 0))
2356 (beginning-of-line))
2357 (when (re-search-forward
2358 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2359 (delete-region (match-beginning 1) (match-end 1))))))))
2361 (defun article-hide-pem (&optional arg)
2362 "Toggle hiding of any PEM headers and signatures in the current article.
2363 If given a negative prefix, always show; if given a positive prefix,
2365 (interactive (gnus-article-hidden-arg))
2366 (unless (gnus-article-check-hidden-text 'pem arg)
2368 (let (buffer-read-only end)
2369 (goto-char (point-min))
2370 ;; Hide the horrendously ugly "header".
2371 (when (and (search-forward
2372 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2374 (setq end (1+ (match-beginning 0))))
2375 (gnus-add-wash-type 'pem)
2376 (gnus-article-hide-text-type
2378 (if (search-forward "\n\n" nil t)
2382 ;; Hide the trailer as well
2383 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2385 (gnus-article-hide-text-type
2386 (match-beginning 0) (match-end 0) 'pem)))))))
2388 (defun article-strip-banner ()
2389 "Strip the banners specified by the `banner' group parameter and by
2390 `gnus-article-address-banner-alist'."
2394 (let ((inhibit-point-motion-hooks t))
2395 (when (gnus-parameter-banner gnus-newsgroup-name)
2396 (article-really-strip-banner
2397 (gnus-parameter-banner gnus-newsgroup-name)))
2398 (when gnus-article-address-banner-alist
2399 (article-really-strip-banner
2400 (let ((from (save-restriction
2402 (article-narrow-to-head)
2403 (mail-fetch-field "from"))))
2406 (caar (mail-header-parse-addresses from))))
2408 (dolist (pair gnus-article-address-banner-alist)
2409 (when (string-match (car pair) from)
2410 (throw 'found (cdr pair)))))))))))))
2412 (defun article-really-strip-banner (banner)
2413 "Strip the banner specified by the argument."
2416 (let ((inhibit-point-motion-hooks t)
2417 (gnus-signature-limit nil)
2421 ((eq banner 'signature)
2422 (when (gnus-article-narrow-to-signature)
2425 (delete-region (point) (point-max))))
2427 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2428 (while (re-search-forward banner nil t)
2429 (delete-region (match-beginning 0) (match-end 0)))))
2431 (while (re-search-forward banner nil t)
2432 (delete-region (match-beginning 0) (match-end 0)))))))))
2434 (defun article-babel ()
2435 "Translate article using an online translation service."
2439 (set-buffer gnus-article-buffer)
2440 (when (article-goto-body)
2441 (let* ((buffer-read-only nil)
2444 (orig (buffer-substring start end))
2445 (trans (babel-as-string orig)))
2447 (narrow-to-region start end)
2448 (delete-region start end)
2451 (defun article-hide-signature (&optional arg)
2452 "Hide the signature in the current article.
2453 If given a negative prefix, always show; if given a positive prefix,
2455 (interactive (gnus-article-hidden-arg))
2456 (unless (gnus-article-check-hidden-text 'signature arg)
2459 (let ((buffer-read-only nil))
2460 (when (gnus-article-narrow-to-signature)
2461 (gnus-article-hide-text-type
2462 (point-min) (point-max) 'signature))))))
2463 (gnus-set-mode-line 'article))
2465 (defun article-strip-headers-in-body ()
2466 "Strip offensive headers from bodies."
2470 (let ((case-fold-search t))
2471 (when (looking-at "x-no-archive:")
2472 (gnus-delete-line)))))
2474 (defun article-strip-leading-blank-lines ()
2475 "Remove all blank lines from the beginning of the article."
2478 (let ((inhibit-point-motion-hooks t)
2480 (when (article-goto-body)
2481 (while (and (not (eobp))
2482 (looking-at "[ \t]*$"))
2483 (gnus-delete-line))))))
2485 (defun article-narrow-to-head ()
2486 "Narrow the buffer to the head of the message.
2487 Point is left at the beginning of the narrowed-to region."
2489 (goto-char (point-min))
2490 (if (search-forward "\n\n" nil 1)
2493 (goto-char (point-min)))
2495 (defun article-goto-body ()
2496 "Place point at the start of the body."
2497 (goto-char (point-min))
2499 ;; This variable is only bound when dealing with separate
2501 (article-goto-body-goes-to-point-min-p
2503 ((search-forward "\n\n" nil t)
2506 (goto-char (point-max))
2509 (defun article-strip-multiple-blank-lines ()
2510 "Replace consecutive blank lines with one empty line."
2513 (let ((inhibit-point-motion-hooks t)
2515 ;; First make all blank lines empty.
2517 (while (re-search-forward "^[ \t]+$" nil t)
2518 (unless (gnus-annotation-in-region-p
2519 (match-beginning 0) (match-end 0))
2520 (replace-match "" nil t)))
2521 ;; Then replace multiple empty lines with a single empty line.
2523 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2524 (unless (gnus-annotation-in-region-p
2525 (match-beginning 0) (match-end 0))
2526 (delete-region (match-beginning 1) (match-end 1)))))))
2528 (defun article-strip-leading-space ()
2529 "Remove all white space from the beginning of the lines in the article."
2532 (let ((inhibit-point-motion-hooks t)
2535 (while (re-search-forward "^[ \t]+" nil t)
2536 (replace-match "" t t)))))
2538 (defun article-strip-trailing-space ()
2539 "Remove all white space from the end of the lines in the article."
2542 (let ((inhibit-point-motion-hooks t)
2545 (while (re-search-forward "[ \t]+$" nil t)
2546 (replace-match "" t t)))))
2548 (defun article-strip-blank-lines ()
2549 "Strip leading, trailing and multiple blank lines."
2551 (article-strip-leading-blank-lines)
2552 (article-remove-trailing-blank-lines)
2553 (article-strip-multiple-blank-lines))
2555 (defun article-strip-all-blank-lines ()
2556 "Strip all blank lines."
2559 (let ((inhibit-point-motion-hooks t)
2562 (while (re-search-forward "^[ \t]*\n" nil t)
2563 (replace-match "" t t)))))
2565 (defun gnus-article-narrow-to-signature ()
2566 "Narrow to the signature; return t if a signature is found, else nil."
2567 (let ((inhibit-point-motion-hooks t))
2568 (when (gnus-article-search-signature)
2570 ;; Check whether we have some limits to what we consider
2571 ;; to be a signature.
2572 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2573 (list gnus-signature-limit)))
2575 (while (setq limit (pop limits))
2576 (if (or (and (integerp limit)
2577 (< (- (point-max) (point)) limit))
2579 (< (count-lines (point) (point-max)) limit))
2580 (and (gnus-functionp limit)
2582 (and (stringp limit)
2583 (not (re-search-forward limit nil t))))
2584 () ; This limit did not succeed.
2588 (narrow-to-region (point) (point-max))
2591 (defun gnus-article-search-signature ()
2592 "Search the current buffer for the signature separator.
2593 Put point at the beginning of the signature separator."
2594 (let ((cur (point)))
2595 (goto-char (point-max))
2596 (if (if (stringp gnus-signature-separator)
2597 (re-search-backward gnus-signature-separator nil t)
2598 (let ((seps gnus-signature-separator))
2600 (not (re-search-backward (car seps) nil t)))
2607 (defun gnus-article-hidden-arg ()
2608 "Return the current prefix arg as a number, or 0 if no prefix."
2609 (list (if current-prefix-arg
2610 (prefix-numeric-value current-prefix-arg)
2613 (defun gnus-article-check-hidden-text (type arg)
2614 "Return nil if hiding is necessary.
2615 Arg can be nil or a number. nil and positive means hide, negative
2616 means show, 0 means toggle."
2619 (let ((hide (gnus-article-hidden-text-p type)))
2625 (gnus-article-show-hidden-text type)
2628 (if (eq hide 'hidden)
2630 (gnus-article-show-hidden-text type)
2634 (defun gnus-article-hidden-text-p (type)
2635 "Say whether the current buffer contains hidden text of type TYPE."
2636 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2638 (not (get-text-property pos 'invisible))
2639 (not (get-text-property pos 'dummy-invisible)))
2641 (text-property-any (1+ pos) (point-max) 'article-type type)))
2646 (defun gnus-article-show-hidden-text (type &optional dummy)
2647 "Show all hidden text of type TYPE.
2648 Originally it is hide instead of DUMMY."
2649 (let ((buffer-read-only nil)
2650 (inhibit-point-motion-hooks t))
2651 (gnus-remove-text-properties-when
2653 (point-min) (point-max)
2654 (cons 'article-type (cons type
2655 gnus-hidden-properties)))
2656 (gnus-delete-wash-type type)))
2658 (defconst article-time-units
2659 `((year . ,(* 365.25 24 60 60))
2660 (week . ,(* 7 24 60 60))
2661 (day . ,(* 24 60 60))
2665 "Mapping from time units to seconds.")
2667 (defun gnus-article-forward-header ()
2668 "Move point to the start of the next header.
2669 If the current header is a continuation header, this can be several
2674 (if (looking-at "[ \t]+[^ \t]")
2678 (defun article-date-ut (&optional type highlight header)
2679 "Convert DATE date to universal time in the current article.
2680 If TYPE is `local', convert to local time; if it is `lapsed', output
2681 how much time has lapsed since DATE. For `lapsed', the value of
2682 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2683 should replace the \"Date:\" one, or should be added below it."
2684 (interactive (list 'ut t))
2685 (let* ((header (or header
2686 (message-fetch-field "date")
2688 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2691 ((not gnus-article-date-lapsed-new-header)
2697 (date (if (vectorp header) (mail-header-date header)
2699 (inhibit-point-motion-hooks t)
2704 (article-narrow-to-head)
2705 (when (re-search-forward tdate-regexp nil t)
2706 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2707 date (or (get-text-property (gnus-point-at-bol)
2710 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2712 (when (and date (not (string= date "")))
2713 (goto-char (point-min))
2714 (let ((buffer-read-only nil))
2715 ;; Delete any old Date headers.
2716 (while (re-search-forward date-regexp nil t)
2718 (delete-region (progn (beginning-of-line) (point))
2719 (progn (gnus-article-forward-header)
2721 (delete-region (progn (beginning-of-line) (point))
2722 (progn (gnus-article-forward-header)
2725 (setq pos (point))))
2726 (when (and (not pos)
2727 (re-search-forward tdate-regexp nil t))
2731 (insert (article-make-date-line date (or type 'ut)))
2737 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2738 (put-text-property (match-beginning 1) (1+ (match-end 1))
2739 'original-date date)
2740 (put-text-property (match-beginning 1) (1+ (match-end 1))
2742 (put-text-property (match-beginning 2) (match-end 2)
2745 (defun article-make-date-line (date type)
2746 "Return a DATE line of TYPE."
2747 (unless (memq type '(local ut original user iso8601 lapsed english))
2748 (error "Unknown conversion type: %s" type))
2750 (let ((time (date-to-time date)))
2752 ;; Convert to the local timezone.
2754 (let ((tz (car (current-time-zone time))))
2755 (format "Date: %s %s%02d%02d" (current-time-string time)
2756 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2757 (/ (% (abs tz) 3600) 60))))
2758 ;; Convert to Universal Time.
2761 (current-time-string
2762 (let* ((e (parse-time-string date))
2763 (tm (apply 'encode-time e))
2765 (ls (- (cadr tm) (car (current-time-zone time)))))
2766 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2767 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2770 ;; Get the original date from the article.
2771 ((eq type 'original)
2772 (concat "Date: " (if (string-match "\n+$" date)
2773 (substring date 0 (match-beginning 0))
2775 ;; Let the user define the format.
2777 (let ((format (or (condition-case nil
2778 (with-current-buffer gnus-summary-buffer
2779 gnus-article-time-format)
2781 gnus-article-time-format)))
2782 (if (gnus-functionp format)
2783 (funcall format time)
2784 (concat "Date: " (format-time-string format time)))))
2787 (let ((tz (car (current-time-zone time))))
2790 (format-time-string "%Y%m%dT%H%M%S" time)
2791 (format "%s%02d%02d"
2792 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2793 (/ (% (abs tz) 3600) 60)))))
2794 ;; Do an X-Sent lapsed format.
2796 ;; If the date is seriously mangled, the timezone functions are
2797 ;; liable to bug out, so we ignore all errors.
2798 (let* ((now (current-time))
2799 (real-time (subtract-time now time))
2800 (real-sec (and real-time
2801 (+ (* (float (car real-time)) 65536)
2803 (sec (and real-time (abs real-sec)))
2813 ;; This is a bit convoluted, but basically we go
2814 ;; through the time units for years, weeks, etc,
2815 ;; and divide things to see whether that results
2816 ;; in positive answers.
2819 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2820 ;; The (remaining) seconds are too few to
2821 ;; be divided into this time unit.
2823 ;; It's big enough, so we output it.
2824 (setq sec (- sec (* num (cdr unit))))
2826 (concat (if prev ", " "") (int-to-string
2828 " " (symbol-name (car unit))
2829 (if (> num 1) "s" ""))
2831 article-time-units "")
2832 ;; If dates are odd, then it might appear like the
2833 ;; article was sent in the future.
2836 " in the future"))))))
2837 ;; Display the date in proper English
2839 (let ((dtime (decode-time time)))
2842 (number-to-string (nth 3 dtime))
2843 (let ((digit (% (nth 3 dtime) 10)))
2845 ((memq (nth 3 dtime) '(11 12 13)) "th")
2851 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2853 (number-to-string (nth 5 dtime))
2855 (format "%02d" (nth 2 dtime))
2857 (format "%02d" (nth 1 dtime)))))))
2859 (format "Date: %s (from Gnus)" date))))
2861 (defun article-date-local (&optional highlight)
2862 "Convert the current article date to the local timezone."
2863 (interactive (list t))
2864 (article-date-ut 'local highlight))
2866 (defun article-date-english (&optional highlight)
2867 "Convert the current article date to something that is proper English."
2868 (interactive (list t))
2869 (article-date-ut 'english highlight))
2871 (defun article-date-original (&optional highlight)
2872 "Convert the current article date to what it was originally.
2873 This is only useful if you have used some other date conversion
2874 function and want to see what the date was before converting."
2875 (interactive (list t))
2876 (article-date-ut 'original highlight))
2878 (defun article-date-lapsed (&optional highlight)
2879 "Convert the current article date to time lapsed since it was sent."
2880 (interactive (list t))
2881 (article-date-ut 'lapsed highlight))
2883 (defun article-update-date-lapsed ()
2884 "Function to be run from a timer to update the lapsed time line."
2885 (let (deactivate-mark)
2890 (set-buffer (window-buffer w))
2891 (when (eq major-mode 'gnus-article-mode)
2892 (goto-char (point-min))
2893 (when (re-search-forward "^X-Sent:" nil t)
2894 (article-date-lapsed t))))
2897 (defun gnus-start-date-timer (&optional n)
2898 "Start a timer to update the X-Sent header in the article buffers.
2899 The numerical prefix says how frequently (in seconds) the function
2904 (gnus-stop-date-timer)
2905 (setq article-lapsed-timer
2906 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2908 (defun gnus-stop-date-timer ()
2909 "Stop the X-Sent timer."
2911 (when article-lapsed-timer
2912 (nnheader-cancel-timer article-lapsed-timer)
2913 (setq article-lapsed-timer nil)))
2915 (defun article-date-user (&optional highlight)
2916 "Convert the current article date to the user-defined format.
2917 This format is defined by the `gnus-article-time-format' variable."
2918 (interactive (list t))
2919 (article-date-ut 'user highlight))
2921 (defun article-date-iso8601 (&optional highlight)
2922 "Convert the current article date to ISO8601."
2923 (interactive (list t))
2924 (article-date-ut 'iso8601 highlight))
2926 ;; (defun article-show-all ()
2927 ;; "Show all hidden text in the article buffer."
2930 ;; (let ((buffer-read-only nil))
2931 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2933 (defun article-remove-leading-whitespace ()
2934 "Remove excessive whitespace from all headers."
2938 (let ((buffer-read-only nil))
2939 (article-narrow-to-head)
2940 (goto-char (point-min))
2941 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2942 (delete-region (match-beginning 1) (match-end 1)))))))
2944 (defun article-emphasize (&optional arg)
2945 "Emphasize text according to `gnus-emphasis-alist'."
2946 (interactive (gnus-article-hidden-arg))
2947 (unless (gnus-article-check-hidden-text 'emphasis arg)
2951 (with-current-buffer gnus-summary-buffer
2952 gnus-article-emphasis-alist)
2954 gnus-emphasis-alist))
2955 (buffer-read-only nil)
2956 (props (append '(article-type emphasis)
2957 gnus-hidden-properties))
2958 regexp elem beg invisible visible face)
2961 (while (setq elem (pop alist))
2963 (setq regexp (car elem)
2964 invisible (nth 1 elem)
2965 visible (nth 2 elem)
2967 (while (re-search-forward regexp nil t)
2968 (when (and (match-beginning visible) (match-beginning invisible))
2969 (gnus-article-hide-text
2970 (match-beginning invisible) (match-end invisible) props)
2971 (gnus-article-unhide-text-type
2972 (match-beginning visible) (match-end visible) 'emphasis)
2973 (gnus-put-overlay-excluding-newlines
2974 (match-beginning visible) (match-end visible) 'face face)
2975 (gnus-add-wash-type 'emphasis)
2976 (goto-char (match-end invisible)))))))))
2978 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2979 "Setup newsgroup emphasis alist."
2980 (unless gnus-article-emphasis-alist
2981 (let ((name (and gnus-newsgroup-name
2982 (gnus-group-real-name gnus-newsgroup-name))))
2983 (make-local-variable 'gnus-article-emphasis-alist)
2984 (setq gnus-article-emphasis-alist
2986 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2987 (while (setq elem (pop alist))
2988 (when (and name (string-match (car elem) name))
2990 highlight (copy-sequence (cdr elem)))))
2992 (copy-sequence highlight-words)
2993 (if gnus-newsgroup-name
2994 (copy-sequence (gnus-group-find-parameter
2995 gnus-newsgroup-name 'highlight-words t)))
2996 gnus-emphasis-alist)))))
2999 (defvar gnus-summary-article-menu)
3000 (defvar gnus-summary-post-menu))
3002 ;;; Saving functions.
3004 (defun gnus-article-save (save-buffer file &optional num)
3005 "Save the currently selected article."
3006 (unless gnus-save-all-headers
3007 ;; Remove headers according to `gnus-saved-headers'.
3008 (let ((gnus-visible-headers
3009 (or gnus-saved-headers gnus-visible-headers))
3010 (gnus-article-buffer save-buffer))
3012 (set-buffer save-buffer)
3013 (article-hide-headers 1 t))))
3014 (save-window-excursion
3015 (if (not gnus-default-article-saver)
3016 (error "No default saver is defined")
3017 ;; !!! Magic! The saving functions all save
3018 ;; `gnus-save-article-buffer' (or so they think), but we
3019 ;; bind that variable to our save-buffer.
3020 (set-buffer gnus-article-buffer)
3021 (let* ((gnus-save-article-buffer save-buffer)
3024 ((not gnus-prompt-before-saving) 'default)
3025 ((eq gnus-prompt-before-saving 'always) nil)
3027 (gnus-number-of-articles-to-be-saved
3028 (when (eq gnus-prompt-before-saving t)
3030 (set-buffer gnus-article-current-summary)
3031 (funcall gnus-default-article-saver filename)))))
3033 (defun gnus-read-save-file-name (prompt &optional filename
3034 function group headers variable)
3036 (funcall function group headers (symbol-value variable)))
3041 ((eq filename 'default)
3047 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3050 (if (and gnus-number-of-articles-to-be-saved
3051 (> gnus-number-of-articles-to-be-saved 1))
3052 (format "these %d articles"
3053 gnus-number-of-articles-to-be-saved)
3056 ;; Let the split methods have their say.
3058 ;; No split name was found.
3061 (concat prompt " (default "
3062 (file-name-nondirectory default-name) ") ")
3063 (file-name-directory default-name)
3065 ;; A single group name is returned.
3066 ((stringp split-name)
3068 (funcall function split-name headers
3069 (symbol-value variable)))
3071 (concat prompt " (default "
3072 (file-name-nondirectory default-name) ") ")
3073 (file-name-directory default-name)
3075 ;; A single split name was found
3076 ((= 1 (length split-name))
3077 (let* ((name (expand-file-name
3079 gnus-article-save-directory))
3080 (dir (cond ((file-directory-p name)
3081 (file-name-as-directory name))
3082 ((file-exists-p name) name)
3083 (t gnus-article-save-directory))))
3085 (concat prompt " (default " name ") ")
3087 ;; A list of splits was found.
3089 (setq split-name (nreverse split-name))
3091 (let ((file-name-history
3092 (nconc split-name file-name-history)))
3096 (concat prompt " (`M-p' for defaults) ")
3097 gnus-article-save-directory
3099 gnus-article-save-directory)))
3100 (car (push result file-name-history)))))))
3101 ;; Create the directory.
3102 (gnus-make-directory (file-name-directory file))
3103 ;; If we have read a directory, we append the default file name.
3104 (when (file-directory-p file)
3105 (setq file (expand-file-name (file-name-nondirectory
3107 (file-name-as-directory file))))
3108 ;; Possibly translate some characters.
3109 (nnheader-translate-file-chars file))))))
3110 (gnus-make-directory (file-name-directory result))
3111 (set variable result)))
3113 (defun gnus-article-archive-name (group)
3114 "Return the first instance of an \"Archive-name\" in the current buffer."
3115 (let ((case-fold-search t))
3116 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3117 (nnheader-concat gnus-article-save-directory
3118 (match-string 1)))))
3120 (defun gnus-article-nndoc-name (group)
3121 "If GROUP is an nndoc group, return the name of the parent group."
3122 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3123 (gnus-group-get-parameter group 'save-article-group)))
3125 (defun gnus-summary-save-in-rmail (&optional filename)
3126 "Append this article to Rmail file.
3127 Optional argument FILENAME specifies file name.
3128 Directory to save to is default to `gnus-article-save-directory'."
3129 (setq filename (gnus-read-save-file-name
3130 "Save %s in rmail file:" filename
3131 gnus-rmail-save-name gnus-newsgroup-name
3132 gnus-current-headers 'gnus-newsgroup-last-rmail))
3133 (gnus-eval-in-buffer-window gnus-save-article-buffer
3137 (gnus-output-to-rmail filename))))
3140 (defun gnus-summary-save-in-mail (&optional filename)
3141 "Append this article to Unix mail file.
3142 Optional argument FILENAME specifies file name.
3143 Directory to save to is default to `gnus-article-save-directory'."
3144 (setq filename (gnus-read-save-file-name
3145 "Save %s in Unix mail file:" filename
3146 gnus-mail-save-name gnus-newsgroup-name
3147 gnus-current-headers 'gnus-newsgroup-last-mail))
3148 (gnus-eval-in-buffer-window gnus-save-article-buffer
3152 (if (and (file-readable-p filename)
3153 (file-regular-p filename)
3154 (mail-file-babyl-p filename))
3155 (rmail-output-to-rmail-file filename t)
3156 (gnus-output-to-mail filename)))))
3159 (defun gnus-summary-save-in-file (&optional filename overwrite)
3160 "Append this article to file.
3161 Optional argument FILENAME specifies file name.
3162 Directory to save to is default to `gnus-article-save-directory'."
3163 (setq filename (gnus-read-save-file-name
3164 "Save %s in file:" filename
3165 gnus-file-save-name gnus-newsgroup-name
3166 gnus-current-headers 'gnus-newsgroup-last-file))
3167 (gnus-eval-in-buffer-window gnus-save-article-buffer
3171 (when (and overwrite
3172 (file-exists-p filename))
3173 (delete-file filename))
3174 (gnus-output-to-file filename))))
3177 (defun gnus-summary-write-to-file (&optional filename)
3178 "Write this article to a file, overwriting it if the file exists.
3179 Optional argument FILENAME specifies file name.
3180 The directory to save in defaults to `gnus-article-save-directory'."
3181 (gnus-summary-save-in-file nil t))
3183 (defun gnus-summary-save-body-in-file (&optional filename)
3184 "Append this article body to a file.
3185 Optional argument FILENAME specifies file name.
3186 The directory to save in defaults to `gnus-article-save-directory'."
3187 (setq filename (gnus-read-save-file-name
3188 "Save %s body in file:" filename
3189 gnus-file-save-name gnus-newsgroup-name
3190 gnus-current-headers 'gnus-newsgroup-last-file))
3191 (gnus-eval-in-buffer-window gnus-save-article-buffer
3195 (when (article-goto-body)
3196 (narrow-to-region (point) (point-max)))
3197 (gnus-output-to-file filename))))
3200 (defun gnus-summary-save-in-pipe (&optional command)
3201 "Pipe this article to subprocess."
3203 (cond ((and (eq command 'default)
3204 gnus-last-shell-command)
3205 gnus-last-shell-command)
3210 "Shell command on %s: "
3211 (if (and gnus-number-of-articles-to-be-saved
3212 (> gnus-number-of-articles-to-be-saved 1))
3213 (format "these %d articles"
3214 gnus-number-of-articles-to-be-saved)
3216 gnus-last-shell-command))))
3217 (when (string-equal command "")
3218 (if gnus-last-shell-command
3219 (setq command gnus-last-shell-command)
3220 (error "A command is required")))
3221 (gnus-eval-in-buffer-window gnus-article-buffer
3224 (shell-command-on-region (point-min) (point-max) command nil)))
3225 (setq gnus-last-shell-command command))
3227 (defun gnus-summary-pipe-to-muttprint (&optional command)
3228 "Pipe this article to muttprint."
3229 (setq command (read-string
3230 "Print using command: " gnus-summary-muttprint-program
3231 nil gnus-summary-muttprint-program))
3232 (gnus-summary-save-in-pipe command))
3234 ;;; Article file names when saving.
3236 (defun gnus-capitalize-newsgroup (newsgroup)
3237 "Capitalize NEWSGROUP name."
3238 (when (not (zerop (length newsgroup)))
3239 (concat (char-to-string (upcase (aref newsgroup 0)))
3240 (substring newsgroup 1))))
3242 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3243 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3244 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3245 Otherwise, it is like ~/News/news/group/num."
3248 (concat (if (gnus-use-long-file-name 'not-save)
3249 (gnus-capitalize-newsgroup newsgroup)
3250 (gnus-newsgroup-directory-form newsgroup))
3251 "/" (int-to-string (mail-header-number headers)))
3252 gnus-article-save-directory)))
3254 (string-equal (file-name-directory default)
3255 (file-name-directory last-file))
3256 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3258 (or last-file default))))
3260 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3261 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3262 If variable `gnus-use-long-file-name' is non-nil, it is
3263 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3266 (concat (if (gnus-use-long-file-name 'not-save)
3268 (gnus-newsgroup-directory-form newsgroup))
3269 "/" (int-to-string (mail-header-number headers)))
3270 gnus-article-save-directory)))
3272 (string-equal (file-name-directory default)
3273 (file-name-directory last-file))
3274 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3276 (or last-file default))))
3278 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3279 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3280 If variable `gnus-use-long-file-name' is non-nil, it is
3281 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3284 (if (gnus-use-long-file-name 'not-save)
3287 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3289 gnus-article-save-directory)))
3291 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3292 "Generate file name from sender."
3293 (let ((from (mail-header-from headers)))
3295 (if (and from (string-match "\\([^ <]+\\)@" from))
3296 (match-string 1 from)
3298 gnus-article-save-directory)))
3300 (defun article-verify-x-pgp-sig ()
3303 (if (gnus-buffer-live-p gnus-original-article-buffer)
3304 (let ((sig (with-current-buffer gnus-original-article-buffer
3305 (gnus-fetch-field "X-PGP-Sig")))
3309 (mml2015-clear-verify-function))
3311 (insert-buffer-substring gnus-original-article-buffer)
3312 (setq items (split-string sig))
3313 (message-narrow-to-head)
3314 (let ((inhibit-point-motion-hooks t)
3315 (case-fold-search t))
3316 ;; Don't verify multiple headers.
3317 (setq headers (mapconcat (lambda (header)
3319 (mail-fetch-field header) "\n"))
3320 (split-string (nth 1 items) ",") "")))
3321 (delete-region (point-min) (point-max))
3322 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3323 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3328 (if (looking-at "^-")
3331 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3332 (insert "Version: " (car items) "\n\n")
3333 (insert (mapconcat 'identity (cddr items) "\n"))
3334 (insert "\n-----END PGP SIGNATURE-----\n")
3335 (let ((mm-security-handle (list (format "multipart/signed"))))
3336 (mml2015-clean-buffer)
3337 (let ((coding-system-for-write (or gnus-newsgroup-charset
3339 (funcall (mml2015-clear-verify-function)))
3341 (or (mm-handle-multipart-ctl-parameter
3342 mm-security-handle 'gnus-details)
3343 (mm-handle-multipart-ctl-parameter
3344 mm-security-handle 'gnus-info)))))
3346 (let (buffer-read-only bface eface)
3348 (message-narrow-to-head)
3349 (goto-char (point-max))
3351 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3352 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3353 (message-remove-header "X-Gnus-PGP-Verify")
3354 (if (re-search-forward "^X-PGP-Sig:" nil t)
3356 (goto-char (point-max)))
3357 (narrow-to-region (point) (point))
3358 (insert "X-Gnus-PGP-Verify: " info "\n")
3359 (goto-char (point-min))
3362 (if (not (looking-at "^[ \t]"))
3366 (goto-char (point-min))
3367 (when (looking-at "\\([^:]+\\): *")
3368 (put-text-property (match-beginning 1) (1+ (match-end 1))
3370 (put-text-property (match-end 0) (point-max)
3371 'face eface)))))))))
3373 (defun article-verify-cancel-lock ()
3374 "Verify Cancel-Lock header."
3376 (if (gnus-buffer-live-p gnus-original-article-buffer)
3377 (canlock-verify gnus-original-article-buffer)))
3384 (setq afunc (car func)
3387 gfunc (intern (format "gnus-%s" func))))
3389 (when (fboundp afunc)
3390 `(lambda (&optional interactive &rest args)
3391 ,(documentation afunc t)
3392 (interactive (list t))
3394 (set-buffer gnus-article-buffer)
3396 (call-interactively ',afunc)
3397 (apply ',afunc args))))))))
3398 '(article-hide-headers
3399 article-verify-x-pgp-sig
3400 article-verify-cancel-lock
3401 article-hide-boring-headers
3402 article-treat-overstrike
3403 article-fill-long-lines
3404 article-capitalize-sentences
3406 article-remove-leading-whitespace
3407 article-display-x-face
3408 article-display-face
3409 article-de-quoted-unreadable
3410 article-de-base64-unreadable
3413 article-unsplit-urls
3414 article-hide-list-identifiers
3415 article-strip-banner
3418 article-hide-signature
3419 article-strip-headers-in-body
3420 article-remove-trailing-blank-lines
3421 article-strip-leading-blank-lines
3422 article-strip-multiple-blank-lines
3423 article-strip-leading-space
3424 article-strip-trailing-space
3425 article-strip-blank-lines
3426 article-strip-all-blank-lines
3428 article-date-english
3429 article-date-iso8601
3430 article-date-original
3432 article-decode-mime-words
3433 article-decode-charset
3434 article-decode-encoded-words
3438 article-treat-dumbquotes
3439 article-normalize-headers
3440 ;; (article-show-all . gnus-article-show-all-headers)
3444 ;;; Gnus article mode
3447 (put 'gnus-article-mode 'mode-class 'special)
3449 (set-keymap-parent gnus-article-mode-map widget-keymap)
3451 (gnus-define-keys gnus-article-mode-map
3452 " " gnus-article-goto-next-page
3453 "\177" gnus-article-goto-prev-page
3454 [delete] gnus-article-goto-prev-page
3455 [backspace] gnus-article-goto-prev-page
3456 "\C-c^" gnus-article-refer-article
3457 "h" gnus-article-show-summary
3458 "s" gnus-article-show-summary
3459 "\C-c\C-m" gnus-article-mail
3460 "?" gnus-article-describe-briefly
3461 "e" gnus-summary-edit-article
3462 "<" beginning-of-buffer
3464 "\C-c\C-i" gnus-info-find-node
3466 "R" gnus-article-reply-with-original
3467 "F" gnus-article-followup-with-original
3468 "\C-hk" gnus-article-describe-key
3469 "\C-hc" gnus-article-describe-key-briefly
3471 "\C-d" gnus-article-read-summary-keys
3472 "\M-*" gnus-article-read-summary-keys
3473 "\M-#" gnus-article-read-summary-keys
3474 "\M-^" gnus-article-read-summary-keys
3475 "\M-g" gnus-article-read-summary-keys)
3477 (substitute-key-definition
3478 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3480 (defun gnus-article-make-menu-bar ()
3481 (unless (boundp 'gnus-article-commands-menu)
3482 (gnus-summary-make-menu-bar))
3483 (gnus-turn-off-edit-menu 'article)
3484 (unless (boundp 'gnus-article-article-menu)
3486 gnus-article-article-menu gnus-article-mode-map ""
3488 ["Scroll forwards" gnus-article-goto-next-page t]
3489 ["Scroll backwards" gnus-article-goto-prev-page t]
3490 ["Show summary" gnus-article-show-summary t]
3491 ["Fetch Message-ID at point" gnus-article-refer-article t]
3492 ["Mail to address at point" gnus-article-mail t]
3493 ["Send a bug report" gnus-bug t]))
3496 gnus-article-treatment-menu gnus-article-mode-map ""
3497 ;; Fixme: this should use :active (and maybe :visible).
3499 ["Hide headers" gnus-article-hide-headers t]
3500 ["Hide signature" gnus-article-hide-signature t]
3501 ["Hide citation" gnus-article-hide-citation t]
3502 ["Treat overstrike" gnus-article-treat-overstrike t]
3503 ["Remove carriage return" gnus-article-remove-cr t]
3504 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3505 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3506 ["Remove base64" gnus-article-de-base64-unreadable t]
3507 ["Treat html" gnus-article-wash-html t]
3508 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3509 ["Decode HZ" gnus-article-decode-HZ t]))
3511 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3513 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3515 (gnus-run-hooks 'gnus-article-menu-hook)))
3517 (defun gnus-article-mode ()
3518 "Major mode for displaying an article.
3520 All normal editing commands are switched off.
3522 The following commands are available in addition to all summary mode
3524 \\<gnus-article-mode-map>
3525 \\[gnus-article-next-page]\t Scroll the article one page forwards
3526 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3527 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3528 \\[gnus-article-show-summary]\t Display the summary buffer
3529 \\[gnus-article-mail]\t Send a reply to the address near point
3530 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3531 \\[gnus-info-find-node]\t Go to the Gnus info node"
3533 (gnus-simplify-mode-line)
3534 (setq mode-name "Article")
3535 (setq major-mode 'gnus-article-mode)
3536 (make-local-variable 'minor-mode-alist)
3537 (use-local-map gnus-article-mode-map)
3538 (when (gnus-visual-p 'article-menu 'menu)
3539 (gnus-article-make-menu-bar)
3540 (when gnus-summary-tool-bar-map
3541 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3542 (gnus-update-format-specifications nil 'article-mode)
3543 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3544 (make-local-variable 'gnus-page-broken)
3545 (make-local-variable 'gnus-button-marker-list)
3546 (make-local-variable 'gnus-article-current-summary)
3547 (make-local-variable 'gnus-article-mime-handles)
3548 (make-local-variable 'gnus-article-decoded-p)
3549 (make-local-variable 'gnus-article-mime-handle-alist)
3550 (make-local-variable 'gnus-article-wash-types)
3551 (make-local-variable 'gnus-article-image-alist)
3552 (make-local-variable 'gnus-article-charset)
3553 (make-local-variable 'gnus-article-ignored-charsets)
3554 (gnus-set-default-directory)
3555 (buffer-disable-undo)
3556 (setq buffer-read-only t)
3557 (set-syntax-table gnus-article-mode-syntax-table)
3558 (mm-enable-multibyte)
3559 (gnus-run-hooks 'gnus-article-mode-hook))
3561 (defun gnus-article-setup-buffer ()
3562 "Initialize the article buffer."
3563 (let* ((name (if gnus-single-article-buffer "*Article*"
3564 (concat "*Article " gnus-newsgroup-name "*")))
3566 (progn (string-match "\\*Article" name)
3567 (concat " *Original Article"
3568 (substring name (match-end 0))))))
3569 (setq gnus-article-buffer name)
3570 (setq gnus-original-article-buffer original)
3571 (setq gnus-article-mime-handle-alist nil)
3572 ;; This might be a variable local to the summary buffer.
3573 (unless gnus-single-article-buffer
3575 (set-buffer gnus-summary-buffer)
3576 (setq gnus-article-buffer name)
3577 (setq gnus-original-article-buffer original)
3578 (gnus-set-global-variables)))
3579 (gnus-article-setup-highlight-words)
3580 ;; Init original article buffer.
3582 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3583 (mm-enable-multibyte)
3584 (setq major-mode 'gnus-original-article-mode)
3585 (make-local-variable 'gnus-original-article))
3586 (if (get-buffer name)
3589 (when (and gnus-article-edit-mode
3592 (y-or-n-p "Article mode edit in progress; discard? ")))
3593 (error "Action aborted"))
3594 (set (make-local-variable 'gnus-article-edit-mode) nil)
3595 (when gnus-article-mime-handles
3596 (mm-destroy-parts gnus-article-mime-handles)
3597 (setq gnus-article-mime-handles nil))
3598 ;; Set it to nil in article-buffer!
3599 (setq gnus-article-mime-handle-alist nil)
3600 (buffer-disable-undo)
3601 (setq buffer-read-only t)
3602 ;; This list just keeps growing if we don't reset it.
3603 (setq gnus-button-marker-list nil)
3604 (unless (eq major-mode 'gnus-article-mode)
3605 (gnus-article-mode))
3608 (set-buffer (gnus-get-buffer-create name))
3610 (make-local-variable 'gnus-summary-buffer)
3611 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3612 (current-buffer)))))
3614 ;; Set article window start at LINE, where LINE is the number of lines
3615 ;; from the head of the article.
3616 (defun gnus-article-set-window-start (&optional line)
3618 (gnus-get-buffer-window gnus-article-buffer t)
3620 (set-buffer gnus-article-buffer)
3621 (goto-char (point-min))
3624 (gnus-message 6 "Moved to bookmark")
3625 (search-forward "\n\n" nil t)
3629 (defun gnus-article-prepare (article &optional all-headers header)
3630 "Prepare ARTICLE in article mode buffer.
3631 ARTICLE should either be an article number or a Message-ID.
3632 If ARTICLE is an id, HEADER should be the article headers.
3633 If ALL-HEADERS is non-nil, no headers are hidden."
3635 ;; Make sure we start in a summary buffer.
3636 (unless (eq major-mode 'gnus-summary-mode)
3637 (set-buffer gnus-summary-buffer))
3638 (setq gnus-summary-buffer (current-buffer))
3639 (let* ((gnus-article (if header (mail-header-number header) article))
3640 (summary-buffer (current-buffer))
3641 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3642 (group gnus-newsgroup-name)
3645 (gnus-article-setup-buffer)
3646 (set-buffer gnus-article-buffer)
3647 ;; Deactivate active regions.
3648 (when (and (boundp 'transient-mark-mode)
3649 transient-mark-mode)
3650 (setq mark-active nil))
3651 (if (not (setq result (let ((buffer-read-only nil))
3652 (gnus-request-article-this-buffer
3654 ;; There is no such article.
3656 (when (and (numberp article)
3657 (not (memq article gnus-newsgroup-sparse)))
3658 (setq gnus-article-current
3659 (cons gnus-newsgroup-name article))
3660 (set-buffer gnus-summary-buffer)
3661 (setq gnus-current-article article)
3662 (if (and (memq article gnus-newsgroup-undownloaded)
3663 (not (gnus-online (gnus-find-method-for-group
3664 gnus-newsgroup-name))))
3666 (gnus-summary-set-agent-mark article)
3667 (message "Message marked for downloading"))
3668 (gnus-summary-mark-article article gnus-canceled-mark)
3669 (unless (memq article gnus-newsgroup-sparse)
3670 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3671 (if (or (eq result 'pseudo)
3672 (eq result 'nneething))
3675 (set-buffer summary-buffer)
3676 (push article gnus-newsgroup-history)
3677 (setq gnus-last-article gnus-current-article
3678 gnus-current-article 0
3679 gnus-current-headers nil
3680 gnus-article-current nil)
3681 (if (eq result 'nneething)
3682 (gnus-configure-windows 'summary)
3683 (gnus-configure-windows 'article))
3684 (gnus-set-global-variables))
3685 (let ((gnus-article-mime-handle-alist-1
3686 gnus-article-mime-handle-alist))
3687 (gnus-set-mode-line 'article)))
3688 ;; The result from the `request' was an actual article -
3689 ;; or at least some text that is now displayed in the
3691 (when (and (numberp article)
3692 (not (eq article gnus-current-article)))
3693 ;; Seems like a new article has been selected.
3694 ;; `gnus-current-article' must be an article number.
3696 (set-buffer summary-buffer)
3697 (push article gnus-newsgroup-history)
3698 (setq gnus-last-article gnus-current-article
3699 gnus-current-article article
3700 gnus-current-headers
3701 (gnus-summary-article-header gnus-current-article)
3702 gnus-article-current
3703 (cons gnus-newsgroup-name gnus-current-article))
3704 (unless (vectorp gnus-current-headers)
3705 (setq gnus-current-headers nil))
3706 (gnus-summary-goto-subject gnus-current-article)
3707 (when (gnus-summary-show-thread)
3708 ;; If the summary buffer really was folded, the
3709 ;; previous goto may not actually have gone to
3710 ;; the right article, but the thread root instead.
3712 (gnus-summary-goto-subject gnus-current-article))
3713 (gnus-run-hooks 'gnus-mark-article-hook)
3714 (gnus-set-mode-line 'summary)
3715 (when (gnus-visual-p 'article-highlight 'highlight)
3716 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3717 ;; Set the global newsgroup variables here.
3718 (gnus-set-global-variables)
3719 (setq gnus-have-all-headers
3720 (or all-headers gnus-show-all-headers))))
3722 (gnus-configure-windows 'article))
3723 (when (or (numberp article)
3725 (gnus-article-prepare-display)
3727 (goto-char (point-min))
3728 (setq gnus-page-broken
3729 (when gnus-break-pages
3730 (gnus-narrow-to-page)
3732 (let ((gnus-article-mime-handle-alist-1
3733 gnus-article-mime-handle-alist))
3734 (gnus-set-mode-line 'article))
3738 (set-window-point (get-buffer-window (current-buffer)) (point))
3739 (gnus-configure-windows 'article)
3743 (defun gnus-article-prepare-display ()
3744 "Make the current buffer look like a nice article."
3745 ;; Hooks for getting information from the article.
3746 ;; This hook must be called before being narrowed.
3747 (let ((gnus-article-buffer (current-buffer))
3749 (unless (eq major-mode 'gnus-article-mode)
3750 (gnus-article-mode))
3751 (setq buffer-read-only nil
3752 gnus-article-wash-types nil
3753 gnus-article-image-alist nil)
3754 (gnus-run-hooks 'gnus-tmp-internal-hook)
3755 (when gnus-display-mime-function
3756 (funcall gnus-display-mime-function))
3757 (gnus-run-hooks 'gnus-article-prepare-hook)))
3760 ;;; Gnus MIME viewing functions
3763 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3764 "Format of the MIME buttons.
3766 Valid specifiers include:
3768 %T MIME type, along with additional info
3769 %n The `name' parameter
3770 %d The description, if any
3771 %l The length of the encoded part
3772 %p The part identifier number
3773 %e Dots if the part isn't displayed
3775 General format specifiers can also be used. See Info node
3776 `(gnus)Formatting Variables'.")
3778 (defvar gnus-mime-button-line-format-alist
3779 '((?t gnus-tmp-type ?s)
3780 (?T gnus-tmp-type-long ?s)
3781 (?n gnus-tmp-name ?s)
3782 (?d gnus-tmp-description ?s)
3784 (?l gnus-tmp-length ?d)
3785 (?e gnus-tmp-dots ?s)))
3787 (defvar gnus-mime-button-commands
3788 '((gnus-article-press-button "\r" "Toggle Display")
3789 (gnus-mime-view-part "v" "View Interactively...")
3790 (gnus-mime-view-part-as-type "t" "View As Type...")
3791 (gnus-mime-view-part-as-charset "C" "View As charset...")
3792 (gnus-mime-save-part "o" "Save...")
3793 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3794 (gnus-mime-delete-part "d" "Delete part")
3795 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3796 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3797 (gnus-mime-view-part-internally "E" "View Internally")
3798 (gnus-mime-view-part-externally "e" "View Externally")
3799 (gnus-mime-print-part "p" "Print")
3800 (gnus-mime-pipe-part "|" "Pipe To Command...")
3801 (gnus-mime-action-on-part "." "Take action on the part...")))
3803 (defun gnus-article-mime-part-status ()
3804 (if gnus-article-mime-handle-alist-1
3805 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3807 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3810 (defvar gnus-mime-button-map
3811 (let ((map (make-sparse-keymap)))
3812 (unless (>= (string-to-number emacs-version) 21)
3813 ;; XEmacs doesn't care.
3814 (set-keymap-parent map gnus-article-mode-map))
3815 (define-key map gnus-mouse-2 'gnus-article-push-button)
3816 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3817 (dolist (c gnus-mime-button-commands)
3818 (define-key map (cadr c) (car c)))
3821 (easy-menu-define gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
3823 ,@(mapcar (lambda (c)
3824 (vector (caddr c) (car c) :enable t)) gnus-mime-button-commands)))
3827 (define-compiler-macro popup-menu (&whole form
3828 menu &optional position prefix)
3829 (if (and (fboundp 'popup-menu)
3830 (not (memq 'popup-menu (assoc "lmenu" load-history))))
3832 ;; Gnus is probably running under Emacs 20.
3833 `(let* ((menu (cdr ,menu))
3834 (response (x-popup-menu
3836 (cons "" (mapcar (lambda (c)
3837 (cons (caddr c) (car c)))
3840 (call-interactively (nth 3 (assq response menu))))))))
3842 (defun gnus-mime-button-menu (event prefix)
3843 "Construct a context-sensitive menu of MIME commands."
3844 (interactive "e\nP")
3845 (save-window-excursion
3846 (let ((pos (event-start event)))
3847 (select-window (posn-window pos))
3848 (goto-char (posn-point pos))
3849 (gnus-article-check-buffer)
3850 (popup-menu gnus-mime-button-menu nil prefix))))
3852 (defun gnus-mime-view-all-parts (&optional handles)
3853 "View all the MIME parts."
3855 (save-current-buffer
3856 (set-buffer gnus-article-buffer)
3857 (let ((handles (or handles gnus-article-mime-handles))
3858 (mail-parse-charset gnus-newsgroup-charset)
3859 (mail-parse-ignored-charsets
3860 (with-current-buffer gnus-summary-buffer
3861 gnus-newsgroup-ignored-charsets)))
3863 (mm-remove-parts handles)
3864 (goto-char (point-min))
3865 (or (search-forward "\n\n") (goto-char (point-max)))
3866 (let (buffer-read-only)
3867 (delete-region (point) (point-max))
3868 (mm-display-parts handles))))))
3870 (defun gnus-mime-save-part-and-strip ()
3871 "Save the MIME part under point then replace it with an external body."
3873 (gnus-article-check-buffer)
3874 (let* ((data (get-text-property (point) 'gnus-data))
3876 (handles gnus-article-mime-handles))
3877 (if (mm-multiple-handles gnus-article-mime-handles)
3878 (error "This function is not implemented"))
3879 (setq file (and data (mm-save-part data)))
3881 (with-current-buffer (mm-handle-buffer data)
3883 (insert "Content-Type: " (mm-handle-media-type data))
3884 (mml-insert-parameter-string (cdr (mm-handle-type data))
3887 (insert "Content-ID: " (message-make-message-id) "\n")
3888 (insert "Content-Transfer-Encoding: binary\n")
3891 (cdr (mm-make-handle nil
3892 `("message/external-body"
3893 (access-type . "LOCAL-FILE")
3895 (set-buffer gnus-summary-buffer)
3896 (gnus-article-edit-article
3899 (let ((mail-parse-charset (or gnus-article-charset
3900 ',gnus-newsgroup-charset))
3901 (mail-parse-ignored-charsets
3902 (or gnus-article-ignored-charsets
3903 ',gnus-newsgroup-ignored-charsets))
3904 (mbl mml-buffer-list))
3905 (setq mml-buffer-list nil)
3906 (insert-buffer gnus-original-article-buffer)
3907 (mime-to-mml ',handles)
3908 (setq gnus-article-mime-handles nil)
3909 (let ((mbl1 mml-buffer-list))
3910 (setq mml-buffer-list mbl)
3911 (set (make-local-variable 'mml-buffer-list) mbl1))
3912 ;; LOCAL argument of add-hook differs between GNU Emacs
3913 ;; and XEmacs. make-local-hook makes sure they are local.
3914 (make-local-hook 'kill-buffer-hook)
3915 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3916 `(lambda (no-highlight)
3917 (let ((mail-parse-charset (or gnus-article-charset
3918 ',gnus-newsgroup-charset))
3919 (message-options message-options)
3920 (message-options-set-recipient)
3921 (mail-parse-ignored-charsets
3922 (or gnus-article-ignored-charsets
3923 ',gnus-newsgroup-ignored-charsets)))
3925 (mml-destroy-buffers)
3926 (remove-hook 'kill-buffer-hook
3927 'mml-destroy-buffers t)
3928 (kill-local-variable 'mml-buffer-list))
3929 (gnus-summary-edit-article-done
3930 ,(or (mail-header-references gnus-current-headers) "")
3931 ,(gnus-group-read-only-p)
3932 ,gnus-summary-buffer no-highlight))))))
3934 (defun gnus-mime-delete-part ()
3935 "Delete the MIME part under point.
3936 Replace it with some information about the removed part."
3938 (gnus-article-check-buffer)
3939 (let* ((data (get-text-property (point) 'gnus-data))
3940 (handles gnus-article-mime-handles)
3944 (mail-decode-encoded-word-string (or (mm-handle-description data)
3947 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
3949 (type (mm-handle-media-type data)))
3950 (if (mm-multiple-handles gnus-article-mime-handles)
3951 (error "This function is not implemented"))
3952 (with-current-buffer (mm-handle-buffer data)
3953 (let ((bsize (format "%s" (buffer-size))))
3957 "<#part type=text/plain nofile=yes disposition=attachment"
3958 " description=\"Deleted attachment (" bsize " Byte)\">"
3960 "| The following attachment has been deleted:\n"
3962 "| Type: " type "\n"
3963 "| Filename: " filename "\n"
3964 "| Size (encoded): " bsize " Byte\n"
3965 "| Description: " description "\n"
3969 (cdr (mm-make-handle nil `("text/plain"))))))
3970 (set-buffer gnus-summary-buffer)
3971 ;; FIXME: maybe some of the following code (borrowed from
3972 ;; `gnus-mime-save-part-and-strip') isn't necessary?
3973 (gnus-article-edit-article
3976 (let ((mail-parse-charset (or gnus-article-charset
3977 ',gnus-newsgroup-charset))
3978 (mail-parse-ignored-charsets
3979 (or gnus-article-ignored-charsets
3980 ',gnus-newsgroup-ignored-charsets))
3981 (mbl mml-buffer-list))
3982 (setq mml-buffer-list nil)
3983 (insert-buffer gnus-original-article-buffer)
3984 (mime-to-mml ',handles)
3985 (setq gnus-article-mime-handles nil)
3986 (let ((mbl1 mml-buffer-list))
3987 (setq mml-buffer-list mbl)
3988 (set (make-local-variable 'mml-buffer-list) mbl1))
3989 ;; LOCAL argument of add-hook differs between GNU Emacs
3990 ;; and XEmacs. make-local-hook makes sure they are local.
3991 (make-local-hook 'kill-buffer-hook)
3992 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3993 `(lambda (no-highlight)
3994 (let ((mail-parse-charset (or gnus-article-charset
3995 ',gnus-newsgroup-charset))
3996 (message-options message-options)
3997 (message-options-set-recipient)
3998 (mail-parse-ignored-charsets
3999 (or gnus-article-ignored-charsets
4000 ',gnus-newsgroup-ignored-charsets)))
4002 (mml-destroy-buffers)
4003 (remove-hook 'kill-buffer-hook
4004 'mml-destroy-buffers t)
4005 (kill-local-variable 'mml-buffer-list))
4006 (gnus-summary-edit-article-done
4007 ,(or (mail-header-references gnus-current-headers) "")
4008 ,(gnus-group-read-only-p)
4009 ,gnus-summary-buffer no-highlight))))
4010 ;; Not in `gnus-mime-save-part-and-strip':
4011 (gnus-article-edit-done)
4012 (gnus-summary-expand-window)
4013 (gnus-summary-show-article))
4015 (defun gnus-mime-save-part ()
4016 "Save the MIME part under point."
4018 (gnus-article-check-buffer)
4019 (let ((data (get-text-property (point) 'gnus-data)))
4021 (mm-save-part data))))
4023 (defun gnus-mime-pipe-part ()
4024 "Pipe the MIME part under point to a process."
4026 (gnus-article-check-buffer)
4027 (let ((data (get-text-property (point) 'gnus-data)))
4029 (mm-pipe-part data))))
4031 (defun gnus-mime-view-part ()
4032 "Interactively choose a viewing method for the MIME part under point."
4034 (gnus-article-check-buffer)
4035 (let ((data (get-text-property (point) 'gnus-data)))
4037 (setq gnus-article-mime-handles
4039 gnus-article-mime-handles (setq data (copy-sequence data))))
4040 (mm-interactively-view-part data))))
4042 (defun gnus-mime-view-part-as-type-internal ()
4043 (gnus-article-check-buffer)
4044 (let* ((name (mail-content-type-get
4045 (mm-handle-type (get-text-property (point) 'gnus-data))
4047 (def-type (and name (mm-default-file-encoding name))))
4048 (and def-type (cons def-type 0))))
4050 (defun gnus-mime-view-part-as-type (&optional mime-type)
4051 "Choose a MIME media type, and view the part as such."
4054 (setq mime-type (completing-read
4055 "View as MIME type: "
4056 (mapcar #'list (mailcap-mime-types))
4058 (gnus-mime-view-part-as-type-internal))))
4059 (gnus-article-check-buffer)
4060 (let ((handle (get-text-property (point) 'gnus-data)))
4063 (mm-make-handle (mm-handle-buffer handle)
4064 (cons mime-type (cdr (mm-handle-type handle)))
4065 (mm-handle-encoding handle)
4066 (mm-handle-undisplayer handle)
4067 (mm-handle-disposition handle)
4068 (mm-handle-description handle)
4070 (mm-handle-id handle)))
4071 (setq gnus-article-mime-handles
4072 (mm-merge-handles gnus-article-mime-handles handle))
4073 (gnus-mm-display-part handle))))
4076 (require 'jka-compr))
4078 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4079 ;; emacs can do that itself.
4081 (defun gnus-mime-jka-compr-maybe-uncompress ()
4082 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4083 The uncompress method used is derived from `buffer-file-name'."
4084 (when (and (fboundp 'jka-compr-installed-p)
4085 (jka-compr-installed-p))
4086 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4088 (let ((basename (file-name-nondirectory buffer-file-name))
4089 (args (jka-compr-info-uncompress-args info))
4090 (prog (jka-compr-info-uncompress-program info))
4091 (message (jka-compr-info-uncompress-message info))
4092 (err-file (jka-compr-make-temp-name)))
4094 (message "%s %s..." message basename))
4096 (unless (memq (apply 'call-process-region
4097 (point-min) (point-max)
4099 t (list t err-file) nil
4101 jka-compr-acceptable-retval-list)
4102 (jka-compr-error prog args basename message err-file))
4103 (jka-compr-delete-temp-file err-file)))))))
4105 (defun gnus-mime-copy-part (&optional handle)
4106 "Put the MIME part under point into a new buffer.
4107 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4110 (gnus-article-check-buffer)
4111 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4112 (contents (and handle (mm-get-part handle)))
4114 (file-name-nondirectory
4116 (mail-content-type-get (mm-handle-type handle) 'name)
4117 (mail-content-type-get (mm-handle-disposition handle)
4120 (buffer (and base (generate-new-buffer base))))
4122 (switch-to-buffer buffer)
4124 ;; We do it this way to make `normal-mode' set the appropriate mode.
4127 (setq buffer-file-name (expand-file-name base))
4128 (gnus-mime-jka-compr-maybe-uncompress)
4130 (setq buffer-file-name nil))
4131 (goto-char (point-min)))))
4133 (defun gnus-mime-print-part (&optional handle filename)
4134 "Print the MIME part under point."
4135 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4136 (gnus-article-check-buffer)
4137 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4138 (contents (and handle (mm-get-part handle)))
4139 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4140 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4145 (mm-save-part-to-file handle file)
4146 (call-process shell-file-name nil
4147 (generate-new-buffer " *mm*")
4149 shell-command-switch
4151 printer file (mm-handle-type handle))))
4155 (gnus-print-buffer))
4156 (ps-despool filename)))))
4158 (defun gnus-mime-inline-part (&optional handle arg)
4159 "Insert the MIME part under point into the current buffer."
4160 (interactive (list nil current-prefix-arg))
4161 (gnus-article-check-buffer)
4162 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4167 (if (and (not arg) (mm-handle-undisplayer handle))
4168 (mm-remove-part handle)
4169 (setq contents (mm-get-part handle))
4172 (setq charset (or (mail-content-type-get
4173 (mm-handle-type handle) 'charset)
4174 gnus-newsgroup-charset)))
4176 (if (mm-handle-undisplayer handle)
4177 (mm-remove-part handle))
4180 gnus-summary-show-article-charset-alist))
4181 (mm-read-coding-system "Charset: ")))))
4183 (mm-insert-inline handle
4185 (setq charset (mm-charset-to-coding-system
4187 (not (eq charset 'ascii)))
4188 (mm-decode-coding-string contents charset)
4192 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4193 "Insert the MIME part under point into the current buffer using the
4195 (interactive (list nil current-prefix-arg))
4196 (gnus-article-check-buffer)
4197 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4202 (if (mm-handle-undisplayer handle)
4203 (mm-remove-part handle))
4204 (let ((gnus-newsgroup-charset
4206 gnus-summary-show-article-charset-alist))
4207 (mm-read-coding-system "Charset: ")))
4208 (gnus-newsgroup-ignored-charsets 'gnus-all))
4209 (gnus-article-press-button)))))
4211 (defun gnus-mime-view-part-externally (&optional handle)
4212 "View the MIME part under point with an external viewer."
4214 (gnus-article-check-buffer)
4215 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4216 (mm-user-display-methods nil)
4217 (mm-inlined-types nil)
4218 (mail-parse-charset gnus-newsgroup-charset)
4219 (mail-parse-ignored-charsets
4220 (save-excursion (set-buffer gnus-summary-buffer)
4221 gnus-newsgroup-ignored-charsets)))
4223 (if (mm-handle-undisplayer handle)
4224 (mm-remove-part handle)
4225 (mm-display-part handle)))))
4227 (defun gnus-mime-view-part-internally (&optional handle)
4228 "View the MIME part under point with an internal viewer.
4229 If no internal viewer is available, use an external viewer."
4231 (gnus-article-check-buffer)
4232 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4233 (mm-inlined-types '(".*"))
4234 (mm-inline-large-images t)
4235 (mail-parse-charset gnus-newsgroup-charset)
4236 (mail-parse-ignored-charsets
4237 (save-excursion (set-buffer gnus-summary-buffer)
4238 gnus-newsgroup-ignored-charsets))
4241 (if (mm-handle-undisplayer handle)
4242 (mm-remove-part handle)
4243 (mm-display-part handle)))))
4245 (defun gnus-mime-action-on-part (&optional action)
4246 "Do something with the MIME attachment at \(point\)."
4248 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4249 (gnus-article-check-buffer)
4250 (let ((action-pair (assoc action gnus-mime-action-alist)))
4252 (funcall (cdr action-pair)))))
4254 (defun gnus-article-part-wrapper (n function)
4255 (save-current-buffer
4256 (set-buffer gnus-article-buffer)
4257 (when (> n (length gnus-article-mime-handle-alist))
4258 (error "No such part"))
4259 (gnus-article-goto-part n)
4260 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4261 (funcall function handle))))
4263 (defun gnus-article-pipe-part (n)
4264 "Pipe MIME part N, which is the numerical prefix."
4266 (gnus-article-part-wrapper n 'mm-pipe-part))
4268 (defun gnus-article-save-part (n)
4269 "Save MIME part N, which is the numerical prefix."
4271 (gnus-article-part-wrapper n 'mm-save-part))
4273 (defun gnus-article-interactively-view-part (n)
4274 "View MIME part N interactively, which is the numerical prefix."
4276 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4278 (defun gnus-article-copy-part (n)
4279 "Copy MIME part N, which is the numerical prefix."
4281 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4283 (defun gnus-article-view-part-as-charset (n)
4284 "Copy MIME part N, which is the numerical prefix."
4286 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4288 (defun gnus-article-view-part-externally (n)
4289 "View MIME part N externally, which is the numerical prefix."
4291 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4293 (defun gnus-article-inline-part (n)
4294 "Inline MIME part N, which is the numerical prefix."
4296 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4298 (defun gnus-article-mime-match-handle-first (condition)
4300 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4301 (while (setq ihandle (pop alist))
4303 ((functionp condition)
4304 (funcall condition (cdr ihandle)))
4305 ((eq condition 'undisplayed)
4306 (not (or (mm-handle-undisplayer (cdr ihandle))
4307 (equal (mm-handle-media-type (cdr ihandle))
4308 "multipart/alternative"))))
4309 ((eq condition 'undisplayed-alternative)
4310 (not (mm-handle-undisplayer (cdr ihandle))))
4312 (gnus-article-goto-part (car ihandle))
4313 (or (not n) (< (car ihandle) n)))
4314 (setq n (car ihandle))))
4318 (defun gnus-article-view-part (&optional n)
4319 "View MIME part N, which is the numerical prefix."
4321 (save-current-buffer
4322 (set-buffer gnus-article-buffer)
4323 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4324 gnus-article-mime-match-handle-function)))
4325 (when (> n (length gnus-article-mime-handle-alist))
4326 (error "No such part"))
4327 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4328 (when (gnus-article-goto-part n)
4329 (if (equal (car handle) "multipart/alternative")
4330 (gnus-article-press-button)
4331 (when (eq (gnus-mm-display-part handle) 'internal)
4332 (gnus-set-window-start)))))))
4334 (defsubst gnus-article-mime-total-parts ()
4335 (if (bufferp (car gnus-article-mime-handles))
4337 (1- (length gnus-article-mime-handles))))
4339 (defun gnus-mm-display-part (handle)
4340 "Display HANDLE and fix MIME button."
4341 (let ((id (get-text-property (point) 'gnus-part))
4346 (let ((window (selected-window))
4347 (mail-parse-charset gnus-newsgroup-charset)
4348 (mail-parse-ignored-charsets
4349 (if (gnus-buffer-live-p gnus-summary-buffer)
4351 (set-buffer gnus-summary-buffer)
4352 gnus-newsgroup-ignored-charsets)
4356 (let ((win (gnus-get-buffer-window (current-buffer) t))
4359 (select-window win))
4362 (if (mm-handle-displayed-p handle)
4363 ;; This will remove the part.
4364 (mm-display-part handle)
4366 (narrow-to-region (point)
4367 (if (eobp) (point) (1+ (point))))
4368 (mm-display-part handle)
4369 ;; We narrow to the part itself and
4370 ;; then call the treatment functions.
4371 (goto-char (point-min))
4373 (narrow-to-region (point) (point-max))
4376 (gnus-article-mime-total-parts)
4377 (mm-handle-media-type handle)))))
4378 (if (window-live-p window)
4379 (select-window window)))))
4382 (gnus-insert-mime-button
4383 handle id (list (mm-handle-displayed-p handle)))
4384 (goto-char point))))
4386 (defun gnus-article-goto-part (n)
4387 "Go to MIME part N."
4388 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4390 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4391 (let ((gnus-tmp-name
4392 (or (mail-content-type-get (mm-handle-type handle) 'name)
4393 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4394 (mail-content-type-get (mm-handle-type handle) 'url)
4396 (gnus-tmp-type (mm-handle-media-type handle))
4397 (gnus-tmp-description
4398 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4401 (if (if displayed (car displayed)
4402 (mm-handle-displayed-p handle))
4404 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4406 gnus-tmp-type-long b e)
4407 (when (string-match ".*/" gnus-tmp-name)
4408 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4409 (setq gnus-tmp-type-long (concat gnus-tmp-type
4410 (and (not (equal gnus-tmp-name ""))
4411 (concat "; " gnus-tmp-name))))
4412 (unless (equal gnus-tmp-description "")
4413 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4418 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4419 `(,@(gnus-local-map-property gnus-mime-button-map)
4420 gnus-callback gnus-mm-display-part
4421 gnus-part ,gnus-tmp-id
4422 article-type annotation
4425 ;; Exclude a newline.
4428 (widget-convert-button
4431 :action 'gnus-widget-press-button
4432 :button-keymap gnus-mime-button-map
4434 (lambda (widget/window &optional overlay pos)
4435 ;; Needed to properly clear the message due to a bug in
4436 ;; wid-edit (XEmacs only).
4437 (if (boundp 'help-echo-owns-message)
4438 (setq help-echo-owns-message t))
4440 "%S: %s the MIME part; %S: more options"
4441 (aref gnus-mouse-2 0)
4442 ;; XEmacs will get a single widget arg; Emacs 21 will get
4443 ;; window, overlay, position.
4444 (if (mm-handle-displayed-p
4446 (with-current-buffer (gnus-overlay-buffer overlay)
4447 (widget-get (widget-at (gnus-overlay-start overlay))
4449 (widget-get widget/window :mime-handle)))
4451 (aref gnus-down-mouse-3 0))))))
4453 (defun gnus-widget-press-button (elems el)
4454 (goto-char (widget-get elems :from))
4455 (gnus-article-press-button))
4457 (defvar gnus-displaying-mime nil)
4459 (defun gnus-display-mime (&optional ihandles)
4460 "Display the MIME parts."
4462 (save-selected-window
4463 (let ((window (get-buffer-window gnus-article-buffer))
4466 (select-window window)
4467 ;; We have to do this since selecting the window
4468 ;; may change the point. So we set the window point.
4469 (set-window-point window point)))
4470 (let* ((handles (or ihandles
4471 (mm-dissect-buffer nil gnus-article-loose-mime)
4472 (and gnus-article-emulate-mime
4474 buffer-read-only handle name type b e display)
4475 (when (and (not ihandles)
4476 (not gnus-displaying-mime))
4477 ;; Top-level call; we clean up.
4478 (when gnus-article-mime-handles
4479 (mm-destroy-parts gnus-article-mime-handles)
4480 (setq gnus-article-mime-handle-alist nil));; A trick.
4481 (setq gnus-article-mime-handles handles)
4482 ;; We allow users to glean info from the handles.
4483 (when gnus-article-mime-part-function
4484 (gnus-mime-part-function handles)))
4486 (or (not (stringp (car handles)))
4489 (when (and (not ihandles)
4490 (not gnus-displaying-mime))
4491 ;; Clean up for mime parts.
4493 (delete-region (point) (point-max)))
4494 (let ((gnus-displaying-mime t))
4495 (gnus-mime-display-part handles)))
4498 (narrow-to-region (point) (point-max))
4499 (gnus-treat-article nil 1 1)
4502 ;; Highlight the headers.
4506 (narrow-to-region (point-min) (point))
4507 (gnus-treat-article 'head))))))))
4509 (defvar gnus-mime-display-multipart-as-mixed nil)
4510 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4511 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4513 (defun gnus-mime-display-part (handle)
4516 ((not (stringp (car handle)))
4517 (gnus-mime-display-single handle))
4518 ;; User-defined multipart
4519 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4520 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4522 ;; multipart/alternative
4523 ((and (equal (car handle) "multipart/alternative")
4524 (not (or gnus-mime-display-multipart-as-mixed
4525 gnus-mime-display-multipart-alternative-as-mixed)))
4526 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4527 (push (cons id handle) gnus-article-mime-handle-alist)
4528 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4529 ;; multipart/related
4530 ((and (equal (car handle) "multipart/related")
4531 (not (or gnus-mime-display-multipart-as-mixed
4532 gnus-mime-display-multipart-related-as-mixed)))
4533 ;;;!!!We should find the start part, but we just default
4534 ;;;!!!to the first part.
4535 ;;(gnus-mime-display-part (cadr handle))
4536 ;;;!!! Most multipart/related is an HTML message plus images.
4537 ;;;!!! Unfortunately we are unable to let W3 display those
4538 ;;;!!! included images, so we just display it as a mixed multipart.
4539 ;;(gnus-mime-display-mixed (cdr handle))
4540 ;;;!!! No, w3 can display everything just fine.
4541 (gnus-mime-display-part (cadr handle)))
4542 ((equal (car handle) "multipart/signed")
4543 (gnus-add-wash-type 'signed)
4544 (gnus-mime-display-security handle))
4545 ((equal (car handle) "multipart/encrypted")
4546 (gnus-add-wash-type 'encrypted)
4547 (gnus-mime-display-security handle))
4548 ;; Other multiparts are handled like multipart/mixed.
4550 (gnus-mime-display-mixed (cdr handle)))))
4552 (defun gnus-mime-part-function (handles)
4553 (if (stringp (car handles))
4554 (mapcar 'gnus-mime-part-function (cdr handles))
4555 (funcall gnus-article-mime-part-function handles)))
4557 (defun gnus-mime-display-mixed (handles)
4558 (mapcar 'gnus-mime-display-part handles))
4560 (defun gnus-mime-display-single (handle)
4561 (let ((type (mm-handle-media-type handle))
4562 (ignored gnus-ignored-mime-types)
4569 (when (string-match (pop ignored) type)
4570 (throw 'ignored nil)))
4571 (if (and (setq not-attachment
4572 (and (not (mm-inline-override-p handle))
4573 (or (not (mm-handle-disposition handle))
4574 (equal (car (mm-handle-disposition handle))
4576 (mm-attachment-override-p handle))))
4577 (mm-automatic-display-p handle)
4579 (mm-inlinable-p handle)
4580 (mm-inlined-p handle))
4581 (mm-automatic-external-display-p type)))
4583 (when (equal (mm-handle-media-supertype handle) "text")
4585 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4587 (push (cons id handle) gnus-article-mime-handle-alist)
4588 (when (or (not display)
4589 (not (gnus-unbuttonized-mime-type-p type)))
4590 ;(gnus-article-insert-newline)
4591 (gnus-insert-mime-button
4592 handle id (list (or display (and not-attachment text))))
4593 (gnus-article-insert-newline)
4594 ;(gnus-article-insert-newline)
4595 ;; Remember modify the number of forward lines.
4603 (let ((mail-parse-charset gnus-newsgroup-charset)
4604 (mail-parse-ignored-charsets
4605 (save-excursion (condition-case ()
4606 (set-buffer gnus-summary-buffer)
4608 gnus-newsgroup-ignored-charsets)))
4609 (mm-display-part handle t))
4610 (goto-char (point-max)))
4611 ((and text not-attachment)
4615 (gnus-article-insert-newline)
4616 (mm-insert-inline handle (mm-get-part handle))
4617 (goto-char (point-max))))
4621 (narrow-to-region beg (point))
4624 (gnus-article-mime-total-parts)
4625 (mm-handle-media-type handle)))))))))
4627 (defun gnus-unbuttonized-mime-type-p (type)
4628 "Say whether TYPE is to be unbuttonized."
4629 (unless gnus-inhibit-mime-unbuttonizing
4631 (let ((types gnus-unbuttonized-mime-types))
4633 (when (string-match (pop types) type)
4634 (throw 'found t)))))
4636 (let ((types gnus-buttonized-mime-types))
4638 (when (string-match (pop types) type)
4639 (throw 'found t)))))))))
4641 (defun gnus-article-insert-newline ()
4642 "Insert a newline, but mark it as undeletable."
4643 (gnus-put-text-property
4644 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4646 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4647 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4650 handle buffer-read-only from props begend not-pref)
4651 (save-window-excursion
4654 (narrow-to-region (car ibegend)
4657 (goto-char (car ibegend))
4660 (delete-region (point-min) (point-max))
4661 (mm-remove-parts handles))
4662 (setq begend (list (point-marker)))
4664 (unless (setq not-pref (cadr (member preferred ihandles)))
4665 (setq not-pref (car ihandles)))
4668 (not (gnus-unbuttonized-mime-type-p
4669 "multipart/alternative")))
4670 (gnus-add-text-properties
4673 (insert (format "%d. " id))
4677 (unless ,(not ibegend)
4678 (setq gnus-article-mime-handle-alist
4679 ',gnus-article-mime-handle-alist))
4680 (gnus-mime-display-alternative
4681 ',ihandles ',not-pref ',begend ,id))
4682 ,@(gnus-local-map-property gnus-mime-button-map)
4683 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4684 face ,gnus-article-button-face
4687 (widget-convert-button 'link from (point)
4688 :action 'gnus-widget-press-button
4689 :button-keymap gnus-widget-button-keymap)
4691 (while (setq handle (pop handles))
4692 (gnus-add-text-properties
4695 (insert (format "(%c) %-18s"
4696 (if (equal handle preferred) ?* ? )
4697 (mm-handle-media-type handle)))
4701 (unless ,(not ibegend)
4702 (setq gnus-article-mime-handle-alist
4703 ',gnus-article-mime-handle-alist))
4704 (gnus-mime-display-alternative
4705 ',ihandles ',handle ',begend ,id))
4706 ,@(gnus-local-map-property gnus-mime-button-map)
4707 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4708 face ,gnus-article-button-face
4711 (widget-convert-button 'link from (point)
4712 :action 'gnus-widget-press-button
4713 :button-keymap gnus-widget-button-keymap)
4717 (if (stringp (car preferred))
4718 (gnus-display-mime preferred)
4719 (let ((mail-parse-charset gnus-newsgroup-charset)
4720 (mail-parse-ignored-charsets
4721 (save-excursion (set-buffer gnus-summary-buffer)
4722 gnus-newsgroup-ignored-charsets)))
4723 (mm-display-part preferred)
4727 (narrow-to-region (car begend) (point-max))
4729 nil (length gnus-article-mime-handle-alist)
4730 (gnus-article-mime-total-parts)
4731 (mm-handle-media-type handle))))))
4732 (goto-char (point-max))
4733 (setcdr begend (point-marker)))))
4735 (goto-char point))))
4737 (defconst gnus-article-wash-status-strings
4738 (let ((alist '((cite "c" "Possible hidden citation text"
4739 " " "All citation text visible")
4740 (headers "h" "Hidden headers"
4741 " " "All headers visible.")
4742 (pgp "p" "Encrypted or signed message status hidden"
4743 " " "No hidden encryption nor digital signature status")
4744 (signature "s" "Signature has been hidden"
4745 " " "Signature is visible")
4746 (overstrike "o" "Overstrike (^H) characters applied"
4747 " " "No overstrike characters applied")
4748 (emphasis "e" "/*_Emphasis_*/ characters applied"
4749 " " "No /*_emphasis_*/ characters applied")))
4751 (dolist (entry alist result)
4752 (let ((key (nth 0 entry))
4753 (on (copy-sequence (nth 1 entry)))
4754 (on-help (nth 2 entry))
4755 (off (copy-sequence (nth 3 entry)))
4756 (off-help (nth 4 entry)))
4757 (put-text-property 0 1 'help-echo on-help on)
4758 (put-text-property 0 1 'help-echo off-help off)
4759 (push (list key on off) result))))
4760 "Alist of strings describing wash status in the mode line.
4761 Each entry has the form (KEY ON OF), where the KEY is a symbol
4762 representing the particular washing function, ON is the string to use
4763 in the article mode line when the washing function is active, and OFF
4764 is the string to use when it is inactive.")
4766 (defun gnus-article-wash-status-entry (key value)
4767 (let ((entry (assoc key gnus-article-wash-status-strings)))
4768 (if value (nth 1 entry) (nth 2 entry))))
4770 (defun gnus-article-wash-status ()
4771 "Return a string which display status of article washing."
4773 (set-buffer gnus-article-buffer)
4774 (let ((cite (memq 'cite gnus-article-wash-types))
4775 (headers (memq 'headers gnus-article-wash-types))
4776 (boring (memq 'boring-headers gnus-article-wash-types))
4777 (pgp (memq 'pgp gnus-article-wash-types))
4778 (pem (memq 'pem gnus-article-wash-types))
4779 (signed (memq 'signed gnus-article-wash-types))
4780 (encrypted (memq 'encrypted gnus-article-wash-types))
4781 (signature (memq 'signature gnus-article-wash-types))
4782 (overstrike (memq 'overstrike gnus-article-wash-types))
4783 (emphasis (memq 'emphasis gnus-article-wash-types)))
4785 (gnus-article-wash-status-entry 'cite cite)
4786 (gnus-article-wash-status-entry 'headers (or headers boring))
4787 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4788 (gnus-article-wash-status-entry 'signature signature)
4789 (gnus-article-wash-status-entry 'overstrike overstrike)
4790 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4792 (defun gnus-add-wash-type (type)
4793 "Add a washing of TYPE to the current status."
4794 (add-to-list 'gnus-article-wash-types type))
4796 (defun gnus-delete-wash-type (type)
4797 "Add a washing of TYPE to the current status."
4798 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4800 (defun gnus-add-image (category image)
4801 "Add IMAGE of CATEGORY to the list of displayed images."
4802 (let ((entry (assq category gnus-article-image-alist)))
4804 (setq entry (list category))
4805 (push entry gnus-article-image-alist))
4806 (nconc entry (list image))))
4808 (defun gnus-delete-images (category)
4809 "Delete all images in CATEGORY."
4810 (let ((entry (assq category gnus-article-image-alist)))
4811 (dolist (image (cdr entry))
4812 (gnus-remove-image image))
4813 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4814 (gnus-delete-wash-type category)))
4816 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4818 (defun gnus-article-maybe-hide-headers ()
4819 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4820 Provided for backwards compatibility."
4821 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4822 (not (save-excursion (set-buffer gnus-summary-buffer)
4823 gnus-have-all-headers)))
4824 (not gnus-inhibit-hiding))
4825 (gnus-article-hide-headers)))
4829 (defun gnus-output-to-file (file-name)
4830 "Append the current article to a file named FILE-NAME."
4831 (let ((artbuf (current-buffer)))
4833 (insert-buffer-substring artbuf)
4834 ;; Append newline at end of the buffer as separator, and then
4836 (goto-char (point-max))
4838 (let ((file-name-coding-system nnmail-pathname-coding-system))
4839 (mm-append-to-file (point-min) (point-max) file-name))
4842 (defun gnus-narrow-to-page (&optional arg)
4843 "Narrow the article buffer to a page.
4844 If given a numerical ARG, move forward ARG pages."
4846 (setq arg (if arg (prefix-numeric-value arg) 0))
4848 (set-buffer gnus-article-buffer)
4849 (goto-char (point-min))
4851 ;; Remove any old next/prev buttons.
4852 (when (gnus-visual-p 'page-marker)
4853 (let ((buffer-read-only nil))
4854 (gnus-remove-text-with-property 'gnus-prev)
4855 (gnus-remove-text-with-property 'gnus-next)))
4858 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4860 (re-search-forward page-delimiter nil 'move arg)))
4861 (goto-char (match-end 0)))
4864 (if (re-search-forward page-delimiter nil 'move)
4867 (when (and (gnus-visual-p 'page-marker)
4868 (not (= (point-min) 1)))
4870 (goto-char (point-min))
4871 (gnus-insert-prev-page-button)))
4872 (when (and (gnus-visual-p 'page-marker)
4873 (< (+ (point-max) 2) (buffer-size)))
4875 (goto-char (point-max))
4876 (gnus-insert-next-page-button)))))
4878 ;; Article mode commands
4880 (defun gnus-article-goto-next-page ()
4881 "Show the next page of the article."
4883 (gnus-eval-in-buffer-window gnus-summary-buffer
4884 (gnus-summary-next-page)))
4886 (defun gnus-article-goto-prev-page ()
4887 "Show the next page of the article."
4889 (gnus-eval-in-buffer-window gnus-summary-buffer
4890 (gnus-summary-prev-page)))
4892 (defun gnus-article-next-page (&optional lines)
4893 "Show the next page of the current article.
4894 If end of article, return non-nil. Otherwise return nil.
4895 Argument LINES specifies lines to be scrolled up."
4897 (move-to-window-line -1)
4898 (if (and (not gnus-article-over-scroll)
4901 (and (pos-visible-in-window-p) ;Not continuation line.
4902 (>= (1+ (point)) (point-max))))) ;Allow for trailing newline.
4903 ;; Nothing in this page.
4904 (if (or (not gnus-page-broken)
4907 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4909 (gnus-narrow-to-page 1) ;Go to next page.
4911 ;; More in this page.
4912 (let ((scroll-in-place nil))
4916 ;; Long lines may cause an end-of-buffer error.
4917 (goto-char (point-max)))))
4918 (move-to-window-line 0)
4921 (defun gnus-article-prev-page (&optional lines)
4922 "Show previous page of current article.
4923 Argument LINES specifies lines to be scrolled down."
4925 (move-to-window-line 0)
4926 (if (and gnus-page-broken
4928 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4930 (gnus-narrow-to-page -1) ;Go to previous page.
4931 (goto-char (point-max))
4933 (let ((scroll-in-place nil))
4937 (beginning-of-buffer
4938 (goto-char (point-min))))
4939 (move-to-window-line 0)))))
4941 (defun gnus-article-only-boring-p ()
4942 "Decide whether there is only boring text remaining in the article.
4943 Something \"interesting\" is a word of at least two letters that does
4944 not have a face in `gnus-article-boring-faces'."
4945 (when (and gnus-article-skip-boring
4946 (boundp 'gnus-article-boring-faces)
4947 (symbol-value 'gnus-article-boring-faces))
4950 (while (re-search-forward "\\b\\w\\w" nil t)
4952 (when (not (gnus-intersection
4953 (gnus-faces-at (point))
4954 (symbol-value 'gnus-article-boring-faces)))
4955 (throw 'only-boring nil)))
4956 (throw 'only-boring t)))))
4958 (defun gnus-article-refer-article ()
4959 "Read article specified by message-id around point."
4962 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
4963 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
4964 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
4965 (let ((msg-id (concat "<" (match-string 0) ">")))
4966 (set-buffer gnus-summary-buffer)
4967 (gnus-summary-refer-article msg-id))
4968 (error "No references around point"))))
4970 (defun gnus-article-show-summary ()
4971 "Reconfigure windows to show summary buffer."
4973 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4974 (error "There is no summary buffer for this article buffer")
4975 (gnus-article-set-globals)
4976 (gnus-configure-windows 'article)
4977 (gnus-summary-goto-subject gnus-current-article)
4978 (gnus-summary-position-point)))
4980 (defun gnus-article-describe-briefly ()
4981 "Describe article mode commands briefly."
4983 (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")))
4985 (defun gnus-article-summary-command ()
4986 "Execute the last keystroke in the summary buffer."
4988 (let ((obuf (current-buffer))
4989 (owin (current-window-configuration))
4991 (switch-to-buffer gnus-article-current-summary 'norecord)
4992 (setq func (lookup-key (current-local-map) (this-command-keys)))
4993 (call-interactively func)
4995 (set-window-configuration owin)
4996 (set-window-point (get-buffer-window (current-buffer)) (point))))
4998 (defun gnus-article-summary-command-nosave ()
4999 "Execute the last keystroke in the summary buffer."
5002 (pop-to-buffer gnus-article-current-summary 'norecord)
5003 (setq func (lookup-key (current-local-map) (this-command-keys)))
5004 (call-interactively func)))
5006 (defun gnus-article-check-buffer ()
5007 "Beep if not in an article buffer."
5008 (unless (equal major-mode 'gnus-article-mode)
5009 (error "Command invoked outside of a Gnus article buffer")))
5011 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5012 "Read a summary buffer key sequence and execute it from the article buffer."
5014 (gnus-article-check-buffer)
5016 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5017 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5018 "=" "^" "\M-^" "|"))
5024 '("n" "Gn" "p" "Gp"))
5027 (set-buffer gnus-article-current-summary)
5028 (let (gnus-pick-mode)
5029 (push (or key last-command-event) unread-command-events)
5030 (setq keys (if (featurep 'xemacs)
5031 (events-to-keys (read-key-sequence nil))
5032 (read-key-sequence nil)))))
5036 (if (or (member keys nosaves)
5037 (member keys nosave-but-article)
5038 (member keys nosave-in-article))
5040 (save-window-excursion
5041 (pop-to-buffer gnus-article-current-summary 'norecord)
5042 ;; We disable the pick minor mode commands.
5043 (let (gnus-pick-mode)
5044 (setq func (lookup-key (current-local-map) keys))))
5048 (unless (member keys nosave-in-article)
5049 (set-buffer gnus-article-current-summary))
5050 (call-interactively func)
5051 (setq new-sum-point (point)))
5052 (when (member keys nosave-but-article)
5053 (pop-to-buffer gnus-article-buffer 'norecord)))
5054 ;; These commands should restore window configuration.
5055 (let ((obuf (current-buffer))
5056 (owin (current-window-configuration))
5058 (summary gnus-article-current-summary)
5059 func in-buffer selected)
5060 (if not-restore-window
5061 (pop-to-buffer summary 'norecord)
5062 (switch-to-buffer summary 'norecord))
5063 (setq in-buffer (current-buffer))
5064 ;; We disable the pick minor mode commands.
5065 (if (and (setq func (let (gnus-pick-mode)
5066 (lookup-key (current-local-map) keys)))
5069 (call-interactively func)
5070 (setq new-sum-point (point))
5071 (when (eq in-buffer (current-buffer))
5072 (setq selected (gnus-summary-select-article))
5074 (unless not-restore-window
5075 (set-window-configuration owin))
5076 (when (eq selected 'old)
5078 (set-window-start (get-buffer-window (current-buffer))
5080 (set-window-point (get-buffer-window (current-buffer))
5082 (let ((win (get-buffer-window gnus-article-current-summary)))
5084 (set-window-point win new-sum-point)))) )
5085 (switch-to-buffer gnus-article-buffer)
5088 (defun gnus-article-describe-key (key)
5089 "Display documentation of the function invoked by KEY. KEY is a string."
5090 (interactive "kDescribe key: ")
5091 (gnus-article-check-buffer)
5092 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5094 (set-buffer gnus-article-current-summary)
5095 (let (gnus-pick-mode)
5096 (if (featurep 'xemacs)
5098 (push (elt key 0) unread-command-events)
5099 (setq key (events-to-keys
5100 (read-key-sequence "Describe key: "))))
5101 (setq unread-command-events
5103 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5104 (string-to-list key)))
5105 (setq key (read-key-sequence "Describe key: "))))
5107 (describe-key key)))
5109 (defun gnus-article-describe-key-briefly (key &optional insert)
5110 "Display documentation of the function invoked by KEY. KEY is a string."
5111 (interactive "kDescribe key: \nP")
5112 (gnus-article-check-buffer)
5113 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5115 (set-buffer gnus-article-current-summary)
5116 (let (gnus-pick-mode)
5117 (if (featurep 'xemacs)
5119 (push (elt key 0) unread-command-events)
5120 (setq key (events-to-keys
5121 (read-key-sequence "Describe key: "))))
5122 (setq unread-command-events
5124 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5125 (string-to-list key)))
5126 (setq key (read-key-sequence "Describe key: "))))
5127 (describe-key-briefly key insert))
5128 (describe-key-briefly key insert)))
5130 (defun gnus-article-reply-with-original (&optional wide)
5131 "Start composing a reply mail to the current message.
5132 The text in the region will be yanked. If the region isn't active,
5133 the entire article will be yanked."
5135 (let ((article (cdr gnus-article-current))
5137 (if (not (gnus-mark-active-p))
5138 (with-current-buffer gnus-summary-buffer
5139 (gnus-summary-reply (list (list article)) wide))
5140 (setq contents (buffer-substring (point) (mark t)))
5141 ;; Deactivate active regions.
5142 (when (and (boundp 'transient-mark-mode)
5143 transient-mark-mode)
5144 (setq mark-active nil))
5145 (with-current-buffer gnus-summary-buffer
5147 (list (list article contents)) wide)))))
5149 (defun gnus-article-followup-with-original ()
5150 "Compose a followup to the current article.
5151 The text in the region will be yanked. If the region isn't active,
5152 the entire article will be yanked."
5154 (let ((article (cdr gnus-article-current))
5156 (if (not (gnus-mark-active-p))
5157 (with-current-buffer gnus-summary-buffer
5158 (gnus-summary-followup (list (list article))))
5159 (setq contents (buffer-substring (point) (mark t)))
5160 ;; Deactivate active regions.
5161 (when (and (boundp 'transient-mark-mode)
5162 transient-mark-mode)
5163 (setq mark-active nil))
5164 (with-current-buffer gnus-summary-buffer
5165 (gnus-summary-followup
5166 (list (list article contents)))))))
5168 (defun gnus-article-hide (&optional arg force)
5169 "Hide all the gruft in the current article.
5170 This means that signatures, cited text and (some) headers will be
5172 If given a prefix, show the hidden text instead."
5173 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5174 (gnus-article-hide-headers arg)
5175 (gnus-article-hide-list-identifiers arg)
5176 (gnus-article-hide-citation-maybe arg force)
5177 (gnus-article-hide-signature arg))
5179 (defun gnus-article-maybe-highlight ()
5180 "Do some article highlighting if article highlighting is requested."
5181 (when (gnus-visual-p 'article-highlight 'highlight)
5182 (gnus-article-highlight-some)))
5184 (defun gnus-check-group-server ()
5185 ;; Make sure the connection to the server is alive.
5186 (unless (gnus-server-opened
5187 (gnus-find-method-for-group gnus-newsgroup-name))
5188 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5189 (gnus-request-group gnus-newsgroup-name t)))
5192 (autoload 'nneething-get-file-name "nneething"))
5194 (defun gnus-request-article-this-buffer (article group)
5195 "Get an article and insert it into this buffer."
5196 (let (do-update-line sparse-header)
5200 (gnus-kill-all-overlays)
5201 (setq group (or group gnus-newsgroup-name))
5203 ;; Using `gnus-request-article' directly will insert the article into
5204 ;; `nntp-server-buffer' - so we'll save some time by not having to
5205 ;; copy it from the server buffer into the article buffer.
5207 ;; We only request an article by message-id when we do not have the
5208 ;; headers for it, so we'll have to get those.
5209 (when (stringp article)
5210 (gnus-read-header article))
5212 ;; If the article number is negative, that means that this article
5213 ;; doesn't belong in this newsgroup (possibly), so we find its
5214 ;; message-id and request it by id instead of number.
5215 (when (and (numberp article)
5217 (get-buffer gnus-summary-buffer)
5218 (gnus-buffer-exists-p gnus-summary-buffer))
5220 (set-buffer gnus-summary-buffer)
5221 (let ((header (gnus-summary-article-header article)))
5224 ((memq article gnus-newsgroup-sparse)
5225 ;; This is a sparse gap article.
5226 (setq do-update-line article)
5227 (setq article (mail-header-id header))
5228 (setq sparse-header (gnus-read-header article))
5229 (setq gnus-newsgroup-sparse
5230 (delq article gnus-newsgroup-sparse)))
5232 ;; It's a real article.
5233 (setq article (mail-header-id header)))
5235 ;; It is an extracted pseudo-article.
5236 (setq article 'pseudo)
5237 (gnus-request-pseudo-article header))))
5239 (let ((method (gnus-find-method-for-group
5240 gnus-newsgroup-name)))
5241 (when (and (eq (car method) 'nneething)
5243 (let ((dir (nneething-get-file-name
5244 (mail-header-id header))))
5245 (when (and (stringp dir)
5246 (file-directory-p dir))
5247 (setq article 'nneething)
5248 (gnus-group-enter-directory dir))))))))
5251 ;; Refuse to select canceled articles.
5252 ((and (numberp article)
5254 (get-buffer gnus-summary-buffer)
5255 (gnus-buffer-exists-p gnus-summary-buffer)
5256 (eq (cdr (save-excursion
5257 (set-buffer gnus-summary-buffer)
5258 (assq article gnus-newsgroup-reads)))
5259 gnus-canceled-mark))
5261 ;; We first check `gnus-original-article-buffer'.
5262 ((and (get-buffer gnus-original-article-buffer)
5265 (set-buffer gnus-original-article-buffer)
5266 (and (equal (car gnus-original-article) group)
5267 (eq (cdr gnus-original-article) article))))
5268 (insert-buffer-substring gnus-original-article-buffer)
5270 ;; Check the backlog.
5271 ((and gnus-keep-backlog
5272 (gnus-backlog-request-article group article (current-buffer)))
5274 ;; Check asynchronous pre-fetch.
5275 ((gnus-async-request-fetched-article group article (current-buffer))
5276 (gnus-async-prefetch-next group article gnus-summary-buffer)
5277 (when (and (numberp article) gnus-keep-backlog)
5278 (gnus-backlog-enter-article group article (current-buffer)))
5281 ((and gnus-use-cache
5283 (gnus-cache-request-article article group))
5285 ;; Check the agent cache.
5286 ((gnus-agent-request-article article group)
5288 ;; Get the article and put into the article buffer.
5289 ((or (stringp article)
5291 (let ((gnus-override-method gnus-override-method)
5292 (methods (and (stringp article)
5293 gnus-refer-article-method))
5294 (backend (car (gnus-find-method-for-group
5295 gnus-newsgroup-name)))
5297 (buffer-read-only nil))
5298 (if (or (not (listp methods))
5299 (and (symbolp (car methods))
5300 (assq (car methods) nnoo-definition-alist)))
5301 (setq methods (list methods)))
5302 (when (and (null gnus-override-method)
5304 (setq gnus-override-method (pop methods)))
5306 (when (eq gnus-override-method 'current)
5307 (setq gnus-override-method
5308 (with-current-buffer gnus-summary-buffer
5309 gnus-current-select-method)))
5311 (gnus-kill-all-overlays)
5312 (let ((gnus-newsgroup-name group))
5313 (gnus-check-group-server))
5315 ((gnus-request-article article group (current-buffer))
5316 (when (numberp article)
5317 (gnus-async-prefetch-next group article
5318 gnus-summary-buffer)
5319 (when gnus-keep-backlog
5320 (gnus-backlog-enter-article
5321 group article (current-buffer))))
5322 (setq result 'article))
5324 (setq gnus-override-method (pop methods)))
5325 ((not (string-match "^400 "
5326 (nnheader-get-report backend)))
5327 ;; If we get 400 server disconnect, reconnect and
5328 ;; retry; otherwise, assume the article has expired.
5329 (setq result 'done))))
5330 (and (eq result 'article) 'article)))
5334 ;; Associate this article with the current summary buffer.
5335 (setq gnus-article-current-summary gnus-summary-buffer)
5337 ;; Take the article from the original article buffer
5338 ;; and place it in the buffer it's supposed to be in.
5339 (when (and (get-buffer gnus-article-buffer)
5340 (equal (buffer-name (current-buffer))
5341 (buffer-name (get-buffer gnus-article-buffer))))
5343 (if (get-buffer gnus-original-article-buffer)
5344 (set-buffer gnus-original-article-buffer)
5345 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5346 (buffer-disable-undo)
5347 (setq major-mode 'gnus-original-article-mode)
5348 (setq buffer-read-only t))
5349 (let (buffer-read-only)
5351 (insert-buffer-substring gnus-article-buffer))
5352 (setq gnus-original-article (cons group article)))
5355 (run-hooks 'gnus-article-decode-hook)
5356 ;; Mark article as decoded or not.
5357 (setq gnus-article-decoded-p gnus-article-decode-hook))
5359 ;; Update sparse articles.
5360 (when (and do-update-line
5361 (or (numberp article)
5363 (let ((buf (current-buffer)))
5364 (set-buffer gnus-summary-buffer)
5365 (gnus-summary-update-article do-update-line sparse-header)
5366 (gnus-summary-goto-subject do-update-line nil t)
5367 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5369 (set-buffer buf))))))
5375 (defcustom gnus-article-edit-mode-hook nil
5376 "Hook run in article edit mode buffers."
5377 :group 'gnus-article-various
5380 (defvar gnus-article-edit-done-function nil)
5382 (defvar gnus-article-edit-mode-map nil)
5383 (defvar gnus-article-edit-mode nil)
5385 ;; Should we be using derived.el for this?
5386 (unless gnus-article-edit-mode-map
5387 (setq gnus-article-edit-mode-map (make-keymap))
5388 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5390 (gnus-define-keys gnus-article-edit-mode-map
5391 "\C-c?" describe-mode
5392 "\C-c\C-c" gnus-article-edit-done
5393 "\C-c\C-k" gnus-article-edit-exit
5394 "\C-c\C-f\C-t" message-goto-to
5395 "\C-c\C-f\C-o" message-goto-from
5396 "\C-c\C-f\C-b" message-goto-bcc
5397 ;;"\C-c\C-f\C-w" message-goto-fcc
5398 "\C-c\C-f\C-c" message-goto-cc
5399 "\C-c\C-f\C-s" message-goto-subject
5400 "\C-c\C-f\C-r" message-goto-reply-to
5401 "\C-c\C-f\C-n" message-goto-newsgroups
5402 "\C-c\C-f\C-d" message-goto-distribution
5403 "\C-c\C-f\C-f" message-goto-followup-to
5404 "\C-c\C-f\C-m" message-goto-mail-followup-to
5405 "\C-c\C-f\C-k" message-goto-keywords
5406 "\C-c\C-f\C-u" message-goto-summary
5407 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5408 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5409 "\C-c\C-b" message-goto-body
5410 "\C-c\C-i" message-goto-signature
5412 "\C-c\C-t" message-insert-to
5413 "\C-c\C-n" message-insert-newsgroups
5414 "\C-c\C-o" message-sort-headers
5415 "\C-c\C-e" message-elide-region
5416 "\C-c\C-v" message-delete-not-region
5417 "\C-c\C-z" message-kill-to-signature
5418 "\M-\r" message-newline-and-reformat
5419 "\C-c\C-a" mml-attach-file
5420 "\C-a" message-beginning-of-line
5422 "\M-;" comment-region)
5424 (gnus-define-keys (gnus-article-edit-wash-map
5425 "\C-c\C-w" gnus-article-edit-mode-map)
5426 "f" gnus-article-edit-full-stops))
5429 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5431 ["Fetch To" message-insert-to t]
5432 ["Fetch Newsgroups" message-insert-newsgroups t]
5434 ["To" message-goto-to t]
5435 ["From" message-goto-from t]
5436 ["Subject" message-goto-subject t]
5437 ["Cc" message-goto-cc t]
5438 ["Reply-To" message-goto-reply-to t]
5439 ["Summary" message-goto-summary t]
5440 ["Keywords" message-goto-keywords t]
5441 ["Newsgroups" message-goto-newsgroups t]
5442 ["Followup-To" message-goto-followup-to t]
5443 ["Mail-Followup-To" message-goto-mail-followup-to t]
5444 ["Distribution" message-goto-distribution t]
5445 ["Body" message-goto-body t]
5446 ["Signature" message-goto-signature t]))
5448 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5449 "Major mode for editing articles.
5450 This is an extended text-mode.
5452 \\{gnus-article-edit-mode-map}"
5453 (make-local-variable 'gnus-article-edit-done-function)
5454 (make-local-variable 'gnus-prev-winconf)
5455 (set (make-local-variable 'font-lock-defaults)
5456 '(message-font-lock-keywords t))
5457 (set (make-local-variable 'mail-header-separator) "")
5458 (set (make-local-variable 'gnus-article-edit-mode) t)
5459 (easy-menu-add message-mode-field-menu message-mode-map)
5461 (setq buffer-read-only nil)
5462 (buffer-enable-undo)
5465 (defun gnus-article-edit (&optional force)
5466 "Edit the current article.
5467 This will have permanent effect only in mail groups.
5468 If FORCE is non-nil, allow editing of articles even in read-only
5471 (when (and (not force)
5472 (gnus-group-read-only-p))
5473 (error "The current newsgroup does not support article editing"))
5474 (gnus-article-date-original)
5475 (gnus-article-edit-article
5477 `(lambda (no-highlight)
5479 (gnus-summary-edit-article-done
5480 ,(or (mail-header-references gnus-current-headers) "")
5481 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5483 (defun gnus-article-edit-article (start-func exit-func)
5484 "Start editing the contents of the current article buffer."
5485 (let ((winconf (current-window-configuration)))
5486 (set-buffer gnus-article-buffer)
5487 (gnus-article-edit-mode)
5488 (funcall start-func)
5489 (set-buffer-modified-p nil)
5490 (gnus-configure-windows 'edit-article)
5491 (setq gnus-article-edit-done-function exit-func)
5492 (setq gnus-prev-winconf winconf)
5493 (gnus-message 6 "C-c C-c to end edits")))
5495 (defun gnus-article-edit-done (&optional arg)
5496 "Update the article edits and exit."
5498 (let ((func gnus-article-edit-done-function)
5499 (buf (current-buffer))
5500 (start (window-start))
5502 (winconf gnus-prev-winconf))
5503 (widen) ;; Widen it in case that users narrowed the buffer.
5506 ;; The cache and backlog have to be flushed somewhat.
5507 (when gnus-keep-backlog
5508 (gnus-backlog-remove-article
5509 (car gnus-article-current) (cdr gnus-article-current)))
5510 ;; Flush original article as well.
5512 (when (get-buffer gnus-original-article-buffer)
5513 (set-buffer gnus-original-article-buffer)
5514 (setq gnus-original-article nil)))
5515 (when gnus-use-cache
5516 (gnus-cache-update-article
5517 (car gnus-article-current) (cdr gnus-article-current)))
5518 ;; We remove all text props from the article buffer.
5519 (kill-all-local-variables)
5520 (gnus-set-text-properties (point-min) (point-max) nil)
5522 (set-window-configuration winconf)
5524 (set-window-start (get-buffer-window buf) start)
5525 (set-window-point (get-buffer-window buf) (point))))
5527 (defun gnus-article-edit-exit ()
5528 "Exit the article editing without updating."
5530 (when (or (not (buffer-modified-p))
5531 (yes-or-no-p "Article modified; kill anyway? "))
5532 (let ((curbuf (current-buffer))
5534 (window-start (window-start)))
5536 (if (gnus-buffer-live-p gnus-original-article-buffer)
5537 (insert-buffer gnus-original-article-buffer))
5538 (let ((winconf gnus-prev-winconf))
5539 (kill-all-local-variables)
5541 (set-window-configuration winconf)
5542 ;; Tippy-toe some to make sure that point remains where it was.
5543 (save-current-buffer
5545 (set-window-start (get-buffer-window (current-buffer)) window-start)
5548 (defun gnus-article-edit-full-stops ()
5549 "Interactively repair spacing at end of sentences."
5552 (goto-char (point-min))
5553 (search-forward-regexp "^$" nil t)
5554 (let ((case-fold-search nil))
5555 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5558 ;;; Article highlights
5561 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5563 ;;; Internal Variables:
5565 (defcustom gnus-button-url-regexp
5566 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5567 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~%&*+\\/[:word:]]\\)"
5568 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)\\)")
5569 "Regular expression that matches URLs."
5570 :group 'gnus-article-buttons
5573 (defcustom gnus-button-valid-fqdn-regexp
5574 message-valid-fqdn-regexp
5575 "Regular expression that matches a valid FQDN."
5576 :group 'gnus-article-buttons
5579 (defcustom gnus-button-man-handler 'manual-entry
5580 "Function to use for displaying man pages.
5581 The function must take at least one argument with a string naming the
5583 :type '(choice (function-item :tag "Man" manual-entry)
5584 (function-item :tag "Woman" woman)
5585 (function :tag "Other"))
5586 :group 'gnus-article-buttons)
5588 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5589 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5590 If the default site is too slow, try to find a CTAN mirror, see
5591 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5592 the variable `gnus-button-handle-ctan'."
5593 :group 'gnus-article-buttons
5594 :link '(custom-manual "(gnus)Group Parameters")
5595 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5596 (const "http://tug.ctan.org/tex-archive/")
5597 (const "http://www.dante.de/CTAN/")
5598 (string :tag "Other")))
5600 (defcustom gnus-button-ctan-handler 'browse-url
5601 "Function to use for displaying CTAN links.
5602 The function must take one argument, the string naming the URL."
5603 :type '(choice (function-item :tag "Browse Url" browse-url)
5604 (function :tag "Other"))
5605 :group 'gnus-article-buttons)
5607 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5608 "Bogus strings removed from CTAN URLs."
5609 :group 'gnus-article-buttons
5610 :type '(choice (const "^/?tex-archive/\\|/")
5611 (regexp :tag "Other")))
5613 (defcustom gnus-button-ctan-directory-regexp
5615 "\\("; Cannot use `\(?: ... \)' (compatibility with Emacs 20).
5616 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5617 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5618 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5620 "Regular expression for ctan directories.
5621 It should match all directories in the top level of `gnus-ctan-url'."
5622 :group 'gnus-article-buttons
5625 (defcustom gnus-button-mid-or-mail-regexp
5626 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
5627 gnus-button-valid-fqdn-regexp
5629 "Regular expression that matches a message ID or a mail address."
5630 :group 'gnus-article-buttons
5633 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5634 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5635 Strings like this can be either a message ID or a mail address. If it is one
5636 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5637 message ID or a mail address, respectivly. If this variable is set to the
5638 symbol `ask', always query the user what do do. If it is a function, this
5639 function will be called with the string as it's only argument. The function
5640 must return `mid', `mail', `invalid' or `ask'."
5641 :group 'gnus-article-buttons
5642 :type '(choice (function-item :tag "Heuristic function"
5643 gnus-button-mid-or-mail-heuristic)
5648 (defcustom gnus-button-mid-or-mail-heuristic-alist
5649 '((-10.0 . ".+\\$.+@")
5652 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5653 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5654 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5655 (-1.0 . "^[^a-z]+@")
5657 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5658 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5659 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5660 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5663 (-1.0 . "^[0-9][0-9]")
5665 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5666 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5667 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5668 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5670 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5671 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5674 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5676 ;; compensation for TDMA dated mail addresses:
5677 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5679 (-20.0 . "\\.fsf@") ;; Gnus
5682 (-20.0 . "_-_") ;; Subject change in thread
5684 (-20.0 . "\\.ln@") ;; leafnode
5685 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5686 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5688 ;; (5.0 . "") ;; $local_part_len <= 7
5689 (10.0 . "^[^0-9]+@")
5690 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5691 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5694 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5696 (0.5 . "^[A-Z][a-z]")
5697 (0.5 . "^[A-Z][a-z][a-z]")
5698 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5699 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5700 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5702 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5703 address. The REGEXP is processed with `case-fold-search' set to `nil'."
5704 :group 'gnus-article-buttons
5705 :type '(repeat (cons (number :tag "Rate")
5706 (regexp :tag "Regexp"))))
5708 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5709 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5710 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5711 address, `ask' if unsure and `invalid' if the string is invalid."
5712 (let ((case-fold-search nil)
5713 (list gnus-button-mid-or-mail-heuristic-alist)
5714 (result 0) rate regexp lpartlen elem)
5716 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5717 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5718 ;; Certain special cases...
5721 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$" "\\|"
5722 "^[0-9]+\.[0-9]+\@compuserve")
5724 (gnus-message 8 "`%s' is a known mail address.")
5725 (setq result 'mail))
5726 (when (string-match "@.*@\\| " mid-or-mail)
5727 (gnus-message 8 "`%s' is invalid.")
5728 (setq result 'invalid))
5729 ;; Nothing more to do, if result is not a number here...
5730 (when (numberp result)
5732 (setq elem (car list)
5736 (when (string-match regexp mid-or-mail)
5737 (setq result (+ result rate))
5739 9 "`%s' matched `%s', rate `%s', result `%s'."
5740 mid-or-mail regexp rate result)))
5741 (when (<= lpartlen 7)
5742 (setq result (+ result 5.0))
5743 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
5744 mid-or-mail result))
5745 (when (>= lpartlen 12)
5746 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
5748 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
5749 ;; Long local part should contain realname if e-mail address,
5750 ;; too many digits: message-id.
5751 ;; $score -= 5.0 + 0.1 * $local_part_len;
5752 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
5753 (setq result (+ result rate))
5755 9 "Many digits in `%s', rate `%s', result `%s'."
5756 mid-or-mail rate result))
5757 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
5759 ;; Too few vowels [^aeiouy]{4,}.*\@
5760 (setq result (+ result -5.0))
5762 9 "Few vowels in `%s', rate `%s', result `%s'."
5763 mid-or-mail -5.0 result))
5765 (setq result (+ result 5.0))
5767 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
5768 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
5770 ;; Maybe we should make this a customizable alist: (condition . 'result)
5771 ((< result -10.0) 'mid)
5772 ((> result 10.0) 'mail)
5775 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5776 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
5777 (url-mid (concat "news" ":" mid-or-mail))
5778 (url-mailto (concat "mailto" ":" mid-or-mail)))
5779 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5780 (when (fboundp pref)
5782 ;; get rid of surrounding angles...
5784 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
5785 (if (or (eq 'mid guessed) (eq 'mail guessed))
5789 (save-window-excursion
5790 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5793 (cond ((eq pref 'mid)
5794 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
5795 (gnus-button-handle-news url-mid))
5797 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
5798 (gnus-url-mailto url-mailto))
5799 (t (gnus-message 3 "Invalid string.")))))
5801 (defun gnus-button-handle-custom (url)
5802 "Follow a Custom URL."
5803 (customize-apropos (gnus-url-unhex-string url)))
5805 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5807 ;; FIXME: Maybe we should merge some of the functions that do quite similar
5810 (defun gnus-button-handle-describe-function (url)
5811 "Call `describe-function' when pushing the corresponding URL button."
5814 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5816 (defun gnus-button-handle-describe-variable (url)
5817 "Call `describe-variable' when pushing the corresponding URL button."
5820 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5822 (defun gnus-button-handle-symbol (url)
5823 "Display help on variable or function.
5824 Calls `describe-variable' or `describe-function'."
5825 (let ((sym (intern url)))
5827 ((fboundp sym) (describe-function sym))
5828 ((boundp sym) (describe-variable sym))
5829 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
5831 (defun gnus-button-handle-describe-key (url)
5832 "Call `describe-key' when pushing the corresponding URL button."
5834 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5835 (keys (ignore-errors (eval `(kbd ,key-string)))))
5838 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5840 (defun gnus-button-handle-apropos (url)
5841 "Call `apropos' when pushing the corresponding URL button."
5842 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5844 (defun gnus-button-handle-apropos-command (url)
5845 "Call `apropos' when pushing the corresponding URL button."
5847 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5849 (defun gnus-button-handle-apropos-variable (url)
5850 "Call `apropos' when pushing the corresponding URL button."
5852 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5853 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5855 (defun gnus-button-handle-apropos-documentation (url)
5856 "Call `apropos' when pushing the corresponding URL button."
5858 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
5859 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5861 (defun gnus-button-handle-library (url)
5862 "Call `locate-library' when pushing the corresponding URL button."
5863 (gnus-message 9 "url=`%s'" url)
5864 (let* ((lib (locate-library url))
5865 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
5867 (gnus-message 1 "Cannot locale library `%s'." url)
5868 (find-file-read-only file))))
5870 (defun gnus-button-handle-ctan (url)
5871 "Call `browse-url' when pushing a CTAN URL button."
5873 gnus-button-ctan-handler
5876 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
5878 (defcustom gnus-button-tex-level 5
5879 "*Integer that says how many TeX-related buttons Gnus will show.
5880 The higher the number, the more buttons will appear and the more false
5881 positives are possible. Note that you can set this variable local to
5882 specifific groups. Setting it higher in TeX groups is probably a good idea.
5883 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5884 how to set variables in specific groups."
5885 :group 'gnus-article-buttons
5886 :link '(custom-manual "(gnus)Group Parameters")
5889 (defcustom gnus-button-man-level 5
5890 "*Integer that says how many man-related buttons Gnus will show.
5891 The higher the number, the more buttons will appear and the more false
5892 positives are possible. Note that you can set this variable local to
5893 specifific groups. Setting it higher in Unix groups is probably a good idea.
5894 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5895 how to set variables in specific groups."
5896 :group 'gnus-article-buttons
5897 :link '(custom-manual "(gnus)Group Parameters")
5900 (defcustom gnus-button-emacs-level 5
5901 "*Integer that says how many emacs-related buttons Gnus will show.
5902 The higher the number, the more buttons will appear and the more false
5903 positives are possible. Note that you can set this variable local to
5904 specifific groups. Setting it higher in Emacs or Gnus related groups is
5905 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
5906 `gnus-parameters' on how to set variables in specific groups."
5907 :group 'gnus-article-buttons
5908 :link '(custom-manual "(gnus)Group Parameters")
5911 (defcustom gnus-button-message-level 5
5912 "*Integer that says how many buttons for news or mail messages will appear.
5913 The higher the number, the more buttons will appear and the more false
5914 positives are possible."
5915 ;; mail addresses, MIDs, URLs for news, ...
5916 :group 'gnus-article-buttons
5919 (defcustom gnus-button-browse-level 5
5920 "*Integer that says how many buttons for browsing will appear.
5921 The higher the number, the more buttons will appear and the more false
5922 positives are possible."
5923 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
5924 :group 'gnus-article-buttons
5927 (defcustom gnus-button-alist
5928 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5929 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
5930 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5931 gnus-button-handle-news 2)
5932 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5933 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 4)
5934 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)"
5935 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 2)
5936 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
5937 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
5938 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
5939 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
5940 ("mailto:\\([-a-z.@_+0-9%=?]+\\)"
5941 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
5942 ("\\bmailto:\\([^ \n\t]+\\)"
5943 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
5945 ("\\bCTAN:[ \t\n]*\\([^>)!;:,'\n\t ]*\\)"
5946 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
5947 ((concat "\\btex-archive/\\("
5948 gnus-button-ctan-directory-regexp
5949 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
5950 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
5953 gnus-button-ctan-directory-regexp
5954 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
5955 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
5957 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)"
5958 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
5959 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
5960 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
5961 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
5962 ;; Info links like `C-h i d m CC Mode RET'
5963 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
5965 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
5966 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
5967 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5968 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
5969 ;; Emacs help commands
5970 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5971 ;; regexp doesn't match arguments containing ` '.
5972 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
5973 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5974 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
5975 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5976 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
5977 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5978 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
5979 ;; The following entries may lead to many false positives so don't enable
5980 ;; them by default (use a high button level):
5981 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
5982 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
5983 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
5984 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
5985 ("`\\([a-z]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
5986 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
5987 ("`\\([a-z]+-[a-z]+\\)'"
5988 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
5989 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
5990 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
5991 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5992 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
5993 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5994 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
5995 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
5996 ;; Unlike the other regexps we really have to require quoting
5997 ;; here to determine where it ends.
5998 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
5999 ;; This is how URLs _should_ be embedded in text (RFC 1738)...
6000 ("<URL: *\\([^<>]*\\)>"
6001 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6003 (gnus-button-url-regexp
6004 0 (>= gnus-button-browse-level 0) browse-url 0)
6006 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6007 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6008 gnus-button-handle-man 1)
6009 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6010 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6011 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6012 gnus-button-handle-man 1)
6013 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6014 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6015 ("\\b\\([a-z][-_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6016 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6017 ;; MID or mail: To avoid too many false positives we don't try to catch
6018 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6019 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6020 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6021 ;; so that non-ambiguous entries (see above) match first.
6022 (gnus-button-mid-or-mail-regexp
6023 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6024 "*Alist of regexps matching buttons in article bodies.
6026 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6027 REGEXP: is the string (case insensitive) matching text around the button (can
6028 also be lisp expression evaluating to a string),
6029 BUTTON: is the number of the regexp grouping actually matching the button,
6030 FORM: is a lisp expression which must eval to true for the button to
6032 CALLBACK: is the function to call when the user push this button, and each
6033 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6035 CALLBACK can also be a variable, in that case the value of that
6036 variable it the real callback function."
6037 :group 'gnus-article-buttons
6038 :type '(repeat (list (choice regexp variable)
6039 (integer :tag "Button")
6041 (function :tag "Callback")
6044 (integer :tag "Regexp group")))))
6046 (defcustom gnus-header-button-alist
6047 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
6048 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6049 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6050 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6051 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6052 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6053 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6054 0 (>= gnus-button-browse-level 0) browse-url 0)
6055 ("^Subject:" gnus-button-url-regexp
6056 0 (>= gnus-button-browse-level 0) browse-url 0)
6057 ("^[^:]+:" gnus-button-url-regexp
6058 0 (>= gnus-button-browse-level 0) browse-url 0)
6059 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)"
6060 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6061 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)"
6062 1 (>= gnus-button-message-level 0) gnus-button-message-id 3))
6063 "*Alist of headers and regexps to match buttons in article heads.
6065 This alist is very similar to `gnus-button-alist', except that each
6066 alist has an additional HEADER element first in each entry:
6068 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6070 HEADER is a regexp to match a header. For a fuller explanation, see
6071 `gnus-button-alist'."
6072 :group 'gnus-article-buttons
6073 :group 'gnus-article-headers
6074 :type '(repeat (list (regexp :tag "Header")
6076 (integer :tag "Button")
6078 (function :tag "Callback")
6081 (integer :tag "Regexp group")))))
6083 (defvar gnus-button-regexp nil)
6084 (defvar gnus-button-marker-list nil)
6085 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6087 (defvar gnus-button-last nil)
6088 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6092 (defun gnus-article-push-button (event)
6093 "Check text under the mouse pointer for a callback function.
6094 If the text under the mouse pointer has a `gnus-callback' property,
6095 call it with the value of the `gnus-data' text property."
6097 (set-buffer (window-buffer (posn-window (event-start event))))
6098 (let* ((pos (posn-point (event-start event)))
6099 (data (get-text-property pos 'gnus-data))
6100 (fun (get-text-property pos 'gnus-callback)))
6103 (funcall fun data))))
6105 (defun gnus-article-press-button ()
6106 "Check text at point for a callback function.
6107 If the text at point has a `gnus-callback' property,
6108 call it with the value of the `gnus-data' text property."
6110 (let ((data (get-text-property (point) 'gnus-data))
6111 (fun (get-text-property (point) 'gnus-callback)))
6113 (funcall fun data))))
6115 (defun gnus-article-highlight (&optional force)
6116 "Highlight current article.
6117 This function calls `gnus-article-highlight-headers',
6118 `gnus-article-highlight-citation',
6119 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6120 do the highlighting. See the documentation for those functions."
6121 (interactive (list 'force))
6122 (gnus-article-highlight-headers)
6123 (gnus-article-highlight-citation force)
6124 (gnus-article-highlight-signature)
6125 (gnus-article-add-buttons force)
6126 (gnus-article-add-buttons-to-head))
6128 (defun gnus-article-highlight-some (&optional force)
6129 "Highlight current article.
6130 This function calls `gnus-article-highlight-headers',
6131 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6132 do the highlighting. See the documentation for those functions."
6133 (interactive (list 'force))
6134 (gnus-article-highlight-headers)
6135 (gnus-article-highlight-signature)
6136 (gnus-article-add-buttons))
6138 (defun gnus-article-highlight-headers ()
6139 "Highlight article headers as specified by `gnus-header-face-alist'."
6142 (set-buffer gnus-article-buffer)
6144 (let ((alist gnus-header-face-alist)
6145 (buffer-read-only nil)
6146 (case-fold-search t)
6147 (inhibit-point-motion-hooks t)
6148 entry regexp header-face field-face from hpoints fpoints)
6149 (article-narrow-to-head)
6150 (while (setq entry (pop alist))
6151 (goto-char (point-min))
6152 (setq regexp (concat "^\\("
6153 (if (string-equal "" (nth 0 entry))
6157 header-face (nth 1 entry)
6158 field-face (nth 2 entry))
6159 (while (and (re-search-forward regexp nil t)
6163 (unless (search-forward ":" nil t)
6165 (when (and header-face
6166 (not (memq (point) hpoints)))
6167 (push (point) hpoints)
6168 (gnus-put-text-property from (point) 'face header-face))
6169 (when (and field-face
6170 (not (memq (setq from (point)) fpoints)))
6172 (if (re-search-forward "^[^ \t]" nil t)
6174 (goto-char (point-max)))
6175 (gnus-put-text-property from (point) 'face field-face))))))))
6177 (defun gnus-article-highlight-signature ()
6178 "Highlight the signature in an article.
6179 It does this by highlighting everything after
6180 `gnus-signature-separator' using `gnus-signature-face'."
6183 (set-buffer gnus-article-buffer)
6184 (let ((buffer-read-only nil)
6185 (inhibit-point-motion-hooks t))
6187 (when (and gnus-signature-face
6188 (gnus-article-narrow-to-signature))
6189 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6190 'face gnus-signature-face)
6192 (gnus-article-search-signature)
6193 (let ((start (match-beginning 0))
6194 (end (set-marker (make-marker) (1+ (match-end 0)))))
6195 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6198 (defun gnus-button-in-region-p (b e prop)
6199 "Say whether PROP exists in the region."
6200 (text-property-not-all b e prop nil))
6202 (defun gnus-article-add-buttons (&optional force)
6203 "Find external references in the article and make buttons of them.
6204 \"External references\" are things like Message-IDs and URLs, as
6205 specified by `gnus-button-alist'."
6206 (interactive (list 'force))
6208 (set-buffer gnus-article-buffer)
6209 (let ((buffer-read-only nil)
6210 (inhibit-point-motion-hooks t)
6211 (case-fold-search t)
6212 (alist gnus-button-alist)
6214 ;; Remove all old markers.
6215 (let (marker entry new-list)
6216 (while (setq marker (pop gnus-button-marker-list))
6217 (if (or (< marker (point-min)) (>= marker (point-max)))
6218 (push marker new-list)
6220 (when (setq entry (gnus-button-entry))
6221 (put-text-property (match-beginning (nth 1 entry))
6222 (match-end (nth 1 entry))
6223 'gnus-callback nil))
6224 (set-marker marker nil)))
6225 (setq gnus-button-marker-list new-list))
6226 ;; We skip the headers.
6229 (while (setq entry (pop alist))
6230 (setq regexp (eval (car entry)))
6232 (while (re-search-forward regexp nil t)
6233 (let* ((start (and entry (match-beginning (nth 1 entry))))
6234 (end (and entry (match-end (nth 1 entry))))
6235 (from (match-beginning 0)))
6236 (when (and (or (eq t (nth 2 entry))
6237 (eval (nth 2 entry)))
6238 (not (gnus-button-in-region-p
6239 start end 'gnus-callback)))
6240 ;; That optional form returned non-nil, so we add the
6242 (gnus-article-add-button
6243 start end 'gnus-button-push
6244 (car (push (set-marker (make-marker) from)
6245 gnus-button-marker-list))))))))))
6247 ;; Add buttons to the head of an article.
6248 (defun gnus-article-add-buttons-to-head ()
6249 "Add buttons to the head of the article."
6252 (set-buffer gnus-article-buffer)
6254 (let ((buffer-read-only nil)
6255 (inhibit-point-motion-hooks t)
6256 (case-fold-search t)
6257 (alist gnus-header-button-alist)
6259 (article-narrow-to-head)
6261 ;; Each alist entry.
6262 (setq entry (car alist)
6264 (goto-char (point-min))
6265 (while (re-search-forward (car entry) nil t)
6266 ;; Each header matching the entry.
6267 (setq beg (match-beginning 0))
6268 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6269 (match-beginning 0))
6272 (while (re-search-forward (eval (nth 1 entry)) end t)
6273 ;; Each match within a header.
6274 (let* ((entry (cdr entry))
6275 (start (match-beginning (nth 1 entry)))
6276 (end (match-end (nth 1 entry)))
6277 (form (nth 2 entry)))
6278 (goto-char (match-end 0))
6280 (gnus-article-add-button
6281 start end (nth 3 entry)
6282 (buffer-substring (match-beginning (nth 4 entry))
6283 (match-end (nth 4 entry)))))))
6284 (goto-char end)))))))
6286 ;;; External functions:
6288 (defun gnus-article-add-button (from to fun &optional data)
6289 "Create a button between FROM and TO with callback FUN and data DATA."
6290 (when gnus-article-button-face
6291 (gnus-overlay-put (gnus-make-overlay from to)
6292 'face gnus-article-button-face))
6293 (gnus-add-text-properties
6295 (nconc (and gnus-article-mouse-face
6296 (list gnus-mouse-face-prop gnus-article-mouse-face))
6297 (list 'gnus-callback fun)
6298 (and data (list 'gnus-data data))))
6299 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6300 :button-keymap gnus-widget-button-keymap))
6302 ;;; Internal functions:
6304 (defun gnus-article-set-globals ()
6306 (set-buffer gnus-summary-buffer)
6307 (gnus-set-global-variables)))
6309 (defun gnus-signature-toggle (end)
6311 (set-buffer gnus-article-buffer)
6312 (let ((buffer-read-only nil)
6313 (inhibit-point-motion-hooks t))
6314 (if (text-property-any end (point-max) 'article-type 'signature)
6316 (gnus-delete-wash-type 'signature)
6317 (gnus-remove-text-properties-when
6318 'article-type 'signature end (point-max)
6319 (cons 'article-type (cons 'signature
6320 gnus-hidden-properties))))
6321 (gnus-add-wash-type 'signature)
6322 (gnus-add-text-properties-when
6323 'article-type nil end (point-max)
6324 (cons 'article-type (cons 'signature
6325 gnus-hidden-properties)))))
6326 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6327 (gnus-set-mode-line 'article))))
6329 (defun gnus-button-entry ()
6330 ;; Return the first entry in `gnus-button-alist' matching this place.
6331 (let ((alist gnus-button-alist)
6334 (setq entry (pop alist))
6335 (if (looking-at (eval (car entry)))
6340 (defun gnus-button-push (marker)
6341 ;; Push button starting at MARKER.
6344 (let* ((entry (gnus-button-entry))
6345 (inhibit-point-motion-hooks t)
6347 (args (mapcar (lambda (group)
6348 (let ((string (match-string group)))
6349 (gnus-set-text-properties
6350 0 (length string) nil string)
6357 (fboundp (symbol-value fun)))
6358 (apply (symbol-value fun) args))
6360 (gnus-message 1 "You must define `%S' to use this button"
6361 (cons fun args)))))))
6363 (defun gnus-parse-news-url (url)
6364 (let (scheme server group message-id articles)
6367 (goto-char (point-min))
6368 (when (looking-at "\\([A-Za-z]+\\):")
6369 (setq scheme (match-string 1))
6370 (goto-char (match-end 0)))
6371 (when (looking-at "//\\([^/]+\\)/")
6372 (setq server (match-string 1))
6373 (goto-char (match-end 0)))
6376 ((looking-at "\\(.*@.*\\)")
6377 (setq message-id (match-string 1)))
6378 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6379 (setq group (match-string 1)
6380 articles (split-string (match-string 2) "-")))
6381 ((looking-at "\\([^/]+\\)/?")
6382 (setq group (match-string 1)))
6384 (error "Unknown news URL syntax"))))
6385 (list scheme server group message-id articles)))
6387 (defun gnus-button-handle-news (url)
6389 (destructuring-bind (scheme server group message-id articles)
6390 (gnus-parse-news-url url)
6394 (set-buffer gnus-summary-buffer)
6396 (let ((gnus-refer-article-method (list (list 'nntp server))))
6397 (gnus-summary-refer-article message-id))
6398 (gnus-summary-refer-article message-id))))
6400 (gnus-button-fetch-group url)))))
6402 (defun gnus-button-handle-man (url)
6404 (funcall gnus-button-man-handler url))
6406 (defun gnus-button-handle-info-url (url)
6407 "Fetch an info URL."
6409 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6410 (gnus-info-find-node
6411 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6413 ")" (gnus-url-unhex-string (match-string 2 url)))))
6414 ((string-match "([^)\"]+)[^\"]+" url)
6416 (gnus-replace-in-string
6417 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6418 (gnus-info-find-node url))
6419 (t (error "Can't parse %s" url))))
6421 (defun gnus-button-handle-info-keystrokes (url)
6422 "Call `info' when pushing the corresponding URL button."
6423 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6428 (defun gnus-button-message-id (message-id)
6431 (set-buffer gnus-summary-buffer)
6432 (gnus-summary-refer-article message-id)))
6434 (defun gnus-button-fetch-group (address)
6435 "Fetch GROUP specified by ADDRESS."
6436 (if (not (string-match "[:/]" address))
6437 ;; This is just a simple group url.
6438 (gnus-group-read-ephemeral-group address gnus-select-method)
6441 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6443 (error "Can't parse %s" address)
6444 (gnus-group-read-ephemeral-group
6445 (match-string 4 address)
6446 `(nntp ,(match-string 1 address)
6447 (nntp-address ,(match-string 1 address))
6448 (nntp-port-number ,(if (match-end 3)
6449 (match-string 3 address)
6452 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6454 (defun gnus-url-parse-query-string (query &optional downcase)
6455 (let (retval pairs cur key val)
6456 (setq pairs (split-string query "&"))
6458 (setq cur (car pairs)
6460 (if (not (string-match "=" cur))
6462 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6463 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6465 (setq key (downcase key)))
6466 (setq cur (assoc key retval))
6468 (setcdr cur (cons val (cdr cur)))
6469 (setq retval (cons (list key val) retval)))))
6472 (defun gnus-url-mailto (url)
6473 ;; Send mail to someone
6474 (when (string-match "mailto:/*\\(.*\\)" url)
6475 (setq url (substring url (match-beginning 1) nil)))
6476 (let (to args subject func)
6477 (if (string-match (regexp-quote "?") url)
6478 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6479 args (gnus-url-parse-query-string
6480 (substring url (match-end 0) nil) t))
6481 (setq to (gnus-url-unhex-string url)))
6482 (setq args (cons (list "to" to) args)
6483 subject (cdr-safe (assoc "subject" args)))
6486 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6489 (message-position-on-field (caar args)))
6490 (insert (mapconcat 'identity (cdar args) ", "))
6491 (setq args (cdr args)))
6494 (message-goto-subject))))
6496 (defun gnus-button-embedded-url (address)
6497 "Activate ADDRESS with `browse-url'."
6498 (browse-url (gnus-strip-whitespace address)))
6500 ;;; Next/prev buttons in the article buffer.
6502 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6503 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6505 (defvar gnus-prev-page-map
6506 (let ((map (make-sparse-keymap)))
6507 (unless (>= emacs-major-version 21)
6508 ;; XEmacs doesn't care.
6509 (set-keymap-parent map gnus-article-mode-map))
6510 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6511 (define-key map "\r" 'gnus-button-prev-page)
6514 (defun gnus-insert-prev-page-button ()
6516 (buffer-read-only nil))
6518 gnus-prev-page-line-format nil
6519 `(,@(gnus-local-map-property gnus-prev-page-map)
6521 gnus-callback gnus-article-button-prev-page
6522 article-type annotation))
6523 (widget-convert-button
6525 ;; Exclude a newline.
6528 :action 'gnus-button-prev-page
6529 :button-keymap gnus-prev-page-map)))
6531 (defvar gnus-prev-page-map
6532 (let ((map (make-sparse-keymap)))
6533 (unless (>= emacs-major-version 21)
6534 ;; XEmacs doesn't care.
6535 (set-keymap-parent map gnus-article-mode-map))
6536 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6537 (define-key map "\r" 'gnus-button-prev-page)
6540 (defvar gnus-next-page-map
6541 (let ((map (make-sparse-keymap)))
6542 (unless (>= emacs-major-version 21)
6543 ;; XEmacs doesn't care.
6544 (set-keymap-parent map gnus-article-mode-map))
6545 (define-key map gnus-mouse-2 'gnus-button-next-page)
6546 (define-key map "\r" 'gnus-button-next-page)
6549 (defun gnus-button-next-page (&optional args more-args)
6550 "Go to the next page."
6552 (let ((win (selected-window)))
6553 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6554 (gnus-article-next-page)
6555 (select-window win)))
6557 (defun gnus-button-prev-page (&optional args more-args)
6558 "Go to the prev page."
6560 (let ((win (selected-window)))
6561 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6562 (gnus-article-prev-page)
6563 (select-window win)))
6565 (defun gnus-insert-next-page-button ()
6567 (buffer-read-only nil))
6568 (gnus-eval-format gnus-next-page-line-format nil
6569 `(,@(gnus-local-map-property gnus-next-page-map)
6571 gnus-callback gnus-article-button-next-page
6572 article-type annotation))
6573 (widget-convert-button
6575 ;; Exclude a newline.
6578 :action 'gnus-button-next-page
6579 :button-keymap gnus-next-page-map)))
6581 (defun gnus-article-button-next-page (arg)
6582 "Go to the next page."
6584 (let ((win (selected-window)))
6585 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6586 (gnus-article-next-page)
6587 (select-window win)))
6589 (defun gnus-article-button-prev-page (arg)
6590 "Go to the prev page."
6592 (let ((win (selected-window)))
6593 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6594 (gnus-article-prev-page)
6595 (select-window win)))
6597 (defvar gnus-decode-header-methods
6598 '(mail-decode-encoded-word-region)
6599 "List of methods used to decode headers.
6601 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6602 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6603 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6604 whose names match REGEXP.
6607 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6608 mail-decode-encoded-word-region
6609 (\"chinese\" . rfc1843-decode-region))
6612 (defvar gnus-decode-header-methods-cache nil)
6614 (defun gnus-multi-decode-header (start end)
6615 "Apply the functions from `gnus-encoded-word-methods' that match."
6616 (unless (and gnus-decode-header-methods-cache
6617 (eq gnus-newsgroup-name
6618 (car gnus-decode-header-methods-cache)))
6619 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6622 (nconc gnus-decode-header-methods-cache (list x))
6623 (if (and gnus-newsgroup-name
6624 (string-match (car x) gnus-newsgroup-name))
6625 (nconc gnus-decode-header-methods-cache
6627 gnus-decode-header-methods))
6628 (let ((xlist gnus-decode-header-methods-cache))
6631 (narrow-to-region start end)
6633 (funcall (pop xlist) (point-min) (point-max))))))
6636 ;;; Treatment top-level handling.
6639 (defun gnus-treat-article (condition &optional part-number total-parts type)
6640 (let ((length (- (point-max) (point-min)))
6641 (alist gnus-treatment-function-alist)
6642 (article-goto-body-goes-to-point-min-p t)
6646 (let ((list gnus-article-treat-types))
6648 (when (string-match (pop list) type)
6649 (throw 'found t)))))))
6650 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6652 (gnus-run-hooks 'gnus-part-display-hook)
6653 (dolist (elem alist)
6656 (when (gnus-buffer-live-p gnus-summary-buffer)
6657 (set-buffer gnus-summary-buffer))
6658 (symbol-value (car elem))))
6659 (when (and (or (consp val)
6661 (gnus-treat-predicate val)
6662 (or (not (get (car elem) 'highlight))
6665 (funcall (cadr elem)))))))
6667 ;; Dynamic variables.
6669 (defvar part-number)
6670 (defvar total-parts)
6675 (defun gnus-treat-predicate (val)
6682 (stringp (car val)))
6683 (apply 'gnus-or (mapcar `(lambda (s)
6684 (string-match s ,(or gnus-newsgroup-name "")))
6687 (let ((pred (pop val)))
6690 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6692 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6694 (not (gnus-treat-predicate (car val))))
6696 (equal (car val) type))
6698 (error "%S is not a valid predicate" pred)))))
6704 (eq part-number total-parts))
6708 (error "%S is not a valid value" val))))
6710 (defun gnus-article-encrypt-body (protocol &optional n)
6711 "Encrypt the article body."
6714 (or gnus-article-encrypt-protocol
6715 (completing-read "Encrypt protocol: "
6716 gnus-article-encrypt-protocol-alist
6718 current-prefix-arg))
6719 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6721 (error (format "Can't find the encrypt protocol %s" protocol)))
6722 (if (member gnus-newsgroup-name '("nndraft:delayed"
6725 (error "Can't encrypt the article in group %s"
6726 gnus-newsgroup-name))
6727 (gnus-summary-iterate n
6729 (set-buffer gnus-summary-buffer)
6730 (let ((mail-parse-charset gnus-newsgroup-charset)
6731 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6732 (summary-buffer gnus-summary-buffer)
6734 (gnus-set-global-variables)
6735 (when (gnus-group-read-only-p)
6736 (error "The current newsgroup does not support article encrypt"))
6737 (gnus-summary-show-article t)
6739 (or (mail-header-references gnus-current-headers) ""))
6740 (set-buffer gnus-article-buffer)
6741 (let* ((buffer-read-only nil)
6743 (mapcar (lambda (field)
6744 (and (save-restriction
6745 (message-narrow-to-head)
6746 (goto-char (point-min))
6747 (search-forward field nil t))
6749 (message-narrow-to-field)
6751 (delete-region (point-min) (point-max))
6753 '("Content-Type:" "Content-Transfer-Encoding:"
6754 "Content-Disposition:"))))
6755 (message-narrow-to-head)
6756 (message-remove-header "MIME-Version")
6757 (goto-char (point-max))
6758 (setq point (point))
6759 (insert (apply 'concat headers))
6761 (narrow-to-region point (point-max))
6762 (let ((message-options message-options))
6763 (message-options-set 'message-sender user-mail-address)
6764 (message-options-set 'message-recipients user-mail-address)
6765 (message-options-set 'message-sign-encrypt 'not)
6767 (goto-char (point-min))
6768 (insert "MIME-Version: 1.0\n")
6770 (gnus-summary-edit-article-done
6771 references nil summary-buffer t))
6772 (when gnus-keep-backlog
6773 (gnus-backlog-remove-article
6774 (car gnus-article-current) (cdr gnus-article-current)))
6776 (when (get-buffer gnus-original-article-buffer)
6777 (set-buffer gnus-original-article-buffer)
6778 (setq gnus-original-article nil)))
6779 (when gnus-use-cache
6780 (gnus-cache-update-article
6781 (car gnus-article-current) (cdr gnus-article-current))))))))
6783 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6784 "The following specs can be used:
6785 %t The security MIME type
6788 %D Details if button is pressed")
6790 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6791 "The following specs can be used:
6792 %t The security MIME type
6795 %D Details if button is pressed")
6797 (defvar gnus-mime-security-button-line-format-alist
6798 '((?t gnus-tmp-type ?s)
6799 (?i gnus-tmp-info ?s)
6800 (?d gnus-tmp-details ?s)
6801 (?D gnus-tmp-pressed-details ?s)))
6803 (defvar gnus-mime-security-button-map
6804 (let ((map (make-sparse-keymap)))
6805 (unless (>= (string-to-number emacs-version) 21)
6806 (set-keymap-parent map gnus-article-mode-map))
6807 (define-key map gnus-mouse-2 'gnus-article-push-button)
6808 (define-key map "\r" 'gnus-article-press-button)
6811 (defvar gnus-mime-security-details-buffer nil)
6813 (defvar gnus-mime-security-button-pressed nil)
6815 (defvar gnus-mime-security-show-details-inline t
6816 "If non-nil, show details in the article buffer.")
6818 (defun gnus-mime-security-verify-or-decrypt (handle)
6819 (mm-remove-parts (cdr handle))
6820 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6821 point buffer-read-only)
6823 (goto-char (car region)))
6825 (narrow-to-region (point) (point))
6826 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6827 (let* ((mm-verify-option 'known)
6828 (mm-decrypt-option 'known)
6829 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6830 (unless (eq nparts (cdr handle))
6831 (mm-destroy-parts (cdr handle))
6832 (setcdr handle nparts))))
6833 (setq point (point))
6834 (gnus-mime-display-security handle)
6835 (goto-char (point-max)))
6837 (delete-region (point) (cdr region))
6838 (set-marker (car region) nil)
6839 (set-marker (cdr region) nil))
6842 (defun gnus-mime-security-show-details (handle)
6843 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6845 (gnus-message 5 "No details.")
6846 (if gnus-mime-security-show-details-inline
6847 (let ((gnus-mime-security-button-pressed
6848 (not (get-text-property (point) 'gnus-mime-details)))
6849 (gnus-mime-security-button-line-format
6850 (get-text-property (point) 'gnus-line-format))
6853 (while (eq (get-text-property (point) 'gnus-line-format)
6854 gnus-mime-security-button-line-format)
6858 (narrow-to-region (point) (point))
6859 (gnus-insert-mime-security-button handle))
6860 (delete-region (point)
6861 (or (text-property-not-all
6864 gnus-mime-security-button-line-format)
6867 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6868 (with-current-buffer gnus-mime-security-details-buffer
6871 (setq gnus-mime-security-details-buffer
6872 (gnus-get-buffer-create "*MIME Security Details*")))
6873 (with-current-buffer gnus-mime-security-details-buffer
6875 (goto-char (point-min)))
6876 (pop-to-buffer gnus-mime-security-details-buffer)))))
6878 (defun gnus-mime-security-press-button (handle)
6880 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6881 (gnus-mime-security-show-details handle)
6882 (gnus-mime-security-verify-or-decrypt handle))))
6884 (defun gnus-insert-mime-security-button (handle &optional displayed)
6885 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6888 (or (nth 2 (assoc protocol mm-verify-function-alist))
6889 (nth 2 (assoc protocol mm-decrypt-function-alist))
6891 (if (equal (car handle) "multipart/signed")
6892 " Signed" " Encrypted")
6895 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6898 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6899 gnus-tmp-pressed-details
6901 (setq gnus-tmp-details
6902 (if gnus-tmp-details
6903 (concat "\n" gnus-tmp-details)
6905 (setq gnus-tmp-pressed-details
6906 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6911 gnus-mime-security-button-line-format
6912 gnus-mime-security-button-line-format-alist
6913 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6914 gnus-callback gnus-mime-security-press-button
6915 gnus-line-format ,gnus-mime-security-button-line-format
6916 gnus-mime-details ,gnus-mime-security-button-pressed
6917 article-type annotation
6920 ;; Exclude a newline.
6923 (widget-convert-button
6926 :action 'gnus-widget-press-button
6927 :button-keymap gnus-mime-security-button-map
6929 (lambda (widget/window &optional overlay pos)
6930 ;; Needed to properly clear the message due to a bug in
6931 ;; wid-edit (XEmacs only).
6932 (when (boundp 'help-echo-owns-message)
6933 (setq help-echo-owns-message t))
6936 (aref gnus-mouse-2 0))))))
6938 (defun gnus-mime-display-security (handle)
6940 (narrow-to-region (point) (point))
6941 (unless (gnus-unbuttonized-mime-type-p (car handle))
6942 (gnus-insert-mime-security-button handle))
6943 (gnus-mime-display-mixed (cdr handle))
6946 (unless (gnus-unbuttonized-mime-type-p (car handle))
6947 (let ((gnus-mime-security-button-line-format
6948 gnus-mime-security-button-end-line-format))
6949 (gnus-insert-mime-security-button handle)))
6950 (mm-set-handle-multipart-parameter
6952 (cons (set-marker (make-marker) (point-min))
6953 (set-marker (make-marker) (point-max))))))
6959 (run-hooks 'gnus-art-load-hook)
6961 ;;; gnus-art.el ends here