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:"
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
698 ("\230" "-") ; This might not be correct.
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-body-boundary-delimiter "_"
728 "String used to delimit header and body.
729 This variable is used by `gnus-article-treat-body-boundary' which can
730 be controlled by `gnus-treat-body-boundary'."
731 :group 'gnus-article-various
732 :type '(choice (item :tag "None" :value nil)
735 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
736 "Defines the location of the faces database.
737 For information on obtaining this database of pretty pictures, please
738 see http://www.cs.indiana.edu/picons/ftp/index.html"
739 :type '(repeat directory)
740 :link '(url-link :tag "download"
741 "http://www.cs.indiana.edu/picons/ftp/index.html")
742 :link '(custom-manual "(gnus)Picons")
745 (defun gnus-picons-installed-p ()
746 "Say whether picons are installed on your machine."
747 (let ((installed nil))
748 (dolist (database gnus-picon-databases)
749 (when (file-exists-p database)
753 (defcustom gnus-article-mime-part-function nil
754 "Function called with a MIME handle as the argument.
755 This is meant for people who want to do something automatic based
756 on parts -- for instance, adding Vcard info to a database."
757 :group 'gnus-article-mime
760 (defcustom gnus-mime-multipart-functions nil
761 "An alist of MIME types to functions to display them."
763 :group 'gnus-article-mime
766 (defcustom gnus-article-date-lapsed-new-header nil
767 "Whether the X-Sent and Date headers can coexist.
768 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
769 either replace the old \"Date:\" header (if this variable is nil), or
770 be added below it (otherwise)."
772 :group 'gnus-article-headers
775 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
776 "Function called with a MIME handle as the argument.
777 This is meant for people who want to view first matched part.
778 For `undisplayed-alternative' (default), the first undisplayed
779 part or alternative part is used. For `undisplayed', the first
780 undisplayed part is used. For a function, the first part which
781 the function return `t' is used. For `nil', the first part is
784 :group 'gnus-article-mime
786 (item :tag "first" :value nil)
787 (item :tag "undisplayed" :value undisplayed)
788 (item :tag "undisplayed or alternative"
789 :value undisplayed-alternative)
792 (defcustom gnus-mime-action-alist
793 '(("save to file" . gnus-mime-save-part)
794 ("save and strip" . gnus-mime-save-part-and-strip)
795 ("display as text" . gnus-mime-inline-part)
796 ("view the part" . gnus-mime-view-part)
797 ("pipe to command" . gnus-mime-pipe-part)
798 ("toggle display" . gnus-article-press-button)
799 ("toggle display" . gnus-article-view-part-as-charset)
800 ("view as type" . gnus-mime-view-part-as-type)
801 ("view internally" . gnus-mime-view-part-internally)
802 ("view externally" . gnus-mime-view-part-externally))
803 "An alist of actions that run on the MIME attachment."
804 :group 'gnus-article-mime
805 :type '(repeat (cons (string :tag "name")
809 ;;; The treatment variables
812 (defvar gnus-part-display-hook nil
813 "Hook called on parts that are to receive treatment.")
815 (defvar gnus-article-treat-custom
816 '(choice (const :tag "Off" nil)
818 (const :tag "Header" head)
819 (const :tag "Last" last)
820 (integer :tag "Less")
821 (repeat :tag "Groups" regexp)
822 (sexp :tag "Predicate")))
824 (defvar gnus-article-treat-head-custom
825 '(choice (const :tag "Off" nil)
826 (const :tag "Header" head)))
828 (defvar gnus-article-treat-types '("text/plain")
831 (defvar gnus-inhibit-treatment nil
832 "Whether to inhibit treatment.")
834 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
835 "Highlight the signature.
836 Valid values are nil, t, `head', `last', an integer or a predicate.
837 See Info node `(gnus)Customizing Articles'."
838 :group 'gnus-article-treat
839 :type gnus-article-treat-custom)
840 (put 'gnus-treat-highlight-signature 'highlight t)
842 (defcustom gnus-treat-buttonize 100000
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 :type gnus-article-treat-custom)
848 (put 'gnus-treat-buttonize 'highlight t)
850 (defcustom gnus-treat-buttonize-head 'head
851 "Add buttons to the head.
852 Valid values are nil, t, `head', `last', an integer or a predicate.
853 See Info node `(gnus)Customizing Articles' for details."
854 :group 'gnus-article-treat
855 :type gnus-article-treat-head-custom)
856 (put 'gnus-treat-buttonize-head 'highlight t)
858 (defcustom gnus-treat-emphasize
859 (and (or window-system
861 (>= (string-to-number emacs-version) 21))
864 Valid values are nil, t, `head', `last', an integer or a predicate.
865 See Info node `(gnus)Customizing Articles' for details."
866 :group 'gnus-article-treat
867 :type gnus-article-treat-custom)
868 (put 'gnus-treat-emphasize 'highlight t)
870 (defcustom gnus-treat-strip-cr nil
871 "Remove carriage returns.
872 Valid values are nil, t, `head', `last', an integer or a predicate.
873 See Info node `(gnus)Customizing Articles' for details."
874 :group 'gnus-article-treat
875 :type gnus-article-treat-custom)
877 (defcustom gnus-treat-unsplit-urls nil
878 "Remove newlines from within URLs.
879 Valid values are nil, t, `head', `last', an integer or a predicate.
880 See Info node `(gnus)Customizing Articles' for details."
881 :group 'gnus-article-treat
882 :type gnus-article-treat-custom)
884 (defcustom gnus-treat-leading-whitespace nil
885 "Remove leading whitespace in headers.
886 Valid values are nil, t, `head', `last', an integer or a predicate.
887 See Info node `(gnus)Customizing Articles' for details."
888 :group 'gnus-article-treat
889 :type gnus-article-treat-custom)
891 (defcustom gnus-treat-hide-headers 'head
893 Valid values are nil, t, `head', `last', an integer or a predicate.
894 See Info node `(gnus)Customizing Articles' for details."
895 :group 'gnus-article-treat
896 :type gnus-article-treat-head-custom)
898 (defcustom gnus-treat-hide-boring-headers nil
899 "Hide boring 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 :type gnus-article-treat-head-custom)
905 (defcustom gnus-treat-hide-signature nil
907 Valid values are nil, t, `head', `last', an integer or a predicate.
908 See Info node `(gnus)Customizing Articles' for details."
909 :group 'gnus-article-treat
910 :type gnus-article-treat-custom)
912 (defcustom gnus-treat-fill-article nil
914 Valid values are nil, t, `head', `last', an integer or a predicate.
915 See Info node `(gnus)Customizing Articles' for details."
916 :group 'gnus-article-treat
917 :type gnus-article-treat-custom)
919 (defcustom gnus-treat-hide-citation nil
921 Valid values are nil, t, `head', `last', an integer or a predicate.
922 See Info node `(gnus)Customizing Articles' for details."
923 :group 'gnus-article-treat
924 :type gnus-article-treat-custom)
926 (defcustom gnus-treat-hide-citation-maybe nil
928 Valid values are nil, t, `head', `last', an integer or a predicate.
929 See Info node `(gnus)Customizing Articles' for details."
930 :group 'gnus-article-treat
931 :type gnus-article-treat-custom)
933 (defcustom gnus-treat-strip-list-identifiers 'head
934 "Strip list identifiers from `gnus-list-identifiers`.
935 Valid values are nil, t, `head', `last', an integer or a predicate.
936 See Info node `(gnus)Customizing Articles' for details."
938 :group 'gnus-article-treat
939 :type gnus-article-treat-custom)
941 (defcustom gnus-treat-strip-pgp t
942 "Strip PGP signatures.
943 Valid values are nil, t, `head', `last', an integer or a predicate.
944 See Info node `(gnus)Customizing Articles' for details."
945 :group 'gnus-article-treat
946 :type gnus-article-treat-custom)
948 (defcustom gnus-treat-strip-pem nil
949 "Strip PEM signatures.
950 Valid values are nil, t, `head', `last', an integer or a predicate.
951 See Info node `(gnus)Customizing Articles' for details."
952 :group 'gnus-article-treat
953 :type gnus-article-treat-custom)
955 (defcustom gnus-treat-strip-banner t
956 "Strip banners from articles.
957 The banner to be stripped is specified in the `banner' group parameter.
958 Valid values are nil, t, `head', `last', an integer or a predicate.
959 See Info node `(gnus)Customizing Articles' for details."
960 :group 'gnus-article-treat
961 :type gnus-article-treat-custom)
963 (defcustom gnus-treat-highlight-headers 'head
964 "Highlight the headers.
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 :type gnus-article-treat-head-custom)
969 (put 'gnus-treat-highlight-headers 'highlight t)
971 (defcustom gnus-treat-highlight-citation t
972 "Highlight cited text.
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 :type gnus-article-treat-custom)
977 (put 'gnus-treat-highlight-citation 'highlight t)
979 (defcustom gnus-treat-date-ut nil
980 "Display the Date in UT (GMT).
981 Valid values are nil, t, `head', `last', an integer or a predicate.
982 See Info node `(gnus)Customizing Articles' for details."
983 :group 'gnus-article-treat
984 :type gnus-article-treat-head-custom)
986 (defcustom gnus-treat-date-local nil
987 "Display the Date in the local timezone.
988 Valid values are nil, t, `head', `last', an integer or a predicate.
989 See Info node `(gnus)Customizing Articles' for details."
990 :group 'gnus-article-treat
991 :type gnus-article-treat-head-custom)
993 (defcustom gnus-treat-date-english nil
994 "Display the Date in a format that can be read aloud in English.
995 Valid values are nil, t, `head', `last', an integer or a predicate.
996 See Info node `(gnus)Customizing Articles' for details."
997 :group 'gnus-article-treat
998 :type gnus-article-treat-head-custom)
1000 (defcustom gnus-treat-date-lapsed nil
1001 "Display the Date header in a way that says how much time has elapsed.
1002 Valid values are nil, t, `head', `last', an integer or a predicate.
1003 See Info node `(gnus)Customizing Articles' for details."
1004 :group 'gnus-article-treat
1005 :type gnus-article-treat-head-custom)
1007 (defcustom gnus-treat-date-original nil
1008 "Display the date in the original timezone.
1009 Valid values are nil, t, `head', `last', an integer or a predicate.
1010 See Info node `(gnus)Customizing Articles' for details."
1011 :group 'gnus-article-treat
1012 :type gnus-article-treat-head-custom)
1014 (defcustom gnus-treat-date-iso8601 nil
1015 "Display the date in the ISO8601 format.
1016 Valid values are nil, t, `head', `last', an integer or a predicate.
1017 See Info node `(gnus)Customizing Articles' for details."
1019 :group 'gnus-article-treat
1020 :type gnus-article-treat-head-custom)
1022 (defcustom gnus-treat-date-user-defined nil
1023 "Display the date in a user-defined format.
1024 The format is defined by the `gnus-article-time-format' variable.
1025 Valid values are nil, t, `head', `last', an integer or a predicate.
1026 See Info node `(gnus)Customizing Articles' for details."
1027 :group 'gnus-article-treat
1028 :type gnus-article-treat-head-custom)
1030 (defcustom gnus-treat-strip-headers-in-body t
1031 "Strip the X-No-Archive header line from the beginning of the body.
1032 Valid values are nil, t, `head', `last', an integer or a predicate.
1033 See Info node `(gnus)Customizing Articles' for details."
1035 :group 'gnus-article-treat
1036 :type gnus-article-treat-custom)
1038 (defcustom gnus-treat-strip-trailing-blank-lines nil
1039 "Strip trailing blank lines.
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 :type gnus-article-treat-custom)
1045 (defcustom gnus-treat-strip-leading-blank-lines nil
1046 "Strip leading blank lines.
1047 Valid values are nil, t, `head', `last', an integer or a predicate.
1048 See Info node `(gnus)Customizing Articles' for details."
1049 :group 'gnus-article-treat
1050 :type gnus-article-treat-custom)
1052 (defcustom gnus-treat-strip-multiple-blank-lines nil
1053 "Strip multiple blank lines.
1054 Valid values are nil, t, `head', `last', an integer or a predicate.
1055 See Info node `(gnus)Customizing Articles' for details."
1056 :group 'gnus-article-treat
1057 :type gnus-article-treat-custom)
1059 (defcustom gnus-treat-unfold-headers 'head
1060 "Unfold folded header lines.
1061 Valid values are nil, t, `head', `last', an integer or a predicate.
1062 See Info node `(gnus)Customizing Articles' for details."
1063 :group 'gnus-article-treat
1064 :type gnus-article-treat-custom)
1066 (defcustom gnus-treat-fold-headers nil
1068 Valid values are nil, t, `head', `last', an integer or a predicate.
1069 See Info node `(gnus)Customizing Articles' for details."
1070 :group 'gnus-article-treat
1071 :type gnus-article-treat-custom)
1073 (defcustom gnus-treat-fold-newsgroups 'head
1074 "Fold the Newsgroups and Followup-To headers.
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 :type gnus-article-treat-custom)
1080 (defcustom gnus-treat-overstrike t
1081 "Treat overstrike highlighting.
1082 Valid values are nil, t, `head', `last', an integer or a predicate.
1083 See Info node `(gnus)Customizing Articles' for details."
1084 :group 'gnus-article-treat
1085 :type gnus-article-treat-custom)
1086 (put 'gnus-treat-overstrike 'highlight t)
1088 (defcustom gnus-treat-display-xface
1089 (and (not noninteractive)
1090 (or (and (fboundp 'image-type-available-p)
1091 (image-type-available-p 'xbm)
1092 (string-match "^0x" (shell-command-to-string "uncompface")))
1093 (and (featurep 'xemacs)
1096 "Display X-Face headers.
1097 Valid values are nil, t, `head', `last', an integer or a predicate.
1098 See Info node `(gnus)Customizing Articles' and Info node
1099 `(gnus)X-Face' for details."
1100 :group 'gnus-article-treat
1102 :type gnus-article-treat-head-custom)
1103 (put 'gnus-treat-display-xface 'highlight t)
1105 (defcustom gnus-treat-display-grey-xface
1106 (and (not noninteractive)
1107 (string-match "^0x" (shell-command-to-string "uncompface"))
1109 "Display grey X-Face headers.
1110 Valid values are nil, t."
1111 :group 'gnus-article-treat
1114 (put 'gnus-treat-display-grey-xface 'highlight t)
1116 (defcustom gnus-treat-display-smileys
1117 (if (or (and (featurep 'xemacs)
1119 (and (fboundp 'image-type-available-p)
1120 (image-type-available-p 'pbm)))
1123 Valid values are nil, t, `head', `last', an integer or a predicate.
1124 See Info node `(gnus)Customizing Articles' and Info node
1125 `(gnus)Smileys' for details."
1126 :group 'gnus-article-treat
1128 :type gnus-article-treat-custom)
1129 (put 'gnus-treat-display-smileys 'highlight t)
1131 (defcustom gnus-treat-from-picon
1132 (if (and (gnus-image-type-available-p 'xpm)
1133 (gnus-picons-installed-p))
1135 "Display picons in the From header.
1136 Valid values are nil, t, `head', `last', an integer or a predicate.
1137 See Info node `(gnus)Customizing Articles' and Info node
1138 `(gnus)Picons' for details."
1139 :group 'gnus-article-treat
1141 :link '(info-link "(gnus)Customizing Articles")
1142 :link '(info-link "(gnus)Picons")
1143 :type gnus-article-treat-head-custom)
1144 (put 'gnus-treat-from-picon 'highlight t)
1146 (defcustom gnus-treat-mail-picon
1147 (if (and (gnus-image-type-available-p 'xpm)
1148 (gnus-picons-installed-p))
1150 "Display picons in To and Cc headers.
1151 Valid values are nil, t, `head', `last', an integer or a predicate.
1152 See Info node `(gnus)Customizing Articles' and Info node
1153 `(gnus)Picons' for details."
1154 :group 'gnus-article-treat
1156 :link '(info-link "(gnus)Customizing Articles")
1157 :link '(info-link "(gnus)Picons")
1158 :type gnus-article-treat-head-custom)
1159 (put 'gnus-treat-mail-picon 'highlight t)
1161 (defcustom gnus-treat-newsgroups-picon
1162 (if (and (gnus-image-type-available-p 'xpm)
1163 (gnus-picons-installed-p))
1165 "Display picons in the Newsgroups and Followup-To headers.
1166 Valid values are nil, t, `head', `last', an integer or a predicate.
1167 See Info node `(gnus)Customizing Articles' and Info node
1168 `(gnus)Picons' for details."
1169 :group 'gnus-article-treat
1171 :link '(info-link "(gnus)Customizing Articles")
1172 :link '(info-link "(gnus)Picons")
1173 :type gnus-article-treat-head-custom)
1174 (put 'gnus-treat-newsgroups-picon 'highlight t)
1176 (defcustom gnus-treat-body-boundary
1177 (if (or gnus-treat-newsgroups-picon
1178 gnus-treat-mail-picon
1179 gnus-treat-from-picon)
1181 "Draw a boundary at the end of the headers.
1182 Valid values are nil, t, `head', `last', an integer or a predicate.
1183 See Info node `(gnus)Customizing Articles' for details."
1185 :group 'gnus-article-treat
1186 :type gnus-article-treat-custom)
1188 (defcustom gnus-treat-capitalize-sentences nil
1189 "Capitalize sentence-starting words.
1190 Valid values are nil, t, `head', `last', an integer or a predicate.
1191 See Info node `(gnus)Customizing Articles' for details."
1193 :group 'gnus-article-treat
1194 :type gnus-article-treat-custom)
1196 (defcustom gnus-treat-fill-long-lines nil
1198 Valid values are nil, t, `head', `last', an integer or a predicate.
1199 See Info node `(gnus)Customizing Articles' for details."
1200 :group 'gnus-article-treat
1201 :type gnus-article-treat-custom)
1203 (defcustom gnus-treat-play-sounds nil
1205 Valid values are nil, t, `head', `last', an integer or a predicate.
1206 See Info node `(gnus)Customizing Articles' for details."
1208 :group 'gnus-article-treat
1209 :type gnus-article-treat-custom)
1211 (defcustom gnus-treat-translate nil
1212 "Translate articles from one language to another.
1213 Valid values are nil, t, `head', `last', an integer or a predicate.
1214 See Info node `(gnus)Customizing Articles' for details."
1216 :group 'gnus-article-treat
1217 :type gnus-article-treat-custom)
1219 (defcustom gnus-treat-x-pgp-sig nil
1221 To automatically treat X-PGP-Sig, set it to head.
1222 Valid values are nil, t, `head', `last', an integer or a predicate.
1223 See Info node `(gnus)Customizing Articles' for details."
1224 :group 'gnus-article-treat
1225 :group 'mime-security
1226 :type gnus-article-treat-custom)
1228 (defvar gnus-article-encrypt-protocol-alist
1229 '(("PGP" . mml2015-self-encrypt)))
1231 ;; Set to nil if more than one protocol added to
1232 ;; gnus-article-encrypt-protocol-alist.
1233 (defcustom gnus-article-encrypt-protocol "PGP"
1234 "The protocol used for encrypt articles.
1235 It is a string, such as \"PGP\". If nil, ask user."
1237 :group 'mime-security)
1239 (defvar gnus-article-wash-function nil
1240 "Function used for converting HTML into text.")
1242 ;;; Internal variables
1244 (defvar gnus-english-month-names
1245 '("January" "February" "March" "April" "May" "June" "July" "August"
1246 "September" "October" "November" "December"))
1248 (defvar article-goto-body-goes-to-point-min-p nil)
1249 (defvar gnus-article-wash-types nil)
1250 (defvar gnus-article-emphasis-alist nil)
1251 (defvar gnus-article-image-alist nil)
1253 (defvar gnus-article-mime-handle-alist-1 nil)
1254 (defvar gnus-treatment-function-alist
1255 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1256 (gnus-treat-strip-banner gnus-article-strip-banner)
1257 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1258 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1259 (gnus-treat-buttonize gnus-article-add-buttons)
1260 (gnus-treat-fill-article gnus-article-fill-cited-article)
1261 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1262 (gnus-treat-strip-cr gnus-article-remove-cr)
1263 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1264 (gnus-treat-date-ut gnus-article-date-ut)
1265 (gnus-treat-date-local gnus-article-date-local)
1266 (gnus-treat-date-english gnus-article-date-english)
1267 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1268 (gnus-treat-date-original gnus-article-date-original)
1269 (gnus-treat-date-user-defined gnus-article-date-user)
1270 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1271 (gnus-treat-display-xface gnus-article-display-x-face)
1272 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1273 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1274 (gnus-treat-hide-signature gnus-article-hide-signature)
1275 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1276 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1277 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1278 (gnus-treat-strip-pem gnus-article-hide-pem)
1279 (gnus-treat-from-picon gnus-treat-from-picon)
1280 (gnus-treat-mail-picon gnus-treat-mail-picon)
1281 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1282 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1283 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1284 (gnus-treat-strip-trailing-blank-lines
1285 gnus-article-remove-trailing-blank-lines)
1286 (gnus-treat-strip-leading-blank-lines
1287 gnus-article-strip-leading-blank-lines)
1288 (gnus-treat-strip-multiple-blank-lines
1289 gnus-article-strip-multiple-blank-lines)
1290 (gnus-treat-overstrike gnus-article-treat-overstrike)
1291 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1292 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1293 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1294 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1295 (gnus-treat-display-smileys gnus-treat-smiley)
1296 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1297 (gnus-treat-emphasize gnus-article-emphasize)
1298 (gnus-treat-hide-citation gnus-article-hide-citation)
1299 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1300 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1301 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1302 (gnus-treat-play-sounds gnus-earcon-display)))
1304 (defvar gnus-article-mime-handle-alist nil)
1305 (defvar article-lapsed-timer nil)
1306 (defvar gnus-article-current-summary nil)
1308 (defvar gnus-article-mode-syntax-table
1309 (let ((table (copy-syntax-table text-mode-syntax-table)))
1310 ;; This causes the citation match run O(2^n).
1311 ;; (modify-syntax-entry ?- "w" table)
1312 (modify-syntax-entry ?> ")<" table)
1313 (modify-syntax-entry ?< "(>" table)
1315 "Syntax table used in article mode buffers.
1316 Initialized from `text-mode-syntax-table.")
1318 (defvar gnus-save-article-buffer nil)
1320 (defvar gnus-article-mode-line-format-alist
1321 (nconc '((?w (gnus-article-wash-status) ?s)
1322 (?m (gnus-article-mime-part-status) ?s))
1323 gnus-summary-mode-line-format-alist))
1325 (defvar gnus-number-of-articles-to-be-saved nil)
1327 (defvar gnus-inhibit-hiding nil)
1329 ;;; Macros for dealing with the article buffer.
1331 (defmacro gnus-with-article-headers (&rest forms)
1333 (set-buffer gnus-article-buffer)
1335 (let ((buffer-read-only nil)
1336 (inhibit-point-motion-hooks t)
1337 (case-fold-search t))
1338 (article-narrow-to-head)
1341 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1342 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1344 (defmacro gnus-with-article-buffer (&rest forms)
1346 (set-buffer gnus-article-buffer)
1347 (let ((buffer-read-only nil))
1350 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1351 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1353 (defun gnus-article-goto-header (header)
1354 "Go to HEADER, which is a regular expression."
1355 (re-search-forward (concat "^\\(" header "\\):") nil t))
1357 (defsubst gnus-article-hide-text (b e props)
1358 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1359 (gnus-add-text-properties-when 'article-type nil b e props)
1360 (when (memq 'intangible props)
1362 (max (1- b) (point-min))
1363 b 'intangible (cddr (memq 'intangible props)))))
1365 (defsubst gnus-article-unhide-text (b e)
1366 "Remove hidden text properties from region between B and E."
1367 (remove-text-properties b e gnus-hidden-properties)
1368 (when (memq 'intangible gnus-hidden-properties)
1369 (put-text-property (max (1- b) (point-min))
1370 b 'intangible nil)))
1372 (defun gnus-article-hide-text-type (b e type)
1373 "Hide text of TYPE between B and E."
1374 (gnus-add-wash-type type)
1375 (gnus-article-hide-text
1376 b e (cons 'article-type (cons type gnus-hidden-properties))))
1378 (defun gnus-article-unhide-text-type (b e type)
1379 "Unhide text of TYPE between B and E."
1380 (gnus-delete-wash-type type)
1381 (remove-text-properties
1382 b e (cons 'article-type (cons type gnus-hidden-properties)))
1383 (when (memq 'intangible gnus-hidden-properties)
1384 (put-text-property (max (1- b) (point-min))
1385 b 'intangible nil)))
1387 (defun gnus-article-hide-text-of-type (type)
1388 "Hide text of TYPE in the current buffer."
1390 (let ((b (point-min))
1392 (while (setq b (text-property-any b e 'article-type type))
1393 (add-text-properties b (incf b) gnus-hidden-properties)))))
1395 (defun gnus-article-delete-text-of-type (type)
1396 "Delete text of TYPE in the current buffer."
1398 (let ((b (point-min)))
1399 (while (setq b (text-property-any b (point-max) 'article-type type))
1401 b (or (text-property-not-all b (point-max) 'article-type type)
1404 (defun gnus-article-delete-invisible-text ()
1405 "Delete all invisible text in the current buffer."
1407 (let ((b (point-min)))
1408 (while (setq b (text-property-any b (point-max) 'invisible t))
1410 b (or (text-property-not-all b (point-max) 'invisible t)
1413 (defun gnus-article-text-type-exists-p (type)
1414 "Say whether any text of type TYPE exists in the buffer."
1415 (text-property-any (point-min) (point-max) 'article-type type))
1417 (defsubst gnus-article-header-rank ()
1418 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1419 (let ((list gnus-sorted-header-list)
1422 (when (looking-at (car list))
1424 (setq list (cdr list))
1428 (defun article-hide-headers (&optional arg delete)
1429 "Hide unwanted headers and possibly sort them as well."
1431 ;; This function might be inhibited.
1432 (unless gnus-inhibit-hiding
1435 (let ((buffer-read-only nil)
1436 (case-fold-search t)
1437 (max (1+ (length gnus-sorted-header-list)))
1438 (ignored (when (not gnus-visible-headers)
1439 (cond ((stringp gnus-ignored-headers)
1440 gnus-ignored-headers)
1441 ((listp gnus-ignored-headers)
1442 (mapconcat 'identity gnus-ignored-headers
1445 (cond ((stringp gnus-visible-headers)
1446 gnus-visible-headers)
1447 ((and gnus-visible-headers
1448 (listp gnus-visible-headers))
1449 (mapconcat 'identity gnus-visible-headers "\\|"))))
1450 (inhibit-point-motion-hooks t)
1452 ;; First we narrow to just the headers.
1453 (article-narrow-to-head)
1454 ;; Hide any "From " lines at the beginning of (mail) articles.
1455 (while (looking-at "From ")
1458 (delete-region (point-min) (point)))
1459 ;; Then treat the rest of the header lines.
1460 ;; Then we use the two regular expressions
1461 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1462 ;; select which header lines is to remain visible in the
1464 (while (re-search-forward "^[^ \t:]*:" nil t)
1466 ;; Mark the rank of the header.
1468 (point) (1+ (point)) 'message-rank
1469 (if (or (and visible (looking-at visible))
1471 (not (looking-at ignored))))
1472 (gnus-article-header-rank)
1475 (message-sort-headers-1)
1476 (when (setq beg (text-property-any
1477 (point-min) (point-max) 'message-rank (+ 2 max)))
1478 ;; We delete the unwanted headers.
1479 (gnus-add-wash-type 'headers)
1480 (add-text-properties (point-min) (+ 5 (point-min))
1481 '(article-type headers dummy-invisible t))
1482 (delete-region beg (point-max))))))))
1484 (defun article-hide-boring-headers (&optional arg)
1485 "Toggle hiding of headers that aren't very interesting.
1486 If given a negative prefix, always show; if given a positive prefix,
1488 (interactive (gnus-article-hidden-arg))
1489 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1490 (not gnus-show-all-headers))
1493 (let ((buffer-read-only nil)
1494 (list gnus-boring-article-headers)
1495 (inhibit-point-motion-hooks t)
1497 (article-narrow-to-head)
1499 (setq elem (pop list))
1500 (goto-char (point-min))
1502 ;; Hide empty headers.
1504 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1506 (gnus-article-hide-text-type
1507 (progn (beginning-of-line) (point))
1510 (if (re-search-forward "^[^ \t]" nil t)
1514 ;; Hide boring Newsgroups header.
1515 ((eq elem 'newsgroups)
1516 (when (gnus-string-equal
1517 (gnus-fetch-field "newsgroups")
1518 (gnus-group-real-name
1519 (if (boundp 'gnus-newsgroup-name)
1522 (gnus-article-hide-header "newsgroups")))
1523 ((eq elem 'to-address)
1524 (let ((to (message-fetch-field "to"))
1526 (gnus-parameter-to-address
1527 (if (boundp 'gnus-newsgroup-name)
1528 gnus-newsgroup-name ""))))
1529 (when (and to to-address
1532 ;; only one address in To
1533 (nth 1 (mail-extract-address-components to))
1535 (gnus-article-hide-header "to"))))
1536 ((eq elem 'followup-to)
1537 (when (gnus-string-equal
1538 (message-fetch-field "followup-to")
1539 (message-fetch-field "newsgroups"))
1540 (gnus-article-hide-header "followup-to")))
1541 ((eq elem 'reply-to)
1542 (let ((from (message-fetch-field "from"))
1543 (reply-to (message-fetch-field "reply-to")))
1548 (nth 1 (mail-extract-address-components from))
1549 (nth 1 (mail-extract-address-components reply-to)))))
1550 (gnus-article-hide-header "reply-to"))))
1552 (let ((date (message-fetch-field "date")))
1554 (< (days-between (current-time-string) date)
1556 (gnus-article-hide-header "date"))))
1558 (let ((to (message-fetch-field "to"))
1559 (cc (message-fetch-field "cc")))
1560 (when (> (length to) 1024)
1561 (gnus-article-hide-header "to"))
1562 (when (> (length cc) 1024)
1563 (gnus-article-hide-header "cc"))))
1567 (goto-char (point-min))
1568 (while (re-search-forward "^to:" nil t)
1569 (setq to-count (1+ to-count)))
1570 (when (> to-count 1)
1571 (while (> to-count 0)
1572 (goto-char (point-min))
1574 (re-search-forward "^to:" nil nil to-count)
1576 (narrow-to-region (point) (point-max))
1577 (gnus-article-hide-header "to"))
1578 (setq to-count (1- to-count))))
1579 (goto-char (point-min))
1580 (while (re-search-forward "^cc:" nil t)
1581 (setq cc-count (1+ cc-count)))
1582 (when (> cc-count 1)
1583 (while (> cc-count 0)
1584 (goto-char (point-min))
1586 (re-search-forward "^cc:" nil nil cc-count)
1588 (narrow-to-region (point) (point-max))
1589 (gnus-article-hide-header "cc"))
1590 (setq cc-count (1- cc-count)))))))))))))
1592 (defun gnus-article-hide-header (header)
1594 (goto-char (point-min))
1595 (when (re-search-forward (concat "^" header ":") nil t)
1596 (gnus-article-hide-text-type
1597 (progn (beginning-of-line) (point))
1600 (if (re-search-forward "^[^ \t]" nil t)
1605 (defvar gnus-article-normalized-header-length 40
1606 "Length of normalized headers.")
1608 (defun article-normalize-headers ()
1609 "Make all header lines 40 characters long."
1611 (let ((buffer-read-only nil)
1615 (article-narrow-to-head)
1618 ((< (setq column (- (gnus-point-at-eol) (point)))
1619 gnus-article-normalized-header-length)
1621 (insert (make-string
1622 (- gnus-article-normalized-header-length column)
1624 ((> column gnus-article-normalized-header-length)
1625 (gnus-put-text-property
1627 (forward-char gnus-article-normalized-header-length)
1634 (forward-line 1))))))
1636 (defun article-treat-dumbquotes ()
1637 "Translate M****s*** sm*rtq**t*s into proper text.
1638 Note that this function guesses whether a character is a sm*rtq**t* or
1639 not, so it should only be used interactively.
1641 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1642 in an attempt to provide more quoting characters. If you see
1643 something like \\222 or \\264 where you're expecting some kind of
1644 apostrophe or quotation mark, then try this wash."
1646 (article-translate-strings gnus-article-dumbquotes-map))
1648 (defun article-translate-characters (from to)
1649 "Translate all characters in the body of the article according to FROM and TO.
1650 FROM is a string of characters to translate from; to is a string of
1651 characters to translate to."
1653 (when (article-goto-body)
1654 (let ((buffer-read-only nil)
1655 (x (make-string 225 ?x))
1657 (while (< (incf i) (length x))
1660 (while (< i (length from))
1661 (aset x (aref from i) (aref to i))
1663 (translate-region (point) (point-max) x)))))
1665 (defun article-translate-strings (map)
1666 "Translate all string in the body of the article according to MAP.
1667 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1669 (when (article-goto-body)
1670 (let ((buffer-read-only nil)
1672 (while (setq elem (pop map))
1674 (while (search-forward (car elem) nil t)
1675 (replace-match (cadr elem)))))))))
1677 (defun article-treat-overstrike ()
1678 "Translate overstrikes into bold text."
1681 (when (article-goto-body)
1682 (let ((buffer-read-only nil))
1683 (while (search-forward "\b" nil t)
1684 (let ((next (char-after))
1685 (previous (char-after (- (point) 2))))
1686 ;; We do the boldification/underlining by hiding the
1687 ;; overstrikes and putting the proper text property
1691 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1692 (put-text-property (point) (1+ (point)) 'face 'bold))
1694 (gnus-article-hide-text-type
1695 (1- (point)) (1+ (point)) 'overstrike)
1697 (- (point) 2) (1- (point)) 'face 'underline))
1699 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1701 (point) (1+ (point)) 'face 'underline)))))))))
1703 (defun gnus-article-treat-unfold-headers ()
1704 "Unfold folded message headers.
1705 Only the headers that fit into the current window width will be
1708 (gnus-with-article-headers
1712 (mail-header-narrow-to-field)
1713 (let ((header (buffer-substring (point-min) (point-max))))
1716 (goto-char (point-min))
1717 (while (re-search-forward "\n[\t ]" nil t)
1718 (replace-match " " t t)))
1719 (setq length (- (point-max) (point-min) 1)))
1720 (when (< length (window-width))
1721 (while (re-search-forward "\n[\t ]" nil t)
1722 (replace-match " " t t)))
1723 (goto-char (point-max)))))))
1725 (defun gnus-article-treat-fold-headers ()
1726 "Fold message headers."
1728 (gnus-with-article-headers
1731 (mail-header-narrow-to-field)
1732 (mail-header-fold-field)
1733 (goto-char (point-max))))))
1735 (defun gnus-treat-smiley ()
1736 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1738 (gnus-with-article-buffer
1739 (if (memq 'smiley gnus-article-wash-types)
1740 (gnus-delete-images 'smiley)
1742 (let ((images (smiley-region (point) (point-max))))
1744 (gnus-add-wash-type 'smiley)
1745 (dolist (image images)
1746 (gnus-add-image 'smiley image)))))))
1748 (defun gnus-article-remove-images ()
1749 "Remove all images from the article buffer."
1751 (gnus-with-article-buffer
1752 (dolist (elem gnus-article-image-alist)
1753 (gnus-delete-images (car elem)))))
1755 (defun gnus-article-treat-fold-newsgroups ()
1756 "Unfold folded message headers.
1757 Only the headers that fit into the current window width will be
1760 (gnus-with-article-headers
1761 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1763 (mail-header-narrow-to-field)
1764 (while (re-search-forward ", *" nil t)
1765 (replace-match ", " t t))
1766 (mail-header-fold-field)
1767 (goto-char (point-max))))))
1769 (defun gnus-article-treat-body-boundary ()
1770 "Place a boundary line at the end of the headers."
1772 (when (and gnus-body-boundary-delimiter
1773 (> (length gnus-body-boundary-delimiter) 0))
1774 (gnus-with-article-headers
1775 (goto-char (point-max))
1776 (let ((start (point)))
1777 (insert "X-Boundary: ")
1778 (gnus-add-text-properties start (point) '(invisible t intangible t))
1780 (while (>= (1- (window-width)) (length str))
1781 (setq str (concat str gnus-body-boundary-delimiter)))
1782 (substring str 0 (1- (window-width))))
1784 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1786 (defun article-fill-long-lines ()
1787 "Fill lines that are wider than the window width."
1790 (let ((buffer-read-only nil)
1791 (width (window-width (get-buffer-window (current-buffer)))))
1794 (let ((adaptive-fill-mode nil)) ;Why? -sm
1797 (when (>= (current-column) (min fill-column width))
1798 (narrow-to-region (min (1+ (point)) (point-max)) (gnus-point-at-bol))
1799 (let ((goback (point-marker)))
1800 (fill-paragraph nil)
1801 (goto-char (marker-position goback)))
1803 (forward-line 1)))))))
1805 (defun article-capitalize-sentences ()
1806 "Capitalize the first word in each sentence."
1809 (let ((buffer-read-only nil)
1810 (paragraph-start "^[\n\^L]"))
1814 (forward-sentence)))))
1816 (defun article-remove-cr ()
1817 "Remove trailing CRs and then translate remaining CRs into LFs."
1820 (let ((buffer-read-only nil))
1821 (goto-char (point-min))
1822 (while (re-search-forward "\r+$" nil t)
1823 (replace-match "" t t))
1824 (goto-char (point-min))
1825 (while (search-forward "\r" nil t)
1826 (replace-match "\n" t t)))))
1828 (defun article-remove-trailing-blank-lines ()
1829 "Remove all trailing blank lines from the article."
1832 (let ((buffer-read-only nil))
1833 (goto-char (point-max))
1837 (while (and (not (bobp))
1838 (looking-at "^[ \t]*$")
1839 (not (gnus-annotation-in-region-p
1840 (point) (gnus-point-at-eol))))
1845 (defun article-display-x-face (&optional force)
1846 "Look for an X-Face header and display it if present."
1847 (interactive (list 'force))
1848 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1849 (gnus-with-article-headers
1850 ;; Delete the old process, if any.
1851 (when (process-status "article-x-face")
1852 (delete-process "article-x-face"))
1853 (if (memq 'xface gnus-article-wash-types)
1854 ;; We have already displayed X-Faces, so we remove them
1856 (gnus-delete-images 'xface)
1858 (let (x-faces from face grey)
1860 (when (and wash-face-p
1862 (goto-char (point-min))
1863 (not (re-search-forward
1864 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
1865 (gnus-buffer-live-p gnus-original-article-buffer))
1866 ;; If type `W f', use gnus-original-article-buffer,
1867 ;; otherwise use the current buffer because displaying
1868 ;; RFC822 parts calls this function too.
1869 (set-buffer gnus-original-article-buffer))
1871 (mail-narrow-to-head)
1872 (if gnus-treat-display-grey-xface
1874 (while (gnus-article-goto-header "X-Face\\(-[0-9]+\\)?")
1875 (if (match-beginning 2)
1878 (push (cons (- (string-to-number (match-string 2)))
1879 (mail-header-field-value))
1881 (push (cons 0 (mail-header-field-value)) x-faces)))
1882 (dolist (x-face (prog1
1884 (sort x-faces 'car-less-than-car)
1886 (setq x-faces nil)))
1887 (push (cdr x-face) x-faces)))
1888 (while (gnus-article-goto-header "X-Face")
1889 (push (mail-header-field-value) x-faces)))
1890 (setq from (message-fetch-field "from"))))
1892 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
1895 (setq image (gnus-create-image xpm 'xpm t))
1896 (gnus-article-goto-header "from")
1898 (insert "From: [no `from' set]\n")
1900 (gnus-add-wash-type 'xface)
1901 (gnus-add-image 'xface image)
1902 (gnus-put-image image)))
1903 ;; Sending multiple EOFs to xv doesn't work, so we only do a
1904 ;; single external face.
1905 (when (stringp gnus-article-x-face-command)
1906 (setq x-faces (list (car x-faces))))
1907 (while (and (setq face (pop x-faces))
1908 gnus-article-x-face-command
1910 ;; Check whether this face is censored.
1911 (not gnus-article-x-face-too-ugly)
1912 (and gnus-article-x-face-too-ugly from
1913 (not (string-match gnus-article-x-face-too-ugly
1915 ;; We display the face.
1916 (if (symbolp gnus-article-x-face-command)
1917 ;; The command is a lisp function, so we call it.
1918 (if (gnus-functionp gnus-article-x-face-command)
1919 (funcall gnus-article-x-face-command face)
1920 (error "%s is not a function" gnus-article-x-face-command))
1921 ;; The command is a string, so we interpret the command
1922 ;; as a, well, command, and fork it off.
1923 (let ((process-connection-type nil))
1924 (process-kill-without-query
1926 "article-x-face" nil shell-file-name shell-command-switch
1927 gnus-article-x-face-command))
1930 (process-send-region "article-x-face"
1931 (point-min) (point-max)))
1932 (process-send-eof "article-x-face"))))))))))
1934 (defun article-decode-mime-words ()
1935 "Decode all MIME-encoded words in the article."
1938 (set-buffer gnus-article-buffer)
1939 (let ((inhibit-point-motion-hooks t)
1941 (mail-parse-charset gnus-newsgroup-charset)
1942 (mail-parse-ignored-charsets
1943 (save-excursion (set-buffer gnus-summary-buffer)
1944 gnus-newsgroup-ignored-charsets)))
1945 (mail-decode-encoded-word-region (point-min) (point-max)))))
1947 (defun article-decode-charset (&optional prompt)
1948 "Decode charset-encoded text in the article.
1949 If PROMPT (the prefix), prompt for a coding system to use."
1951 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1953 (mail-parse-charset gnus-newsgroup-charset)
1954 (mail-parse-ignored-charsets
1955 (save-excursion (condition-case nil
1956 (set-buffer gnus-summary-buffer)
1958 gnus-newsgroup-ignored-charsets))
1959 ct cte ctl charset format)
1962 (article-narrow-to-head)
1963 (setq ct (message-fetch-field "Content-Type" t)
1964 cte (message-fetch-field "Content-Transfer-Encoding" t)
1965 ctl (and ct (ignore-errors
1966 (mail-header-parse-content-type ct)))
1969 (mm-read-coding-system "Charset to decode: "))
1971 (mail-content-type-get ctl 'charset)))
1972 format (and ctl (mail-content-type-get ctl 'format)))
1974 (setq cte (mail-header-strip cte)))
1975 (if (and ctl (not (string-match "/" (car ctl))))
1977 (goto-char (point-max)))
1980 (narrow-to-region (point) (point-max))
1981 (when (and (eq mail-parse-charset 'gnus-decoded)
1982 (eq (mm-body-7-or-8) '8bit))
1983 ;; The text code could have been decoded.
1984 (setq charset mail-parse-charset))
1985 (when (and (or (not ctl)
1986 (equal (car ctl) "text/plain"))
1987 (not format)) ;; article with format will decode later.
1989 charset (and cte (intern (downcase
1990 (gnus-strip-whitespace cte))))
1993 (defun article-decode-encoded-words ()
1994 "Remove encoded-word encoding from headers."
1995 (let ((inhibit-point-motion-hooks t)
1996 (mail-parse-charset gnus-newsgroup-charset)
1997 (mail-parse-ignored-charsets
1998 (save-excursion (condition-case nil
1999 (set-buffer gnus-summary-buffer)
2001 gnus-newsgroup-ignored-charsets))
2004 (article-narrow-to-head)
2005 (funcall gnus-decode-header-function (point-min) (point-max)))))
2007 (defun article-decode-group-name ()
2008 "Decode group names in `Newsgroups:'."
2009 (let ((inhibit-point-motion-hooks t)
2011 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2012 (when (and (or gnus-group-name-charset-method-alist
2013 gnus-group-name-charset-group-alist)
2014 (gnus-buffer-live-p gnus-original-article-buffer))
2015 (when (nnmail-fetch-field "Newsgroups")
2016 (nnheader-replace-header "Newsgroups"
2017 (gnus-decode-newsgroups
2018 (with-current-buffer
2019 gnus-original-article-buffer
2020 (nnmail-fetch-field "Newsgroups"))
2021 gnus-newsgroup-name method)))
2022 (when (nnmail-fetch-field "Followup-To")
2023 (nnheader-replace-header "Followup-To"
2024 (gnus-decode-newsgroups
2025 (with-current-buffer
2026 gnus-original-article-buffer
2027 (nnmail-fetch-field "Followup-To"))
2028 gnus-newsgroup-name method))))))
2030 (defun article-de-quoted-unreadable (&optional force read-charset)
2031 "Translate a quoted-printable-encoded article.
2032 If FORCE, decode the article whether it is marked as quoted-printable
2034 If READ-CHARSET, ask for a coding system."
2035 (interactive (list 'force current-prefix-arg))
2037 (let ((buffer-read-only nil) type charset)
2038 (if (gnus-buffer-live-p gnus-original-article-buffer)
2039 (with-current-buffer gnus-original-article-buffer
2041 (gnus-fetch-field "content-transfer-encoding"))
2042 (let* ((ct (gnus-fetch-field "content-type"))
2045 (mail-header-parse-content-type ct)))))
2046 (setq charset (and ctl
2047 (mail-content-type-get ctl 'charset)))
2048 (if (stringp charset)
2049 (setq charset (intern (downcase charset)))))))
2051 (setq charset (mm-read-coding-system "Charset: " charset)))
2053 (setq charset gnus-newsgroup-charset))
2055 (and type (let ((case-fold-search t))
2056 (string-match "quoted-printable" type))))
2058 (quoted-printable-decode-region
2059 (point) (point-max) (mm-charset-to-coding-system charset))))))
2061 (defun article-de-base64-unreadable (&optional force read-charset)
2062 "Translate a base64 article.
2063 If FORCE, decode the article whether it is marked as base64 not.
2064 If READ-CHARSET, ask for a coding system."
2065 (interactive (list 'force current-prefix-arg))
2067 (let ((buffer-read-only nil) type charset)
2068 (if (gnus-buffer-live-p gnus-original-article-buffer)
2069 (with-current-buffer gnus-original-article-buffer
2071 (gnus-fetch-field "content-transfer-encoding"))
2072 (let* ((ct (gnus-fetch-field "content-type"))
2075 (mail-header-parse-content-type ct)))))
2076 (setq charset (and ctl
2077 (mail-content-type-get ctl 'charset)))
2078 (if (stringp charset)
2079 (setq charset (intern (downcase charset)))))))
2081 (setq charset (mm-read-coding-system "Charset: " charset)))
2083 (setq charset gnus-newsgroup-charset))
2085 (and type (let ((case-fold-search t))
2086 (string-match "base64" type))))
2089 (narrow-to-region (point) (point-max))
2090 (base64-decode-region (point-min) (point-max))
2091 (mm-decode-coding-region
2092 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2097 (defun article-decode-HZ ()
2098 "Translate a HZ-encoded article."
2102 (let ((buffer-read-only nil))
2103 (rfc1843-decode-region (point-min) (point-max)))))
2105 (defun article-unsplit-urls ()
2106 "Remove the newlines that some other mailers insert into URLs."
2109 (let ((buffer-read-only nil))
2110 (goto-char (point-min))
2111 (while (re-search-forward
2112 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2113 (replace-match "\\1\\3" t)))
2114 (when (and gnus-display-mime-function (interactive-p))
2115 (funcall gnus-display-mime-function))))
2118 (defun article-wash-html (&optional read-charset)
2119 "Format an html article.
2120 If READ-CHARSET, ask for a coding system."
2123 (let ((buffer-read-only nil)
2125 (if (gnus-buffer-live-p gnus-original-article-buffer)
2126 (with-current-buffer gnus-original-article-buffer
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 (save-window-excursion
2142 (narrow-to-region (point) (point-max))
2143 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2144 (entry (assq func mm-text-html-washer-alist)))
2146 (setq func (cdr entry)))
2148 ((gnus-functionp func)
2151 (apply (car func) (cdr func))))))))))
2153 (defun gnus-article-wash-html-with-w3 ()
2154 "Wash the current buffer with w3."
2156 (let ((w3-strict-width (window-width))
2157 (url-standalone-mode t)
2158 (url-gateway-unplugged t)
2159 (w3-honor-stylesheets nil))
2161 (w3-region (point-min) (point-max))
2164 (defun gnus-article-wash-html-with-w3m ()
2165 "Wash the current buffer with emacs-w3m."
2168 (narrow-to-region (point) (point-max))
2169 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2172 (w3m-display-inline-images mm-inline-text-html-with-images)
2173 w3m-force-redisplay)
2174 (w3m-region (point-min) (point-max)))
2175 (when mm-inline-text-html-with-w3m-keymap
2176 (add-text-properties
2177 (point-min) (point-max)
2178 (append '(mm-inline-text-html-with-w3m t)
2179 (gnus-local-map-property mm-w3m-mode-map))))))
2181 (defun article-hide-list-identifiers ()
2182 "Remove list identifies from the Subject header.
2183 The `gnus-list-identifiers' variable specifies what to do."
2185 (let ((inhibit-point-motion-hooks t)
2186 (regexp (if (consp gnus-list-identifiers)
2187 (mapconcat 'identity gnus-list-identifiers " *\\|")
2188 gnus-list-identifiers))
2193 (article-narrow-to-head)
2194 (goto-char (point-min))
2195 (while (re-search-forward
2196 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2198 (delete-region (match-beginning 2) (match-end 0))
2199 (beginning-of-line))
2200 (when (re-search-forward
2201 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2202 (delete-region (match-beginning 1) (match-end 1))))))))
2204 (defun article-hide-pgp ()
2205 "Remove any PGP headers and signatures in the current article."
2209 (let ((inhibit-point-motion-hooks t)
2210 buffer-read-only beg end)
2212 ;; Hide the "header".
2213 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2214 (gnus-add-wash-type 'pgp)
2215 (delete-region (match-beginning 0) (match-end 0))
2216 ;; Remove armor headers (rfc2440 6.2)
2217 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2220 ;; Hide the actual signature.
2221 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2222 (setq end (1+ (match-beginning 0)))
2225 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2227 ;; Perhaps we shouldn't hide to the end of the buffer
2228 ;; if there is no end to the signature?
2230 ;; Hide "- " PGP quotation markers.
2232 (narrow-to-region beg end)
2233 (goto-char (point-min))
2234 (while (re-search-forward "^- " nil t)
2236 (match-beginning 0) (match-end 0)))
2238 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2240 (defun article-hide-pem (&optional arg)
2241 "Toggle hiding of any PEM headers and signatures in the current article.
2242 If given a negative prefix, always show; if given a positive prefix,
2244 (interactive (gnus-article-hidden-arg))
2245 (unless (gnus-article-check-hidden-text 'pem arg)
2247 (let (buffer-read-only end)
2248 (goto-char (point-min))
2249 ;; Hide the horrendously ugly "header".
2250 (when (and (search-forward
2251 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2253 (setq end (1+ (match-beginning 0))))
2254 (gnus-add-wash-type 'pem)
2255 (gnus-article-hide-text-type
2257 (if (search-forward "\n\n" nil t)
2261 ;; Hide the trailer as well
2262 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2264 (gnus-article-hide-text-type
2265 (match-beginning 0) (match-end 0) 'pem)))))))
2267 (defun article-strip-banner ()
2268 "Strip the banner specified by the `banner' group parameter."
2272 (let ((inhibit-point-motion-hooks t)
2273 (banner (gnus-parameter-banner gnus-newsgroup-name))
2274 (gnus-signature-limit nil)
2275 buffer-read-only beg end)
2276 (when (and gnus-article-address-banner-alist
2279 (let ((from (save-restriction
2281 (article-narrow-to-head)
2282 (mail-fetch-field "from"))))
2285 (caar (mail-header-parse-addresses from))))
2287 (dolist (pair gnus-article-address-banner-alist)
2288 (when (string-match (car pair) from)
2289 (throw 'found (cdr pair)))))))))
2293 ((eq banner 'signature)
2294 (when (gnus-article-narrow-to-signature)
2297 (delete-region (point) (point-max))))
2299 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2300 (while (re-search-forward banner nil t)
2301 (delete-region (match-beginning 0) (match-end 0)))))
2303 (while (re-search-forward banner nil t)
2304 (delete-region (match-beginning 0) (match-end 0))))))))))
2306 (defun article-babel ()
2307 "Translate article using an online translation service."
2311 (set-buffer gnus-article-buffer)
2312 (when (article-goto-body)
2313 (let* ((buffer-read-only nil)
2316 (orig (buffer-substring start end))
2317 (trans (babel-as-string orig)))
2319 (narrow-to-region start end)
2320 (delete-region start end)
2323 (defun article-hide-signature (&optional arg)
2324 "Hide the signature in the current article.
2325 If given a negative prefix, always show; if given a positive prefix,
2327 (interactive (gnus-article-hidden-arg))
2328 (unless (gnus-article-check-hidden-text 'signature arg)
2331 (let ((buffer-read-only nil))
2332 (when (gnus-article-narrow-to-signature)
2333 (gnus-article-hide-text-type
2334 (point-min) (point-max) 'signature))))))
2335 (gnus-set-mode-line 'article))
2337 (defun article-strip-headers-in-body ()
2338 "Strip offensive headers from bodies."
2342 (let ((case-fold-search t))
2343 (when (looking-at "x-no-archive:")
2344 (gnus-delete-line)))))
2346 (defun article-strip-leading-blank-lines ()
2347 "Remove all blank lines from the beginning of the article."
2350 (let ((inhibit-point-motion-hooks t)
2352 (when (article-goto-body)
2353 (while (and (not (eobp))
2354 (looking-at "[ \t]*$"))
2355 (gnus-delete-line))))))
2357 (defun article-narrow-to-head ()
2358 "Narrow the buffer to the head of the message.
2359 Point is left at the beginning of the narrowed-to region."
2361 (goto-char (point-min))
2362 (if (search-forward "\n\n" nil 1)
2365 (goto-char (point-min)))
2367 (defun article-goto-body ()
2368 "Place point at the start of the body."
2369 (goto-char (point-min))
2371 ;; This variable is only bound when dealing with separate
2373 (article-goto-body-goes-to-point-min-p
2375 ((search-forward "\n\n" nil t)
2378 (goto-char (point-max))
2381 (defun article-strip-multiple-blank-lines ()
2382 "Replace consecutive blank lines with one empty line."
2385 (let ((inhibit-point-motion-hooks t)
2387 ;; First make all blank lines empty.
2389 (while (re-search-forward "^[ \t]+$" nil t)
2390 (unless (gnus-annotation-in-region-p
2391 (match-beginning 0) (match-end 0))
2392 (replace-match "" nil t)))
2393 ;; Then replace multiple empty lines with a single empty line.
2395 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2396 (unless (gnus-annotation-in-region-p
2397 (match-beginning 0) (match-end 0))
2398 (delete-region (match-beginning 1) (match-end 1)))))))
2400 (defun article-strip-leading-space ()
2401 "Remove all white space from the beginning of the lines in the article."
2404 (let ((inhibit-point-motion-hooks t)
2407 (while (re-search-forward "^[ \t]+" nil t)
2408 (replace-match "" t t)))))
2410 (defun article-strip-trailing-space ()
2411 "Remove all white space from the end of the lines in the article."
2414 (let ((inhibit-point-motion-hooks t)
2417 (while (re-search-forward "[ \t]+$" nil t)
2418 (replace-match "" t t)))))
2420 (defun article-strip-blank-lines ()
2421 "Strip leading, trailing and multiple blank lines."
2423 (article-strip-leading-blank-lines)
2424 (article-remove-trailing-blank-lines)
2425 (article-strip-multiple-blank-lines))
2427 (defun article-strip-all-blank-lines ()
2428 "Strip all blank lines."
2431 (let ((inhibit-point-motion-hooks t)
2434 (while (re-search-forward "^[ \t]*\n" nil t)
2435 (replace-match "" t t)))))
2437 (defun gnus-article-narrow-to-signature ()
2438 "Narrow to the signature; return t if a signature is found, else nil."
2439 (let ((inhibit-point-motion-hooks t))
2440 (when (gnus-article-search-signature)
2442 ;; Check whether we have some limits to what we consider
2443 ;; to be a signature.
2444 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2445 (list gnus-signature-limit)))
2447 (while (setq limit (pop limits))
2448 (if (or (and (integerp limit)
2449 (< (- (point-max) (point)) limit))
2451 (< (count-lines (point) (point-max)) limit))
2452 (and (gnus-functionp limit)
2454 (and (stringp limit)
2455 (not (re-search-forward limit nil t))))
2456 () ; This limit did not succeed.
2460 (narrow-to-region (point) (point-max))
2463 (defun gnus-article-search-signature ()
2464 "Search the current buffer for the signature separator.
2465 Put point at the beginning of the signature separator."
2466 (let ((cur (point)))
2467 (goto-char (point-max))
2468 (if (if (stringp gnus-signature-separator)
2469 (re-search-backward gnus-signature-separator nil t)
2470 (let ((seps gnus-signature-separator))
2472 (not (re-search-backward (car seps) nil t)))
2479 (defun gnus-article-hidden-arg ()
2480 "Return the current prefix arg as a number, or 0 if no prefix."
2481 (list (if current-prefix-arg
2482 (prefix-numeric-value current-prefix-arg)
2485 (defun gnus-article-check-hidden-text (type arg)
2486 "Return nil if hiding is necessary.
2487 Arg can be nil or a number. nil and positive means hide, negative
2488 means show, 0 means toggle."
2491 (let ((hide (gnus-article-hidden-text-p type)))
2497 (gnus-article-show-hidden-text type)
2500 (if (eq hide 'hidden)
2502 (gnus-article-show-hidden-text type)
2506 (defun gnus-article-hidden-text-p (type)
2507 "Say whether the current buffer contains hidden text of type TYPE."
2508 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2510 (not (get-text-property pos 'invisible))
2511 (not (get-text-property pos 'dummy-invisible)))
2513 (text-property-any (1+ pos) (point-max) 'article-type type)))
2518 (defun gnus-article-show-hidden-text (type &optional dummy)
2519 "Show all hidden text of type TYPE.
2520 Originally it is hide instead of DUMMY."
2521 (let ((buffer-read-only nil)
2522 (inhibit-point-motion-hooks t))
2523 (gnus-remove-text-properties-when
2525 (point-min) (point-max)
2526 (cons 'article-type (cons type
2527 gnus-hidden-properties)))
2528 (gnus-delete-wash-type type)))
2530 (defconst article-time-units
2531 `((year . ,(* 365.25 24 60 60))
2532 (week . ,(* 7 24 60 60))
2533 (day . ,(* 24 60 60))
2537 "Mapping from time units to seconds.")
2539 (defun article-date-ut (&optional type highlight header)
2540 "Convert DATE date to universal time in the current article.
2541 If TYPE is `local', convert to local time; if it is `lapsed', output
2542 how much time has lapsed since DATE. For `lapsed', the value of
2543 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2544 should replace the \"Date:\" one, or should be added below it."
2545 (interactive (list 'ut t))
2546 (let* ((header (or header
2547 (message-fetch-field "date")
2549 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2552 ((not gnus-article-date-lapsed-new-header)
2558 (date (if (vectorp header) (mail-header-date header)
2560 (inhibit-point-motion-hooks t)
2565 (article-narrow-to-head)
2566 (when (re-search-forward tdate-regexp nil t)
2567 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2568 date (or (get-text-property (gnus-point-at-bol)
2571 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2573 (when (and date (not (string= date "")))
2574 (goto-char (point-min))
2575 (let ((buffer-read-only nil))
2576 ;; Delete any old Date headers.
2577 (while (re-search-forward date-regexp nil t)
2579 (delete-region (progn (beginning-of-line) (point))
2580 (progn (forward-line 1) (point)))
2581 (delete-region (progn (beginning-of-line) (point))
2582 (progn (end-of-line) (point)))
2583 (setq pos (point))))
2584 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2586 (if pos (goto-char pos))
2587 (insert (article-make-date-line date (or type 'ut)))
2593 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2594 (put-text-property (match-beginning 1) (1+ (match-end 1))
2595 'original-date date)
2596 (put-text-property (match-beginning 1) (1+ (match-end 1))
2598 (put-text-property (match-beginning 2) (match-end 2)
2601 (defun article-make-date-line (date type)
2602 "Return a DATE line of TYPE."
2603 (unless (memq type '(local ut original user iso8601 lapsed english))
2604 (error "Unknown conversion type: %s" type))
2606 (let ((time (date-to-time date)))
2608 ;; Convert to the local timezone.
2610 (let ((tz (car (current-time-zone time))))
2611 (format "Date: %s %s%02d%02d" (current-time-string time)
2612 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2613 (/ (% (abs tz) 3600) 60))))
2614 ;; Convert to Universal Time.
2617 (current-time-string
2618 (let* ((e (parse-time-string date))
2619 (tm (apply 'encode-time e))
2621 (ls (- (cadr tm) (car (current-time-zone time)))))
2622 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2623 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2626 ;; Get the original date from the article.
2627 ((eq type 'original)
2628 (concat "Date: " (if (string-match "\n+$" date)
2629 (substring date 0 (match-beginning 0))
2631 ;; Let the user define the format.
2633 (let ((format (or (condition-case nil
2634 (with-current-buffer gnus-summary-buffer
2635 gnus-article-time-format)
2637 gnus-article-time-format)))
2638 (if (gnus-functionp format)
2639 (funcall format time)
2640 (concat "Date: " (format-time-string format time)))))
2643 (let ((tz (car (current-time-zone time))))
2646 (format-time-string "%Y%m%dT%H%M%S" time)
2647 (format "%s%02d%02d"
2648 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2649 (/ (% (abs tz) 3600) 60)))))
2650 ;; Do an X-Sent lapsed format.
2652 ;; If the date is seriously mangled, the timezone functions are
2653 ;; liable to bug out, so we ignore all errors.
2654 (let* ((now (current-time))
2655 (real-time (subtract-time now time))
2656 (real-sec (and real-time
2657 (+ (* (float (car real-time)) 65536)
2659 (sec (and real-time (abs real-sec)))
2669 ;; This is a bit convoluted, but basically we go
2670 ;; through the time units for years, weeks, etc,
2671 ;; and divide things to see whether that results
2672 ;; in positive answers.
2675 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2676 ;; The (remaining) seconds are too few to
2677 ;; be divided into this time unit.
2679 ;; It's big enough, so we output it.
2680 (setq sec (- sec (* num (cdr unit))))
2682 (concat (if prev ", " "") (int-to-string
2684 " " (symbol-name (car unit))
2685 (if (> num 1) "s" ""))
2687 article-time-units "")
2688 ;; If dates are odd, then it might appear like the
2689 ;; article was sent in the future.
2692 " in the future"))))))
2693 ;; Display the date in proper English
2695 (let ((dtime (decode-time time)))
2698 (number-to-string (nth 3 dtime))
2699 (let ((digit (% (nth 3 dtime) 10)))
2701 ((memq (nth 3 dtime) '(11 12 13)) "th")
2707 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2709 (number-to-string (nth 5 dtime))
2711 (format "%02d" (nth 2 dtime))
2713 (format "%02d" (nth 1 dtime)))))))
2715 (format "Date: %s (from Gnus)" date))))
2717 (defun article-date-local (&optional highlight)
2718 "Convert the current article date to the local timezone."
2719 (interactive (list t))
2720 (article-date-ut 'local highlight))
2722 (defun article-date-english (&optional highlight)
2723 "Convert the current article date to something that is proper English."
2724 (interactive (list t))
2725 (article-date-ut 'english highlight))
2727 (defun article-date-original (&optional highlight)
2728 "Convert the current article date to what it was originally.
2729 This is only useful if you have used some other date conversion
2730 function and want to see what the date was before converting."
2731 (interactive (list t))
2732 (article-date-ut 'original highlight))
2734 (defun article-date-lapsed (&optional highlight)
2735 "Convert the current article date to time lapsed since it was sent."
2736 (interactive (list t))
2737 (article-date-ut 'lapsed highlight))
2739 (defun article-update-date-lapsed ()
2740 "Function to be run from a timer to update the lapsed time line."
2741 (let (deactivate-mark)
2746 (set-buffer (window-buffer w))
2747 (when (eq major-mode 'gnus-article-mode)
2748 (goto-char (point-min))
2749 (when (re-search-forward "^X-Sent:" nil t)
2750 (article-date-lapsed t))))
2753 (defun gnus-start-date-timer (&optional n)
2754 "Start a timer to update the X-Sent header in the article buffers.
2755 The numerical prefix says how frequently (in seconds) the function
2760 (gnus-stop-date-timer)
2761 (setq article-lapsed-timer
2762 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2764 (defun gnus-stop-date-timer ()
2765 "Stop the X-Sent timer."
2767 (when article-lapsed-timer
2768 (nnheader-cancel-timer article-lapsed-timer)
2769 (setq article-lapsed-timer nil)))
2771 (defun article-date-user (&optional highlight)
2772 "Convert the current article date to the user-defined format.
2773 This format is defined by the `gnus-article-time-format' variable."
2774 (interactive (list t))
2775 (article-date-ut 'user highlight))
2777 (defun article-date-iso8601 (&optional highlight)
2778 "Convert the current article date to ISO8601."
2779 (interactive (list t))
2780 (article-date-ut 'iso8601 highlight))
2782 ;; (defun article-show-all ()
2783 ;; "Show all hidden text in the article buffer."
2786 ;; (let ((buffer-read-only nil))
2787 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2789 (defun article-remove-leading-whitespace ()
2790 "Remove excessive whitespace from all headers."
2794 (let ((buffer-read-only nil))
2795 (article-narrow-to-head)
2796 (goto-char (point-min))
2797 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2798 (delete-region (match-beginning 1) (match-end 1)))))))
2800 (defun article-emphasize (&optional arg)
2801 "Emphasize text according to `gnus-emphasis-alist'."
2802 (interactive (gnus-article-hidden-arg))
2803 (unless (gnus-article-check-hidden-text 'emphasis arg)
2807 (with-current-buffer gnus-summary-buffer
2808 gnus-article-emphasis-alist)
2810 gnus-emphasis-alist))
2811 (buffer-read-only nil)
2812 (props (append '(article-type emphasis)
2813 gnus-hidden-properties))
2814 regexp elem beg invisible visible face)
2817 (while (setq elem (pop alist))
2819 (setq regexp (car elem)
2820 invisible (nth 1 elem)
2821 visible (nth 2 elem)
2823 (while (re-search-forward regexp nil t)
2824 (when (and (match-beginning visible) (match-beginning invisible))
2825 (gnus-article-hide-text
2826 (match-beginning invisible) (match-end invisible) props)
2827 (gnus-article-unhide-text-type
2828 (match-beginning visible) (match-end visible) 'emphasis)
2829 (gnus-put-overlay-excluding-newlines
2830 (match-beginning visible) (match-end visible) 'face face)
2831 (gnus-add-wash-type 'emphasis)
2832 (goto-char (match-end invisible)))))))))
2834 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2835 "Setup newsgroup emphasis alist."
2836 (unless gnus-article-emphasis-alist
2837 (let ((name (and gnus-newsgroup-name
2838 (gnus-group-real-name gnus-newsgroup-name))))
2839 (make-local-variable 'gnus-article-emphasis-alist)
2840 (setq gnus-article-emphasis-alist
2842 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2843 (while (setq elem (pop alist))
2844 (when (and name (string-match (car elem) name))
2846 highlight (copy-sequence (cdr elem)))))
2848 (copy-sequence highlight-words)
2849 (if gnus-newsgroup-name
2850 (copy-sequence (gnus-group-find-parameter
2851 gnus-newsgroup-name 'highlight-words t)))
2852 gnus-emphasis-alist)))))
2855 (defvar gnus-summary-article-menu)
2856 (defvar gnus-summary-post-menu))
2858 ;;; Saving functions.
2860 (defun gnus-article-save (save-buffer file &optional num)
2861 "Save the currently selected article."
2862 (unless gnus-save-all-headers
2863 ;; Remove headers according to `gnus-saved-headers'.
2864 (let ((gnus-visible-headers
2865 (or gnus-saved-headers gnus-visible-headers))
2866 (gnus-article-buffer save-buffer))
2868 (set-buffer save-buffer)
2869 (article-hide-headers 1 t))))
2870 (save-window-excursion
2871 (if (not gnus-default-article-saver)
2872 (error "No default saver is defined")
2873 ;; !!! Magic! The saving functions all save
2874 ;; `gnus-save-article-buffer' (or so they think), but we
2875 ;; bind that variable to our save-buffer.
2876 (set-buffer gnus-article-buffer)
2877 (let* ((gnus-save-article-buffer save-buffer)
2880 ((not gnus-prompt-before-saving) 'default)
2881 ((eq gnus-prompt-before-saving 'always) nil)
2883 (gnus-number-of-articles-to-be-saved
2884 (when (eq gnus-prompt-before-saving t)
2886 (set-buffer gnus-article-current-summary)
2887 (funcall gnus-default-article-saver filename)))))
2889 (defun gnus-read-save-file-name (prompt &optional filename
2890 function group headers variable)
2892 (funcall function group headers (symbol-value variable)))
2897 ((eq filename 'default)
2903 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2906 (if (and gnus-number-of-articles-to-be-saved
2907 (> gnus-number-of-articles-to-be-saved 1))
2908 (format "these %d articles"
2909 gnus-number-of-articles-to-be-saved)
2912 ;; Let the split methods have their say.
2914 ;; No split name was found.
2917 (concat prompt " (default "
2918 (file-name-nondirectory default-name) ") ")
2919 (file-name-directory default-name)
2921 ;; A single group name is returned.
2922 ((stringp split-name)
2924 (funcall function split-name headers
2925 (symbol-value variable)))
2927 (concat prompt " (default "
2928 (file-name-nondirectory default-name) ") ")
2929 (file-name-directory default-name)
2931 ;; A single split name was found
2932 ((= 1 (length split-name))
2933 (let* ((name (expand-file-name
2935 gnus-article-save-directory))
2936 (dir (cond ((file-directory-p name)
2937 (file-name-as-directory name))
2938 ((file-exists-p name) name)
2939 (t gnus-article-save-directory))))
2941 (concat prompt " (default " name ") ")
2943 ;; A list of splits was found.
2945 (setq split-name (nreverse split-name))
2947 (let ((file-name-history
2948 (nconc split-name file-name-history)))
2952 (concat prompt " (`M-p' for defaults) ")
2953 gnus-article-save-directory
2955 gnus-article-save-directory)))
2956 (car (push result file-name-history)))))))
2957 ;; Create the directory.
2958 (gnus-make-directory (file-name-directory file))
2959 ;; If we have read a directory, we append the default file name.
2960 (when (file-directory-p file)
2961 (setq file (expand-file-name (file-name-nondirectory
2963 (file-name-as-directory file))))
2964 ;; Possibly translate some characters.
2965 (nnheader-translate-file-chars file))))))
2966 (gnus-make-directory (file-name-directory result))
2967 (set variable result)))
2969 (defun gnus-article-archive-name (group)
2970 "Return the first instance of an \"Archive-name\" in the current buffer."
2971 (let ((case-fold-search t))
2972 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2973 (nnheader-concat gnus-article-save-directory
2974 (match-string 1)))))
2976 (defun gnus-article-nndoc-name (group)
2977 "If GROUP is an nndoc group, return the name of the parent group."
2978 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2979 (gnus-group-get-parameter group 'save-article-group)))
2981 (defun gnus-summary-save-in-rmail (&optional filename)
2982 "Append this article to Rmail file.
2983 Optional argument FILENAME specifies file name.
2984 Directory to save to is default to `gnus-article-save-directory'."
2985 (setq filename (gnus-read-save-file-name
2986 "Save %s in rmail file:" filename
2987 gnus-rmail-save-name gnus-newsgroup-name
2988 gnus-current-headers 'gnus-newsgroup-last-rmail))
2989 (gnus-eval-in-buffer-window gnus-save-article-buffer
2993 (gnus-output-to-rmail filename))))
2996 (defun gnus-summary-save-in-mail (&optional filename)
2997 "Append this article to Unix mail file.
2998 Optional argument FILENAME specifies file name.
2999 Directory to save to is default to `gnus-article-save-directory'."
3000 (setq filename (gnus-read-save-file-name
3001 "Save %s in Unix mail file:" filename
3002 gnus-mail-save-name gnus-newsgroup-name
3003 gnus-current-headers 'gnus-newsgroup-last-mail))
3004 (gnus-eval-in-buffer-window gnus-save-article-buffer
3008 (if (and (file-readable-p filename)
3009 (mail-file-babyl-p filename))
3010 (rmail-output-to-rmail-file filename t)
3011 (gnus-output-to-mail filename)))))
3014 (defun gnus-summary-save-in-file (&optional filename overwrite)
3015 "Append this article to file.
3016 Optional argument FILENAME specifies file name.
3017 Directory to save to is default to `gnus-article-save-directory'."
3018 (setq filename (gnus-read-save-file-name
3019 "Save %s in file:" filename
3020 gnus-file-save-name gnus-newsgroup-name
3021 gnus-current-headers 'gnus-newsgroup-last-file))
3022 (gnus-eval-in-buffer-window gnus-save-article-buffer
3026 (when (and overwrite
3027 (file-exists-p filename))
3028 (delete-file filename))
3029 (gnus-output-to-file filename))))
3032 (defun gnus-summary-write-to-file (&optional filename)
3033 "Write this article to a file, overwriting it if the file exists.
3034 Optional argument FILENAME specifies file name.
3035 The directory to save in defaults to `gnus-article-save-directory'."
3036 (gnus-summary-save-in-file nil t))
3038 (defun gnus-summary-save-body-in-file (&optional filename)
3039 "Append this article body to a file.
3040 Optional argument FILENAME specifies file name.
3041 The directory to save in defaults to `gnus-article-save-directory'."
3042 (setq filename (gnus-read-save-file-name
3043 "Save %s body in file:" filename
3044 gnus-file-save-name gnus-newsgroup-name
3045 gnus-current-headers 'gnus-newsgroup-last-file))
3046 (gnus-eval-in-buffer-window gnus-save-article-buffer
3050 (when (article-goto-body)
3051 (narrow-to-region (point) (point-max)))
3052 (gnus-output-to-file filename))))
3055 (defun gnus-summary-save-in-pipe (&optional command)
3056 "Pipe this article to subprocess."
3058 (cond ((and (eq command 'default)
3059 gnus-last-shell-command)
3060 gnus-last-shell-command)
3065 "Shell command on %s: "
3066 (if (and gnus-number-of-articles-to-be-saved
3067 (> gnus-number-of-articles-to-be-saved 1))
3068 (format "these %d articles"
3069 gnus-number-of-articles-to-be-saved)
3071 gnus-last-shell-command))))
3072 (when (string-equal command "")
3073 (if gnus-last-shell-command
3074 (setq command gnus-last-shell-command)
3075 (error "A command is required")))
3076 (gnus-eval-in-buffer-window gnus-article-buffer
3079 (shell-command-on-region (point-min) (point-max) command nil)))
3080 (setq gnus-last-shell-command command))
3082 (defun gnus-summary-pipe-to-muttprint (&optional command)
3083 "Pipe this article to muttprint."
3084 (setq command (read-string
3085 "Print using command: " gnus-summary-muttprint-program
3086 nil gnus-summary-muttprint-program))
3087 (gnus-summary-save-in-pipe command))
3089 ;;; Article file names when saving.
3091 (defun gnus-capitalize-newsgroup (newsgroup)
3092 "Capitalize NEWSGROUP name."
3093 (when (not (zerop (length newsgroup)))
3094 (concat (char-to-string (upcase (aref newsgroup 0)))
3095 (substring newsgroup 1))))
3097 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3098 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3099 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3100 Otherwise, it is like ~/News/news/group/num."
3103 (concat (if (gnus-use-long-file-name 'not-save)
3104 (gnus-capitalize-newsgroup newsgroup)
3105 (gnus-newsgroup-directory-form newsgroup))
3106 "/" (int-to-string (mail-header-number headers)))
3107 gnus-article-save-directory)))
3109 (string-equal (file-name-directory default)
3110 (file-name-directory last-file))
3111 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3113 (or last-file default))))
3115 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3116 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3117 If variable `gnus-use-long-file-name' is non-nil, it is
3118 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3121 (concat (if (gnus-use-long-file-name 'not-save)
3123 (gnus-newsgroup-directory-form newsgroup))
3124 "/" (int-to-string (mail-header-number headers)))
3125 gnus-article-save-directory)))
3127 (string-equal (file-name-directory default)
3128 (file-name-directory last-file))
3129 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3131 (or last-file default))))
3133 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3134 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3135 If variable `gnus-use-long-file-name' is non-nil, it is
3136 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3139 (if (gnus-use-long-file-name 'not-save)
3142 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3144 gnus-article-save-directory)))
3146 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3147 "Generate file name from sender."
3148 (let ((from (mail-header-from headers)))
3150 (if (and from (string-match "\\([^ <]+\\)@" from))
3151 (match-string 1 from)
3153 gnus-article-save-directory)))
3155 (defun article-verify-x-pgp-sig ()
3158 (if (gnus-buffer-live-p gnus-original-article-buffer)
3159 (let ((sig (with-current-buffer gnus-original-article-buffer
3160 (gnus-fetch-field "X-PGP-Sig")))
3164 (mml2015-clear-verify-function))
3166 (insert-buffer gnus-original-article-buffer)
3167 (setq items (split-string sig))
3168 (message-narrow-to-head)
3169 (let ((inhibit-point-motion-hooks t)
3170 (case-fold-search t))
3171 ;; Don't verify multiple headers.
3172 (setq headers (mapconcat (lambda (header)
3174 (mail-fetch-field header) "\n"))
3175 (split-string (nth 1 items) ",") "")))
3176 (delete-region (point-min) (point-max))
3177 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3178 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3183 (if (looking-at "^-")
3186 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3187 (insert "Version: " (car items) "\n\n")
3188 (insert (mapconcat 'identity (cddr items) "\n"))
3189 (insert "\n-----END PGP SIGNATURE-----\n")
3190 (let ((mm-security-handle (list (format "multipart/signed"))))
3191 (mml2015-clean-buffer)
3192 (let ((coding-system-for-write (or gnus-newsgroup-charset
3194 (funcall (mml2015-clear-verify-function)))
3196 (or (mm-handle-multipart-ctl-parameter
3197 mm-security-handle 'gnus-details)
3198 (mm-handle-multipart-ctl-parameter
3199 mm-security-handle 'gnus-info)))))
3201 (let (buffer-read-only bface eface)
3203 (message-narrow-to-head)
3204 (goto-char (point-max))
3206 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3207 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3208 (message-remove-header "X-Gnus-PGP-Verify")
3209 (if (re-search-forward "^X-PGP-Sig:" nil t)
3211 (goto-char (point-max)))
3212 (narrow-to-region (point) (point))
3213 (insert "X-Gnus-PGP-Verify: " info "\n")
3214 (goto-char (point-min))
3217 (if (not (looking-at "^[ \t]"))
3221 (goto-char (point-min))
3222 (when (looking-at "\\([^:]+\\): *")
3223 (put-text-property (match-beginning 1) (1+ (match-end 1))
3225 (put-text-property (match-end 0) (point-max)
3226 'face eface)))))))))
3228 (defun article-verify-cancel-lock ()
3229 "Verify Cancel-Lock header."
3231 (if (gnus-buffer-live-p gnus-original-article-buffer)
3232 (canlock-verify gnus-original-article-buffer)))
3239 (setq afunc (car func)
3242 gfunc (intern (format "gnus-%s" func))))
3244 (when (fboundp afunc)
3245 `(lambda (&optional interactive &rest args)
3246 ,(documentation afunc t)
3247 (interactive (list t))
3249 (set-buffer gnus-article-buffer)
3251 (call-interactively ',afunc)
3252 (apply ',afunc args))))))))
3253 '(article-hide-headers
3254 article-verify-x-pgp-sig
3255 article-verify-cancel-lock
3256 article-hide-boring-headers
3257 article-treat-overstrike
3258 article-fill-long-lines
3259 article-capitalize-sentences
3261 article-remove-leading-whitespace
3262 article-display-x-face
3263 article-de-quoted-unreadable
3264 article-de-base64-unreadable
3267 article-unsplit-urls
3268 article-hide-list-identifiers
3270 article-strip-banner
3273 article-hide-signature
3274 article-strip-headers-in-body
3275 article-remove-trailing-blank-lines
3276 article-strip-leading-blank-lines
3277 article-strip-multiple-blank-lines
3278 article-strip-leading-space
3279 article-strip-trailing-space
3280 article-strip-blank-lines
3281 article-strip-all-blank-lines
3283 article-date-english
3284 article-date-iso8601
3285 article-date-original
3287 article-decode-mime-words
3288 article-decode-charset
3289 article-decode-encoded-words
3293 article-treat-dumbquotes
3294 article-normalize-headers
3295 ;; (article-show-all . gnus-article-show-all-headers)
3299 ;;; Gnus article mode
3302 (put 'gnus-article-mode 'mode-class 'special)
3304 (set-keymap-parent gnus-article-mode-map widget-keymap)
3306 (gnus-define-keys gnus-article-mode-map
3307 " " gnus-article-goto-next-page
3308 "\177" gnus-article-goto-prev-page
3309 [delete] gnus-article-goto-prev-page
3310 [backspace] gnus-article-goto-prev-page
3311 "\C-c^" gnus-article-refer-article
3312 "h" gnus-article-show-summary
3313 "s" gnus-article-show-summary
3314 "\C-c\C-m" gnus-article-mail
3315 "?" gnus-article-describe-briefly
3316 "e" gnus-summary-edit-article
3317 "<" beginning-of-buffer
3319 "\C-c\C-i" gnus-info-find-node
3321 "R" gnus-article-reply-with-original
3322 "F" gnus-article-followup-with-original
3323 "\C-hk" gnus-article-describe-key
3324 "\C-hc" gnus-article-describe-key-briefly
3326 "\C-d" gnus-article-read-summary-keys
3327 "\M-*" gnus-article-read-summary-keys
3328 "\M-#" gnus-article-read-summary-keys
3329 "\M-^" gnus-article-read-summary-keys
3330 "\M-g" gnus-article-read-summary-keys)
3332 (substitute-key-definition
3333 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3335 (defun gnus-article-make-menu-bar ()
3336 (unless (boundp 'gnus-article-commands-menu)
3337 (gnus-summary-make-menu-bar))
3338 (gnus-turn-off-edit-menu 'article)
3339 (unless (boundp 'gnus-article-article-menu)
3341 gnus-article-article-menu gnus-article-mode-map ""
3343 ["Scroll forwards" gnus-article-goto-next-page t]
3344 ["Scroll backwards" gnus-article-goto-prev-page t]
3345 ["Show summary" gnus-article-show-summary t]
3346 ["Fetch Message-ID at point" gnus-article-refer-article t]
3347 ["Mail to address at point" gnus-article-mail t]
3348 ["Send a bug report" gnus-bug t]))
3351 gnus-article-treatment-menu gnus-article-mode-map ""
3352 ;; Fixme: this should use :active (and maybe :visible).
3354 ["Hide headers" gnus-article-hide-headers t]
3355 ["Hide signature" gnus-article-hide-signature t]
3356 ["Hide citation" gnus-article-hide-citation t]
3357 ["Treat overstrike" gnus-article-treat-overstrike t]
3358 ["Remove carriage return" gnus-article-remove-cr t]
3359 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3360 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3361 ["Remove base64" gnus-article-de-base64-unreadable t]
3362 ["Treat html" gnus-article-wash-html t]
3363 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3364 ["Decode HZ" gnus-article-decode-HZ t]))
3366 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3368 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3370 (gnus-run-hooks 'gnus-article-menu-hook)))
3372 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3375 (defun gnus-article-mode ()
3376 "Major mode for displaying an article.
3378 All normal editing commands are switched off.
3380 The following commands are available in addition to all summary mode
3382 \\<gnus-article-mode-map>
3383 \\[gnus-article-next-page]\t Scroll the article one page forwards
3384 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3385 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3386 \\[gnus-article-show-summary]\t Display the summary buffer
3387 \\[gnus-article-mail]\t Send a reply to the address near point
3388 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3389 \\[gnus-info-find-node]\t Go to the Gnus info node"
3391 (gnus-simplify-mode-line)
3392 (setq mode-name "Article")
3393 (setq major-mode 'gnus-article-mode)
3394 (make-local-variable 'minor-mode-alist)
3395 (use-local-map gnus-article-mode-map)
3396 (when (gnus-visual-p 'article-menu 'menu)
3397 (gnus-article-make-menu-bar))
3398 (gnus-update-format-specifications nil 'article-mode)
3399 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3400 (make-local-variable 'gnus-page-broken)
3401 (make-local-variable 'gnus-button-marker-list)
3402 (make-local-variable 'gnus-article-current-summary)
3403 (make-local-variable 'gnus-article-mime-handles)
3404 (make-local-variable 'gnus-article-decoded-p)
3405 (make-local-variable 'gnus-article-mime-handle-alist)
3406 (make-local-variable 'gnus-article-wash-types)
3407 (make-local-variable 'gnus-article-image-alist)
3408 (make-local-variable 'gnus-article-charset)
3409 (make-local-variable 'gnus-article-ignored-charsets)
3410 (gnus-set-default-directory)
3411 (buffer-disable-undo)
3412 (setq buffer-read-only t)
3413 (set-syntax-table gnus-article-mode-syntax-table)
3414 (mm-enable-multibyte)
3415 (gnus-run-hooks 'gnus-article-mode-hook))
3417 (defun gnus-article-setup-buffer ()
3418 "Initialize the article buffer."
3419 (let* ((name (if gnus-single-article-buffer "*Article*"
3420 (concat "*Article " gnus-newsgroup-name "*")))
3422 (progn (string-match "\\*Article" name)
3423 (concat " *Original Article"
3424 (substring name (match-end 0))))))
3425 (setq gnus-article-buffer name)
3426 (setq gnus-original-article-buffer original)
3427 (setq gnus-article-mime-handle-alist nil)
3428 ;; This might be a variable local to the summary buffer.
3429 (unless gnus-single-article-buffer
3431 (set-buffer gnus-summary-buffer)
3432 (setq gnus-article-buffer name)
3433 (setq gnus-original-article-buffer original)
3434 (gnus-set-global-variables)))
3435 (gnus-article-setup-highlight-words)
3436 ;; Init original article buffer.
3438 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3439 (mm-enable-multibyte)
3440 (setq major-mode 'gnus-original-article-mode)
3441 (make-local-variable 'gnus-original-article))
3442 (if (get-buffer name)
3445 (when gnus-article-mime-handles
3446 (mm-destroy-parts gnus-article-mime-handles)
3447 (setq gnus-article-mime-handles nil))
3448 ;; Set it to nil in article-buffer!
3449 (setq gnus-article-mime-handle-alist nil)
3450 (buffer-disable-undo)
3451 (setq buffer-read-only t)
3452 (unless (eq major-mode 'gnus-article-mode)
3453 (gnus-article-mode))
3456 (set-buffer (gnus-get-buffer-create name))
3458 (make-local-variable 'gnus-summary-buffer)
3459 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3460 (current-buffer)))))
3462 ;; Set article window start at LINE, where LINE is the number of lines
3463 ;; from the head of the article.
3464 (defun gnus-article-set-window-start (&optional line)
3466 (gnus-get-buffer-window gnus-article-buffer t)
3468 (set-buffer gnus-article-buffer)
3469 (goto-char (point-min))
3472 (gnus-message 6 "Moved to bookmark")
3473 (search-forward "\n\n" nil t)
3477 (defun gnus-article-prepare (article &optional all-headers header)
3478 "Prepare ARTICLE in article mode buffer.
3479 ARTICLE should either be an article number or a Message-ID.
3480 If ARTICLE is an id, HEADER should be the article headers.
3481 If ALL-HEADERS is non-nil, no headers are hidden."
3483 ;; Make sure we start in a summary buffer.
3484 (unless (eq major-mode 'gnus-summary-mode)
3485 (set-buffer gnus-summary-buffer))
3486 (setq gnus-summary-buffer (current-buffer))
3487 (let* ((gnus-article (if header (mail-header-number header) article))
3488 (summary-buffer (current-buffer))
3489 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3490 (group gnus-newsgroup-name)
3493 (gnus-article-setup-buffer)
3494 (set-buffer gnus-article-buffer)
3495 ;; Deactivate active regions.
3496 (when (and (boundp 'transient-mark-mode)
3497 transient-mark-mode)
3498 (setq mark-active nil))
3499 (if (not (setq result (let ((buffer-read-only nil))
3500 (gnus-request-article-this-buffer
3502 ;; There is no such article.
3504 (when (and (numberp article)
3505 (not (memq article gnus-newsgroup-sparse)))
3506 (setq gnus-article-current
3507 (cons gnus-newsgroup-name article))
3508 (set-buffer gnus-summary-buffer)
3509 (setq gnus-current-article article)
3510 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3512 (gnus-summary-set-agent-mark article)
3513 (message "Message marked for downloading"))
3514 (gnus-summary-mark-article article gnus-canceled-mark)
3515 (unless (memq article gnus-newsgroup-sparse)
3516 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3517 (if (or (eq result 'pseudo)
3518 (eq result 'nneething))
3521 (set-buffer summary-buffer)
3522 (push article gnus-newsgroup-history)
3523 (setq gnus-last-article gnus-current-article
3524 gnus-current-article 0
3525 gnus-current-headers nil
3526 gnus-article-current nil)
3527 (if (eq result 'nneething)
3528 (gnus-configure-windows 'summary)
3529 (gnus-configure-windows 'article))
3530 (gnus-set-global-variables))
3531 (let ((gnus-article-mime-handle-alist-1
3532 gnus-article-mime-handle-alist))
3533 (gnus-set-mode-line 'article)))
3534 ;; The result from the `request' was an actual article -
3535 ;; or at least some text that is now displayed in the
3537 (when (and (numberp article)
3538 (not (eq article gnus-current-article)))
3539 ;; Seems like a new article has been selected.
3540 ;; `gnus-current-article' must be an article number.
3542 (set-buffer summary-buffer)
3543 (push article gnus-newsgroup-history)
3544 (setq gnus-last-article gnus-current-article
3545 gnus-current-article article
3546 gnus-current-headers
3547 (gnus-summary-article-header gnus-current-article)
3548 gnus-article-current
3549 (cons gnus-newsgroup-name gnus-current-article))
3550 (unless (vectorp gnus-current-headers)
3551 (setq gnus-current-headers nil))
3552 (gnus-summary-goto-subject gnus-current-article)
3553 (when (gnus-summary-show-thread)
3554 ;; If the summary buffer really was folded, the
3555 ;; previous goto may not actually have gone to
3556 ;; the right article, but the thread root instead.
3558 (gnus-summary-goto-subject gnus-current-article))
3559 (gnus-run-hooks 'gnus-mark-article-hook)
3560 (gnus-set-mode-line 'summary)
3561 (when (gnus-visual-p 'article-highlight 'highlight)
3562 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3563 ;; Set the global newsgroup variables here.
3564 (gnus-set-global-variables)
3565 (setq gnus-have-all-headers
3566 (or all-headers gnus-show-all-headers))))
3568 (gnus-configure-windows 'article))
3569 (when (or (numberp article)
3571 (gnus-article-prepare-display)
3573 (goto-char (point-min))
3574 (setq gnus-page-broken
3575 (when gnus-break-pages
3576 (gnus-narrow-to-page)
3578 (let ((gnus-article-mime-handle-alist-1
3579 gnus-article-mime-handle-alist))
3580 (gnus-set-mode-line 'article))
3584 (set-window-point (get-buffer-window (current-buffer)) (point))
3585 (gnus-configure-windows 'article)
3589 (defun gnus-article-prepare-display ()
3590 "Make the current buffer look like a nice article."
3591 ;; Hooks for getting information from the article.
3592 ;; This hook must be called before being narrowed.
3593 (let ((gnus-article-buffer (current-buffer))
3595 (unless (eq major-mode 'gnus-article-mode)
3596 (gnus-article-mode))
3597 (setq buffer-read-only nil
3598 gnus-article-wash-types nil
3599 gnus-article-image-alist nil)
3600 (gnus-run-hooks 'gnus-tmp-internal-hook)
3601 (when gnus-display-mime-function
3602 (funcall gnus-display-mime-function))
3603 (gnus-run-hooks 'gnus-article-prepare-hook)))
3606 ;;; Gnus MIME viewing functions
3609 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3610 "Format of the MIME buttons.
3612 Valid specifiers include:
3614 %T MIME type, along with additional info
3615 %n The `name' parameter
3616 %d The description, if any
3617 %l The length of the encoded part
3618 %p The part identifier number
3619 %e Dots if the part isn't displayed
3621 General format specifiers can also be used. See
3622 (gnus)Formatting Variables.")
3624 (defvar gnus-mime-button-line-format-alist
3625 '((?t gnus-tmp-type ?s)
3626 (?T gnus-tmp-type-long ?s)
3627 (?n gnus-tmp-name ?s)
3628 (?d gnus-tmp-description ?s)
3630 (?l gnus-tmp-length ?d)
3631 (?e gnus-tmp-dots ?s)))
3633 (defvar gnus-mime-button-commands
3634 '((gnus-article-press-button "\r" "Toggle Display")
3635 (gnus-mime-view-part "v" "View Interactively...")
3636 (gnus-mime-view-part-as-type "t" "View As Type...")
3637 (gnus-mime-view-part-as-charset "C" "View As charset...")
3638 (gnus-mime-save-part "o" "Save...")
3639 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3640 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3641 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3642 (gnus-mime-view-part-internally "E" "View Internally")
3643 (gnus-mime-view-part-externally "e" "View Externally")
3644 (gnus-mime-print-part "p" "Print")
3645 (gnus-mime-pipe-part "|" "Pipe To Command...")
3646 (gnus-mime-action-on-part "." "Take action on the part")))
3648 (defun gnus-article-mime-part-status ()
3649 (if gnus-article-mime-handle-alist-1
3650 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3652 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3655 (defvar gnus-mime-button-map
3656 (let ((map (make-sparse-keymap)))
3657 (unless (>= (string-to-number emacs-version) 21)
3658 ;; XEmacs doesn't care.
3659 (set-keymap-parent map gnus-article-mode-map))
3660 (define-key map gnus-mouse-2 'gnus-article-push-button)
3661 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3662 (dolist (c gnus-mime-button-commands)
3663 (define-key map (cadr c) (car c)))
3666 (defun gnus-mime-button-menu (event)
3667 "Construct a context-sensitive menu of MIME commands."
3669 (save-window-excursion
3670 (let ((pos (event-start event)))
3671 (select-window (posn-window pos))
3672 (goto-char (posn-point pos))
3673 (gnus-article-check-buffer)
3674 (let ((response (x-popup-menu
3676 ("" ,@(mapcar (lambda (c)
3677 (cons (caddr c) (car c)))
3678 gnus-mime-button-commands))))))
3680 (call-interactively response))))))
3682 (defun gnus-mime-view-all-parts (&optional handles)
3683 "View all the MIME parts."
3685 (save-current-buffer
3686 (set-buffer gnus-article-buffer)
3687 (let ((handles (or handles gnus-article-mime-handles))
3688 (mail-parse-charset gnus-newsgroup-charset)
3689 (mail-parse-ignored-charsets
3690 (with-current-buffer gnus-summary-buffer
3691 gnus-newsgroup-ignored-charsets)))
3693 (mm-remove-parts handles)
3694 (goto-char (point-min))
3695 (or (search-forward "\n\n") (goto-char (point-max)))
3696 (let (buffer-read-only)
3697 (delete-region (point) (point-max))
3698 (mm-display-parts handles))))))
3700 (defun gnus-mime-save-part-and-strip ()
3701 "Save the MIME part under point then replace it with an external body."
3703 (gnus-article-check-buffer)
3704 (let* ((data (get-text-property (point) 'gnus-data))
3706 (handles gnus-article-mime-handles))
3707 (if (mm-multiple-handles gnus-article-mime-handles)
3708 (error "This function is not implemented"))
3709 (setq file (and data (mm-save-part data)))
3711 (with-current-buffer (mm-handle-buffer data)
3713 (insert "Content-Type: " (mm-handle-media-type data))
3714 (mml-insert-parameter-string (cdr (mm-handle-type data))
3717 (insert "Content-ID: " (message-make-message-id) "\n")
3718 (insert "Content-Transfer-Encoding: binary\n")
3721 (cdr (mm-make-handle nil
3722 `("message/external-body"
3723 (access-type . "LOCAL-FILE")
3725 (set-buffer gnus-summary-buffer)
3726 (gnus-article-edit-article
3729 (let ((mail-parse-charset (or gnus-article-charset
3730 ',gnus-newsgroup-charset))
3731 (mail-parse-ignored-charsets
3732 (or gnus-article-ignored-charsets
3733 ',gnus-newsgroup-ignored-charsets))
3734 (mbl mml-buffer-list))
3735 (setq mml-buffer-list nil)
3736 (insert-buffer gnus-original-article-buffer)
3737 (mime-to-mml ',handles)
3738 (setq gnus-article-mime-handles nil)
3739 (let ((mbl1 mml-buffer-list))
3740 (setq mml-buffer-list mbl)
3741 (set (make-local-variable 'mml-buffer-list) mbl1))
3742 ;; LOCAL argument of add-hook differs between GNU Emacs
3743 ;; and XEmacs. make-local-hook makes sure they are local.
3744 (make-local-hook 'kill-buffer-hook)
3745 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3746 `(lambda (no-highlight)
3747 (let ((mail-parse-charset (or gnus-article-charset
3748 ',gnus-newsgroup-charset))
3749 (message-options message-options)
3750 (message-options-set-recipient)
3751 (mail-parse-ignored-charsets
3752 (or gnus-article-ignored-charsets
3753 ',gnus-newsgroup-ignored-charsets)))
3755 (mml-destroy-buffers)
3756 (remove-hook 'kill-buffer-hook
3757 'mml-destroy-buffers t)
3758 (kill-local-variable 'mml-buffer-list))
3759 (gnus-summary-edit-article-done
3760 ,(or (mail-header-references gnus-current-headers) "")
3761 ,(gnus-group-read-only-p)
3762 ,gnus-summary-buffer no-highlight))))))
3764 (defun gnus-mime-save-part ()
3765 "Save the MIME part under point."
3767 (gnus-article-check-buffer)
3768 (let ((data (get-text-property (point) 'gnus-data)))
3770 (mm-save-part data))))
3772 (defun gnus-mime-pipe-part ()
3773 "Pipe the MIME part under point to a process."
3775 (gnus-article-check-buffer)
3776 (let ((data (get-text-property (point) 'gnus-data)))
3778 (mm-pipe-part data))))
3780 (defun gnus-mime-view-part ()
3781 "Interactively choose a viewing method for the MIME part under point."
3783 (gnus-article-check-buffer)
3784 (let ((data (get-text-property (point) 'gnus-data)))
3786 (setq gnus-article-mime-handles
3788 gnus-article-mime-handles (setq data (copy-sequence data))))
3789 (mm-interactively-view-part data))))
3791 (defun gnus-mime-view-part-as-type-internal ()
3792 (gnus-article-check-buffer)
3793 (let* ((name (mail-content-type-get
3794 (mm-handle-type (get-text-property (point) 'gnus-data))
3796 (def-type (and name (mm-default-file-encoding name))))
3797 (and def-type (cons def-type 0))))
3799 (defun gnus-mime-view-part-as-type (&optional mime-type)
3800 "Choose a MIME media type, and view the part as such."
3803 (setq mime-type (completing-read
3804 "View as MIME type: "
3805 (mapcar #'list (mailcap-mime-types))
3807 (gnus-mime-view-part-as-type-internal))))
3808 (gnus-article-check-buffer)
3809 (let ((handle (get-text-property (point) 'gnus-data)))
3812 (mm-make-handle (mm-handle-buffer handle)
3813 (cons mime-type (cdr (mm-handle-type handle)))
3814 (mm-handle-encoding handle)
3815 (mm-handle-undisplayer handle)
3816 (mm-handle-disposition handle)
3817 (mm-handle-description handle)
3819 (mm-handle-id handle)))
3820 (setq gnus-article-mime-handles
3821 (mm-merge-handles gnus-article-mime-handles handle))
3822 (gnus-mm-display-part handle))))
3824 (defun gnus-mime-copy-part (&optional handle)
3825 "Put the MIME part under point into a new buffer."
3827 (gnus-article-check-buffer)
3828 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3829 (contents (and handle (mm-get-part handle)))
3831 (file-name-nondirectory
3833 (mail-content-type-get (mm-handle-type handle) 'name)
3834 (mail-content-type-get (mm-handle-type handle)
3837 (buffer (and base (generate-new-buffer base))))
3839 (switch-to-buffer buffer)
3841 ;; We do it this way to make `normal-mode' set the appropriate mode.
3844 (setq buffer-file-name (expand-file-name base))
3846 (setq buffer-file-name nil))
3847 (goto-char (point-min)))))
3849 (defun gnus-mime-print-part (&optional handle filename)
3850 "Print the MIME part under point."
3851 (interactive (list nil (ps-print-preprint current-prefix-arg)))
3852 (gnus-article-check-buffer)
3853 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3854 (contents (and handle (mm-get-part handle)))
3855 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
3856 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
3861 (with-temp-file file
3863 (call-process shell-file-name nil
3864 (generate-new-buffer " *mm*")
3866 shell-command-switch
3868 printer file (mm-handle-type handle))))
3872 (gnus-print-buffer))
3873 (ps-despool filename)))))
3875 (defun gnus-mime-inline-part (&optional handle arg)
3876 "Insert the MIME part under point into the current buffer."
3877 (interactive (list nil current-prefix-arg))
3878 (gnus-article-check-buffer)
3879 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3884 (if (and (not arg) (mm-handle-undisplayer handle))
3885 (mm-remove-part handle)
3886 (setq contents (mm-get-part handle))
3889 (setq charset (or (mail-content-type-get
3890 (mm-handle-type handle) 'charset)
3891 gnus-newsgroup-charset)))
3893 (if (mm-handle-undisplayer handle)
3894 (mm-remove-part handle))
3897 gnus-summary-show-article-charset-alist))
3898 (mm-read-coding-system "Charset: ")))))
3900 (mm-insert-inline handle
3902 (setq charset (mm-charset-to-coding-system
3904 (not (eq charset 'ascii)))
3905 (mm-decode-coding-string contents charset)
3909 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3910 "Insert the MIME part under point into the current buffer using the
3912 (interactive (list nil current-prefix-arg))
3913 (gnus-article-check-buffer)
3914 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3919 (if (mm-handle-undisplayer handle)
3920 (mm-remove-part handle))
3921 (let ((gnus-newsgroup-charset
3923 gnus-summary-show-article-charset-alist))
3924 (mm-read-coding-system "Charset: ")))
3925 (gnus-newsgroup-ignored-charsets 'gnus-all))
3926 (gnus-article-press-button)))))
3928 (defun gnus-mime-view-part-externally (&optional handle)
3929 "View the MIME part under point with an external viewer."
3931 (gnus-article-check-buffer)
3932 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3933 (mm-user-display-methods nil)
3934 (mm-inlined-types nil)
3935 (mail-parse-charset gnus-newsgroup-charset)
3936 (mail-parse-ignored-charsets
3937 (save-excursion (set-buffer gnus-summary-buffer)
3938 gnus-newsgroup-ignored-charsets)))
3940 (if (mm-handle-undisplayer handle)
3941 (mm-remove-part handle)
3942 (mm-display-part handle)))))
3944 (defun gnus-mime-view-part-internally (&optional handle)
3945 "View the MIME part under point with an internal viewer.
3946 If no internal viewer is available, use an external viewer."
3948 (gnus-article-check-buffer)
3949 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3950 (mm-inlined-types '(".*"))
3951 (mm-inline-large-images t)
3952 (mail-parse-charset gnus-newsgroup-charset)
3953 (mail-parse-ignored-charsets
3954 (save-excursion (set-buffer gnus-summary-buffer)
3955 gnus-newsgroup-ignored-charsets)))
3957 (if (mm-handle-undisplayer handle)
3958 (mm-remove-part handle)
3959 (mm-display-part handle)))))
3961 (defun gnus-mime-action-on-part (&optional action)
3962 "Do something with the MIME attachment at \(point\)."
3964 (list (completing-read "Action: " gnus-mime-action-alist)))
3965 (gnus-article-check-buffer)
3966 (let ((action-pair (assoc action gnus-mime-action-alist)))
3968 (funcall (cdr action-pair)))))
3970 (defun gnus-article-part-wrapper (n function)
3971 (save-current-buffer
3972 (set-buffer gnus-article-buffer)
3973 (when (> n (length gnus-article-mime-handle-alist))
3974 (error "No such part"))
3975 (gnus-article-goto-part n)
3976 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3977 (funcall function handle))))
3979 (defun gnus-article-pipe-part (n)
3980 "Pipe MIME part N, which is the numerical prefix."
3982 (gnus-article-part-wrapper n 'mm-pipe-part))
3984 (defun gnus-article-save-part (n)
3985 "Save MIME part N, which is the numerical prefix."
3987 (gnus-article-part-wrapper n 'mm-save-part))
3989 (defun gnus-article-interactively-view-part (n)
3990 "View MIME part N interactively, which is the numerical prefix."
3992 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3994 (defun gnus-article-copy-part (n)
3995 "Copy MIME part N, which is the numerical prefix."
3997 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3999 (defun gnus-article-view-part-as-charset (n)
4000 "Copy MIME part N, which is the numerical prefix."
4002 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4004 (defun gnus-article-view-part-externally (n)
4005 "View MIME part N externally, which is the numerical prefix."
4007 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4009 (defun gnus-article-inline-part (n)
4010 "Inline MIME part N, which is the numerical prefix."
4012 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4014 (defun gnus-article-mime-match-handle-first (condition)
4016 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4017 (while (setq ihandle (pop alist))
4019 ((functionp condition)
4020 (funcall condition (cdr ihandle)))
4021 ((eq condition 'undisplayed)
4022 (not (or (mm-handle-undisplayer (cdr ihandle))
4023 (equal (mm-handle-media-type (cdr ihandle))
4024 "multipart/alternative"))))
4025 ((eq condition 'undisplayed-alternative)
4026 (not (mm-handle-undisplayer (cdr ihandle))))
4028 (gnus-article-goto-part (car ihandle))
4029 (or (not n) (< (car ihandle) n)))
4030 (setq n (car ihandle))))
4034 (defun gnus-article-view-part (&optional n)
4035 "View MIME part N, which is the numerical prefix."
4037 (save-current-buffer
4038 (set-buffer gnus-article-buffer)
4039 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4040 gnus-article-mime-match-handle-function)))
4041 (when (> n (length gnus-article-mime-handle-alist))
4042 (error "No such part"))
4043 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4044 (when (gnus-article-goto-part n)
4045 (if (equal (car handle) "multipart/alternative")
4046 (gnus-article-press-button)
4047 (when (eq (gnus-mm-display-part handle) 'internal)
4048 (gnus-set-window-start)))))))
4050 (defsubst gnus-article-mime-total-parts ()
4051 (if (bufferp (car gnus-article-mime-handles))
4053 (1- (length gnus-article-mime-handles))))
4055 (defun gnus-mm-display-part (handle)
4056 "Display HANDLE and fix MIME button."
4057 (let ((id (get-text-property (point) 'gnus-part))
4062 (let ((window (selected-window))
4063 (mail-parse-charset gnus-newsgroup-charset)
4064 (mail-parse-ignored-charsets
4065 (if (gnus-buffer-live-p gnus-summary-buffer)
4067 (set-buffer gnus-summary-buffer)
4068 gnus-newsgroup-ignored-charsets)
4072 (let ((win (gnus-get-buffer-window (current-buffer) t))
4075 (select-window win))
4078 (if (mm-handle-displayed-p handle)
4079 ;; This will remove the part.
4080 (mm-display-part handle)
4082 (narrow-to-region (point)
4083 (if (eobp) (point) (1+ (point))))
4084 (mm-display-part handle)
4085 ;; We narrow to the part itself and
4086 ;; then call the treatment functions.
4087 (goto-char (point-min))
4089 (narrow-to-region (point) (point-max))
4092 (gnus-article-mime-total-parts)
4093 (mm-handle-media-type handle)))))
4094 (if (window-live-p window)
4095 (select-window window)))))
4097 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4098 (gnus-insert-mime-button
4099 handle id (list (mm-handle-displayed-p handle)))
4100 (goto-char point))))
4102 (defun gnus-article-goto-part (n)
4103 "Go to MIME part N."
4104 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4106 (goto-char point))))
4108 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4109 (let ((gnus-tmp-name
4110 (or (mail-content-type-get (mm-handle-type handle) 'name)
4111 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4112 (mail-content-type-get (mm-handle-type handle) 'url)
4114 (gnus-tmp-type (mm-handle-media-type handle))
4115 (gnus-tmp-description
4116 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4119 (if (if displayed (car displayed)
4120 (mm-handle-displayed-p handle))
4122 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4124 gnus-tmp-type-long b e)
4125 (when (string-match ".*/" gnus-tmp-name)
4126 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4127 (setq gnus-tmp-type-long (concat gnus-tmp-type
4128 (and (not (equal gnus-tmp-name ""))
4129 (concat "; " gnus-tmp-name))))
4130 (unless (equal gnus-tmp-description "")
4131 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4136 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4137 `(,@(gnus-local-map-property gnus-mime-button-map)
4138 gnus-callback gnus-mm-display-part
4139 gnus-part ,gnus-tmp-id
4140 article-type annotation
4143 (widget-convert-button
4146 :action 'gnus-widget-press-button
4147 :button-keymap gnus-mime-button-map
4149 (lambda (widget/window &optional overlay pos)
4150 ;; Needed to properly clear the message due to a bug in
4151 ;; wid-edit (XEmacs only).
4152 (if (boundp 'help-echo-owns-message)
4153 (setq help-echo-owns-message t))
4155 "%S: %s the MIME part; %S: more options"
4156 (aref gnus-mouse-2 0)
4157 ;; XEmacs will get a single widget arg; Emacs 21 will get
4158 ;; window, overlay, position.
4159 (if (mm-handle-displayed-p
4161 (with-current-buffer (gnus-overlay-buffer overlay)
4162 (widget-get (widget-at (gnus-overlay-start overlay))
4164 (widget-get widget/window :mime-handle)))
4166 (aref gnus-down-mouse-3 0))))))
4168 (defun gnus-widget-press-button (elems el)
4169 (goto-char (widget-get elems :from))
4170 (gnus-article-press-button))
4172 (defvar gnus-displaying-mime nil)
4174 (defun gnus-display-mime (&optional ihandles)
4175 "Display the MIME parts."
4177 (save-selected-window
4178 (let ((window (get-buffer-window gnus-article-buffer))
4181 (select-window window)
4182 ;; We have to do this since selecting the window
4183 ;; may change the point. So we set the window point.
4184 (set-window-point window point)))
4185 (let* ((handles (or ihandles (mm-dissect-buffer
4186 nil gnus-article-loose-mime)
4188 buffer-read-only handle name type b e display)
4189 (when (and (not ihandles)
4190 (not gnus-displaying-mime))
4191 ;; Top-level call; we clean up.
4192 (when gnus-article-mime-handles
4193 (mm-destroy-parts gnus-article-mime-handles)
4194 (setq gnus-article-mime-handle-alist nil));; A trick.
4195 (setq gnus-article-mime-handles handles)
4196 ;; We allow users to glean info from the handles.
4197 (when gnus-article-mime-part-function
4198 (gnus-mime-part-function handles)))
4200 (or (not (stringp (car handles)))
4203 (when (and (not ihandles)
4204 (not gnus-displaying-mime))
4205 ;; Clean up for mime parts.
4207 (delete-region (point) (point-max)))
4208 (let ((gnus-displaying-mime t))
4209 (gnus-mime-display-part handles)))
4212 (narrow-to-region (point) (point-max))
4213 (gnus-treat-article nil 1 1)
4216 ;; Highlight the headers.
4220 (narrow-to-region (point-min) (point))
4221 (gnus-treat-article 'head))))))))
4223 (defvar gnus-mime-display-multipart-as-mixed nil)
4224 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4225 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4227 (defun gnus-mime-display-part (handle)
4230 ((not (stringp (car handle)))
4231 (gnus-mime-display-single handle))
4232 ;; User-defined multipart
4233 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4234 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4236 ;; multipart/alternative
4237 ((and (equal (car handle) "multipart/alternative")
4238 (not (or gnus-mime-display-multipart-as-mixed
4239 gnus-mime-display-multipart-alternative-as-mixed)))
4240 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4241 (push (cons id handle) gnus-article-mime-handle-alist)
4242 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4243 ;; multipart/related
4244 ((and (equal (car handle) "multipart/related")
4245 (not (or gnus-mime-display-multipart-as-mixed
4246 gnus-mime-display-multipart-related-as-mixed)))
4247 ;;;!!!We should find the start part, but we just default
4248 ;;;!!!to the first part.
4249 ;;(gnus-mime-display-part (cadr handle))
4250 ;;;!!! Most multipart/related is an HTML message plus images.
4251 ;;;!!! Unfortunately we are unable to let W3 display those
4252 ;;;!!! included images, so we just display it as a mixed multipart.
4253 ;;(gnus-mime-display-mixed (cdr handle))
4254 ;;;!!! No, w3 can display everything just fine.
4255 (gnus-mime-display-part (cadr handle)))
4256 ((equal (car handle) "multipart/signed")
4257 (gnus-add-wash-type 'signed)
4258 (gnus-mime-display-security handle))
4259 ((equal (car handle) "multipart/encrypted")
4260 (gnus-add-wash-type 'encrypted)
4261 (gnus-mime-display-security handle))
4262 ;; Other multiparts are handled like multipart/mixed.
4264 (gnus-mime-display-mixed (cdr handle)))))
4266 (defun gnus-mime-part-function (handles)
4267 (if (stringp (car handles))
4268 (mapcar 'gnus-mime-part-function (cdr handles))
4269 (funcall gnus-article-mime-part-function handles)))
4271 (defun gnus-mime-display-mixed (handles)
4272 (mapcar 'gnus-mime-display-part handles))
4274 (defun gnus-mime-display-single (handle)
4275 (let ((type (mm-handle-media-type handle))
4276 (ignored gnus-ignored-mime-types)
4283 (when (string-match (pop ignored) type)
4284 (throw 'ignored nil)))
4285 (if (and (setq not-attachment
4286 (and (not (mm-inline-override-p handle))
4287 (or (not (mm-handle-disposition handle))
4288 (equal (car (mm-handle-disposition handle))
4290 (mm-attachment-override-p handle))))
4291 (mm-automatic-display-p handle)
4293 (mm-inlinable-p handle)
4294 (mm-inlined-p handle))
4295 (mm-automatic-external-display-p type)))
4297 (when (equal (mm-handle-media-supertype handle) "text")
4299 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4301 (push (cons id handle) gnus-article-mime-handle-alist)
4302 (when (or (not display)
4303 (not (gnus-unbuttonized-mime-type-p type)))
4304 ;(gnus-article-insert-newline)
4305 (gnus-insert-mime-button
4306 handle id (list (or display (and not-attachment text))))
4307 (gnus-article-insert-newline)
4308 ;(gnus-article-insert-newline)
4309 ;; Remember modify the number of forward lines.
4317 (let ((mail-parse-charset gnus-newsgroup-charset)
4318 (mail-parse-ignored-charsets
4319 (save-excursion (condition-case ()
4320 (set-buffer gnus-summary-buffer)
4322 gnus-newsgroup-ignored-charsets)))
4323 (mm-display-part handle t))
4324 (goto-char (point-max)))
4325 ((and text not-attachment)
4329 (gnus-article-insert-newline)
4330 (mm-insert-inline handle (mm-get-part handle))
4331 (goto-char (point-max))))
4335 (narrow-to-region beg (point))
4338 (gnus-article-mime-total-parts)
4339 (mm-handle-media-type handle)))))))))
4341 (defun gnus-unbuttonized-mime-type-p (type)
4342 "Say whether TYPE is to be unbuttonized."
4343 (unless gnus-inhibit-mime-unbuttonizing
4345 (let ((types gnus-unbuttonized-mime-types))
4347 (when (string-match (pop types) type)
4348 (throw 'found t)))))
4350 (let ((types gnus-buttonized-mime-types))
4352 (when (string-match (pop types) type)
4353 (throw 'found t)))))))))
4355 (defun gnus-article-insert-newline ()
4356 "Insert a newline, but mark it as undeletable."
4357 (gnus-put-text-property
4358 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4360 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4361 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4364 handle buffer-read-only from props begend not-pref)
4365 (save-window-excursion
4368 (narrow-to-region (car ibegend)
4371 (goto-char (car ibegend))
4374 (delete-region (point-min) (point-max))
4375 (mm-remove-parts handles))
4376 (setq begend (list (point-marker)))
4378 (unless (setq not-pref (cadr (member preferred ihandles)))
4379 (setq not-pref (car ihandles)))
4382 (not (gnus-unbuttonized-mime-type-p
4383 "multipart/alternative")))
4384 (gnus-add-text-properties
4387 (insert (format "%d. " id))
4391 (unless ,(not ibegend)
4392 (setq gnus-article-mime-handle-alist
4393 ',gnus-article-mime-handle-alist))
4394 (gnus-mime-display-alternative
4395 ',ihandles ',not-pref ',begend ,id))
4396 ,@(gnus-local-map-property gnus-mime-button-map)
4397 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4398 face ,gnus-article-button-face
4401 (widget-convert-button 'link from (point)
4402 :action 'gnus-widget-press-button
4403 :button-keymap gnus-widget-button-keymap)
4405 (while (setq handle (pop handles))
4406 (gnus-add-text-properties
4409 (insert (format "(%c) %-18s"
4410 (if (equal handle preferred) ?* ? )
4411 (mm-handle-media-type handle)))
4415 (unless ,(not ibegend)
4416 (setq gnus-article-mime-handle-alist
4417 ',gnus-article-mime-handle-alist))
4418 (gnus-mime-display-alternative
4419 ',ihandles ',handle ',begend ,id))
4420 ,@(gnus-local-map-property gnus-mime-button-map)
4421 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4422 face ,gnus-article-button-face
4425 (widget-convert-button 'link from (point)
4426 :action 'gnus-widget-press-button
4427 :button-keymap gnus-widget-button-keymap)
4431 (if (stringp (car preferred))
4432 (gnus-display-mime preferred)
4433 (let ((mail-parse-charset gnus-newsgroup-charset)
4434 (mail-parse-ignored-charsets
4435 (save-excursion (set-buffer gnus-summary-buffer)
4436 gnus-newsgroup-ignored-charsets)))
4437 (mm-display-part preferred)
4441 (narrow-to-region (car begend) (point-max))
4443 nil (length gnus-article-mime-handle-alist)
4444 (gnus-article-mime-total-parts)
4445 (mm-handle-media-type handle))))))
4446 (goto-char (point-max))
4447 (setcdr begend (point-marker)))))
4449 (goto-char point))))
4451 (defconst gnus-article-wash-status-strings
4452 (let ((alist '((cite "c" "Possible hidden citation text"
4453 " " "All citation text visible")
4454 (headers "h" "Hidden headers"
4455 " " "All headers visible.")
4456 (pgp "p" "Encrypted or signed message status hidden"
4457 " " "No hidden encryption nor digital signature status")
4458 (signature "s" "Signature has been hidden"
4459 " " "Signature is visible")
4460 (overstrike "o" "Overstrike (^H) characters applied"
4461 " " "No overstrike characters applied")
4462 (emphasis "e" "/*_Emphasis_*/ characters applied"
4463 " " "No /*_emphasis_*/ characters applied")))
4465 (dolist (entry alist result)
4466 (let ((key (nth 0 entry))
4467 (on (copy-sequence (nth 1 entry)))
4468 (on-help (nth 2 entry))
4469 (off (copy-sequence (nth 3 entry)))
4470 (off-help (nth 4 entry)))
4471 (put-text-property 0 1 'help-echo on-help on)
4472 (put-text-property 0 1 'help-echo off-help off)
4473 (push (list key on off) result))))
4474 "Alist of strings describing wash status in the mode line.
4475 Each entry has the form (KEY ON OF), where the KEY is a symbol
4476 representing the particular washing function, ON is the string to use
4477 in the article mode line when the washing function is active, and OFF
4478 is the string to use when it is inactive.")
4480 (defun gnus-article-wash-status-entry (key value)
4481 (let ((entry (assoc key gnus-article-wash-status-strings)))
4482 (if value (nth 1 entry) (nth 2 entry))))
4484 (defun gnus-article-wash-status ()
4485 "Return a string which display status of article washing."
4487 (set-buffer gnus-article-buffer)
4488 (let ((cite (memq 'cite gnus-article-wash-types))
4489 (headers (memq 'headers gnus-article-wash-types))
4490 (boring (memq 'boring-headers gnus-article-wash-types))
4491 (pgp (memq 'pgp gnus-article-wash-types))
4492 (pem (memq 'pem gnus-article-wash-types))
4493 (signed (memq 'signed gnus-article-wash-types))
4494 (encrypted (memq 'encrypted gnus-article-wash-types))
4495 (signature (memq 'signature gnus-article-wash-types))
4496 (overstrike (memq 'overstrike gnus-article-wash-types))
4497 (emphasis (memq 'emphasis gnus-article-wash-types)))
4499 (gnus-article-wash-status-entry 'cite cite)
4500 (gnus-article-wash-status-entry 'headers (or headers boring))
4501 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4502 (gnus-article-wash-status-entry 'signature signature)
4503 (gnus-article-wash-status-entry 'overstrike overstrike)
4504 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4506 (defun gnus-add-wash-type (type)
4507 "Add a washing of TYPE to the current status."
4508 (add-to-list 'gnus-article-wash-types type))
4510 (defun gnus-delete-wash-type (type)
4511 "Add a washing of TYPE to the current status."
4512 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4514 (defun gnus-add-image (category image)
4515 "Add IMAGE of CATEGORY to the list of displayed images."
4516 (let ((entry (assq category gnus-article-image-alist)))
4518 (setq entry (list category))
4519 (push entry gnus-article-image-alist))
4520 (nconc entry (list image))))
4522 (defun gnus-delete-images (category)
4523 "Delete all images in CATEGORY."
4524 (let ((entry (assq category gnus-article-image-alist)))
4525 (dolist (image (cdr entry))
4526 (gnus-remove-image image))
4527 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4528 (gnus-delete-wash-type category)))
4530 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4532 (defun gnus-article-maybe-hide-headers ()
4533 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4534 Provided for backwards compatibility."
4535 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4536 (not (save-excursion (set-buffer gnus-summary-buffer)
4537 gnus-have-all-headers)))
4538 (not gnus-inhibit-hiding))
4539 (gnus-article-hide-headers)))
4543 (defun gnus-output-to-file (file-name)
4544 "Append the current article to a file named FILE-NAME."
4545 (let ((artbuf (current-buffer)))
4547 (insert-buffer-substring artbuf)
4548 ;; Append newline at end of the buffer as separator, and then
4550 (goto-char (point-max))
4552 (let ((file-name-coding-system nnmail-pathname-coding-system))
4553 (mm-append-to-file (point-min) (point-max) file-name))
4556 (defun gnus-narrow-to-page (&optional arg)
4557 "Narrow the article buffer to a page.
4558 If given a numerical ARG, move forward ARG pages."
4560 (setq arg (if arg (prefix-numeric-value arg) 0))
4562 (set-buffer gnus-article-buffer)
4563 (goto-char (point-min))
4565 ;; Remove any old next/prev buttons.
4566 (when (gnus-visual-p 'page-marker)
4567 (let ((buffer-read-only nil))
4568 (gnus-remove-text-with-property 'gnus-prev)
4569 (gnus-remove-text-with-property 'gnus-next)))
4572 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4574 (re-search-forward page-delimiter nil 'move arg)))
4575 (goto-char (match-end 0)))
4578 (if (re-search-forward page-delimiter nil 'move)
4581 (when (and (gnus-visual-p 'page-marker)
4582 (not (= (point-min) 1)))
4584 (goto-char (point-min))
4585 (gnus-insert-prev-page-button)))
4586 (when (and (gnus-visual-p 'page-marker)
4587 (< (+ (point-max) 2) (buffer-size)))
4589 (goto-char (point-max))
4590 (gnus-insert-next-page-button)))))
4592 ;; Article mode commands
4594 (defun gnus-article-goto-next-page ()
4595 "Show the next page of the article."
4597 (when (gnus-article-next-page)
4598 (goto-char (point-min))
4599 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4601 (defun gnus-article-goto-prev-page ()
4602 "Show the next page of the article."
4604 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4605 (gnus-article-prev-page nil)))
4607 (defun gnus-article-next-page (&optional lines)
4608 "Show the next page of the current article.
4609 If end of article, return non-nil. Otherwise return nil.
4610 Argument LINES specifies lines to be scrolled up."
4612 (move-to-window-line -1)
4615 (and (pos-visible-in-window-p) ;Not continuation line.
4617 ;; Nothing in this page.
4618 (if (or (not gnus-page-broken)
4621 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4623 (gnus-narrow-to-page 1) ;Go to next page.
4625 ;; More in this page.
4626 (let ((scroll-in-place nil))
4630 ;; Long lines may cause an end-of-buffer error.
4631 (goto-char (point-max)))))
4632 (move-to-window-line 0)
4635 (defun gnus-article-prev-page (&optional lines)
4636 "Show previous page of current article.
4637 Argument LINES specifies lines to be scrolled down."
4639 (move-to-window-line 0)
4640 (if (and gnus-page-broken
4642 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4644 (gnus-narrow-to-page -1) ;Go to previous page.
4645 (goto-char (point-max))
4647 (let ((scroll-in-place nil))
4651 (beginning-of-buffer
4652 (goto-char (point-min))))
4653 (move-to-window-line 0)))))
4655 (defun gnus-article-refer-article ()
4656 "Read article specified by message-id around point."
4658 (let ((point (point)))
4659 (search-forward ">" nil t) ;Move point to end of "<....>".
4660 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4661 (let ((message-id (match-string 1)))
4663 (set-buffer gnus-summary-buffer)
4664 (gnus-summary-refer-article message-id))
4666 (error "No references around point"))))
4668 (defun gnus-article-show-summary ()
4669 "Reconfigure windows to show summary buffer."
4671 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4672 (error "There is no summary buffer for this article buffer")
4673 (gnus-article-set-globals)
4674 (gnus-configure-windows 'article)
4675 (gnus-summary-goto-subject gnus-current-article)
4676 (gnus-summary-position-point)))
4678 (defun gnus-article-describe-briefly ()
4679 "Describe article mode commands briefly."
4681 (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")))
4683 (defun gnus-article-summary-command ()
4684 "Execute the last keystroke in the summary buffer."
4686 (let ((obuf (current-buffer))
4687 (owin (current-window-configuration))
4689 (switch-to-buffer gnus-article-current-summary 'norecord)
4690 (setq func (lookup-key (current-local-map) (this-command-keys)))
4691 (call-interactively func)
4693 (set-window-configuration owin)
4694 (set-window-point (get-buffer-window (current-buffer)) (point))))
4696 (defun gnus-article-summary-command-nosave ()
4697 "Execute the last keystroke in the summary buffer."
4700 (pop-to-buffer gnus-article-current-summary 'norecord)
4701 (setq func (lookup-key (current-local-map) (this-command-keys)))
4702 (call-interactively func)))
4704 (defun gnus-article-check-buffer ()
4705 "Beep if not in an article buffer."
4706 (unless (equal major-mode 'gnus-article-mode)
4707 (error "Command invoked outside of a Gnus article buffer")))
4709 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4710 "Read a summary buffer key sequence and execute it from the article buffer."
4712 (gnus-article-check-buffer)
4714 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4715 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4716 "=" "^" "\M-^" "|"))
4722 '("n" "Gn" "p" "Gp"))
4725 (set-buffer gnus-article-current-summary)
4726 (let (gnus-pick-mode)
4727 (push (or key last-command-event) unread-command-events)
4728 (setq keys (if (featurep 'xemacs)
4729 (events-to-keys (read-key-sequence nil))
4730 (read-key-sequence nil)))))
4734 (if (or (member keys nosaves)
4735 (member keys nosave-but-article)
4736 (member keys nosave-in-article))
4738 (save-window-excursion
4739 (pop-to-buffer gnus-article-current-summary 'norecord)
4740 ;; We disable the pick minor mode commands.
4741 (let (gnus-pick-mode)
4742 (setq func (lookup-key (current-local-map) keys))))
4746 (unless (member keys nosave-in-article)
4747 (set-buffer gnus-article-current-summary))
4748 (call-interactively func)
4749 (setq new-sum-point (point)))
4750 (when (member keys nosave-but-article)
4751 (pop-to-buffer gnus-article-buffer 'norecord)))
4752 ;; These commands should restore window configuration.
4753 (let ((obuf (current-buffer))
4754 (owin (current-window-configuration))
4756 (summary gnus-article-current-summary)
4757 func in-buffer selected)
4758 (if not-restore-window
4759 (pop-to-buffer summary 'norecord)
4760 (switch-to-buffer summary 'norecord))
4761 (setq in-buffer (current-buffer))
4762 ;; We disable the pick minor mode commands.
4763 (if (and (setq func (let (gnus-pick-mode)
4764 (lookup-key (current-local-map) keys)))
4767 (call-interactively func)
4768 (setq new-sum-point (point))
4769 (when (eq in-buffer (current-buffer))
4770 (setq selected (gnus-summary-select-article))
4772 (unless not-restore-window
4773 (set-window-configuration owin))
4774 (when (eq selected 'old)
4776 (set-window-start (get-buffer-window (current-buffer))
4778 (set-window-point (get-buffer-window (current-buffer))
4780 (let ((win (get-buffer-window gnus-article-current-summary)))
4782 (set-window-point win new-sum-point)))) )
4783 (switch-to-buffer gnus-article-buffer)
4786 (defun gnus-article-describe-key (key)
4787 "Display documentation of the function invoked by KEY. KEY is a string."
4788 (interactive "kDescribe key: ")
4789 (gnus-article-check-buffer)
4790 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4792 (set-buffer gnus-article-current-summary)
4793 (let (gnus-pick-mode)
4794 (if (featurep 'xemacs)
4796 (push (elt key 0) unread-command-events)
4797 (setq key (events-to-keys
4798 (read-key-sequence "Describe key: "))))
4799 (setq unread-command-events
4801 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4802 (string-to-list key)))
4803 (setq key (read-key-sequence "Describe key: "))))
4805 (describe-key key)))
4807 (defun gnus-article-describe-key-briefly (key &optional insert)
4808 "Display documentation of the function invoked by KEY. KEY is a string."
4809 (interactive "kDescribe key: \nP")
4810 (gnus-article-check-buffer)
4811 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4813 (set-buffer gnus-article-current-summary)
4814 (let (gnus-pick-mode)
4815 (if (featurep 'xemacs)
4817 (push (elt key 0) unread-command-events)
4818 (setq key (events-to-keys
4819 (read-key-sequence "Describe key: "))))
4820 (setq unread-command-events
4822 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4823 (string-to-list key)))
4824 (setq key (read-key-sequence "Describe key: "))))
4825 (describe-key-briefly key insert))
4826 (describe-key-briefly key insert)))
4828 (defun gnus-article-reply-with-original (&optional wide)
4829 "Start composing a reply mail to the current message.
4830 The text in the region will be yanked. If the region isn't active,
4831 the entire article will be yanked."
4833 (let ((article (cdr gnus-article-current)) cont)
4835 (with-current-buffer gnus-summary-buffer
4836 (gnus-summary-reply (list (list article)) wide))
4837 (setq cont (buffer-substring (point) (mark t)))
4838 ;; Deactivate active regions.
4839 (when (and (boundp 'transient-mark-mode)
4840 transient-mark-mode)
4841 (setq mark-active nil))
4842 (with-current-buffer gnus-summary-buffer
4844 (list (list article cont)) wide)))))
4846 (defun gnus-article-followup-with-original ()
4847 "Compose a followup to the current article.
4848 The text in the region will be yanked. If the region isn't active,
4849 the entire article will be yanked."
4851 (let ((article (cdr gnus-article-current)) cont)
4853 (with-current-buffer gnus-summary-buffer
4854 (gnus-summary-followup (list (list article))))
4855 (setq cont (buffer-substring (point) (mark t)))
4856 ;; Deactivate active regions.
4857 (when (and (boundp 'transient-mark-mode)
4858 transient-mark-mode)
4859 (setq mark-active nil))
4860 (with-current-buffer gnus-summary-buffer
4861 (gnus-summary-followup
4862 (list (list article cont)))))))
4864 (defun gnus-article-hide (&optional arg force)
4865 "Hide all the gruft in the current article.
4866 This means that PGP stuff, signatures, cited text and (some)
4867 headers will be hidden.
4868 If given a prefix, show the hidden text instead."
4869 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4870 (gnus-article-hide-headers arg)
4871 (gnus-article-hide-list-identifiers arg)
4872 (gnus-article-hide-pgp arg)
4873 (gnus-article-hide-citation-maybe arg force)
4874 (gnus-article-hide-signature arg))
4876 (defun gnus-article-maybe-highlight ()
4877 "Do some article highlighting if article highlighting is requested."
4878 (when (gnus-visual-p 'article-highlight 'highlight)
4879 (gnus-article-highlight-some)))
4881 (defun gnus-check-group-server ()
4882 ;; Make sure the connection to the server is alive.
4883 (unless (gnus-server-opened
4884 (gnus-find-method-for-group gnus-newsgroup-name))
4885 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4886 (gnus-request-group gnus-newsgroup-name t)))
4889 (autoload 'nneething-get-file-name "nneething"))
4891 (defun gnus-request-article-this-buffer (article group)
4892 "Get an article and insert it into this buffer."
4893 (let (do-update-line sparse-header)
4897 (gnus-kill-all-overlays)
4898 (setq group (or group gnus-newsgroup-name))
4900 ;; Using `gnus-request-article' directly will insert the article into
4901 ;; `nntp-server-buffer' - so we'll save some time by not having to
4902 ;; copy it from the server buffer into the article buffer.
4904 ;; We only request an article by message-id when we do not have the
4905 ;; headers for it, so we'll have to get those.
4906 (when (stringp article)
4907 (gnus-read-header article))
4909 ;; If the article number is negative, that means that this article
4910 ;; doesn't belong in this newsgroup (possibly), so we find its
4911 ;; message-id and request it by id instead of number.
4912 (when (and (numberp article)
4914 (get-buffer gnus-summary-buffer)
4915 (gnus-buffer-exists-p gnus-summary-buffer))
4917 (set-buffer gnus-summary-buffer)
4918 (let ((header (gnus-summary-article-header article)))
4921 ((memq article gnus-newsgroup-sparse)
4922 ;; This is a sparse gap article.
4923 (setq do-update-line article)
4924 (setq article (mail-header-id header))
4925 (setq sparse-header (gnus-read-header article))
4926 (setq gnus-newsgroup-sparse
4927 (delq article gnus-newsgroup-sparse)))
4929 ;; It's a real article.
4930 (setq article (mail-header-id header)))
4932 ;; It is an extracted pseudo-article.
4933 (setq article 'pseudo)
4934 (gnus-request-pseudo-article header))))
4936 (let ((method (gnus-find-method-for-group
4937 gnus-newsgroup-name)))
4938 (when (and (eq (car method) 'nneething)
4940 (let ((dir (nneething-get-file-name
4941 (mail-header-id header))))
4942 (when (and (stringp dir)
4943 (file-directory-p dir))
4944 (setq article 'nneething)
4945 (gnus-group-enter-directory dir))))))))
4948 ;; Refuse to select canceled articles.
4949 ((and (numberp article)
4951 (get-buffer gnus-summary-buffer)
4952 (gnus-buffer-exists-p gnus-summary-buffer)
4953 (eq (cdr (save-excursion
4954 (set-buffer gnus-summary-buffer)
4955 (assq article gnus-newsgroup-reads)))
4956 gnus-canceled-mark))
4958 ;; We first check `gnus-original-article-buffer'.
4959 ((and (get-buffer gnus-original-article-buffer)
4962 (set-buffer gnus-original-article-buffer)
4963 (and (equal (car gnus-original-article) group)
4964 (eq (cdr gnus-original-article) article))))
4965 (insert-buffer-substring gnus-original-article-buffer)
4967 ;; Check the backlog.
4968 ((and gnus-keep-backlog
4969 (gnus-backlog-request-article group article (current-buffer)))
4971 ;; Check asynchronous pre-fetch.
4972 ((gnus-async-request-fetched-article group article (current-buffer))
4973 (gnus-async-prefetch-next group article gnus-summary-buffer)
4974 (when (and (numberp article) gnus-keep-backlog)
4975 (gnus-backlog-enter-article group article (current-buffer)))
4978 ((and gnus-use-cache
4980 (gnus-cache-request-article article group))
4982 ;; Check the agent cache.
4983 ((and gnus-agent gnus-agent-cache gnus-plugged
4985 (gnus-agent-request-article article group))
4987 ;; Get the article and put into the article buffer.
4988 ((or (stringp article)
4990 (let ((gnus-override-method gnus-override-method)
4991 (methods (and (stringp article)
4992 gnus-refer-article-method))
4993 (backend (car (gnus-find-method-for-group
4994 gnus-newsgroup-name)))
4996 (buffer-read-only nil))
4997 (if (or (not (listp methods))
4998 (and (symbolp (car methods))
4999 (assq (car methods) nnoo-definition-alist)))
5000 (setq methods (list methods)))
5001 (when (and (null gnus-override-method)
5003 (setq gnus-override-method (pop methods)))
5005 (when (eq gnus-override-method 'current)
5006 (setq gnus-override-method
5007 (with-current-buffer gnus-summary-buffer
5008 gnus-current-select-method)))
5010 (gnus-kill-all-overlays)
5011 (let ((gnus-newsgroup-name group))
5012 (gnus-check-group-server))
5014 ((gnus-request-article article group (current-buffer))
5015 (when (numberp article)
5016 (gnus-async-prefetch-next group article
5017 gnus-summary-buffer)
5018 (when gnus-keep-backlog
5019 (gnus-backlog-enter-article
5020 group article (current-buffer))))
5021 (setq result 'article))
5023 (setq gnus-override-method (pop methods)))
5024 ((not (string-match "^400 "
5025 (nnheader-get-report backend)))
5026 ;; If we get 400 server disconnect, reconnect and
5027 ;; retry; otherwise, assume the article has expired.
5028 (setq result 'done))))
5029 (and (eq result 'article) 'article)))
5033 ;; Associate this article with the current summary buffer.
5034 (setq gnus-article-current-summary gnus-summary-buffer)
5036 ;; Take the article from the original article buffer
5037 ;; and place it in the buffer it's supposed to be in.
5038 (when (and (get-buffer gnus-article-buffer)
5039 (equal (buffer-name (current-buffer))
5040 (buffer-name (get-buffer gnus-article-buffer))))
5042 (if (get-buffer gnus-original-article-buffer)
5043 (set-buffer gnus-original-article-buffer)
5044 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5045 (buffer-disable-undo)
5046 (setq major-mode 'gnus-original-article-mode)
5047 (setq buffer-read-only t))
5048 (let (buffer-read-only)
5050 (insert-buffer-substring gnus-article-buffer))
5051 (setq gnus-original-article (cons group article)))
5054 (run-hooks 'gnus-article-decode-hook)
5055 ;; Mark article as decoded or not.
5056 (setq gnus-article-decoded-p gnus-article-decode-hook))
5058 ;; Update sparse articles.
5059 (when (and do-update-line
5060 (or (numberp article)
5062 (let ((buf (current-buffer)))
5063 (set-buffer gnus-summary-buffer)
5064 (gnus-summary-update-article do-update-line sparse-header)
5065 (gnus-summary-goto-subject do-update-line nil t)
5066 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5068 (set-buffer buf))))))
5074 (defcustom gnus-article-edit-mode-hook nil
5075 "Hook run in article edit mode buffers."
5076 :group 'gnus-article-various
5079 (defvar gnus-article-edit-done-function nil)
5081 (defvar gnus-article-edit-mode-map nil)
5083 ;; Should we be using derived.el for this?
5084 (unless gnus-article-edit-mode-map
5085 (setq gnus-article-edit-mode-map (make-keymap))
5086 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5089 (gnus-define-keys gnus-article-edit-mode-map
5090 "\C-c?" describe-mode
5091 "\C-c\C-c" gnus-article-edit-done
5092 "\C-c\C-k" gnus-article-edit-exit
5093 "\C-c\C-f\C-t" message-goto-to
5094 "\C-c\C-f\C-o" message-goto-from
5095 "\C-c\C-f\C-b" message-goto-bcc
5096 ;;"\C-c\C-f\C-w" message-goto-fcc
5097 "\C-c\C-f\C-c" message-goto-cc
5098 "\C-c\C-f\C-s" message-goto-subject
5099 "\C-c\C-f\C-r" message-goto-reply-to
5100 "\C-c\C-f\C-n" message-goto-newsgroups
5101 "\C-c\C-f\C-d" message-goto-distribution
5102 "\C-c\C-f\C-f" message-goto-followup-to
5103 "\C-c\C-f\C-m" message-goto-mail-followup-to
5104 "\C-c\C-f\C-k" message-goto-keywords
5105 "\C-c\C-f\C-u" message-goto-summary
5106 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5107 "\C-c\C-f\C-a" message-gen-unsubscribed-mft
5108 "\C-c\C-b" message-goto-body
5109 "\C-c\C-i" message-goto-signature
5111 "\C-c\C-t" message-insert-to
5112 "\C-c\C-n" message-insert-newsgroups
5113 "\C-c\C-o" message-sort-headers
5114 "\C-c\C-e" message-elide-region
5115 "\C-c\C-v" message-delete-not-region
5116 "\C-c\C-z" message-kill-to-signature
5117 "\M-\r" message-newline-and-reformat
5118 "\C-c\C-a" mml-attach-file
5119 "\C-a" message-beginning-of-line
5121 "\M-;" comment-region)
5123 (gnus-define-keys (gnus-article-edit-wash-map
5124 "\C-c\C-w" gnus-article-edit-mode-map)
5125 "f" gnus-article-edit-full-stops))
5128 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5130 ["Fetch To" message-insert-to t]
5131 ["Fetch Newsgroups" message-insert-newsgroups t]
5133 ["To" message-goto-to t]
5134 ["From" message-goto-from t]
5135 ["Subject" message-goto-subject t]
5136 ["Cc" message-goto-cc t]
5137 ["Reply-To" message-goto-reply-to t]
5138 ["Summary" message-goto-summary t]
5139 ["Keywords" message-goto-keywords t]
5140 ["Newsgroups" message-goto-newsgroups t]
5141 ["Followup-To" message-goto-followup-to t]
5142 ["Mail-Followup-To" message-goto-mail-followup-to t]
5143 ["Distribution" message-goto-distribution t]
5144 ["Body" message-goto-body t]
5145 ["Signature" message-goto-signature t]))
5147 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5148 "Major mode for editing articles.
5149 This is an extended text-mode.
5151 \\{gnus-article-edit-mode-map}"
5152 (make-local-variable 'gnus-article-edit-done-function)
5153 (make-local-variable 'gnus-prev-winconf)
5154 (set (make-local-variable 'font-lock-defaults)
5155 '(message-font-lock-keywords t))
5156 (set (make-local-variable 'mail-header-separator) "")
5157 (easy-menu-add message-mode-field-menu message-mode-map)
5159 (setq buffer-read-only nil)
5160 (buffer-enable-undo)
5163 (defun gnus-article-edit (&optional force)
5164 "Edit the current article.
5165 This will have permanent effect only in mail groups.
5166 If FORCE is non-nil, allow editing of articles even in read-only
5169 (when (and (not force)
5170 (gnus-group-read-only-p))
5171 (error "The current newsgroup does not support article editing"))
5172 (gnus-article-date-original)
5173 (gnus-article-edit-article
5175 `(lambda (no-highlight)
5177 (gnus-summary-edit-article-done
5178 ,(or (mail-header-references gnus-current-headers) "")
5179 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5181 (defun gnus-article-edit-article (start-func exit-func)
5182 "Start editing the contents of the current article buffer."
5183 (let ((winconf (current-window-configuration)))
5184 (set-buffer gnus-article-buffer)
5185 (gnus-article-edit-mode)
5186 (funcall start-func)
5187 (set-buffer-modified-p nil)
5188 (gnus-configure-windows 'edit-article)
5189 (setq gnus-article-edit-done-function exit-func)
5190 (setq gnus-prev-winconf winconf)
5191 (gnus-message 6 "C-c C-c to end edits")))
5193 (defun gnus-article-edit-done (&optional arg)
5194 "Update the article edits and exit."
5196 (let ((func gnus-article-edit-done-function)
5197 (buf (current-buffer))
5198 (start (window-start))
5200 (winconf gnus-prev-winconf))
5201 (widen) ;; Widen it in case that users narrowed the buffer.
5204 ;; The cache and backlog have to be flushed somewhat.
5205 (when gnus-keep-backlog
5206 (gnus-backlog-remove-article
5207 (car gnus-article-current) (cdr gnus-article-current)))
5208 ;; Flush original article as well.
5210 (when (get-buffer gnus-original-article-buffer)
5211 (set-buffer gnus-original-article-buffer)
5212 (setq gnus-original-article nil)))
5213 (when gnus-use-cache
5214 (gnus-cache-update-article
5215 (car gnus-article-current) (cdr gnus-article-current)))
5216 ;; We remove all text props from the article buffer.
5217 (kill-all-local-variables)
5218 (gnus-set-text-properties (point-min) (point-max) nil)
5220 (set-window-configuration winconf)
5222 (set-window-start (get-buffer-window buf) start)
5223 (set-window-point (get-buffer-window buf) (point))))
5225 (defun gnus-article-edit-exit ()
5226 "Exit the article editing without updating."
5228 (when (or (not (buffer-modified-p))
5229 (yes-or-no-p "Article modified; kill anyway? "))
5230 (let ((curbuf (current-buffer))
5232 (window-start (window-start)))
5234 (if (gnus-buffer-live-p gnus-original-article-buffer)
5235 (insert-buffer gnus-original-article-buffer))
5236 (let ((winconf gnus-prev-winconf))
5238 (set-window-configuration winconf)
5239 ;; Tippy-toe some to make sure that point remains where it was.
5240 (save-current-buffer
5242 (set-window-start (get-buffer-window (current-buffer)) window-start)
5245 (defun gnus-article-edit-full-stops ()
5246 "Interactively repair spacing at end of sentences."
5249 (goto-char (point-min))
5250 (search-forward-regexp "^$" nil t)
5251 (let ((case-fold-search nil))
5252 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5255 ;;; Article highlights
5258 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5260 ;;; Internal Variables:
5262 (defcustom gnus-button-url-regexp
5263 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5264 "\\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:]]\\)"
5265 "\\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\\)\\)")
5266 "Regular expression that matches URLs."
5267 :group 'gnus-article-buttons
5270 (defcustom gnus-button-man-handler 'man
5271 "Function to use for displaying man pages.
5272 The function must take at least one argument with a string naming the
5274 :type '(choice (function-item :tag "Man" man)
5275 (function-item :tag "Woman" woman)
5276 (function :tag "Other"))
5277 :group 'gnus-article-buttons)
5279 (defcustom gnus-button-prefer-mid-or-mail 'guess
5280 "What to do when the button on a string as \"foo123@bar.com\" is pushed.
5281 Strings like this can be either a message ID or a mail address. If the
5282 variable is set to the symbol `ask', query the user what do do. If it is the
5283 symbol `guess', Gnus will do a guess and query the user what do do if it is
5284 ambiguous. If it is one of the sybols `mid' or `mail', Gnus will always assume
5285 that the string is a message ID or a mail address, respectivly. See the
5286 variable `gnus-button-guessed-mid-regexp' for details concerning the
5288 ;; FIXME: doc-string could/should be improved.
5289 :group 'gnus-article-buttons
5290 :type '(choice (const ask)
5295 (defcustom gnus-button-guessed-mid-regexp
5297 "^<?\\(slrn\\|Pine\\.\\)"
5298 "\\|\\.fsf@\\|\\.ln@\\|@4ax\\.com\\|@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de"
5299 "\\|^<?.*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*@")
5300 "Regular expression that matches message IDs and not mail addresses."
5301 ;; TODO: Incorporate more matches from
5302 ;; <URL:http://piology.org/perl/id-or-mail.pl.html>. I.e. translate the
5303 ;; Perl-REs to Elisp-REs.
5304 :group 'gnus-article-buttons
5307 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5308 (let* ((pref gnus-button-prefer-mid-or-mail)
5309 (url-mid (concat "news" ":" mid-or-mail))
5310 (url-mailto (concat "mailto" ":" mid-or-mail)))
5311 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5312 ;; If it looks like a MID (well known readers or servers) use 'mid,
5313 ;; otherwise 'ask the user.
5314 (if (eq pref 'guess)
5315 (if (string-match gnus-button-guessed-mid-regexp mid-or-mail)
5319 (save-window-excursion
5320 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5323 (cond ((eq pref 'mid)
5324 (gnus-message 9 "calling `gnus-button-handle-news' %s" url-mid)
5325 (gnus-button-handle-news url-mid))
5327 (gnus-message 9 "calling `gnus-url-mailto' %s" url-mailto)
5328 (gnus-url-mailto url-mailto)))))
5330 (defun gnus-button-handle-custom (url)
5331 "Follow a Custom URL."
5332 (customize-apropos (gnus-url-unhex-string url)))
5334 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[F1]1>?\\)")
5336 (defun gnus-button-handle-describe-function (url)
5337 "Call describe-function when pushing the corresponing URL button."
5340 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5342 (defun gnus-button-handle-describe-variable (url)
5343 "Call describe-variable when pushing the corresponing URL button."
5346 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5348 ;; FIXME: Is is possible to implement this? Else it should be removed here
5349 ;; and in `gnus-button-alist'.
5350 (defun gnus-button-handle-describe-key (url)
5351 "Call describe-key when pushing the corresponing URL button."
5352 (error "not implemented"))
5354 (defun gnus-button-handle-apropos (url)
5355 "Call apropos when pushing the corresponing URL button."
5356 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5358 (defun gnus-button-handle-apropos-command (url)
5359 "Call apropos when pushing the corresponing URL button."
5360 (apropos-command (gnus-replace-in-string url
5361 gnus-button-handle-describe-prefix "")))
5363 (defun gnus-button-handle-apropos-variable (url)
5364 "Call apropos when pushing the corresponing URL button."
5365 (apropos-variable (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5367 (defcustom gnus-button-man-level 5
5368 "*Integer that says how many man-related buttons Gnus will show.
5369 The higher the number, the more buttons will appear and the more false
5370 positves are possible. Note that you can set this variable local to
5371 specifific groups. Setting it higher in Unix groups is probably a good idea.
5372 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5373 how to set variables in specific groups."
5374 :group 'gnus-article-buttons
5377 (defcustom gnus-button-emacs-level 5
5378 "*Integer that says how many emacs-related buttons Gnus will show.
5379 The higher the number, the more buttons will appear and the more false
5380 positves are possible. Note that you can set this variable local to
5381 specifific groups. Setting it higher in Emacs or Gnus related groups is
5382 probably a good idea.See Info node `(gnus)Group Parameters' and the variable
5383 `gnus-parameters' on how to set variables in specific groups."
5384 :group 'gnus-article-buttons
5387 (defcustom gnus-button-mail-level 5
5388 "*Integer that says how many buttons for message IDs or mail addresses will appear.
5389 The higher the number, the more buttons will appear and the more false
5390 positves are possible."
5391 :group 'gnus-article-buttons
5394 (defcustom gnus-button-alist
5395 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5396 0 t gnus-button-handle-news 3)
5397 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5398 gnus-button-handle-news 2)
5399 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5401 gnus-button-fetch-group 4)
5402 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5403 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5404 t gnus-button-message-id 3)
5405 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5406 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5407 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5409 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5410 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2)
5412 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5413 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
5414 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5415 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
5416 ;; Emacs help commands
5417 ("M-x[ \t\n]apropos[ \t\n]\\([^ ]+\\)[ \t\n]RET"
5418 ;; regexp doesn't match arguments containing ` '.
5419 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
5420 ("M-x[ \t\n]apropos-command[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5421 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
5422 ("M-x[ \t\n]apropos-variable[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5423 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
5424 ("\\W\\(C-h\\|<?[F1]1>?\\)[ \t\n]f[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5425 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
5426 ("\\W\\(C-h\\|<?[F1]1>?\\)[ \t\n]v[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5427 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
5428 ("\\W\\(C-h\\|<?[F1]1>?\\)[ \t\n]k[ \t\n]\\([^ ]+\\)[ \t\n]" 0
5429 ;; this regexp needs to be fixed!
5430 (>= gnus-button-emacs-level 9) gnus-button-handle-describe-key 2)
5431 ;; This is how URLs _should_ be embedded in text...
5432 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5434 (gnus-button-url-regexp 0 t browse-url 0)
5436 ("\\b\\([a-z][a-z]+\\)([0-9])\\W" 0
5437 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
5438 gnus-button-handle-man 1)
5439 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
5440 ("\\b\\([a-zA-Z][-_.a-zA-Z0-9]+\\)([0-9])\\W" 0
5441 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
5442 gnus-button-handle-man 1)
5443 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm), SoWWWAnchor(3iv)
5444 ("\\b\\([a-zA-Z][-_.:a-zA-Z0-9]+\\)([0-9][a-z]*)\\W" 0
5445 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
5446 ;; MID or mail: To avoid too many false positives we don't try to catch
5447 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
5448 ;; at least one dot. TLD must contain two or three chars or be a know TLD
5449 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
5450 ;; so that non-ambiguous entries (see above) match first.
5451 ("\\b\\(<?[a-zA-Z0-9][^<>\")!;:,{}\n\t ]*@[a-zA-Z0-9][-.a-zA-Z0-9]+\\.\\([a-zA-Z][a-zA-Z]\\([a-zA-Z]\\)?\\|[Ii][Nn][Ff][Oo]\\|[Nn][Aa][Mm][Ee]\\)>?\\)\\b"
5452 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1))
5453 "*Alist of regexps matching buttons in article bodies.
5455 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5456 REGEXP: is the string matching text around the button (can also be lisp
5457 expression evaluating to a string),
5458 BUTTON: is the number of the regexp grouping actually matching the button,
5459 FORM: is a lisp expression which must eval to true for the button to
5461 CALLBACK: is the function to call when the user push this button, and each
5462 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5464 CALLBACK can also be a variable, in that case the value of that
5465 variable it the real callback function."
5466 :group 'gnus-article-buttons
5467 :type '(repeat (list (choice regexp variable)
5468 (integer :tag "Button")
5470 (function :tag "Callback")
5473 (integer :tag "Regexp group")))))
5475 (defcustom gnus-header-button-alist
5476 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5477 0 t gnus-button-message-id 0)
5478 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5479 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5480 0 t gnus-button-mailto 0)
5481 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
5482 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
5483 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
5484 ("^[^:]+:" "\\bmailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5485 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5486 gnus-button-message-id 3))
5487 "*Alist of headers and regexps to match buttons in article heads.
5489 This alist is very similar to `gnus-button-alist', except that each
5490 alist has an additional HEADER element first in each entry:
5492 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5494 HEADER is a regexp to match a header. For a fuller explanation, see
5495 `gnus-button-alist'."
5496 :group 'gnus-article-buttons
5497 :group 'gnus-article-headers
5498 :type '(repeat (list (regexp :tag "Header")
5500 (integer :tag "Button")
5502 (function :tag "Callback")
5505 (integer :tag "Regexp group")))))
5507 (defvar gnus-button-regexp nil)
5508 (defvar gnus-button-marker-list nil)
5509 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5511 (defvar gnus-button-last nil)
5512 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5516 (defun gnus-article-push-button (event)
5517 "Check text under the mouse pointer for a callback function.
5518 If the text under the mouse pointer has a `gnus-callback' property,
5519 call it with the value of the `gnus-data' text property."
5521 (set-buffer (window-buffer (posn-window (event-start event))))
5522 (let* ((pos (posn-point (event-start event)))
5523 (data (get-text-property pos 'gnus-data))
5524 (fun (get-text-property pos 'gnus-callback)))
5527 (funcall fun data))))
5529 (defun gnus-article-press-button ()
5530 "Check text at point for a callback function.
5531 If the text at point has a `gnus-callback' property,
5532 call it with the value of the `gnus-data' text property."
5534 (let* ((data (get-text-property (point) 'gnus-data))
5535 (fun (get-text-property (point) 'gnus-callback)))
5537 (funcall fun data))))
5539 (defun gnus-article-highlight (&optional force)
5540 "Highlight current article.
5541 This function calls `gnus-article-highlight-headers',
5542 `gnus-article-highlight-citation',
5543 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5544 do the highlighting. See the documentation for those functions."
5545 (interactive (list 'force))
5546 (gnus-article-highlight-headers)
5547 (gnus-article-highlight-citation force)
5548 (gnus-article-highlight-signature)
5549 (gnus-article-add-buttons force)
5550 (gnus-article-add-buttons-to-head))
5552 (defun gnus-article-highlight-some (&optional force)
5553 "Highlight current article.
5554 This function calls `gnus-article-highlight-headers',
5555 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5556 do the highlighting. See the documentation for those functions."
5557 (interactive (list 'force))
5558 (gnus-article-highlight-headers)
5559 (gnus-article-highlight-signature)
5560 (gnus-article-add-buttons))
5562 (defun gnus-article-highlight-headers ()
5563 "Highlight article headers as specified by `gnus-header-face-alist'."
5566 (set-buffer gnus-article-buffer)
5568 (let ((alist gnus-header-face-alist)
5569 (buffer-read-only nil)
5570 (case-fold-search t)
5571 (inhibit-point-motion-hooks t)
5572 entry regexp header-face field-face from hpoints fpoints)
5573 (article-narrow-to-head)
5574 (while (setq entry (pop alist))
5575 (goto-char (point-min))
5576 (setq regexp (concat "^\\("
5577 (if (string-equal "" (nth 0 entry))
5581 header-face (nth 1 entry)
5582 field-face (nth 2 entry))
5583 (while (and (re-search-forward regexp nil t)
5587 (unless (search-forward ":" nil t)
5589 (when (and header-face
5590 (not (memq (point) hpoints)))
5591 (push (point) hpoints)
5592 (gnus-put-text-property from (point) 'face header-face))
5593 (when (and field-face
5594 (not (memq (setq from (point)) fpoints)))
5596 (if (re-search-forward "^[^ \t]" nil t)
5598 (goto-char (point-max)))
5599 (gnus-put-text-property from (point) 'face field-face))))))))
5601 (defun gnus-article-highlight-signature ()
5602 "Highlight the signature in an article.
5603 It does this by highlighting everything after
5604 `gnus-signature-separator' using `gnus-signature-face'."
5607 (set-buffer gnus-article-buffer)
5608 (let ((buffer-read-only nil)
5609 (inhibit-point-motion-hooks t))
5611 (when (and gnus-signature-face
5612 (gnus-article-narrow-to-signature))
5613 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5614 'face gnus-signature-face)
5616 (gnus-article-search-signature)
5617 (let ((start (match-beginning 0))
5618 (end (set-marker (make-marker) (1+ (match-end 0)))))
5619 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5622 (defun gnus-button-in-region-p (b e prop)
5623 "Say whether PROP exists in the region."
5624 (text-property-not-all b e prop nil))
5626 (defun gnus-article-add-buttons (&optional force)
5627 "Find external references in the article and make buttons of them.
5628 \"External references\" are things like Message-IDs and URLs, as
5629 specified by `gnus-button-alist'."
5630 (interactive (list 'force))
5632 (set-buffer gnus-article-buffer)
5633 (let ((buffer-read-only nil)
5634 (inhibit-point-motion-hooks t)
5635 (case-fold-search t)
5636 (alist gnus-button-alist)
5638 ;; Remove all old markers.
5639 (let (marker entry new-list)
5640 (while (setq marker (pop gnus-button-marker-list))
5641 (if (or (< marker (point-min)) (>= marker (point-max)))
5642 (push marker new-list)
5644 (when (setq entry (gnus-button-entry))
5645 (put-text-property (match-beginning (nth 1 entry))
5646 (match-end (nth 1 entry))
5647 'gnus-callback nil))
5648 (set-marker marker nil)))
5649 (setq gnus-button-marker-list new-list))
5650 ;; We skip the headers.
5653 (while (setq entry (pop alist))
5654 (setq regexp (eval (car entry)))
5656 (while (re-search-forward regexp nil t)
5657 (let* ((start (and entry (match-beginning (nth 1 entry))))
5658 (end (and entry (match-end (nth 1 entry))))
5659 (from (match-beginning 0)))
5660 (when (and (or (eq t (nth 2 entry))
5661 (eval (nth 2 entry)))
5662 (not (gnus-button-in-region-p
5663 start end 'gnus-callback)))
5664 ;; That optional form returned non-nil, so we add the
5666 (gnus-article-add-button
5667 start end 'gnus-button-push
5668 (car (push (set-marker (make-marker) from)
5669 gnus-button-marker-list))))))))))
5671 ;; Add buttons to the head of an article.
5672 (defun gnus-article-add-buttons-to-head ()
5673 "Add buttons to the head of the article."
5676 (set-buffer gnus-article-buffer)
5678 (let ((buffer-read-only nil)
5679 (inhibit-point-motion-hooks t)
5680 (case-fold-search t)
5681 (alist gnus-header-button-alist)
5683 (article-narrow-to-head)
5685 ;; Each alist entry.
5686 (setq entry (car alist)
5688 (goto-char (point-min))
5689 (while (re-search-forward (car entry) nil t)
5690 ;; Each header matching the entry.
5691 (setq beg (match-beginning 0))
5692 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5693 (match-beginning 0))
5696 (while (re-search-forward (eval (nth 1 entry)) end t)
5697 ;; Each match within a header.
5698 (let* ((entry (cdr entry))
5699 (start (match-beginning (nth 1 entry)))
5700 (end (match-end (nth 1 entry)))
5701 (form (nth 2 entry)))
5702 (goto-char (match-end 0))
5704 (gnus-article-add-button
5705 start end (nth 3 entry)
5706 (buffer-substring (match-beginning (nth 4 entry))
5707 (match-end (nth 4 entry)))))))
5708 (goto-char end)))))))
5710 ;;; External functions:
5712 (defun gnus-article-add-button (from to fun &optional data)
5713 "Create a button between FROM and TO with callback FUN and data DATA."
5714 (when gnus-article-button-face
5715 (gnus-overlay-put (gnus-make-overlay from to)
5716 'face gnus-article-button-face))
5717 (gnus-add-text-properties
5719 (nconc (and gnus-article-mouse-face
5720 (list gnus-mouse-face-prop gnus-article-mouse-face))
5721 (list 'gnus-callback fun)
5722 (and data (list 'gnus-data data))))
5723 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5724 :button-keymap gnus-widget-button-keymap))
5726 ;;; Internal functions:
5728 (defun gnus-article-set-globals ()
5730 (set-buffer gnus-summary-buffer)
5731 (gnus-set-global-variables)))
5733 (defun gnus-signature-toggle (end)
5735 (set-buffer gnus-article-buffer)
5736 (let ((buffer-read-only nil)
5737 (inhibit-point-motion-hooks t))
5738 (if (text-property-any end (point-max) 'article-type 'signature)
5740 (gnus-delete-wash-type 'signature)
5741 (gnus-remove-text-properties-when
5742 'article-type 'signature end (point-max)
5743 (cons 'article-type (cons 'signature
5744 gnus-hidden-properties))))
5745 (gnus-add-wash-type 'signature)
5746 (gnus-add-text-properties-when
5747 'article-type nil end (point-max)
5748 (cons 'article-type (cons 'signature
5749 gnus-hidden-properties)))))
5750 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5751 (gnus-set-mode-line 'article))))
5753 (defun gnus-button-entry ()
5754 ;; Return the first entry in `gnus-button-alist' matching this place.
5755 (let ((alist gnus-button-alist)
5758 (setq entry (pop alist))
5759 (if (looking-at (eval (car entry)))
5764 (defun gnus-button-push (marker)
5765 ;; Push button starting at MARKER.
5768 (let* ((entry (gnus-button-entry))
5769 (inhibit-point-motion-hooks t)
5771 (args (mapcar (lambda (group)
5772 (let ((string (match-string group)))
5773 (gnus-set-text-properties
5774 0 (length string) nil string)
5781 (fboundp (symbol-value fun)))
5782 (apply (symbol-value fun) args))
5784 (gnus-message 1 "You must define `%S' to use this button"
5785 (cons fun args)))))))
5787 (defun gnus-parse-news-url (url)
5788 (let (scheme server group message-id articles)
5791 (goto-char (point-min))
5792 (when (looking-at "\\([A-Za-z]+\\):")
5793 (setq scheme (match-string 1))
5794 (goto-char (match-end 0)))
5795 (when (looking-at "//\\([^/]+\\)/")
5796 (setq server (match-string 1))
5797 (goto-char (match-end 0)))
5800 ((looking-at "\\(.*@.*\\)")
5801 (setq message-id (match-string 1)))
5802 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5803 (setq group (match-string 1)
5804 articles (split-string (match-string 2) "-")))
5805 ((looking-at "\\([^/]+\\)/?")
5806 (setq group (match-string 1)))
5808 (error "Unknown news URL syntax"))))
5809 (list scheme server group message-id articles)))
5811 (defun gnus-button-handle-news (url)
5813 (destructuring-bind (scheme server group message-id articles)
5814 (gnus-parse-news-url url)
5818 (set-buffer gnus-summary-buffer)
5820 (let ((gnus-refer-article-method (list (list 'nntp server))))
5821 (gnus-summary-refer-article message-id))
5822 (gnus-summary-refer-article message-id))))
5824 (gnus-button-fetch-group url)))))
5826 (defun gnus-button-handle-man (url)
5828 (funcall gnus-button-man-handler url))
5830 (defun gnus-button-handle-info (url)
5831 "Fetch an info URL."
5833 "^\\([^:/]+\\)?/\\(.*\\)"
5835 (gnus-info-find-node
5836 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5839 (gnus-url-unhex-string (match-string 2 url))))
5840 (error "Can't parse %s" url)))
5842 (defun gnus-button-message-id (message-id)
5845 (set-buffer gnus-summary-buffer)
5846 (gnus-summary-refer-article message-id)))
5848 (defun gnus-button-fetch-group (address)
5849 "Fetch GROUP specified by ADDRESS."
5850 (if (not (string-match "[:/]" address))
5851 ;; This is just a simple group url.
5852 (gnus-group-read-ephemeral-group address gnus-select-method)
5855 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5857 (error "Can't parse %s" address)
5858 (gnus-group-read-ephemeral-group
5859 (match-string 4 address)
5860 `(nntp ,(match-string 1 address)
5861 (nntp-address ,(match-string 1 address))
5862 (nntp-port-number ,(if (match-end 3)
5863 (match-string 3 address)
5866 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5868 (defun gnus-url-parse-query-string (query &optional downcase)
5869 (let (retval pairs cur key val)
5870 (setq pairs (split-string query "&"))
5872 (setq cur (car pairs)
5874 (if (not (string-match "=" cur))
5876 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5877 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
5879 (setq key (downcase key)))
5880 (setq cur (assoc key retval))
5882 (setcdr cur (cons val (cdr cur)))
5883 (setq retval (cons (list key val) retval)))))
5886 (defun gnus-url-mailto (url)
5887 ;; Send mail to someone
5888 (when (string-match "mailto:/*\\(.*\\)" url)
5889 (setq url (substring url (match-beginning 1) nil)))
5890 (let (to args subject func)
5891 (if (string-match (regexp-quote "?") url)
5892 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5893 args (gnus-url-parse-query-string
5894 (substring url (match-end 0) nil) t))
5895 (setq to (gnus-url-unhex-string url)))
5896 (setq args (cons (list "to" to) args)
5897 subject (cdr-safe (assoc "subject" args)))
5900 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5903 (message-position-on-field (caar args)))
5904 (insert (mapconcat 'identity (cdar args) ", "))
5905 (setq args (cdr args)))
5908 (message-goto-subject))))
5910 (defun gnus-button-embedded-url (address)
5911 "Activate ADDRESS with `browse-url'."
5912 (browse-url (gnus-strip-whitespace address)))
5914 ;;; Next/prev buttons in the article buffer.
5916 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5917 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5919 (defvar gnus-prev-page-map
5920 (let ((map (make-sparse-keymap)))
5921 (unless (>= emacs-major-version 21)
5922 ;; XEmacs doesn't care.
5923 (set-keymap-parent map gnus-article-mode-map))
5924 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5925 (define-key map "\r" 'gnus-button-prev-page)
5928 (defun gnus-insert-prev-page-button ()
5930 (buffer-read-only nil))
5932 gnus-prev-page-line-format nil
5933 `(,@(gnus-local-map-property gnus-prev-page-map)
5935 gnus-callback gnus-article-button-prev-page
5936 article-type annotation))
5937 (widget-convert-button
5939 :action 'gnus-button-prev-page
5940 :button-keymap gnus-prev-page-map)))
5942 (defvar gnus-prev-page-map
5943 (let ((map (make-sparse-keymap)))
5944 (unless (>= emacs-major-version 21)
5945 ;; XEmacs doesn't care.
5946 (set-keymap-parent map gnus-article-mode-map))
5947 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5948 (define-key map "\r" 'gnus-button-prev-page)
5951 (defvar gnus-next-page-map
5952 (let ((map (make-sparse-keymap)))
5953 (unless (>= emacs-major-version 21)
5954 ;; XEmacs doesn't care.
5955 (set-keymap-parent map gnus-article-mode-map))
5956 (define-key map gnus-mouse-2 'gnus-button-next-page)
5957 (define-key map "\r" 'gnus-button-next-page)
5960 (defun gnus-button-next-page (&optional args more-args)
5961 "Go to the next page."
5963 (let ((win (selected-window)))
5964 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5965 (gnus-article-next-page)
5966 (select-window win)))
5968 (defun gnus-button-prev-page (&optional args more-args)
5969 "Go to the prev page."
5971 (let ((win (selected-window)))
5972 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5973 (gnus-article-prev-page)
5974 (select-window win)))
5976 (defun gnus-insert-next-page-button ()
5978 (buffer-read-only nil))
5979 (gnus-eval-format gnus-next-page-line-format nil
5980 `(,@(gnus-local-map-property gnus-next-page-map)
5982 gnus-callback gnus-article-button-next-page
5983 article-type annotation))
5984 (widget-convert-button
5986 :action 'gnus-button-next-page
5987 :button-keymap gnus-next-page-map)))
5989 (defun gnus-article-button-next-page (arg)
5990 "Go to the next page."
5992 (let ((win (selected-window)))
5993 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5994 (gnus-article-next-page)
5995 (select-window win)))
5997 (defun gnus-article-button-prev-page (arg)
5998 "Go to the prev page."
6000 (let ((win (selected-window)))
6001 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6002 (gnus-article-prev-page)
6003 (select-window win)))
6005 (defvar gnus-decode-header-methods
6006 '(mail-decode-encoded-word-region)
6007 "List of methods used to decode headers.
6009 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6010 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6011 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6012 whose names match REGEXP.
6015 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6016 mail-decode-encoded-word-region
6017 (\"chinese\" . rfc1843-decode-region))
6020 (defvar gnus-decode-header-methods-cache nil)
6022 (defun gnus-multi-decode-header (start end)
6023 "Apply the functions from `gnus-encoded-word-methods' that match."
6024 (unless (and gnus-decode-header-methods-cache
6025 (eq gnus-newsgroup-name
6026 (car gnus-decode-header-methods-cache)))
6027 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6030 (nconc gnus-decode-header-methods-cache (list x))
6031 (if (and gnus-newsgroup-name
6032 (string-match (car x) gnus-newsgroup-name))
6033 (nconc gnus-decode-header-methods-cache
6035 gnus-decode-header-methods))
6036 (let ((xlist gnus-decode-header-methods-cache))
6039 (narrow-to-region start end)
6041 (funcall (pop xlist) (point-min) (point-max))))))
6044 ;;; Treatment top-level handling.
6047 (defun gnus-treat-article (condition &optional part-number total-parts type)
6048 (let ((length (- (point-max) (point-min)))
6049 (alist gnus-treatment-function-alist)
6050 (article-goto-body-goes-to-point-min-p t)
6054 (let ((list gnus-article-treat-types))
6056 (when (string-match (pop list) type)
6057 (throw 'found t)))))))
6058 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6060 (gnus-run-hooks 'gnus-part-display-hook)
6061 (while (setq elem (pop alist))
6064 (if (gnus-buffer-live-p gnus-summary-buffer)
6065 (set-buffer gnus-summary-buffer))
6066 (symbol-value (car elem))))
6067 (when (and (or (consp val)
6069 (gnus-treat-predicate val)
6070 (or (not (get (car elem) 'highlight))
6073 (funcall (cadr elem)))))))
6075 ;; Dynamic variables.
6077 (defvar part-number)
6078 (defvar total-parts)
6083 (defun gnus-treat-predicate (val)
6088 (stringp (car val)))
6089 (apply 'gnus-or (mapcar `(lambda (s)
6090 (string-match s ,(or gnus-newsgroup-name "")))
6093 (let ((pred (pop val)))
6096 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6098 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6100 (not (gnus-treat-predicate (car val))))
6102 (equal (car val) type))
6104 (error "%S is not a valid predicate" pred)))))
6112 (eq part-number total-parts))
6116 (error "%S is not a valid value" val))))
6118 (defun gnus-article-encrypt-body (protocol &optional n)
6119 "Encrypt the article body."
6122 (or gnus-article-encrypt-protocol
6123 (completing-read "Encrypt protocol: "
6124 gnus-article-encrypt-protocol-alist
6126 current-prefix-arg))
6127 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6129 (error (format "Can't find the encrypt protocol %s" protocol)))
6130 (if (equal gnus-newsgroup-name "nndraft:drafts")
6131 (error "Can't encrypt the article in group nndraft:drafts"))
6132 (if (equal gnus-newsgroup-name "nndraft:queue")
6133 (error "Don't encrypt the article in group nndraft:queue"))
6134 (gnus-summary-iterate n
6136 (set-buffer gnus-summary-buffer)
6137 (let ((mail-parse-charset gnus-newsgroup-charset)
6138 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6139 (summary-buffer gnus-summary-buffer)
6141 (gnus-set-global-variables)
6142 (when (gnus-group-read-only-p)
6143 (error "The current newsgroup does not support article encrypt"))
6144 (gnus-summary-show-article t)
6146 (or (mail-header-references gnus-current-headers) ""))
6147 (set-buffer gnus-article-buffer)
6148 (let* ((buffer-read-only nil)
6150 (mapcar (lambda (field)
6151 (and (save-restriction
6152 (message-narrow-to-head)
6153 (goto-char (point-min))
6154 (search-forward field nil t))
6156 (message-narrow-to-field)
6157 (buffer-substring (point-min) (point-max))
6158 (delete-region (point-min) (point-max))
6160 '("Content-Type:" "Content-Transfer-Encoding:"
6161 "Content-Disposition:"))))
6162 (message-narrow-to-head)
6163 (message-remove-header "MIME-Version")
6164 (goto-char (point-max))
6165 (setq point (point))
6166 (insert (apply 'concat headers))
6168 (narrow-to-region point (point-max))
6169 (let ((message-options message-options))
6170 (message-options-set 'message-sender user-mail-address)
6171 (message-options-set 'message-recipients user-mail-address)
6172 (message-options-set 'message-sign-encrypt 'not)
6174 (goto-char (point-min))
6175 (insert "MIME-Version: 1.0\n")
6177 (gnus-summary-edit-article-done
6178 references nil summary-buffer t))
6179 (when gnus-keep-backlog
6180 (gnus-backlog-remove-article
6181 (car gnus-article-current) (cdr gnus-article-current)))
6183 (when (get-buffer gnus-original-article-buffer)
6184 (set-buffer gnus-original-article-buffer)
6185 (setq gnus-original-article nil)))
6186 (when gnus-use-cache
6187 (gnus-cache-update-article
6188 (car gnus-article-current) (cdr gnus-article-current))))))))
6190 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6191 "The following specs can be used:
6192 %t The security MIME type
6195 %D Details if button is pressed")
6197 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6198 "The following specs can be used:
6199 %t The security MIME type
6202 %D Details if button is pressed")
6204 (defvar gnus-mime-security-button-line-format-alist
6205 '((?t gnus-tmp-type ?s)
6206 (?i gnus-tmp-info ?s)
6207 (?d gnus-tmp-details ?s)
6208 (?D gnus-tmp-pressed-details ?s)))
6210 (defvar gnus-mime-security-button-map
6211 (let ((map (make-sparse-keymap)))
6212 (unless (>= (string-to-number emacs-version) 21)
6213 (set-keymap-parent map gnus-article-mode-map))
6214 (define-key map gnus-mouse-2 'gnus-article-push-button)
6215 (define-key map "\r" 'gnus-article-press-button)
6218 (defvar gnus-mime-security-details-buffer nil)
6220 (defvar gnus-mime-security-button-pressed nil)
6222 (defvar gnus-mime-security-show-details-inline t
6223 "If non-nil, show details in the article buffer.")
6225 (defun gnus-mime-security-verify-or-decrypt (handle)
6226 (mm-remove-parts (cdr handle))
6227 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6228 point buffer-read-only)
6230 (goto-char (car region)))
6232 (narrow-to-region (point) (point))
6233 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6234 (let* ((mm-verify-option 'known)
6235 (mm-decrypt-option 'known)
6236 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6237 (unless (eq nparts (cdr handle))
6238 (mm-destroy-parts (cdr handle))
6239 (setcdr handle nparts))))
6240 (setq point (point))
6241 (gnus-mime-display-security handle)
6242 (goto-char (point-max)))
6244 (delete-region (point) (cdr region))
6245 (set-marker (car region) nil)
6246 (set-marker (cdr region) nil))
6249 (defun gnus-mime-security-show-details (handle)
6250 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6252 (if gnus-mime-security-show-details-inline
6253 (let ((gnus-mime-security-button-pressed t)
6254 (gnus-mime-security-button-line-format
6255 (get-text-property (point) 'gnus-line-format))
6258 (while (eq (get-text-property (point) 'gnus-line-format)
6259 gnus-mime-security-button-line-format)
6263 (narrow-to-region (point) (point))
6264 (gnus-insert-mime-security-button handle))
6265 (delete-region (point)
6266 (or (text-property-not-all
6269 gnus-mime-security-button-line-format)
6271 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6272 (with-current-buffer gnus-mime-security-details-buffer
6275 (setq gnus-mime-security-details-buffer
6276 (gnus-get-buffer-create "*MIME Security Details*")))
6277 (with-current-buffer gnus-mime-security-details-buffer
6279 (goto-char (point-min)))
6280 (pop-to-buffer gnus-mime-security-details-buffer))
6281 (gnus-message 5 "No details."))))
6283 (defun gnus-mime-security-press-button (handle)
6284 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6285 (gnus-mime-security-show-details handle)
6286 (gnus-mime-security-verify-or-decrypt handle)))
6288 (defun gnus-insert-mime-security-button (handle &optional displayed)
6289 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6292 (or (nth 2 (assoc protocol mm-verify-function-alist))
6293 (nth 2 (assoc protocol mm-decrypt-function-alist))
6295 (if (equal (car handle) "multipart/signed")
6296 " Signed" " Encrypted")
6299 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6302 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6303 gnus-tmp-pressed-details
6305 (setq gnus-tmp-details
6306 (if gnus-tmp-details
6307 (concat "\n" gnus-tmp-details) ""))
6308 (setq gnus-tmp-pressed-details
6309 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6314 gnus-mime-security-button-line-format
6315 gnus-mime-security-button-line-format-alist
6316 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6317 gnus-callback gnus-mime-security-press-button
6318 gnus-line-format ,gnus-mime-security-button-line-format
6319 article-type annotation
6322 (widget-convert-button
6325 :action 'gnus-widget-press-button
6326 :button-keymap gnus-mime-security-button-map
6328 (lambda (widget/window &optional overlay pos)
6329 ;; Needed to properly clear the message due to a bug in
6330 ;; wid-edit (XEmacs only).
6331 (if (boundp 'help-echo-owns-message)
6332 (setq help-echo-owns-message t))
6335 (aref gnus-mouse-2 0))))))
6337 (defun gnus-mime-display-security (handle)
6339 (narrow-to-region (point) (point))
6340 (unless (gnus-unbuttonized-mime-type-p (car handle))
6341 (gnus-insert-mime-security-button handle))
6342 (gnus-mime-display-mixed (cdr handle))
6345 (unless (gnus-unbuttonized-mime-type-p (car handle))
6346 (let ((gnus-mime-security-button-line-format
6347 gnus-mime-security-button-end-line-format))
6348 (gnus-insert-mime-security-button handle)))
6349 (mm-set-handle-multipart-parameter
6351 (cons (set-marker (make-marker) (point-min))
6352 (set-marker (make-marker) (point-max))))))
6358 (run-hooks 'gnus-art-load-hook)
6360 ;;; gnus-art.el ends here