1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
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.
29 (eval-when-compile (require 'cl))
43 (autoload 'gnus-msg-mail "gnus-msg" nil t)
44 (autoload 'gnus-button-mailto "gnus-msg")
45 (autoload 'gnus-button-reply "gnus-msg" nil t)
47 (defgroup gnus-article nil
49 :link '(custom-manual "(gnus)The Article Buffer")
52 (defgroup gnus-article-treat nil
53 "Treating article parts."
54 :link '(custom-manual "(gnus)Article Hiding")
57 (defgroup gnus-article-hiding nil
58 "Hiding article parts."
59 :link '(custom-manual "(gnus)Article Hiding")
62 (defgroup gnus-article-highlight nil
63 "Article highlighting."
64 :link '(custom-manual "(gnus)Article Highlighting")
68 (defgroup gnus-article-signature nil
70 :link '(custom-manual "(gnus)Article Signature")
73 (defgroup gnus-article-headers nil
75 :link '(custom-manual "(gnus)Hiding Headers")
78 (defgroup gnus-article-washing nil
79 "Special commands on articles."
80 :link '(custom-manual "(gnus)Article Washing")
83 (defgroup gnus-article-emphasis nil
84 "Fontisizing articles."
85 :link '(custom-manual "(gnus)Article Fontisizing")
88 (defgroup gnus-article-saving nil
90 :link '(custom-manual "(gnus)Saving Articles")
93 (defgroup gnus-article-mime nil
94 "Worshiping the MIME wonder."
95 :link '(custom-manual "(gnus)Using MIME")
98 (defgroup gnus-article-buttons nil
99 "Pushable buttons in the article buffer."
100 :link '(custom-manual "(gnus)Article Buttons")
101 :group 'gnus-article)
103 (defgroup gnus-article-various nil
104 "Other article options."
105 :link '(custom-manual "(gnus)Misc Article")
106 :group 'gnus-article)
108 (defcustom gnus-ignored-headers
109 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
110 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
111 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
112 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
113 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
114 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face"
115 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
116 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
117 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
118 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
119 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
120 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
121 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
122 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
123 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
124 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
125 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
126 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
127 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
128 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
129 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
130 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
131 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
132 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
133 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
134 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
135 "^X-Received:" "^Content-length:" "X-precedence:"
136 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
137 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
138 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
139 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
140 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
141 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:"
142 "^X-Request-PGP:" "^X-Fingerprint:" "^X-WRIEnvto:" "^X-WRIEnvfrom:"
143 "^X-Virus-Scanned:" "^X-Delivery-Agent:" "^Posted-Date:" "^X-Gateway:"
144 "^X-Local-Origin:" "^X-Local-Destination:" "^X-UserInfo1:"
145 "^X-Received-Date:" "^X-Hashcash:")
146 "*All headers that start with this regexp will be hidden.
147 This variable can also be a list of regexps of headers to be ignored.
148 If `gnus-visible-headers' is non-nil, this variable will be ignored."
149 :type '(choice :custom-show nil
152 :group 'gnus-article-hiding)
154 (defcustom gnus-visible-headers
155 "^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:"
156 "*All headers that do not match this regexp will be hidden.
157 This variable can also be a list of regexp of headers to remain visible.
158 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
159 :type '(repeat :value-to-internal (lambda (widget value)
160 (custom-split-regexp-maybe value))
161 :match (lambda (widget value)
163 (widget-editable-list-match widget value)))
165 :group 'gnus-article-hiding)
167 (defcustom gnus-sorted-header-list
168 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
169 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
170 "*This variable is a list of regular expressions.
171 If it is non-nil, headers that match the regular expressions will
172 be placed first in the article buffer in the sequence specified by
174 :type '(repeat regexp)
175 :group 'gnus-article-hiding)
177 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
178 "Headers that are only to be displayed if they have interesting data.
179 Possible values in this list are:
181 'empty Headers with no content.
182 'newsgroups Newsgroup identical to Gnus group.
183 'to-address To identical to To-address.
184 'followup-to Followup-to identical to Newsgroups.
185 'reply-to Reply-to identical to From.
186 'date Date less than four days old.
187 'long-to To and/or Cc longer than 1024 characters.
188 'many-to Multiple To and/or Cc."
189 :type '(set (const :tag "Headers with no content." empty)
190 (const :tag "Newsgroups identical to Gnus group." newsgroups)
191 (const :tag "To identical to To-address." to-address)
192 (const :tag "Followup-to identical to Newsgroups." followup-to)
193 (const :tag "Reply-to identical to From." reply-to)
194 (const :tag "Date less than four days old." date)
195 (const :tag "To and/or Cc longer than 1024 characters." long-to)
196 (const :tag "Multiple To and/or Cc headers." many-to))
197 :group 'gnus-article-hiding)
199 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
200 "Regexp matching signature separator.
201 This can also be a list of regexps. In that case, it will be checked
202 from head to tail looking for a separator. Searches will be done from
203 the end of the buffer."
204 :type '(repeat string)
205 :group 'gnus-article-signature)
207 (defcustom gnus-signature-limit nil
208 "Provide a limit to what is considered a signature.
209 If it is a number, no signature may not be longer (in characters) than
210 that number. If it is a floating point number, no signature may be
211 longer (in lines) than that number. If it is a function, the function
212 will be called without any parameters, and if it returns nil, there is
213 no signature in the buffer. If it is a string, it will be used as a
214 regexp. If it matches, the text in question is not a signature."
215 :type '(choice (integer :value 200)
217 (function :value fun)
218 (regexp :value ".*"))
219 :group 'gnus-article-signature)
221 (defcustom gnus-hidden-properties '(invisible t intangible t)
222 "Property list to use for hiding text."
224 :group 'gnus-article-hiding)
226 ;; Fixme: This isn't the right thing for mixed graphical and and
227 ;; non-graphical frames in a session.
228 (defcustom gnus-article-x-face-command
229 (if (featurep 'xemacs)
230 (if (or (gnus-image-type-available-p 'xface)
231 (gnus-image-type-available-p 'pbm))
232 'gnus-display-x-face-in-from
233 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
234 (if (gnus-image-type-available-p 'pbm)
235 'gnus-display-x-face-in-from
236 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
238 "*String or function to be executed to display an X-Face header.
239 If it is a string, the command will be executed in a sub-shell
240 asynchronously. The compressed face will be piped to this command."
241 :type `(choice string
242 (function-item gnus-display-x-face-in-from)
246 :group 'gnus-article-washing)
248 (defcustom gnus-article-x-face-too-ugly nil
249 "Regexp matching posters whose face shouldn't be shown automatically."
250 :type '(choice regexp (const nil))
251 :group 'gnus-article-washing)
253 (defcustom gnus-article-banner-alist nil
254 "Banner alist for stripping.
256 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
258 :type '(repeat (cons symbol regexp))
259 :group 'gnus-article-washing)
261 (gnus-define-group-parameter
264 "Alist of regexps (to match group names) and banner."
265 :variable-group gnus-article-washing
267 '(choice :tag "Banner"
269 (const :tag "Remove signature" signature)
270 (symbol :tag "Item in `gnus-article-banner-alist'" none)
272 (const :tag "None" nil))
274 "If non-nil, specify how to remove `banners' from articles.
276 Symbol `signature' means to remove signatures delimited by
277 `gnus-signature-separator'. Any other symbol is used to look up a
278 regular expression to match the banner in `gnus-article-banner-alist'.
279 A string is used as a regular expression to match the banner
282 (defcustom gnus-article-address-banner-alist nil
283 "Alist of mail addresses and banners.
284 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
285 to match a mail address in the From: header, BANNER is one of a symbol
286 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
287 If ADDRESS matches author's mail address, it will remove things like
288 advertisements. For example:
290 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
294 (regexp :tag "Address")
295 (choice :tag "Banner" :value nil
296 (const :tag "Remove signature" signature)
297 (symbol :tag "Item in `gnus-article-banner-alist'" none)
299 (const :tag "None" nil))))
300 :group 'gnus-article-washing)
302 (defcustom gnus-emphasis-alist
304 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
309 ("_/" "/_" underline-italic)
310 ("_\\*" "\\*_" underline-bold)
311 ("\\*/" "/\\*" bold-italic)
312 ("_\\*/" "/\\*_" underline-bold-italic))))
316 (format format (car spec) (cadr spec))
317 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
319 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
320 2 3 gnus-emphasis-strikethru)
321 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
322 2 3 gnus-emphasis-underline)))
323 "*Alist that says how to fontify certain phrases.
324 Each item looks like this:
326 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
328 The first element is a regular expression to be matched. The second
329 is a number that says what regular expression grouping used to find
330 the entire emphasized word. The third is a number that says what
331 regexp grouping should be displayed and highlighted. The fourth
332 is the face used for highlighting."
333 :type '(repeat (list :value ("" 0 0 default)
335 (integer :tag "Match group")
336 (integer :tag "Emphasize group")
338 :group 'gnus-article-emphasis)
340 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
341 "A regexp to describe whitespace which should not be emphasized.
342 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
343 The former avoids underlining of leading and trailing whitespace,
344 and the latter avoids underlining any whitespace at all."
346 :group 'gnus-article-emphasis
349 (defface gnus-emphasis-bold '((t (:bold t)))
350 "Face used for displaying strong emphasized text (*word*)."
351 :group 'gnus-article-emphasis)
353 (defface gnus-emphasis-italic '((t (:italic t)))
354 "Face used for displaying italic emphasized text (/word/)."
355 :group 'gnus-article-emphasis)
357 (defface gnus-emphasis-underline '((t (:underline t)))
358 "Face used for displaying underlined emphasized text (_word_)."
359 :group 'gnus-article-emphasis)
361 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
362 "Face used for displaying underlined bold emphasized text (_*word*_)."
363 :group 'gnus-article-emphasis)
365 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
366 "Face used for displaying underlined italic emphasized text (_/word/_)."
367 :group 'gnus-article-emphasis)
369 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
370 "Face used for displaying bold italic emphasized text (/*word*/)."
371 :group 'gnus-article-emphasis)
373 (defface gnus-emphasis-underline-bold-italic
374 '((t (:bold t :italic t :underline t)))
375 "Face used for displaying underlined bold italic emphasized text.
376 Example: (_/*word*/_)."
377 :group 'gnus-article-emphasis)
379 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
380 "Face used for displaying strike-through text (-word-)."
381 :group 'gnus-article-emphasis)
383 (defface gnus-emphasis-highlight-words
384 '((t (:background "black" :foreground "yellow")))
385 "Face used for displaying highlighted words."
386 :group 'gnus-article-emphasis)
388 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
389 "Format for display of Date headers in article bodies.
390 See `format-time-string' for the possible values.
392 The variable can also be function, which should return a complete Date
393 header. The function is called with one argument, the time, which can
394 be fed to `format-time-string'."
395 :type '(choice string symbol)
396 :link '(custom-manual "(gnus)Article Date")
397 :group 'gnus-article-washing)
400 (autoload 'mail-extract-address-components "mail-extr"))
402 (defcustom gnus-save-all-headers t
403 "*If non-nil, don't remove any headers before saving."
404 :group 'gnus-article-saving
407 (defcustom gnus-prompt-before-saving 'always
408 "*This variable says how much prompting is to be done when saving articles.
409 If it is nil, no prompting will be done, and the articles will be
410 saved to the default files. If this variable is `always', each and
411 every article that is saved will be preceded by a prompt, even when
412 saving large batches of articles. If this variable is neither nil not
413 `always', there the user will be prompted once for a file name for
414 each invocation of the saving commands."
415 :group 'gnus-article-saving
416 :type '(choice (item always)
417 (item :tag "never" nil)
418 (sexp :tag "once" :format "%t\n" :value t)))
420 (defcustom gnus-saved-headers gnus-visible-headers
421 "Headers to keep if `gnus-save-all-headers' is nil.
422 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
423 If that variable is nil, however, all headers that match this regexp
424 will be kept while the rest will be deleted before saving."
425 :group 'gnus-article-saving
428 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
429 "A function to save articles in your favourite format.
430 The function must be interactively callable (in other words, it must
431 be an Emacs command).
433 Gnus provides the following functions:
435 * gnus-summary-save-in-rmail (Rmail format)
436 * gnus-summary-save-in-mail (Unix mail format)
437 * gnus-summary-save-in-folder (MH folder)
438 * gnus-summary-save-in-file (article format)
439 * gnus-summary-save-body-in-file (article body)
440 * gnus-summary-save-in-vm (use VM's folder format)
441 * gnus-summary-write-to-file (article format -- overwrite)."
442 :group 'gnus-article-saving
443 :type '(radio (function-item gnus-summary-save-in-rmail)
444 (function-item gnus-summary-save-in-mail)
445 (function-item gnus-summary-save-in-folder)
446 (function-item gnus-summary-save-in-file)
447 (function-item gnus-summary-save-body-in-file)
448 (function-item gnus-summary-save-in-vm)
449 (function-item gnus-summary-write-to-file)))
451 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
452 "A function generating a file name to save articles in Rmail format.
453 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
454 :group 'gnus-article-saving
457 (defcustom gnus-mail-save-name 'gnus-plain-save-name
458 "A function generating a file name to save articles in Unix mail format.
459 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
460 :group 'gnus-article-saving
463 (defcustom gnus-folder-save-name 'gnus-folder-save-name
464 "A function generating a file name to save articles in MH folder.
465 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
466 :group 'gnus-article-saving
469 (defcustom gnus-file-save-name 'gnus-numeric-save-name
470 "A function generating a file name to save articles in article format.
471 The function is called with NEWSGROUP, HEADERS, and optional
473 :group 'gnus-article-saving
476 (defcustom gnus-split-methods
477 '((gnus-article-archive-name)
478 (gnus-article-nndoc-name))
479 "*Variable used to suggest where articles are to be saved.
480 For instance, if you would like to save articles related to Gnus in
481 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
482 you could set this variable to something like:
484 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
485 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
487 This variable is an alist where the where the key is the match and the
488 value is a list of possible files to save in if the match is non-nil.
490 If the match is a string, it is used as a regexp match on the
491 article. If the match is a symbol, that symbol will be funcalled
492 from the buffer of the article to be saved with the newsgroup as the
493 parameter. If it is a list, it will be evaled in the same buffer.
495 If this form or function returns a string, this string will be used as
496 a possible file name; and if it returns a non-nil list, that list will
497 be used as possible file names."
498 :group 'gnus-article-saving
499 :type '(repeat (choice (list :value (fun) function)
500 (cons :value ("" "") regexp (repeat string))
503 (defcustom gnus-page-delimiter "^\^L"
504 "*Regexp describing what to use as article page delimiters.
505 The default value is \"^\^L\", which is a form linefeed at the
506 beginning of a line."
508 :group 'gnus-article-various)
510 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
511 "*The format specification for the article mode line.
512 See `gnus-summary-mode-line-format' for a closer description.
514 The following additional specs are available:
516 %w The article washing status.
517 %m The number of MIME parts in the article."
519 :group 'gnus-article-various)
521 (defcustom gnus-article-mode-hook nil
522 "*A hook for Gnus article mode."
524 :group 'gnus-article-various)
526 (when (featurep 'xemacs)
527 ;; Extracted from gnus-xmas-define in order to preserve user settings
528 (when (fboundp 'turn-off-scroll-in-place)
529 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
530 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
531 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
533 (defcustom gnus-article-menu-hook nil
534 "*Hook run after the creation of the article mode menu."
536 :group 'gnus-article-various)
538 (defcustom gnus-article-prepare-hook nil
539 "*A hook called after an article has been prepared in the article buffer."
541 :group 'gnus-article-various)
543 (defcustom gnus-article-hide-pgp-hook nil
544 "*A hook called after successfully hiding a PGP signature."
546 :group 'gnus-article-various)
548 (defcustom gnus-article-button-face 'bold
549 "Face used for highlighting buttons in the article buffer.
551 An article button is a piece of text that you can activate by pressing
552 `RET' or `mouse-2' above it."
554 :group 'gnus-article-buttons)
556 (defcustom gnus-article-mouse-face 'highlight
557 "Face used for mouse highlighting in the article buffer.
559 Article buttons will be displayed in this face when the cursor is
562 :group 'gnus-article-buttons)
564 (defcustom gnus-signature-face 'gnus-signature-face
565 "Face used for highlighting a signature in the article buffer.
566 Obsolete; use the face `gnus-signature-face' for customizations instead."
568 :group 'gnus-article-highlight
569 :group 'gnus-article-signature)
571 (defface gnus-signature-face
574 "Face used for highlighting a signature in the article buffer."
575 :group 'gnus-article-highlight
576 :group 'gnus-article-signature)
578 (defface gnus-header-from-face
581 (:foreground "spring green"))
584 (:foreground "red3"))
587 "Face used for displaying from headers."
588 :group 'gnus-article-headers
589 :group 'gnus-article-highlight)
591 (defface gnus-header-subject-face
594 (:foreground "SeaGreen3"))
597 (:foreground "red4"))
599 (:bold t :italic t)))
600 "Face used for displaying subject headers."
601 :group 'gnus-article-headers
602 :group 'gnus-article-highlight)
604 (defface gnus-header-newsgroups-face
607 (:foreground "yellow" :italic t))
610 (:foreground "MidnightBlue" :italic t))
613 "Face used for displaying newsgroups headers."
614 :group 'gnus-article-headers
615 :group 'gnus-article-highlight)
617 (defface gnus-header-name-face
620 (:foreground "SeaGreen"))
623 (:foreground "maroon"))
626 "Face used for displaying header names."
627 :group 'gnus-article-headers
628 :group 'gnus-article-highlight)
630 (defface gnus-header-content-face
633 (:foreground "forest green" :italic t))
636 (:foreground "indianred4" :italic t))
638 (:italic t))) "Face used for displaying header content."
639 :group 'gnus-article-headers
640 :group 'gnus-article-highlight)
642 (defcustom gnus-header-face-alist
643 '(("From" nil gnus-header-from-face)
644 ("Subject" nil gnus-header-subject-face)
645 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
646 ("" gnus-header-name-face gnus-header-content-face))
647 "*Controls highlighting of article header.
649 An alist of the form (HEADER NAME CONTENT).
651 HEADER is a regular expression which should match the name of an
652 header header and NAME and CONTENT are either face names or nil.
654 The name of each header field will be displayed using the face
655 specified by the first element in the list where HEADER match the
656 header name and NAME is non-nil. Similarly, the content will be
657 displayed by the first non-nil matching CONTENT face."
658 :group 'gnus-article-headers
659 :group 'gnus-article-highlight
660 :type '(repeat (list (regexp :tag "Header")
662 (item :tag "skip" nil)
663 (face :value default))
664 (choice :tag "Content"
665 (item :tag "skip" nil)
666 (face :value default)))))
668 (defcustom gnus-article-decode-hook
669 '(article-decode-charset article-decode-encoded-words
670 article-decode-group-name)
671 "*Hook run to decode charsets in articles."
672 :group 'gnus-article-headers
675 (defcustom gnus-display-mime-function 'gnus-display-mime
676 "Function to display MIME articles."
677 :group 'gnus-article-mime
680 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
681 "Function used to decode headers.")
683 (defvar gnus-article-dumbquotes-map
703 "Table for MS-to-Latin1 translation.")
705 (defcustom gnus-ignored-mime-types nil
706 "List of MIME types that should be ignored by Gnus."
708 :group 'gnus-article-mime
709 :type '(repeat regexp))
711 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
712 "List of MIME types that should not be given buttons when rendered inline.
713 See also `gnus-buttonized-mime-types' which may override this variable."
715 :group 'gnus-article-mime
716 :type '(repeat regexp))
718 (defcustom gnus-buttonized-mime-types nil
719 "List of MIME types that should be given buttons when rendered inline.
720 If set, this variable overrides `gnus-unbuttonized-mime-types'.
721 To see e.g. security buttons you could set this to
722 `(\"multipart/signed\")'."
724 :group 'gnus-article-mime
725 :type '(repeat regexp))
727 (defcustom gnus-inhibit-mime-unbuttonizing nil
728 "If non-nil, all MIME parts get buttons.
729 When nil (the default value), then some MIME parts do not get buttons,
730 as described by the variables `gnus-buttonized-mime-types' and
731 `gnus-unbuttonized-mime-types'."
735 (defcustom gnus-body-boundary-delimiter "_"
736 "String used to delimit header and body.
737 This variable is used by `gnus-article-treat-body-boundary' which can
738 be controlled by `gnus-treat-body-boundary'."
739 :group 'gnus-article-various
740 :type '(choice (item :tag "None" :value nil)
743 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
744 "Defines the location of the faces database.
745 For information on obtaining this database of pretty pictures, please
746 see http://www.cs.indiana.edu/picons/ftp/index.html"
747 :type '(repeat directory)
748 :link '(url-link :tag "download"
749 "http://www.cs.indiana.edu/picons/ftp/index.html")
750 :link '(custom-manual "(gnus)Picons")
753 (defun gnus-picons-installed-p ()
754 "Say whether picons are installed on your machine."
755 (let ((installed nil))
756 (dolist (database gnus-picon-databases)
757 (when (file-exists-p database)
761 (defcustom gnus-article-mime-part-function nil
762 "Function called with a MIME handle as the argument.
763 This is meant for people who want to do something automatic based
764 on parts -- for instance, adding Vcard info to a database."
765 :group 'gnus-article-mime
768 (defcustom gnus-mime-multipart-functions nil
769 "An alist of MIME types to functions to display them."
771 :group 'gnus-article-mime
774 (defcustom gnus-article-date-lapsed-new-header nil
775 "Whether the X-Sent and Date headers can coexist.
776 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
777 either replace the old \"Date:\" header (if this variable is nil), or
778 be added below it (otherwise)."
780 :group 'gnus-article-headers
783 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
784 "Function called with a MIME handle as the argument.
785 This is meant for people who want to view first matched part.
786 For `undisplayed-alternative' (default), the first undisplayed
787 part or alternative part is used. For `undisplayed', the first
788 undisplayed part is used. For a function, the first part which
789 the function return `t' is used. For `nil', the first part is
792 :group 'gnus-article-mime
794 (item :tag "first" :value nil)
795 (item :tag "undisplayed" :value undisplayed)
796 (item :tag "undisplayed or alternative"
797 :value undisplayed-alternative)
800 (defcustom gnus-mime-action-alist
801 '(("save to file" . gnus-mime-save-part)
802 ("save and strip" . gnus-mime-save-part-and-strip)
803 ("display as text" . gnus-mime-inline-part)
804 ("view the part" . gnus-mime-view-part)
805 ("pipe to command" . gnus-mime-pipe-part)
806 ("toggle display" . gnus-article-press-button)
807 ("toggle display" . gnus-article-view-part-as-charset)
808 ("view as type" . gnus-mime-view-part-as-type)
809 ("view internally" . gnus-mime-view-part-internally)
810 ("view externally" . gnus-mime-view-part-externally))
811 "An alist of actions that run on the MIME attachment."
812 :group 'gnus-article-mime
813 :type '(repeat (cons (string :tag "name")
817 ;;; The treatment variables
820 (defvar gnus-part-display-hook nil
821 "Hook called on parts that are to receive treatment.")
823 (defvar gnus-article-treat-custom
824 '(choice (const :tag "Off" nil)
826 (const :tag "Header" head)
827 (const :tag "Last" last)
828 (integer :tag "Less")
829 (repeat :tag "Groups" regexp)
830 (sexp :tag "Predicate")))
832 (defvar gnus-article-treat-head-custom
833 '(choice (const :tag "Off" nil)
834 (const :tag "Header" head)))
836 (defvar gnus-article-treat-types '("text/plain")
839 (defvar gnus-inhibit-treatment nil
840 "Whether to inhibit treatment.")
842 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
843 "Highlight the signature.
844 Valid values are nil, t, `head', `last', an integer or a predicate.
845 See Info node `(gnus)Customizing Articles'."
846 :group 'gnus-article-treat
847 :link '(custom-manual "(gnus)Customizing Articles")
848 :type gnus-article-treat-custom)
849 (put 'gnus-treat-highlight-signature 'highlight t)
851 (defcustom gnus-treat-buttonize 100000
853 Valid values are nil, t, `head', `last', an integer or a predicate.
854 See Info node `(gnus)Customizing Articles'."
855 :group 'gnus-article-treat
856 :link '(custom-manual "(gnus)Customizing Articles")
857 :type gnus-article-treat-custom)
858 (put 'gnus-treat-buttonize 'highlight t)
860 (defcustom gnus-treat-buttonize-head 'head
861 "Add buttons to the head.
862 Valid values are nil, t, `head', `last', an integer or a predicate.
863 See Info node `(gnus)Customizing Articles' for details."
864 :group 'gnus-article-treat
865 :link '(custom-manual "(gnus)Customizing Articles")
866 :type gnus-article-treat-head-custom)
867 (put 'gnus-treat-buttonize-head 'highlight t)
869 (defcustom gnus-treat-emphasize
870 (and (or window-system
872 (>= (string-to-number emacs-version) 21))
875 Valid values are nil, t, `head', `last', an integer or a predicate.
876 See Info node `(gnus)Customizing Articles' for details."
877 :group 'gnus-article-treat
878 :link '(custom-manual "(gnus)Customizing Articles")
879 :type gnus-article-treat-custom)
880 (put 'gnus-treat-emphasize 'highlight t)
882 (defcustom gnus-treat-strip-cr nil
883 "Remove carriage returns.
884 Valid values are nil, t, `head', `last', an integer or a predicate.
885 See Info node `(gnus)Customizing Articles' for details."
886 :group 'gnus-article-treat
887 :link '(custom-manual "(gnus)Customizing Articles")
888 :type gnus-article-treat-custom)
890 (defcustom gnus-treat-unsplit-urls nil
891 "Remove newlines from within URLs.
892 Valid values are nil, t, `head', `last', an integer or a predicate.
893 See Info node `(gnus)Customizing Articles' for details."
894 :group 'gnus-article-treat
895 :link '(custom-manual "(gnus)Customizing Articles")
896 :type gnus-article-treat-custom)
898 (defcustom gnus-treat-leading-whitespace nil
899 "Remove leading whitespace in headers.
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)
906 (defcustom gnus-treat-hide-headers 'head
908 Valid values are nil, t, `head', `last', an integer or a predicate.
909 See Info node `(gnus)Customizing Articles' for details."
910 :group 'gnus-article-treat
911 :link '(custom-manual "(gnus)Customizing Articles")
912 :type gnus-article-treat-head-custom)
914 (defcustom gnus-treat-hide-boring-headers nil
915 "Hide boring headers.
916 Valid values are nil, t, `head', `last', an integer or a predicate.
917 See Info node `(gnus)Customizing Articles' for details."
918 :group 'gnus-article-treat
919 :link '(custom-manual "(gnus)Customizing Articles")
920 :type gnus-article-treat-head-custom)
922 (defcustom gnus-treat-hide-signature nil
924 Valid values are nil, t, `head', `last', an integer or a predicate.
925 See Info node `(gnus)Customizing Articles' for details."
926 :group 'gnus-article-treat
927 :link '(custom-manual "(gnus)Customizing Articles")
928 :type gnus-article-treat-custom)
930 (defcustom gnus-treat-fill-article nil
932 Valid values are nil, t, `head', `last', an integer or a predicate.
933 See Info node `(gnus)Customizing Articles' for details."
934 :group 'gnus-article-treat
935 :link '(custom-manual "(gnus)Customizing Articles")
936 :type gnus-article-treat-custom)
938 (defcustom gnus-treat-hide-citation nil
940 Valid values are nil, t, `head', `last', an integer or a predicate.
941 See Info node `(gnus)Customizing Articles' for details."
942 :group 'gnus-article-treat
943 :link '(custom-manual "(gnus)Customizing Articles")
944 :type gnus-article-treat-custom)
946 (defcustom gnus-treat-hide-citation-maybe nil
948 Valid values are nil, t, `head', `last', an integer or a predicate.
949 See Info node `(gnus)Customizing Articles' for details."
950 :group 'gnus-article-treat
951 :link '(custom-manual "(gnus)Customizing Articles")
952 :type gnus-article-treat-custom)
954 (defcustom gnus-treat-strip-list-identifiers 'head
955 "Strip list identifiers from `gnus-list-identifiers`.
956 Valid values are nil, t, `head', `last', an integer or a predicate.
957 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-strip-pgp t
964 "Strip PGP signatures.
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-strip-pem nil
972 "Strip PEM signatures.
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-banner t
980 "Strip banners from articles.
981 The banner to be stripped is specified in the `banner' group parameter.
982 Valid values are nil, t, `head', `last', an integer or a predicate.
983 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 (defcustom gnus-treat-highlight-headers 'head
989 "Highlight the headers.
990 Valid values are nil, t, `head', `last', an integer or a predicate.
991 See Info node `(gnus)Customizing Articles' for details."
992 :group 'gnus-article-treat
993 :link '(custom-manual "(gnus)Customizing Articles")
994 :type gnus-article-treat-head-custom)
995 (put 'gnus-treat-highlight-headers 'highlight t)
997 (defcustom gnus-treat-highlight-citation t
998 "Highlight cited text.
999 Valid values are nil, t, `head', `last', an integer or a predicate.
1000 See Info node `(gnus)Customizing Articles' for details."
1001 :group 'gnus-article-treat
1002 :link '(custom-manual "(gnus)Customizing Articles")
1003 :type gnus-article-treat-custom)
1004 (put 'gnus-treat-highlight-citation 'highlight t)
1006 (defcustom gnus-treat-date-ut nil
1007 "Display the Date in UT (GMT).
1008 Valid values are nil, t, `head', `last', an integer or a predicate.
1009 See Info node `(gnus)Customizing Articles' for details."
1010 :group 'gnus-article-treat
1011 :link '(custom-manual "(gnus)Customizing Articles")
1012 :type gnus-article-treat-head-custom)
1014 (defcustom gnus-treat-date-local nil
1015 "Display the Date in the local timezone.
1016 Valid values are nil, t, `head', `last', an integer or a predicate.
1017 See Info node `(gnus)Customizing Articles' for details."
1018 :group 'gnus-article-treat
1019 :link '(custom-manual "(gnus)Customizing Articles")
1020 :type gnus-article-treat-head-custom)
1022 (defcustom gnus-treat-date-english nil
1023 "Display the Date in a format that can be read aloud in English.
1024 Valid values are nil, t, `head', `last', an integer or a predicate.
1025 See Info node `(gnus)Customizing Articles' for details."
1026 :group 'gnus-article-treat
1027 :link '(custom-manual "(gnus)Customizing Articles")
1028 :type gnus-article-treat-head-custom)
1030 (defcustom gnus-treat-date-lapsed nil
1031 "Display the Date header in a way that says how much time has elapsed.
1032 Valid values are nil, t, `head', `last', an integer or a predicate.
1033 See Info node `(gnus)Customizing Articles' for details."
1034 :group 'gnus-article-treat
1035 :link '(custom-manual "(gnus)Customizing Articles")
1036 :type gnus-article-treat-head-custom)
1038 (defcustom gnus-treat-date-original nil
1039 "Display the date in the original timezone.
1040 Valid values are nil, t, `head', `last', an integer or a predicate.
1041 See Info node `(gnus)Customizing Articles' for details."
1042 :group 'gnus-article-treat
1043 :link '(custom-manual "(gnus)Customizing Articles")
1044 :type gnus-article-treat-head-custom)
1046 (defcustom gnus-treat-date-iso8601 nil
1047 "Display the date in the ISO8601 format.
1048 Valid values are nil, t, `head', `last', an integer or a predicate.
1049 See Info node `(gnus)Customizing Articles' for details."
1051 :group 'gnus-article-treat
1052 :link '(custom-manual "(gnus)Customizing Articles")
1053 :type gnus-article-treat-head-custom)
1055 (defcustom gnus-treat-date-user-defined nil
1056 "Display the date in a user-defined format.
1057 The format is defined by the `gnus-article-time-format' variable.
1058 Valid values are nil, t, `head', `last', an integer or a predicate.
1059 See Info node `(gnus)Customizing Articles' for details."
1060 :group 'gnus-article-treat
1061 :link '(custom-manual "(gnus)Customizing Articles")
1062 :type gnus-article-treat-head-custom)
1064 (defcustom gnus-treat-strip-headers-in-body t
1065 "Strip the X-No-Archive header line from the beginning of the body.
1066 Valid values are nil, t, `head', `last', an integer or a predicate.
1067 See Info node `(gnus)Customizing Articles' for details."
1069 :group 'gnus-article-treat
1070 :link '(custom-manual "(gnus)Customizing Articles")
1071 :type gnus-article-treat-custom)
1073 (defcustom gnus-treat-strip-trailing-blank-lines nil
1074 "Strip trailing blank lines.
1075 Valid values are nil, t, `head', `last', an integer or a predicate.
1076 See Info node `(gnus)Customizing Articles' for details."
1077 :group 'gnus-article-treat
1078 :link '(custom-manual "(gnus)Customizing Articles")
1079 :type gnus-article-treat-custom)
1081 (defcustom gnus-treat-strip-leading-blank-lines nil
1082 "Strip leading blank lines.
1083 Valid values are nil, t, `head', `last', an integer or a predicate.
1084 See Info node `(gnus)Customizing Articles' for details."
1085 :group 'gnus-article-treat
1086 :link '(custom-manual "(gnus)Customizing Articles")
1087 :type gnus-article-treat-custom)
1089 (defcustom gnus-treat-strip-multiple-blank-lines nil
1090 "Strip multiple blank lines.
1091 Valid values are nil, t, `head', `last', an integer or a predicate.
1092 See Info node `(gnus)Customizing Articles' for details."
1093 :group 'gnus-article-treat
1094 :link '(custom-manual "(gnus)Customizing Articles")
1095 :type gnus-article-treat-custom)
1097 (defcustom gnus-treat-unfold-headers 'head
1098 "Unfold folded header lines.
1099 Valid values are nil, t, `head', `last', an integer or a predicate.
1100 See Info node `(gnus)Customizing Articles' for details."
1101 :group 'gnus-article-treat
1102 :link '(custom-manual "(gnus)Customizing Articles")
1103 :type gnus-article-treat-custom)
1105 (defcustom gnus-treat-fold-headers nil
1107 Valid values are nil, t, `head', `last', an integer or a predicate.
1108 See Info node `(gnus)Customizing Articles' for details."
1109 :group 'gnus-article-treat
1110 :link '(custom-manual "(gnus)Customizing Articles")
1111 :type gnus-article-treat-custom)
1113 (defcustom gnus-treat-fold-newsgroups 'head
1114 "Fold the Newsgroups and Followup-To headers.
1115 Valid values are nil, t, `head', `last', an integer or a predicate.
1116 See Info node `(gnus)Customizing Articles' for details."
1117 :group 'gnus-article-treat
1118 :link '(custom-manual "(gnus)Customizing Articles")
1119 :type gnus-article-treat-custom)
1121 (defcustom gnus-treat-overstrike t
1122 "Treat overstrike highlighting.
1123 Valid values are nil, t, `head', `last', an integer or a predicate.
1124 See Info node `(gnus)Customizing Articles' for details."
1125 :group 'gnus-article-treat
1126 :link '(custom-manual "(gnus)Customizing Articles")
1127 :type gnus-article-treat-custom)
1128 (put 'gnus-treat-overstrike 'highlight t)
1130 (defcustom gnus-treat-display-xface
1131 (and (not noninteractive)
1132 (or (and (fboundp 'image-type-available-p)
1133 (image-type-available-p 'xbm)
1134 (string-match "^0x" (shell-command-to-string "uncompface")))
1135 (and (featurep 'xemacs)
1138 "Display X-Face headers.
1139 Valid values are nil, t, `head', `last', an integer or a predicate.
1140 See Info node `(gnus)Customizing Articles' and Info node
1141 `(gnus)X-Face' for details."
1142 :group 'gnus-article-treat
1144 :link '(custom-manual "(gnus)Customizing Articles")
1145 :link '(custom-manual "(gnus)X-Face")
1146 :type gnus-article-treat-head-custom)
1147 (put 'gnus-treat-display-xface 'highlight t)
1149 (defcustom gnus-treat-display-grey-xface
1150 (and (not noninteractive)
1151 (string-match "^0x" (shell-command-to-string "uncompface"))
1153 "Display grey X-Face headers.
1154 Valid values are nil, t."
1155 :group 'gnus-article-treat
1158 (put 'gnus-treat-display-grey-xface 'highlight t)
1160 (defcustom gnus-treat-display-smileys
1161 (if (or (and (featurep 'xemacs)
1163 (and (fboundp 'image-type-available-p)
1164 (image-type-available-p 'pbm)))
1167 Valid values are nil, t, `head', `last', an integer or a predicate.
1168 See Info node `(gnus)Customizing Articles' and Info node
1169 `(gnus)Smileys' for details."
1170 :group 'gnus-article-treat
1172 :link '(custom-manual "(gnus)Customizing Articles")
1173 :link '(custom-manual "(gnus)Smileys")
1174 :type gnus-article-treat-custom)
1175 (put 'gnus-treat-display-smileys 'highlight t)
1177 (defcustom gnus-treat-from-picon
1178 (if (and (gnus-image-type-available-p 'xpm)
1179 (gnus-picons-installed-p))
1181 "Display picons in the From header.
1182 Valid values are nil, t, `head', `last', an integer or a predicate.
1183 See Info node `(gnus)Customizing Articles' and Info node
1184 `(gnus)Picons' for details."
1185 :group 'gnus-article-treat
1187 :link '(custom-manual "(gnus)Customizing Articles")
1188 :link '(custom-manual "(gnus)Picons")
1189 :type gnus-article-treat-head-custom)
1190 (put 'gnus-treat-from-picon 'highlight t)
1192 (defcustom gnus-treat-mail-picon
1193 (if (and (gnus-image-type-available-p 'xpm)
1194 (gnus-picons-installed-p))
1196 "Display picons in To and Cc headers.
1197 Valid values are nil, t, `head', `last', an integer or a predicate.
1198 See Info node `(gnus)Customizing Articles' and Info node
1199 `(gnus)Picons' for details."
1200 :group 'gnus-article-treat
1202 :link '(custom-manual "(gnus)Customizing Articles")
1203 :link '(custom-manual "(gnus)Picons")
1204 :type gnus-article-treat-head-custom)
1205 (put 'gnus-treat-mail-picon 'highlight t)
1207 (defcustom gnus-treat-newsgroups-picon
1208 (if (and (gnus-image-type-available-p 'xpm)
1209 (gnus-picons-installed-p))
1211 "Display picons in the Newsgroups and Followup-To headers.
1212 Valid values are nil, t, `head', `last', an integer or a predicate.
1213 See Info node `(gnus)Customizing Articles' and Info node
1214 `(gnus)Picons' for details."
1215 :group 'gnus-article-treat
1217 :link '(custom-manual "(gnus)Customizing Articles")
1218 :link '(custom-manual "(gnus)Picons")
1219 :type gnus-article-treat-head-custom)
1220 (put 'gnus-treat-newsgroups-picon 'highlight t)
1222 (defcustom gnus-treat-body-boundary
1223 (if (or gnus-treat-newsgroups-picon
1224 gnus-treat-mail-picon
1225 gnus-treat-from-picon)
1227 "Draw a boundary at the end of the headers.
1228 Valid values are nil, t, `head', `last', an integer or a predicate.
1229 See Info node `(gnus)Customizing Articles' for details."
1231 :group 'gnus-article-treat
1232 :link '(custom-manual "(gnus)Customizing Articles")
1233 :type gnus-article-treat-custom)
1235 (defcustom gnus-treat-capitalize-sentences nil
1236 "Capitalize sentence-starting words.
1237 Valid values are nil, t, `head', `last', an integer or a predicate.
1238 See Info node `(gnus)Customizing Articles' for details."
1240 :group 'gnus-article-treat
1241 :link '(custom-manual "(gnus)Customizing Articles")
1242 :type gnus-article-treat-custom)
1244 (defcustom gnus-treat-fill-long-lines nil
1246 Valid values are nil, t, `head', `last', an integer or a predicate.
1247 See Info node `(gnus)Customizing Articles' for details."
1248 :group 'gnus-article-treat
1249 :link '(custom-manual "(gnus)Customizing Articles")
1250 :type gnus-article-treat-custom)
1252 (defcustom gnus-treat-play-sounds nil
1254 Valid values are nil, t, `head', `last', an integer or a predicate.
1255 See Info node `(gnus)Customizing Articles' for details."
1257 :group 'gnus-article-treat
1258 :link '(custom-manual "(gnus)Customizing Articles")
1259 :type gnus-article-treat-custom)
1261 (defcustom gnus-treat-translate nil
1262 "Translate articles from one language to another.
1263 Valid values are nil, t, `head', `last', an integer or a predicate.
1264 See Info node `(gnus)Customizing Articles' for details."
1266 :group 'gnus-article-treat
1267 :link '(custom-manual "(gnus)Customizing Articles")
1268 :type gnus-article-treat-custom)
1270 (defcustom gnus-treat-x-pgp-sig nil
1272 To automatically treat X-PGP-Sig, set it to head.
1273 Valid values are nil, t, `head', `last', an integer or a predicate.
1274 See Info node `(gnus)Customizing Articles' for details."
1275 :group 'gnus-article-treat
1276 :group 'mime-security
1277 :link '(custom-manual "(gnus)Customizing Articles")
1278 :type gnus-article-treat-custom)
1280 (defvar gnus-article-encrypt-protocol-alist
1281 '(("PGP" . mml2015-self-encrypt)))
1283 ;; Set to nil if more than one protocol added to
1284 ;; gnus-article-encrypt-protocol-alist.
1285 (defcustom gnus-article-encrypt-protocol "PGP"
1286 "The protocol used for encrypt articles.
1287 It is a string, such as \"PGP\". If nil, ask user."
1289 :group 'mime-security)
1291 (defvar gnus-article-wash-function nil
1292 "Function used for converting HTML into text.")
1294 ;;; Internal variables
1296 (defvar gnus-english-month-names
1297 '("January" "February" "March" "April" "May" "June" "July" "August"
1298 "September" "October" "November" "December"))
1300 (defvar article-goto-body-goes-to-point-min-p nil)
1301 (defvar gnus-article-wash-types nil)
1302 (defvar gnus-article-emphasis-alist nil)
1303 (defvar gnus-article-image-alist nil)
1305 (defvar gnus-article-mime-handle-alist-1 nil)
1306 (defvar gnus-treatment-function-alist
1307 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1308 (gnus-treat-strip-banner gnus-article-strip-banner)
1309 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1310 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1311 (gnus-treat-buttonize gnus-article-add-buttons)
1312 (gnus-treat-fill-article gnus-article-fill-cited-article)
1313 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1314 (gnus-treat-strip-cr gnus-article-remove-cr)
1315 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1316 (gnus-treat-date-ut gnus-article-date-ut)
1317 (gnus-treat-date-local gnus-article-date-local)
1318 (gnus-treat-date-english gnus-article-date-english)
1319 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1320 (gnus-treat-date-original gnus-article-date-original)
1321 (gnus-treat-date-user-defined gnus-article-date-user)
1322 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1323 (gnus-treat-display-xface gnus-article-display-x-face)
1324 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1325 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1326 (gnus-treat-hide-signature gnus-article-hide-signature)
1327 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1328 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1329 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1330 (gnus-treat-strip-pem gnus-article-hide-pem)
1331 (gnus-treat-from-picon gnus-treat-from-picon)
1332 (gnus-treat-mail-picon gnus-treat-mail-picon)
1333 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1334 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1335 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1336 (gnus-treat-strip-trailing-blank-lines
1337 gnus-article-remove-trailing-blank-lines)
1338 (gnus-treat-strip-leading-blank-lines
1339 gnus-article-strip-leading-blank-lines)
1340 (gnus-treat-strip-multiple-blank-lines
1341 gnus-article-strip-multiple-blank-lines)
1342 (gnus-treat-overstrike gnus-article-treat-overstrike)
1343 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1344 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1345 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1346 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1347 (gnus-treat-display-smileys gnus-treat-smiley)
1348 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1349 (gnus-treat-emphasize gnus-article-emphasize)
1350 (gnus-treat-hide-citation gnus-article-hide-citation)
1351 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1352 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1353 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1354 (gnus-treat-play-sounds gnus-earcon-display)))
1356 (defvar gnus-article-mime-handle-alist nil)
1357 (defvar article-lapsed-timer nil)
1358 (defvar gnus-article-current-summary nil)
1360 (defvar gnus-article-mode-syntax-table
1361 (let ((table (copy-syntax-table text-mode-syntax-table)))
1362 ;; This causes the citation match run O(2^n).
1363 ;; (modify-syntax-entry ?- "w" table)
1364 (modify-syntax-entry ?> ")<" table)
1365 (modify-syntax-entry ?< "(>" table)
1366 ;; make M-. in article buffers work for `foo' strings
1367 (modify-syntax-entry ?' " " table)
1368 (modify-syntax-entry ?` " " table)
1370 "Syntax table used in article mode buffers.
1371 Initialized from `text-mode-syntax-table.")
1373 (defvar gnus-save-article-buffer nil)
1375 (defvar gnus-article-mode-line-format-alist
1376 (nconc '((?w (gnus-article-wash-status) ?s)
1377 (?m (gnus-article-mime-part-status) ?s))
1378 gnus-summary-mode-line-format-alist))
1380 (defvar gnus-number-of-articles-to-be-saved nil)
1382 (defvar gnus-inhibit-hiding nil)
1384 ;;; Macros for dealing with the article buffer.
1386 (defmacro gnus-with-article-headers (&rest forms)
1388 (set-buffer gnus-article-buffer)
1390 (let ((buffer-read-only nil)
1391 (inhibit-point-motion-hooks t)
1392 (case-fold-search t))
1393 (article-narrow-to-head)
1396 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1397 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1399 (defmacro gnus-with-article-buffer (&rest forms)
1401 (set-buffer gnus-article-buffer)
1402 (let ((buffer-read-only nil))
1405 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1406 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1408 (defun gnus-article-goto-header (header)
1409 "Go to HEADER, which is a regular expression."
1410 (re-search-forward (concat "^\\(" header "\\):") nil t))
1412 (defsubst gnus-article-hide-text (b e props)
1413 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1414 (gnus-add-text-properties-when 'article-type nil b e props)
1415 (when (memq 'intangible props)
1417 (max (1- b) (point-min))
1418 b 'intangible (cddr (memq 'intangible props)))))
1420 (defsubst gnus-article-unhide-text (b e)
1421 "Remove hidden text properties from region between B and E."
1422 (remove-text-properties b e gnus-hidden-properties)
1423 (when (memq 'intangible gnus-hidden-properties)
1424 (put-text-property (max (1- b) (point-min))
1425 b 'intangible nil)))
1427 (defun gnus-article-hide-text-type (b e type)
1428 "Hide text of TYPE between B and E."
1429 (gnus-add-wash-type type)
1430 (gnus-article-hide-text
1431 b e (cons 'article-type (cons type gnus-hidden-properties))))
1433 (defun gnus-article-unhide-text-type (b e type)
1434 "Unhide text of TYPE between B and E."
1435 (gnus-delete-wash-type type)
1436 (remove-text-properties
1437 b e (cons 'article-type (cons type gnus-hidden-properties)))
1438 (when (memq 'intangible gnus-hidden-properties)
1439 (put-text-property (max (1- b) (point-min))
1440 b 'intangible nil)))
1442 (defun gnus-article-hide-text-of-type (type)
1443 "Hide text of TYPE in the current buffer."
1445 (let ((b (point-min))
1447 (while (setq b (text-property-any b e 'article-type type))
1448 (add-text-properties b (incf b) gnus-hidden-properties)))))
1450 (defun gnus-article-delete-text-of-type (type)
1451 "Delete text of TYPE in the current buffer."
1453 (let ((b (point-min)))
1454 (while (setq b (text-property-any b (point-max) 'article-type type))
1456 b (or (text-property-not-all b (point-max) 'article-type type)
1459 (defun gnus-article-delete-invisible-text ()
1460 "Delete all invisible text in the current buffer."
1462 (let ((b (point-min)))
1463 (while (setq b (text-property-any b (point-max) 'invisible t))
1465 b (or (text-property-not-all b (point-max) 'invisible t)
1468 (defun gnus-article-text-type-exists-p (type)
1469 "Say whether any text of type TYPE exists in the buffer."
1470 (text-property-any (point-min) (point-max) 'article-type type))
1472 (defsubst gnus-article-header-rank ()
1473 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1474 (let ((list gnus-sorted-header-list)
1477 (if (looking-at (car list))
1479 (setq list (cdr list))
1483 (defun article-hide-headers (&optional arg delete)
1484 "Hide unwanted headers and possibly sort them as well."
1486 ;; This function might be inhibited.
1487 (unless gnus-inhibit-hiding
1490 (let ((buffer-read-only nil)
1491 (case-fold-search t)
1492 (max (1+ (length gnus-sorted-header-list)))
1493 (ignored (when (not gnus-visible-headers)
1494 (cond ((stringp gnus-ignored-headers)
1495 gnus-ignored-headers)
1496 ((listp gnus-ignored-headers)
1497 (mapconcat 'identity gnus-ignored-headers
1500 (cond ((stringp gnus-visible-headers)
1501 gnus-visible-headers)
1502 ((and gnus-visible-headers
1503 (listp gnus-visible-headers))
1504 (mapconcat 'identity gnus-visible-headers "\\|"))))
1505 (inhibit-point-motion-hooks t)
1507 ;; First we narrow to just the headers.
1508 (article-narrow-to-head)
1509 ;; Hide any "From " lines at the beginning of (mail) articles.
1510 (while (looking-at "From ")
1513 (delete-region (point-min) (point)))
1514 ;; Then treat the rest of the header lines.
1515 ;; Then we use the two regular expressions
1516 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1517 ;; select which header lines is to remain visible in the
1519 (while (re-search-forward "^[^ \t:]*:" nil t)
1521 ;; Mark the rank of the header.
1523 (point) (1+ (point)) 'message-rank
1524 (if (or (and visible (looking-at visible))
1526 (not (looking-at ignored))))
1527 (gnus-article-header-rank)
1530 (message-sort-headers-1)
1531 (when (setq beg (text-property-any
1532 (point-min) (point-max) 'message-rank (+ 2 max)))
1533 ;; We delete the unwanted headers.
1534 (gnus-add-wash-type 'headers)
1535 (add-text-properties (point-min) (+ 5 (point-min))
1536 '(article-type headers dummy-invisible t))
1537 (delete-region beg (point-max))))))))
1539 (defun article-hide-boring-headers (&optional arg)
1540 "Toggle hiding of headers that aren't very interesting.
1541 If given a negative prefix, always show; if given a positive prefix,
1543 (interactive (gnus-article-hidden-arg))
1544 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1545 (not gnus-show-all-headers))
1548 (let ((buffer-read-only nil)
1549 (list gnus-boring-article-headers)
1550 (inhibit-point-motion-hooks t)
1552 (article-narrow-to-head)
1554 (setq elem (pop list))
1555 (goto-char (point-min))
1557 ;; Hide empty headers.
1559 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1561 (gnus-article-hide-text-type
1562 (progn (beginning-of-line) (point))
1565 (if (re-search-forward "^[^ \t]" nil t)
1569 ;; Hide boring Newsgroups header.
1570 ((eq elem 'newsgroups)
1571 (when (gnus-string-equal
1572 (gnus-fetch-field "newsgroups")
1573 (gnus-group-real-name
1574 (if (boundp 'gnus-newsgroup-name)
1577 (gnus-article-hide-header "newsgroups")))
1578 ((eq elem 'to-address)
1579 (let ((to (message-fetch-field "to"))
1581 (gnus-parameter-to-address
1582 (if (boundp 'gnus-newsgroup-name)
1583 gnus-newsgroup-name ""))))
1584 (when (and to to-address
1587 ;; only one address in To
1588 (nth 1 (mail-extract-address-components to))
1590 (gnus-article-hide-header "to"))))
1591 ((eq elem 'followup-to)
1592 (when (gnus-string-equal
1593 (message-fetch-field "followup-to")
1594 (message-fetch-field "newsgroups"))
1595 (gnus-article-hide-header "followup-to")))
1596 ((eq elem 'reply-to)
1597 (let ((from (message-fetch-field "from"))
1598 (reply-to (message-fetch-field "reply-to")))
1603 (nth 1 (mail-extract-address-components from))
1604 (nth 1 (mail-extract-address-components reply-to)))))
1605 (gnus-article-hide-header "reply-to"))))
1607 (let ((date (message-fetch-field "date")))
1609 (< (days-between (current-time-string) date)
1611 (gnus-article-hide-header "date"))))
1613 (let ((to (message-fetch-field "to"))
1614 (cc (message-fetch-field "cc")))
1615 (when (> (length to) 1024)
1616 (gnus-article-hide-header "to"))
1617 (when (> (length cc) 1024)
1618 (gnus-article-hide-header "cc"))))
1622 (goto-char (point-min))
1623 (while (re-search-forward "^to:" nil t)
1624 (setq to-count (1+ to-count)))
1625 (when (> to-count 1)
1626 (while (> to-count 0)
1627 (goto-char (point-min))
1629 (re-search-forward "^to:" nil nil to-count)
1631 (narrow-to-region (point) (point-max))
1632 (gnus-article-hide-header "to"))
1633 (setq to-count (1- to-count))))
1634 (goto-char (point-min))
1635 (while (re-search-forward "^cc:" nil t)
1636 (setq cc-count (1+ cc-count)))
1637 (when (> cc-count 1)
1638 (while (> cc-count 0)
1639 (goto-char (point-min))
1641 (re-search-forward "^cc:" nil nil cc-count)
1643 (narrow-to-region (point) (point-max))
1644 (gnus-article-hide-header "cc"))
1645 (setq cc-count (1- cc-count)))))))))))))
1647 (defun gnus-article-hide-header (header)
1649 (goto-char (point-min))
1650 (when (re-search-forward (concat "^" header ":") nil t)
1651 (gnus-article-hide-text-type
1652 (progn (beginning-of-line) (point))
1655 (if (re-search-forward "^[^ \t]" nil t)
1660 (defvar gnus-article-normalized-header-length 40
1661 "Length of normalized headers.")
1663 (defun article-normalize-headers ()
1664 "Make all header lines 40 characters long."
1666 (let ((buffer-read-only nil)
1670 (article-narrow-to-head)
1673 ((< (setq column (- (gnus-point-at-eol) (point)))
1674 gnus-article-normalized-header-length)
1676 (insert (make-string
1677 (- gnus-article-normalized-header-length column)
1679 ((> column gnus-article-normalized-header-length)
1680 (gnus-put-text-property
1682 (forward-char gnus-article-normalized-header-length)
1689 (forward-line 1))))))
1691 (defun article-treat-dumbquotes ()
1692 "Translate M****s*** sm*rtq**t*s into proper text.
1693 Note that this function guesses whether a character is a sm*rtq**t* or
1694 not, so it should only be used interactively.
1696 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1697 in an attempt to provide more quoting characters. If you see
1698 something like \\222 or \\264 where you're expecting some kind of
1699 apostrophe or quotation mark, then try this wash."
1701 (article-translate-strings gnus-article-dumbquotes-map))
1703 (defun article-translate-characters (from to)
1704 "Translate all characters in the body of the article according to FROM and TO.
1705 FROM is a string of characters to translate from; to is a string of
1706 characters to translate to."
1708 (when (article-goto-body)
1709 (let ((buffer-read-only nil)
1710 (x (make-string 225 ?x))
1712 (while (< (incf i) (length x))
1715 (while (< i (length from))
1716 (aset x (aref from i) (aref to i))
1718 (translate-region (point) (point-max) x)))))
1720 (defun article-translate-strings (map)
1721 "Translate all string in the body of the article according to MAP.
1722 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1724 (when (article-goto-body)
1725 (let ((buffer-read-only nil)
1727 (while (setq elem (pop map))
1729 (while (search-forward (car elem) nil t)
1730 (replace-match (cadr elem)))))))))
1732 (defun article-treat-overstrike ()
1733 "Translate overstrikes into bold text."
1736 (when (article-goto-body)
1737 (let ((buffer-read-only nil))
1738 (while (search-forward "\b" nil t)
1739 (let ((next (char-after))
1740 (previous (char-after (- (point) 2))))
1741 ;; We do the boldification/underlining by hiding the
1742 ;; overstrikes and putting the proper text property
1746 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1747 (put-text-property (point) (1+ (point)) 'face 'bold))
1749 (gnus-article-hide-text-type
1750 (1- (point)) (1+ (point)) 'overstrike)
1752 (- (point) 2) (1- (point)) 'face 'underline))
1754 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1756 (point) (1+ (point)) 'face 'underline)))))))))
1758 (defun gnus-article-treat-unfold-headers ()
1759 "Unfold folded message headers.
1760 Only the headers that fit into the current window width will be
1763 (gnus-with-article-headers
1767 (mail-header-narrow-to-field)
1768 (let ((header (buffer-substring (point-min) (point-max))))
1771 (goto-char (point-min))
1772 (while (re-search-forward "\n[\t ]" nil t)
1773 (replace-match " " t t)))
1774 (setq length (- (point-max) (point-min) 1)))
1775 (when (< length (window-width))
1776 (while (re-search-forward "\n[\t ]" nil t)
1777 (replace-match " " t t)))
1778 (goto-char (point-max)))))))
1780 (defun gnus-article-treat-fold-headers ()
1781 "Fold message headers."
1783 (gnus-with-article-headers
1786 (mail-header-narrow-to-field)
1787 (mail-header-fold-field)
1788 (goto-char (point-max))))))
1790 (defun gnus-treat-smiley ()
1791 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1793 (gnus-with-article-buffer
1794 (if (memq 'smiley gnus-article-wash-types)
1795 (gnus-delete-images 'smiley)
1797 (let ((images (smiley-region (point) (point-max))))
1799 (gnus-add-wash-type 'smiley)
1800 (dolist (image images)
1801 (gnus-add-image 'smiley image)))))))
1803 (defun gnus-article-remove-images ()
1804 "Remove all images from the article buffer."
1806 (gnus-with-article-buffer
1807 (dolist (elem gnus-article-image-alist)
1808 (gnus-delete-images (car elem)))))
1810 (defun gnus-article-treat-fold-newsgroups ()
1811 "Unfold folded message headers.
1812 Only the headers that fit into the current window width will be
1815 (gnus-with-article-headers
1816 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1818 (mail-header-narrow-to-field)
1819 (while (re-search-forward ", *" nil t)
1820 (replace-match ", " t t))
1821 (mail-header-fold-field)
1822 (goto-char (point-max))))))
1824 (defun gnus-article-treat-body-boundary ()
1825 "Place a boundary line at the end of the headers."
1827 (when (and gnus-body-boundary-delimiter
1828 (> (length gnus-body-boundary-delimiter) 0))
1829 (gnus-with-article-headers
1830 (goto-char (point-max))
1831 (let ((start (point)))
1832 (insert "X-Boundary: ")
1833 (gnus-add-text-properties start (point) '(invisible t intangible t))
1835 (while (>= (1- (window-width)) (length str))
1836 (setq str (concat str gnus-body-boundary-delimiter)))
1837 (substring str 0 (1- (window-width))))
1839 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1841 (defun article-fill-long-lines ()
1842 "Fill lines that are wider than the window width."
1845 (let ((buffer-read-only nil)
1846 (width (window-width (get-buffer-window (current-buffer)))))
1849 (let ((adaptive-fill-mode nil)) ;Why? -sm
1852 (when (>= (current-column) (min fill-column width))
1853 (narrow-to-region (min (1+ (point)) (point-max)) (gnus-point-at-bol))
1854 (let ((goback (point-marker)))
1855 (fill-paragraph nil)
1856 (goto-char (marker-position goback)))
1858 (forward-line 1)))))))
1860 (defun article-capitalize-sentences ()
1861 "Capitalize the first word in each sentence."
1864 (let ((buffer-read-only nil)
1865 (paragraph-start "^[\n\^L]"))
1869 (forward-sentence)))))
1871 (defun article-remove-cr ()
1872 "Remove trailing CRs and then translate remaining CRs into LFs."
1875 (let ((buffer-read-only nil))
1876 (goto-char (point-min))
1877 (while (re-search-forward "\r+$" nil t)
1878 (replace-match "" t t))
1879 (goto-char (point-min))
1880 (while (search-forward "\r" nil t)
1881 (replace-match "\n" t t)))))
1883 (defun article-remove-trailing-blank-lines ()
1884 "Remove all trailing blank lines from the article."
1887 (let ((buffer-read-only nil))
1888 (goto-char (point-max))
1892 (while (and (not (bobp))
1893 (looking-at "^[ \t]*$")
1894 (not (gnus-annotation-in-region-p
1895 (point) (gnus-point-at-eol))))
1900 (defun article-display-x-face (&optional force)
1901 "Look for an X-Face header and display it if present."
1902 (interactive (list 'force))
1903 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1904 (gnus-with-article-headers
1905 ;; Delete the old process, if any.
1906 (when (process-status "article-x-face")
1907 (delete-process "article-x-face"))
1908 (if (memq 'xface gnus-article-wash-types)
1909 ;; We have already displayed X-Faces, so we remove them
1911 (gnus-delete-images 'xface)
1913 (let (x-faces from face grey)
1915 (when (and wash-face-p
1917 (goto-char (point-min))
1918 (not (re-search-forward
1919 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
1920 (gnus-buffer-live-p gnus-original-article-buffer))
1921 ;; If type `W f', use gnus-original-article-buffer,
1922 ;; otherwise use the current buffer because displaying
1923 ;; RFC822 parts calls this function too.
1924 (set-buffer gnus-original-article-buffer))
1926 (mail-narrow-to-head)
1927 (if gnus-treat-display-grey-xface
1929 (while (gnus-article-goto-header "X-Face\\(-[0-9]+\\)?")
1930 (if (match-beginning 2)
1933 (push (cons (- (string-to-number (match-string 2)))
1934 (mail-header-field-value))
1936 (push (cons 0 (mail-header-field-value)) x-faces)))
1937 (dolist (x-face (prog1
1939 (sort x-faces 'car-less-than-car)
1941 (setq x-faces nil)))
1942 (push (cdr x-face) x-faces)))
1943 (while (gnus-article-goto-header "X-Face")
1944 (push (mail-header-field-value) x-faces)))
1945 (setq from (message-fetch-field "from"))))
1947 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
1950 (setq image (gnus-create-image xpm 'xpm t))
1951 (gnus-article-goto-header "from")
1953 (insert "From: [no `from' set]\n")
1955 (gnus-add-wash-type 'xface)
1956 (gnus-add-image 'xface image)
1957 (gnus-put-image image)))
1958 ;; Sending multiple EOFs to xv doesn't work, so we only do a
1959 ;; single external face.
1960 (when (stringp gnus-article-x-face-command)
1961 (setq x-faces (list (car x-faces))))
1962 (while (and (setq face (pop x-faces))
1963 gnus-article-x-face-command
1965 ;; Check whether this face is censored.
1966 (not gnus-article-x-face-too-ugly)
1967 (and gnus-article-x-face-too-ugly from
1968 (not (string-match gnus-article-x-face-too-ugly
1970 ;; We display the face.
1971 (if (symbolp gnus-article-x-face-command)
1972 ;; The command is a lisp function, so we call it.
1973 (if (gnus-functionp gnus-article-x-face-command)
1974 (funcall gnus-article-x-face-command face)
1975 (error "%s is not a function" gnus-article-x-face-command))
1976 ;; The command is a string, so we interpret the command
1977 ;; as a, well, command, and fork it off.
1978 (let ((process-connection-type nil))
1979 (process-kill-without-query
1981 "article-x-face" nil shell-file-name shell-command-switch
1982 gnus-article-x-face-command))
1985 (process-send-region "article-x-face"
1986 (point-min) (point-max)))
1987 (process-send-eof "article-x-face"))))))))))
1989 (defun article-decode-mime-words ()
1990 "Decode all MIME-encoded words in the article."
1993 (set-buffer gnus-article-buffer)
1994 (let ((inhibit-point-motion-hooks t)
1996 (mail-parse-charset gnus-newsgroup-charset)
1997 (mail-parse-ignored-charsets
1998 (save-excursion (set-buffer gnus-summary-buffer)
1999 gnus-newsgroup-ignored-charsets)))
2000 (mail-decode-encoded-word-region (point-min) (point-max)))))
2002 (defun article-decode-charset (&optional prompt)
2003 "Decode charset-encoded text in the article.
2004 If PROMPT (the prefix), prompt for a coding system to use."
2006 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2008 (mail-parse-charset gnus-newsgroup-charset)
2009 (mail-parse-ignored-charsets
2010 (save-excursion (condition-case nil
2011 (set-buffer gnus-summary-buffer)
2013 gnus-newsgroup-ignored-charsets))
2014 ct cte ctl charset format)
2017 (article-narrow-to-head)
2018 (setq ct (message-fetch-field "Content-Type" t)
2019 cte (message-fetch-field "Content-Transfer-Encoding" t)
2020 ctl (and ct (ignore-errors
2021 (mail-header-parse-content-type ct)))
2024 (mm-read-coding-system "Charset to decode: "))
2026 (mail-content-type-get ctl 'charset)))
2027 format (and ctl (mail-content-type-get ctl 'format)))
2029 (setq cte (mail-header-strip cte)))
2030 (if (and ctl (not (string-match "/" (car ctl))))
2032 (goto-char (point-max)))
2035 (narrow-to-region (point) (point-max))
2036 (when (and (eq mail-parse-charset 'gnus-decoded)
2037 (eq (mm-body-7-or-8) '8bit))
2038 ;; The text code could have been decoded.
2039 (setq charset mail-parse-charset))
2040 (when (and (or (not ctl)
2041 (equal (car ctl) "text/plain"))
2042 (not format)) ;; article with format will decode later.
2044 charset (and cte (intern (downcase
2045 (gnus-strip-whitespace cte))))
2048 (defun article-decode-encoded-words ()
2049 "Remove encoded-word encoding from headers."
2050 (let ((inhibit-point-motion-hooks t)
2051 (mail-parse-charset gnus-newsgroup-charset)
2052 (mail-parse-ignored-charsets
2053 (save-excursion (condition-case nil
2054 (set-buffer gnus-summary-buffer)
2056 gnus-newsgroup-ignored-charsets))
2059 (article-narrow-to-head)
2060 (funcall gnus-decode-header-function (point-min) (point-max)))))
2062 (defun article-decode-group-name ()
2063 "Decode group names in `Newsgroups:'."
2064 (let ((inhibit-point-motion-hooks t)
2066 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2067 (when (and (or gnus-group-name-charset-method-alist
2068 gnus-group-name-charset-group-alist)
2069 (gnus-buffer-live-p gnus-original-article-buffer))
2070 (when (nnmail-fetch-field "Newsgroups")
2071 (nnheader-replace-header "Newsgroups"
2072 (gnus-decode-newsgroups
2073 (with-current-buffer
2074 gnus-original-article-buffer
2075 (nnmail-fetch-field "Newsgroups"))
2076 gnus-newsgroup-name method)))
2077 (when (nnmail-fetch-field "Followup-To")
2078 (nnheader-replace-header "Followup-To"
2079 (gnus-decode-newsgroups
2080 (with-current-buffer
2081 gnus-original-article-buffer
2082 (nnmail-fetch-field "Followup-To"))
2083 gnus-newsgroup-name method))))))
2085 (defun article-de-quoted-unreadable (&optional force read-charset)
2086 "Translate a quoted-printable-encoded article.
2087 If FORCE, decode the article whether it is marked as quoted-printable
2089 If READ-CHARSET, ask for a coding system."
2090 (interactive (list 'force current-prefix-arg))
2092 (let ((buffer-read-only nil) type charset)
2093 (if (gnus-buffer-live-p gnus-original-article-buffer)
2094 (with-current-buffer gnus-original-article-buffer
2096 (gnus-fetch-field "content-transfer-encoding"))
2097 (let* ((ct (gnus-fetch-field "content-type"))
2100 (mail-header-parse-content-type ct)))))
2101 (setq charset (and ctl
2102 (mail-content-type-get ctl 'charset)))
2103 (if (stringp charset)
2104 (setq charset (intern (downcase charset)))))))
2106 (setq charset (mm-read-coding-system "Charset: " charset)))
2108 (setq charset gnus-newsgroup-charset))
2110 (and type (let ((case-fold-search t))
2111 (string-match "quoted-printable" type))))
2113 (quoted-printable-decode-region
2114 (point) (point-max) (mm-charset-to-coding-system charset))))))
2116 (defun article-de-base64-unreadable (&optional force read-charset)
2117 "Translate a base64 article.
2118 If FORCE, decode the article whether it is marked as base64 not.
2119 If READ-CHARSET, ask for a coding system."
2120 (interactive (list 'force current-prefix-arg))
2122 (let ((buffer-read-only nil) type charset)
2123 (if (gnus-buffer-live-p gnus-original-article-buffer)
2124 (with-current-buffer gnus-original-article-buffer
2126 (gnus-fetch-field "content-transfer-encoding"))
2127 (let* ((ct (gnus-fetch-field "content-type"))
2130 (mail-header-parse-content-type ct)))))
2131 (setq charset (and ctl
2132 (mail-content-type-get ctl 'charset)))
2133 (if (stringp charset)
2134 (setq charset (intern (downcase charset)))))))
2136 (setq charset (mm-read-coding-system "Charset: " charset)))
2138 (setq charset gnus-newsgroup-charset))
2140 (and type (let ((case-fold-search t))
2141 (string-match "base64" type))))
2144 (narrow-to-region (point) (point-max))
2145 (base64-decode-region (point-min) (point-max))
2146 (mm-decode-coding-region
2147 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2152 (defun article-decode-HZ ()
2153 "Translate a HZ-encoded article."
2157 (let ((buffer-read-only nil))
2158 (rfc1843-decode-region (point-min) (point-max)))))
2160 (defun article-unsplit-urls ()
2161 "Remove the newlines that some other mailers insert into URLs."
2164 (let ((buffer-read-only nil))
2165 (goto-char (point-min))
2166 (while (re-search-forward
2167 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2168 (replace-match "\\1\\3" t)))
2169 (when (and gnus-display-mime-function (interactive-p))
2170 (funcall gnus-display-mime-function))))
2173 (defun article-wash-html (&optional read-charset)
2174 "Format an html article.
2175 If READ-CHARSET, ask for a coding system."
2178 (let ((buffer-read-only nil)
2180 (if (gnus-buffer-live-p gnus-original-article-buffer)
2181 (with-current-buffer gnus-original-article-buffer
2182 (let* ((ct (gnus-fetch-field "content-type"))
2185 (mail-header-parse-content-type ct)))))
2186 (setq charset (and ctl
2187 (mail-content-type-get ctl 'charset)))
2188 (if (stringp charset)
2189 (setq charset (intern (downcase charset)))))))
2191 (setq charset (mm-read-coding-system "Charset: " charset)))
2193 (setq charset gnus-newsgroup-charset))
2195 (save-window-excursion
2197 (narrow-to-region (point) (point-max))
2198 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2199 (entry (assq func mm-text-html-washer-alist)))
2201 (setq func (cdr entry)))
2203 ((gnus-functionp func)
2206 (apply (car func) (cdr func))))))))))
2208 (defun gnus-article-wash-html-with-w3 ()
2209 "Wash the current buffer with w3."
2211 (let ((w3-strict-width (window-width))
2212 (url-standalone-mode t)
2213 (url-gateway-unplugged t)
2214 (w3-honor-stylesheets nil))
2216 (w3-region (point-min) (point-max))
2219 (defun gnus-article-wash-html-with-w3m ()
2220 "Wash the current buffer with emacs-w3m."
2223 (narrow-to-region (point) (point-max))
2224 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2227 (w3m-display-inline-images mm-inline-text-html-with-images)
2228 w3m-force-redisplay)
2229 (w3m-region (point-min) (point-max)))
2230 (when mm-inline-text-html-with-w3m-keymap
2231 (add-text-properties
2232 (point-min) (point-max)
2233 (nconc (mm-w3m-local-map-property)
2234 '(mm-inline-text-html-with-w3m t))))))
2236 (defun article-hide-list-identifiers ()
2237 "Remove list identifies from the Subject header.
2238 The `gnus-list-identifiers' variable specifies what to do."
2240 (let ((inhibit-point-motion-hooks t)
2241 (regexp (if (consp gnus-list-identifiers)
2242 (mapconcat 'identity gnus-list-identifiers " *\\|")
2243 gnus-list-identifiers))
2248 (article-narrow-to-head)
2249 (goto-char (point-min))
2250 (while (re-search-forward
2251 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2253 (delete-region (match-beginning 2) (match-end 0))
2254 (beginning-of-line))
2255 (when (re-search-forward
2256 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2257 (delete-region (match-beginning 1) (match-end 1))))))))
2259 (defun article-hide-pgp ()
2260 "Remove any PGP headers and signatures in the current article."
2264 (let ((inhibit-point-motion-hooks t)
2265 buffer-read-only beg end)
2267 ;; Hide the "header".
2268 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2269 (gnus-add-wash-type 'pgp)
2270 (delete-region (match-beginning 0) (match-end 0))
2271 ;; Remove armor headers (rfc2440 6.2)
2272 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2275 ;; Hide the actual signature.
2276 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2277 (setq end (1+ (match-beginning 0)))
2280 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2282 ;; Perhaps we shouldn't hide to the end of the buffer
2283 ;; if there is no end to the signature?
2285 ;; Hide "- " PGP quotation markers.
2287 (narrow-to-region beg end)
2288 (goto-char (point-min))
2289 (while (re-search-forward "^- " nil t)
2291 (match-beginning 0) (match-end 0)))
2293 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2295 (defun article-hide-pem (&optional arg)
2296 "Toggle hiding of any PEM headers and signatures in the current article.
2297 If given a negative prefix, always show; if given a positive prefix,
2299 (interactive (gnus-article-hidden-arg))
2300 (unless (gnus-article-check-hidden-text 'pem arg)
2302 (let (buffer-read-only end)
2303 (goto-char (point-min))
2304 ;; Hide the horrendously ugly "header".
2305 (when (and (search-forward
2306 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2308 (setq end (1+ (match-beginning 0))))
2309 (gnus-add-wash-type 'pem)
2310 (gnus-article-hide-text-type
2312 (if (search-forward "\n\n" nil t)
2316 ;; Hide the trailer as well
2317 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2319 (gnus-article-hide-text-type
2320 (match-beginning 0) (match-end 0) 'pem)))))))
2322 (defun article-strip-banner ()
2323 "Strip the banner specified by the `banner' group parameter."
2327 (let ((inhibit-point-motion-hooks t)
2328 (banner (gnus-parameter-banner gnus-newsgroup-name))
2329 (gnus-signature-limit nil)
2330 buffer-read-only beg end)
2331 (when (and gnus-article-address-banner-alist
2334 (let ((from (save-restriction
2336 (article-narrow-to-head)
2337 (mail-fetch-field "from"))))
2340 (caar (mail-header-parse-addresses from))))
2342 (dolist (pair gnus-article-address-banner-alist)
2343 (when (string-match (car pair) from)
2344 (throw 'found (cdr pair)))))))))
2348 ((eq banner 'signature)
2349 (when (gnus-article-narrow-to-signature)
2352 (delete-region (point) (point-max))))
2354 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2355 (while (re-search-forward banner nil t)
2356 (delete-region (match-beginning 0) (match-end 0)))))
2358 (while (re-search-forward banner nil t)
2359 (delete-region (match-beginning 0) (match-end 0))))))))))
2361 (defun article-babel ()
2362 "Translate article using an online translation service."
2366 (set-buffer gnus-article-buffer)
2367 (when (article-goto-body)
2368 (let* ((buffer-read-only nil)
2371 (orig (buffer-substring start end))
2372 (trans (babel-as-string orig)))
2374 (narrow-to-region start end)
2375 (delete-region start end)
2378 (defun article-hide-signature (&optional arg)
2379 "Hide the signature in the current article.
2380 If given a negative prefix, always show; if given a positive prefix,
2382 (interactive (gnus-article-hidden-arg))
2383 (unless (gnus-article-check-hidden-text 'signature arg)
2386 (let ((buffer-read-only nil))
2387 (when (gnus-article-narrow-to-signature)
2388 (gnus-article-hide-text-type
2389 (point-min) (point-max) 'signature))))))
2390 (gnus-set-mode-line 'article))
2392 (defun article-strip-headers-in-body ()
2393 "Strip offensive headers from bodies."
2397 (let ((case-fold-search t))
2398 (when (looking-at "x-no-archive:")
2399 (gnus-delete-line)))))
2401 (defun article-strip-leading-blank-lines ()
2402 "Remove all blank lines from the beginning of the article."
2405 (let ((inhibit-point-motion-hooks t)
2407 (when (article-goto-body)
2408 (while (and (not (eobp))
2409 (looking-at "[ \t]*$"))
2410 (gnus-delete-line))))))
2412 (defun article-narrow-to-head ()
2413 "Narrow the buffer to the head of the message.
2414 Point is left at the beginning of the narrowed-to region."
2416 (goto-char (point-min))
2417 (if (search-forward "\n\n" nil 1)
2420 (goto-char (point-min)))
2422 (defun article-goto-body ()
2423 "Place point at the start of the body."
2424 (goto-char (point-min))
2426 ;; This variable is only bound when dealing with separate
2428 (article-goto-body-goes-to-point-min-p
2430 ((search-forward "\n\n" nil t)
2433 (goto-char (point-max))
2436 (defun article-strip-multiple-blank-lines ()
2437 "Replace consecutive blank lines with one empty line."
2440 (let ((inhibit-point-motion-hooks t)
2442 ;; First make all blank lines empty.
2444 (while (re-search-forward "^[ \t]+$" nil t)
2445 (unless (gnus-annotation-in-region-p
2446 (match-beginning 0) (match-end 0))
2447 (replace-match "" nil t)))
2448 ;; Then replace multiple empty lines with a single empty line.
2450 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2451 (unless (gnus-annotation-in-region-p
2452 (match-beginning 0) (match-end 0))
2453 (delete-region (match-beginning 1) (match-end 1)))))))
2455 (defun article-strip-leading-space ()
2456 "Remove all white space from the beginning of the lines in the article."
2459 (let ((inhibit-point-motion-hooks t)
2462 (while (re-search-forward "^[ \t]+" nil t)
2463 (replace-match "" t t)))))
2465 (defun article-strip-trailing-space ()
2466 "Remove all white space from the end of the lines in the article."
2469 (let ((inhibit-point-motion-hooks t)
2472 (while (re-search-forward "[ \t]+$" nil t)
2473 (replace-match "" t t)))))
2475 (defun article-strip-blank-lines ()
2476 "Strip leading, trailing and multiple blank lines."
2478 (article-strip-leading-blank-lines)
2479 (article-remove-trailing-blank-lines)
2480 (article-strip-multiple-blank-lines))
2482 (defun article-strip-all-blank-lines ()
2483 "Strip all blank lines."
2486 (let ((inhibit-point-motion-hooks t)
2489 (while (re-search-forward "^[ \t]*\n" nil t)
2490 (replace-match "" t t)))))
2492 (defun gnus-article-narrow-to-signature ()
2493 "Narrow to the signature; return t if a signature is found, else nil."
2494 (let ((inhibit-point-motion-hooks t))
2495 (when (gnus-article-search-signature)
2497 ;; Check whether we have some limits to what we consider
2498 ;; to be a signature.
2499 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2500 (list gnus-signature-limit)))
2502 (while (setq limit (pop limits))
2503 (if (or (and (integerp limit)
2504 (< (- (point-max) (point)) limit))
2506 (< (count-lines (point) (point-max)) limit))
2507 (and (gnus-functionp limit)
2509 (and (stringp limit)
2510 (not (re-search-forward limit nil t))))
2511 () ; This limit did not succeed.
2515 (narrow-to-region (point) (point-max))
2518 (defun gnus-article-search-signature ()
2519 "Search the current buffer for the signature separator.
2520 Put point at the beginning of the signature separator."
2521 (let ((cur (point)))
2522 (goto-char (point-max))
2523 (if (if (stringp gnus-signature-separator)
2524 (re-search-backward gnus-signature-separator nil t)
2525 (let ((seps gnus-signature-separator))
2527 (not (re-search-backward (car seps) nil t)))
2534 (defun gnus-article-hidden-arg ()
2535 "Return the current prefix arg as a number, or 0 if no prefix."
2536 (list (if current-prefix-arg
2537 (prefix-numeric-value current-prefix-arg)
2540 (defun gnus-article-check-hidden-text (type arg)
2541 "Return nil if hiding is necessary.
2542 Arg can be nil or a number. nil and positive means hide, negative
2543 means show, 0 means toggle."
2546 (let ((hide (gnus-article-hidden-text-p type)))
2552 (gnus-article-show-hidden-text type)
2555 (if (eq hide 'hidden)
2557 (gnus-article-show-hidden-text type)
2561 (defun gnus-article-hidden-text-p (type)
2562 "Say whether the current buffer contains hidden text of type TYPE."
2563 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2565 (not (get-text-property pos 'invisible))
2566 (not (get-text-property pos 'dummy-invisible)))
2568 (text-property-any (1+ pos) (point-max) 'article-type type)))
2573 (defun gnus-article-show-hidden-text (type &optional dummy)
2574 "Show all hidden text of type TYPE.
2575 Originally it is hide instead of DUMMY."
2576 (let ((buffer-read-only nil)
2577 (inhibit-point-motion-hooks t))
2578 (gnus-remove-text-properties-when
2580 (point-min) (point-max)
2581 (cons 'article-type (cons type
2582 gnus-hidden-properties)))
2583 (gnus-delete-wash-type type)))
2585 (defconst article-time-units
2586 `((year . ,(* 365.25 24 60 60))
2587 (week . ,(* 7 24 60 60))
2588 (day . ,(* 24 60 60))
2592 "Mapping from time units to seconds.")
2594 (defun article-date-ut (&optional type highlight header)
2595 "Convert DATE date to universal time in the current article.
2596 If TYPE is `local', convert to local time; if it is `lapsed', output
2597 how much time has lapsed since DATE. For `lapsed', the value of
2598 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2599 should replace the \"Date:\" one, or should be added below it."
2600 (interactive (list 'ut t))
2601 (let* ((header (or header
2602 (message-fetch-field "date")
2604 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2607 ((not gnus-article-date-lapsed-new-header)
2613 (date (if (vectorp header) (mail-header-date header)
2615 (inhibit-point-motion-hooks t)
2620 (article-narrow-to-head)
2621 (when (re-search-forward tdate-regexp nil t)
2622 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2623 date (or (get-text-property (gnus-point-at-bol)
2626 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2628 (when (and date (not (string= date "")))
2629 (goto-char (point-min))
2630 (let ((buffer-read-only nil))
2631 ;; Delete any old Date headers.
2632 (while (re-search-forward date-regexp nil t)
2634 (delete-region (progn (beginning-of-line) (point))
2635 (progn (forward-line 1) (point)))
2636 (delete-region (progn (beginning-of-line) (point))
2637 (progn (end-of-line) (point)))
2638 (setq pos (point))))
2639 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2641 (if pos (goto-char pos))
2642 (insert (article-make-date-line date (or type 'ut)))
2648 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2649 (put-text-property (match-beginning 1) (1+ (match-end 1))
2650 'original-date date)
2651 (put-text-property (match-beginning 1) (1+ (match-end 1))
2653 (put-text-property (match-beginning 2) (match-end 2)
2656 (defun article-make-date-line (date type)
2657 "Return a DATE line of TYPE."
2658 (unless (memq type '(local ut original user iso8601 lapsed english))
2659 (error "Unknown conversion type: %s" type))
2661 (let ((time (date-to-time date)))
2663 ;; Convert to the local timezone.
2665 (let ((tz (car (current-time-zone time))))
2666 (format "Date: %s %s%02d%02d" (current-time-string time)
2667 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2668 (/ (% (abs tz) 3600) 60))))
2669 ;; Convert to Universal Time.
2672 (current-time-string
2673 (let* ((e (parse-time-string date))
2674 (tm (apply 'encode-time e))
2676 (ls (- (cadr tm) (car (current-time-zone time)))))
2677 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2678 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2681 ;; Get the original date from the article.
2682 ((eq type 'original)
2683 (concat "Date: " (if (string-match "\n+$" date)
2684 (substring date 0 (match-beginning 0))
2686 ;; Let the user define the format.
2688 (let ((format (or (condition-case nil
2689 (with-current-buffer gnus-summary-buffer
2690 gnus-article-time-format)
2692 gnus-article-time-format)))
2693 (if (gnus-functionp format)
2694 (funcall format time)
2695 (concat "Date: " (format-time-string format time)))))
2698 (let ((tz (car (current-time-zone time))))
2701 (format-time-string "%Y%m%dT%H%M%S" time)
2702 (format "%s%02d%02d"
2703 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2704 (/ (% (abs tz) 3600) 60)))))
2705 ;; Do an X-Sent lapsed format.
2707 ;; If the date is seriously mangled, the timezone functions are
2708 ;; liable to bug out, so we ignore all errors.
2709 (let* ((now (current-time))
2710 (real-time (subtract-time now time))
2711 (real-sec (and real-time
2712 (+ (* (float (car real-time)) 65536)
2714 (sec (and real-time (abs real-sec)))
2724 ;; This is a bit convoluted, but basically we go
2725 ;; through the time units for years, weeks, etc,
2726 ;; and divide things to see whether that results
2727 ;; in positive answers.
2730 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2731 ;; The (remaining) seconds are too few to
2732 ;; be divided into this time unit.
2734 ;; It's big enough, so we output it.
2735 (setq sec (- sec (* num (cdr unit))))
2737 (concat (if prev ", " "") (int-to-string
2739 " " (symbol-name (car unit))
2740 (if (> num 1) "s" ""))
2742 article-time-units "")
2743 ;; If dates are odd, then it might appear like the
2744 ;; article was sent in the future.
2747 " in the future"))))))
2748 ;; Display the date in proper English
2750 (let ((dtime (decode-time time)))
2753 (number-to-string (nth 3 dtime))
2754 (let ((digit (% (nth 3 dtime) 10)))
2756 ((memq (nth 3 dtime) '(11 12 13)) "th")
2762 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2764 (number-to-string (nth 5 dtime))
2766 (format "%02d" (nth 2 dtime))
2768 (format "%02d" (nth 1 dtime)))))))
2770 (format "Date: %s (from Gnus)" date))))
2772 (defun article-date-local (&optional highlight)
2773 "Convert the current article date to the local timezone."
2774 (interactive (list t))
2775 (article-date-ut 'local highlight))
2777 (defun article-date-english (&optional highlight)
2778 "Convert the current article date to something that is proper English."
2779 (interactive (list t))
2780 (article-date-ut 'english highlight))
2782 (defun article-date-original (&optional highlight)
2783 "Convert the current article date to what it was originally.
2784 This is only useful if you have used some other date conversion
2785 function and want to see what the date was before converting."
2786 (interactive (list t))
2787 (article-date-ut 'original highlight))
2789 (defun article-date-lapsed (&optional highlight)
2790 "Convert the current article date to time lapsed since it was sent."
2791 (interactive (list t))
2792 (article-date-ut 'lapsed highlight))
2794 (defun article-update-date-lapsed ()
2795 "Function to be run from a timer to update the lapsed time line."
2796 (let (deactivate-mark)
2801 (set-buffer (window-buffer w))
2802 (when (eq major-mode 'gnus-article-mode)
2803 (goto-char (point-min))
2804 (when (re-search-forward "^X-Sent:" nil t)
2805 (article-date-lapsed t))))
2808 (defun gnus-start-date-timer (&optional n)
2809 "Start a timer to update the X-Sent header in the article buffers.
2810 The numerical prefix says how frequently (in seconds) the function
2815 (gnus-stop-date-timer)
2816 (setq article-lapsed-timer
2817 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2819 (defun gnus-stop-date-timer ()
2820 "Stop the X-Sent timer."
2822 (when article-lapsed-timer
2823 (nnheader-cancel-timer article-lapsed-timer)
2824 (setq article-lapsed-timer nil)))
2826 (defun article-date-user (&optional highlight)
2827 "Convert the current article date to the user-defined format.
2828 This format is defined by the `gnus-article-time-format' variable."
2829 (interactive (list t))
2830 (article-date-ut 'user highlight))
2832 (defun article-date-iso8601 (&optional highlight)
2833 "Convert the current article date to ISO8601."
2834 (interactive (list t))
2835 (article-date-ut 'iso8601 highlight))
2837 ;; (defun article-show-all ()
2838 ;; "Show all hidden text in the article buffer."
2841 ;; (let ((buffer-read-only nil))
2842 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2844 (defun article-remove-leading-whitespace ()
2845 "Remove excessive whitespace from all headers."
2849 (let ((buffer-read-only nil))
2850 (article-narrow-to-head)
2851 (goto-char (point-min))
2852 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2853 (delete-region (match-beginning 1) (match-end 1)))))))
2855 (defun article-emphasize (&optional arg)
2856 "Emphasize text according to `gnus-emphasis-alist'."
2857 (interactive (gnus-article-hidden-arg))
2858 (unless (gnus-article-check-hidden-text 'emphasis arg)
2862 (with-current-buffer gnus-summary-buffer
2863 gnus-article-emphasis-alist)
2865 gnus-emphasis-alist))
2866 (buffer-read-only nil)
2867 (props (append '(article-type emphasis)
2868 gnus-hidden-properties))
2869 regexp elem beg invisible visible face)
2872 (while (setq elem (pop alist))
2874 (setq regexp (car elem)
2875 invisible (nth 1 elem)
2876 visible (nth 2 elem)
2878 (while (re-search-forward regexp nil t)
2879 (when (and (match-beginning visible) (match-beginning invisible))
2880 (gnus-article-hide-text
2881 (match-beginning invisible) (match-end invisible) props)
2882 (gnus-article-unhide-text-type
2883 (match-beginning visible) (match-end visible) 'emphasis)
2884 (gnus-put-overlay-excluding-newlines
2885 (match-beginning visible) (match-end visible) 'face face)
2886 (gnus-add-wash-type 'emphasis)
2887 (goto-char (match-end invisible)))))))))
2889 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2890 "Setup newsgroup emphasis alist."
2891 (unless gnus-article-emphasis-alist
2892 (let ((name (and gnus-newsgroup-name
2893 (gnus-group-real-name gnus-newsgroup-name))))
2894 (make-local-variable 'gnus-article-emphasis-alist)
2895 (setq gnus-article-emphasis-alist
2897 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2898 (while (setq elem (pop alist))
2899 (when (and name (string-match (car elem) name))
2901 highlight (copy-sequence (cdr elem)))))
2903 (copy-sequence highlight-words)
2904 (if gnus-newsgroup-name
2905 (copy-sequence (gnus-group-find-parameter
2906 gnus-newsgroup-name 'highlight-words t)))
2907 gnus-emphasis-alist)))))
2910 (defvar gnus-summary-article-menu)
2911 (defvar gnus-summary-post-menu))
2913 ;;; Saving functions.
2915 (defun gnus-article-save (save-buffer file &optional num)
2916 "Save the currently selected article."
2917 (unless gnus-save-all-headers
2918 ;; Remove headers according to `gnus-saved-headers'.
2919 (let ((gnus-visible-headers
2920 (or gnus-saved-headers gnus-visible-headers))
2921 (gnus-article-buffer save-buffer))
2923 (set-buffer save-buffer)
2924 (article-hide-headers 1 t))))
2925 (save-window-excursion
2926 (if (not gnus-default-article-saver)
2927 (error "No default saver is defined")
2928 ;; !!! Magic! The saving functions all save
2929 ;; `gnus-save-article-buffer' (or so they think), but we
2930 ;; bind that variable to our save-buffer.
2931 (set-buffer gnus-article-buffer)
2932 (let* ((gnus-save-article-buffer save-buffer)
2935 ((not gnus-prompt-before-saving) 'default)
2936 ((eq gnus-prompt-before-saving 'always) nil)
2938 (gnus-number-of-articles-to-be-saved
2939 (when (eq gnus-prompt-before-saving t)
2941 (set-buffer gnus-article-current-summary)
2942 (funcall gnus-default-article-saver filename)))))
2944 (defun gnus-read-save-file-name (prompt &optional filename
2945 function group headers variable)
2947 (funcall function group headers (symbol-value variable)))
2952 ((eq filename 'default)
2958 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2961 (if (and gnus-number-of-articles-to-be-saved
2962 (> gnus-number-of-articles-to-be-saved 1))
2963 (format "these %d articles"
2964 gnus-number-of-articles-to-be-saved)
2967 ;; Let the split methods have their say.
2969 ;; No split name was found.
2972 (concat prompt " (default "
2973 (file-name-nondirectory default-name) ") ")
2974 (file-name-directory default-name)
2976 ;; A single group name is returned.
2977 ((stringp split-name)
2979 (funcall function split-name headers
2980 (symbol-value variable)))
2982 (concat prompt " (default "
2983 (file-name-nondirectory default-name) ") ")
2984 (file-name-directory default-name)
2986 ;; A single split name was found
2987 ((= 1 (length split-name))
2988 (let* ((name (expand-file-name
2990 gnus-article-save-directory))
2991 (dir (cond ((file-directory-p name)
2992 (file-name-as-directory name))
2993 ((file-exists-p name) name)
2994 (t gnus-article-save-directory))))
2996 (concat prompt " (default " name ") ")
2998 ;; A list of splits was found.
3000 (setq split-name (nreverse split-name))
3002 (let ((file-name-history
3003 (nconc split-name file-name-history)))
3007 (concat prompt " (`M-p' for defaults) ")
3008 gnus-article-save-directory
3010 gnus-article-save-directory)))
3011 (car (push result file-name-history)))))))
3012 ;; Create the directory.
3013 (gnus-make-directory (file-name-directory file))
3014 ;; If we have read a directory, we append the default file name.
3015 (when (file-directory-p file)
3016 (setq file (expand-file-name (file-name-nondirectory
3018 (file-name-as-directory file))))
3019 ;; Possibly translate some characters.
3020 (nnheader-translate-file-chars file))))))
3021 (gnus-make-directory (file-name-directory result))
3022 (set variable result)))
3024 (defun gnus-article-archive-name (group)
3025 "Return the first instance of an \"Archive-name\" in the current buffer."
3026 (let ((case-fold-search t))
3027 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3028 (nnheader-concat gnus-article-save-directory
3029 (match-string 1)))))
3031 (defun gnus-article-nndoc-name (group)
3032 "If GROUP is an nndoc group, return the name of the parent group."
3033 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3034 (gnus-group-get-parameter group 'save-article-group)))
3036 (defun gnus-summary-save-in-rmail (&optional filename)
3037 "Append this article to Rmail file.
3038 Optional argument FILENAME specifies file name.
3039 Directory to save to is default to `gnus-article-save-directory'."
3040 (setq filename (gnus-read-save-file-name
3041 "Save %s in rmail file:" filename
3042 gnus-rmail-save-name gnus-newsgroup-name
3043 gnus-current-headers 'gnus-newsgroup-last-rmail))
3044 (gnus-eval-in-buffer-window gnus-save-article-buffer
3048 (gnus-output-to-rmail filename))))
3051 (defun gnus-summary-save-in-mail (&optional filename)
3052 "Append this article to Unix mail file.
3053 Optional argument FILENAME specifies file name.
3054 Directory to save to is default to `gnus-article-save-directory'."
3055 (setq filename (gnus-read-save-file-name
3056 "Save %s in Unix mail file:" filename
3057 gnus-mail-save-name gnus-newsgroup-name
3058 gnus-current-headers 'gnus-newsgroup-last-mail))
3059 (gnus-eval-in-buffer-window gnus-save-article-buffer
3063 (if (and (file-readable-p filename)
3064 (mail-file-babyl-p filename))
3065 (rmail-output-to-rmail-file filename t)
3066 (gnus-output-to-mail filename)))))
3069 (defun gnus-summary-save-in-file (&optional filename overwrite)
3070 "Append this article to file.
3071 Optional argument FILENAME specifies file name.
3072 Directory to save to is default to `gnus-article-save-directory'."
3073 (setq filename (gnus-read-save-file-name
3074 "Save %s in file:" filename
3075 gnus-file-save-name gnus-newsgroup-name
3076 gnus-current-headers 'gnus-newsgroup-last-file))
3077 (gnus-eval-in-buffer-window gnus-save-article-buffer
3081 (when (and overwrite
3082 (file-exists-p filename))
3083 (delete-file filename))
3084 (gnus-output-to-file filename))))
3087 (defun gnus-summary-write-to-file (&optional filename)
3088 "Write this article to a file, overwriting it if the file exists.
3089 Optional argument FILENAME specifies file name.
3090 The directory to save in defaults to `gnus-article-save-directory'."
3091 (gnus-summary-save-in-file nil t))
3093 (defun gnus-summary-save-body-in-file (&optional filename)
3094 "Append this article body to a file.
3095 Optional argument FILENAME specifies file name.
3096 The directory to save in defaults to `gnus-article-save-directory'."
3097 (setq filename (gnus-read-save-file-name
3098 "Save %s body in file:" filename
3099 gnus-file-save-name gnus-newsgroup-name
3100 gnus-current-headers 'gnus-newsgroup-last-file))
3101 (gnus-eval-in-buffer-window gnus-save-article-buffer
3105 (when (article-goto-body)
3106 (narrow-to-region (point) (point-max)))
3107 (gnus-output-to-file filename))))
3110 (defun gnus-summary-save-in-pipe (&optional command)
3111 "Pipe this article to subprocess."
3113 (cond ((and (eq command 'default)
3114 gnus-last-shell-command)
3115 gnus-last-shell-command)
3120 "Shell command on %s: "
3121 (if (and gnus-number-of-articles-to-be-saved
3122 (> gnus-number-of-articles-to-be-saved 1))
3123 (format "these %d articles"
3124 gnus-number-of-articles-to-be-saved)
3126 gnus-last-shell-command))))
3127 (when (string-equal command "")
3128 (if gnus-last-shell-command
3129 (setq command gnus-last-shell-command)
3130 (error "A command is required")))
3131 (gnus-eval-in-buffer-window gnus-article-buffer
3134 (shell-command-on-region (point-min) (point-max) command nil)))
3135 (setq gnus-last-shell-command command))
3137 (defun gnus-summary-pipe-to-muttprint (&optional command)
3138 "Pipe this article to muttprint."
3139 (setq command (read-string
3140 "Print using command: " gnus-summary-muttprint-program
3141 nil gnus-summary-muttprint-program))
3142 (gnus-summary-save-in-pipe command))
3144 ;;; Article file names when saving.
3146 (defun gnus-capitalize-newsgroup (newsgroup)
3147 "Capitalize NEWSGROUP name."
3148 (when (not (zerop (length newsgroup)))
3149 (concat (char-to-string (upcase (aref newsgroup 0)))
3150 (substring newsgroup 1))))
3152 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3153 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3154 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3155 Otherwise, it is like ~/News/news/group/num."
3158 (concat (if (gnus-use-long-file-name 'not-save)
3159 (gnus-capitalize-newsgroup newsgroup)
3160 (gnus-newsgroup-directory-form newsgroup))
3161 "/" (int-to-string (mail-header-number headers)))
3162 gnus-article-save-directory)))
3164 (string-equal (file-name-directory default)
3165 (file-name-directory last-file))
3166 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3168 (or last-file default))))
3170 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3171 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3172 If variable `gnus-use-long-file-name' is non-nil, it is
3173 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3176 (concat (if (gnus-use-long-file-name 'not-save)
3178 (gnus-newsgroup-directory-form newsgroup))
3179 "/" (int-to-string (mail-header-number headers)))
3180 gnus-article-save-directory)))
3182 (string-equal (file-name-directory default)
3183 (file-name-directory last-file))
3184 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3186 (or last-file default))))
3188 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3189 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3190 If variable `gnus-use-long-file-name' is non-nil, it is
3191 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3194 (if (gnus-use-long-file-name 'not-save)
3197 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3199 gnus-article-save-directory)))
3201 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3202 "Generate file name from sender."
3203 (let ((from (mail-header-from headers)))
3205 (if (and from (string-match "\\([^ <]+\\)@" from))
3206 (match-string 1 from)
3208 gnus-article-save-directory)))
3210 (defun article-verify-x-pgp-sig ()
3213 (if (gnus-buffer-live-p gnus-original-article-buffer)
3214 (let ((sig (with-current-buffer gnus-original-article-buffer
3215 (gnus-fetch-field "X-PGP-Sig")))
3219 (mml2015-clear-verify-function))
3221 (insert-buffer gnus-original-article-buffer)
3222 (setq items (split-string sig))
3223 (message-narrow-to-head)
3224 (let ((inhibit-point-motion-hooks t)
3225 (case-fold-search t))
3226 ;; Don't verify multiple headers.
3227 (setq headers (mapconcat (lambda (header)
3229 (mail-fetch-field header) "\n"))
3230 (split-string (nth 1 items) ",") "")))
3231 (delete-region (point-min) (point-max))
3232 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3233 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3238 (if (looking-at "^-")
3241 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3242 (insert "Version: " (car items) "\n\n")
3243 (insert (mapconcat 'identity (cddr items) "\n"))
3244 (insert "\n-----END PGP SIGNATURE-----\n")
3245 (let ((mm-security-handle (list (format "multipart/signed"))))
3246 (mml2015-clean-buffer)
3247 (let ((coding-system-for-write (or gnus-newsgroup-charset
3249 (funcall (mml2015-clear-verify-function)))
3251 (or (mm-handle-multipart-ctl-parameter
3252 mm-security-handle 'gnus-details)
3253 (mm-handle-multipart-ctl-parameter
3254 mm-security-handle 'gnus-info)))))
3256 (let (buffer-read-only bface eface)
3258 (message-narrow-to-head)
3259 (goto-char (point-max))
3261 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3262 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3263 (message-remove-header "X-Gnus-PGP-Verify")
3264 (if (re-search-forward "^X-PGP-Sig:" nil t)
3266 (goto-char (point-max)))
3267 (narrow-to-region (point) (point))
3268 (insert "X-Gnus-PGP-Verify: " info "\n")
3269 (goto-char (point-min))
3272 (if (not (looking-at "^[ \t]"))
3276 (goto-char (point-min))
3277 (when (looking-at "\\([^:]+\\): *")
3278 (put-text-property (match-beginning 1) (1+ (match-end 1))
3280 (put-text-property (match-end 0) (point-max)
3281 'face eface)))))))))
3283 (defun article-verify-cancel-lock ()
3284 "Verify Cancel-Lock header."
3286 (if (gnus-buffer-live-p gnus-original-article-buffer)
3287 (canlock-verify gnus-original-article-buffer)))
3294 (setq afunc (car func)
3297 gfunc (intern (format "gnus-%s" func))))
3299 (when (fboundp afunc)
3300 `(lambda (&optional interactive &rest args)
3301 ,(documentation afunc t)
3302 (interactive (list t))
3304 (set-buffer gnus-article-buffer)
3306 (call-interactively ',afunc)
3307 (apply ',afunc args))))))))
3308 '(article-hide-headers
3309 article-verify-x-pgp-sig
3310 article-verify-cancel-lock
3311 article-hide-boring-headers
3312 article-treat-overstrike
3313 article-fill-long-lines
3314 article-capitalize-sentences
3316 article-remove-leading-whitespace
3317 article-display-x-face
3318 article-de-quoted-unreadable
3319 article-de-base64-unreadable
3322 article-unsplit-urls
3323 article-hide-list-identifiers
3325 article-strip-banner
3328 article-hide-signature
3329 article-strip-headers-in-body
3330 article-remove-trailing-blank-lines
3331 article-strip-leading-blank-lines
3332 article-strip-multiple-blank-lines
3333 article-strip-leading-space
3334 article-strip-trailing-space
3335 article-strip-blank-lines
3336 article-strip-all-blank-lines
3338 article-date-english
3339 article-date-iso8601
3340 article-date-original
3342 article-decode-mime-words
3343 article-decode-charset
3344 article-decode-encoded-words
3348 article-treat-dumbquotes
3349 article-normalize-headers
3350 ;; (article-show-all . gnus-article-show-all-headers)
3354 ;;; Gnus article mode
3357 (put 'gnus-article-mode 'mode-class 'special)
3359 (set-keymap-parent gnus-article-mode-map widget-keymap)
3361 (gnus-define-keys gnus-article-mode-map
3362 " " gnus-article-goto-next-page
3363 "\177" gnus-article-goto-prev-page
3364 [delete] gnus-article-goto-prev-page
3365 [backspace] gnus-article-goto-prev-page
3366 "\C-c^" gnus-article-refer-article
3367 "h" gnus-article-show-summary
3368 "s" gnus-article-show-summary
3369 "\C-c\C-m" gnus-article-mail
3370 "?" gnus-article-describe-briefly
3371 "e" gnus-summary-edit-article
3372 "<" beginning-of-buffer
3374 "\C-c\C-i" gnus-info-find-node
3376 "R" gnus-article-reply-with-original
3377 "F" gnus-article-followup-with-original
3378 "\C-hk" gnus-article-describe-key
3379 "\C-hc" gnus-article-describe-key-briefly
3381 "\C-d" gnus-article-read-summary-keys
3382 "\M-*" gnus-article-read-summary-keys
3383 "\M-#" gnus-article-read-summary-keys
3384 "\M-^" gnus-article-read-summary-keys
3385 "\M-g" gnus-article-read-summary-keys)
3387 (substitute-key-definition
3388 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3390 (defun gnus-article-make-menu-bar ()
3391 (unless (boundp 'gnus-article-commands-menu)
3392 (gnus-summary-make-menu-bar))
3393 (gnus-turn-off-edit-menu 'article)
3394 (unless (boundp 'gnus-article-article-menu)
3396 gnus-article-article-menu gnus-article-mode-map ""
3398 ["Scroll forwards" gnus-article-goto-next-page t]
3399 ["Scroll backwards" gnus-article-goto-prev-page t]
3400 ["Show summary" gnus-article-show-summary t]
3401 ["Fetch Message-ID at point" gnus-article-refer-article t]
3402 ["Mail to address at point" gnus-article-mail t]
3403 ["Send a bug report" gnus-bug t]))
3406 gnus-article-treatment-menu gnus-article-mode-map ""
3407 ;; Fixme: this should use :active (and maybe :visible).
3409 ["Hide headers" gnus-article-hide-headers t]
3410 ["Hide signature" gnus-article-hide-signature t]
3411 ["Hide citation" gnus-article-hide-citation t]
3412 ["Treat overstrike" gnus-article-treat-overstrike t]
3413 ["Remove carriage return" gnus-article-remove-cr t]
3414 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3415 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3416 ["Remove base64" gnus-article-de-base64-unreadable t]
3417 ["Treat html" gnus-article-wash-html t]
3418 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3419 ["Decode HZ" gnus-article-decode-HZ t]))
3421 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3423 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3425 (gnus-run-hooks 'gnus-article-menu-hook)))
3427 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3430 (defun gnus-article-mode ()
3431 "Major mode for displaying an article.
3433 All normal editing commands are switched off.
3435 The following commands are available in addition to all summary mode
3437 \\<gnus-article-mode-map>
3438 \\[gnus-article-next-page]\t Scroll the article one page forwards
3439 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3440 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3441 \\[gnus-article-show-summary]\t Display the summary buffer
3442 \\[gnus-article-mail]\t Send a reply to the address near point
3443 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3444 \\[gnus-info-find-node]\t Go to the Gnus info node"
3446 (gnus-simplify-mode-line)
3447 (setq mode-name "Article")
3448 (setq major-mode 'gnus-article-mode)
3449 (make-local-variable 'minor-mode-alist)
3450 (use-local-map gnus-article-mode-map)
3451 (when (gnus-visual-p 'article-menu 'menu)
3452 (gnus-article-make-menu-bar))
3453 (gnus-update-format-specifications nil 'article-mode)
3454 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3455 (make-local-variable 'gnus-page-broken)
3456 (make-local-variable 'gnus-button-marker-list)
3457 (make-local-variable 'gnus-article-current-summary)
3458 (make-local-variable 'gnus-article-mime-handles)
3459 (make-local-variable 'gnus-article-decoded-p)
3460 (make-local-variable 'gnus-article-mime-handle-alist)
3461 (make-local-variable 'gnus-article-wash-types)
3462 (make-local-variable 'gnus-article-image-alist)
3463 (make-local-variable 'gnus-article-charset)
3464 (make-local-variable 'gnus-article-ignored-charsets)
3465 (gnus-set-default-directory)
3466 (buffer-disable-undo)
3467 (setq buffer-read-only t)
3468 (set-syntax-table gnus-article-mode-syntax-table)
3469 (mm-enable-multibyte)
3470 (gnus-run-hooks 'gnus-article-mode-hook))
3472 (defun gnus-article-setup-buffer ()
3473 "Initialize the article buffer."
3474 (let* ((name (if gnus-single-article-buffer "*Article*"
3475 (concat "*Article " gnus-newsgroup-name "*")))
3477 (progn (string-match "\\*Article" name)
3478 (concat " *Original Article"
3479 (substring name (match-end 0))))))
3480 (setq gnus-article-buffer name)
3481 (setq gnus-original-article-buffer original)
3482 (setq gnus-article-mime-handle-alist nil)
3483 ;; This might be a variable local to the summary buffer.
3484 (unless gnus-single-article-buffer
3486 (set-buffer gnus-summary-buffer)
3487 (setq gnus-article-buffer name)
3488 (setq gnus-original-article-buffer original)
3489 (gnus-set-global-variables)))
3490 (gnus-article-setup-highlight-words)
3491 ;; Init original article buffer.
3493 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3494 (mm-enable-multibyte)
3495 (setq major-mode 'gnus-original-article-mode)
3496 (make-local-variable 'gnus-original-article))
3497 (if (get-buffer name)
3500 (when (and gnus-article-edit-mode
3503 (y-or-n-p "Article mode edit in progress; discard? ")))
3504 (error "Action aborted"))
3505 (set (make-local-variable 'gnus-article-edit-mode) nil)
3506 (when gnus-article-mime-handles
3507 (mm-destroy-parts gnus-article-mime-handles)
3508 (setq gnus-article-mime-handles nil))
3509 ;; Set it to nil in article-buffer!
3510 (setq gnus-article-mime-handle-alist nil)
3511 (buffer-disable-undo)
3512 (setq buffer-read-only t)
3513 (unless (eq major-mode 'gnus-article-mode)
3514 (gnus-article-mode))
3517 (set-buffer (gnus-get-buffer-create name))
3519 (make-local-variable 'gnus-summary-buffer)
3520 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3521 (current-buffer)))))
3523 ;; Set article window start at LINE, where LINE is the number of lines
3524 ;; from the head of the article.
3525 (defun gnus-article-set-window-start (&optional line)
3527 (gnus-get-buffer-window gnus-article-buffer t)
3529 (set-buffer gnus-article-buffer)
3530 (goto-char (point-min))
3533 (gnus-message 6 "Moved to bookmark")
3534 (search-forward "\n\n" nil t)
3538 (defun gnus-article-prepare (article &optional all-headers header)
3539 "Prepare ARTICLE in article mode buffer.
3540 ARTICLE should either be an article number or a Message-ID.
3541 If ARTICLE is an id, HEADER should be the article headers.
3542 If ALL-HEADERS is non-nil, no headers are hidden."
3544 ;; Make sure we start in a summary buffer.
3545 (unless (eq major-mode 'gnus-summary-mode)
3546 (set-buffer gnus-summary-buffer))
3547 (setq gnus-summary-buffer (current-buffer))
3548 (let* ((gnus-article (if header (mail-header-number header) article))
3549 (summary-buffer (current-buffer))
3550 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3551 (group gnus-newsgroup-name)
3554 (gnus-article-setup-buffer)
3555 (set-buffer gnus-article-buffer)
3556 ;; Deactivate active regions.
3557 (when (and (boundp 'transient-mark-mode)
3558 transient-mark-mode)
3559 (setq mark-active nil))
3560 (if (not (setq result (let ((buffer-read-only nil))
3561 (gnus-request-article-this-buffer
3563 ;; There is no such article.
3565 (when (and (numberp article)
3566 (not (memq article gnus-newsgroup-sparse)))
3567 (setq gnus-article-current
3568 (cons gnus-newsgroup-name article))
3569 (set-buffer gnus-summary-buffer)
3570 (setq gnus-current-article article)
3571 (if (memq article gnus-newsgroup-undownloaded)
3573 (gnus-summary-set-agent-mark article)
3574 (message "Message marked for downloading"))
3575 (gnus-summary-mark-article article gnus-canceled-mark)
3576 (unless (memq article gnus-newsgroup-sparse)
3577 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3578 (if (or (eq result 'pseudo)
3579 (eq result 'nneething))
3582 (set-buffer summary-buffer)
3583 (push article gnus-newsgroup-history)
3584 (setq gnus-last-article gnus-current-article
3585 gnus-current-article 0
3586 gnus-current-headers nil
3587 gnus-article-current nil)
3588 (if (eq result 'nneething)
3589 (gnus-configure-windows 'summary)
3590 (gnus-configure-windows 'article))
3591 (gnus-set-global-variables))
3592 (let ((gnus-article-mime-handle-alist-1
3593 gnus-article-mime-handle-alist))
3594 (gnus-set-mode-line 'article)))
3595 ;; The result from the `request' was an actual article -
3596 ;; or at least some text that is now displayed in the
3598 (when (and (numberp article)
3599 (not (eq article gnus-current-article)))
3600 ;; Seems like a new article has been selected.
3601 ;; `gnus-current-article' must be an article number.
3603 (set-buffer summary-buffer)
3604 (push article gnus-newsgroup-history)
3605 (setq gnus-last-article gnus-current-article
3606 gnus-current-article article
3607 gnus-current-headers
3608 (gnus-summary-article-header gnus-current-article)
3609 gnus-article-current
3610 (cons gnus-newsgroup-name gnus-current-article))
3611 (unless (vectorp gnus-current-headers)
3612 (setq gnus-current-headers nil))
3613 (gnus-summary-goto-subject gnus-current-article)
3614 (when (gnus-summary-show-thread)
3615 ;; If the summary buffer really was folded, the
3616 ;; previous goto may not actually have gone to
3617 ;; the right article, but the thread root instead.
3619 (gnus-summary-goto-subject gnus-current-article))
3620 (gnus-run-hooks 'gnus-mark-article-hook)
3621 (gnus-set-mode-line 'summary)
3622 (when (gnus-visual-p 'article-highlight 'highlight)
3623 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3624 ;; Set the global newsgroup variables here.
3625 (gnus-set-global-variables)
3626 (setq gnus-have-all-headers
3627 (or all-headers gnus-show-all-headers))))
3629 (gnus-configure-windows 'article))
3630 (when (or (numberp article)
3632 (gnus-article-prepare-display)
3634 (goto-char (point-min))
3635 (setq gnus-page-broken
3636 (when gnus-break-pages
3637 (gnus-narrow-to-page)
3639 (let ((gnus-article-mime-handle-alist-1
3640 gnus-article-mime-handle-alist))
3641 (gnus-set-mode-line 'article))
3645 (set-window-point (get-buffer-window (current-buffer)) (point))
3646 (gnus-configure-windows 'article)
3650 (defun gnus-article-prepare-display ()
3651 "Make the current buffer look like a nice article."
3652 ;; Hooks for getting information from the article.
3653 ;; This hook must be called before being narrowed.
3654 (let ((gnus-article-buffer (current-buffer))
3656 (unless (eq major-mode 'gnus-article-mode)
3657 (gnus-article-mode))
3658 (setq buffer-read-only nil
3659 gnus-article-wash-types nil
3660 gnus-article-image-alist nil)
3661 (gnus-run-hooks 'gnus-tmp-internal-hook)
3662 (when gnus-display-mime-function
3663 (funcall gnus-display-mime-function))
3664 (gnus-run-hooks 'gnus-article-prepare-hook)))
3667 ;;; Gnus MIME viewing functions
3670 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3671 "Format of the MIME buttons.
3673 Valid specifiers include:
3675 %T MIME type, along with additional info
3676 %n The `name' parameter
3677 %d The description, if any
3678 %l The length of the encoded part
3679 %p The part identifier number
3680 %e Dots if the part isn't displayed
3682 General format specifiers can also be used. See Info node
3683 `(gnus)Formatting Variables'.")
3685 (defvar gnus-mime-button-line-format-alist
3686 '((?t gnus-tmp-type ?s)
3687 (?T gnus-tmp-type-long ?s)
3688 (?n gnus-tmp-name ?s)
3689 (?d gnus-tmp-description ?s)
3691 (?l gnus-tmp-length ?d)
3692 (?e gnus-tmp-dots ?s)))
3694 (defvar gnus-mime-button-commands
3695 '((gnus-article-press-button "\r" "Toggle Display")
3696 (gnus-mime-view-part "v" "View Interactively...")
3697 (gnus-mime-view-part-as-type "t" "View As Type...")
3698 (gnus-mime-view-part-as-charset "C" "View As charset...")
3699 (gnus-mime-save-part "o" "Save...")
3700 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3701 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3702 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3703 (gnus-mime-view-part-internally "E" "View Internally")
3704 (gnus-mime-view-part-externally "e" "View Externally")
3705 (gnus-mime-print-part "p" "Print")
3706 (gnus-mime-pipe-part "|" "Pipe To Command...")
3707 (gnus-mime-action-on-part "." "Take action on the part")))
3709 (defun gnus-article-mime-part-status ()
3710 (if gnus-article-mime-handle-alist-1
3711 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3713 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3716 (defvar gnus-mime-button-map
3717 (let ((map (make-sparse-keymap)))
3718 (unless (>= (string-to-number emacs-version) 21)
3719 ;; XEmacs doesn't care.
3720 (set-keymap-parent map gnus-article-mode-map))
3721 (define-key map gnus-mouse-2 'gnus-article-push-button)
3722 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3723 (dolist (c gnus-mime-button-commands)
3724 (define-key map (cadr c) (car c)))
3727 (defun gnus-mime-button-menu (event)
3728 "Construct a context-sensitive menu of MIME commands."
3730 (save-window-excursion
3731 (let ((pos (event-start event)))
3732 (select-window (posn-window pos))
3733 (goto-char (posn-point pos))
3734 (gnus-article-check-buffer)
3735 (let ((response (x-popup-menu
3737 ("" ,@(mapcar (lambda (c)
3738 (cons (caddr c) (car c)))
3739 gnus-mime-button-commands))))))
3741 (call-interactively response))))))
3743 (defun gnus-mime-view-all-parts (&optional handles)
3744 "View all the MIME parts."
3746 (save-current-buffer
3747 (set-buffer gnus-article-buffer)
3748 (let ((handles (or handles gnus-article-mime-handles))
3749 (mail-parse-charset gnus-newsgroup-charset)
3750 (mail-parse-ignored-charsets
3751 (with-current-buffer gnus-summary-buffer
3752 gnus-newsgroup-ignored-charsets)))
3754 (mm-remove-parts handles)
3755 (goto-char (point-min))
3756 (or (search-forward "\n\n") (goto-char (point-max)))
3757 (let (buffer-read-only)
3758 (delete-region (point) (point-max))
3759 (mm-display-parts handles))))))
3761 (defun gnus-mime-save-part-and-strip ()
3762 "Save the MIME part under point then replace it with an external body."
3764 (gnus-article-check-buffer)
3765 (let* ((data (get-text-property (point) 'gnus-data))
3767 (handles gnus-article-mime-handles))
3768 (if (mm-multiple-handles gnus-article-mime-handles)
3769 (error "This function is not implemented"))
3770 (setq file (and data (mm-save-part data)))
3772 (with-current-buffer (mm-handle-buffer data)
3774 (insert "Content-Type: " (mm-handle-media-type data))
3775 (mml-insert-parameter-string (cdr (mm-handle-type data))
3778 (insert "Content-ID: " (message-make-message-id) "\n")
3779 (insert "Content-Transfer-Encoding: binary\n")
3782 (cdr (mm-make-handle nil
3783 `("message/external-body"
3784 (access-type . "LOCAL-FILE")
3786 (set-buffer gnus-summary-buffer)
3787 (gnus-article-edit-article
3790 (let ((mail-parse-charset (or gnus-article-charset
3791 ',gnus-newsgroup-charset))
3792 (mail-parse-ignored-charsets
3793 (or gnus-article-ignored-charsets
3794 ',gnus-newsgroup-ignored-charsets))
3795 (mbl mml-buffer-list))
3796 (setq mml-buffer-list nil)
3797 (insert-buffer gnus-original-article-buffer)
3798 (mime-to-mml ',handles)
3799 (setq gnus-article-mime-handles nil)
3800 (let ((mbl1 mml-buffer-list))
3801 (setq mml-buffer-list mbl)
3802 (set (make-local-variable 'mml-buffer-list) mbl1))
3803 ;; LOCAL argument of add-hook differs between GNU Emacs
3804 ;; and XEmacs. make-local-hook makes sure they are local.
3805 (make-local-hook 'kill-buffer-hook)
3806 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3807 `(lambda (no-highlight)
3808 (let ((mail-parse-charset (or gnus-article-charset
3809 ',gnus-newsgroup-charset))
3810 (message-options message-options)
3811 (message-options-set-recipient)
3812 (mail-parse-ignored-charsets
3813 (or gnus-article-ignored-charsets
3814 ',gnus-newsgroup-ignored-charsets)))
3816 (mml-destroy-buffers)
3817 (remove-hook 'kill-buffer-hook
3818 'mml-destroy-buffers t)
3819 (kill-local-variable 'mml-buffer-list))
3820 (gnus-summary-edit-article-done
3821 ,(or (mail-header-references gnus-current-headers) "")
3822 ,(gnus-group-read-only-p)
3823 ,gnus-summary-buffer no-highlight))))))
3825 (defun gnus-mime-save-part ()
3826 "Save the MIME part under point."
3828 (gnus-article-check-buffer)
3829 (let ((data (get-text-property (point) 'gnus-data)))
3831 (mm-save-part data))))
3833 (defun gnus-mime-pipe-part ()
3834 "Pipe the MIME part under point to a process."
3836 (gnus-article-check-buffer)
3837 (let ((data (get-text-property (point) 'gnus-data)))
3839 (mm-pipe-part data))))
3841 (defun gnus-mime-view-part ()
3842 "Interactively choose a viewing method for the MIME part under point."
3844 (gnus-article-check-buffer)
3845 (let ((data (get-text-property (point) 'gnus-data)))
3847 (setq gnus-article-mime-handles
3849 gnus-article-mime-handles (setq data (copy-sequence data))))
3850 (mm-interactively-view-part data))))
3852 (defun gnus-mime-view-part-as-type-internal ()
3853 (gnus-article-check-buffer)
3854 (let* ((name (mail-content-type-get
3855 (mm-handle-type (get-text-property (point) 'gnus-data))
3857 (def-type (and name (mm-default-file-encoding name))))
3858 (and def-type (cons def-type 0))))
3860 (defun gnus-mime-view-part-as-type (&optional mime-type)
3861 "Choose a MIME media type, and view the part as such."
3864 (setq mime-type (completing-read
3865 "View as MIME type: "
3866 (mapcar #'list (mailcap-mime-types))
3868 (gnus-mime-view-part-as-type-internal))))
3869 (gnus-article-check-buffer)
3870 (let ((handle (get-text-property (point) 'gnus-data)))
3873 (mm-make-handle (mm-handle-buffer handle)
3874 (cons mime-type (cdr (mm-handle-type handle)))
3875 (mm-handle-encoding handle)
3876 (mm-handle-undisplayer handle)
3877 (mm-handle-disposition handle)
3878 (mm-handle-description handle)
3880 (mm-handle-id handle)))
3881 (setq gnus-article-mime-handles
3882 (mm-merge-handles gnus-article-mime-handles handle))
3883 (gnus-mm-display-part handle))))
3885 (defun gnus-mime-copy-part (&optional handle)
3886 "Put the MIME part under point into a new buffer."
3888 (gnus-article-check-buffer)
3889 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3890 (contents (and handle (mm-get-part handle)))
3892 (file-name-nondirectory
3894 (mail-content-type-get (mm-handle-type handle) 'name)
3895 (mail-content-type-get (mm-handle-disposition handle)
3898 (buffer (and base (generate-new-buffer base))))
3900 (switch-to-buffer buffer)
3902 ;; We do it this way to make `normal-mode' set the appropriate mode.
3905 (setq buffer-file-name (expand-file-name base))
3907 (setq buffer-file-name nil))
3908 (goto-char (point-min)))))
3910 (defun gnus-mime-print-part (&optional handle filename)
3911 "Print the MIME part under point."
3912 (interactive (list nil (ps-print-preprint current-prefix-arg)))
3913 (gnus-article-check-buffer)
3914 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3915 (contents (and handle (mm-get-part handle)))
3916 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
3917 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
3922 (with-temp-file file
3924 (call-process shell-file-name nil
3925 (generate-new-buffer " *mm*")
3927 shell-command-switch
3929 printer file (mm-handle-type handle))))
3933 (gnus-print-buffer))
3934 (ps-despool filename)))))
3936 (defun gnus-mime-inline-part (&optional handle arg)
3937 "Insert the MIME part under point into the current buffer."
3938 (interactive (list nil current-prefix-arg))
3939 (gnus-article-check-buffer)
3940 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3945 (if (and (not arg) (mm-handle-undisplayer handle))
3946 (mm-remove-part handle)
3947 (setq contents (mm-get-part handle))
3950 (setq charset (or (mail-content-type-get
3951 (mm-handle-type handle) 'charset)
3952 gnus-newsgroup-charset)))
3954 (if (mm-handle-undisplayer handle)
3955 (mm-remove-part handle))
3958 gnus-summary-show-article-charset-alist))
3959 (mm-read-coding-system "Charset: ")))))
3961 (mm-insert-inline handle
3963 (setq charset (mm-charset-to-coding-system
3965 (not (eq charset 'ascii)))
3966 (mm-decode-coding-string contents charset)
3970 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3971 "Insert the MIME part under point into the current buffer using the
3973 (interactive (list nil current-prefix-arg))
3974 (gnus-article-check-buffer)
3975 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3980 (if (mm-handle-undisplayer handle)
3981 (mm-remove-part handle))
3982 (let ((gnus-newsgroup-charset
3984 gnus-summary-show-article-charset-alist))
3985 (mm-read-coding-system "Charset: ")))
3986 (gnus-newsgroup-ignored-charsets 'gnus-all))
3987 (gnus-article-press-button)))))
3989 (defun gnus-mime-view-part-externally (&optional handle)
3990 "View the MIME part under point with an external viewer."
3992 (gnus-article-check-buffer)
3993 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3994 (mm-user-display-methods nil)
3995 (mm-inlined-types nil)
3996 (mail-parse-charset gnus-newsgroup-charset)
3997 (mail-parse-ignored-charsets
3998 (save-excursion (set-buffer gnus-summary-buffer)
3999 gnus-newsgroup-ignored-charsets)))
4001 (if (mm-handle-undisplayer handle)
4002 (mm-remove-part handle)
4003 (mm-display-part handle)))))
4005 (defun gnus-mime-view-part-internally (&optional handle)
4006 "View the MIME part under point with an internal viewer.
4007 If no internal viewer is available, use an external viewer."
4009 (gnus-article-check-buffer)
4010 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4011 (mm-inlined-types '(".*"))
4012 (mm-inline-large-images t)
4013 (mail-parse-charset gnus-newsgroup-charset)
4014 (mail-parse-ignored-charsets
4015 (save-excursion (set-buffer gnus-summary-buffer)
4016 gnus-newsgroup-ignored-charsets)))
4018 (if (mm-handle-undisplayer handle)
4019 (mm-remove-part handle)
4020 (mm-display-part handle)))))
4022 (defun gnus-mime-action-on-part (&optional action)
4023 "Do something with the MIME attachment at \(point\)."
4025 (list (completing-read "Action: " gnus-mime-action-alist)))
4026 (gnus-article-check-buffer)
4027 (let ((action-pair (assoc action gnus-mime-action-alist)))
4029 (funcall (cdr action-pair)))))
4031 (defun gnus-article-part-wrapper (n function)
4032 (save-current-buffer
4033 (set-buffer gnus-article-buffer)
4034 (when (> n (length gnus-article-mime-handle-alist))
4035 (error "No such part"))
4036 (gnus-article-goto-part n)
4037 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4038 (funcall function handle))))
4040 (defun gnus-article-pipe-part (n)
4041 "Pipe MIME part N, which is the numerical prefix."
4043 (gnus-article-part-wrapper n 'mm-pipe-part))
4045 (defun gnus-article-save-part (n)
4046 "Save MIME part N, which is the numerical prefix."
4048 (gnus-article-part-wrapper n 'mm-save-part))
4050 (defun gnus-article-interactively-view-part (n)
4051 "View MIME part N interactively, which is the numerical prefix."
4053 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4055 (defun gnus-article-copy-part (n)
4056 "Copy MIME part N, which is the numerical prefix."
4058 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4060 (defun gnus-article-view-part-as-charset (n)
4061 "Copy MIME part N, which is the numerical prefix."
4063 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4065 (defun gnus-article-view-part-externally (n)
4066 "View MIME part N externally, which is the numerical prefix."
4068 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4070 (defun gnus-article-inline-part (n)
4071 "Inline MIME part N, which is the numerical prefix."
4073 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4075 (defun gnus-article-mime-match-handle-first (condition)
4077 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4078 (while (setq ihandle (pop alist))
4080 ((functionp condition)
4081 (funcall condition (cdr ihandle)))
4082 ((eq condition 'undisplayed)
4083 (not (or (mm-handle-undisplayer (cdr ihandle))
4084 (equal (mm-handle-media-type (cdr ihandle))
4085 "multipart/alternative"))))
4086 ((eq condition 'undisplayed-alternative)
4087 (not (mm-handle-undisplayer (cdr ihandle))))
4089 (gnus-article-goto-part (car ihandle))
4090 (or (not n) (< (car ihandle) n)))
4091 (setq n (car ihandle))))
4095 (defun gnus-article-view-part (&optional n)
4096 "View MIME part N, which is the numerical prefix."
4098 (save-current-buffer
4099 (set-buffer gnus-article-buffer)
4100 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4101 gnus-article-mime-match-handle-function)))
4102 (when (> n (length gnus-article-mime-handle-alist))
4103 (error "No such part"))
4104 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4105 (when (gnus-article-goto-part n)
4106 (if (equal (car handle) "multipart/alternative")
4107 (gnus-article-press-button)
4108 (when (eq (gnus-mm-display-part handle) 'internal)
4109 (gnus-set-window-start)))))))
4111 (defsubst gnus-article-mime-total-parts ()
4112 (if (bufferp (car gnus-article-mime-handles))
4114 (1- (length gnus-article-mime-handles))))
4116 (defun gnus-mm-display-part (handle)
4117 "Display HANDLE and fix MIME button."
4118 (let ((id (get-text-property (point) 'gnus-part))
4123 (let ((window (selected-window))
4124 (mail-parse-charset gnus-newsgroup-charset)
4125 (mail-parse-ignored-charsets
4126 (if (gnus-buffer-live-p gnus-summary-buffer)
4128 (set-buffer gnus-summary-buffer)
4129 gnus-newsgroup-ignored-charsets)
4133 (let ((win (gnus-get-buffer-window (current-buffer) t))
4136 (select-window win))
4139 (if (mm-handle-displayed-p handle)
4140 ;; This will remove the part.
4141 (mm-display-part handle)
4143 (narrow-to-region (point)
4144 (if (eobp) (point) (1+ (point))))
4145 (mm-display-part handle)
4146 ;; We narrow to the part itself and
4147 ;; then call the treatment functions.
4148 (goto-char (point-min))
4150 (narrow-to-region (point) (point-max))
4153 (gnus-article-mime-total-parts)
4154 (mm-handle-media-type handle)))))
4155 (if (window-live-p window)
4156 (select-window window)))))
4158 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4159 (gnus-insert-mime-button
4160 handle id (list (mm-handle-displayed-p handle)))
4161 (goto-char point))))
4163 (defun gnus-article-goto-part (n)
4164 "Go to MIME part N."
4165 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4167 (goto-char point))))
4169 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4170 (let ((gnus-tmp-name
4171 (or (mail-content-type-get (mm-handle-type handle) 'name)
4172 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4173 (mail-content-type-get (mm-handle-type handle) 'url)
4175 (gnus-tmp-type (mm-handle-media-type handle))
4176 (gnus-tmp-description
4177 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4180 (if (if displayed (car displayed)
4181 (mm-handle-displayed-p handle))
4183 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4185 gnus-tmp-type-long b e)
4186 (when (string-match ".*/" gnus-tmp-name)
4187 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4188 (setq gnus-tmp-type-long (concat gnus-tmp-type
4189 (and (not (equal gnus-tmp-name ""))
4190 (concat "; " gnus-tmp-name))))
4191 (unless (equal gnus-tmp-description "")
4192 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4197 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4198 `(,@(gnus-local-map-property gnus-mime-button-map)
4199 gnus-callback gnus-mm-display-part
4200 gnus-part ,gnus-tmp-id
4201 article-type annotation
4204 (widget-convert-button
4207 :action 'gnus-widget-press-button
4208 :button-keymap gnus-mime-button-map
4210 (lambda (widget/window &optional overlay pos)
4211 ;; Needed to properly clear the message due to a bug in
4212 ;; wid-edit (XEmacs only).
4213 (if (boundp 'help-echo-owns-message)
4214 (setq help-echo-owns-message t))
4216 "%S: %s the MIME part; %S: more options"
4217 (aref gnus-mouse-2 0)
4218 ;; XEmacs will get a single widget arg; Emacs 21 will get
4219 ;; window, overlay, position.
4220 (if (mm-handle-displayed-p
4222 (with-current-buffer (gnus-overlay-buffer overlay)
4223 (widget-get (widget-at (gnus-overlay-start overlay))
4225 (widget-get widget/window :mime-handle)))
4227 (aref gnus-down-mouse-3 0))))))
4229 (defun gnus-widget-press-button (elems el)
4230 (goto-char (widget-get elems :from))
4231 (gnus-article-press-button))
4233 (defvar gnus-displaying-mime nil)
4235 (defun gnus-display-mime (&optional ihandles)
4236 "Display the MIME parts."
4238 (save-selected-window
4239 (let ((window (get-buffer-window gnus-article-buffer))
4242 (select-window window)
4243 ;; We have to do this since selecting the window
4244 ;; may change the point. So we set the window point.
4245 (set-window-point window point)))
4246 (let* ((handles (or ihandles (mm-dissect-buffer
4247 nil gnus-article-loose-mime)
4249 buffer-read-only handle name type b e display)
4250 (when (and (not ihandles)
4251 (not gnus-displaying-mime))
4252 ;; Top-level call; we clean up.
4253 (when gnus-article-mime-handles
4254 (mm-destroy-parts gnus-article-mime-handles)
4255 (setq gnus-article-mime-handle-alist nil));; A trick.
4256 (setq gnus-article-mime-handles handles)
4257 ;; We allow users to glean info from the handles.
4258 (when gnus-article-mime-part-function
4259 (gnus-mime-part-function handles)))
4261 (or (not (stringp (car handles)))
4264 (when (and (not ihandles)
4265 (not gnus-displaying-mime))
4266 ;; Clean up for mime parts.
4268 (delete-region (point) (point-max)))
4269 (let ((gnus-displaying-mime t))
4270 (gnus-mime-display-part handles)))
4273 (narrow-to-region (point) (point-max))
4274 (gnus-treat-article nil 1 1)
4277 ;; Highlight the headers.
4281 (narrow-to-region (point-min) (point))
4282 (gnus-treat-article 'head))))))))
4284 (defvar gnus-mime-display-multipart-as-mixed nil)
4285 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4286 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4288 (defun gnus-mime-display-part (handle)
4291 ((not (stringp (car handle)))
4292 (gnus-mime-display-single handle))
4293 ;; User-defined multipart
4294 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4295 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4297 ;; multipart/alternative
4298 ((and (equal (car handle) "multipart/alternative")
4299 (not (or gnus-mime-display-multipart-as-mixed
4300 gnus-mime-display-multipart-alternative-as-mixed)))
4301 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4302 (push (cons id handle) gnus-article-mime-handle-alist)
4303 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4304 ;; multipart/related
4305 ((and (equal (car handle) "multipart/related")
4306 (not (or gnus-mime-display-multipart-as-mixed
4307 gnus-mime-display-multipart-related-as-mixed)))
4308 ;;;!!!We should find the start part, but we just default
4309 ;;;!!!to the first part.
4310 ;;(gnus-mime-display-part (cadr handle))
4311 ;;;!!! Most multipart/related is an HTML message plus images.
4312 ;;;!!! Unfortunately we are unable to let W3 display those
4313 ;;;!!! included images, so we just display it as a mixed multipart.
4314 ;;(gnus-mime-display-mixed (cdr handle))
4315 ;;;!!! No, w3 can display everything just fine.
4316 (gnus-mime-display-part (cadr handle)))
4317 ((equal (car handle) "multipart/signed")
4318 (gnus-add-wash-type 'signed)
4319 (gnus-mime-display-security handle))
4320 ((equal (car handle) "multipart/encrypted")
4321 (gnus-add-wash-type 'encrypted)
4322 (gnus-mime-display-security handle))
4323 ;; Other multiparts are handled like multipart/mixed.
4325 (gnus-mime-display-mixed (cdr handle)))))
4327 (defun gnus-mime-part-function (handles)
4328 (if (stringp (car handles))
4329 (mapcar 'gnus-mime-part-function (cdr handles))
4330 (funcall gnus-article-mime-part-function handles)))
4332 (defun gnus-mime-display-mixed (handles)
4333 (mapcar 'gnus-mime-display-part handles))
4335 (defun gnus-mime-display-single (handle)
4336 (let ((type (mm-handle-media-type handle))
4337 (ignored gnus-ignored-mime-types)
4344 (when (string-match (pop ignored) type)
4345 (throw 'ignored nil)))
4346 (if (and (setq not-attachment
4347 (and (not (mm-inline-override-p handle))
4348 (or (not (mm-handle-disposition handle))
4349 (equal (car (mm-handle-disposition handle))
4351 (mm-attachment-override-p handle))))
4352 (mm-automatic-display-p handle)
4354 (mm-inlinable-p handle)
4355 (mm-inlined-p handle))
4356 (mm-automatic-external-display-p type)))
4358 (when (equal (mm-handle-media-supertype handle) "text")
4360 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4362 (push (cons id handle) gnus-article-mime-handle-alist)
4363 (when (or (not display)
4364 (not (gnus-unbuttonized-mime-type-p type)))
4365 ;(gnus-article-insert-newline)
4366 (gnus-insert-mime-button
4367 handle id (list (or display (and not-attachment text))))
4368 (gnus-article-insert-newline)
4369 ;(gnus-article-insert-newline)
4370 ;; Remember modify the number of forward lines.
4378 (let ((mail-parse-charset gnus-newsgroup-charset)
4379 (mail-parse-ignored-charsets
4380 (save-excursion (condition-case ()
4381 (set-buffer gnus-summary-buffer)
4383 gnus-newsgroup-ignored-charsets)))
4384 (mm-display-part handle t))
4385 (goto-char (point-max)))
4386 ((and text not-attachment)
4390 (gnus-article-insert-newline)
4391 (mm-insert-inline handle (mm-get-part handle))
4392 (goto-char (point-max))))
4396 (narrow-to-region beg (point))
4399 (gnus-article-mime-total-parts)
4400 (mm-handle-media-type handle)))))))))
4402 (defun gnus-unbuttonized-mime-type-p (type)
4403 "Say whether TYPE is to be unbuttonized."
4404 (unless gnus-inhibit-mime-unbuttonizing
4406 (let ((types gnus-unbuttonized-mime-types))
4408 (when (string-match (pop types) type)
4409 (throw 'found t)))))
4411 (let ((types gnus-buttonized-mime-types))
4413 (when (string-match (pop types) type)
4414 (throw 'found t)))))))))
4416 (defun gnus-article-insert-newline ()
4417 "Insert a newline, but mark it as undeletable."
4418 (gnus-put-text-property
4419 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4421 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4422 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4425 handle buffer-read-only from props begend not-pref)
4426 (save-window-excursion
4429 (narrow-to-region (car ibegend)
4432 (goto-char (car ibegend))
4435 (delete-region (point-min) (point-max))
4436 (mm-remove-parts handles))
4437 (setq begend (list (point-marker)))
4439 (unless (setq not-pref (cadr (member preferred ihandles)))
4440 (setq not-pref (car ihandles)))
4443 (not (gnus-unbuttonized-mime-type-p
4444 "multipart/alternative")))
4445 (gnus-add-text-properties
4448 (insert (format "%d. " id))
4452 (unless ,(not ibegend)
4453 (setq gnus-article-mime-handle-alist
4454 ',gnus-article-mime-handle-alist))
4455 (gnus-mime-display-alternative
4456 ',ihandles ',not-pref ',begend ,id))
4457 ,@(gnus-local-map-property gnus-mime-button-map)
4458 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4459 face ,gnus-article-button-face
4462 (widget-convert-button 'link from (point)
4463 :action 'gnus-widget-press-button
4464 :button-keymap gnus-widget-button-keymap)
4466 (while (setq handle (pop handles))
4467 (gnus-add-text-properties
4470 (insert (format "(%c) %-18s"
4471 (if (equal handle preferred) ?* ? )
4472 (mm-handle-media-type handle)))
4476 (unless ,(not ibegend)
4477 (setq gnus-article-mime-handle-alist
4478 ',gnus-article-mime-handle-alist))
4479 (gnus-mime-display-alternative
4480 ',ihandles ',handle ',begend ,id))
4481 ,@(gnus-local-map-property gnus-mime-button-map)
4482 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4483 face ,gnus-article-button-face
4486 (widget-convert-button 'link from (point)
4487 :action 'gnus-widget-press-button
4488 :button-keymap gnus-widget-button-keymap)
4492 (if (stringp (car preferred))
4493 (gnus-display-mime preferred)
4494 (let ((mail-parse-charset gnus-newsgroup-charset)
4495 (mail-parse-ignored-charsets
4496 (save-excursion (set-buffer gnus-summary-buffer)
4497 gnus-newsgroup-ignored-charsets)))
4498 (mm-display-part preferred)
4502 (narrow-to-region (car begend) (point-max))
4504 nil (length gnus-article-mime-handle-alist)
4505 (gnus-article-mime-total-parts)
4506 (mm-handle-media-type handle))))))
4507 (goto-char (point-max))
4508 (setcdr begend (point-marker)))))
4510 (goto-char point))))
4512 (defconst gnus-article-wash-status-strings
4513 (let ((alist '((cite "c" "Possible hidden citation text"
4514 " " "All citation text visible")
4515 (headers "h" "Hidden headers"
4516 " " "All headers visible.")
4517 (pgp "p" "Encrypted or signed message status hidden"
4518 " " "No hidden encryption nor digital signature status")
4519 (signature "s" "Signature has been hidden"
4520 " " "Signature is visible")
4521 (overstrike "o" "Overstrike (^H) characters applied"
4522 " " "No overstrike characters applied")
4523 (emphasis "e" "/*_Emphasis_*/ characters applied"
4524 " " "No /*_emphasis_*/ characters applied")))
4526 (dolist (entry alist result)
4527 (let ((key (nth 0 entry))
4528 (on (copy-sequence (nth 1 entry)))
4529 (on-help (nth 2 entry))
4530 (off (copy-sequence (nth 3 entry)))
4531 (off-help (nth 4 entry)))
4532 (put-text-property 0 1 'help-echo on-help on)
4533 (put-text-property 0 1 'help-echo off-help off)
4534 (push (list key on off) result))))
4535 "Alist of strings describing wash status in the mode line.
4536 Each entry has the form (KEY ON OF), where the KEY is a symbol
4537 representing the particular washing function, ON is the string to use
4538 in the article mode line when the washing function is active, and OFF
4539 is the string to use when it is inactive.")
4541 (defun gnus-article-wash-status-entry (key value)
4542 (let ((entry (assoc key gnus-article-wash-status-strings)))
4543 (if value (nth 1 entry) (nth 2 entry))))
4545 (defun gnus-article-wash-status ()
4546 "Return a string which display status of article washing."
4548 (set-buffer gnus-article-buffer)
4549 (let ((cite (memq 'cite gnus-article-wash-types))
4550 (headers (memq 'headers gnus-article-wash-types))
4551 (boring (memq 'boring-headers gnus-article-wash-types))
4552 (pgp (memq 'pgp gnus-article-wash-types))
4553 (pem (memq 'pem gnus-article-wash-types))
4554 (signed (memq 'signed gnus-article-wash-types))
4555 (encrypted (memq 'encrypted gnus-article-wash-types))
4556 (signature (memq 'signature gnus-article-wash-types))
4557 (overstrike (memq 'overstrike gnus-article-wash-types))
4558 (emphasis (memq 'emphasis gnus-article-wash-types)))
4560 (gnus-article-wash-status-entry 'cite cite)
4561 (gnus-article-wash-status-entry 'headers (or headers boring))
4562 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4563 (gnus-article-wash-status-entry 'signature signature)
4564 (gnus-article-wash-status-entry 'overstrike overstrike)
4565 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4567 (defun gnus-add-wash-type (type)
4568 "Add a washing of TYPE to the current status."
4569 (add-to-list 'gnus-article-wash-types type))
4571 (defun gnus-delete-wash-type (type)
4572 "Add a washing of TYPE to the current status."
4573 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4575 (defun gnus-add-image (category image)
4576 "Add IMAGE of CATEGORY to the list of displayed images."
4577 (let ((entry (assq category gnus-article-image-alist)))
4579 (setq entry (list category))
4580 (push entry gnus-article-image-alist))
4581 (nconc entry (list image))))
4583 (defun gnus-delete-images (category)
4584 "Delete all images in CATEGORY."
4585 (let ((entry (assq category gnus-article-image-alist)))
4586 (dolist (image (cdr entry))
4587 (gnus-remove-image image))
4588 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4589 (gnus-delete-wash-type category)))
4591 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4593 (defun gnus-article-maybe-hide-headers ()
4594 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4595 Provided for backwards compatibility."
4596 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4597 (not (save-excursion (set-buffer gnus-summary-buffer)
4598 gnus-have-all-headers)))
4599 (not gnus-inhibit-hiding))
4600 (gnus-article-hide-headers)))
4604 (defun gnus-output-to-file (file-name)
4605 "Append the current article to a file named FILE-NAME."
4606 (let ((artbuf (current-buffer)))
4608 (insert-buffer-substring artbuf)
4609 ;; Append newline at end of the buffer as separator, and then
4611 (goto-char (point-max))
4613 (let ((file-name-coding-system nnmail-pathname-coding-system))
4614 (mm-append-to-file (point-min) (point-max) file-name))
4617 (defun gnus-narrow-to-page (&optional arg)
4618 "Narrow the article buffer to a page.
4619 If given a numerical ARG, move forward ARG pages."
4621 (setq arg (if arg (prefix-numeric-value arg) 0))
4623 (set-buffer gnus-article-buffer)
4624 (goto-char (point-min))
4626 ;; Remove any old next/prev buttons.
4627 (when (gnus-visual-p 'page-marker)
4628 (let ((buffer-read-only nil))
4629 (gnus-remove-text-with-property 'gnus-prev)
4630 (gnus-remove-text-with-property 'gnus-next)))
4633 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4635 (re-search-forward page-delimiter nil 'move arg)))
4636 (goto-char (match-end 0)))
4639 (if (re-search-forward page-delimiter nil 'move)
4642 (when (and (gnus-visual-p 'page-marker)
4643 (not (= (point-min) 1)))
4645 (goto-char (point-min))
4646 (gnus-insert-prev-page-button)))
4647 (when (and (gnus-visual-p 'page-marker)
4648 (< (+ (point-max) 2) (buffer-size)))
4650 (goto-char (point-max))
4651 (gnus-insert-next-page-button)))))
4653 ;; Article mode commands
4655 (defun gnus-article-goto-next-page ()
4656 "Show the next page of the article."
4658 (when (gnus-article-next-page)
4659 (goto-char (point-min))
4660 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4662 (defun gnus-article-goto-prev-page ()
4663 "Show the next page of the article."
4665 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4666 (gnus-article-prev-page nil)))
4668 (defun gnus-article-next-page (&optional lines)
4669 "Show the next page of the current article.
4670 If end of article, return non-nil. Otherwise return nil.
4671 Argument LINES specifies lines to be scrolled up."
4673 (move-to-window-line -1)
4676 (and (pos-visible-in-window-p) ;Not continuation line.
4678 ;; Nothing in this page.
4679 (if (or (not gnus-page-broken)
4682 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4684 (gnus-narrow-to-page 1) ;Go to next page.
4686 ;; More in this page.
4687 (let ((scroll-in-place nil))
4691 ;; Long lines may cause an end-of-buffer error.
4692 (goto-char (point-max)))))
4693 (move-to-window-line 0)
4696 (defun gnus-article-prev-page (&optional lines)
4697 "Show previous page of current article.
4698 Argument LINES specifies lines to be scrolled down."
4700 (move-to-window-line 0)
4701 (if (and gnus-page-broken
4703 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4705 (gnus-narrow-to-page -1) ;Go to previous page.
4706 (goto-char (point-max))
4708 (let ((scroll-in-place nil))
4712 (beginning-of-buffer
4713 (goto-char (point-min))))
4714 (move-to-window-line 0)))))
4716 (defun gnus-article-refer-article ()
4717 "Read article specified by message-id around point."
4719 (let ((point (point)))
4720 (search-forward ">" nil t) ;Move point to end of "<....>".
4721 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4722 (let ((message-id (match-string 1)))
4724 (set-buffer gnus-summary-buffer)
4725 (gnus-summary-refer-article message-id))
4727 (error "No references around point"))))
4729 (defun gnus-article-show-summary ()
4730 "Reconfigure windows to show summary buffer."
4732 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4733 (error "There is no summary buffer for this article buffer")
4734 (gnus-article-set-globals)
4735 (gnus-configure-windows 'article)
4736 (gnus-summary-goto-subject gnus-current-article)
4737 (gnus-summary-position-point)))
4739 (defun gnus-article-describe-briefly ()
4740 "Describe article mode commands briefly."
4742 (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")))
4744 (defun gnus-article-summary-command ()
4745 "Execute the last keystroke in the summary buffer."
4747 (let ((obuf (current-buffer))
4748 (owin (current-window-configuration))
4750 (switch-to-buffer gnus-article-current-summary 'norecord)
4751 (setq func (lookup-key (current-local-map) (this-command-keys)))
4752 (call-interactively func)
4754 (set-window-configuration owin)
4755 (set-window-point (get-buffer-window (current-buffer)) (point))))
4757 (defun gnus-article-summary-command-nosave ()
4758 "Execute the last keystroke in the summary buffer."
4761 (pop-to-buffer gnus-article-current-summary 'norecord)
4762 (setq func (lookup-key (current-local-map) (this-command-keys)))
4763 (call-interactively func)))
4765 (defun gnus-article-check-buffer ()
4766 "Beep if not in an article buffer."
4767 (unless (equal major-mode 'gnus-article-mode)
4768 (error "Command invoked outside of a Gnus article buffer")))
4770 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4771 "Read a summary buffer key sequence and execute it from the article buffer."
4773 (gnus-article-check-buffer)
4775 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4776 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4777 "=" "^" "\M-^" "|"))
4783 '("n" "Gn" "p" "Gp"))
4786 (set-buffer gnus-article-current-summary)
4787 (let (gnus-pick-mode)
4788 (push (or key last-command-event) unread-command-events)
4789 (setq keys (if (featurep 'xemacs)
4790 (events-to-keys (read-key-sequence nil))
4791 (read-key-sequence nil)))))
4795 (if (or (member keys nosaves)
4796 (member keys nosave-but-article)
4797 (member keys nosave-in-article))
4799 (save-window-excursion
4800 (pop-to-buffer gnus-article-current-summary 'norecord)
4801 ;; We disable the pick minor mode commands.
4802 (let (gnus-pick-mode)
4803 (setq func (lookup-key (current-local-map) keys))))
4807 (unless (member keys nosave-in-article)
4808 (set-buffer gnus-article-current-summary))
4809 (call-interactively func)
4810 (setq new-sum-point (point)))
4811 (when (member keys nosave-but-article)
4812 (pop-to-buffer gnus-article-buffer 'norecord)))
4813 ;; These commands should restore window configuration.
4814 (let ((obuf (current-buffer))
4815 (owin (current-window-configuration))
4817 (summary gnus-article-current-summary)
4818 func in-buffer selected)
4819 (if not-restore-window
4820 (pop-to-buffer summary 'norecord)
4821 (switch-to-buffer summary 'norecord))
4822 (setq in-buffer (current-buffer))
4823 ;; We disable the pick minor mode commands.
4824 (if (and (setq func (let (gnus-pick-mode)
4825 (lookup-key (current-local-map) keys)))
4828 (call-interactively func)
4829 (setq new-sum-point (point))
4830 (when (eq in-buffer (current-buffer))
4831 (setq selected (gnus-summary-select-article))
4833 (unless not-restore-window
4834 (set-window-configuration owin))
4835 (when (eq selected 'old)
4837 (set-window-start (get-buffer-window (current-buffer))
4839 (set-window-point (get-buffer-window (current-buffer))
4841 (let ((win (get-buffer-window gnus-article-current-summary)))
4843 (set-window-point win new-sum-point)))) )
4844 (switch-to-buffer gnus-article-buffer)
4847 (defun gnus-article-describe-key (key)
4848 "Display documentation of the function invoked by KEY. KEY is a string."
4849 (interactive "kDescribe key: ")
4850 (gnus-article-check-buffer)
4851 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4853 (set-buffer gnus-article-current-summary)
4854 (let (gnus-pick-mode)
4855 (if (featurep 'xemacs)
4857 (push (elt key 0) unread-command-events)
4858 (setq key (events-to-keys
4859 (read-key-sequence "Describe key: "))))
4860 (setq unread-command-events
4862 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4863 (string-to-list key)))
4864 (setq key (read-key-sequence "Describe key: "))))
4866 (describe-key key)))
4868 (defun gnus-article-describe-key-briefly (key &optional insert)
4869 "Display documentation of the function invoked by KEY. KEY is a string."
4870 (interactive "kDescribe key: \nP")
4871 (gnus-article-check-buffer)
4872 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4874 (set-buffer gnus-article-current-summary)
4875 (let (gnus-pick-mode)
4876 (if (featurep 'xemacs)
4878 (push (elt key 0) unread-command-events)
4879 (setq key (events-to-keys
4880 (read-key-sequence "Describe key: "))))
4881 (setq unread-command-events
4883 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4884 (string-to-list key)))
4885 (setq key (read-key-sequence "Describe key: "))))
4886 (describe-key-briefly key insert))
4887 (describe-key-briefly key insert)))
4889 (defun gnus-article-reply-with-original (&optional wide)
4890 "Start composing a reply mail to the current message.
4891 The text in the region will be yanked. If the region isn't active,
4892 the entire article will be yanked."
4894 (let ((article (cdr gnus-article-current)) cont)
4896 (with-current-buffer gnus-summary-buffer
4897 (gnus-summary-reply (list (list article)) wide))
4898 (setq cont (buffer-substring (point) (mark t)))
4899 ;; Deactivate active regions.
4900 (when (and (boundp 'transient-mark-mode)
4901 transient-mark-mode)
4902 (setq mark-active nil))
4903 (with-current-buffer gnus-summary-buffer
4905 (list (list article cont)) wide)))))
4907 (defun gnus-article-followup-with-original ()
4908 "Compose a followup to the current article.
4909 The text in the region will be yanked. If the region isn't active,
4910 the entire article will be yanked."
4912 (let ((article (cdr gnus-article-current)) cont)
4914 (with-current-buffer gnus-summary-buffer
4915 (gnus-summary-followup (list (list article))))
4916 (setq cont (buffer-substring (point) (mark t)))
4917 ;; Deactivate active regions.
4918 (when (and (boundp 'transient-mark-mode)
4919 transient-mark-mode)
4920 (setq mark-active nil))
4921 (with-current-buffer gnus-summary-buffer
4922 (gnus-summary-followup
4923 (list (list article cont)))))))
4925 (defun gnus-article-hide (&optional arg force)
4926 "Hide all the gruft in the current article.
4927 This means that PGP stuff, signatures, cited text and (some)
4928 headers will be hidden.
4929 If given a prefix, show the hidden text instead."
4930 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4931 (gnus-article-hide-headers arg)
4932 (gnus-article-hide-list-identifiers arg)
4933 (gnus-article-hide-pgp arg)
4934 (gnus-article-hide-citation-maybe arg force)
4935 (gnus-article-hide-signature arg))
4937 (defun gnus-article-maybe-highlight ()
4938 "Do some article highlighting if article highlighting is requested."
4939 (when (gnus-visual-p 'article-highlight 'highlight)
4940 (gnus-article-highlight-some)))
4942 (defun gnus-check-group-server ()
4943 ;; Make sure the connection to the server is alive.
4944 (unless (gnus-server-opened
4945 (gnus-find-method-for-group gnus-newsgroup-name))
4946 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4947 (gnus-request-group gnus-newsgroup-name t)))
4950 (autoload 'nneething-get-file-name "nneething"))
4952 (defun gnus-request-article-this-buffer (article group)
4953 "Get an article and insert it into this buffer."
4954 (let (do-update-line sparse-header)
4958 (gnus-kill-all-overlays)
4959 (setq group (or group gnus-newsgroup-name))
4961 ;; Using `gnus-request-article' directly will insert the article into
4962 ;; `nntp-server-buffer' - so we'll save some time by not having to
4963 ;; copy it from the server buffer into the article buffer.
4965 ;; We only request an article by message-id when we do not have the
4966 ;; headers for it, so we'll have to get those.
4967 (when (stringp article)
4968 (gnus-read-header article))
4970 ;; If the article number is negative, that means that this article
4971 ;; doesn't belong in this newsgroup (possibly), so we find its
4972 ;; message-id and request it by id instead of number.
4973 (when (and (numberp article)
4975 (get-buffer gnus-summary-buffer)
4976 (gnus-buffer-exists-p gnus-summary-buffer))
4978 (set-buffer gnus-summary-buffer)
4979 (let ((header (gnus-summary-article-header article)))
4982 ((memq article gnus-newsgroup-sparse)
4983 ;; This is a sparse gap article.
4984 (setq do-update-line article)
4985 (setq article (mail-header-id header))
4986 (setq sparse-header (gnus-read-header article))
4987 (setq gnus-newsgroup-sparse
4988 (delq article gnus-newsgroup-sparse)))
4990 ;; It's a real article.
4991 (setq article (mail-header-id header)))
4993 ;; It is an extracted pseudo-article.
4994 (setq article 'pseudo)
4995 (gnus-request-pseudo-article header))))
4997 (let ((method (gnus-find-method-for-group
4998 gnus-newsgroup-name)))
4999 (when (and (eq (car method) 'nneething)
5001 (let ((dir (nneething-get-file-name
5002 (mail-header-id header))))
5003 (when (and (stringp dir)
5004 (file-directory-p dir))
5005 (setq article 'nneething)
5006 (gnus-group-enter-directory dir))))))))
5009 ;; Refuse to select canceled articles.
5010 ((and (numberp article)
5012 (get-buffer gnus-summary-buffer)
5013 (gnus-buffer-exists-p gnus-summary-buffer)
5014 (eq (cdr (save-excursion
5015 (set-buffer gnus-summary-buffer)
5016 (assq article gnus-newsgroup-reads)))
5017 gnus-canceled-mark))
5019 ;; We first check `gnus-original-article-buffer'.
5020 ((and (get-buffer gnus-original-article-buffer)
5023 (set-buffer gnus-original-article-buffer)
5024 (and (equal (car gnus-original-article) group)
5025 (eq (cdr gnus-original-article) article))))
5026 (insert-buffer-substring gnus-original-article-buffer)
5028 ;; Check the backlog.
5029 ((and gnus-keep-backlog
5030 (gnus-backlog-request-article group article (current-buffer)))
5032 ;; Check asynchronous pre-fetch.
5033 ((gnus-async-request-fetched-article group article (current-buffer))
5034 (gnus-async-prefetch-next group article gnus-summary-buffer)
5035 (when (and (numberp article) gnus-keep-backlog)
5036 (gnus-backlog-enter-article group article (current-buffer)))
5039 ((and gnus-use-cache
5041 (gnus-cache-request-article article group))
5043 ;; Check the agent cache.
5044 ((and gnus-agent gnus-agent-cache gnus-plugged
5046 (gnus-agent-request-article article group))
5048 ;; Get the article and put into the article buffer.
5049 ((or (stringp article)
5051 (let ((gnus-override-method gnus-override-method)
5052 (methods (and (stringp article)
5053 gnus-refer-article-method))
5054 (backend (car (gnus-find-method-for-group
5055 gnus-newsgroup-name)))
5057 (buffer-read-only nil))
5058 (if (or (not (listp methods))
5059 (and (symbolp (car methods))
5060 (assq (car methods) nnoo-definition-alist)))
5061 (setq methods (list methods)))
5062 (when (and (null gnus-override-method)
5064 (setq gnus-override-method (pop methods)))
5066 (when (eq gnus-override-method 'current)
5067 (setq gnus-override-method
5068 (with-current-buffer gnus-summary-buffer
5069 gnus-current-select-method)))
5071 (gnus-kill-all-overlays)
5072 (let ((gnus-newsgroup-name group))
5073 (gnus-check-group-server))
5075 ((gnus-request-article article group (current-buffer))
5076 (when (numberp article)
5077 (gnus-async-prefetch-next group article
5078 gnus-summary-buffer)
5079 (when gnus-keep-backlog
5080 (gnus-backlog-enter-article
5081 group article (current-buffer))))
5082 (setq result 'article))
5084 (setq gnus-override-method (pop methods)))
5085 ((not (string-match "^400 "
5086 (nnheader-get-report backend)))
5087 ;; If we get 400 server disconnect, reconnect and
5088 ;; retry; otherwise, assume the article has expired.
5089 (setq result 'done))))
5090 (and (eq result 'article) 'article)))
5094 ;; Associate this article with the current summary buffer.
5095 (setq gnus-article-current-summary gnus-summary-buffer)
5097 ;; Take the article from the original article buffer
5098 ;; and place it in the buffer it's supposed to be in.
5099 (when (and (get-buffer gnus-article-buffer)
5100 (equal (buffer-name (current-buffer))
5101 (buffer-name (get-buffer gnus-article-buffer))))
5103 (if (get-buffer gnus-original-article-buffer)
5104 (set-buffer gnus-original-article-buffer)
5105 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5106 (buffer-disable-undo)
5107 (setq major-mode 'gnus-original-article-mode)
5108 (setq buffer-read-only t))
5109 (let (buffer-read-only)
5111 (insert-buffer-substring gnus-article-buffer))
5112 (setq gnus-original-article (cons group article)))
5115 (run-hooks 'gnus-article-decode-hook)
5116 ;; Mark article as decoded or not.
5117 (setq gnus-article-decoded-p gnus-article-decode-hook))
5119 ;; Update sparse articles.
5120 (when (and do-update-line
5121 (or (numberp article)
5123 (let ((buf (current-buffer)))
5124 (set-buffer gnus-summary-buffer)
5125 (gnus-summary-update-article do-update-line sparse-header)
5126 (gnus-summary-goto-subject do-update-line nil t)
5127 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5129 (set-buffer buf))))))
5135 (defcustom gnus-article-edit-mode-hook nil
5136 "Hook run in article edit mode buffers."
5137 :group 'gnus-article-various
5140 (defvar gnus-article-edit-done-function nil)
5142 (defvar gnus-article-edit-mode-map nil)
5143 (defvar gnus-article-edit-mode nil)
5145 ;; Should we be using derived.el for this?
5146 (unless gnus-article-edit-mode-map
5147 (setq gnus-article-edit-mode-map (make-keymap))
5148 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5150 (gnus-define-keys gnus-article-edit-mode-map
5151 "\C-c?" describe-mode
5152 "\C-c\C-c" gnus-article-edit-done
5153 "\C-c\C-k" gnus-article-edit-exit
5154 "\C-c\C-f\C-t" message-goto-to
5155 "\C-c\C-f\C-o" message-goto-from
5156 "\C-c\C-f\C-b" message-goto-bcc
5157 ;;"\C-c\C-f\C-w" message-goto-fcc
5158 "\C-c\C-f\C-c" message-goto-cc
5159 "\C-c\C-f\C-s" message-goto-subject
5160 "\C-c\C-f\C-r" message-goto-reply-to
5161 "\C-c\C-f\C-n" message-goto-newsgroups
5162 "\C-c\C-f\C-d" message-goto-distribution
5163 "\C-c\C-f\C-f" message-goto-followup-to
5164 "\C-c\C-f\C-m" message-goto-mail-followup-to
5165 "\C-c\C-f\C-k" message-goto-keywords
5166 "\C-c\C-f\C-u" message-goto-summary
5167 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5168 "\C-c\C-f\C-a" message-gen-unsubscribed-mft
5169 "\C-c\C-b" message-goto-body
5170 "\C-c\C-i" message-goto-signature
5172 "\C-c\C-t" message-insert-to
5173 "\C-c\C-n" message-insert-newsgroups
5174 "\C-c\C-o" message-sort-headers
5175 "\C-c\C-e" message-elide-region
5176 "\C-c\C-v" message-delete-not-region
5177 "\C-c\C-z" message-kill-to-signature
5178 "\M-\r" message-newline-and-reformat
5179 "\C-c\C-a" mml-attach-file
5180 "\C-a" message-beginning-of-line
5182 "\M-;" comment-region)
5184 (gnus-define-keys (gnus-article-edit-wash-map
5185 "\C-c\C-w" gnus-article-edit-mode-map)
5186 "f" gnus-article-edit-full-stops))
5189 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5191 ["Fetch To" message-insert-to t]
5192 ["Fetch Newsgroups" message-insert-newsgroups t]
5194 ["To" message-goto-to t]
5195 ["From" message-goto-from t]
5196 ["Subject" message-goto-subject t]
5197 ["Cc" message-goto-cc t]
5198 ["Reply-To" message-goto-reply-to t]
5199 ["Summary" message-goto-summary t]
5200 ["Keywords" message-goto-keywords t]
5201 ["Newsgroups" message-goto-newsgroups t]
5202 ["Followup-To" message-goto-followup-to t]
5203 ["Mail-Followup-To" message-goto-mail-followup-to t]
5204 ["Distribution" message-goto-distribution t]
5205 ["Body" message-goto-body t]
5206 ["Signature" message-goto-signature t]))
5208 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5209 "Major mode for editing articles.
5210 This is an extended text-mode.
5212 \\{gnus-article-edit-mode-map}"
5213 (make-local-variable 'gnus-article-edit-done-function)
5214 (make-local-variable 'gnus-prev-winconf)
5215 (set (make-local-variable 'font-lock-defaults)
5216 '(message-font-lock-keywords t))
5217 (set (make-local-variable 'mail-header-separator) "")
5218 (set (make-local-variable 'gnus-article-edit-mode) t)
5219 (easy-menu-add message-mode-field-menu message-mode-map)
5221 (setq buffer-read-only nil)
5222 (buffer-enable-undo)
5225 (defun gnus-article-edit (&optional force)
5226 "Edit the current article.
5227 This will have permanent effect only in mail groups.
5228 If FORCE is non-nil, allow editing of articles even in read-only
5231 (when (and (not force)
5232 (gnus-group-read-only-p))
5233 (error "The current newsgroup does not support article editing"))
5234 (gnus-article-date-original)
5235 (gnus-article-edit-article
5237 `(lambda (no-highlight)
5239 (gnus-summary-edit-article-done
5240 ,(or (mail-header-references gnus-current-headers) "")
5241 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5243 (defun gnus-article-edit-article (start-func exit-func)
5244 "Start editing the contents of the current article buffer."
5245 (let ((winconf (current-window-configuration)))
5246 (set-buffer gnus-article-buffer)
5247 (gnus-article-edit-mode)
5248 (funcall start-func)
5249 (set-buffer-modified-p nil)
5250 (gnus-configure-windows 'edit-article)
5251 (setq gnus-article-edit-done-function exit-func)
5252 (setq gnus-prev-winconf winconf)
5253 (gnus-message 6 "C-c C-c to end edits")))
5255 (defun gnus-article-edit-done (&optional arg)
5256 "Update the article edits and exit."
5258 (let ((func gnus-article-edit-done-function)
5259 (buf (current-buffer))
5260 (start (window-start))
5262 (winconf gnus-prev-winconf))
5263 (widen) ;; Widen it in case that users narrowed the buffer.
5266 ;; The cache and backlog have to be flushed somewhat.
5267 (when gnus-keep-backlog
5268 (gnus-backlog-remove-article
5269 (car gnus-article-current) (cdr gnus-article-current)))
5270 ;; Flush original article as well.
5272 (when (get-buffer gnus-original-article-buffer)
5273 (set-buffer gnus-original-article-buffer)
5274 (setq gnus-original-article nil)))
5275 (when gnus-use-cache
5276 (gnus-cache-update-article
5277 (car gnus-article-current) (cdr gnus-article-current)))
5278 ;; We remove all text props from the article buffer.
5279 (kill-all-local-variables)
5280 (gnus-set-text-properties (point-min) (point-max) nil)
5282 (set-window-configuration winconf)
5284 (set-window-start (get-buffer-window buf) start)
5285 (set-window-point (get-buffer-window buf) (point))))
5287 (defun gnus-article-edit-exit ()
5288 "Exit the article editing without updating."
5290 (when (or (not (buffer-modified-p))
5291 (yes-or-no-p "Article modified; kill anyway? "))
5292 (let ((curbuf (current-buffer))
5294 (window-start (window-start)))
5296 (if (gnus-buffer-live-p gnus-original-article-buffer)
5297 (insert-buffer gnus-original-article-buffer))
5298 (let ((winconf gnus-prev-winconf))
5299 (kill-all-local-variables)
5301 (set-window-configuration winconf)
5302 ;; Tippy-toe some to make sure that point remains where it was.
5303 (save-current-buffer
5305 (set-window-start (get-buffer-window (current-buffer)) window-start)
5308 (defun gnus-article-edit-full-stops ()
5309 "Interactively repair spacing at end of sentences."
5312 (goto-char (point-min))
5313 (search-forward-regexp "^$" nil t)
5314 (let ((case-fold-search nil))
5315 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5318 ;;; Article highlights
5321 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5323 ;;; Internal Variables:
5325 (defcustom gnus-button-url-regexp
5326 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5327 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?[-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,[:word:]]+[-a-zA-Z0-9_=#$@~`%&*+|\\/[:word:]]\\)"
5328 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?\\([-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)\\)")
5329 "Regular expression that matches URLs."
5330 :group 'gnus-article-buttons
5333 (defcustom gnus-button-valid-fqdn-regexp
5334 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
5336 "\\([a-z][a-z]" ;; two letter country TDLs
5337 "\\|biz\\|com\\|edu\\|gov\\|int\\|mil\\|net\\|org"
5338 "\\|aero\\|coop\\|info\\|name\\|museum"
5339 "\\|arpa\\|pro\\|uucp\\|bitnet\\|bofh" ;; old style?
5341 "Regular expression that matches a valid FQDN."
5342 :group 'gnus-article-buttons
5345 (defcustom gnus-button-man-handler 'manual-entry
5346 "Function to use for displaying man pages.
5347 The function must take at least one argument with a string naming the
5349 :type '(choice (function-item :tag "Man" manual-entry)
5350 (function-item :tag "Woman" woman)
5351 (function :tag "Other"))
5352 :group 'gnus-article-buttons)
5354 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5355 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5356 If the default site is too slow, try to find a CTAN mirror, see
5357 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5358 the variable `gnus-button-handle-ctan'."
5359 :group 'gnus-article-buttons
5360 :link '(custom-manual "(gnus)Group Parameters")
5361 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5362 (const "http://tug.ctan.org/tex-archive/")
5363 (const "http://www.dante.de/CTAN/")
5364 (string :tag "Other")))
5366 (defcustom gnus-button-ctan-handler 'browse-url
5367 "Function to use for displaying CTAN links.
5368 The function must take one argument, the string naming the URL."
5369 :type '(choice (function-item :tag "Browse Url" browse-url)
5370 (function :tag "Other"))
5371 :group 'gnus-article-buttons)
5373 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5374 "Bogus strings removed from CTAN URLs."
5375 :group 'gnus-article-buttons
5376 :type '(choice (const "^/?tex-archive/\\|/")
5377 (regexp :tag "Other")))
5379 (defcustom gnus-button-mid-or-mail-regexp
5380 (concat "\\b\\(<?[a-zA-Z0-9][^<>\")!;:,{}\n\t ]*@"
5381 gnus-button-valid-fqdn-regexp
5383 "Regular expression that matches a message ID or a mail address."
5384 :group 'gnus-article-buttons
5387 (defcustom gnus-button-prefer-mid-or-mail 'guess
5388 "What to do when the button on a string as \"foo123@bar.com\" is pushed.
5389 Strings like this can be either a message ID or a mail address. If the
5390 variable is set to the symbol `ask', query the user what do do. If it is the
5391 symbol `guess', Gnus will do a guess and query the user what do do if it is
5392 ambiguous. See the variable `gnus-button-guessed-mid-regexp' for details
5393 concerning the guessing. If it is one of the sybols `mid' or `mail', Gnus
5394 will always assume that the string is a message ID or a mail address,
5396 ;; FIXME: doc-string could/should be improved.
5397 :group 'gnus-article-buttons
5398 :type '(choice (const ask)
5403 (defcustom gnus-button-guessed-mid-regexp
5405 "^<?\\(slrn\\|Pine\\.\\)"
5406 "\\|\\.fsf@\\|\\.fsf_-_@\\|\\.ln@"
5407 "\\|@4ax\\.com\\|@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de"
5408 "\\|^<?.*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*@")
5409 "Regular expression that matches message IDs and not mail addresses."
5410 ;; TODO: Incorporate more matches from
5411 ;; <URL:http://piology.org/perl/id-or-mail.pl.html>. I.e. translate the
5412 ;; Perl-REs to Elisp-REs.
5413 :group 'gnus-article-buttons
5416 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5417 (let* ((pref gnus-button-prefer-mid-or-mail)
5418 (url-mid (concat "news" ":" mid-or-mail))
5419 (url-mailto (concat "mailto" ":" mid-or-mail)))
5420 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5421 ;; If it looks like a MID (well known readers or servers) use 'mid,
5422 ;; otherwise 'ask the user.
5423 (if (eq pref 'guess)
5424 (if (string-match gnus-button-guessed-mid-regexp mid-or-mail)
5428 (save-window-excursion
5429 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5432 (cond ((eq pref 'mid)
5433 (gnus-message 9 "calling `gnus-button-handle-news' %s" url-mid)
5434 (gnus-button-handle-news url-mid))
5436 (gnus-message 9 "calling `gnus-url-mailto' %s" url-mailto)
5437 (gnus-url-mailto url-mailto)))))
5439 (defun gnus-button-handle-custom (url)
5440 "Follow a Custom URL."
5441 (customize-apropos (gnus-url-unhex-string url)))
5443 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5445 (defun gnus-button-handle-describe-function (url)
5446 "Call describe-function when pushing the corresponding URL button."
5449 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5451 (defun gnus-button-handle-describe-variable (url)
5452 "Call describe-variable when pushing the corresponding URL button."
5455 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5457 ;; FIXME: Is is possible to implement this? Else it should be removed here
5458 ;; and in `gnus-button-alist'.
5459 (defun gnus-button-handle-describe-key (url)
5460 "Call describe-key when pushing the corresponding URL button."
5461 (error "not implemented"))
5463 (defun gnus-button-handle-apropos (url)
5464 "Call apropos when pushing the corresponding URL button."
5465 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5467 (defun gnus-button-handle-apropos-command (url)
5468 "Call apropos when pushing the corresponding URL button."
5470 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5472 (defun gnus-button-handle-apropos-variable (url)
5473 "Call apropos when pushing the corresponding URL button."
5475 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5476 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5478 (defun gnus-button-handle-apropos-documentation (url)
5479 "Call apropos when pushing the corresponding URL button."
5481 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
5482 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5484 (defun gnus-button-handle-ctan (url)
5485 "Call `browse-url' when pushing a CTAN URL button."
5487 gnus-button-ctan-handler
5490 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
5492 (defcustom gnus-button-tex-level 5
5493 "*Integer that says how many TeX-related buttons Gnus will show.
5494 The higher the number, the more buttons will appear and the more false
5495 positives are possible. Note that you can set this variable local to
5496 specifific groups. Setting it higher in TeX groups is probably a good idea.
5497 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5498 how to set variables in specific groups."
5499 :group 'gnus-article-buttons
5500 :link '(custom-manual "(gnus)Group Parameters")
5503 (defcustom gnus-button-man-level 5
5504 "*Integer that says how many man-related buttons Gnus will show.
5505 The higher the number, the more buttons will appear and the more false
5506 positives are possible. Note that you can set this variable local to
5507 specifific groups. Setting it higher in Unix groups is probably a good idea.
5508 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5509 how to set variables in specific groups."
5510 :group 'gnus-article-buttons
5511 :link '(custom-manual "(gnus)Group Parameters")
5514 (defcustom gnus-button-emacs-level 5
5515 "*Integer that says how many emacs-related buttons Gnus will show.
5516 The higher the number, the more buttons will appear and the more false
5517 positives are possible. Note that you can set this variable local to
5518 specifific groups. Setting it higher in Emacs or Gnus related groups is
5519 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
5520 `gnus-parameters' on how to set variables in specific groups."
5521 :group 'gnus-article-buttons
5522 :link '(custom-manual "(gnus)Group Parameters")
5525 (defcustom gnus-button-mail-level 5
5526 "*Integer that says how many buttons for message IDs or mail addresses will appear.
5527 The higher the number, the more buttons will appear and the more false
5528 positives are possible."
5529 :group 'gnus-article-buttons
5532 (defcustom gnus-button-alist
5533 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5534 0 t gnus-button-handle-news 3)
5535 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5536 gnus-button-handle-news 2)
5537 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5539 gnus-button-fetch-group 4)
5540 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5541 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5542 t gnus-button-message-id 3)
5543 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5544 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5545 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5547 ("\\bCTAN:[ \t\n]*\\([^>)!;:,\n\t ]*\\)" 0 (>= gnus-button-tex-level 1)
5548 gnus-button-handle-ctan 1)
5550 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5551 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2)
5553 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5554 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
5555 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5556 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
5557 ;; Emacs help commands
5558 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5559 ;; regexp doesn't match arguments containing ` '.
5560 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
5561 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5562 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
5563 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5564 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
5565 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5566 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
5567 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5568 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
5569 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5570 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
5571 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+" 0
5572 ;; this regexp needs to be fixed!
5573 (>= gnus-button-emacs-level 9) gnus-button-handle-describe-key 2)
5574 ;; This is how URLs _should_ be embedded in text...
5575 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5577 (gnus-button-url-regexp 0 t browse-url 0)
5579 ("\\b\\([a-z][a-z]+\\)([1-9])\\W" 0
5580 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
5581 gnus-button-handle-man 1)
5582 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
5583 ("\\b\\([a-zA-Z][-_.a-zA-Z0-9]+\\)([1-9])\\W" 0
5584 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
5585 gnus-button-handle-man 1)
5586 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
5587 ;; SoWWWAnchor(3iv), XSelectInput(3X11)
5588 ("\\b\\([a-zA-Z][-_.:a-zA-Z0-9]+\\)([1-9][X1a-z]*)\\W" 0
5589 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
5590 ;; MID or mail: To avoid too many false positives we don't try to catch
5591 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
5592 ;; at least one dot. TLD must contain two or three chars or be a know TLD
5593 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
5594 ;; so that non-ambiguous entries (see above) match first.
5595 (gnus-button-mid-or-mail-regexp
5596 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1))
5597 "*Alist of regexps matching buttons in article bodies.
5599 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5600 REGEXP: is the string matching text around the button (can also be lisp
5601 expression evaluating to a string),
5602 BUTTON: is the number of the regexp grouping actually matching the button,
5603 FORM: is a lisp expression which must eval to true for the button to
5605 CALLBACK: is the function to call when the user push this button, and each
5606 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5608 CALLBACK can also be a variable, in that case the value of that
5609 variable it the real callback function."
5610 :group 'gnus-article-buttons
5611 :type '(repeat (list (choice regexp variable)
5612 (integer :tag "Button")
5614 (function :tag "Callback")
5617 (integer :tag "Regexp group")))))
5619 (defcustom gnus-header-button-alist
5620 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5621 0 t gnus-button-message-id 0)
5622 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5623 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5624 0 t gnus-button-mailto 0)
5625 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
5626 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
5627 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
5628 ("^[^:]+:" "\\bmailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5629 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5630 gnus-button-message-id 3))
5631 "*Alist of headers and regexps to match buttons in article heads.
5633 This alist is very similar to `gnus-button-alist', except that each
5634 alist has an additional HEADER element first in each entry:
5636 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5638 HEADER is a regexp to match a header. For a fuller explanation, see
5639 `gnus-button-alist'."
5640 :group 'gnus-article-buttons
5641 :group 'gnus-article-headers
5642 :type '(repeat (list (regexp :tag "Header")
5644 (integer :tag "Button")
5646 (function :tag "Callback")
5649 (integer :tag "Regexp group")))))
5651 (defvar gnus-button-regexp nil)
5652 (defvar gnus-button-marker-list nil)
5653 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5655 (defvar gnus-button-last nil)
5656 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5660 (defun gnus-article-push-button (event)
5661 "Check text under the mouse pointer for a callback function.
5662 If the text under the mouse pointer has a `gnus-callback' property,
5663 call it with the value of the `gnus-data' text property."
5665 (set-buffer (window-buffer (posn-window (event-start event))))
5666 (let* ((pos (posn-point (event-start event)))
5667 (data (get-text-property pos 'gnus-data))
5668 (fun (get-text-property pos 'gnus-callback)))
5671 (funcall fun data))))
5673 (defun gnus-article-press-button ()
5674 "Check text at point for a callback function.
5675 If the text at point has a `gnus-callback' property,
5676 call it with the value of the `gnus-data' text property."
5678 (let* ((data (get-text-property (point) 'gnus-data))
5679 (fun (get-text-property (point) 'gnus-callback)))
5681 (funcall fun data))))
5683 (defun gnus-article-highlight (&optional force)
5684 "Highlight current article.
5685 This function calls `gnus-article-highlight-headers',
5686 `gnus-article-highlight-citation',
5687 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5688 do the highlighting. See the documentation for those functions."
5689 (interactive (list 'force))
5690 (gnus-article-highlight-headers)
5691 (gnus-article-highlight-citation force)
5692 (gnus-article-highlight-signature)
5693 (gnus-article-add-buttons force)
5694 (gnus-article-add-buttons-to-head))
5696 (defun gnus-article-highlight-some (&optional force)
5697 "Highlight current article.
5698 This function calls `gnus-article-highlight-headers',
5699 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5700 do the highlighting. See the documentation for those functions."
5701 (interactive (list 'force))
5702 (gnus-article-highlight-headers)
5703 (gnus-article-highlight-signature)
5704 (gnus-article-add-buttons))
5706 (defun gnus-article-highlight-headers ()
5707 "Highlight article headers as specified by `gnus-header-face-alist'."
5710 (set-buffer gnus-article-buffer)
5712 (let ((alist gnus-header-face-alist)
5713 (buffer-read-only nil)
5714 (case-fold-search t)
5715 (inhibit-point-motion-hooks t)
5716 entry regexp header-face field-face from hpoints fpoints)
5717 (article-narrow-to-head)
5718 (while (setq entry (pop alist))
5719 (goto-char (point-min))
5720 (setq regexp (concat "^\\("
5721 (if (string-equal "" (nth 0 entry))
5725 header-face (nth 1 entry)
5726 field-face (nth 2 entry))
5727 (while (and (re-search-forward regexp nil t)
5731 (unless (search-forward ":" nil t)
5733 (when (and header-face
5734 (not (memq (point) hpoints)))
5735 (push (point) hpoints)
5736 (gnus-put-text-property from (point) 'face header-face))
5737 (when (and field-face
5738 (not (memq (setq from (point)) fpoints)))
5740 (if (re-search-forward "^[^ \t]" nil t)
5742 (goto-char (point-max)))
5743 (gnus-put-text-property from (point) 'face field-face))))))))
5745 (defun gnus-article-highlight-signature ()
5746 "Highlight the signature in an article.
5747 It does this by highlighting everything after
5748 `gnus-signature-separator' using `gnus-signature-face'."
5751 (set-buffer gnus-article-buffer)
5752 (let ((buffer-read-only nil)
5753 (inhibit-point-motion-hooks t))
5755 (when (and gnus-signature-face
5756 (gnus-article-narrow-to-signature))
5757 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5758 'face gnus-signature-face)
5760 (gnus-article-search-signature)
5761 (let ((start (match-beginning 0))
5762 (end (set-marker (make-marker) (1+ (match-end 0)))))
5763 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5766 (defun gnus-button-in-region-p (b e prop)
5767 "Say whether PROP exists in the region."
5768 (text-property-not-all b e prop nil))
5770 (defun gnus-article-add-buttons (&optional force)
5771 "Find external references in the article and make buttons of them.
5772 \"External references\" are things like Message-IDs and URLs, as
5773 specified by `gnus-button-alist'."
5774 (interactive (list 'force))
5776 (set-buffer gnus-article-buffer)
5777 (let ((buffer-read-only nil)
5778 (inhibit-point-motion-hooks t)
5779 (case-fold-search t)
5780 (alist gnus-button-alist)
5782 ;; Remove all old markers.
5783 (let (marker entry new-list)
5784 (while (setq marker (pop gnus-button-marker-list))
5785 (if (or (< marker (point-min)) (>= marker (point-max)))
5786 (push marker new-list)
5788 (when (setq entry (gnus-button-entry))
5789 (put-text-property (match-beginning (nth 1 entry))
5790 (match-end (nth 1 entry))
5791 'gnus-callback nil))
5792 (set-marker marker nil)))
5793 (setq gnus-button-marker-list new-list))
5794 ;; We skip the headers.
5797 (while (setq entry (pop alist))
5798 (setq regexp (eval (car entry)))
5800 (while (re-search-forward regexp nil t)
5801 (let* ((start (and entry (match-beginning (nth 1 entry))))
5802 (end (and entry (match-end (nth 1 entry))))
5803 (from (match-beginning 0)))
5804 (when (and (or (eq t (nth 2 entry))
5805 (eval (nth 2 entry)))
5806 (not (gnus-button-in-region-p
5807 start end 'gnus-callback)))
5808 ;; That optional form returned non-nil, so we add the
5810 (gnus-article-add-button
5811 start end 'gnus-button-push
5812 (car (push (set-marker (make-marker) from)
5813 gnus-button-marker-list))))))))))
5815 ;; Add buttons to the head of an article.
5816 (defun gnus-article-add-buttons-to-head ()
5817 "Add buttons to the head of the article."
5820 (set-buffer gnus-article-buffer)
5822 (let ((buffer-read-only nil)
5823 (inhibit-point-motion-hooks t)
5824 (case-fold-search t)
5825 (alist gnus-header-button-alist)
5827 (article-narrow-to-head)
5829 ;; Each alist entry.
5830 (setq entry (car alist)
5832 (goto-char (point-min))
5833 (while (re-search-forward (car entry) nil t)
5834 ;; Each header matching the entry.
5835 (setq beg (match-beginning 0))
5836 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5837 (match-beginning 0))
5840 (while (re-search-forward (eval (nth 1 entry)) end t)
5841 ;; Each match within a header.
5842 (let* ((entry (cdr entry))
5843 (start (match-beginning (nth 1 entry)))
5844 (end (match-end (nth 1 entry)))
5845 (form (nth 2 entry)))
5846 (goto-char (match-end 0))
5848 (gnus-article-add-button
5849 start end (nth 3 entry)
5850 (buffer-substring (match-beginning (nth 4 entry))
5851 (match-end (nth 4 entry)))))))
5852 (goto-char end)))))))
5854 ;;; External functions:
5856 (defun gnus-article-add-button (from to fun &optional data)
5857 "Create a button between FROM and TO with callback FUN and data DATA."
5858 (when gnus-article-button-face
5859 (gnus-overlay-put (gnus-make-overlay from to)
5860 'face gnus-article-button-face))
5861 (gnus-add-text-properties
5863 (nconc (and gnus-article-mouse-face
5864 (list gnus-mouse-face-prop gnus-article-mouse-face))
5865 (list 'gnus-callback fun)
5866 (and data (list 'gnus-data data))))
5867 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5868 :button-keymap gnus-widget-button-keymap))
5870 ;;; Internal functions:
5872 (defun gnus-article-set-globals ()
5874 (set-buffer gnus-summary-buffer)
5875 (gnus-set-global-variables)))
5877 (defun gnus-signature-toggle (end)
5879 (set-buffer gnus-article-buffer)
5880 (let ((buffer-read-only nil)
5881 (inhibit-point-motion-hooks t))
5882 (if (text-property-any end (point-max) 'article-type 'signature)
5884 (gnus-delete-wash-type 'signature)
5885 (gnus-remove-text-properties-when
5886 'article-type 'signature end (point-max)
5887 (cons 'article-type (cons 'signature
5888 gnus-hidden-properties))))
5889 (gnus-add-wash-type 'signature)
5890 (gnus-add-text-properties-when
5891 'article-type nil end (point-max)
5892 (cons 'article-type (cons 'signature
5893 gnus-hidden-properties)))))
5894 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5895 (gnus-set-mode-line 'article))))
5897 (defun gnus-button-entry ()
5898 ;; Return the first entry in `gnus-button-alist' matching this place.
5899 (let ((alist gnus-button-alist)
5902 (setq entry (pop alist))
5903 (if (looking-at (eval (car entry)))
5908 (defun gnus-button-push (marker)
5909 ;; Push button starting at MARKER.
5912 (let* ((entry (gnus-button-entry))
5913 (inhibit-point-motion-hooks t)
5915 (args (mapcar (lambda (group)
5916 (let ((string (match-string group)))
5917 (gnus-set-text-properties
5918 0 (length string) nil string)
5925 (fboundp (symbol-value fun)))
5926 (apply (symbol-value fun) args))
5928 (gnus-message 1 "You must define `%S' to use this button"
5929 (cons fun args)))))))
5931 (defun gnus-parse-news-url (url)
5932 (let (scheme server group message-id articles)
5935 (goto-char (point-min))
5936 (when (looking-at "\\([A-Za-z]+\\):")
5937 (setq scheme (match-string 1))
5938 (goto-char (match-end 0)))
5939 (when (looking-at "//\\([^/]+\\)/")
5940 (setq server (match-string 1))
5941 (goto-char (match-end 0)))
5944 ((looking-at "\\(.*@.*\\)")
5945 (setq message-id (match-string 1)))
5946 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5947 (setq group (match-string 1)
5948 articles (split-string (match-string 2) "-")))
5949 ((looking-at "\\([^/]+\\)/?")
5950 (setq group (match-string 1)))
5952 (error "Unknown news URL syntax"))))
5953 (list scheme server group message-id articles)))
5955 (defun gnus-button-handle-news (url)
5957 (destructuring-bind (scheme server group message-id articles)
5958 (gnus-parse-news-url url)
5962 (set-buffer gnus-summary-buffer)
5964 (let ((gnus-refer-article-method (list (list 'nntp server))))
5965 (gnus-summary-refer-article message-id))
5966 (gnus-summary-refer-article message-id))))
5968 (gnus-button-fetch-group url)))))
5970 (defun gnus-button-handle-man (url)
5972 (funcall gnus-button-man-handler url))
5974 (defun gnus-button-handle-info (url)
5975 "Fetch an info URL."
5977 "^\\([^:/]+\\)?/\\(.*\\)"
5979 (gnus-info-find-node
5980 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5983 (gnus-url-unhex-string (match-string 2 url))))
5984 (error "Can't parse %s" url)))
5986 (defun gnus-button-message-id (message-id)
5989 (set-buffer gnus-summary-buffer)
5990 (gnus-summary-refer-article message-id)))
5992 (defun gnus-button-fetch-group (address)
5993 "Fetch GROUP specified by ADDRESS."
5994 (if (not (string-match "[:/]" address))
5995 ;; This is just a simple group url.
5996 (gnus-group-read-ephemeral-group address gnus-select-method)
5999 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6001 (error "Can't parse %s" address)
6002 (gnus-group-read-ephemeral-group
6003 (match-string 4 address)
6004 `(nntp ,(match-string 1 address)
6005 (nntp-address ,(match-string 1 address))
6006 (nntp-port-number ,(if (match-end 3)
6007 (match-string 3 address)
6010 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6012 (defun gnus-url-parse-query-string (query &optional downcase)
6013 (let (retval pairs cur key val)
6014 (setq pairs (split-string query "&"))
6016 (setq cur (car pairs)
6018 (if (not (string-match "=" cur))
6020 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6021 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6023 (setq key (downcase key)))
6024 (setq cur (assoc key retval))
6026 (setcdr cur (cons val (cdr cur)))
6027 (setq retval (cons (list key val) retval)))))
6030 (defun gnus-url-mailto (url)
6031 ;; Send mail to someone
6032 (when (string-match "mailto:/*\\(.*\\)" url)
6033 (setq url (substring url (match-beginning 1) nil)))
6034 (let (to args subject func)
6035 (if (string-match (regexp-quote "?") url)
6036 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6037 args (gnus-url-parse-query-string
6038 (substring url (match-end 0) nil) t))
6039 (setq to (gnus-url-unhex-string url)))
6040 (setq args (cons (list "to" to) args)
6041 subject (cdr-safe (assoc "subject" args)))
6044 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6047 (message-position-on-field (caar args)))
6048 (insert (mapconcat 'identity (cdar args) ", "))
6049 (setq args (cdr args)))
6052 (message-goto-subject))))
6054 (defun gnus-button-embedded-url (address)
6055 "Activate ADDRESS with `browse-url'."
6056 (browse-url (gnus-strip-whitespace address)))
6058 ;;; Next/prev buttons in the article buffer.
6060 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6061 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6063 (defvar gnus-prev-page-map
6064 (let ((map (make-sparse-keymap)))
6065 (unless (>= emacs-major-version 21)
6066 ;; XEmacs doesn't care.
6067 (set-keymap-parent map gnus-article-mode-map))
6068 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6069 (define-key map "\r" 'gnus-button-prev-page)
6072 (defun gnus-insert-prev-page-button ()
6074 (buffer-read-only nil))
6076 gnus-prev-page-line-format nil
6077 `(,@(gnus-local-map-property gnus-prev-page-map)
6079 gnus-callback gnus-article-button-prev-page
6080 article-type annotation))
6081 (widget-convert-button
6083 :action 'gnus-button-prev-page
6084 :button-keymap gnus-prev-page-map)))
6086 (defvar gnus-prev-page-map
6087 (let ((map (make-sparse-keymap)))
6088 (unless (>= emacs-major-version 21)
6089 ;; XEmacs doesn't care.
6090 (set-keymap-parent map gnus-article-mode-map))
6091 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6092 (define-key map "\r" 'gnus-button-prev-page)
6095 (defvar gnus-next-page-map
6096 (let ((map (make-sparse-keymap)))
6097 (unless (>= emacs-major-version 21)
6098 ;; XEmacs doesn't care.
6099 (set-keymap-parent map gnus-article-mode-map))
6100 (define-key map gnus-mouse-2 'gnus-button-next-page)
6101 (define-key map "\r" 'gnus-button-next-page)
6104 (defun gnus-button-next-page (&optional args more-args)
6105 "Go to the next page."
6107 (let ((win (selected-window)))
6108 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6109 (gnus-article-next-page)
6110 (select-window win)))
6112 (defun gnus-button-prev-page (&optional args more-args)
6113 "Go to the prev page."
6115 (let ((win (selected-window)))
6116 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6117 (gnus-article-prev-page)
6118 (select-window win)))
6120 (defun gnus-insert-next-page-button ()
6122 (buffer-read-only nil))
6123 (gnus-eval-format gnus-next-page-line-format nil
6124 `(,@(gnus-local-map-property gnus-next-page-map)
6126 gnus-callback gnus-article-button-next-page
6127 article-type annotation))
6128 (widget-convert-button
6130 :action 'gnus-button-next-page
6131 :button-keymap gnus-next-page-map)))
6133 (defun gnus-article-button-next-page (arg)
6134 "Go to the next page."
6136 (let ((win (selected-window)))
6137 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6138 (gnus-article-next-page)
6139 (select-window win)))
6141 (defun gnus-article-button-prev-page (arg)
6142 "Go to the prev page."
6144 (let ((win (selected-window)))
6145 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6146 (gnus-article-prev-page)
6147 (select-window win)))
6149 (defvar gnus-decode-header-methods
6150 '(mail-decode-encoded-word-region)
6151 "List of methods used to decode headers.
6153 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6154 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6155 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6156 whose names match REGEXP.
6159 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6160 mail-decode-encoded-word-region
6161 (\"chinese\" . rfc1843-decode-region))
6164 (defvar gnus-decode-header-methods-cache nil)
6166 (defun gnus-multi-decode-header (start end)
6167 "Apply the functions from `gnus-encoded-word-methods' that match."
6168 (unless (and gnus-decode-header-methods-cache
6169 (eq gnus-newsgroup-name
6170 (car gnus-decode-header-methods-cache)))
6171 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6174 (nconc gnus-decode-header-methods-cache (list x))
6175 (if (and gnus-newsgroup-name
6176 (string-match (car x) gnus-newsgroup-name))
6177 (nconc gnus-decode-header-methods-cache
6179 gnus-decode-header-methods))
6180 (let ((xlist gnus-decode-header-methods-cache))
6183 (narrow-to-region start end)
6185 (funcall (pop xlist) (point-min) (point-max))))))
6188 ;;; Treatment top-level handling.
6191 (defun gnus-treat-article (condition &optional part-number total-parts type)
6192 (let ((length (- (point-max) (point-min)))
6193 (alist gnus-treatment-function-alist)
6194 (article-goto-body-goes-to-point-min-p t)
6198 (let ((list gnus-article-treat-types))
6200 (when (string-match (pop list) type)
6201 (throw 'found t)))))))
6202 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6204 (gnus-run-hooks 'gnus-part-display-hook)
6205 (while (setq elem (pop alist))
6208 (if (gnus-buffer-live-p gnus-summary-buffer)
6209 (set-buffer gnus-summary-buffer))
6210 (symbol-value (car elem))))
6211 (when (and (or (consp val)
6213 (gnus-treat-predicate val)
6214 (or (not (get (car elem) 'highlight))
6217 (funcall (cadr elem)))))))
6219 ;; Dynamic variables.
6221 (defvar part-number)
6222 (defvar total-parts)
6227 (defun gnus-treat-predicate (val)
6232 (stringp (car val)))
6233 (apply 'gnus-or (mapcar `(lambda (s)
6234 (string-match s ,(or gnus-newsgroup-name "")))
6237 (let ((pred (pop val)))
6240 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6242 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6244 (not (gnus-treat-predicate (car val))))
6246 (equal (car val) type))
6248 (error "%S is not a valid predicate" pred)))))
6256 (eq part-number total-parts))
6260 (error "%S is not a valid value" val))))
6262 (defun gnus-article-encrypt-body (protocol &optional n)
6263 "Encrypt the article body."
6266 (or gnus-article-encrypt-protocol
6267 (completing-read "Encrypt protocol: "
6268 gnus-article-encrypt-protocol-alist
6270 current-prefix-arg))
6271 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6273 (error (format "Can't find the encrypt protocol %s" protocol)))
6274 (if (member gnus-newsgroup-name '("nndraft:delayed"
6277 (error "Can't encrypt the article in group %s"
6278 gnus-newsgroup-name))
6279 (gnus-summary-iterate n
6281 (set-buffer gnus-summary-buffer)
6282 (let ((mail-parse-charset gnus-newsgroup-charset)
6283 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6284 (summary-buffer gnus-summary-buffer)
6286 (gnus-set-global-variables)
6287 (when (gnus-group-read-only-p)
6288 (error "The current newsgroup does not support article encrypt"))
6289 (gnus-summary-show-article t)
6291 (or (mail-header-references gnus-current-headers) ""))
6292 (set-buffer gnus-article-buffer)
6293 (let* ((buffer-read-only nil)
6295 (mapcar (lambda (field)
6296 (and (save-restriction
6297 (message-narrow-to-head)
6298 (goto-char (point-min))
6299 (search-forward field nil t))
6301 (message-narrow-to-field)
6302 (buffer-substring (point-min) (point-max))
6303 (delete-region (point-min) (point-max))
6305 '("Content-Type:" "Content-Transfer-Encoding:"
6306 "Content-Disposition:"))))
6307 (message-narrow-to-head)
6308 (message-remove-header "MIME-Version")
6309 (goto-char (point-max))
6310 (setq point (point))
6311 (insert (apply 'concat headers))
6313 (narrow-to-region point (point-max))
6314 (let ((message-options message-options))
6315 (message-options-set 'message-sender user-mail-address)
6316 (message-options-set 'message-recipients user-mail-address)
6317 (message-options-set 'message-sign-encrypt 'not)
6319 (goto-char (point-min))
6320 (insert "MIME-Version: 1.0\n")
6322 (gnus-summary-edit-article-done
6323 references nil summary-buffer t))
6324 (when gnus-keep-backlog
6325 (gnus-backlog-remove-article
6326 (car gnus-article-current) (cdr gnus-article-current)))
6328 (when (get-buffer gnus-original-article-buffer)
6329 (set-buffer gnus-original-article-buffer)
6330 (setq gnus-original-article nil)))
6331 (when gnus-use-cache
6332 (gnus-cache-update-article
6333 (car gnus-article-current) (cdr gnus-article-current))))))))
6335 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6336 "The following specs can be used:
6337 %t The security MIME type
6340 %D Details if button is pressed")
6342 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6343 "The following specs can be used:
6344 %t The security MIME type
6347 %D Details if button is pressed")
6349 (defvar gnus-mime-security-button-line-format-alist
6350 '((?t gnus-tmp-type ?s)
6351 (?i gnus-tmp-info ?s)
6352 (?d gnus-tmp-details ?s)
6353 (?D gnus-tmp-pressed-details ?s)))
6355 (defvar gnus-mime-security-button-map
6356 (let ((map (make-sparse-keymap)))
6357 (unless (>= (string-to-number emacs-version) 21)
6358 (set-keymap-parent map gnus-article-mode-map))
6359 (define-key map gnus-mouse-2 'gnus-article-push-button)
6360 (define-key map "\r" 'gnus-article-press-button)
6363 (defvar gnus-mime-security-details-buffer nil)
6365 (defvar gnus-mime-security-button-pressed nil)
6367 (defvar gnus-mime-security-show-details-inline t
6368 "If non-nil, show details in the article buffer.")
6370 (defun gnus-mime-security-verify-or-decrypt (handle)
6371 (mm-remove-parts (cdr handle))
6372 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6373 point buffer-read-only)
6375 (goto-char (car region)))
6377 (narrow-to-region (point) (point))
6378 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6379 (let* ((mm-verify-option 'known)
6380 (mm-decrypt-option 'known)
6381 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6382 (unless (eq nparts (cdr handle))
6383 (mm-destroy-parts (cdr handle))
6384 (setcdr handle nparts))))
6385 (setq point (point))
6386 (gnus-mime-display-security handle)
6387 (goto-char (point-max)))
6389 (delete-region (point) (cdr region))
6390 (set-marker (car region) nil)
6391 (set-marker (cdr region) nil))
6394 (defun gnus-mime-security-show-details (handle)
6395 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6397 (if gnus-mime-security-show-details-inline
6398 (let ((gnus-mime-security-button-pressed t)
6399 (gnus-mime-security-button-line-format
6400 (get-text-property (point) 'gnus-line-format))
6403 (while (eq (get-text-property (point) 'gnus-line-format)
6404 gnus-mime-security-button-line-format)
6408 (narrow-to-region (point) (point))
6409 (gnus-insert-mime-security-button handle))
6410 (delete-region (point)
6411 (or (text-property-not-all
6414 gnus-mime-security-button-line-format)
6416 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6417 (with-current-buffer gnus-mime-security-details-buffer
6420 (setq gnus-mime-security-details-buffer
6421 (gnus-get-buffer-create "*MIME Security Details*")))
6422 (with-current-buffer gnus-mime-security-details-buffer
6424 (goto-char (point-min)))
6425 (pop-to-buffer gnus-mime-security-details-buffer))
6426 (gnus-message 5 "No details."))))
6428 (defun gnus-mime-security-press-button (handle)
6429 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6430 (gnus-mime-security-show-details handle)
6431 (gnus-mime-security-verify-or-decrypt handle)))
6433 (defun gnus-insert-mime-security-button (handle &optional displayed)
6434 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6437 (or (nth 2 (assoc protocol mm-verify-function-alist))
6438 (nth 2 (assoc protocol mm-decrypt-function-alist))
6440 (if (equal (car handle) "multipart/signed")
6441 " Signed" " Encrypted")
6444 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6447 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6448 gnus-tmp-pressed-details
6450 (setq gnus-tmp-details
6451 (if gnus-tmp-details
6452 (concat "\n" gnus-tmp-details) ""))
6453 (setq gnus-tmp-pressed-details
6454 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6459 gnus-mime-security-button-line-format
6460 gnus-mime-security-button-line-format-alist
6461 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6462 gnus-callback gnus-mime-security-press-button
6463 gnus-line-format ,gnus-mime-security-button-line-format
6464 article-type annotation
6467 (widget-convert-button
6470 :action 'gnus-widget-press-button
6471 :button-keymap gnus-mime-security-button-map
6473 (lambda (widget/window &optional overlay pos)
6474 ;; Needed to properly clear the message due to a bug in
6475 ;; wid-edit (XEmacs only).
6476 (if (boundp 'help-echo-owns-message)
6477 (setq help-echo-owns-message t))
6480 (aref gnus-mouse-2 0))))))
6482 (defun gnus-mime-display-security (handle)
6484 (narrow-to-region (point) (point))
6485 (unless (gnus-unbuttonized-mime-type-p (car handle))
6486 (gnus-insert-mime-security-button handle))
6487 (gnus-mime-display-mixed (cdr handle))
6490 (unless (gnus-unbuttonized-mime-type-p (car handle))
6491 (let ((gnus-mime-security-button-line-format
6492 gnus-mime-security-button-end-line-format))
6493 (gnus-insert-mime-security-button handle)))
6494 (mm-set-handle-multipart-parameter
6496 (cons (set-marker (make-marker) (point-min))
6497 (set-marker (make-marker) (point-max))))))
6503 (run-hooks 'gnus-art-load-hook)
6505 ;;; gnus-art.el ends here