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" "X-Gpg-.*" "X-Disclaimer"))
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 non-graphical
247 ;; 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 (if (featurep 'xemacs)
400 '((t (:strikethru t)))
401 '((t (:strike-through t))))
402 "Face used for displaying strike-through text (-word-)."
403 :group 'gnus-article-emphasis)
405 (defface gnus-emphasis-highlight-words
406 '((t (:background "black" :foreground "yellow")))
407 "Face used for displaying highlighted words."
408 :group 'gnus-article-emphasis)
410 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
411 "Format for display of Date headers in article bodies.
412 See `format-time-string' for the possible values.
414 The variable can also be function, which should return a complete Date
415 header. The function is called with one argument, the time, which can
416 be fed to `format-time-string'."
417 :type '(choice string symbol)
418 :link '(custom-manual "(gnus)Article Date")
419 :group 'gnus-article-washing)
422 (autoload 'mail-extract-address-components "mail-extr"))
424 (defcustom gnus-save-all-headers t
425 "*If non-nil, don't remove any headers before saving."
426 :group 'gnus-article-saving
429 (defcustom gnus-prompt-before-saving 'always
430 "*This variable says how much prompting is to be done when saving articles.
431 If it is nil, no prompting will be done, and the articles will be
432 saved to the default files. If this variable is `always', each and
433 every article that is saved will be preceded by a prompt, even when
434 saving large batches of articles. If this variable is neither nil not
435 `always', there the user will be prompted once for a file name for
436 each invocation of the saving commands."
437 :group 'gnus-article-saving
438 :type '(choice (item always)
439 (item :tag "never" nil)
440 (sexp :tag "once" :format "%t\n" :value t)))
442 (defcustom gnus-saved-headers gnus-visible-headers
443 "Headers to keep if `gnus-save-all-headers' is nil.
444 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
445 If that variable is nil, however, all headers that match this regexp
446 will be kept while the rest will be deleted before saving."
447 :group 'gnus-article-saving
450 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
451 "A function to save articles in your favourite format.
452 The function must be interactively callable (in other words, it must
453 be an Emacs command).
455 Gnus provides the following functions:
457 * gnus-summary-save-in-rmail (Rmail format)
458 * gnus-summary-save-in-mail (Unix mail format)
459 * gnus-summary-save-in-folder (MH folder)
460 * gnus-summary-save-in-file (article format)
461 * gnus-summary-save-body-in-file (article body)
462 * gnus-summary-save-in-vm (use VM's folder format)
463 * gnus-summary-write-to-file (article format -- overwrite)."
464 :group 'gnus-article-saving
465 :type '(radio (function-item gnus-summary-save-in-rmail)
466 (function-item gnus-summary-save-in-mail)
467 (function-item gnus-summary-save-in-folder)
468 (function-item gnus-summary-save-in-file)
469 (function-item gnus-summary-save-body-in-file)
470 (function-item gnus-summary-save-in-vm)
471 (function-item gnus-summary-write-to-file)))
473 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
474 "A function generating a file name to save articles in Rmail format.
475 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
476 :group 'gnus-article-saving
479 (defcustom gnus-mail-save-name 'gnus-plain-save-name
480 "A function generating a file name to save articles in Unix mail format.
481 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
482 :group 'gnus-article-saving
485 (defcustom gnus-folder-save-name 'gnus-folder-save-name
486 "A function generating a file name to save articles in MH folder.
487 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
488 :group 'gnus-article-saving
491 (defcustom gnus-file-save-name 'gnus-numeric-save-name
492 "A function generating a file name to save articles in article format.
493 The function is called with NEWSGROUP, HEADERS, and optional
495 :group 'gnus-article-saving
498 (defcustom gnus-split-methods
499 '((gnus-article-archive-name)
500 (gnus-article-nndoc-name))
501 "*Variable used to suggest where articles are to be saved.
502 For instance, if you would like to save articles related to Gnus in
503 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
504 you could set this variable to something like:
506 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
507 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
509 This variable is an alist where the where the key is the match and the
510 value is a list of possible files to save in if the match is non-nil.
512 If the match is a string, it is used as a regexp match on the
513 article. If the match is a symbol, that symbol will be funcalled
514 from the buffer of the article to be saved with the newsgroup as the
515 parameter. If it is a list, it will be evaled in the same buffer.
517 If this form or function returns a string, this string will be used as
518 a possible file name; and if it returns a non-nil list, that list will
519 be used as possible file names."
520 :group 'gnus-article-saving
521 :type '(repeat (choice (list :value (fun) function)
522 (cons :value ("" "") regexp (repeat string))
525 (defcustom gnus-page-delimiter "^\^L"
526 "*Regexp describing what to use as article page delimiters.
527 The default value is \"^\^L\", which is a form linefeed at the
528 beginning of a line."
530 :group 'gnus-article-various)
532 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
533 "*The format specification for the article mode line.
534 See `gnus-summary-mode-line-format' for a closer description.
536 The following additional specs are available:
538 %w The article washing status.
539 %m The number of MIME parts in the article."
541 :group 'gnus-article-various)
543 (defcustom gnus-article-mode-hook nil
544 "*A hook for Gnus article mode."
546 :group 'gnus-article-various)
548 (when (featurep 'xemacs)
549 ;; Extracted from gnus-xmas-define in order to preserve user settings
550 (when (fboundp 'turn-off-scroll-in-place)
551 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
552 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
553 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
555 (defcustom gnus-article-menu-hook nil
556 "*Hook run after the creation of the article mode menu."
558 :group 'gnus-article-various)
560 (defcustom gnus-article-prepare-hook nil
561 "*A hook called after an article has been prepared in the article buffer."
563 :group 'gnus-article-various)
565 (make-obsolete-variable 'gnus-article-hide-pgp-hook
566 "This variable is obsolete in Gnus 5.10.")
568 (defcustom gnus-article-button-face 'bold
569 "Face used for highlighting buttons in the article buffer.
571 An article button is a piece of text that you can activate by pressing
572 `RET' or `mouse-2' above it."
574 :group 'gnus-article-buttons)
576 (defcustom gnus-article-mouse-face 'highlight
577 "Face used for mouse highlighting in the article buffer.
579 Article buttons will be displayed in this face when the cursor is
582 :group 'gnus-article-buttons)
584 (defcustom gnus-signature-face 'gnus-signature-face
585 "Face used for highlighting a signature in the article buffer.
586 Obsolete; use the face `gnus-signature-face' for customizations instead."
588 :group 'gnus-article-highlight
589 :group 'gnus-article-signature)
591 (defface gnus-signature-face
594 "Face used for highlighting a signature in the article buffer."
595 :group 'gnus-article-highlight
596 :group 'gnus-article-signature)
598 (defface gnus-header-from-face
601 (:foreground "spring green"))
604 (:foreground "red3"))
607 "Face used for displaying from headers."
608 :group 'gnus-article-headers
609 :group 'gnus-article-highlight)
611 (defface gnus-header-subject-face
614 (:foreground "SeaGreen3"))
617 (:foreground "red4"))
619 (:bold t :italic t)))
620 "Face used for displaying subject headers."
621 :group 'gnus-article-headers
622 :group 'gnus-article-highlight)
624 (defface gnus-header-newsgroups-face
627 (:foreground "yellow" :italic t))
630 (:foreground "MidnightBlue" :italic t))
633 "Face used for displaying newsgroups headers.
634 In the default setup this face is only used for crossposted
636 :group 'gnus-article-headers
637 :group 'gnus-article-highlight)
639 (defface gnus-header-name-face
642 (:foreground "SeaGreen"))
645 (:foreground "maroon"))
648 "Face used for displaying header names."
649 :group 'gnus-article-headers
650 :group 'gnus-article-highlight)
652 (defface gnus-header-content-face
655 (:foreground "forest green" :italic t))
658 (:foreground "indianred4" :italic t))
660 (:italic t))) "Face used for displaying header content."
661 :group 'gnus-article-headers
662 :group 'gnus-article-highlight)
664 (defcustom gnus-header-face-alist
665 '(("From" nil gnus-header-from-face)
666 ("Subject" nil gnus-header-subject-face)
667 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
668 ("" gnus-header-name-face gnus-header-content-face))
669 "*Controls highlighting of article headers.
671 An alist of the form (HEADER NAME CONTENT).
673 HEADER is a regular expression which should match the name of a
674 header and NAME and CONTENT are either face names or nil.
676 The name of each header field will be displayed using the face
677 specified by the first element in the list where HEADER matches
678 the header name and NAME is non-nil. Similarly, the content will
679 be displayed by the first non-nil matching CONTENT face."
680 :group 'gnus-article-headers
681 :group 'gnus-article-highlight
682 :type '(repeat (list (regexp :tag "Header")
684 (item :tag "skip" nil)
685 (face :value default))
686 (choice :tag "Content"
687 (item :tag "skip" nil)
688 (face :value default)))))
690 (defcustom gnus-article-decode-hook
691 '(article-decode-charset article-decode-encoded-words
692 article-decode-group-name article-decode-idna-rhs)
693 "*Hook run to decode charsets in articles."
694 :group 'gnus-article-headers
697 (defcustom gnus-display-mime-function 'gnus-display-mime
698 "Function to display MIME articles."
699 :group 'gnus-article-mime
702 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
703 "Function used to decode headers.")
705 (defvar gnus-article-dumbquotes-map
725 "Table for MS-to-Latin1 translation.")
727 (defcustom gnus-ignored-mime-types nil
728 "List of MIME types that should be ignored by Gnus."
730 :group 'gnus-article-mime
731 :type '(repeat regexp))
733 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
734 "List of MIME types that should not be given buttons when rendered inline.
735 See also `gnus-buttonized-mime-types' which may override this variable.
736 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
738 :group 'gnus-article-mime
739 :type '(repeat regexp))
741 (defcustom gnus-buttonized-mime-types nil
742 "List of MIME types that should be given buttons when rendered inline.
743 If set, this variable overrides `gnus-unbuttonized-mime-types'.
744 To see e.g. security buttons you could set this to
745 `(\"multipart/signed\")'.
746 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
748 :group 'gnus-article-mime
749 :type '(repeat regexp))
751 (defcustom gnus-inhibit-mime-unbuttonizing nil
752 "If non-nil, all MIME parts get buttons.
753 When nil (the default value), then some MIME parts do not get buttons,
754 as described by the variables `gnus-buttonized-mime-types' and
755 `gnus-unbuttonized-mime-types'."
759 (defcustom gnus-body-boundary-delimiter "_"
760 "String used to delimit header and body.
761 This variable is used by `gnus-article-treat-body-boundary' which can
762 be controlled by `gnus-treat-body-boundary'."
763 :group 'gnus-article-various
764 :type '(choice (item :tag "None" :value nil)
767 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
768 "Defines the location of the faces database.
769 For information on obtaining this database of pretty pictures, please
770 see http://www.cs.indiana.edu/picons/ftp/index.html"
771 :type '(repeat directory)
772 :link '(url-link :tag "download"
773 "http://www.cs.indiana.edu/picons/ftp/index.html")
774 :link '(custom-manual "(gnus)Picons")
777 (defun gnus-picons-installed-p ()
778 "Say whether picons are installed on your machine."
779 (let ((installed nil))
780 (dolist (database gnus-picon-databases)
781 (when (file-exists-p database)
785 (defcustom gnus-article-mime-part-function nil
786 "Function called with a MIME handle as the argument.
787 This is meant for people who want to do something automatic based
788 on parts -- for instance, adding Vcard info to a database."
789 :group 'gnus-article-mime
792 (defcustom gnus-mime-multipart-functions nil
793 "An alist of MIME types to functions to display them."
795 :group 'gnus-article-mime
798 (defcustom gnus-article-date-lapsed-new-header nil
799 "Whether the X-Sent and Date headers can coexist.
800 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
801 either replace the old \"Date:\" header (if this variable is nil), or
802 be added below it (otherwise)."
804 :group 'gnus-article-headers
807 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
808 "Function called with a MIME handle as the argument.
809 This is meant for people who want to view first matched part.
810 For `undisplayed-alternative' (default), the first undisplayed
811 part or alternative part is used. For `undisplayed', the first
812 undisplayed part is used. For a function, the first part which
813 the function return t is used. For nil, the first part is
816 :group 'gnus-article-mime
818 (item :tag "first" :value nil)
819 (item :tag "undisplayed" :value undisplayed)
820 (item :tag "undisplayed or alternative"
821 :value undisplayed-alternative)
824 (defcustom gnus-mime-action-alist
825 '(("save to file" . gnus-mime-save-part)
826 ("save and strip" . gnus-mime-save-part-and-strip)
827 ("delete part" . gnus-mime-delete-part)
828 ("display as text" . gnus-mime-inline-part)
829 ("view the part" . gnus-mime-view-part)
830 ("pipe to command" . gnus-mime-pipe-part)
831 ("toggle display" . gnus-article-press-button)
832 ("toggle display" . gnus-article-view-part-as-charset)
833 ("view as type" . gnus-mime-view-part-as-type)
834 ("view internally" . gnus-mime-view-part-internally)
835 ("view externally" . gnus-mime-view-part-externally))
836 "An alist of actions that run on the MIME attachment."
837 :group 'gnus-article-mime
838 :type '(repeat (cons (string :tag "name")
842 ;;; The treatment variables
845 (defvar gnus-part-display-hook nil
846 "Hook called on parts that are to receive treatment.")
848 (defvar gnus-article-treat-custom
849 '(choice (const :tag "Off" nil)
851 (const :tag "Header" head)
852 (const :tag "Last" last)
853 (integer :tag "Less")
854 (repeat :tag "Groups" regexp)
855 (sexp :tag "Predicate")))
857 (defvar gnus-article-treat-head-custom
858 '(choice (const :tag "Off" nil)
859 (const :tag "Header" head)))
861 (defvar gnus-article-treat-types '("text/plain")
864 (defvar gnus-inhibit-treatment nil
865 "Whether to inhibit treatment.")
867 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
868 "Highlight the signature.
869 Valid values are nil, t, `head', `last', an integer or a predicate.
870 See Info node `(gnus)Customizing Articles'."
871 :group 'gnus-article-treat
872 :link '(custom-manual "(gnus)Customizing Articles")
873 :type gnus-article-treat-custom)
874 (put 'gnus-treat-highlight-signature 'highlight t)
876 (defcustom gnus-treat-buttonize 100000
878 Valid values are nil, t, `head', `last', an integer or a predicate.
879 See Info node `(gnus)Customizing Articles'."
880 :group 'gnus-article-treat
881 :link '(custom-manual "(gnus)Customizing Articles")
882 :type gnus-article-treat-custom)
883 (put 'gnus-treat-buttonize 'highlight t)
885 (defcustom gnus-treat-buttonize-head 'head
886 "Add buttons to the head.
887 Valid values are nil, t, `head', `last', an integer or a predicate.
888 See Info node `(gnus)Customizing Articles' for details."
889 :group 'gnus-article-treat
890 :link '(custom-manual "(gnus)Customizing Articles")
891 :type gnus-article-treat-head-custom)
892 (put 'gnus-treat-buttonize-head 'highlight t)
894 (defcustom gnus-treat-emphasize
895 (and (or window-system
897 (>= (string-to-number emacs-version) 21))
900 Valid values are nil, t, `head', `last', an integer or a predicate.
901 See Info node `(gnus)Customizing Articles' for details."
902 :group 'gnus-article-treat
903 :link '(custom-manual "(gnus)Customizing Articles")
904 :type gnus-article-treat-custom)
905 (put 'gnus-treat-emphasize 'highlight t)
907 (defcustom gnus-treat-strip-cr nil
908 "Remove carriage returns.
909 Valid values are nil, t, `head', `last', an integer or a predicate.
910 See Info node `(gnus)Customizing Articles' for details."
911 :group 'gnus-article-treat
912 :link '(custom-manual "(gnus)Customizing Articles")
913 :type gnus-article-treat-custom)
915 (defcustom gnus-treat-unsplit-urls nil
916 "Remove newlines from within URLs.
917 Valid values are nil, t, `head', `last', an integer or a predicate.
918 See Info node `(gnus)Customizing Articles' for details."
919 :group 'gnus-article-treat
920 :link '(custom-manual "(gnus)Customizing Articles")
921 :type gnus-article-treat-custom)
923 (defcustom gnus-treat-leading-whitespace nil
924 "Remove leading whitespace in headers.
925 Valid values are nil, t, `head', `last', an integer or a predicate.
926 See Info node `(gnus)Customizing Articles' for details."
927 :group 'gnus-article-treat
928 :link '(custom-manual "(gnus)Customizing Articles")
929 :type gnus-article-treat-custom)
931 (defcustom gnus-treat-hide-headers 'head
933 Valid values are nil, t, `head', `last', an integer or a predicate.
934 See Info node `(gnus)Customizing Articles' for details."
935 :group 'gnus-article-treat
936 :link '(custom-manual "(gnus)Customizing Articles")
937 :type gnus-article-treat-head-custom)
939 (defcustom gnus-treat-hide-boring-headers nil
940 "Hide boring headers.
941 Valid values are nil, t, `head', `last', an integer or a predicate.
942 See Info node `(gnus)Customizing Articles' for details."
943 :group 'gnus-article-treat
944 :link '(custom-manual "(gnus)Customizing Articles")
945 :type gnus-article-treat-head-custom)
947 (defcustom gnus-treat-hide-signature nil
949 Valid values are nil, t, `head', `last', an integer or a predicate.
950 See Info node `(gnus)Customizing Articles' for details."
951 :group 'gnus-article-treat
952 :link '(custom-manual "(gnus)Customizing Articles")
953 :type gnus-article-treat-custom)
955 (defcustom gnus-treat-fill-article nil
957 Valid values are nil, t, `head', `last', an integer or a predicate.
958 See Info node `(gnus)Customizing Articles' for details."
959 :group 'gnus-article-treat
960 :link '(custom-manual "(gnus)Customizing Articles")
961 :type gnus-article-treat-custom)
963 (defcustom gnus-treat-hide-citation nil
965 Valid values are nil, t, `head', `last', an integer or a predicate.
966 See Info node `(gnus)Customizing Articles' for details."
967 :group 'gnus-article-treat
968 :link '(custom-manual "(gnus)Customizing Articles")
969 :type gnus-article-treat-custom)
971 (defcustom gnus-treat-hide-citation-maybe nil
973 Valid values are nil, t, `head', `last', an integer or a predicate.
974 See Info node `(gnus)Customizing Articles' for details."
975 :group 'gnus-article-treat
976 :link '(custom-manual "(gnus)Customizing Articles")
977 :type gnus-article-treat-custom)
979 (defcustom gnus-treat-strip-list-identifiers 'head
980 "Strip list identifiers from `gnus-list-identifiers`.
981 Valid values are nil, t, `head', `last', an integer or a predicate.
982 See Info node `(gnus)Customizing Articles' for details."
984 :group 'gnus-article-treat
985 :link '(custom-manual "(gnus)Customizing Articles")
986 :type gnus-article-treat-custom)
988 (make-obsolete-variable 'gnus-treat-strip-pgp
989 "This option is obsolete in Gnus 5.10.")
991 (defcustom gnus-treat-strip-pem nil
992 "Strip PEM signatures.
993 Valid values are nil, t, `head', `last', an integer or a predicate.
994 See Info node `(gnus)Customizing Articles' for details."
995 :group 'gnus-article-treat
996 :link '(custom-manual "(gnus)Customizing Articles")
997 :type gnus-article-treat-custom)
999 (defcustom gnus-treat-strip-banner t
1000 "Strip banners from articles.
1001 The banner to be stripped is specified in the `banner' group parameter.
1002 Valid values are nil, t, `head', `last', an integer or a predicate.
1003 See Info node `(gnus)Customizing Articles' for details."
1004 :group 'gnus-article-treat
1005 :link '(custom-manual "(gnus)Customizing Articles")
1006 :type gnus-article-treat-custom)
1008 (defcustom gnus-treat-highlight-headers 'head
1009 "Highlight the headers.
1010 Valid values are nil, t, `head', `last', an integer or a predicate.
1011 See Info node `(gnus)Customizing Articles' for details."
1012 :group 'gnus-article-treat
1013 :link '(custom-manual "(gnus)Customizing Articles")
1014 :type gnus-article-treat-head-custom)
1015 (put 'gnus-treat-highlight-headers 'highlight t)
1017 (defcustom gnus-treat-highlight-citation t
1018 "Highlight cited text.
1019 Valid values are nil, t, `head', `last', an integer or a predicate.
1020 See Info node `(gnus)Customizing Articles' for details."
1021 :group 'gnus-article-treat
1022 :link '(custom-manual "(gnus)Customizing Articles")
1023 :type gnus-article-treat-custom)
1024 (put 'gnus-treat-highlight-citation 'highlight t)
1026 (defcustom gnus-treat-date-ut nil
1027 "Display the Date in UT (GMT).
1028 Valid values are nil, t, `head', `last', an integer or a predicate.
1029 See Info node `(gnus)Customizing Articles' for details."
1030 :group 'gnus-article-treat
1031 :link '(custom-manual "(gnus)Customizing Articles")
1032 :type gnus-article-treat-head-custom)
1034 (defcustom gnus-treat-date-local nil
1035 "Display the Date in the local timezone.
1036 Valid values are nil, t, `head', `last', an integer or a predicate.
1037 See Info node `(gnus)Customizing Articles' for details."
1038 :group 'gnus-article-treat
1039 :link '(custom-manual "(gnus)Customizing Articles")
1040 :type gnus-article-treat-head-custom)
1042 (defcustom gnus-treat-date-english nil
1043 "Display the Date in a format that can be read aloud in English.
1044 Valid values are nil, t, `head', `last', an integer or a predicate.
1045 See Info node `(gnus)Customizing Articles' for details."
1046 :group 'gnus-article-treat
1047 :link '(custom-manual "(gnus)Customizing Articles")
1048 :type gnus-article-treat-head-custom)
1050 (defcustom gnus-treat-date-lapsed nil
1051 "Display the Date header in a way that says how much time has elapsed.
1052 Valid values are nil, t, `head', `last', an integer or a predicate.
1053 See Info node `(gnus)Customizing Articles' for details."
1054 :group 'gnus-article-treat
1055 :link '(custom-manual "(gnus)Customizing Articles")
1056 :type gnus-article-treat-head-custom)
1058 (defcustom gnus-treat-date-original nil
1059 "Display the date in the original timezone.
1060 Valid values are nil, t, `head', `last', an integer or a predicate.
1061 See Info node `(gnus)Customizing Articles' for details."
1062 :group 'gnus-article-treat
1063 :link '(custom-manual "(gnus)Customizing Articles")
1064 :type gnus-article-treat-head-custom)
1066 (defcustom gnus-treat-date-iso8601 nil
1067 "Display the date in the ISO8601 format.
1068 Valid values are nil, t, `head', `last', an integer or a predicate.
1069 See Info node `(gnus)Customizing Articles' for details."
1071 :group 'gnus-article-treat
1072 :link '(custom-manual "(gnus)Customizing Articles")
1073 :type gnus-article-treat-head-custom)
1075 (defcustom gnus-treat-date-user-defined nil
1076 "Display the date in a user-defined format.
1077 The format is defined by the `gnus-article-time-format' variable.
1078 Valid values are nil, t, `head', `last', an integer or a predicate.
1079 See Info node `(gnus)Customizing Articles' for details."
1080 :group 'gnus-article-treat
1081 :link '(custom-manual "(gnus)Customizing Articles")
1082 :type gnus-article-treat-head-custom)
1084 (defcustom gnus-treat-strip-headers-in-body t
1085 "Strip the X-No-Archive header line from the beginning of the body.
1086 Valid values are nil, t, `head', `last', an integer or a predicate.
1087 See Info node `(gnus)Customizing Articles' for details."
1089 :group 'gnus-article-treat
1090 :link '(custom-manual "(gnus)Customizing Articles")
1091 :type gnus-article-treat-custom)
1093 (defcustom gnus-treat-strip-trailing-blank-lines nil
1094 "Strip trailing blank lines.
1095 Valid values are nil, t, `head', `last', an integer or a predicate.
1096 See Info node `(gnus)Customizing Articles' for details."
1097 :group 'gnus-article-treat
1098 :link '(custom-manual "(gnus)Customizing Articles")
1099 :type gnus-article-treat-custom)
1101 (defcustom gnus-treat-strip-leading-blank-lines nil
1102 "Strip leading blank lines.
1103 Valid values are nil, t, `head', `last', an integer or a predicate.
1104 See Info node `(gnus)Customizing Articles' for details."
1105 :group 'gnus-article-treat
1106 :link '(custom-manual "(gnus)Customizing Articles")
1107 :type gnus-article-treat-custom)
1109 (defcustom gnus-treat-strip-multiple-blank-lines nil
1110 "Strip multiple blank lines.
1111 Valid values are nil, t, `head', `last', an integer or a predicate.
1112 See Info node `(gnus)Customizing Articles' for details."
1113 :group 'gnus-article-treat
1114 :link '(custom-manual "(gnus)Customizing Articles")
1115 :type gnus-article-treat-custom)
1117 (defcustom gnus-treat-unfold-headers 'head
1118 "Unfold folded header lines.
1119 Valid values are nil, t, `head', `last', an integer or a predicate.
1120 See Info node `(gnus)Customizing Articles' for details."
1121 :group 'gnus-article-treat
1122 :link '(custom-manual "(gnus)Customizing Articles")
1123 :type gnus-article-treat-custom)
1125 (defcustom gnus-treat-fold-headers nil
1127 Valid values are nil, t, `head', `last', an integer or a predicate.
1128 See Info node `(gnus)Customizing Articles' for details."
1129 :group 'gnus-article-treat
1130 :link '(custom-manual "(gnus)Customizing Articles")
1131 :type gnus-article-treat-custom)
1133 (defcustom gnus-treat-fold-newsgroups 'head
1134 "Fold the Newsgroups and Followup-To headers.
1135 Valid values are nil, t, `head', `last', an integer or a predicate.
1136 See Info node `(gnus)Customizing Articles' for details."
1137 :group 'gnus-article-treat
1138 :link '(custom-manual "(gnus)Customizing Articles")
1139 :type gnus-article-treat-custom)
1141 (defcustom gnus-treat-overstrike t
1142 "Treat overstrike highlighting.
1143 Valid values are nil, t, `head', `last', an integer or a predicate.
1144 See Info node `(gnus)Customizing Articles' for details."
1145 :group 'gnus-article-treat
1146 :link '(custom-manual "(gnus)Customizing Articles")
1147 :type gnus-article-treat-custom)
1148 (put 'gnus-treat-overstrike 'highlight t)
1150 (make-obsolete-variable 'gnus-treat-display-xface
1151 'gnus-treat-display-x-face)
1153 (defcustom gnus-treat-display-x-face
1154 (and (not noninteractive)
1155 (or (and (fboundp 'image-type-available-p)
1156 (image-type-available-p 'xbm)
1157 (string-match "^0x" (shell-command-to-string "uncompface"))
1158 (executable-find "icontopbm"))
1159 (and (featurep 'xemacs)
1162 "Display X-Face headers.
1163 Valid values are nil, t, `head', `last', an integer or a predicate.
1164 See Info node `(gnus)Customizing Articles' and Info node
1165 `(gnus)X-Face' for details."
1166 :group 'gnus-article-treat
1168 :link '(custom-manual "(gnus)Customizing Articles")
1169 :link '(custom-manual "(gnus)X-Face")
1170 :type gnus-article-treat-head-custom
1171 :set (lambda (symbol value)
1174 (cond ((or (boundp symbol) (get symbol 'saved-value))
1176 ((boundp 'gnus-treat-display-xface)
1178 ** gnus-treat-display-xface is an obsolete variable;\
1179 use gnus-treat-display-x-face instead")
1180 (default-value 'gnus-treat-display-xface))
1181 ((get 'gnus-treat-display-xface 'saved-value)
1183 ** gnus-treat-display-xface is an obsolete variable;\
1184 use gnus-treat-display-x-face instead")
1185 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1188 (put 'gnus-treat-display-x-face 'highlight t)
1190 (defcustom gnus-treat-display-face
1191 (and (not noninteractive)
1192 (or (and (fboundp 'image-type-available-p)
1193 (image-type-available-p 'png))
1194 (and (featurep 'xemacs)
1197 "Display Face headers.
1198 Valid values are nil, t, `head', `last', an integer or a predicate.
1199 See Info node `(gnus)Customizing Articles' and Info node
1200 `(gnus)X-Face' for details."
1201 :group 'gnus-article-treat
1203 :link '(custom-manual "(gnus)Customizing Articles")
1204 :link '(custom-manual "(gnus)X-Face")
1205 :type gnus-article-treat-head-custom)
1206 (put 'gnus-treat-display-face 'highlight t)
1208 (defcustom gnus-treat-display-smileys
1209 (if (or (and (featurep 'xemacs)
1211 (and (fboundp 'image-type-available-p)
1212 (image-type-available-p 'pbm)))
1215 Valid values are nil, t, `head', `last', an integer or a predicate.
1216 See Info node `(gnus)Customizing Articles' and Info node
1217 `(gnus)Smileys' for details."
1218 :group 'gnus-article-treat
1220 :link '(custom-manual "(gnus)Customizing Articles")
1221 :link '(custom-manual "(gnus)Smileys")
1222 :type gnus-article-treat-custom)
1223 (put 'gnus-treat-display-smileys 'highlight t)
1225 (defcustom gnus-treat-from-picon
1226 (if (and (gnus-image-type-available-p 'xpm)
1227 (gnus-picons-installed-p))
1229 "Display picons in the From header.
1230 Valid values are nil, t, `head', `last', an integer or a predicate.
1231 See Info node `(gnus)Customizing Articles' and Info node
1232 `(gnus)Picons' for details."
1233 :group 'gnus-article-treat
1235 :link '(custom-manual "(gnus)Customizing Articles")
1236 :link '(custom-manual "(gnus)Picons")
1237 :type gnus-article-treat-head-custom)
1238 (put 'gnus-treat-from-picon 'highlight t)
1240 (defcustom gnus-treat-mail-picon
1241 (if (and (gnus-image-type-available-p 'xpm)
1242 (gnus-picons-installed-p))
1244 "Display picons in To and Cc headers.
1245 Valid values are nil, t, `head', `last', an integer or a predicate.
1246 See Info node `(gnus)Customizing Articles' and Info node
1247 `(gnus)Picons' for details."
1248 :group 'gnus-article-treat
1250 :link '(custom-manual "(gnus)Customizing Articles")
1251 :link '(custom-manual "(gnus)Picons")
1252 :type gnus-article-treat-head-custom)
1253 (put 'gnus-treat-mail-picon 'highlight t)
1255 (defcustom gnus-treat-newsgroups-picon
1256 (if (and (gnus-image-type-available-p 'xpm)
1257 (gnus-picons-installed-p))
1259 "Display picons in the Newsgroups and Followup-To headers.
1260 Valid values are nil, t, `head', `last', an integer or a predicate.
1261 See Info node `(gnus)Customizing Articles' and Info node
1262 `(gnus)Picons' for details."
1263 :group 'gnus-article-treat
1265 :link '(custom-manual "(gnus)Customizing Articles")
1266 :link '(custom-manual "(gnus)Picons")
1267 :type gnus-article-treat-head-custom)
1268 (put 'gnus-treat-newsgroups-picon 'highlight t)
1270 (defcustom gnus-treat-body-boundary
1271 (if (or gnus-treat-newsgroups-picon
1272 gnus-treat-mail-picon
1273 gnus-treat-from-picon)
1275 "Draw a boundary at the end of the headers.
1276 Valid values are nil, t, `head', `last', an integer or a predicate.
1277 See Info node `(gnus)Customizing Articles' for details."
1279 :group 'gnus-article-treat
1280 :link '(custom-manual "(gnus)Customizing Articles")
1281 :type gnus-article-treat-custom)
1283 (defcustom gnus-treat-capitalize-sentences nil
1284 "Capitalize sentence-starting words.
1285 Valid values are nil, t, `head', `last', an integer or a predicate.
1286 See Info node `(gnus)Customizing Articles' for details."
1288 :group 'gnus-article-treat
1289 :link '(custom-manual "(gnus)Customizing Articles")
1290 :type gnus-article-treat-custom)
1292 (defcustom gnus-treat-wash-html nil
1294 Valid values are nil, t, `head', `last', an integer or a predicate.
1295 See Info node `(gnus)Customizing Articles' for details."
1296 :group 'gnus-article-treat
1297 :link '(custom-manual "(gnus)Customizing Articles")
1298 :type gnus-article-treat-custom)
1300 (defcustom gnus-treat-fill-long-lines nil
1302 Valid values are nil, t, `head', `last', an integer or a predicate.
1303 See Info node `(gnus)Customizing Articles' for details."
1304 :group 'gnus-article-treat
1305 :link '(custom-manual "(gnus)Customizing Articles")
1306 :type gnus-article-treat-custom)
1308 (defcustom gnus-treat-play-sounds nil
1310 Valid values are nil, t, `head', `last', an integer or a predicate.
1311 See Info node `(gnus)Customizing Articles' for details."
1313 :group 'gnus-article-treat
1314 :link '(custom-manual "(gnus)Customizing Articles")
1315 :type gnus-article-treat-custom)
1317 (defcustom gnus-treat-translate nil
1318 "Translate articles from one language to another.
1319 Valid values are nil, t, `head', `last', an integer or a predicate.
1320 See Info node `(gnus)Customizing Articles' for details."
1322 :group 'gnus-article-treat
1323 :link '(custom-manual "(gnus)Customizing Articles")
1324 :type gnus-article-treat-custom)
1326 (defcustom gnus-treat-x-pgp-sig nil
1328 To automatically treat X-PGP-Sig, set it to head.
1329 Valid values are nil, t, `head', `last', an integer or a predicate.
1330 See Info node `(gnus)Customizing Articles' for details."
1331 :group 'gnus-article-treat
1332 :group 'mime-security
1333 :link '(custom-manual "(gnus)Customizing Articles")
1334 :type gnus-article-treat-custom)
1336 (defvar gnus-article-encrypt-protocol-alist
1337 '(("PGP" . mml2015-self-encrypt)))
1339 ;; Set to nil if more than one protocol added to
1340 ;; gnus-article-encrypt-protocol-alist.
1341 (defcustom gnus-article-encrypt-protocol "PGP"
1342 "The protocol used for encrypt articles.
1343 It is a string, such as \"PGP\". If nil, ask user."
1345 :group 'mime-security)
1347 (defvar gnus-article-wash-function nil
1348 "Function used for converting HTML into text.")
1350 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1351 (mm-coding-system-p 'utf-8)
1352 (executable-find idna-program))
1353 "Whether IDNA decoding of headers is used when viewing messages.
1354 This requires GNU Libidn, and by default only enabled if it is found."
1355 :group 'gnus-article-headers
1358 (defcustom gnus-article-over-scroll nil
1359 "If non-nil, allow scrolling the article buffer even when there no more text."
1360 :group 'gnus-article
1363 ;;; Internal variables
1365 (defvar gnus-english-month-names
1366 '("January" "February" "March" "April" "May" "June" "July" "August"
1367 "September" "October" "November" "December"))
1369 (defvar article-goto-body-goes-to-point-min-p nil)
1370 (defvar gnus-article-wash-types nil)
1371 (defvar gnus-article-emphasis-alist nil)
1372 (defvar gnus-article-image-alist nil)
1374 (defvar gnus-article-mime-handle-alist-1 nil)
1375 (defvar gnus-treatment-function-alist
1376 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1377 (gnus-treat-strip-banner gnus-article-strip-banner)
1378 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1379 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1380 (gnus-treat-buttonize gnus-article-add-buttons)
1381 (gnus-treat-fill-article gnus-article-fill-cited-article)
1382 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1383 (gnus-treat-strip-cr gnus-article-remove-cr)
1384 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1385 (gnus-treat-date-ut gnus-article-date-ut)
1386 (gnus-treat-date-local gnus-article-date-local)
1387 (gnus-treat-date-english gnus-article-date-english)
1388 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1389 (gnus-treat-date-original gnus-article-date-original)
1390 (gnus-treat-date-user-defined gnus-article-date-user)
1391 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1392 (gnus-treat-display-x-face gnus-article-display-x-face)
1393 (gnus-treat-display-face gnus-article-display-face)
1394 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1395 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1396 (gnus-treat-hide-signature gnus-article-hide-signature)
1397 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1398 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1399 (gnus-treat-strip-pem gnus-article-hide-pem)
1400 (gnus-treat-from-picon gnus-treat-from-picon)
1401 (gnus-treat-mail-picon gnus-treat-mail-picon)
1402 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1403 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1404 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1405 (gnus-treat-strip-trailing-blank-lines
1406 gnus-article-remove-trailing-blank-lines)
1407 (gnus-treat-strip-leading-blank-lines
1408 gnus-article-strip-leading-blank-lines)
1409 (gnus-treat-strip-multiple-blank-lines
1410 gnus-article-strip-multiple-blank-lines)
1411 (gnus-treat-overstrike gnus-article-treat-overstrike)
1412 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1413 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1414 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1415 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1416 (gnus-treat-display-smileys gnus-treat-smiley)
1417 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1418 (gnus-treat-wash-html gnus-article-wash-html)
1419 (gnus-treat-emphasize gnus-article-emphasize)
1420 (gnus-treat-hide-citation gnus-article-hide-citation)
1421 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1422 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1423 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1424 (gnus-treat-play-sounds gnus-earcon-display)))
1426 (defvar gnus-article-mime-handle-alist nil)
1427 (defvar article-lapsed-timer nil)
1428 (defvar gnus-article-current-summary nil)
1430 (defvar gnus-article-mode-syntax-table
1431 (let ((table (copy-syntax-table text-mode-syntax-table)))
1432 ;; This causes the citation match run O(2^n).
1433 ;; (modify-syntax-entry ?- "w" table)
1434 (modify-syntax-entry ?> ")<" table)
1435 (modify-syntax-entry ?< "(>" table)
1436 ;; make M-. in article buffers work for `foo' strings
1437 (modify-syntax-entry ?' " " table)
1438 (modify-syntax-entry ?` " " table)
1440 "Syntax table used in article mode buffers.
1441 Initialized from `text-mode-syntax-table.")
1443 (defvar gnus-save-article-buffer nil)
1445 (defvar gnus-article-mode-line-format-alist
1446 (nconc '((?w (gnus-article-wash-status) ?s)
1447 (?m (gnus-article-mime-part-status) ?s))
1448 gnus-summary-mode-line-format-alist))
1450 (defvar gnus-number-of-articles-to-be-saved nil)
1452 (defvar gnus-inhibit-hiding nil)
1454 ;;; Macros for dealing with the article buffer.
1456 (defmacro gnus-with-article-headers (&rest forms)
1458 (set-buffer gnus-article-buffer)
1460 (let ((buffer-read-only nil)
1461 (inhibit-point-motion-hooks t)
1462 (case-fold-search t))
1463 (article-narrow-to-head)
1466 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1467 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1469 (defmacro gnus-with-article-buffer (&rest forms)
1471 (set-buffer gnus-article-buffer)
1472 (let ((buffer-read-only nil))
1475 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1476 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1478 (defun gnus-article-goto-header (header)
1479 "Go to HEADER, which is a regular expression."
1480 (re-search-forward (concat "^\\(" header "\\):") nil t))
1482 (defsubst gnus-article-hide-text (b e props)
1483 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1484 (gnus-add-text-properties-when 'article-type nil b e props)
1485 (when (memq 'intangible props)
1487 (max (1- b) (point-min))
1488 b 'intangible (cddr (memq 'intangible props)))))
1490 (defsubst gnus-article-unhide-text (b e)
1491 "Remove hidden text properties from region between B and E."
1492 (remove-text-properties b e gnus-hidden-properties)
1493 (when (memq 'intangible gnus-hidden-properties)
1494 (put-text-property (max (1- b) (point-min))
1495 b 'intangible nil)))
1497 (defun gnus-article-hide-text-type (b e type)
1498 "Hide text of TYPE between B and E."
1499 (gnus-add-wash-type type)
1500 (gnus-article-hide-text
1501 b e (cons 'article-type (cons type gnus-hidden-properties))))
1503 (defun gnus-article-unhide-text-type (b e type)
1504 "Unhide text of TYPE between B and E."
1505 (gnus-delete-wash-type type)
1506 (remove-text-properties
1507 b e (cons 'article-type (cons type gnus-hidden-properties)))
1508 (when (memq 'intangible gnus-hidden-properties)
1509 (put-text-property (max (1- b) (point-min))
1510 b 'intangible nil)))
1512 (defun gnus-article-hide-text-of-type (type)
1513 "Hide text of TYPE in the current buffer."
1515 (let ((b (point-min))
1517 (while (setq b (text-property-any b e 'article-type type))
1518 (add-text-properties b (incf b) gnus-hidden-properties)))))
1520 (defun gnus-article-delete-text-of-type (type)
1521 "Delete text of TYPE in the current buffer."
1523 (let ((b (point-min)))
1524 (while (setq b (text-property-any b (point-max) 'article-type type))
1526 b (or (text-property-not-all b (point-max) 'article-type type)
1529 (defun gnus-article-delete-invisible-text ()
1530 "Delete all invisible text in the current buffer."
1532 (let ((b (point-min)))
1533 (while (setq b (text-property-any b (point-max) 'invisible t))
1535 b (or (text-property-not-all b (point-max) 'invisible t)
1538 (defun gnus-article-text-type-exists-p (type)
1539 "Say whether any text of type TYPE exists in the buffer."
1540 (text-property-any (point-min) (point-max) 'article-type type))
1542 (defsubst gnus-article-header-rank ()
1543 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1544 (let ((list gnus-sorted-header-list)
1547 (if (looking-at (car list))
1549 (setq list (cdr list))
1553 (defun article-hide-headers (&optional arg delete)
1554 "Hide unwanted headers and possibly sort them as well."
1556 ;; This function might be inhibited.
1557 (unless gnus-inhibit-hiding
1560 (let ((buffer-read-only nil)
1561 (case-fold-search t)
1562 (max (1+ (length gnus-sorted-header-list)))
1563 (ignored (when (not gnus-visible-headers)
1564 (cond ((stringp gnus-ignored-headers)
1565 gnus-ignored-headers)
1566 ((listp gnus-ignored-headers)
1567 (mapconcat 'identity gnus-ignored-headers
1570 (cond ((stringp gnus-visible-headers)
1571 gnus-visible-headers)
1572 ((and gnus-visible-headers
1573 (listp gnus-visible-headers))
1574 (mapconcat 'identity gnus-visible-headers "\\|"))))
1575 (inhibit-point-motion-hooks t)
1577 ;; First we narrow to just the headers.
1578 (article-narrow-to-head)
1579 ;; Hide any "From " lines at the beginning of (mail) articles.
1580 (while (looking-at "From ")
1583 (delete-region (point-min) (point)))
1584 ;; Then treat the rest of the header lines.
1585 ;; Then we use the two regular expressions
1586 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1587 ;; select which header lines is to remain visible in the
1589 (while (re-search-forward "^[^ \t:]*:" nil t)
1591 ;; Mark the rank of the header.
1593 (point) (1+ (point)) 'message-rank
1594 (if (or (and visible (looking-at visible))
1596 (not (looking-at ignored))))
1597 (gnus-article-header-rank)
1600 (message-sort-headers-1)
1601 (when (setq beg (text-property-any
1602 (point-min) (point-max) 'message-rank (+ 2 max)))
1603 ;; We delete the unwanted headers.
1604 (gnus-add-wash-type 'headers)
1605 (add-text-properties (point-min) (+ 5 (point-min))
1606 '(article-type headers dummy-invisible t))
1607 (delete-region beg (point-max))))))))
1609 (defun article-hide-boring-headers (&optional arg)
1610 "Toggle hiding of headers that aren't very interesting.
1611 If given a negative prefix, always show; if given a positive prefix,
1613 (interactive (gnus-article-hidden-arg))
1614 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1615 (not gnus-show-all-headers))
1618 (let ((buffer-read-only nil)
1619 (list gnus-boring-article-headers)
1620 (inhibit-point-motion-hooks t)
1622 (article-narrow-to-head)
1624 (setq elem (pop list))
1625 (goto-char (point-min))
1627 ;; Hide empty headers.
1629 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1631 (gnus-article-hide-text-type
1635 (if (re-search-forward "^[^ \t]" nil t)
1639 ;; Hide boring Newsgroups header.
1640 ((eq elem 'newsgroups)
1641 (when (gnus-string-equal
1642 (gnus-fetch-field "newsgroups")
1643 (gnus-group-real-name
1644 (if (boundp 'gnus-newsgroup-name)
1647 (gnus-article-hide-header "newsgroups")))
1648 ((eq elem 'to-address)
1649 (let ((to (message-fetch-field "to"))
1651 (gnus-parameter-to-address
1652 (if (boundp 'gnus-newsgroup-name)
1653 gnus-newsgroup-name ""))))
1654 (when (and to to-address
1657 ;; only one address in To
1658 (nth 1 (mail-extract-address-components to))
1660 (gnus-article-hide-header "to"))))
1662 (let ((to (message-fetch-field "to"))
1664 (gnus-parameter-to-list
1665 (if (boundp 'gnus-newsgroup-name)
1666 gnus-newsgroup-name ""))))
1667 (when (and to to-list
1670 ;; only one address in To
1671 (nth 1 (mail-extract-address-components to))
1673 (gnus-article-hide-header "to"))))
1675 (let ((cc (message-fetch-field "cc"))
1677 (gnus-parameter-to-list
1678 (if (boundp 'gnus-newsgroup-name)
1679 gnus-newsgroup-name ""))))
1680 (when (and cc to-list
1683 ;; only one address in CC
1684 (nth 1 (mail-extract-address-components cc))
1686 (gnus-article-hide-header "cc"))))
1687 ((eq elem 'followup-to)
1688 (when (gnus-string-equal
1689 (message-fetch-field "followup-to")
1690 (message-fetch-field "newsgroups"))
1691 (gnus-article-hide-header "followup-to")))
1692 ((eq elem 'reply-to)
1693 (if (gnus-group-find-parameter
1694 gnus-newsgroup-name 'broken-reply-to)
1695 (gnus-article-hide-header "reply-to")
1696 (let ((from (message-fetch-field "from"))
1697 (reply-to (message-fetch-field "reply-to")))
1702 (nth 1 (mail-extract-address-components from))
1703 (nth 1 (mail-extract-address-components reply-to)))))
1704 (gnus-article-hide-header "reply-to")))))
1706 (let ((date (message-fetch-field "date")))
1708 (< (days-between (current-time-string) date)
1710 (gnus-article-hide-header "date"))))
1712 (let ((to (message-fetch-field "to"))
1713 (cc (message-fetch-field "cc")))
1714 (when (> (length to) 1024)
1715 (gnus-article-hide-header "to"))
1716 (when (> (length cc) 1024)
1717 (gnus-article-hide-header "cc"))))
1721 (goto-char (point-min))
1722 (while (re-search-forward "^to:" nil t)
1723 (setq to-count (1+ to-count)))
1724 (when (> to-count 1)
1725 (while (> to-count 0)
1726 (goto-char (point-min))
1728 (re-search-forward "^to:" nil nil to-count)
1730 (narrow-to-region (point) (point-max))
1731 (gnus-article-hide-header "to"))
1732 (setq to-count (1- to-count))))
1733 (goto-char (point-min))
1734 (while (re-search-forward "^cc:" nil t)
1735 (setq cc-count (1+ cc-count)))
1736 (when (> cc-count 1)
1737 (while (> cc-count 0)
1738 (goto-char (point-min))
1740 (re-search-forward "^cc:" nil nil cc-count)
1742 (narrow-to-region (point) (point-max))
1743 (gnus-article-hide-header "cc"))
1744 (setq cc-count (1- cc-count)))))))))))))
1746 (defun gnus-article-hide-header (header)
1748 (goto-char (point-min))
1749 (when (re-search-forward (concat "^" header ":") nil t)
1750 (gnus-article-hide-text-type
1754 (if (re-search-forward "^[^ \t]" nil t)
1759 (defvar gnus-article-normalized-header-length 40
1760 "Length of normalized headers.")
1762 (defun article-normalize-headers ()
1763 "Make all header lines 40 characters long."
1765 (let ((buffer-read-only nil)
1769 (article-narrow-to-head)
1772 ((< (setq column (- (gnus-point-at-eol) (point)))
1773 gnus-article-normalized-header-length)
1775 (insert (make-string
1776 (- gnus-article-normalized-header-length column)
1778 ((> column gnus-article-normalized-header-length)
1779 (gnus-put-text-property
1781 (forward-char gnus-article-normalized-header-length)
1788 (forward-line 1))))))
1790 (defun article-treat-dumbquotes ()
1791 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1792 Note that this function guesses whether a character is a sm*rtq**t* or
1793 not, so it should only be used interactively.
1795 Sm*rtq**t*s are M****s***'s unilateral extension to the
1796 iso-8859-1 character map in an attempt to provide more quoting
1797 characters. If you see something like \\222 or \\264 where
1798 you're expecting some kind of apostrophe or quotation mark, then
1801 (article-translate-strings gnus-article-dumbquotes-map))
1803 (defun article-translate-characters (from to)
1804 "Translate all characters in the body of the article according to FROM and TO.
1805 FROM is a string of characters to translate from; to is a string of
1806 characters to translate to."
1808 (when (article-goto-body)
1809 (let ((buffer-read-only nil)
1810 (x (make-string 225 ?x))
1812 (while (< (incf i) (length x))
1815 (while (< i (length from))
1816 (aset x (aref from i) (aref to i))
1818 (translate-region (point) (point-max) x)))))
1820 (defun article-translate-strings (map)
1821 "Translate all string in the body of the article according to MAP.
1822 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1824 (when (article-goto-body)
1825 (let ((buffer-read-only nil)
1827 (while (setq elem (pop map))
1829 (while (search-forward (car elem) nil t)
1830 (replace-match (cadr elem)))))))))
1832 (defun article-treat-overstrike ()
1833 "Translate overstrikes into bold text."
1836 (when (article-goto-body)
1837 (let ((buffer-read-only nil))
1838 (while (search-forward "\b" nil t)
1839 (let ((next (char-after))
1840 (previous (char-after (- (point) 2))))
1841 ;; We do the boldification/underlining by hiding the
1842 ;; overstrikes and putting the proper text property
1846 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1847 (put-text-property (point) (1+ (point)) 'face 'bold))
1849 (gnus-article-hide-text-type
1850 (1- (point)) (1+ (point)) 'overstrike)
1852 (- (point) 2) (1- (point)) 'face 'underline))
1854 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1856 (point) (1+ (point)) 'face 'underline)))))))))
1858 (defun gnus-article-treat-unfold-headers ()
1859 "Unfold folded message headers.
1860 Only the headers that fit into the current window width will be
1863 (gnus-with-article-headers
1867 (mail-header-narrow-to-field)
1868 (let ((header (buffer-string)))
1871 (goto-char (point-min))
1872 (while (re-search-forward "\n[\t ]" nil t)
1873 (replace-match " " t t)))
1874 (setq length (- (point-max) (point-min) 1)))
1875 (when (< length (window-width))
1876 (while (re-search-forward "\n[\t ]" nil t)
1877 (replace-match " " t t)))
1878 (goto-char (point-max)))))))
1880 (defun gnus-article-treat-fold-headers ()
1881 "Fold message headers."
1883 (gnus-with-article-headers
1886 (mail-header-narrow-to-field)
1887 (mail-header-fold-field)
1888 (goto-char (point-max))))))
1890 (defun gnus-treat-smiley ()
1891 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1893 (gnus-with-article-buffer
1894 (if (memq 'smiley gnus-article-wash-types)
1895 (gnus-delete-images 'smiley)
1897 (let ((images (smiley-region (point) (point-max))))
1899 (gnus-add-wash-type 'smiley)
1900 (dolist (image images)
1901 (gnus-add-image 'smiley image)))))))
1903 (defun gnus-article-remove-images ()
1904 "Remove all images from the article buffer."
1906 (gnus-with-article-buffer
1907 (dolist (elem gnus-article-image-alist)
1908 (gnus-delete-images (car elem)))))
1910 (defun gnus-article-treat-fold-newsgroups ()
1911 "Unfold folded message headers.
1912 Only the headers that fit into the current window width will be
1915 (gnus-with-article-headers
1916 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1918 (mail-header-narrow-to-field)
1919 (while (re-search-forward ", *" nil t)
1920 (replace-match ", " t t))
1921 (mail-header-fold-field)
1922 (goto-char (point-max))))))
1924 (defun gnus-article-treat-body-boundary ()
1925 "Place a boundary line at the end of the headers."
1927 (when (and gnus-body-boundary-delimiter
1928 (> (length gnus-body-boundary-delimiter) 0))
1929 (gnus-with-article-headers
1930 (goto-char (point-max))
1931 (let ((start (point)))
1932 (insert "X-Boundary: ")
1933 (gnus-add-text-properties start (point) '(invisible t intangible t))
1935 (while (>= (1- (window-width)) (length str))
1936 (setq str (concat str gnus-body-boundary-delimiter)))
1937 (substring str 0 (1- (window-width))))
1939 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1941 (defun article-fill-long-lines ()
1942 "Fill lines that are wider than the window width."
1945 (let ((buffer-read-only nil)
1946 (width (window-width (get-buffer-window (current-buffer)))))
1949 (let ((adaptive-fill-mode nil)) ;Why? -sm
1952 (when (>= (current-column) (min fill-column width))
1953 (narrow-to-region (min (1+ (point)) (point-max))
1954 (gnus-point-at-bol))
1955 (let ((goback (point-marker)))
1956 (fill-paragraph nil)
1957 (goto-char (marker-position goback)))
1959 (forward-line 1)))))))
1961 (defun article-capitalize-sentences ()
1962 "Capitalize the first word in each sentence."
1965 (let ((buffer-read-only nil)
1966 (paragraph-start "^[\n\^L]"))
1970 (forward-sentence)))))
1972 (defun article-remove-cr ()
1973 "Remove trailing CRs and then translate remaining CRs into LFs."
1976 (let ((buffer-read-only nil))
1977 (goto-char (point-min))
1978 (while (re-search-forward "\r+$" nil t)
1979 (replace-match "" t t))
1980 (goto-char (point-min))
1981 (while (search-forward "\r" nil t)
1982 (replace-match "\n" t t)))))
1984 (defun article-remove-trailing-blank-lines ()
1985 "Remove all trailing blank lines from the article."
1988 (let ((buffer-read-only nil))
1989 (goto-char (point-max))
1993 (while (and (not (bobp))
1994 (looking-at "^[ \t]*$")
1995 (not (gnus-annotation-in-region-p
1996 (point) (gnus-point-at-eol))))
2001 (defun article-display-face ()
2002 "Display any Face headers in the header."
2004 (let ((wash-face-p buffer-read-only))
2005 (gnus-with-article-headers
2006 ;; When displaying parts, this function can be called several times on
2007 ;; the same article, without any intended toggle semantic (as typing `W
2008 ;; D d' would have). So face deletion must occur only when we come from
2009 ;; an interactive command, that is when the *Article* buffer is
2011 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2012 (gnus-delete-images 'face)
2015 (when (and wash-face-p
2017 (goto-char (point-min))
2018 (not (re-search-forward "^Face:[\t ]*" nil t)))
2019 (gnus-buffer-live-p gnus-original-article-buffer))
2020 (set-buffer gnus-original-article-buffer))
2022 (mail-narrow-to-head)
2023 (while (gnus-article-goto-header "Face")
2024 (push (mail-header-field-value) faces))))
2025 (while (setq face (pop faces))
2026 (let ((png (gnus-convert-face-to-png face))
2029 (setq image (gnus-create-image png 'png t))
2030 (gnus-article-goto-header "from")
2032 (insert "From: [no `from' set]\n")
2034 (gnus-add-wash-type 'face)
2035 (gnus-add-image 'face image)
2036 (gnus-put-image image nil 'face))))))
2039 (defun article-display-x-face (&optional force)
2040 "Look for an X-Face header and display it if present."
2041 (interactive (list 'force))
2042 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2043 (gnus-with-article-headers
2044 ;; Delete the old process, if any.
2045 (when (process-status "article-x-face")
2046 (delete-process "article-x-face"))
2047 ;; See the comment in `article-display-face'.
2048 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2049 ;; We have already displayed X-Faces, so we remove them
2051 (gnus-delete-images 'xface)
2053 (let (x-faces from face)
2055 (when (and wash-face-p
2057 (goto-char (point-min))
2058 (not (re-search-forward
2059 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2060 (gnus-buffer-live-p gnus-original-article-buffer))
2061 ;; If type `W f', use gnus-original-article-buffer,
2062 ;; otherwise use the current buffer because displaying
2063 ;; RFC822 parts calls this function too.
2064 (set-buffer gnus-original-article-buffer))
2066 (mail-narrow-to-head)
2067 (while (gnus-article-goto-header "X-Face")
2068 (push (mail-header-field-value) x-faces))
2069 (setq from (message-fetch-field "from"))))
2070 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2071 ;; single external face.
2072 (when (stringp gnus-article-x-face-command)
2073 (setq x-faces (list (car x-faces))))
2074 (while (and (setq face (pop x-faces))
2075 gnus-article-x-face-command
2077 ;; Check whether this face is censored.
2078 (not gnus-article-x-face-too-ugly)
2079 (and gnus-article-x-face-too-ugly from
2080 (not (string-match gnus-article-x-face-too-ugly
2082 ;; We display the face.
2083 (cond ((stringp gnus-article-x-face-command)
2084 ;; The command is a string, so we interpret the command
2085 ;; as a, well, command, and fork it off.
2086 (let ((process-connection-type nil))
2087 (process-kill-without-query
2089 "article-x-face" nil shell-file-name
2090 shell-command-switch gnus-article-x-face-command))
2093 (process-send-region "article-x-face"
2094 (point-min) (point-max)))
2095 (process-send-eof "article-x-face")))
2096 ((functionp gnus-article-x-face-command)
2097 ;; The command is a lisp function, so we call it.
2098 (funcall gnus-article-x-face-command face))
2100 (error "%s is not a function"
2101 gnus-article-x-face-command)))))))))
2103 (defun article-decode-mime-words ()
2104 "Decode all MIME-encoded words in the article."
2107 (set-buffer gnus-article-buffer)
2108 (let ((inhibit-point-motion-hooks t)
2110 (mail-parse-charset gnus-newsgroup-charset)
2111 (mail-parse-ignored-charsets
2112 (save-excursion (set-buffer gnus-summary-buffer)
2113 gnus-newsgroup-ignored-charsets)))
2114 (mail-decode-encoded-word-region (point-min) (point-max)))))
2116 (defun article-decode-charset (&optional prompt)
2117 "Decode charset-encoded text in the article.
2118 If PROMPT (the prefix), prompt for a coding system to use."
2120 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2122 (mail-parse-charset gnus-newsgroup-charset)
2123 (mail-parse-ignored-charsets
2124 (save-excursion (condition-case nil
2125 (set-buffer gnus-summary-buffer)
2127 gnus-newsgroup-ignored-charsets))
2128 ct cte ctl charset format)
2131 (article-narrow-to-head)
2132 (setq ct (message-fetch-field "Content-Type" t)
2133 cte (message-fetch-field "Content-Transfer-Encoding" t)
2134 ctl (and ct (ignore-errors
2135 (mail-header-parse-content-type ct)))
2138 (mm-read-coding-system "Charset to decode: "))
2140 (mail-content-type-get ctl 'charset)))
2141 format (and ctl (mail-content-type-get ctl 'format)))
2143 (setq cte (mail-header-strip cte)))
2144 (if (and ctl (not (string-match "/" (car ctl))))
2146 (goto-char (point-max)))
2149 (narrow-to-region (point) (point-max))
2150 (when (and (eq mail-parse-charset 'gnus-decoded)
2151 (eq (mm-body-7-or-8) '8bit))
2152 ;; The text code could have been decoded.
2153 (setq charset mail-parse-charset))
2154 (when (and (or (not ctl)
2155 (equal (car ctl) "text/plain"))
2156 (not format)) ;; article with format will decode later.
2158 charset (and cte (intern (downcase
2159 (gnus-strip-whitespace cte))))
2162 (defun article-decode-encoded-words ()
2163 "Remove encoded-word encoding from headers."
2164 (let ((inhibit-point-motion-hooks t)
2165 (mail-parse-charset gnus-newsgroup-charset)
2166 (mail-parse-ignored-charsets
2167 (save-excursion (condition-case nil
2168 (set-buffer gnus-summary-buffer)
2170 gnus-newsgroup-ignored-charsets))
2173 (article-narrow-to-head)
2174 (funcall gnus-decode-header-function (point-min) (point-max)))))
2176 (defun article-decode-group-name ()
2177 "Decode group names in `Newsgroups:'."
2178 (let ((inhibit-point-motion-hooks t)
2180 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2181 (when (and (or gnus-group-name-charset-method-alist
2182 gnus-group-name-charset-group-alist)
2183 (gnus-buffer-live-p gnus-original-article-buffer))
2185 (article-narrow-to-head)
2186 (with-current-buffer gnus-original-article-buffer
2187 (goto-char (point-min)))
2188 (while (re-search-forward
2189 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2190 (replace-match (save-match-data
2191 (gnus-decode-newsgroups
2192 ;; XXX how to use data in article buffer?
2193 (with-current-buffer gnus-original-article-buffer
2195 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2198 gnus-newsgroup-name method))
2200 (goto-char (point-min))
2201 (with-current-buffer gnus-original-article-buffer
2202 (goto-char (point-min)))
2203 (while (re-search-forward
2204 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2205 (replace-match (save-match-data
2206 (gnus-decode-newsgroups
2207 ;; XXX how to use data in article buffer?
2208 (with-current-buffer gnus-original-article-buffer
2210 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2213 gnus-newsgroup-name method))
2216 (autoload 'idna-to-unicode "idna")
2218 (defun article-decode-idna-rhs ()
2219 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2222 (let ((inhibit-point-motion-hooks t)
2224 (article-narrow-to-head)
2225 (goto-char (point-min))
2226 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2228 (when (save-match-data
2229 (and (setq ace (match-string 1))
2231 (and (re-search-backward "^[^ \t]" nil t)
2232 (looking-at "From\\|To\\|Cc")))
2233 (save-excursion (backward-char)
2234 (message-idna-inside-rhs-p))
2235 (setq unicode (idna-to-unicode ace))))
2236 (unless (string= ace unicode)
2237 (replace-match unicode nil nil nil 1)))))))))
2239 (defun article-de-quoted-unreadable (&optional force read-charset)
2240 "Translate a quoted-printable-encoded article.
2241 If FORCE, decode the article whether it is marked as quoted-printable
2243 If READ-CHARSET, ask for a coding system."
2244 (interactive (list 'force current-prefix-arg))
2246 (let ((buffer-read-only nil) type charset)
2247 (if (gnus-buffer-live-p gnus-original-article-buffer)
2248 (with-current-buffer gnus-original-article-buffer
2250 (gnus-fetch-field "content-transfer-encoding"))
2251 (let* ((ct (gnus-fetch-field "content-type"))
2254 (mail-header-parse-content-type ct)))))
2255 (setq charset (and ctl
2256 (mail-content-type-get ctl 'charset)))
2257 (if (stringp charset)
2258 (setq charset (intern (downcase charset)))))))
2260 (setq charset (mm-read-coding-system "Charset: " charset)))
2262 (setq charset gnus-newsgroup-charset))
2264 (and type (let ((case-fold-search t))
2265 (string-match "quoted-printable" type))))
2267 (quoted-printable-decode-region
2268 (point) (point-max) (mm-charset-to-coding-system charset))))))
2270 (defun article-de-base64-unreadable (&optional force read-charset)
2271 "Translate a base64 article.
2272 If FORCE, decode the article whether it is marked as base64 not.
2273 If READ-CHARSET, ask for a coding system."
2274 (interactive (list 'force current-prefix-arg))
2276 (let ((buffer-read-only nil) type charset)
2277 (if (gnus-buffer-live-p gnus-original-article-buffer)
2278 (with-current-buffer gnus-original-article-buffer
2280 (gnus-fetch-field "content-transfer-encoding"))
2281 (let* ((ct (gnus-fetch-field "content-type"))
2284 (mail-header-parse-content-type ct)))))
2285 (setq charset (and ctl
2286 (mail-content-type-get ctl 'charset)))
2287 (if (stringp charset)
2288 (setq charset (intern (downcase charset)))))))
2290 (setq charset (mm-read-coding-system "Charset: " charset)))
2292 (setq charset gnus-newsgroup-charset))
2294 (and type (let ((case-fold-search t))
2295 (string-match "base64" type))))
2298 (narrow-to-region (point) (point-max))
2299 (base64-decode-region (point-min) (point-max))
2300 (mm-decode-coding-region
2301 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2306 (defun article-decode-HZ ()
2307 "Translate a HZ-encoded article."
2311 (let ((buffer-read-only nil))
2312 (rfc1843-decode-region (point-min) (point-max)))))
2314 (defun article-unsplit-urls ()
2315 "Remove the newlines that some other mailers insert into URLs."
2318 (let ((buffer-read-only nil))
2319 (goto-char (point-min))
2320 (while (re-search-forward
2321 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2322 (replace-match "\\1\\3" t)))
2323 (when (interactive-p)
2324 (gnus-treat-article nil))))
2327 (defun article-wash-html (&optional read-charset)
2328 "Format an HTML article.
2329 If READ-CHARSET, ask for a coding system."
2332 (let ((buffer-read-only nil)
2334 (when (gnus-buffer-live-p gnus-original-article-buffer)
2335 (with-current-buffer gnus-original-article-buffer
2336 (let* ((ct (gnus-fetch-field "content-type"))
2339 (mail-header-parse-content-type ct)))))
2340 (setq charset (and ctl
2341 (mail-content-type-get ctl 'charset)))
2342 (when (stringp charset)
2343 (setq charset (intern (downcase charset)))))))
2345 (setq charset (mm-read-coding-system "Charset: " charset)))
2347 (setq charset gnus-newsgroup-charset))
2349 (save-window-excursion
2351 (narrow-to-region (point) (point-max))
2352 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2353 (entry (assq func mm-text-html-washer-alist)))
2355 (setq func (cdr entry)))
2360 (apply (car func) (cdr func))))))))))
2362 (defun gnus-article-wash-html-with-w3 ()
2363 "Wash the current buffer with w3."
2365 (let ((w3-strict-width (window-width))
2366 (url-standalone-mode t)
2367 (url-gateway-unplugged t)
2368 (w3-honor-stylesheets nil))
2370 (w3-region (point-min) (point-max))
2373 (defun gnus-article-wash-html-with-w3m ()
2374 "Wash the current buffer with emacs-w3m."
2377 (narrow-to-region (point) (point-max))
2378 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2381 w3m-force-redisplay)
2382 (w3m-region (point-min) (point-max)))
2383 (when mm-inline-text-html-with-w3m-keymap
2384 (add-text-properties
2385 (point-min) (point-max)
2386 (nconc (mm-w3m-local-map-property)
2387 '(mm-inline-text-html-with-w3m t))))))
2389 (defun article-hide-list-identifiers ()
2390 "Remove list identifies from the Subject header.
2391 The `gnus-list-identifiers' variable specifies what to do."
2393 (let ((inhibit-point-motion-hooks t)
2394 (regexp (if (consp gnus-list-identifiers)
2395 (mapconcat 'identity gnus-list-identifiers " *\\|")
2396 gnus-list-identifiers))
2401 (article-narrow-to-head)
2402 (goto-char (point-min))
2403 (while (re-search-forward
2404 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2406 (delete-region (match-beginning 2) (match-end 0))
2407 (beginning-of-line))
2408 (when (re-search-forward
2409 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2410 (delete-region (match-beginning 1) (match-end 1))))))))
2412 (defun article-hide-pem (&optional arg)
2413 "Toggle hiding of any PEM headers and signatures in the current article.
2414 If given a negative prefix, always show; if given a positive prefix,
2416 (interactive (gnus-article-hidden-arg))
2417 (unless (gnus-article-check-hidden-text 'pem arg)
2419 (let (buffer-read-only end)
2420 (goto-char (point-min))
2421 ;; Hide the horrendously ugly "header".
2422 (when (and (search-forward
2423 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2425 (setq end (1+ (match-beginning 0))))
2426 (gnus-add-wash-type 'pem)
2427 (gnus-article-hide-text-type
2429 (if (search-forward "\n\n" nil t)
2433 ;; Hide the trailer as well
2434 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2436 (gnus-article-hide-text-type
2437 (match-beginning 0) (match-end 0) 'pem)))))))
2439 (defun article-strip-banner ()
2440 "Strip the banners specified by the `banner' group parameter and by
2441 `gnus-article-address-banner-alist'."
2445 (let ((inhibit-point-motion-hooks t))
2446 (when (gnus-parameter-banner gnus-newsgroup-name)
2447 (article-really-strip-banner
2448 (gnus-parameter-banner gnus-newsgroup-name)))
2449 (when gnus-article-address-banner-alist
2450 (article-really-strip-banner
2451 (let ((from (save-restriction
2453 (article-narrow-to-head)
2454 (mail-fetch-field "from"))))
2457 (caar (mail-header-parse-addresses from))))
2459 (dolist (pair gnus-article-address-banner-alist)
2460 (when (string-match (car pair) from)
2461 (throw 'found (cdr pair)))))))))))))
2463 (defun article-really-strip-banner (banner)
2464 "Strip the banner specified by the argument."
2467 (let ((inhibit-point-motion-hooks t)
2468 (gnus-signature-limit nil)
2472 ((eq banner 'signature)
2473 (when (gnus-article-narrow-to-signature)
2476 (delete-region (point) (point-max))))
2478 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2479 (while (re-search-forward banner nil t)
2480 (delete-region (match-beginning 0) (match-end 0)))))
2482 (while (re-search-forward banner nil t)
2483 (delete-region (match-beginning 0) (match-end 0)))))))))
2485 (defun article-babel ()
2486 "Translate article using an online translation service."
2490 (set-buffer gnus-article-buffer)
2491 (when (article-goto-body)
2492 (let* ((buffer-read-only nil)
2495 (orig (buffer-substring start end))
2496 (trans (babel-as-string orig)))
2498 (narrow-to-region start end)
2499 (delete-region start end)
2502 (defun article-hide-signature (&optional arg)
2503 "Hide the signature in the current article.
2504 If given a negative prefix, always show; if given a positive prefix,
2506 (interactive (gnus-article-hidden-arg))
2507 (unless (gnus-article-check-hidden-text 'signature arg)
2510 (let ((buffer-read-only nil))
2511 (when (gnus-article-narrow-to-signature)
2512 (gnus-article-hide-text-type
2513 (point-min) (point-max) 'signature))))))
2514 (gnus-set-mode-line 'article))
2516 (defun article-strip-headers-in-body ()
2517 "Strip offensive headers from bodies."
2521 (let ((case-fold-search t))
2522 (when (looking-at "x-no-archive:")
2523 (gnus-delete-line)))))
2525 (defun article-strip-leading-blank-lines ()
2526 "Remove all blank lines from the beginning of the article."
2529 (let ((inhibit-point-motion-hooks t)
2531 (when (article-goto-body)
2532 (while (and (not (eobp))
2533 (looking-at "[ \t]*$"))
2534 (gnus-delete-line))))))
2536 (defun article-narrow-to-head ()
2537 "Narrow the buffer to the head of the message.
2538 Point is left at the beginning of the narrowed-to region."
2540 (goto-char (point-min))
2541 (if (search-forward "\n\n" nil 1)
2544 (goto-char (point-min)))
2546 (defun article-goto-body ()
2547 "Place point at the start of the body."
2548 (goto-char (point-min))
2550 ;; This variable is only bound when dealing with separate
2552 (article-goto-body-goes-to-point-min-p
2554 ((search-forward "\n\n" nil t)
2557 (goto-char (point-max))
2560 (defun article-strip-multiple-blank-lines ()
2561 "Replace consecutive blank lines with one empty line."
2564 (let ((inhibit-point-motion-hooks t)
2566 ;; First make all blank lines empty.
2568 (while (re-search-forward "^[ \t]+$" nil t)
2569 (unless (gnus-annotation-in-region-p
2570 (match-beginning 0) (match-end 0))
2571 (replace-match "" nil t)))
2572 ;; Then replace multiple empty lines with a single empty line.
2574 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2575 (unless (gnus-annotation-in-region-p
2576 (match-beginning 0) (match-end 0))
2577 (delete-region (match-beginning 1) (match-end 1)))))))
2579 (defun article-strip-leading-space ()
2580 "Remove all white space from the beginning of the lines in the article."
2583 (let ((inhibit-point-motion-hooks t)
2586 (while (re-search-forward "^[ \t]+" nil t)
2587 (replace-match "" t t)))))
2589 (defun article-strip-trailing-space ()
2590 "Remove all white space from the end of the lines in the article."
2593 (let ((inhibit-point-motion-hooks t)
2596 (while (re-search-forward "[ \t]+$" nil t)
2597 (replace-match "" t t)))))
2599 (defun article-strip-blank-lines ()
2600 "Strip leading, trailing and multiple blank lines."
2602 (article-strip-leading-blank-lines)
2603 (article-remove-trailing-blank-lines)
2604 (article-strip-multiple-blank-lines))
2606 (defun article-strip-all-blank-lines ()
2607 "Strip all blank lines."
2610 (let ((inhibit-point-motion-hooks t)
2613 (while (re-search-forward "^[ \t]*\n" nil t)
2614 (replace-match "" t t)))))
2616 (defun gnus-article-narrow-to-signature ()
2617 "Narrow to the signature; return t if a signature is found, else nil."
2618 (let ((inhibit-point-motion-hooks t))
2619 (when (gnus-article-search-signature)
2621 ;; Check whether we have some limits to what we consider
2622 ;; to be a signature.
2623 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2624 (list gnus-signature-limit)))
2626 (while (setq limit (pop limits))
2627 (if (or (and (integerp limit)
2628 (< (- (point-max) (point)) limit))
2630 (< (count-lines (point) (point-max)) limit))
2631 (and (functionp limit)
2633 (and (stringp limit)
2634 (not (re-search-forward limit nil t))))
2635 () ; This limit did not succeed.
2639 (narrow-to-region (point) (point-max))
2642 (defun gnus-article-search-signature ()
2643 "Search the current buffer for the signature separator.
2644 Put point at the beginning of the signature separator."
2645 (let ((cur (point)))
2646 (goto-char (point-max))
2647 (if (if (stringp gnus-signature-separator)
2648 (re-search-backward gnus-signature-separator nil t)
2649 (let ((seps gnus-signature-separator))
2651 (not (re-search-backward (car seps) nil t)))
2658 (defun gnus-article-hidden-arg ()
2659 "Return the current prefix arg as a number, or 0 if no prefix."
2660 (list (if current-prefix-arg
2661 (prefix-numeric-value current-prefix-arg)
2664 (defun gnus-article-check-hidden-text (type arg)
2665 "Return nil if hiding is necessary.
2666 Arg can be nil or a number. nil and positive means hide, negative
2667 means show, 0 means toggle."
2670 (let ((hide (gnus-article-hidden-text-p type)))
2676 (gnus-article-show-hidden-text type)
2679 (if (eq hide 'hidden)
2681 (gnus-article-show-hidden-text type)
2685 (defun gnus-article-hidden-text-p (type)
2686 "Say whether the current buffer contains hidden text of type TYPE."
2687 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2689 (not (get-text-property pos 'invisible))
2690 (not (get-text-property pos 'dummy-invisible)))
2692 (text-property-any (1+ pos) (point-max) 'article-type type)))
2697 (defun gnus-article-show-hidden-text (type &optional dummy)
2698 "Show all hidden text of type TYPE.
2699 Originally it is hide instead of DUMMY."
2700 (let ((buffer-read-only nil)
2701 (inhibit-point-motion-hooks t))
2702 (gnus-remove-text-properties-when
2704 (point-min) (point-max)
2705 (cons 'article-type (cons type
2706 gnus-hidden-properties)))
2707 (gnus-delete-wash-type type)))
2709 (defconst article-time-units
2710 `((year . ,(* 365.25 24 60 60))
2711 (week . ,(* 7 24 60 60))
2712 (day . ,(* 24 60 60))
2716 "Mapping from time units to seconds.")
2718 (defun gnus-article-forward-header ()
2719 "Move point to the start of the next header.
2720 If the current header is a continuation header, this can be several
2725 (if (looking-at "[ \t]+[^ \t]")
2729 (defun article-date-ut (&optional type highlight header)
2730 "Convert DATE date to universal time in the current article.
2731 If TYPE is `local', convert to local time; if it is `lapsed', output
2732 how much time has lapsed since DATE. For `lapsed', the value of
2733 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2734 should replace the \"Date:\" one, or should be added below it."
2735 (interactive (list 'ut t))
2736 (let* ((header (or header
2737 (message-fetch-field "date")
2739 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2742 ((not gnus-article-date-lapsed-new-header)
2748 (date (if (vectorp header) (mail-header-date header)
2750 (inhibit-point-motion-hooks t)
2755 (article-narrow-to-head)
2756 (when (re-search-forward tdate-regexp nil t)
2757 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2758 date (or (get-text-property (gnus-point-at-bol)
2761 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2763 (when (and date (not (string= date "")))
2764 (goto-char (point-min))
2765 (let ((buffer-read-only nil))
2766 ;; Delete any old Date headers.
2767 (while (re-search-forward date-regexp nil t)
2769 (delete-region (progn (beginning-of-line) (point))
2770 (progn (gnus-article-forward-header)
2772 (delete-region (progn (beginning-of-line) (point))
2773 (progn (gnus-article-forward-header)
2776 (setq pos (point))))
2777 (when (and (not pos)
2778 (re-search-forward tdate-regexp nil t))
2782 (insert (article-make-date-line date (or type 'ut)))
2788 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2789 (put-text-property (match-beginning 1) (1+ (match-end 1))
2790 'original-date date)
2791 (put-text-property (match-beginning 1) (1+ (match-end 1))
2793 (put-text-property (match-beginning 2) (match-end 2)
2796 (defun article-make-date-line (date type)
2797 "Return a DATE line of TYPE."
2798 (unless (memq type '(local ut original user iso8601 lapsed english))
2799 (error "Unknown conversion type: %s" type))
2801 (let ((time (date-to-time date)))
2803 ;; Convert to the local timezone.
2805 (let ((tz (car (current-time-zone time))))
2806 (format "Date: %s %s%02d%02d" (current-time-string time)
2807 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2808 (/ (% (abs tz) 3600) 60))))
2809 ;; Convert to Universal Time.
2812 (current-time-string
2813 (let* ((e (parse-time-string date))
2814 (tm (apply 'encode-time e))
2816 (ls (- (cadr tm) (car (current-time-zone time)))))
2817 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2818 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2821 ;; Get the original date from the article.
2822 ((eq type 'original)
2823 (concat "Date: " (if (string-match "\n+$" date)
2824 (substring date 0 (match-beginning 0))
2826 ;; Let the user define the format.
2828 (let ((format (or (condition-case nil
2829 (with-current-buffer gnus-summary-buffer
2830 gnus-article-time-format)
2832 gnus-article-time-format)))
2833 (if (functionp format)
2834 (funcall format time)
2835 (concat "Date: " (format-time-string format time)))))
2838 (let ((tz (car (current-time-zone time))))
2841 (format-time-string "%Y%m%dT%H%M%S" time)
2842 (format "%s%02d%02d"
2843 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2844 (/ (% (abs tz) 3600) 60)))))
2845 ;; Do an X-Sent lapsed format.
2847 ;; If the date is seriously mangled, the timezone functions are
2848 ;; liable to bug out, so we ignore all errors.
2849 (let* ((now (current-time))
2850 (real-time (subtract-time now time))
2851 (real-sec (and real-time
2852 (+ (* (float (car real-time)) 65536)
2854 (sec (and real-time (abs real-sec)))
2864 ;; This is a bit convoluted, but basically we go
2865 ;; through the time units for years, weeks, etc,
2866 ;; and divide things to see whether that results
2867 ;; in positive answers.
2870 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2871 ;; The (remaining) seconds are too few to
2872 ;; be divided into this time unit.
2874 ;; It's big enough, so we output it.
2875 (setq sec (- sec (* num (cdr unit))))
2877 (concat (if prev ", " "") (int-to-string
2879 " " (symbol-name (car unit))
2880 (if (> num 1) "s" ""))
2882 article-time-units "")
2883 ;; If dates are odd, then it might appear like the
2884 ;; article was sent in the future.
2887 " in the future"))))))
2888 ;; Display the date in proper English
2890 (let ((dtime (decode-time time)))
2893 (number-to-string (nth 3 dtime))
2894 (let ((digit (% (nth 3 dtime) 10)))
2896 ((memq (nth 3 dtime) '(11 12 13)) "th")
2902 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2904 (number-to-string (nth 5 dtime))
2906 (format "%02d" (nth 2 dtime))
2908 (format "%02d" (nth 1 dtime)))))))
2910 (format "Date: %s (from Gnus)" date))))
2912 (defun article-date-local (&optional highlight)
2913 "Convert the current article date to the local timezone."
2914 (interactive (list t))
2915 (article-date-ut 'local highlight))
2917 (defun article-date-english (&optional highlight)
2918 "Convert the current article date to something that is proper English."
2919 (interactive (list t))
2920 (article-date-ut 'english highlight))
2922 (defun article-date-original (&optional highlight)
2923 "Convert the current article date to what it was originally.
2924 This is only useful if you have used some other date conversion
2925 function and want to see what the date was before converting."
2926 (interactive (list t))
2927 (article-date-ut 'original highlight))
2929 (defun article-date-lapsed (&optional highlight)
2930 "Convert the current article date to time lapsed since it was sent."
2931 (interactive (list t))
2932 (article-date-ut 'lapsed highlight))
2934 (defun article-update-date-lapsed ()
2935 "Function to be run from a timer to update the lapsed time line."
2936 (let (deactivate-mark)
2941 (set-buffer (window-buffer w))
2942 (when (eq major-mode 'gnus-article-mode)
2943 (let ((mark (point-marker)))
2944 (goto-char (point-min))
2945 (when (re-search-forward "^X-Sent:" nil t)
2946 (article-date-lapsed t))
2947 (goto-char (marker-position mark))
2948 (move-marker mark nil))))
2951 (defun gnus-start-date-timer (&optional n)
2952 "Start a timer to update the X-Sent header in the article buffers.
2953 The numerical prefix says how frequently (in seconds) the function
2958 (gnus-stop-date-timer)
2959 (setq article-lapsed-timer
2960 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2962 (defun gnus-stop-date-timer ()
2963 "Stop the X-Sent timer."
2965 (when article-lapsed-timer
2966 (nnheader-cancel-timer article-lapsed-timer)
2967 (setq article-lapsed-timer nil)))
2969 (defun article-date-user (&optional highlight)
2970 "Convert the current article date to the user-defined format.
2971 This format is defined by the `gnus-article-time-format' variable."
2972 (interactive (list t))
2973 (article-date-ut 'user highlight))
2975 (defun article-date-iso8601 (&optional highlight)
2976 "Convert the current article date to ISO8601."
2977 (interactive (list t))
2978 (article-date-ut 'iso8601 highlight))
2980 ;; (defun article-show-all ()
2981 ;; "Show all hidden text in the article buffer."
2984 ;; (let ((buffer-read-only nil))
2985 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2987 (defun article-remove-leading-whitespace ()
2988 "Remove excessive whitespace from all headers."
2992 (let ((buffer-read-only nil))
2993 (article-narrow-to-head)
2994 (goto-char (point-min))
2995 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2996 (delete-region (match-beginning 1) (match-end 1)))))))
2998 (defun article-emphasize (&optional arg)
2999 "Emphasize text according to `gnus-emphasis-alist'."
3000 (interactive (gnus-article-hidden-arg))
3001 (unless (gnus-article-check-hidden-text 'emphasis arg)
3005 (with-current-buffer gnus-summary-buffer
3006 gnus-article-emphasis-alist)
3008 gnus-emphasis-alist))
3009 (buffer-read-only nil)
3010 (props (append '(article-type emphasis)
3011 gnus-hidden-properties))
3012 regexp elem beg invisible visible face)
3015 (while (setq elem (pop alist))
3017 (setq regexp (car elem)
3018 invisible (nth 1 elem)
3019 visible (nth 2 elem)
3021 (while (re-search-forward regexp nil t)
3022 (when (and (match-beginning visible) (match-beginning invisible))
3023 (gnus-article-hide-text
3024 (match-beginning invisible) (match-end invisible) props)
3025 (gnus-article-unhide-text-type
3026 (match-beginning visible) (match-end visible) 'emphasis)
3027 (gnus-put-overlay-excluding-newlines
3028 (match-beginning visible) (match-end visible) 'face face)
3029 (gnus-add-wash-type 'emphasis)
3030 (goto-char (match-end invisible)))))))))
3032 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3033 "Setup newsgroup emphasis alist."
3034 (unless gnus-article-emphasis-alist
3035 (let ((name (and gnus-newsgroup-name
3036 (gnus-group-real-name gnus-newsgroup-name))))
3037 (make-local-variable 'gnus-article-emphasis-alist)
3038 (setq gnus-article-emphasis-alist
3040 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3041 (while (setq elem (pop alist))
3042 (when (and name (string-match (car elem) name))
3044 highlight (copy-sequence (cdr elem)))))
3046 (copy-sequence highlight-words)
3047 (if gnus-newsgroup-name
3048 (copy-sequence (gnus-group-find-parameter
3049 gnus-newsgroup-name 'highlight-words t)))
3050 gnus-emphasis-alist)))))
3053 (defvar gnus-summary-article-menu)
3054 (defvar gnus-summary-post-menu))
3056 ;;; Saving functions.
3058 (defun gnus-article-save (save-buffer file &optional num)
3059 "Save the currently selected article."
3060 (unless gnus-save-all-headers
3061 ;; Remove headers according to `gnus-saved-headers'.
3062 (let ((gnus-visible-headers
3063 (or gnus-saved-headers gnus-visible-headers))
3064 (gnus-article-buffer save-buffer))
3066 (set-buffer save-buffer)
3067 (article-hide-headers 1 t))))
3068 (save-window-excursion
3069 (if (not gnus-default-article-saver)
3070 (error "No default saver is defined")
3071 ;; !!! Magic! The saving functions all save
3072 ;; `gnus-save-article-buffer' (or so they think), but we
3073 ;; bind that variable to our save-buffer.
3074 (set-buffer gnus-article-buffer)
3075 (let* ((gnus-save-article-buffer save-buffer)
3078 ((not gnus-prompt-before-saving) 'default)
3079 ((eq gnus-prompt-before-saving 'always) nil)
3081 (gnus-number-of-articles-to-be-saved
3082 (when (eq gnus-prompt-before-saving t)
3084 (set-buffer gnus-article-current-summary)
3085 (funcall gnus-default-article-saver filename)))))
3087 (defun gnus-read-save-file-name (prompt &optional filename
3088 function group headers variable)
3090 (funcall function group headers (symbol-value variable)))
3095 ((eq filename 'default)
3101 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3104 (if (and gnus-number-of-articles-to-be-saved
3105 (> gnus-number-of-articles-to-be-saved 1))
3106 (format "these %d articles"
3107 gnus-number-of-articles-to-be-saved)
3110 ;; Let the split methods have their say.
3112 ;; No split name was found.
3115 (concat prompt " (default "
3116 (file-name-nondirectory default-name) ") ")
3117 (file-name-directory default-name)
3119 ;; A single group name is returned.
3120 ((stringp split-name)
3122 (funcall function split-name headers
3123 (symbol-value variable)))
3125 (concat prompt " (default "
3126 (file-name-nondirectory default-name) ") ")
3127 (file-name-directory default-name)
3129 ;; A single split name was found
3130 ((= 1 (length split-name))
3131 (let* ((name (expand-file-name
3133 gnus-article-save-directory))
3134 (dir (cond ((file-directory-p name)
3135 (file-name-as-directory name))
3136 ((file-exists-p name) name)
3137 (t gnus-article-save-directory))))
3139 (concat prompt " (default " name ") ")
3141 ;; A list of splits was found.
3143 (setq split-name (nreverse split-name))
3145 (let ((file-name-history
3146 (nconc split-name file-name-history)))
3150 (concat prompt " (`M-p' for defaults) ")
3151 gnus-article-save-directory
3153 gnus-article-save-directory)))
3154 (car (push result file-name-history)))))))
3155 ;; Create the directory.
3156 (gnus-make-directory (file-name-directory file))
3157 ;; If we have read a directory, we append the default file name.
3158 (when (file-directory-p file)
3159 (setq file (expand-file-name (file-name-nondirectory
3161 (file-name-as-directory file))))
3162 ;; Possibly translate some characters.
3163 (nnheader-translate-file-chars file))))))
3164 (gnus-make-directory (file-name-directory result))
3165 (set variable result)))
3167 (defun gnus-article-archive-name (group)
3168 "Return the first instance of an \"Archive-name\" in the current buffer."
3169 (let ((case-fold-search t))
3170 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3171 (nnheader-concat gnus-article-save-directory
3172 (match-string 1)))))
3174 (defun gnus-article-nndoc-name (group)
3175 "If GROUP is an nndoc group, return the name of the parent group."
3176 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3177 (gnus-group-get-parameter group 'save-article-group)))
3179 (defun gnus-summary-save-in-rmail (&optional filename)
3180 "Append this article to Rmail file.
3181 Optional argument FILENAME specifies file name.
3182 Directory to save to is default to `gnus-article-save-directory'."
3183 (setq filename (gnus-read-save-file-name
3184 "Save %s in rmail file:" filename
3185 gnus-rmail-save-name gnus-newsgroup-name
3186 gnus-current-headers 'gnus-newsgroup-last-rmail))
3187 (gnus-eval-in-buffer-window gnus-save-article-buffer
3191 (gnus-output-to-rmail filename))))
3194 (defun gnus-summary-save-in-mail (&optional filename)
3195 "Append this article to Unix mail file.
3196 Optional argument FILENAME specifies file name.
3197 Directory to save to is default to `gnus-article-save-directory'."
3198 (setq filename (gnus-read-save-file-name
3199 "Save %s in Unix mail file:" filename
3200 gnus-mail-save-name gnus-newsgroup-name
3201 gnus-current-headers 'gnus-newsgroup-last-mail))
3202 (gnus-eval-in-buffer-window gnus-save-article-buffer
3206 (if (and (file-readable-p filename)
3207 (file-regular-p filename)
3208 (mail-file-babyl-p filename))
3209 (rmail-output-to-rmail-file filename t)
3210 (gnus-output-to-mail filename)))))
3213 (defun gnus-summary-save-in-file (&optional filename overwrite)
3214 "Append this article to file.
3215 Optional argument FILENAME specifies file name.
3216 Directory to save to is default to `gnus-article-save-directory'."
3217 (setq filename (gnus-read-save-file-name
3218 "Save %s in file:" filename
3219 gnus-file-save-name gnus-newsgroup-name
3220 gnus-current-headers 'gnus-newsgroup-last-file))
3221 (gnus-eval-in-buffer-window gnus-save-article-buffer
3225 (when (and overwrite
3226 (file-exists-p filename))
3227 (delete-file filename))
3228 (gnus-output-to-file filename))))
3231 (defun gnus-summary-write-to-file (&optional filename)
3232 "Write this article to a file, overwriting it if the file exists.
3233 Optional argument FILENAME specifies file name.
3234 The directory to save in defaults to `gnus-article-save-directory'."
3235 (gnus-summary-save-in-file nil t))
3237 (defun gnus-summary-save-body-in-file (&optional filename)
3238 "Append this article body to a file.
3239 Optional argument FILENAME specifies file name.
3240 The directory to save in defaults to `gnus-article-save-directory'."
3241 (setq filename (gnus-read-save-file-name
3242 "Save %s body in file:" filename
3243 gnus-file-save-name gnus-newsgroup-name
3244 gnus-current-headers 'gnus-newsgroup-last-file))
3245 (gnus-eval-in-buffer-window gnus-save-article-buffer
3249 (when (article-goto-body)
3250 (narrow-to-region (point) (point-max)))
3251 (gnus-output-to-file filename))))
3254 (defun gnus-summary-save-in-pipe (&optional command)
3255 "Pipe this article to subprocess."
3257 (cond ((and (eq command 'default)
3258 gnus-last-shell-command)
3259 gnus-last-shell-command)
3264 "Shell command on %s: "
3265 (if (and gnus-number-of-articles-to-be-saved
3266 (> gnus-number-of-articles-to-be-saved 1))
3267 (format "these %d articles"
3268 gnus-number-of-articles-to-be-saved)
3270 gnus-last-shell-command))))
3271 (when (string-equal command "")
3272 (if gnus-last-shell-command
3273 (setq command gnus-last-shell-command)
3274 (error "A command is required")))
3275 (gnus-eval-in-buffer-window gnus-article-buffer
3278 (shell-command-on-region (point-min) (point-max) command nil)))
3279 (setq gnus-last-shell-command command))
3281 (defmacro gnus-read-string (prompt &optional initial-contents history
3283 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3284 (if (and (featurep 'xemacs)
3285 (< emacs-minor-version 2))
3286 `(read-string ,prompt ,initial-contents ,history)
3287 `(read-string ,prompt ,initial-contents ,history ,default-value)))
3289 (defun gnus-summary-pipe-to-muttprint (&optional command)
3290 "Pipe this article to muttprint."
3291 (setq command (gnus-read-string
3292 "Print using command: " gnus-summary-muttprint-program
3293 nil gnus-summary-muttprint-program))
3294 (gnus-summary-save-in-pipe command))
3296 ;;; Article file names when saving.
3298 (defun gnus-capitalize-newsgroup (newsgroup)
3299 "Capitalize NEWSGROUP name."
3300 (when (not (zerop (length newsgroup)))
3301 (concat (char-to-string (upcase (aref newsgroup 0)))
3302 (substring newsgroup 1))))
3304 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3305 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3306 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3307 Otherwise, it is like ~/News/news/group/num."
3310 (concat (if (gnus-use-long-file-name 'not-save)
3311 (gnus-capitalize-newsgroup newsgroup)
3312 (gnus-newsgroup-directory-form newsgroup))
3313 "/" (int-to-string (mail-header-number headers)))
3314 gnus-article-save-directory)))
3316 (string-equal (file-name-directory default)
3317 (file-name-directory last-file))
3318 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3320 (or last-file default))))
3322 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3323 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3324 If variable `gnus-use-long-file-name' is non-nil, it is
3325 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3328 (concat (if (gnus-use-long-file-name 'not-save)
3330 (gnus-newsgroup-directory-form newsgroup))
3331 "/" (int-to-string (mail-header-number headers)))
3332 gnus-article-save-directory)))
3334 (string-equal (file-name-directory default)
3335 (file-name-directory last-file))
3336 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3338 (or last-file default))))
3340 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3341 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3342 If variable `gnus-use-long-file-name' is non-nil, it is
3343 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3346 (if (gnus-use-long-file-name 'not-save)
3349 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3351 gnus-article-save-directory)))
3353 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3354 "Generate file name from sender."
3355 (let ((from (mail-header-from headers)))
3357 (if (and from (string-match "\\([^ <]+\\)@" from))
3358 (match-string 1 from)
3360 gnus-article-save-directory)))
3362 (defun article-verify-x-pgp-sig ()
3365 (if (gnus-buffer-live-p gnus-original-article-buffer)
3366 (let ((sig (with-current-buffer gnus-original-article-buffer
3367 (gnus-fetch-field "X-PGP-Sig")))
3371 (mml2015-clear-verify-function))
3373 (insert-buffer-substring gnus-original-article-buffer)
3374 (setq items (split-string sig))
3375 (message-narrow-to-head)
3376 (let ((inhibit-point-motion-hooks t)
3377 (case-fold-search t))
3378 ;; Don't verify multiple headers.
3379 (setq headers (mapconcat (lambda (header)
3381 (mail-fetch-field header)
3383 (split-string (nth 1 items) ",") "")))
3384 (delete-region (point-min) (point-max))
3385 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3386 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3391 (if (looking-at "^-")
3394 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3395 (insert "Version: " (car items) "\n\n")
3396 (insert (mapconcat 'identity (cddr items) "\n"))
3397 (insert "\n-----END PGP SIGNATURE-----\n")
3398 (let ((mm-security-handle (list (format "multipart/signed"))))
3399 (mml2015-clean-buffer)
3400 (let ((coding-system-for-write (or gnus-newsgroup-charset
3402 (funcall (mml2015-clear-verify-function)))
3404 (or (mm-handle-multipart-ctl-parameter
3405 mm-security-handle 'gnus-details)
3406 (mm-handle-multipart-ctl-parameter
3407 mm-security-handle 'gnus-info)))))
3409 (let (buffer-read-only bface eface)
3411 (message-narrow-to-head)
3412 (goto-char (point-max))
3414 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3415 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3416 (message-remove-header "X-Gnus-PGP-Verify")
3417 (if (re-search-forward "^X-PGP-Sig:" nil t)
3419 (goto-char (point-max)))
3420 (narrow-to-region (point) (point))
3421 (insert "X-Gnus-PGP-Verify: " info "\n")
3422 (goto-char (point-min))
3425 (if (not (looking-at "^[ \t]"))
3429 (goto-char (point-min))
3430 (when (looking-at "\\([^:]+\\): *")
3431 (put-text-property (match-beginning 1) (1+ (match-end 1))
3433 (put-text-property (match-end 0) (point-max)
3434 'face eface)))))))))
3436 (defun article-verify-cancel-lock ()
3437 "Verify Cancel-Lock header."
3439 (if (gnus-buffer-live-p gnus-original-article-buffer)
3440 (canlock-verify gnus-original-article-buffer)))
3447 (setq afunc (car func)
3450 gfunc (intern (format "gnus-%s" func))))
3452 (when (fboundp afunc)
3453 `(lambda (&optional interactive &rest args)
3454 ,(documentation afunc t)
3455 (interactive (list t))
3457 (set-buffer gnus-article-buffer)
3459 (call-interactively ',afunc)
3460 (apply ',afunc args))))))))
3461 '(article-hide-headers
3462 article-verify-x-pgp-sig
3463 article-verify-cancel-lock
3464 article-hide-boring-headers
3465 article-treat-overstrike
3466 article-fill-long-lines
3467 article-capitalize-sentences
3469 article-remove-leading-whitespace
3470 article-display-x-face
3471 article-display-face
3472 article-de-quoted-unreadable
3473 article-de-base64-unreadable
3476 article-unsplit-urls
3477 article-hide-list-identifiers
3478 article-strip-banner
3481 article-hide-signature
3482 article-strip-headers-in-body
3483 article-remove-trailing-blank-lines
3484 article-strip-leading-blank-lines
3485 article-strip-multiple-blank-lines
3486 article-strip-leading-space
3487 article-strip-trailing-space
3488 article-strip-blank-lines
3489 article-strip-all-blank-lines
3491 article-date-english
3492 article-date-iso8601
3493 article-date-original
3495 article-decode-mime-words
3496 article-decode-charset
3497 article-decode-encoded-words
3501 article-treat-dumbquotes
3502 article-normalize-headers
3503 ;; (article-show-all . gnus-article-show-all-headers)
3507 ;;; Gnus article mode
3510 (put 'gnus-article-mode 'mode-class 'special)
3512 (set-keymap-parent gnus-article-mode-map widget-keymap)
3514 (gnus-define-keys gnus-article-mode-map
3515 " " gnus-article-goto-next-page
3516 "\177" gnus-article-goto-prev-page
3517 [delete] gnus-article-goto-prev-page
3518 [backspace] gnus-article-goto-prev-page
3519 "\C-c^" gnus-article-refer-article
3520 "h" gnus-article-show-summary
3521 "s" gnus-article-show-summary
3522 "\C-c\C-m" gnus-article-mail
3523 "?" gnus-article-describe-briefly
3524 "e" gnus-summary-edit-article
3525 "<" beginning-of-buffer
3527 "\C-c\C-i" gnus-info-find-node
3529 "R" gnus-article-reply-with-original
3530 "F" gnus-article-followup-with-original
3531 "\C-hk" gnus-article-describe-key
3532 "\C-hc" gnus-article-describe-key-briefly
3534 "\C-d" gnus-article-read-summary-keys
3535 "\M-*" gnus-article-read-summary-keys
3536 "\M-#" gnus-article-read-summary-keys
3537 "\M-^" gnus-article-read-summary-keys
3538 "\M-g" gnus-article-read-summary-keys)
3540 (substitute-key-definition
3541 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3543 (defun gnus-article-make-menu-bar ()
3544 (unless (boundp 'gnus-article-commands-menu)
3545 (gnus-summary-make-menu-bar))
3546 (gnus-turn-off-edit-menu 'article)
3547 (unless (boundp 'gnus-article-article-menu)
3549 gnus-article-article-menu gnus-article-mode-map ""
3551 ["Scroll forwards" gnus-article-goto-next-page t]
3552 ["Scroll backwards" gnus-article-goto-prev-page t]
3553 ["Show summary" gnus-article-show-summary t]
3554 ["Fetch Message-ID at point" gnus-article-refer-article t]
3555 ["Mail to address at point" gnus-article-mail t]
3556 ["Send a bug report" gnus-bug t]))
3559 gnus-article-treatment-menu gnus-article-mode-map ""
3560 ;; Fixme: this should use :active (and maybe :visible).
3562 ["Hide headers" gnus-article-hide-headers t]
3563 ["Hide signature" gnus-article-hide-signature t]
3564 ["Hide citation" gnus-article-hide-citation t]
3565 ["Treat overstrike" gnus-article-treat-overstrike t]
3566 ["Remove carriage return" gnus-article-remove-cr t]
3567 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3568 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3569 ["Remove base64" gnus-article-de-base64-unreadable t]
3570 ["Treat html" gnus-article-wash-html t]
3571 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3572 ["Decode HZ" gnus-article-decode-HZ t]))
3574 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3576 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3578 (gnus-run-hooks 'gnus-article-menu-hook)))
3580 (defun gnus-article-mode ()
3581 "Major mode for displaying an article.
3583 All normal editing commands are switched off.
3585 The following commands are available in addition to all summary mode
3587 \\<gnus-article-mode-map>
3588 \\[gnus-article-next-page]\t Scroll the article one page forwards
3589 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3590 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3591 \\[gnus-article-show-summary]\t Display the summary buffer
3592 \\[gnus-article-mail]\t Send a reply to the address near point
3593 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3594 \\[gnus-info-find-node]\t Go to the Gnus info node"
3596 (gnus-simplify-mode-line)
3597 (setq mode-name "Article")
3598 (setq major-mode 'gnus-article-mode)
3599 (make-local-variable 'minor-mode-alist)
3600 (use-local-map gnus-article-mode-map)
3601 (when (gnus-visual-p 'article-menu 'menu)
3602 (gnus-article-make-menu-bar)
3603 (when gnus-summary-tool-bar-map
3604 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3605 (gnus-update-format-specifications nil 'article-mode)
3606 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3607 (set (make-local-variable 'gnus-page-broken) nil)
3608 (make-local-variable 'gnus-button-marker-list)
3609 (make-local-variable 'gnus-article-current-summary)
3610 (make-local-variable 'gnus-article-mime-handles)
3611 (make-local-variable 'gnus-article-decoded-p)
3612 (make-local-variable 'gnus-article-mime-handle-alist)
3613 (make-local-variable 'gnus-article-wash-types)
3614 (make-local-variable 'gnus-article-image-alist)
3615 (make-local-variable 'gnus-article-charset)
3616 (make-local-variable 'gnus-article-ignored-charsets)
3617 (gnus-set-default-directory)
3618 (buffer-disable-undo)
3619 (setq buffer-read-only t)
3620 (set-syntax-table gnus-article-mode-syntax-table)
3621 (mm-enable-multibyte)
3622 (gnus-run-hooks 'gnus-article-mode-hook))
3624 (defun gnus-article-setup-buffer ()
3625 "Initialize the article buffer."
3626 (let* ((name (if gnus-single-article-buffer "*Article*"
3627 (concat "*Article " gnus-newsgroup-name "*")))
3629 (progn (string-match "\\*Article" name)
3630 (concat " *Original Article"
3631 (substring name (match-end 0))))))
3632 (setq gnus-article-buffer name)
3633 (setq gnus-original-article-buffer original)
3634 (setq gnus-article-mime-handle-alist nil)
3635 ;; This might be a variable local to the summary buffer.
3636 (unless gnus-single-article-buffer
3638 (set-buffer gnus-summary-buffer)
3639 (setq gnus-article-buffer name)
3640 (setq gnus-original-article-buffer original)
3641 (gnus-set-global-variables)))
3642 (gnus-article-setup-highlight-words)
3643 ;; Init original article buffer.
3645 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3646 (mm-enable-multibyte)
3647 (setq major-mode 'gnus-original-article-mode)
3648 (make-local-variable 'gnus-original-article))
3649 (if (get-buffer name)
3652 (when (and gnus-article-edit-mode
3655 (y-or-n-p "Article mode edit in progress; discard? ")))
3656 (error "Action aborted"))
3657 (set (make-local-variable 'gnus-article-edit-mode) nil)
3658 (when gnus-article-mime-handles
3659 (mm-destroy-parts gnus-article-mime-handles)
3660 (setq gnus-article-mime-handles nil))
3661 ;; Set it to nil in article-buffer!
3662 (setq gnus-article-mime-handle-alist nil)
3663 (buffer-disable-undo)
3664 (setq buffer-read-only t)
3665 ;; This list just keeps growing if we don't reset it.
3666 (setq gnus-button-marker-list nil)
3667 (unless (eq major-mode 'gnus-article-mode)
3668 (gnus-article-mode))
3671 (set-buffer (gnus-get-buffer-create name))
3673 (make-local-variable 'gnus-summary-buffer)
3674 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3675 (current-buffer)))))
3677 ;; Set article window start at LINE, where LINE is the number of lines
3678 ;; from the head of the article.
3679 (defun gnus-article-set-window-start (&optional line)
3681 (gnus-get-buffer-window gnus-article-buffer t)
3683 (set-buffer gnus-article-buffer)
3684 (goto-char (point-min))
3687 (gnus-message 6 "Moved to bookmark")
3688 (search-forward "\n\n" nil t)
3692 (defun gnus-article-prepare (article &optional all-headers header)
3693 "Prepare ARTICLE in article mode buffer.
3694 ARTICLE should either be an article number or a Message-ID.
3695 If ARTICLE is an id, HEADER should be the article headers.
3696 If ALL-HEADERS is non-nil, no headers are hidden."
3698 ;; Make sure we start in a summary buffer.
3699 (unless (eq major-mode 'gnus-summary-mode)
3700 (set-buffer gnus-summary-buffer))
3701 (setq gnus-summary-buffer (current-buffer))
3702 (let* ((gnus-article (if header (mail-header-number header) article))
3703 (summary-buffer (current-buffer))
3704 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3705 (group gnus-newsgroup-name)
3708 (gnus-article-setup-buffer)
3709 (set-buffer gnus-article-buffer)
3710 ;; Deactivate active regions.
3711 (when (and (boundp 'transient-mark-mode)
3712 transient-mark-mode)
3713 (setq mark-active nil))
3714 (if (not (setq result (let ((buffer-read-only nil))
3715 (gnus-request-article-this-buffer
3717 ;; There is no such article.
3719 (when (and (numberp article)
3720 (not (memq article gnus-newsgroup-sparse)))
3721 (setq gnus-article-current
3722 (cons gnus-newsgroup-name article))
3723 (set-buffer gnus-summary-buffer)
3724 (setq gnus-current-article article)
3725 (if (and (memq article gnus-newsgroup-undownloaded)
3726 (not (gnus-online (gnus-find-method-for-group
3727 gnus-newsgroup-name))))
3729 (gnus-summary-set-agent-mark article)
3730 (message "Message marked for downloading"))
3731 (gnus-summary-mark-article article gnus-canceled-mark)
3732 (unless (memq article gnus-newsgroup-sparse)
3733 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3734 (if (or (eq result 'pseudo)
3735 (eq result 'nneething))
3738 (set-buffer summary-buffer)
3739 (push article gnus-newsgroup-history)
3740 (setq gnus-last-article gnus-current-article
3741 gnus-current-article 0
3742 gnus-current-headers nil
3743 gnus-article-current nil)
3744 (if (eq result 'nneething)
3745 (gnus-configure-windows 'summary)
3746 (gnus-configure-windows 'article))
3747 (gnus-set-global-variables))
3748 (let ((gnus-article-mime-handle-alist-1
3749 gnus-article-mime-handle-alist))
3750 (gnus-set-mode-line 'article)))
3751 ;; The result from the `request' was an actual article -
3752 ;; or at least some text that is now displayed in the
3754 (when (and (numberp article)
3755 (not (eq article gnus-current-article)))
3756 ;; Seems like a new article has been selected.
3757 ;; `gnus-current-article' must be an article number.
3759 (set-buffer summary-buffer)
3760 (push article gnus-newsgroup-history)
3761 (setq gnus-last-article gnus-current-article
3762 gnus-current-article article
3763 gnus-current-headers
3764 (gnus-summary-article-header gnus-current-article)
3765 gnus-article-current
3766 (cons gnus-newsgroup-name gnus-current-article))
3767 (unless (vectorp gnus-current-headers)
3768 (setq gnus-current-headers nil))
3769 (gnus-summary-goto-subject gnus-current-article)
3770 (when (gnus-summary-show-thread)
3771 ;; If the summary buffer really was folded, the
3772 ;; previous goto may not actually have gone to
3773 ;; the right article, but the thread root instead.
3775 (gnus-summary-goto-subject gnus-current-article))
3776 (gnus-run-hooks 'gnus-mark-article-hook)
3777 (gnus-set-mode-line 'summary)
3778 (when (gnus-visual-p 'article-highlight 'highlight)
3779 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3780 ;; Set the global newsgroup variables here.
3781 (gnus-set-global-variables)
3782 (setq gnus-have-all-headers
3783 (or all-headers gnus-show-all-headers))))
3785 (gnus-configure-windows 'article))
3786 (when (or (numberp article)
3788 (gnus-article-prepare-display)
3790 (goto-char (point-min))
3791 (when gnus-break-pages
3792 (gnus-narrow-to-page)))
3793 (let ((gnus-article-mime-handle-alist-1
3794 gnus-article-mime-handle-alist))
3795 (gnus-set-mode-line 'article))
3799 (set-window-point (get-buffer-window (current-buffer)) (point))
3800 (gnus-configure-windows 'article)
3804 (defun gnus-article-prepare-display ()
3805 "Make the current buffer look like a nice article."
3806 ;; Hooks for getting information from the article.
3807 ;; This hook must be called before being narrowed.
3808 (let ((gnus-article-buffer (current-buffer))
3810 (unless (eq major-mode 'gnus-article-mode)
3811 (gnus-article-mode))
3812 (setq buffer-read-only nil
3813 gnus-article-wash-types nil
3814 gnus-article-image-alist nil)
3815 (gnus-run-hooks 'gnus-tmp-internal-hook)
3816 (when gnus-display-mime-function
3817 (funcall gnus-display-mime-function))
3818 (gnus-run-hooks 'gnus-article-prepare-hook)))
3821 ;;; Gnus MIME viewing functions
3824 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3825 "Format of the MIME buttons.
3827 Valid specifiers include:
3829 %T MIME type, along with additional info
3830 %n The `name' parameter
3831 %d The description, if any
3832 %l The length of the encoded part
3833 %p The part identifier number
3834 %e Dots if the part isn't displayed
3836 General format specifiers can also be used. See Info node
3837 `(gnus)Formatting Variables'.")
3839 (defvar gnus-mime-button-line-format-alist
3840 '((?t gnus-tmp-type ?s)
3841 (?T gnus-tmp-type-long ?s)
3842 (?n gnus-tmp-name ?s)
3843 (?d gnus-tmp-description ?s)
3845 (?l gnus-tmp-length ?d)
3846 (?e gnus-tmp-dots ?s)))
3848 (defvar gnus-mime-button-commands
3849 '((gnus-article-press-button "\r" "Toggle Display")
3850 (gnus-mime-view-part "v" "View Interactively...")
3851 (gnus-mime-view-part-as-type "t" "View As Type...")
3852 (gnus-mime-view-part-as-charset "C" "View As charset...")
3853 (gnus-mime-save-part "o" "Save...")
3854 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3855 (gnus-mime-delete-part "d" "Delete part")
3856 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3857 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3858 (gnus-mime-view-part-internally "E" "View Internally")
3859 (gnus-mime-view-part-externally "e" "View Externally")
3860 (gnus-mime-print-part "p" "Print")
3861 (gnus-mime-pipe-part "|" "Pipe To Command...")
3862 (gnus-mime-action-on-part "." "Take action on the part...")))
3864 (defun gnus-article-mime-part-status ()
3865 (if gnus-article-mime-handle-alist-1
3866 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3868 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3871 (defvar gnus-mime-button-map
3872 (let ((map (make-sparse-keymap)))
3873 (unless (>= (string-to-number emacs-version) 21)
3874 ;; XEmacs doesn't care.
3875 (set-keymap-parent map gnus-article-mode-map))
3876 (define-key map gnus-mouse-2 'gnus-article-push-button)
3877 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3878 (dolist (c gnus-mime-button-commands)
3879 (define-key map (cadr c) (car c)))
3883 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
3885 ,@(mapcar (lambda (c)
3886 (vector (caddr c) (car c) :enable t))
3887 gnus-mime-button-commands)))
3890 (define-compiler-macro popup-menu (&whole form
3891 menu &optional position prefix)
3892 (if (and (fboundp 'popup-menu)
3893 (not (memq 'popup-menu (assoc "lmenu" load-history))))
3895 ;; Gnus is probably running under Emacs 20.
3896 `(let* ((menu (cdr ,menu))
3897 (response (x-popup-menu
3899 (cons "" (mapcar (lambda (c)
3900 (cons (caddr c) (car c)))
3903 (call-interactively (nth 3 (assq response menu))))))))
3905 (defun gnus-mime-button-menu (event prefix)
3906 "Construct a context-sensitive menu of MIME commands."
3907 (interactive "e\nP")
3908 (save-window-excursion
3909 (let ((pos (event-start event)))
3910 (select-window (posn-window pos))
3911 (goto-char (posn-point pos))
3912 (gnus-article-check-buffer)
3913 (popup-menu gnus-mime-button-menu nil prefix))))
3915 (defun gnus-mime-view-all-parts (&optional handles)
3916 "View all the MIME parts."
3918 (save-current-buffer
3919 (set-buffer gnus-article-buffer)
3920 (let ((handles (or handles gnus-article-mime-handles))
3921 (mail-parse-charset gnus-newsgroup-charset)
3922 (mail-parse-ignored-charsets
3923 (with-current-buffer gnus-summary-buffer
3924 gnus-newsgroup-ignored-charsets)))
3926 (mm-remove-parts handles)
3927 (goto-char (point-min))
3928 (or (search-forward "\n\n") (goto-char (point-max)))
3929 (let (buffer-read-only)
3930 (delete-region (point) (point-max))
3931 (mm-display-parts handles))))))
3933 (defun gnus-mime-save-part-and-strip ()
3934 "Save the MIME part under point then replace it with an external body."
3936 (gnus-article-check-buffer)
3937 (let* ((data (get-text-property (point) 'gnus-data))
3939 (handles gnus-article-mime-handles))
3940 (if (mm-multiple-handles gnus-article-mime-handles)
3941 (error "This function is not implemented"))
3942 (setq file (and data (mm-save-part data)))
3944 (with-current-buffer (mm-handle-buffer data)
3946 (insert "Content-Type: " (mm-handle-media-type data))
3947 (mml-insert-parameter-string (cdr (mm-handle-type data))
3950 (insert "Content-ID: " (message-make-message-id) "\n")
3951 (insert "Content-Transfer-Encoding: binary\n")
3954 (cdr (mm-make-handle nil
3955 `("message/external-body"
3956 (access-type . "LOCAL-FILE")
3958 (set-buffer gnus-summary-buffer)
3959 (gnus-article-edit-article
3962 (let ((mail-parse-charset (or gnus-article-charset
3963 ',gnus-newsgroup-charset))
3964 (mail-parse-ignored-charsets
3965 (or gnus-article-ignored-charsets
3966 ',gnus-newsgroup-ignored-charsets))
3967 (mbl mml-buffer-list))
3968 (setq mml-buffer-list nil)
3969 (insert-buffer gnus-original-article-buffer)
3970 (mime-to-mml ',handles)
3971 (setq gnus-article-mime-handles nil)
3972 (let ((mbl1 mml-buffer-list))
3973 (setq mml-buffer-list mbl)
3974 (set (make-local-variable 'mml-buffer-list) mbl1))
3975 (gnus-make-local-hook 'kill-buffer-hook)
3976 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3977 `(lambda (no-highlight)
3978 (let ((mail-parse-charset (or gnus-article-charset
3979 ',gnus-newsgroup-charset))
3980 (message-options message-options)
3981 (message-options-set-recipient)
3982 (mail-parse-ignored-charsets
3983 (or gnus-article-ignored-charsets
3984 ',gnus-newsgroup-ignored-charsets)))
3986 (mml-destroy-buffers)
3987 (remove-hook 'kill-buffer-hook
3988 'mml-destroy-buffers t)
3989 (kill-local-variable 'mml-buffer-list))
3990 (gnus-summary-edit-article-done
3991 ,(or (mail-header-references gnus-current-headers) "")
3992 ,(gnus-group-read-only-p)
3993 ,gnus-summary-buffer no-highlight))))))
3995 (defun gnus-mime-delete-part ()
3996 "Delete the MIME part under point.
3997 Replace it with some information about the removed part."
3999 (gnus-article-check-buffer)
4000 (unless (and gnus-novice-user
4001 (not (gnus-yes-or-no-p
4002 "Really delete attachment forever? ")))
4003 (let* ((data (get-text-property (point) 'gnus-data))
4004 (handles gnus-article-mime-handles)
4008 (mail-decode-encoded-word-string (or (mm-handle-description data)
4011 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4013 (type (mm-handle-media-type data)))
4014 (if (mm-multiple-handles gnus-article-mime-handles)
4015 (error "This function is not implemented"))
4016 (with-current-buffer (mm-handle-buffer data)
4017 (let ((bsize (format "%s" (buffer-size))))
4022 "| The following attachment has been deleted:\n"
4024 "| Type: " type "\n"
4025 "| Filename: " filename "\n"
4026 "| Size (encoded): " bsize " Byte\n"
4027 "| Description: " description "\n"
4030 (cdr (mm-make-handle
4031 nil `("text/plain") nil nil
4033 (format "Deleted attachment (%s bytes)" bsize))))))
4034 (set-buffer gnus-summary-buffer)
4035 ;; FIXME: maybe some of the following code (borrowed from
4036 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4037 (gnus-article-edit-article
4040 (let ((mail-parse-charset (or gnus-article-charset
4041 ',gnus-newsgroup-charset))
4042 (mail-parse-ignored-charsets
4043 (or gnus-article-ignored-charsets
4044 ',gnus-newsgroup-ignored-charsets))
4045 (mbl mml-buffer-list))
4046 (setq mml-buffer-list nil)
4047 (insert-buffer gnus-original-article-buffer)
4048 (mime-to-mml ',handles)
4049 (setq gnus-article-mime-handles nil)
4050 (let ((mbl1 mml-buffer-list))
4051 (setq mml-buffer-list mbl)
4052 (set (make-local-variable 'mml-buffer-list) mbl1))
4053 (gnus-make-local-hook 'kill-buffer-hook)
4054 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4055 `(lambda (no-highlight)
4056 (let ((mail-parse-charset (or gnus-article-charset
4057 ',gnus-newsgroup-charset))
4058 (message-options message-options)
4059 (message-options-set-recipient)
4060 (mail-parse-ignored-charsets
4061 (or gnus-article-ignored-charsets
4062 ',gnus-newsgroup-ignored-charsets)))
4064 (mml-destroy-buffers)
4065 (remove-hook 'kill-buffer-hook
4066 'mml-destroy-buffers t)
4067 (kill-local-variable 'mml-buffer-list))
4068 (gnus-summary-edit-article-done
4069 ,(or (mail-header-references gnus-current-headers) "")
4070 ,(gnus-group-read-only-p)
4071 ,gnus-summary-buffer no-highlight)))))
4072 ;; Not in `gnus-mime-save-part-and-strip':
4073 (gnus-article-edit-done)
4074 (gnus-summary-expand-window)
4075 (gnus-summary-show-article))
4077 (defun gnus-mime-save-part ()
4078 "Save the MIME part under point."
4080 (gnus-article-check-buffer)
4081 (let ((data (get-text-property (point) 'gnus-data)))
4083 (mm-save-part data))))
4085 (defun gnus-mime-pipe-part ()
4086 "Pipe the MIME part under point to a process."
4088 (gnus-article-check-buffer)
4089 (let ((data (get-text-property (point) 'gnus-data)))
4091 (mm-pipe-part data))))
4093 (defun gnus-mime-view-part ()
4094 "Interactively choose a viewing method for the MIME part under point."
4096 (gnus-article-check-buffer)
4097 (let ((data (get-text-property (point) 'gnus-data)))
4099 (setq gnus-article-mime-handles
4101 gnus-article-mime-handles (setq data (copy-sequence data))))
4102 (mm-interactively-view-part data))))
4104 (defun gnus-mime-view-part-as-type-internal ()
4105 (gnus-article-check-buffer)
4106 (let* ((name (mail-content-type-get
4107 (mm-handle-type (get-text-property (point) 'gnus-data))
4109 (def-type (and name (mm-default-file-encoding name))))
4110 (and def-type (cons def-type 0))))
4112 (defun gnus-mime-view-part-as-type (&optional mime-type)
4113 "Choose a MIME media type, and view the part as such."
4116 (setq mime-type (completing-read
4117 "View as MIME type: "
4118 (mapcar #'list (mailcap-mime-types))
4120 (gnus-mime-view-part-as-type-internal))))
4121 (gnus-article-check-buffer)
4122 (let ((handle (get-text-property (point) 'gnus-data)))
4125 (mm-make-handle (mm-handle-buffer handle)
4126 (cons mime-type (cdr (mm-handle-type handle)))
4127 (mm-handle-encoding handle)
4128 (mm-handle-undisplayer handle)
4129 (mm-handle-disposition handle)
4130 (mm-handle-description handle)
4132 (mm-handle-id handle)))
4133 (setq gnus-article-mime-handles
4134 (mm-merge-handles gnus-article-mime-handles handle))
4135 (gnus-mm-display-part handle))))
4138 (require 'jka-compr))
4140 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4141 ;; emacs can do that itself.
4143 (defun gnus-mime-jka-compr-maybe-uncompress ()
4144 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4145 The uncompress method used is derived from `buffer-file-name'."
4146 (when (and (fboundp 'jka-compr-installed-p)
4147 (jka-compr-installed-p))
4148 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4150 (let ((basename (file-name-nondirectory buffer-file-name))
4151 (args (jka-compr-info-uncompress-args info))
4152 (prog (jka-compr-info-uncompress-program info))
4153 (message (jka-compr-info-uncompress-message info))
4154 (err-file (jka-compr-make-temp-name)))
4156 (message "%s %s..." message basename))
4158 (unless (memq (apply 'call-process-region
4159 (point-min) (point-max)
4161 t (list t err-file) nil
4163 jka-compr-acceptable-retval-list)
4164 (jka-compr-error prog args basename message err-file))
4165 (jka-compr-delete-temp-file err-file)))))))
4167 (defun gnus-mime-copy-part (&optional handle)
4168 "Put the MIME part under point into a new buffer.
4169 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4172 (gnus-article-check-buffer)
4173 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4174 (contents (and handle (mm-get-part handle)))
4176 (file-name-nondirectory
4178 (mail-content-type-get (mm-handle-type handle) 'name)
4179 (mail-content-type-get (mm-handle-disposition handle)
4182 (buffer (and base (generate-new-buffer base))))
4184 (switch-to-buffer buffer)
4186 ;; We do it this way to make `normal-mode' set the appropriate mode.
4189 (setq buffer-file-name (expand-file-name base))
4190 (gnus-mime-jka-compr-maybe-uncompress)
4192 (setq buffer-file-name nil))
4193 (goto-char (point-min)))))
4195 (defun gnus-mime-print-part (&optional handle filename)
4196 "Print the MIME part under point."
4197 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4198 (gnus-article-check-buffer)
4199 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4200 (contents (and handle (mm-get-part handle)))
4201 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4202 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4207 (mm-save-part-to-file handle file)
4208 (call-process shell-file-name nil
4209 (generate-new-buffer " *mm*")
4211 shell-command-switch
4213 printer file (mm-handle-type handle))))
4217 (gnus-print-buffer))
4218 (ps-despool filename)))))
4220 (defun gnus-mime-inline-part (&optional handle arg)
4221 "Insert the MIME part under point into the current buffer."
4222 (interactive (list nil current-prefix-arg))
4223 (gnus-article-check-buffer)
4224 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4229 (if (and (not arg) (mm-handle-undisplayer handle))
4230 (mm-remove-part handle)
4231 (setq contents (mm-get-part handle))
4234 (setq charset (or (mail-content-type-get
4235 (mm-handle-type handle) 'charset)
4236 gnus-newsgroup-charset)))
4238 (if (mm-handle-undisplayer handle)
4239 (mm-remove-part handle))
4242 gnus-summary-show-article-charset-alist))
4243 (mm-read-coding-system "Charset: ")))))
4245 (mm-insert-inline handle
4247 (setq charset (mm-charset-to-coding-system
4249 (not (eq charset 'ascii)))
4250 (mm-decode-coding-string contents charset)
4254 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4255 "Insert the MIME part under point into the current buffer using the
4257 (interactive (list nil current-prefix-arg))
4258 (gnus-article-check-buffer)
4259 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4264 (if (mm-handle-undisplayer handle)
4265 (mm-remove-part handle))
4266 (let ((gnus-newsgroup-charset
4268 gnus-summary-show-article-charset-alist))
4269 (mm-read-coding-system "Charset: ")))
4270 (gnus-newsgroup-ignored-charsets 'gnus-all))
4271 (gnus-article-press-button)))))
4273 (defun gnus-mime-view-part-externally (&optional handle)
4274 "View the MIME part under point with an external viewer."
4276 (gnus-article-check-buffer)
4277 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4278 (mm-user-display-methods nil)
4279 (mm-inlined-types nil)
4280 (mail-parse-charset gnus-newsgroup-charset)
4281 (mail-parse-ignored-charsets
4282 (save-excursion (set-buffer gnus-summary-buffer)
4283 gnus-newsgroup-ignored-charsets)))
4285 (if (mm-handle-undisplayer handle)
4286 (mm-remove-part handle)
4287 (mm-display-part handle)))))
4289 (defun gnus-mime-view-part-internally (&optional handle)
4290 "View the MIME part under point with an internal viewer.
4291 If no internal viewer is available, use an external viewer."
4293 (gnus-article-check-buffer)
4294 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4295 (mm-inlined-types '(".*"))
4296 (mm-inline-large-images t)
4297 (mail-parse-charset gnus-newsgroup-charset)
4298 (mail-parse-ignored-charsets
4299 (save-excursion (set-buffer gnus-summary-buffer)
4300 gnus-newsgroup-ignored-charsets))
4303 (if (mm-handle-undisplayer handle)
4304 (mm-remove-part handle)
4305 (mm-display-part handle)))))
4307 (defun gnus-mime-action-on-part (&optional action)
4308 "Do something with the MIME attachment at \(point\)."
4310 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4311 (gnus-article-check-buffer)
4312 (let ((action-pair (assoc action gnus-mime-action-alist)))
4314 (funcall (cdr action-pair)))))
4316 (defun gnus-article-part-wrapper (n function)
4317 (save-current-buffer
4318 (set-buffer gnus-article-buffer)
4319 (when (> n (length gnus-article-mime-handle-alist))
4320 (error "No such part"))
4321 (gnus-article-goto-part n)
4322 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4323 (funcall function handle))))
4325 (defun gnus-article-pipe-part (n)
4326 "Pipe MIME part N, which is the numerical prefix."
4328 (gnus-article-part-wrapper n 'mm-pipe-part))
4330 (defun gnus-article-save-part (n)
4331 "Save MIME part N, which is the numerical prefix."
4333 (gnus-article-part-wrapper n 'mm-save-part))
4335 (defun gnus-article-interactively-view-part (n)
4336 "View MIME part N interactively, which is the numerical prefix."
4338 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4340 (defun gnus-article-copy-part (n)
4341 "Copy MIME part N, which is the numerical prefix."
4343 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4345 (defun gnus-article-view-part-as-charset (n)
4346 "View MIME part N using a specified charset.
4347 N is the numerical prefix."
4349 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4351 (defun gnus-article-view-part-externally (n)
4352 "View MIME part N externally, which is the numerical prefix."
4354 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4356 (defun gnus-article-inline-part (n)
4357 "Inline MIME part N, which is the numerical prefix."
4359 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4361 (defun gnus-article-mime-match-handle-first (condition)
4363 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4364 (while (setq ihandle (pop alist))
4366 ((functionp condition)
4367 (funcall condition (cdr ihandle)))
4368 ((eq condition 'undisplayed)
4369 (not (or (mm-handle-undisplayer (cdr ihandle))
4370 (equal (mm-handle-media-type (cdr ihandle))
4371 "multipart/alternative"))))
4372 ((eq condition 'undisplayed-alternative)
4373 (not (mm-handle-undisplayer (cdr ihandle))))
4375 (gnus-article-goto-part (car ihandle))
4376 (or (not n) (< (car ihandle) n)))
4377 (setq n (car ihandle))))
4381 (defun gnus-article-view-part (&optional n)
4382 "View MIME part N, which is the numerical prefix."
4384 (save-current-buffer
4385 (set-buffer gnus-article-buffer)
4386 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4387 gnus-article-mime-match-handle-function)))
4388 (when (> n (length gnus-article-mime-handle-alist))
4389 (error "No such part"))
4390 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4391 (when (gnus-article-goto-part n)
4392 (if (equal (car handle) "multipart/alternative")
4393 (gnus-article-press-button)
4394 (when (eq (gnus-mm-display-part handle) 'internal)
4395 (gnus-set-window-start)))))))
4397 (defsubst gnus-article-mime-total-parts ()
4398 (if (bufferp (car gnus-article-mime-handles))
4400 (1- (length gnus-article-mime-handles))))
4402 (defun gnus-mm-display-part (handle)
4403 "Display HANDLE and fix MIME button."
4404 (let ((id (get-text-property (point) 'gnus-part))
4409 (let ((window (selected-window))
4410 (mail-parse-charset gnus-newsgroup-charset)
4411 (mail-parse-ignored-charsets
4412 (if (gnus-buffer-live-p gnus-summary-buffer)
4414 (set-buffer gnus-summary-buffer)
4415 gnus-newsgroup-ignored-charsets)
4419 (let ((win (gnus-get-buffer-window (current-buffer) t))
4422 (select-window win))
4425 (if (mm-handle-displayed-p handle)
4426 ;; This will remove the part.
4427 (mm-display-part handle)
4429 (narrow-to-region (point)
4430 (if (eobp) (point) (1+ (point))))
4431 (mm-display-part handle)
4432 ;; We narrow to the part itself and
4433 ;; then call the treatment functions.
4434 (goto-char (point-min))
4436 (narrow-to-region (point) (point-max))
4439 (gnus-article-mime-total-parts)
4440 (mm-handle-media-type handle)))))
4441 (if (window-live-p window)
4442 (select-window window)))))
4445 (gnus-insert-mime-button
4446 handle id (list (mm-handle-displayed-p handle)))
4447 (goto-char point))))
4449 (defun gnus-article-goto-part (n)
4450 "Go to MIME part N."
4451 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4453 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4454 (let ((gnus-tmp-name
4455 (or (mail-content-type-get (mm-handle-type handle) 'name)
4456 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4457 (mail-content-type-get (mm-handle-type handle) 'url)
4459 (gnus-tmp-type (mm-handle-media-type handle))
4460 (gnus-tmp-description
4461 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4464 (if (if displayed (car displayed)
4465 (mm-handle-displayed-p handle))
4467 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4469 gnus-tmp-type-long b e)
4470 (when (string-match ".*/" gnus-tmp-name)
4471 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4472 (setq gnus-tmp-type-long (concat gnus-tmp-type
4473 (and (not (equal gnus-tmp-name ""))
4474 (concat "; " gnus-tmp-name))))
4475 (unless (equal gnus-tmp-description "")
4476 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4481 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4482 `(,@(gnus-local-map-property gnus-mime-button-map)
4483 gnus-callback gnus-mm-display-part
4484 gnus-part ,gnus-tmp-id
4485 article-type annotation
4488 ;; Exclude a newline.
4491 (widget-convert-button
4494 :action 'gnus-widget-press-button
4495 :button-keymap gnus-mime-button-map
4497 (lambda (widget/window &optional overlay pos)
4498 ;; Needed to properly clear the message due to a bug in
4499 ;; wid-edit (XEmacs only).
4500 (if (boundp 'help-echo-owns-message)
4501 (setq help-echo-owns-message t))
4503 "%S: %s the MIME part; %S: more options"
4504 (aref gnus-mouse-2 0)
4505 ;; XEmacs will get a single widget arg; Emacs 21 will get
4506 ;; window, overlay, position.
4507 (if (mm-handle-displayed-p
4509 (with-current-buffer (gnus-overlay-buffer overlay)
4510 (widget-get (widget-at (gnus-overlay-start overlay))
4512 (widget-get widget/window :mime-handle)))
4514 (aref gnus-down-mouse-3 0))))))
4516 (defun gnus-widget-press-button (elems el)
4517 (goto-char (widget-get elems :from))
4518 (gnus-article-press-button))
4520 (defvar gnus-displaying-mime nil)
4522 (defun gnus-display-mime (&optional ihandles)
4523 "Display the MIME parts."
4525 (save-selected-window
4526 (let ((window (get-buffer-window gnus-article-buffer))
4529 (select-window window)
4530 ;; We have to do this since selecting the window
4531 ;; may change the point. So we set the window point.
4532 (set-window-point window point)))
4533 (let* ((handles (or ihandles
4534 (mm-dissect-buffer nil gnus-article-loose-mime)
4535 (and gnus-article-emulate-mime
4537 buffer-read-only handle name type b e display)
4538 (when (and (not ihandles)
4539 (not gnus-displaying-mime))
4540 ;; Top-level call; we clean up.
4541 (when gnus-article-mime-handles
4542 (mm-destroy-parts gnus-article-mime-handles)
4543 (setq gnus-article-mime-handle-alist nil));; A trick.
4544 (setq gnus-article-mime-handles handles)
4545 ;; We allow users to glean info from the handles.
4546 (when gnus-article-mime-part-function
4547 (gnus-mime-part-function handles)))
4549 (or (not (stringp (car handles)))
4552 (when (and (not ihandles)
4553 (not gnus-displaying-mime))
4554 ;; Clean up for mime parts.
4556 (delete-region (point) (point-max)))
4557 (let ((gnus-displaying-mime t))
4558 (gnus-mime-display-part handles)))
4561 (narrow-to-region (point) (point-max))
4562 (gnus-treat-article nil 1 1)
4565 ;; Highlight the headers.
4569 (narrow-to-region (point-min) (point))
4570 (gnus-treat-article 'head))))))))
4572 (defcustom gnus-mime-display-multipart-as-mixed nil
4573 "Display \"multipart\" parts as \"multipart/mixed\".
4575 If t, it overrides nil values of
4576 `gnus-mime-display-multipart-alternative-as-mixed' and
4577 `gnus-mime-display-multipart-related-as-mixed'."
4578 :group 'gnus-article-mime
4581 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4582 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4583 :group 'gnus-article-mime
4586 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4587 "Display \"multipart/related\" parts as \"multipart/mixed\".
4589 If displaying \"text/html\" is discouraged \(see
4590 `mm-discouraged-alternatives'\) images or other material inside a
4591 \"multipart/related\" part might be overlooked when this variable is nil."
4592 :group 'gnus-article-mime
4595 (defun gnus-mime-display-part (handle)
4598 ((not (stringp (car handle)))
4599 (gnus-mime-display-single handle))
4600 ;; User-defined multipart
4601 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4602 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4604 ;; multipart/alternative
4605 ((and (equal (car handle) "multipart/alternative")
4606 (not (or gnus-mime-display-multipart-as-mixed
4607 gnus-mime-display-multipart-alternative-as-mixed)))
4608 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4609 (push (cons id handle) gnus-article-mime-handle-alist)
4610 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4611 ;; multipart/related
4612 ((and (equal (car handle) "multipart/related")
4613 (not (or gnus-mime-display-multipart-as-mixed
4614 gnus-mime-display-multipart-related-as-mixed)))
4615 ;;;!!!We should find the start part, but we just default
4616 ;;;!!!to the first part.
4617 ;;(gnus-mime-display-part (cadr handle))
4618 ;;;!!! Most multipart/related is an HTML message plus images.
4619 ;;;!!! Unfortunately we are unable to let W3 display those
4620 ;;;!!! included images, so we just display it as a mixed multipart.
4621 ;;(gnus-mime-display-mixed (cdr handle))
4622 ;;;!!! No, w3 can display everything just fine.
4623 (gnus-mime-display-part (cadr handle)))
4624 ((equal (car handle) "multipart/signed")
4625 (gnus-add-wash-type 'signed)
4626 (gnus-mime-display-security handle))
4627 ((equal (car handle) "multipart/encrypted")
4628 (gnus-add-wash-type 'encrypted)
4629 (gnus-mime-display-security handle))
4630 ;; Other multiparts are handled like multipart/mixed.
4632 (gnus-mime-display-mixed (cdr handle)))))
4634 (defun gnus-mime-part-function (handles)
4635 (if (stringp (car handles))
4636 (mapcar 'gnus-mime-part-function (cdr handles))
4637 (funcall gnus-article-mime-part-function handles)))
4639 (defun gnus-mime-display-mixed (handles)
4640 (mapcar 'gnus-mime-display-part handles))
4642 (defun gnus-mime-display-single (handle)
4643 (let ((type (mm-handle-media-type handle))
4644 (ignored gnus-ignored-mime-types)
4651 (when (string-match (pop ignored) type)
4652 (throw 'ignored nil)))
4653 (if (and (setq not-attachment
4654 (and (not (mm-inline-override-p handle))
4655 (or (not (mm-handle-disposition handle))
4656 (equal (car (mm-handle-disposition handle))
4658 (mm-attachment-override-p handle))))
4659 (mm-automatic-display-p handle)
4661 (mm-inlinable-p handle)
4662 (mm-inlined-p handle))
4663 (mm-automatic-external-display-p type)))
4665 (when (equal (mm-handle-media-supertype handle) "text")
4667 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4669 (push (cons id handle) gnus-article-mime-handle-alist)
4670 (when (or (not display)
4671 (not (gnus-unbuttonized-mime-type-p type)))
4672 ;(gnus-article-insert-newline)
4673 (gnus-insert-mime-button
4674 handle id (list (or display (and not-attachment text))))
4675 (gnus-article-insert-newline)
4676 ;(gnus-article-insert-newline)
4677 ;; Remember modify the number of forward lines.
4685 (let ((mail-parse-charset gnus-newsgroup-charset)
4686 (mail-parse-ignored-charsets
4687 (save-excursion (condition-case ()
4688 (set-buffer gnus-summary-buffer)
4690 gnus-newsgroup-ignored-charsets)))
4691 (mm-display-part handle t))
4692 (goto-char (point-max)))
4693 ((and text not-attachment)
4697 (gnus-article-insert-newline)
4698 (mm-insert-inline handle (mm-get-part handle))
4699 (goto-char (point-max))))
4703 (narrow-to-region beg (point))
4706 (gnus-article-mime-total-parts)
4707 (mm-handle-media-type handle)))))))))
4709 (defun gnus-unbuttonized-mime-type-p (type)
4710 "Say whether TYPE is to be unbuttonized."
4711 (unless gnus-inhibit-mime-unbuttonizing
4713 (let ((types gnus-unbuttonized-mime-types))
4715 (when (string-match (pop types) type)
4716 (throw 'found t)))))
4718 (let ((types gnus-buttonized-mime-types))
4720 (when (string-match (pop types) type)
4721 (throw 'found t)))))))))
4723 (defun gnus-article-insert-newline ()
4724 "Insert a newline, but mark it as undeletable."
4725 (gnus-put-text-property
4726 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4728 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4729 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4732 handle buffer-read-only from props begend not-pref)
4733 (save-window-excursion
4736 (narrow-to-region (car ibegend)
4739 (goto-char (car ibegend))
4742 (delete-region (point-min) (point-max))
4743 (mm-remove-parts handles))
4744 (setq begend (list (point-marker)))
4746 (unless (setq not-pref (cadr (member preferred ihandles)))
4747 (setq not-pref (car ihandles)))
4750 (not (gnus-unbuttonized-mime-type-p
4751 "multipart/alternative")))
4752 (gnus-add-text-properties
4755 (insert (format "%d. " id))
4759 (unless ,(not ibegend)
4760 (setq gnus-article-mime-handle-alist
4761 ',gnus-article-mime-handle-alist))
4762 (gnus-mime-display-alternative
4763 ',ihandles ',not-pref ',begend ,id))
4764 ,@(gnus-local-map-property gnus-mime-button-map)
4765 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4766 face ,gnus-article-button-face
4769 (widget-convert-button 'link from (point)
4770 :action 'gnus-widget-press-button
4771 :button-keymap gnus-widget-button-keymap)
4773 (while (setq handle (pop handles))
4774 (gnus-add-text-properties
4777 (insert (format "(%c) %-18s"
4778 (if (equal handle preferred) ?* ? )
4779 (mm-handle-media-type handle)))
4783 (unless ,(not ibegend)
4784 (setq gnus-article-mime-handle-alist
4785 ',gnus-article-mime-handle-alist))
4786 (gnus-mime-display-alternative
4787 ',ihandles ',handle ',begend ,id))
4788 ,@(gnus-local-map-property gnus-mime-button-map)
4789 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4790 face ,gnus-article-button-face
4793 (widget-convert-button 'link from (point)
4794 :action 'gnus-widget-press-button
4795 :button-keymap gnus-widget-button-keymap)
4799 (if (stringp (car preferred))
4800 (gnus-display-mime preferred)
4801 (let ((mail-parse-charset gnus-newsgroup-charset)
4802 (mail-parse-ignored-charsets
4803 (save-excursion (set-buffer gnus-summary-buffer)
4804 gnus-newsgroup-ignored-charsets)))
4805 (mm-display-part preferred)
4809 (narrow-to-region (car begend) (point-max))
4811 nil (length gnus-article-mime-handle-alist)
4812 (gnus-article-mime-total-parts)
4813 (mm-handle-media-type handle))))))
4814 (goto-char (point-max))
4815 (setcdr begend (point-marker)))))
4817 (goto-char point))))
4819 (defconst gnus-article-wash-status-strings
4820 (let ((alist '((cite "c" "Possible hidden citation text"
4821 " " "All citation text visible")
4822 (headers "h" "Hidden headers"
4823 " " "All headers visible.")
4824 (pgp "p" "Encrypted or signed message status hidden"
4825 " " "No hidden encryption nor digital signature status")
4826 (signature "s" "Signature has been hidden"
4827 " " "Signature is visible")
4828 (overstrike "o" "Overstrike (^H) characters applied"
4829 " " "No overstrike characters applied")
4830 (emphasis "e" "/*_Emphasis_*/ characters applied"
4831 " " "No /*_emphasis_*/ characters applied")))
4833 (dolist (entry alist result)
4834 (let ((key (nth 0 entry))
4835 (on (copy-sequence (nth 1 entry)))
4836 (on-help (nth 2 entry))
4837 (off (copy-sequence (nth 3 entry)))
4838 (off-help (nth 4 entry)))
4839 (put-text-property 0 1 'help-echo on-help on)
4840 (put-text-property 0 1 'help-echo off-help off)
4841 (push (list key on off) result))))
4842 "Alist of strings describing wash status in the mode line.
4843 Each entry has the form (KEY ON OF), where the KEY is a symbol
4844 representing the particular washing function, ON is the string to use
4845 in the article mode line when the washing function is active, and OFF
4846 is the string to use when it is inactive.")
4848 (defun gnus-article-wash-status-entry (key value)
4849 (let ((entry (assoc key gnus-article-wash-status-strings)))
4850 (if value (nth 1 entry) (nth 2 entry))))
4852 (defun gnus-article-wash-status ()
4853 "Return a string which display status of article washing."
4855 (set-buffer gnus-article-buffer)
4856 (let ((cite (memq 'cite gnus-article-wash-types))
4857 (headers (memq 'headers gnus-article-wash-types))
4858 (boring (memq 'boring-headers gnus-article-wash-types))
4859 (pgp (memq 'pgp gnus-article-wash-types))
4860 (pem (memq 'pem gnus-article-wash-types))
4861 (signed (memq 'signed gnus-article-wash-types))
4862 (encrypted (memq 'encrypted gnus-article-wash-types))
4863 (signature (memq 'signature gnus-article-wash-types))
4864 (overstrike (memq 'overstrike gnus-article-wash-types))
4865 (emphasis (memq 'emphasis gnus-article-wash-types)))
4867 (gnus-article-wash-status-entry 'cite cite)
4868 (gnus-article-wash-status-entry 'headers (or headers boring))
4869 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4870 (gnus-article-wash-status-entry 'signature signature)
4871 (gnus-article-wash-status-entry 'overstrike overstrike)
4872 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4874 (defun gnus-add-wash-type (type)
4875 "Add a washing of TYPE to the current status."
4876 (add-to-list 'gnus-article-wash-types type))
4878 (defun gnus-delete-wash-type (type)
4879 "Add a washing of TYPE to the current status."
4880 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4882 (defun gnus-add-image (category image)
4883 "Add IMAGE of CATEGORY to the list of displayed images."
4884 (let ((entry (assq category gnus-article-image-alist)))
4886 (setq entry (list category))
4887 (push entry gnus-article-image-alist))
4888 (nconc entry (list image))))
4890 (defun gnus-delete-images (category)
4891 "Delete all images in CATEGORY."
4892 (let ((entry (assq category gnus-article-image-alist)))
4893 (dolist (image (cdr entry))
4894 (gnus-remove-image image category))
4895 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4896 (gnus-delete-wash-type category)))
4898 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4900 (defun gnus-article-maybe-hide-headers ()
4901 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4902 Provided for backwards compatibility."
4903 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4904 (not (save-excursion (set-buffer gnus-summary-buffer)
4905 gnus-have-all-headers)))
4906 (not gnus-inhibit-hiding))
4907 (gnus-article-hide-headers)))
4911 (defun gnus-output-to-file (file-name)
4912 "Append the current article to a file named FILE-NAME."
4913 (let ((artbuf (current-buffer)))
4915 (insert-buffer-substring artbuf)
4916 ;; Append newline at end of the buffer as separator, and then
4918 (goto-char (point-max))
4920 (let ((file-name-coding-system nnmail-pathname-coding-system))
4921 (mm-append-to-file (point-min) (point-max) file-name))
4924 (defun gnus-narrow-to-page (&optional arg)
4925 "Narrow the article buffer to a page.
4926 If given a numerical ARG, move forward ARG pages."
4928 (setq arg (if arg (prefix-numeric-value arg) 0))
4930 (set-buffer gnus-article-buffer)
4931 (goto-char (point-min))
4933 ;; Remove any old next/prev buttons.
4934 (when (gnus-visual-p 'page-marker)
4935 (let ((buffer-read-only nil))
4936 (gnus-remove-text-with-property 'gnus-prev)
4937 (gnus-remove-text-with-property 'gnus-next)))
4940 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4942 (re-search-forward page-delimiter nil 'move arg)))
4943 (goto-char (match-end 0))
4945 (goto-char (point-min))
4946 (setq gnus-page-broken
4947 (and (re-search-forward page-delimiter nil t) t))))
4948 (when gnus-page-broken
4951 (if (re-search-forward page-delimiter nil 'move)
4954 (when (and (gnus-visual-p 'page-marker)
4955 (not (= (point-min) 1)))
4957 (goto-char (point-min))
4958 (gnus-insert-prev-page-button)))
4959 (when (and (gnus-visual-p 'page-marker)
4960 (< (+ (point-max) 2) (buffer-size)))
4962 (goto-char (point-max))
4963 (gnus-insert-next-page-button))))))
4965 ;; Article mode commands
4967 (defun gnus-article-goto-next-page ()
4968 "Show the next page of the article."
4970 (when (gnus-article-next-page)
4971 (goto-char (point-min))
4972 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4975 (defun gnus-article-goto-prev-page ()
4976 "Show the previous page of the article."
4979 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4980 (gnus-article-prev-page nil)))
4982 ;; This is cleaner but currently breaks `gnus-pick-mode':
4984 ;; (defun gnus-article-goto-next-page ()
4985 ;; "Show the next page of the article."
4987 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
4988 ;; (gnus-summary-next-page)))
4990 ;; (defun gnus-article-goto-prev-page ()
4991 ;; "Show the next page of the article."
4993 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
4994 ;; (gnus-summary-prev-page)))
4996 (defun gnus-article-next-page (&optional lines)
4997 "Show the next page of the current article.
4998 If end of article, return non-nil. Otherwise return nil.
4999 Argument LINES specifies lines to be scrolled up."
5001 (move-to-window-line -1)
5004 (and (pos-visible-in-window-p) ;Not continuation line.
5005 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5006 ;; Nothing in this page.
5007 (if (or (not gnus-page-broken)
5011 (eobp)))) ;Real end-of-buffer?
5013 (when gnus-article-over-scroll
5014 (gnus-article-next-page-1 lines))
5016 (gnus-narrow-to-page 1) ;Go to next page.
5018 ;; More in this page.
5019 (gnus-article-next-page-1 lines)
5022 (defun gnus-article-next-page-1 (lines)
5023 (let ((scroll-in-place nil))
5027 ;; Long lines may cause an end-of-buffer error.
5028 (goto-char (point-max)))))
5029 (move-to-window-line 0))
5031 (defun gnus-article-prev-page (&optional lines)
5032 "Show previous page of current article.
5033 Argument LINES specifies lines to be scrolled down."
5035 (move-to-window-line 0)
5036 (if (and gnus-page-broken
5038 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5040 (gnus-narrow-to-page -1) ;Go to previous page.
5041 (goto-char (point-max))
5043 (let ((scroll-in-place nil))
5047 (beginning-of-buffer
5048 (goto-char (point-min))))
5049 (move-to-window-line 0)))))
5051 (defun gnus-article-only-boring-p ()
5052 "Decide whether there is only boring text remaining in the article.
5053 Something \"interesting\" is a word of at least two letters that does
5054 not have a face in `gnus-article-boring-faces'."
5055 (when (and gnus-article-skip-boring
5056 (boundp 'gnus-article-boring-faces)
5057 (symbol-value 'gnus-article-boring-faces))
5060 (while (re-search-forward "\\b\\w\\w" nil t)
5062 (when (not (gnus-intersection
5063 (gnus-faces-at (point))
5064 (symbol-value 'gnus-article-boring-faces)))
5065 (throw 'only-boring nil)))
5066 (throw 'only-boring t)))))
5068 (defun gnus-article-refer-article ()
5069 "Read article specified by message-id around point."
5072 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5073 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5074 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5075 (let ((msg-id (concat "<" (match-string 0) ">")))
5076 (set-buffer gnus-summary-buffer)
5077 (gnus-summary-refer-article msg-id))
5078 (error "No references around point"))))
5080 (defun gnus-article-show-summary ()
5081 "Reconfigure windows to show summary buffer."
5083 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5084 (error "There is no summary buffer for this article buffer")
5085 (gnus-article-set-globals)
5086 (gnus-configure-windows 'article)
5087 (gnus-summary-goto-subject gnus-current-article)
5088 (gnus-summary-position-point)))
5090 (defun gnus-article-describe-briefly ()
5091 "Describe article mode commands briefly."
5093 (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")))
5095 (defun gnus-article-summary-command ()
5096 "Execute the last keystroke in the summary buffer."
5098 (let ((obuf (current-buffer))
5099 (owin (current-window-configuration))
5101 (switch-to-buffer gnus-article-current-summary 'norecord)
5102 (setq func (lookup-key (current-local-map) (this-command-keys)))
5103 (call-interactively func)
5105 (set-window-configuration owin)
5106 (set-window-point (get-buffer-window (current-buffer)) (point))))
5108 (defun gnus-article-summary-command-nosave ()
5109 "Execute the last keystroke in the summary buffer."
5112 (pop-to-buffer gnus-article-current-summary 'norecord)
5113 (setq func (lookup-key (current-local-map) (this-command-keys)))
5114 (call-interactively func)))
5116 (defun gnus-article-check-buffer ()
5117 "Beep if not in an article buffer."
5118 (unless (equal major-mode 'gnus-article-mode)
5119 (error "Command invoked outside of a Gnus article buffer")))
5121 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5122 "Read a summary buffer key sequence and execute it from the article buffer."
5124 (gnus-article-check-buffer)
5126 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5127 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5128 "=" "^" "\M-^" "|"))
5134 '("n" "Gn" "p" "Gp"))
5137 (set-buffer gnus-article-current-summary)
5138 (let (gnus-pick-mode)
5139 (push (or key last-command-event) unread-command-events)
5140 (setq keys (if (featurep 'xemacs)
5141 (events-to-keys (read-key-sequence nil))
5142 (read-key-sequence nil)))))
5146 (if (or (member keys nosaves)
5147 (member keys nosave-but-article)
5148 (member keys nosave-in-article))
5150 (save-window-excursion
5151 (pop-to-buffer gnus-article-current-summary 'norecord)
5152 ;; We disable the pick minor mode commands.
5153 (let (gnus-pick-mode)
5154 (setq func (lookup-key (current-local-map) keys))))
5158 (unless (member keys nosave-in-article)
5159 (set-buffer gnus-article-current-summary))
5160 (call-interactively func)
5161 (setq new-sum-point (point)))
5162 (when (member keys nosave-but-article)
5163 (pop-to-buffer gnus-article-buffer 'norecord)))
5164 ;; These commands should restore window configuration.
5165 (let ((obuf (current-buffer))
5166 (owin (current-window-configuration))
5168 (summary gnus-article-current-summary)
5169 func in-buffer selected)
5170 (if not-restore-window
5171 (pop-to-buffer summary 'norecord)
5172 (switch-to-buffer summary 'norecord))
5173 (setq in-buffer (current-buffer))
5174 ;; We disable the pick minor mode commands.
5175 (if (and (setq func (let (gnus-pick-mode)
5176 (lookup-key (current-local-map) keys)))
5179 (call-interactively func)
5180 (setq new-sum-point (point))
5181 (when (eq in-buffer (current-buffer))
5182 (setq selected (gnus-summary-select-article))
5184 (unless not-restore-window
5185 (set-window-configuration owin))
5186 (when (eq selected 'old)
5188 (set-window-start (get-buffer-window (current-buffer))
5190 (set-window-point (get-buffer-window (current-buffer))
5192 (let ((win (get-buffer-window gnus-article-current-summary)))
5194 (set-window-point win new-sum-point)))) )
5195 (switch-to-buffer gnus-article-buffer)
5198 (defun gnus-article-describe-key (key)
5199 "Display documentation of the function invoked by KEY. KEY is a string."
5200 (interactive "kDescribe key: ")
5201 (gnus-article-check-buffer)
5202 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5204 (set-buffer gnus-article-current-summary)
5205 (let (gnus-pick-mode)
5206 (if (featurep 'xemacs)
5208 (push (elt key 0) unread-command-events)
5209 (setq key (events-to-keys
5210 (read-key-sequence "Describe key: "))))
5211 (setq unread-command-events
5213 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5214 (string-to-list key)))
5215 (setq key (read-key-sequence "Describe key: "))))
5217 (describe-key key)))
5219 (defun gnus-article-describe-key-briefly (key &optional insert)
5220 "Display documentation of the function invoked by KEY. KEY is a string."
5221 (interactive "kDescribe key: \nP")
5222 (gnus-article-check-buffer)
5223 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5225 (set-buffer gnus-article-current-summary)
5226 (let (gnus-pick-mode)
5227 (if (featurep 'xemacs)
5229 (push (elt key 0) unread-command-events)
5230 (setq key (events-to-keys
5231 (read-key-sequence "Describe key: "))))
5232 (setq unread-command-events
5234 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5235 (string-to-list key)))
5236 (setq key (read-key-sequence "Describe key: "))))
5237 (describe-key-briefly key insert))
5238 (describe-key-briefly key insert)))
5240 (defun gnus-article-reply-with-original (&optional wide)
5241 "Start composing a reply mail to the current message.
5242 The text in the region will be yanked. If the region isn't active,
5243 the entire article will be yanked."
5245 (let ((article (cdr gnus-article-current))
5247 (if (not (gnus-mark-active-p))
5248 (with-current-buffer gnus-summary-buffer
5249 (gnus-summary-reply (list (list article)) wide))
5250 (setq contents (buffer-substring (point) (mark t)))
5251 ;; Deactivate active regions.
5252 (when (and (boundp 'transient-mark-mode)
5253 transient-mark-mode)
5254 (setq mark-active nil))
5255 (with-current-buffer gnus-summary-buffer
5257 (list (list article contents)) wide)))))
5259 (defun gnus-article-followup-with-original ()
5260 "Compose a followup to the current article.
5261 The text in the region will be yanked. If the region isn't active,
5262 the entire article will be yanked."
5264 (let ((article (cdr gnus-article-current))
5266 (if (not (gnus-mark-active-p))
5267 (with-current-buffer gnus-summary-buffer
5268 (gnus-summary-followup (list (list article))))
5269 (setq contents (buffer-substring (point) (mark t)))
5270 ;; Deactivate active regions.
5271 (when (and (boundp 'transient-mark-mode)
5272 transient-mark-mode)
5273 (setq mark-active nil))
5274 (with-current-buffer gnus-summary-buffer
5275 (gnus-summary-followup
5276 (list (list article contents)))))))
5278 (defun gnus-article-hide (&optional arg force)
5279 "Hide all the gruft in the current article.
5280 This means that signatures, cited text and (some) headers will be
5282 If given a prefix, show the hidden text instead."
5283 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5284 (gnus-article-hide-headers arg)
5285 (gnus-article-hide-list-identifiers arg)
5286 (gnus-article-hide-citation-maybe arg force)
5287 (gnus-article-hide-signature arg))
5289 (defun gnus-article-maybe-highlight ()
5290 "Do some article highlighting if article highlighting is requested."
5291 (when (gnus-visual-p 'article-highlight 'highlight)
5292 (gnus-article-highlight-some)))
5294 (defun gnus-check-group-server ()
5295 ;; Make sure the connection to the server is alive.
5296 (unless (gnus-server-opened
5297 (gnus-find-method-for-group gnus-newsgroup-name))
5298 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5299 (gnus-request-group gnus-newsgroup-name t)))
5302 (autoload 'nneething-get-file-name "nneething"))
5304 (defun gnus-request-article-this-buffer (article group)
5305 "Get an article and insert it into this buffer."
5306 (let (do-update-line sparse-header)
5310 (gnus-kill-all-overlays)
5311 (setq group (or group gnus-newsgroup-name))
5313 ;; Using `gnus-request-article' directly will insert the article into
5314 ;; `nntp-server-buffer' - so we'll save some time by not having to
5315 ;; copy it from the server buffer into the article buffer.
5317 ;; We only request an article by message-id when we do not have the
5318 ;; headers for it, so we'll have to get those.
5319 (when (stringp article)
5320 (gnus-read-header article))
5322 ;; If the article number is negative, that means that this article
5323 ;; doesn't belong in this newsgroup (possibly), so we find its
5324 ;; message-id and request it by id instead of number.
5325 (when (and (numberp article)
5327 (get-buffer gnus-summary-buffer)
5328 (gnus-buffer-exists-p gnus-summary-buffer))
5330 (set-buffer gnus-summary-buffer)
5331 (let ((header (gnus-summary-article-header article)))
5334 ((memq article gnus-newsgroup-sparse)
5335 ;; This is a sparse gap article.
5336 (setq do-update-line article)
5337 (setq article (mail-header-id header))
5338 (setq sparse-header (gnus-read-header article))
5339 (setq gnus-newsgroup-sparse
5340 (delq article gnus-newsgroup-sparse)))
5342 ;; It's a real article.
5343 (setq article (mail-header-id header)))
5345 ;; It is an extracted pseudo-article.
5346 (setq article 'pseudo)
5347 (gnus-request-pseudo-article header))))
5349 (let ((method (gnus-find-method-for-group
5350 gnus-newsgroup-name)))
5351 (when (and (eq (car method) 'nneething)
5353 (let ((dir (nneething-get-file-name
5354 (mail-header-id header))))
5355 (when (and (stringp dir)
5356 (file-directory-p dir))
5357 (setq article 'nneething)
5358 (gnus-group-enter-directory dir))))))))
5361 ;; Refuse to select canceled articles.
5362 ((and (numberp article)
5364 (get-buffer gnus-summary-buffer)
5365 (gnus-buffer-exists-p gnus-summary-buffer)
5366 (eq (cdr (save-excursion
5367 (set-buffer gnus-summary-buffer)
5368 (assq article gnus-newsgroup-reads)))
5369 gnus-canceled-mark))
5371 ;; We first check `gnus-original-article-buffer'.
5372 ((and (get-buffer gnus-original-article-buffer)
5375 (set-buffer gnus-original-article-buffer)
5376 (and (equal (car gnus-original-article) group)
5377 (eq (cdr gnus-original-article) article))))
5378 (insert-buffer-substring gnus-original-article-buffer)
5380 ;; Check the backlog.
5381 ((and gnus-keep-backlog
5382 (gnus-backlog-request-article group article (current-buffer)))
5384 ;; Check asynchronous pre-fetch.
5385 ((gnus-async-request-fetched-article group article (current-buffer))
5386 (gnus-async-prefetch-next group article gnus-summary-buffer)
5387 (when (and (numberp article) gnus-keep-backlog)
5388 (gnus-backlog-enter-article group article (current-buffer)))
5391 ((and gnus-use-cache
5393 (gnus-cache-request-article article group))
5395 ;; Check the agent cache.
5396 ((gnus-agent-request-article article group)
5398 ;; Get the article and put into the article buffer.
5399 ((or (stringp article)
5401 (let ((gnus-override-method gnus-override-method)
5402 (methods (and (stringp article)
5403 gnus-refer-article-method))
5404 (backend (car (gnus-find-method-for-group
5405 gnus-newsgroup-name)))
5407 (buffer-read-only nil))
5408 (if (or (not (listp methods))
5409 (and (symbolp (car methods))
5410 (assq (car methods) nnoo-definition-alist)))
5411 (setq methods (list methods)))
5412 (when (and (null gnus-override-method)
5414 (setq gnus-override-method (pop methods)))
5416 (when (eq gnus-override-method 'current)
5417 (setq gnus-override-method
5418 (with-current-buffer gnus-summary-buffer
5419 gnus-current-select-method)))
5421 (gnus-kill-all-overlays)
5422 (let ((gnus-newsgroup-name group))
5423 (gnus-check-group-server))
5425 ((gnus-request-article article group (current-buffer))
5426 (when (numberp article)
5427 (gnus-async-prefetch-next group article
5428 gnus-summary-buffer)
5429 (when gnus-keep-backlog
5430 (gnus-backlog-enter-article
5431 group article (current-buffer))))
5432 (setq result 'article))
5434 (setq gnus-override-method (pop methods)))
5435 ((not (string-match "^400 "
5436 (nnheader-get-report backend)))
5437 ;; If we get 400 server disconnect, reconnect and
5438 ;; retry; otherwise, assume the article has expired.
5439 (setq result 'done))))
5440 (and (eq result 'article) 'article)))
5444 ;; Associate this article with the current summary buffer.
5445 (setq gnus-article-current-summary gnus-summary-buffer)
5447 ;; Take the article from the original article buffer
5448 ;; and place it in the buffer it's supposed to be in.
5449 (when (and (get-buffer gnus-article-buffer)
5450 (equal (buffer-name (current-buffer))
5451 (buffer-name (get-buffer gnus-article-buffer))))
5453 (if (get-buffer gnus-original-article-buffer)
5454 (set-buffer gnus-original-article-buffer)
5455 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5456 (buffer-disable-undo)
5457 (setq major-mode 'gnus-original-article-mode)
5458 (setq buffer-read-only t))
5459 (let (buffer-read-only)
5461 (insert-buffer-substring gnus-article-buffer))
5462 (setq gnus-original-article (cons group article)))
5465 (run-hooks 'gnus-article-decode-hook)
5466 ;; Mark article as decoded or not.
5467 (setq gnus-article-decoded-p gnus-article-decode-hook))
5469 ;; Update sparse articles.
5470 (when (and do-update-line
5471 (or (numberp article)
5473 (let ((buf (current-buffer)))
5474 (set-buffer gnus-summary-buffer)
5475 (gnus-summary-update-article do-update-line sparse-header)
5476 (gnus-summary-goto-subject do-update-line nil t)
5477 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5479 (set-buffer buf))))))
5485 (defcustom gnus-article-edit-mode-hook nil
5486 "Hook run in article edit mode buffers."
5487 :group 'gnus-article-various
5490 (defvar gnus-article-edit-done-function nil)
5492 (defvar gnus-article-edit-mode-map nil)
5493 (defvar gnus-article-edit-mode nil)
5495 ;; Should we be using derived.el for this?
5496 (unless gnus-article-edit-mode-map
5497 (setq gnus-article-edit-mode-map (make-keymap))
5498 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5500 (gnus-define-keys gnus-article-edit-mode-map
5501 "\C-c?" describe-mode
5502 "\C-c\C-c" gnus-article-edit-done
5503 "\C-c\C-k" gnus-article-edit-exit
5504 "\C-c\C-f\C-t" message-goto-to
5505 "\C-c\C-f\C-o" message-goto-from
5506 "\C-c\C-f\C-b" message-goto-bcc
5507 ;;"\C-c\C-f\C-w" message-goto-fcc
5508 "\C-c\C-f\C-c" message-goto-cc
5509 "\C-c\C-f\C-s" message-goto-subject
5510 "\C-c\C-f\C-r" message-goto-reply-to
5511 "\C-c\C-f\C-n" message-goto-newsgroups
5512 "\C-c\C-f\C-d" message-goto-distribution
5513 "\C-c\C-f\C-f" message-goto-followup-to
5514 "\C-c\C-f\C-m" message-goto-mail-followup-to
5515 "\C-c\C-f\C-k" message-goto-keywords
5516 "\C-c\C-f\C-u" message-goto-summary
5517 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5518 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5519 "\C-c\C-b" message-goto-body
5520 "\C-c\C-i" message-goto-signature
5522 "\C-c\C-t" message-insert-to
5523 "\C-c\C-n" message-insert-newsgroups
5524 "\C-c\C-o" message-sort-headers
5525 "\C-c\C-e" message-elide-region
5526 "\C-c\C-v" message-delete-not-region
5527 "\C-c\C-z" message-kill-to-signature
5528 "\M-\r" message-newline-and-reformat
5529 "\C-c\C-a" mml-attach-file
5530 "\C-a" message-beginning-of-line
5532 "\M-;" comment-region)
5534 (gnus-define-keys (gnus-article-edit-wash-map
5535 "\C-c\C-w" gnus-article-edit-mode-map)
5536 "f" gnus-article-edit-full-stops))
5539 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5541 ["Fetch To" message-insert-to t]
5542 ["Fetch Newsgroups" message-insert-newsgroups t]
5544 ["To" message-goto-to t]
5545 ["From" message-goto-from t]
5546 ["Subject" message-goto-subject t]
5547 ["Cc" message-goto-cc t]
5548 ["Reply-To" message-goto-reply-to t]
5549 ["Summary" message-goto-summary t]
5550 ["Keywords" message-goto-keywords t]
5551 ["Newsgroups" message-goto-newsgroups t]
5552 ["Followup-To" message-goto-followup-to t]
5553 ["Mail-Followup-To" message-goto-mail-followup-to t]
5554 ["Distribution" message-goto-distribution t]
5555 ["Body" message-goto-body t]
5556 ["Signature" message-goto-signature t]))
5558 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5559 "Major mode for editing articles.
5560 This is an extended text-mode.
5562 \\{gnus-article-edit-mode-map}"
5563 (make-local-variable 'gnus-article-edit-done-function)
5564 (make-local-variable 'gnus-prev-winconf)
5565 (set (make-local-variable 'font-lock-defaults)
5566 '(message-font-lock-keywords t))
5567 (set (make-local-variable 'mail-header-separator) "")
5568 (set (make-local-variable 'gnus-article-edit-mode) t)
5569 (easy-menu-add message-mode-field-menu message-mode-map)
5571 (setq buffer-read-only nil)
5572 (buffer-enable-undo)
5575 (defun gnus-article-edit (&optional force)
5576 "Edit the current article.
5577 This will have permanent effect only in mail groups.
5578 If FORCE is non-nil, allow editing of articles even in read-only
5581 (when (and (not force)
5582 (gnus-group-read-only-p))
5583 (error "The current newsgroup does not support article editing"))
5584 (gnus-article-date-original)
5585 (gnus-article-edit-article
5587 `(lambda (no-highlight)
5589 (gnus-summary-edit-article-done
5590 ,(or (mail-header-references gnus-current-headers) "")
5591 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5593 (defun gnus-article-edit-article (start-func exit-func)
5594 "Start editing the contents of the current article buffer."
5595 (let ((winconf (current-window-configuration)))
5596 (set-buffer gnus-article-buffer)
5597 (gnus-article-edit-mode)
5598 (funcall start-func)
5599 (set-buffer-modified-p nil)
5600 (gnus-configure-windows 'edit-article)
5601 (setq gnus-article-edit-done-function exit-func)
5602 (setq gnus-prev-winconf winconf)
5603 (gnus-message 6 "C-c C-c to end edits")))
5605 (defun gnus-article-edit-done (&optional arg)
5606 "Update the article edits and exit."
5608 (let ((func gnus-article-edit-done-function)
5609 (buf (current-buffer))
5610 (start (window-start))
5612 (winconf gnus-prev-winconf))
5613 (widen) ;; Widen it in case that users narrowed the buffer.
5616 ;; The cache and backlog have to be flushed somewhat.
5617 (when gnus-keep-backlog
5618 (gnus-backlog-remove-article
5619 (car gnus-article-current) (cdr gnus-article-current)))
5620 ;; Flush original article as well.
5622 (when (get-buffer gnus-original-article-buffer)
5623 (set-buffer gnus-original-article-buffer)
5624 (setq gnus-original-article nil)))
5625 (when gnus-use-cache
5626 (gnus-cache-update-article
5627 (car gnus-article-current) (cdr gnus-article-current)))
5628 ;; We remove all text props from the article buffer.
5629 (kill-all-local-variables)
5630 (gnus-set-text-properties (point-min) (point-max) nil)
5632 (set-window-configuration winconf)
5634 (set-window-start (get-buffer-window buf) start)
5635 (set-window-point (get-buffer-window buf) (point)))
5636 (gnus-summary-show-article))
5638 (defun gnus-article-edit-exit ()
5639 "Exit the article editing without updating."
5641 (when (or (not (buffer-modified-p))
5642 (yes-or-no-p "Article modified; kill anyway? "))
5643 (let ((curbuf (current-buffer))
5645 (window-start (window-start)))
5647 (if (gnus-buffer-live-p gnus-original-article-buffer)
5648 (insert-buffer gnus-original-article-buffer))
5649 (let ((winconf gnus-prev-winconf))
5650 (kill-all-local-variables)
5652 (set-window-configuration winconf)
5653 ;; Tippy-toe some to make sure that point remains where it was.
5654 (save-current-buffer
5656 (set-window-start (get-buffer-window (current-buffer)) window-start)
5658 (gnus-summary-show-article)))
5660 (defun gnus-article-edit-full-stops ()
5661 "Interactively repair spacing at end of sentences."
5664 (goto-char (point-min))
5665 (search-forward-regexp "^$" nil t)
5666 (let ((case-fold-search nil))
5667 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5670 ;;; Article highlights
5673 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5675 ;;; Internal Variables:
5677 (defcustom gnus-button-url-regexp
5678 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5679 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~%&*+\\/[:word:]]\\)"
5680 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)\\)")
5681 "Regular expression that matches URLs."
5682 :group 'gnus-article-buttons
5685 (defcustom gnus-button-valid-fqdn-regexp
5686 message-valid-fqdn-regexp
5687 "Regular expression that matches a valid FQDN."
5688 :group 'gnus-article-buttons
5691 (defcustom gnus-button-man-handler 'manual-entry
5692 "Function to use for displaying man pages.
5693 The function must take at least one argument with a string naming the
5695 :type '(choice (function-item :tag "Man" manual-entry)
5696 (function-item :tag "Woman" woman)
5697 (function :tag "Other"))
5698 :group 'gnus-article-buttons)
5700 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5701 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5702 If the default site is too slow, try to find a CTAN mirror, see
5703 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5704 the variable `gnus-button-handle-ctan'."
5705 :group 'gnus-article-buttons
5706 :link '(custom-manual "(gnus)Group Parameters")
5707 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5708 (const "http://tug.ctan.org/tex-archive/")
5709 (const "http://www.dante.de/CTAN/")
5710 (string :tag "Other")))
5712 (defcustom gnus-button-ctan-handler 'browse-url
5713 "Function to use for displaying CTAN links.
5714 The function must take one argument, the string naming the URL."
5715 :type '(choice (function-item :tag "Browse Url" browse-url)
5716 (function :tag "Other"))
5717 :group 'gnus-article-buttons)
5719 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5720 "Bogus strings removed from CTAN URLs."
5721 :group 'gnus-article-buttons
5722 :type '(choice (const "^/?tex-archive/\\|/")
5723 (regexp :tag "Other")))
5725 (defcustom gnus-button-ctan-directory-regexp
5727 "\\("; Cannot use `\(?: ... \)' (compatibility with Emacs 20).
5728 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5729 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5730 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5732 "Regular expression for ctan directories.
5733 It should match all directories in the top level of `gnus-ctan-url'."
5734 :group 'gnus-article-buttons
5737 (defcustom gnus-button-mid-or-mail-regexp
5738 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
5739 gnus-button-valid-fqdn-regexp
5741 "Regular expression that matches a message ID or a mail address."
5742 :group 'gnus-article-buttons
5745 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5746 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5747 Strings like this can be either a message ID or a mail address. If it is one
5748 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5749 message ID or a mail address, respectively. If this variable is set to the
5750 symbol `ask', always query the user what do do. If it is a function, this
5751 function will be called with the string as it's only argument. The function
5752 must return `mid', `mail', `invalid' or `ask'."
5753 :group 'gnus-article-buttons
5754 :type '(choice (function-item :tag "Heuristic function"
5755 gnus-button-mid-or-mail-heuristic)
5760 (defcustom gnus-button-mid-or-mail-heuristic-alist
5761 '((-10.0 . ".+\\$.+@")
5764 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5765 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5766 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5767 (-1.0 . "^[^a-z]+@")
5769 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5770 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5771 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5772 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5775 (-1.0 . "^[0-9][0-9]")
5777 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5778 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5779 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5780 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5782 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5783 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5786 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5788 ;; compensation for TDMA dated mail addresses:
5789 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5791 (-20.0 . "\\.fsf@") ;; Gnus
5794 (-20.0 . "_-_") ;; Subject change in thread
5796 (-20.0 . "\\.ln@") ;; leafnode
5797 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5798 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5800 ;; (5.0 . "") ;; $local_part_len <= 7
5801 (10.0 . "^[^0-9]+@")
5802 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5803 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5806 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5808 (0.5 . "^[A-Z][a-z]")
5809 (0.5 . "^[A-Z][a-z][a-z]")
5810 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5811 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5812 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5814 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5815 address. The REGEXP is processed with `case-fold-search' set to nil."
5816 :group 'gnus-article-buttons
5817 :type '(repeat (cons (number :tag "Rate")
5818 (regexp :tag "Regexp"))))
5820 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5821 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5822 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5823 address, `ask' if unsure and `invalid' if the string is invalid."
5824 (let ((case-fold-search nil)
5825 (list gnus-button-mid-or-mail-heuristic-alist)
5826 (result 0) rate regexp lpartlen elem)
5828 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5829 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5830 ;; Certain special cases...
5833 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$" "\\|"
5834 "^[0-9]+\.[0-9]+\@compuserve")
5836 (gnus-message 8 "`%s' is a known mail address.")
5837 (setq result 'mail))
5838 (when (string-match "@.*@\\| " mid-or-mail)
5839 (gnus-message 8 "`%s' is invalid.")
5840 (setq result 'invalid))
5841 ;; Nothing more to do, if result is not a number here...
5842 (when (numberp result)
5844 (setq elem (car list)
5848 (when (string-match regexp mid-or-mail)
5849 (setq result (+ result rate))
5851 9 "`%s' matched `%s', rate `%s', result `%s'."
5852 mid-or-mail regexp rate result)))
5853 (when (<= lpartlen 7)
5854 (setq result (+ result 5.0))
5855 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
5856 mid-or-mail result))
5857 (when (>= lpartlen 12)
5858 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
5860 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
5861 ;; Long local part should contain realname if e-mail address,
5862 ;; too many digits: message-id.
5863 ;; $score -= 5.0 + 0.1 * $local_part_len;
5864 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
5865 (setq result (+ result rate))
5867 9 "Many digits in `%s', rate `%s', result `%s'."
5868 mid-or-mail rate result))
5869 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
5871 ;; Too few vowels [^aeiouy]{4,}.*\@
5872 (setq result (+ result -5.0))
5874 9 "Few vowels in `%s', rate `%s', result `%s'."
5875 mid-or-mail -5.0 result))
5877 (setq result (+ result 5.0))
5879 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
5880 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
5882 ;; Maybe we should make this a customizable alist: (condition . 'result)
5883 ((< result -10.0) 'mid)
5884 ((> result 10.0) 'mail)
5887 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5888 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
5889 (url-mid (concat "news" ":" mid-or-mail))
5890 (url-mailto (concat "mailto" ":" mid-or-mail)))
5891 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5892 (when (fboundp pref)
5894 ;; get rid of surrounding angles...
5896 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
5897 (if (or (eq 'mid guessed) (eq 'mail guessed))
5901 (save-window-excursion
5902 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5905 (cond ((eq pref 'mid)
5906 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
5907 (gnus-button-handle-news url-mid))
5909 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
5910 (gnus-url-mailto url-mailto))
5911 (t (gnus-message 3 "Invalid string.")))))
5913 (defun gnus-button-handle-custom (url)
5914 "Follow a Custom URL."
5915 (customize-apropos (gnus-url-unhex-string url)))
5917 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5919 ;; FIXME: Maybe we should merge some of the functions that do quite similar
5922 (defun gnus-button-handle-describe-function (url)
5923 "Call `describe-function' when pushing the corresponding URL button."
5926 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5928 (defun gnus-button-handle-describe-variable (url)
5929 "Call `describe-variable' when pushing the corresponding URL button."
5932 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5934 (defun gnus-button-handle-symbol (url)
5935 "Display help on variable or function.
5936 Calls `describe-variable' or `describe-function'."
5937 (let ((sym (intern url)))
5939 ((fboundp sym) (describe-function sym))
5940 ((boundp sym) (describe-variable sym))
5941 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
5943 (defun gnus-button-handle-describe-key (url)
5944 "Call `describe-key' when pushing the corresponding URL button."
5946 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5947 (keys (ignore-errors (eval `(kbd ,key-string)))))
5950 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5952 (defun gnus-button-handle-apropos (url)
5953 "Call `apropos' when pushing the corresponding URL button."
5954 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5956 (defun gnus-button-handle-apropos-command (url)
5957 "Call `apropos' when pushing the corresponding URL button."
5959 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5961 (defun gnus-button-handle-apropos-variable (url)
5962 "Call `apropos' when pushing the corresponding URL button."
5964 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5965 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5967 (defun gnus-button-handle-apropos-documentation (url)
5968 "Call `apropos' when pushing the corresponding URL button."
5970 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
5971 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5973 (defun gnus-button-handle-library (url)
5974 "Call `locate-library' when pushing the corresponding URL button."
5975 (gnus-message 9 "url=`%s'" url)
5976 (let* ((lib (locate-library url))
5977 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
5979 (gnus-message 1 "Cannot locale library `%s'." url)
5980 (find-file-read-only file))))
5982 (defun gnus-button-handle-ctan (url)
5983 "Call `browse-url' when pushing a CTAN URL button."
5985 gnus-button-ctan-handler
5988 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
5990 (defcustom gnus-button-tex-level 5
5991 "*Integer that says how many TeX-related buttons Gnus will show.
5992 The higher the number, the more buttons will appear and the more false
5993 positives are possible. Note that you can set this variable local to
5994 specific groups. Setting it higher in TeX groups is probably a good idea.
5995 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5996 how to set variables in specific groups."
5997 :group 'gnus-article-buttons
5998 :link '(custom-manual "(gnus)Group Parameters")
6001 (defcustom gnus-button-man-level 5
6002 "*Integer that says how many man-related buttons Gnus will show.
6003 The higher the number, the more buttons will appear and the more false
6004 positives are possible. Note that you can set this variable local to
6005 specific groups. Setting it higher in Unix groups is probably a good idea.
6006 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6007 how to set variables in specific groups."
6008 :group 'gnus-article-buttons
6009 :link '(custom-manual "(gnus)Group Parameters")
6012 (defcustom gnus-button-emacs-level 5
6013 "*Integer that says how many emacs-related buttons Gnus will show.
6014 The higher the number, the more buttons will appear and the more false
6015 positives are possible. Note that you can set this variable local to
6016 specific groups. Setting it higher in Emacs or Gnus related groups is
6017 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6018 `gnus-parameters' on how to set variables in specific groups."
6019 :group 'gnus-article-buttons
6020 :link '(custom-manual "(gnus)Group Parameters")
6023 (defcustom gnus-button-message-level 5
6024 "*Integer that says how many buttons for news or mail messages will appear.
6025 The higher the number, the more buttons will appear and the more false
6026 positives are possible."
6027 ;; mail addresses, MIDs, URLs for news, ...
6028 :group 'gnus-article-buttons
6031 (defcustom gnus-button-browse-level 5
6032 "*Integer that says how many buttons for browsing will appear.
6033 The higher the number, the more buttons will appear and the more false
6034 positives are possible."
6035 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6036 :group 'gnus-article-buttons
6039 (defcustom gnus-button-alist
6040 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6041 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6042 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6043 gnus-button-handle-news 2)
6044 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6045 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6046 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6047 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6048 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6049 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6050 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6051 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6052 ("mailto:\\([-a-z.@_+0-9%=?&]+\\)"
6053 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6054 ("\\bmailto:\\([^ \n\t]+\\)"
6055 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6057 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6058 gnus-button-ctan-directory-regexp
6059 "[^][>)!;:,'\n\t ]+\\)")
6060 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6061 ((concat "\\btex-archive/\\("
6062 gnus-button-ctan-directory-regexp
6063 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6064 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6067 gnus-button-ctan-directory-regexp
6068 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6069 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6070 ;; This is info (home-grown style) <info://foo/bar+baz>
6071 ("\\binfo://\\([^'\">\n\t ]+\\)"
6072 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6073 ;; Info GNOME style <info:foo#bar_baz>
6074 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6075 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6076 ;; Info KDE style <info:(foo)bar baz>
6077 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6078 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6079 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6080 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6081 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6082 ;; Info links like `C-h i d m CC Mode RET'
6083 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6085 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6086 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6087 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6088 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6089 ;; Emacs help commands
6090 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6091 ;; regexp doesn't match arguments containing ` '.
6092 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6093 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6094 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6095 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6096 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6097 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6098 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6099 ;; The following entries may lead to many false positives so don't enable
6100 ;; them by default (use a high button level):
6101 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6102 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6103 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6104 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6105 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6106 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6107 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6108 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6109 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6110 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6111 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6112 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6113 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6114 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6115 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6116 ;; Unlike the other regexps we really have to require quoting
6117 ;; here to determine where it ends.
6118 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6119 ;; This is how URLs _should_ be embedded in text (RFC 1738)...
6120 ("<URL: *\\([^<>]*\\)>"
6121 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6123 (gnus-button-url-regexp
6124 0 (>= gnus-button-browse-level 0) browse-url 0)
6126 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6127 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6128 gnus-button-handle-man 1)
6129 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6130 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6131 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6132 gnus-button-handle-man 1)
6133 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6134 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6135 ("\\b\\([a-z][-+_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6136 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6137 ;; MID or mail: To avoid too many false positives we don't try to catch
6138 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6139 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6140 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6141 ;; so that non-ambiguous entries (see above) match first.
6142 (gnus-button-mid-or-mail-regexp
6143 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6144 "*Alist of regexps matching buttons in article bodies.
6146 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6147 REGEXP: is the string (case insensitive) matching text around the button (can
6148 also be Lisp expression evaluating to a string),
6149 BUTTON: is the number of the regexp grouping actually matching the button,
6150 FORM: is a Lisp expression which must eval to true for the button to
6152 CALLBACK: is the function to call when the user push this button, and each
6153 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6155 CALLBACK can also be a variable, in that case the value of that
6156 variable it the real callback function."
6157 :group 'gnus-article-buttons
6158 :type '(repeat (list (choice regexp variable sexp)
6159 (integer :tag "Button")
6161 (function :tag "Callback")
6164 (integer :tag "Regexp group")))))
6166 (defcustom gnus-header-button-alist
6167 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6168 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6169 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6170 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6171 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6172 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6173 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6174 0 (>= gnus-button-browse-level 0) browse-url 0)
6175 ("^Subject:" gnus-button-url-regexp
6176 0 (>= gnus-button-browse-level 0) browse-url 0)
6177 ("^[^:]+:" gnus-button-url-regexp
6178 0 (>= gnus-button-browse-level 0) browse-url 0)
6179 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&]+\\)"
6180 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6181 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6182 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6183 "*Alist of headers and regexps to match buttons in article heads.
6185 This alist is very similar to `gnus-button-alist', except that each
6186 alist has an additional HEADER element first in each entry:
6188 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6190 HEADER is a regexp to match a header. For a fuller explanation, see
6191 `gnus-button-alist'."
6192 :group 'gnus-article-buttons
6193 :group 'gnus-article-headers
6194 :type '(repeat (list (regexp :tag "Header")
6195 (choice regexp variable)
6196 (integer :tag "Button")
6198 (function :tag "Callback")
6201 (integer :tag "Regexp group")))))
6203 (defvar gnus-button-regexp nil)
6204 (defvar gnus-button-marker-list nil)
6205 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6207 (defvar gnus-button-last nil)
6208 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6212 (defun gnus-article-push-button (event)
6213 "Check text under the mouse pointer for a callback function.
6214 If the text under the mouse pointer has a `gnus-callback' property,
6215 call it with the value of the `gnus-data' text property."
6217 (set-buffer (window-buffer (posn-window (event-start event))))
6218 (let* ((pos (posn-point (event-start event)))
6219 (data (get-text-property pos 'gnus-data))
6220 (fun (get-text-property pos 'gnus-callback)))
6223 (funcall fun data))))
6225 (defun gnus-article-press-button ()
6226 "Check text at point for a callback function.
6227 If the text at point has a `gnus-callback' property,
6228 call it with the value of the `gnus-data' text property."
6230 (let ((data (get-text-property (point) 'gnus-data))
6231 (fun (get-text-property (point) 'gnus-callback)))
6233 (funcall fun data))))
6235 (defun gnus-article-highlight (&optional force)
6236 "Highlight current article.
6237 This function calls `gnus-article-highlight-headers',
6238 `gnus-article-highlight-citation',
6239 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6240 do the highlighting. See the documentation for those functions."
6241 (interactive (list 'force))
6242 (gnus-article-highlight-headers)
6243 (gnus-article-highlight-citation force)
6244 (gnus-article-highlight-signature)
6245 (gnus-article-add-buttons force)
6246 (gnus-article-add-buttons-to-head))
6248 (defun gnus-article-highlight-some (&optional force)
6249 "Highlight current article.
6250 This function calls `gnus-article-highlight-headers',
6251 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6252 do the highlighting. See the documentation for those functions."
6253 (interactive (list 'force))
6254 (gnus-article-highlight-headers)
6255 (gnus-article-highlight-signature)
6256 (gnus-article-add-buttons))
6258 (defun gnus-article-highlight-headers ()
6259 "Highlight article headers as specified by `gnus-header-face-alist'."
6262 (set-buffer gnus-article-buffer)
6264 (let ((alist gnus-header-face-alist)
6265 (buffer-read-only nil)
6266 (case-fold-search t)
6267 (inhibit-point-motion-hooks t)
6268 entry regexp header-face field-face from hpoints fpoints)
6269 (article-narrow-to-head)
6270 (while (setq entry (pop alist))
6271 (goto-char (point-min))
6272 (setq regexp (concat "^\\("
6273 (if (string-equal "" (nth 0 entry))
6277 header-face (nth 1 entry)
6278 field-face (nth 2 entry))
6279 (while (and (re-search-forward regexp nil t)
6283 (unless (search-forward ":" nil t)
6285 (when (and header-face
6286 (not (memq (point) hpoints)))
6287 (push (point) hpoints)
6288 (gnus-put-text-property from (point) 'face header-face))
6289 (when (and field-face
6290 (not (memq (setq from (point)) fpoints)))
6292 (if (re-search-forward "^[^ \t]" nil t)
6294 (goto-char (point-max)))
6295 (gnus-put-text-property from (point) 'face field-face))))))))
6297 (defun gnus-article-highlight-signature ()
6298 "Highlight the signature in an article.
6299 It does this by highlighting everything after
6300 `gnus-signature-separator' using `gnus-signature-face'."
6303 (set-buffer gnus-article-buffer)
6304 (let ((buffer-read-only nil)
6305 (inhibit-point-motion-hooks t))
6307 (when (and gnus-signature-face
6308 (gnus-article-narrow-to-signature))
6309 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6310 'face gnus-signature-face)
6312 (gnus-article-search-signature)
6313 (let ((start (match-beginning 0))
6314 (end (set-marker (make-marker) (1+ (match-end 0)))))
6315 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6318 (defun gnus-button-in-region-p (b e prop)
6319 "Say whether PROP exists in the region."
6320 (text-property-not-all b e prop nil))
6322 (defun gnus-article-add-buttons (&optional force)
6323 "Find external references in the article and make buttons of them.
6324 \"External references\" are things like Message-IDs and URLs, as
6325 specified by `gnus-button-alist'."
6326 (interactive (list 'force))
6328 (set-buffer gnus-article-buffer)
6329 (let ((buffer-read-only nil)
6330 (inhibit-point-motion-hooks t)
6331 (case-fold-search t)
6332 (alist gnus-button-alist)
6334 ;; Remove all old markers.
6335 (let (marker entry new-list)
6336 (while (setq marker (pop gnus-button-marker-list))
6337 (if (or (< marker (point-min)) (>= marker (point-max)))
6338 (push marker new-list)
6340 (when (setq entry (gnus-button-entry))
6341 (put-text-property (match-beginning (nth 1 entry))
6342 (match-end (nth 1 entry))
6343 'gnus-callback nil))
6344 (set-marker marker nil)))
6345 (setq gnus-button-marker-list new-list))
6346 ;; We skip the headers.
6349 (while (setq entry (pop alist))
6350 (setq regexp (eval (car entry)))
6352 (while (re-search-forward regexp nil t)
6353 (let* ((start (and entry (match-beginning (nth 1 entry))))
6354 (end (and entry (match-end (nth 1 entry))))
6355 (from (match-beginning 0)))
6356 (when (and (or (eq t (nth 2 entry))
6357 (eval (nth 2 entry)))
6358 (not (gnus-button-in-region-p
6359 start end 'gnus-callback)))
6360 ;; That optional form returned non-nil, so we add the
6362 (gnus-article-add-button
6363 start end 'gnus-button-push
6364 (car (push (set-marker (make-marker) from)
6365 gnus-button-marker-list))))))))))
6367 ;; Add buttons to the head of an article.
6368 (defun gnus-article-add-buttons-to-head ()
6369 "Add buttons to the head of the article."
6372 (set-buffer gnus-article-buffer)
6374 (let ((buffer-read-only nil)
6375 (inhibit-point-motion-hooks t)
6376 (case-fold-search t)
6377 (alist gnus-header-button-alist)
6379 (article-narrow-to-head)
6381 ;; Each alist entry.
6382 (setq entry (car alist)
6384 (goto-char (point-min))
6385 (while (re-search-forward (car entry) nil t)
6386 ;; Each header matching the entry.
6387 (setq beg (match-beginning 0))
6388 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6389 (match-beginning 0))
6392 (while (re-search-forward (eval (nth 1 entry)) end t)
6393 ;; Each match within a header.
6394 (let* ((entry (cdr entry))
6395 (start (match-beginning (nth 1 entry)))
6396 (end (match-end (nth 1 entry)))
6397 (form (nth 2 entry)))
6398 (goto-char (match-end 0))
6400 (gnus-article-add-button
6401 start end (nth 3 entry)
6402 (buffer-substring (match-beginning (nth 4 entry))
6403 (match-end (nth 4 entry)))))))
6404 (goto-char end)))))))
6406 ;;; External functions:
6408 (defun gnus-article-add-button (from to fun &optional data)
6409 "Create a button between FROM and TO with callback FUN and data DATA."
6410 (when gnus-article-button-face
6411 (gnus-overlay-put (gnus-make-overlay from to)
6412 'face gnus-article-button-face))
6413 (gnus-add-text-properties
6415 (nconc (and gnus-article-mouse-face
6416 (list gnus-mouse-face-prop gnus-article-mouse-face))
6417 (list 'gnus-callback fun)
6418 (and data (list 'gnus-data data))))
6419 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6420 :button-keymap gnus-widget-button-keymap))
6422 ;;; Internal functions:
6424 (defun gnus-article-set-globals ()
6426 (set-buffer gnus-summary-buffer)
6427 (gnus-set-global-variables)))
6429 (defun gnus-signature-toggle (end)
6431 (set-buffer gnus-article-buffer)
6432 (let ((buffer-read-only nil)
6433 (inhibit-point-motion-hooks t))
6434 (if (text-property-any end (point-max) 'article-type 'signature)
6436 (gnus-delete-wash-type 'signature)
6437 (gnus-remove-text-properties-when
6438 'article-type 'signature end (point-max)
6439 (cons 'article-type (cons 'signature
6440 gnus-hidden-properties))))
6441 (gnus-add-wash-type 'signature)
6442 (gnus-add-text-properties-when
6443 'article-type nil end (point-max)
6444 (cons 'article-type (cons 'signature
6445 gnus-hidden-properties)))))
6446 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6447 (gnus-set-mode-line 'article))))
6449 (defun gnus-button-entry ()
6450 ;; Return the first entry in `gnus-button-alist' matching this place.
6451 (let ((alist gnus-button-alist)
6454 (setq entry (pop alist))
6455 (if (looking-at (eval (car entry)))
6460 (defun gnus-button-push (marker)
6461 ;; Push button starting at MARKER.
6464 (let* ((entry (gnus-button-entry))
6465 (inhibit-point-motion-hooks t)
6467 (args (mapcar (lambda (group)
6468 (let ((string (match-string group)))
6469 (gnus-set-text-properties
6470 0 (length string) nil string)
6477 (fboundp (symbol-value fun)))
6478 (apply (symbol-value fun) args))
6480 (gnus-message 1 "You must define `%S' to use this button"
6481 (cons fun args)))))))
6483 (defun gnus-parse-news-url (url)
6484 (let (scheme server group message-id articles)
6487 (goto-char (point-min))
6488 (when (looking-at "\\([A-Za-z]+\\):")
6489 (setq scheme (match-string 1))
6490 (goto-char (match-end 0)))
6491 (when (looking-at "//\\([^/]+\\)/")
6492 (setq server (match-string 1))
6493 (goto-char (match-end 0)))
6496 ((looking-at "\\(.*@.*\\)")
6497 (setq message-id (match-string 1)))
6498 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6499 (setq group (match-string 1)
6500 articles (split-string (match-string 2) "-")))
6501 ((looking-at "\\([^/]+\\)/?")
6502 (setq group (match-string 1)))
6504 (error "Unknown news URL syntax"))))
6505 (list scheme server group message-id articles)))
6507 (defun gnus-button-handle-news (url)
6509 (destructuring-bind (scheme server group message-id articles)
6510 (gnus-parse-news-url url)
6514 (set-buffer gnus-summary-buffer)
6516 (let ((gnus-refer-article-method (list (list 'nntp server))))
6517 (gnus-summary-refer-article message-id))
6518 (gnus-summary-refer-article message-id))))
6520 (gnus-button-fetch-group url)))))
6522 (defun gnus-button-handle-man (url)
6524 (funcall gnus-button-man-handler url))
6526 (defun gnus-button-handle-info-url (url)
6527 "Fetch an info URL."
6528 (setq url (mm-subst-char-in-string ?+ ?\ url))
6530 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6531 (gnus-info-find-node
6532 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6534 ")" (gnus-url-unhex-string (match-string 2 url)))))
6535 ((string-match "([^)\"]+)[^\"]+" url)
6537 (gnus-replace-in-string
6538 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6539 (gnus-info-find-node url))
6540 (t (error "Can't parse %s" url))))
6542 (defun gnus-button-handle-info-url-gnome (url)
6543 "Fetch GNOME style info URL."
6544 (setq url (mm-subst-char-in-string ?_ ?\ url))
6545 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6546 (gnus-info-find-node
6548 (gnus-url-unhex-string
6549 (match-string 1 url))
6551 (or (gnus-url-unhex-string
6552 (match-string 2 url))
6554 (error "Can't parse %s" url)))
6556 (defun gnus-button-handle-info-url-kde (url)
6557 "Fetch KDE style info URL."
6558 (gnus-info-find-node (gnus-url-unhex-string url)))
6560 (defun gnus-button-handle-info-keystrokes (url)
6561 "Call `info' when pushing the corresponding URL button."
6562 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6567 (defun gnus-button-message-id (message-id)
6570 (set-buffer gnus-summary-buffer)
6571 (gnus-summary-refer-article message-id)))
6573 (defun gnus-button-fetch-group (address)
6574 "Fetch GROUP specified by ADDRESS."
6575 (if (not (string-match "[:/]" address))
6576 ;; This is just a simple group url.
6577 (gnus-group-read-ephemeral-group address gnus-select-method)
6580 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6582 (error "Can't parse %s" address)
6583 (gnus-group-read-ephemeral-group
6584 (match-string 4 address)
6585 `(nntp ,(match-string 1 address)
6586 (nntp-address ,(match-string 1 address))
6587 (nntp-port-number ,(if (match-end 3)
6588 (match-string 3 address)
6591 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6593 (defun gnus-url-parse-query-string (query &optional downcase)
6594 (let (retval pairs cur key val)
6595 (setq pairs (split-string query "&"))
6597 (setq cur (car pairs)
6599 (if (not (string-match "=" cur))
6601 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6602 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6604 (setq key (downcase key)))
6605 (setq cur (assoc key retval))
6607 (setcdr cur (cons val (cdr cur)))
6608 (setq retval (cons (list key val) retval)))))
6611 (defun gnus-url-mailto (url)
6612 ;; Send mail to someone
6613 (when (string-match "mailto:/*\\(.*\\)" url)
6614 (setq url (substring url (match-beginning 1) nil)))
6615 (let (to args subject func)
6616 (setq args (gnus-url-parse-query-string
6617 (if (string-match "^\\?" url)
6619 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6620 (concat "to=" (match-string 1 url) "&"
6621 (match-string 2 url))
6622 (concat "to=" url)))
6624 subject (cdr-safe (assoc "subject" args)))
6627 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6630 (message-position-on-field (caar args)))
6631 (insert (gnus-replace-in-string
6632 (mapconcat 'identity (reverse (cdar args)) ", ")
6634 (setq args (cdr args)))
6637 (message-goto-subject))))
6639 (defun gnus-button-embedded-url (address)
6640 "Activate ADDRESS with `browse-url'."
6641 (browse-url (gnus-strip-whitespace address)))
6643 ;;; Next/prev buttons in the article buffer.
6645 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6646 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6648 (defvar gnus-prev-page-map
6649 (let ((map (make-sparse-keymap)))
6650 (unless (>= emacs-major-version 21)
6651 ;; XEmacs doesn't care.
6652 (set-keymap-parent map gnus-article-mode-map))
6653 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6654 (define-key map "\r" 'gnus-button-prev-page)
6657 (defun gnus-insert-prev-page-button ()
6659 (buffer-read-only nil))
6661 gnus-prev-page-line-format nil
6662 `(,@(gnus-local-map-property gnus-prev-page-map)
6664 gnus-callback gnus-article-button-prev-page
6665 article-type annotation))
6666 (widget-convert-button
6668 ;; Exclude a newline.
6671 :action 'gnus-button-prev-page
6672 :button-keymap gnus-prev-page-map)))
6674 (defvar gnus-prev-page-map
6675 (let ((map (make-sparse-keymap)))
6676 (unless (>= emacs-major-version 21)
6677 ;; XEmacs doesn't care.
6678 (set-keymap-parent map gnus-article-mode-map))
6679 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6680 (define-key map "\r" 'gnus-button-prev-page)
6683 (defvar gnus-next-page-map
6684 (let ((map (make-sparse-keymap)))
6685 (unless (>= emacs-major-version 21)
6686 ;; XEmacs doesn't care.
6687 (set-keymap-parent map gnus-article-mode-map))
6688 (define-key map gnus-mouse-2 'gnus-button-next-page)
6689 (define-key map "\r" 'gnus-button-next-page)
6692 (defun gnus-button-next-page (&optional args more-args)
6693 "Go to the next page."
6695 (let ((win (selected-window)))
6696 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6697 (gnus-article-next-page)
6698 (select-window win)))
6700 (defun gnus-button-prev-page (&optional args more-args)
6701 "Go to the prev page."
6703 (let ((win (selected-window)))
6704 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6705 (gnus-article-prev-page)
6706 (select-window win)))
6708 (defun gnus-insert-next-page-button ()
6710 (buffer-read-only nil))
6711 (gnus-eval-format gnus-next-page-line-format nil
6712 `(,@(gnus-local-map-property gnus-next-page-map)
6714 gnus-callback gnus-article-button-next-page
6715 article-type annotation))
6716 (widget-convert-button
6718 ;; Exclude a newline.
6721 :action 'gnus-button-next-page
6722 :button-keymap gnus-next-page-map)))
6724 (defun gnus-article-button-next-page (arg)
6725 "Go to the next page."
6727 (let ((win (selected-window)))
6728 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6729 (gnus-article-next-page)
6730 (select-window win)))
6732 (defun gnus-article-button-prev-page (arg)
6733 "Go to the prev page."
6735 (let ((win (selected-window)))
6736 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6737 (gnus-article-prev-page)
6738 (select-window win)))
6740 (defvar gnus-decode-header-methods
6741 '(mail-decode-encoded-word-region)
6742 "List of methods used to decode headers.
6744 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6745 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6746 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6747 whose names match REGEXP.
6750 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6751 mail-decode-encoded-word-region
6752 (\"chinese\" . rfc1843-decode-region))
6755 (defvar gnus-decode-header-methods-cache nil)
6757 (defun gnus-multi-decode-header (start end)
6758 "Apply the functions from `gnus-encoded-word-methods' that match."
6759 (unless (and gnus-decode-header-methods-cache
6760 (eq gnus-newsgroup-name
6761 (car gnus-decode-header-methods-cache)))
6762 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6765 (nconc gnus-decode-header-methods-cache (list x))
6766 (if (and gnus-newsgroup-name
6767 (string-match (car x) gnus-newsgroup-name))
6768 (nconc gnus-decode-header-methods-cache
6770 gnus-decode-header-methods))
6771 (let ((xlist gnus-decode-header-methods-cache))
6774 (narrow-to-region start end)
6776 (funcall (pop xlist) (point-min) (point-max))))))
6779 ;;; Treatment top-level handling.
6782 (defun gnus-treat-article (condition &optional part-number total-parts type)
6783 (let ((length (- (point-max) (point-min)))
6784 (alist gnus-treatment-function-alist)
6785 (article-goto-body-goes-to-point-min-p t)
6789 (let ((list gnus-article-treat-types))
6791 (when (string-match (pop list) type)
6792 (throw 'found t)))))))
6793 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6795 (gnus-run-hooks 'gnus-part-display-hook)
6796 (dolist (elem alist)
6799 (when (gnus-buffer-live-p gnus-summary-buffer)
6800 (set-buffer gnus-summary-buffer))
6801 (symbol-value (car elem))))
6802 (when (and (or (consp val)
6804 (gnus-treat-predicate val)
6805 (or (not (get (car elem) 'highlight))
6808 (funcall (cadr elem)))))))
6810 ;; Dynamic variables.
6812 (defvar part-number)
6813 (defvar total-parts)
6818 (defun gnus-treat-predicate (val)
6825 (stringp (car val)))
6826 (apply 'gnus-or (mapcar `(lambda (s)
6827 (string-match s ,(or gnus-newsgroup-name "")))
6830 (let ((pred (pop val)))
6833 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6835 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6837 (not (gnus-treat-predicate (car val))))
6839 (equal (car val) type))
6841 (error "%S is not a valid predicate" pred)))))
6847 (eq part-number total-parts))
6851 (error "%S is not a valid value" val))))
6853 (defun gnus-article-encrypt-body (protocol &optional n)
6854 "Encrypt the article body."
6857 (or gnus-article-encrypt-protocol
6858 (completing-read "Encrypt protocol: "
6859 gnus-article-encrypt-protocol-alist
6861 current-prefix-arg))
6862 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6864 (error (format "Can't find the encrypt protocol %s" protocol)))
6865 (if (member gnus-newsgroup-name '("nndraft:delayed"
6868 (error "Can't encrypt the article in group %s"
6869 gnus-newsgroup-name))
6870 (gnus-summary-iterate n
6872 (set-buffer gnus-summary-buffer)
6873 (let ((mail-parse-charset gnus-newsgroup-charset)
6874 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6875 (summary-buffer gnus-summary-buffer)
6877 (gnus-set-global-variables)
6878 (when (gnus-group-read-only-p)
6879 (error "The current newsgroup does not support article encrypt"))
6880 (gnus-summary-show-article t)
6882 (or (mail-header-references gnus-current-headers) ""))
6883 (set-buffer gnus-article-buffer)
6884 (let* ((buffer-read-only nil)
6886 (mapcar (lambda (field)
6887 (and (save-restriction
6888 (message-narrow-to-head)
6889 (goto-char (point-min))
6890 (search-forward field nil t))
6892 (message-narrow-to-field)
6894 (delete-region (point-min) (point-max))
6896 '("Content-Type:" "Content-Transfer-Encoding:"
6897 "Content-Disposition:"))))
6898 (message-narrow-to-head)
6899 (message-remove-header "MIME-Version")
6900 (goto-char (point-max))
6901 (setq point (point))
6902 (insert (apply 'concat headers))
6904 (narrow-to-region point (point-max))
6905 (let ((message-options message-options))
6906 (message-options-set 'message-sender user-mail-address)
6907 (message-options-set 'message-recipients user-mail-address)
6908 (message-options-set 'message-sign-encrypt 'not)
6910 (goto-char (point-min))
6911 (insert "MIME-Version: 1.0\n")
6913 (gnus-summary-edit-article-done
6914 references nil summary-buffer t))
6915 (when gnus-keep-backlog
6916 (gnus-backlog-remove-article
6917 (car gnus-article-current) (cdr gnus-article-current)))
6919 (when (get-buffer gnus-original-article-buffer)
6920 (set-buffer gnus-original-article-buffer)
6921 (setq gnus-original-article nil)))
6922 (when gnus-use-cache
6923 (gnus-cache-update-article
6924 (car gnus-article-current) (cdr gnus-article-current))))))))
6926 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6927 "The following specs can be used:
6928 %t The security MIME type
6931 %D Details if button is pressed")
6933 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6934 "The following specs can be used:
6935 %t The security MIME type
6938 %D Details if button is pressed")
6940 (defvar gnus-mime-security-button-line-format-alist
6941 '((?t gnus-tmp-type ?s)
6942 (?i gnus-tmp-info ?s)
6943 (?d gnus-tmp-details ?s)
6944 (?D gnus-tmp-pressed-details ?s)))
6946 (defvar gnus-mime-security-button-map
6947 (let ((map (make-sparse-keymap)))
6948 (unless (>= (string-to-number emacs-version) 21)
6949 (set-keymap-parent map gnus-article-mode-map))
6950 (define-key map gnus-mouse-2 'gnus-article-push-button)
6951 (define-key map "\r" 'gnus-article-press-button)
6954 (defvar gnus-mime-security-details-buffer nil)
6956 (defvar gnus-mime-security-button-pressed nil)
6958 (defvar gnus-mime-security-show-details-inline t
6959 "If non-nil, show details in the article buffer.")
6961 (defun gnus-mime-security-verify-or-decrypt (handle)
6962 (mm-remove-parts (cdr handle))
6963 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6964 point buffer-read-only)
6966 (goto-char (car region)))
6968 (narrow-to-region (point) (point))
6969 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6970 (let* ((mm-verify-option 'known)
6971 (mm-decrypt-option 'known)
6972 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6973 (unless (eq nparts (cdr handle))
6974 (mm-destroy-parts (cdr handle))
6975 (setcdr handle nparts))))
6976 (setq point (point))
6977 (gnus-mime-display-security handle)
6978 (goto-char (point-max)))
6980 (delete-region (point) (cdr region))
6981 (set-marker (car region) nil)
6982 (set-marker (cdr region) nil))
6985 (defun gnus-mime-security-show-details (handle)
6986 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6988 (gnus-message 5 "No details.")
6989 (if gnus-mime-security-show-details-inline
6990 (let ((gnus-mime-security-button-pressed
6991 (not (get-text-property (point) 'gnus-mime-details)))
6992 (gnus-mime-security-button-line-format
6993 (get-text-property (point) 'gnus-line-format))
6996 (while (eq (get-text-property (point) 'gnus-line-format)
6997 gnus-mime-security-button-line-format)
7001 (narrow-to-region (point) (point))
7002 (gnus-insert-mime-security-button handle))
7003 (delete-region (point)
7004 (or (text-property-not-all
7007 gnus-mime-security-button-line-format)
7010 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7011 (with-current-buffer gnus-mime-security-details-buffer
7014 (setq gnus-mime-security-details-buffer
7015 (gnus-get-buffer-create "*MIME Security Details*")))
7016 (with-current-buffer gnus-mime-security-details-buffer
7018 (goto-char (point-min)))
7019 (pop-to-buffer gnus-mime-security-details-buffer)))))
7021 (defun gnus-mime-security-press-button (handle)
7023 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7024 (gnus-mime-security-show-details handle)
7025 (gnus-mime-security-verify-or-decrypt handle))))
7027 (defun gnus-insert-mime-security-button (handle &optional displayed)
7028 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7031 (or (nth 2 (assoc protocol mm-verify-function-alist))
7032 (nth 2 (assoc protocol mm-decrypt-function-alist))
7034 (if (equal (car handle) "multipart/signed")
7035 " Signed" " Encrypted")
7038 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7041 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7042 gnus-tmp-pressed-details
7044 (setq gnus-tmp-details
7045 (if gnus-tmp-details
7046 (concat "\n" gnus-tmp-details)
7048 (setq gnus-tmp-pressed-details
7049 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7054 gnus-mime-security-button-line-format
7055 gnus-mime-security-button-line-format-alist
7056 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7057 gnus-callback gnus-mime-security-press-button
7058 gnus-line-format ,gnus-mime-security-button-line-format
7059 gnus-mime-details ,gnus-mime-security-button-pressed
7060 article-type annotation
7063 ;; Exclude a newline.
7066 (widget-convert-button
7069 :action 'gnus-widget-press-button
7070 :button-keymap gnus-mime-security-button-map
7072 (lambda (widget/window &optional overlay pos)
7073 ;; Needed to properly clear the message due to a bug in
7074 ;; wid-edit (XEmacs only).
7075 (when (boundp 'help-echo-owns-message)
7076 (setq help-echo-owns-message t))
7079 (aref gnus-mouse-2 0))))))
7081 (defun gnus-mime-display-security (handle)
7083 (narrow-to-region (point) (point))
7084 (unless (gnus-unbuttonized-mime-type-p (car handle))
7085 (gnus-insert-mime-security-button handle))
7086 (gnus-mime-display-mixed (cdr handle))
7089 (unless (gnus-unbuttonized-mime-type-p (car handle))
7090 (let ((gnus-mime-security-button-line-format
7091 gnus-mime-security-button-end-line-format))
7092 (gnus-insert-mime-security-button handle)))
7093 (mm-set-handle-multipart-parameter
7095 (cons (set-marker (make-marker) (point-min))
7096 (set-marker (make-marker) (point-max))))))
7102 (run-hooks 'gnus-art-load-hook)
7104 ;;; gnus-art.el ends here