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
703 "Table for MS-to-Latin1 translation.")
705 (defcustom gnus-ignored-mime-types nil
706 "List of MIME types that should be ignored by Gnus."
708 :group 'gnus-article-mime
709 :type '(repeat regexp))
711 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
712 "List of MIME types that should not be given buttons when rendered inline.
713 See also `gnus-buttonized-mime-types' which may override this variable."
715 :group 'gnus-article-mime
716 :type '(repeat regexp))
718 (defcustom gnus-buttonized-mime-types nil
719 "List of MIME types that should be given buttons when rendered inline.
720 If set, this variable overrides `gnus-unbuttonized-mime-types'.
721 To see e.g. security buttons you could set this to
722 `(\"multipart/signed\")'."
724 :group 'gnus-article-mime
725 :type '(repeat regexp))
727 (defcustom gnus-inhibit-mime-unbuttonizing nil
728 "If non-nil, all MIME parts get buttons.
729 When nil (the default value), then some MIME parts do not get buttons,
730 as described by the variables `gnus-buttonized-mime-types' and
731 `gnus-unbuttonized-mime-types'."
735 (defcustom gnus-body-boundary-delimiter "_"
736 "String used to delimit header and body.
737 This variable is used by `gnus-article-treat-body-boundary' which can
738 be controlled by `gnus-treat-body-boundary'."
739 :group 'gnus-article-various
740 :type '(choice (item :tag "None" :value nil)
743 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
744 "Defines the location of the faces database.
745 For information on obtaining this database of pretty pictures, please
746 see http://www.cs.indiana.edu/picons/ftp/index.html"
747 :type '(repeat directory)
748 :link '(url-link :tag "download"
749 "http://www.cs.indiana.edu/picons/ftp/index.html")
750 :link '(custom-manual "(gnus)Picons")
753 (defun gnus-picons-installed-p ()
754 "Say whether picons are installed on your machine."
755 (let ((installed nil))
756 (dolist (database gnus-picon-databases)
757 (when (file-exists-p database)
761 (defcustom gnus-article-mime-part-function nil
762 "Function called with a MIME handle as the argument.
763 This is meant for people who want to do something automatic based
764 on parts -- for instance, adding Vcard info to a database."
765 :group 'gnus-article-mime
768 (defcustom gnus-mime-multipart-functions nil
769 "An alist of MIME types to functions to display them."
771 :group 'gnus-article-mime
774 (defcustom gnus-article-date-lapsed-new-header nil
775 "Whether the X-Sent and Date headers can coexist.
776 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
777 either replace the old \"Date:\" header (if this variable is nil), or
778 be added below it (otherwise)."
780 :group 'gnus-article-headers
783 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
784 "Function called with a MIME handle as the argument.
785 This is meant for people who want to view first matched part.
786 For `undisplayed-alternative' (default), the first undisplayed
787 part or alternative part is used. For `undisplayed', the first
788 undisplayed part is used. For a function, the first part which
789 the function return `t' is used. For `nil', the first part is
792 :group 'gnus-article-mime
794 (item :tag "first" :value nil)
795 (item :tag "undisplayed" :value undisplayed)
796 (item :tag "undisplayed or alternative"
797 :value undisplayed-alternative)
800 (defcustom gnus-mime-action-alist
801 '(("save to file" . gnus-mime-save-part)
802 ("save and strip" . gnus-mime-save-part-and-strip)
803 ("display as text" . gnus-mime-inline-part)
804 ("view the part" . gnus-mime-view-part)
805 ("pipe to command" . gnus-mime-pipe-part)
806 ("toggle display" . gnus-article-press-button)
807 ("toggle display" . gnus-article-view-part-as-charset)
808 ("view as type" . gnus-mime-view-part-as-type)
809 ("view internally" . gnus-mime-view-part-internally)
810 ("view externally" . gnus-mime-view-part-externally))
811 "An alist of actions that run on the MIME attachment."
812 :group 'gnus-article-mime
813 :type '(repeat (cons (string :tag "name")
817 ;;; The treatment variables
820 (defvar gnus-part-display-hook nil
821 "Hook called on parts that are to receive treatment.")
823 (defvar gnus-article-treat-custom
824 '(choice (const :tag "Off" nil)
826 (const :tag "Header" head)
827 (const :tag "Last" last)
828 (integer :tag "Less")
829 (repeat :tag "Groups" regexp)
830 (sexp :tag "Predicate")))
832 (defvar gnus-article-treat-head-custom
833 '(choice (const :tag "Off" nil)
834 (const :tag "Header" head)))
836 (defvar gnus-article-treat-types '("text/plain")
839 (defvar gnus-inhibit-treatment nil
840 "Whether to inhibit treatment.")
842 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
843 "Highlight the signature.
844 Valid values are nil, t, `head', `last', an integer or a predicate.
845 See Info node `(gnus)Customizing Articles'."
846 :group 'gnus-article-treat
847 :link '(custom-manual "(gnus)Customizing Articles")
848 :type gnus-article-treat-custom)
849 (put 'gnus-treat-highlight-signature 'highlight t)
851 (defcustom gnus-treat-buttonize 100000
853 Valid values are nil, t, `head', `last', an integer or a predicate.
854 See Info node `(gnus)Customizing Articles'."
855 :group 'gnus-article-treat
856 :link '(custom-manual "(gnus)Customizing Articles")
857 :type gnus-article-treat-custom)
858 (put 'gnus-treat-buttonize 'highlight t)
860 (defcustom gnus-treat-buttonize-head 'head
861 "Add buttons to the head.
862 Valid values are nil, t, `head', `last', an integer or a predicate.
863 See Info node `(gnus)Customizing Articles' for details."
864 :group 'gnus-article-treat
865 :link '(custom-manual "(gnus)Customizing Articles")
866 :type gnus-article-treat-head-custom)
867 (put 'gnus-treat-buttonize-head 'highlight t)
869 (defcustom gnus-treat-emphasize
870 (and (or window-system
872 (>= (string-to-number emacs-version) 21))
875 Valid values are nil, t, `head', `last', an integer or a predicate.
876 See Info node `(gnus)Customizing Articles' for details."
877 :group 'gnus-article-treat
878 :link '(custom-manual "(gnus)Customizing Articles")
879 :type gnus-article-treat-custom)
880 (put 'gnus-treat-emphasize 'highlight t)
882 (defcustom gnus-treat-strip-cr nil
883 "Remove carriage returns.
884 Valid values are nil, t, `head', `last', an integer or a predicate.
885 See Info node `(gnus)Customizing Articles' for details."
886 :group 'gnus-article-treat
887 :link '(custom-manual "(gnus)Customizing Articles")
888 :type gnus-article-treat-custom)
890 (defcustom gnus-treat-unsplit-urls nil
891 "Remove newlines from within URLs.
892 Valid values are nil, t, `head', `last', an integer or a predicate.
893 See Info node `(gnus)Customizing Articles' for details."
894 :group 'gnus-article-treat
895 :link '(custom-manual "(gnus)Customizing Articles")
896 :type gnus-article-treat-custom)
898 (defcustom gnus-treat-leading-whitespace nil
899 "Remove leading whitespace in headers.
900 Valid values are nil, t, `head', `last', an integer or a predicate.
901 See Info node `(gnus)Customizing Articles' for details."
902 :group 'gnus-article-treat
903 :link '(custom-manual "(gnus)Customizing Articles")
904 :type gnus-article-treat-custom)
906 (defcustom gnus-treat-hide-headers 'head
908 Valid values are nil, t, `head', `last', an integer or a predicate.
909 See Info node `(gnus)Customizing Articles' for details."
910 :group 'gnus-article-treat
911 :link '(custom-manual "(gnus)Customizing Articles")
912 :type gnus-article-treat-head-custom)
914 (defcustom gnus-treat-hide-boring-headers nil
915 "Hide boring headers.
916 Valid values are nil, t, `head', `last', an integer or a predicate.
917 See Info node `(gnus)Customizing Articles' for details."
918 :group 'gnus-article-treat
919 :link '(custom-manual "(gnus)Customizing Articles")
920 :type gnus-article-treat-head-custom)
922 (defcustom gnus-treat-hide-signature nil
924 Valid values are nil, t, `head', `last', an integer or a predicate.
925 See Info node `(gnus)Customizing Articles' for details."
926 :group 'gnus-article-treat
927 :link '(custom-manual "(gnus)Customizing Articles")
928 :type gnus-article-treat-custom)
930 (defcustom gnus-treat-fill-article nil
932 Valid values are nil, t, `head', `last', an integer or a predicate.
933 See Info node `(gnus)Customizing Articles' for details."
934 :group 'gnus-article-treat
935 :link '(custom-manual "(gnus)Customizing Articles")
936 :type gnus-article-treat-custom)
938 (defcustom gnus-treat-hide-citation nil
940 Valid values are nil, t, `head', `last', an integer or a predicate.
941 See Info node `(gnus)Customizing Articles' for details."
942 :group 'gnus-article-treat
943 :link '(custom-manual "(gnus)Customizing Articles")
944 :type gnus-article-treat-custom)
946 (defcustom gnus-treat-hide-citation-maybe nil
948 Valid values are nil, t, `head', `last', an integer or a predicate.
949 See Info node `(gnus)Customizing Articles' for details."
950 :group 'gnus-article-treat
951 :link '(custom-manual "(gnus)Customizing Articles")
952 :type gnus-article-treat-custom)
954 (defcustom gnus-treat-strip-list-identifiers 'head
955 "Strip list identifiers from `gnus-list-identifiers`.
956 Valid values are nil, t, `head', `last', an integer or a predicate.
957 See Info node `(gnus)Customizing Articles' for details."
959 :group 'gnus-article-treat
960 :link '(custom-manual "(gnus)Customizing Articles")
961 :type gnus-article-treat-custom)
963 (defcustom gnus-treat-strip-pgp t
964 "Strip PGP signatures.
965 Valid values are nil, t, `head', `last', an integer or a predicate.
966 See Info node `(gnus)Customizing Articles' for details."
967 :group 'gnus-article-treat
968 :link '(custom-manual "(gnus)Customizing Articles")
969 :type gnus-article-treat-custom)
971 (defcustom gnus-treat-strip-pem nil
972 "Strip PEM signatures.
973 Valid values are nil, t, `head', `last', an integer or a predicate.
974 See Info node `(gnus)Customizing Articles' for details."
975 :group 'gnus-article-treat
976 :link '(custom-manual "(gnus)Customizing Articles")
977 :type gnus-article-treat-custom)
979 (defcustom gnus-treat-strip-banner t
980 "Strip banners from articles.
981 The banner to be stripped is specified in the `banner' group parameter.
982 Valid values are nil, t, `head', `last', an integer or a predicate.
983 See Info node `(gnus)Customizing Articles' for details."
984 :group 'gnus-article-treat
985 :link '(custom-manual "(gnus)Customizing Articles")
986 :type gnus-article-treat-custom)
988 (defcustom gnus-treat-highlight-headers 'head
989 "Highlight the headers.
990 Valid values are nil, t, `head', `last', an integer or a predicate.
991 See Info node `(gnus)Customizing Articles' for details."
992 :group 'gnus-article-treat
993 :link '(custom-manual "(gnus)Customizing Articles")
994 :type gnus-article-treat-head-custom)
995 (put 'gnus-treat-highlight-headers 'highlight t)
997 (defcustom gnus-treat-highlight-citation t
998 "Highlight cited text.
999 Valid values are nil, t, `head', `last', an integer or a predicate.
1000 See Info node `(gnus)Customizing Articles' for details."
1001 :group 'gnus-article-treat
1002 :link '(custom-manual "(gnus)Customizing Articles")
1003 :type gnus-article-treat-custom)
1004 (put 'gnus-treat-highlight-citation 'highlight t)
1006 (defcustom gnus-treat-date-ut nil
1007 "Display the Date in UT (GMT).
1008 Valid values are nil, t, `head', `last', an integer or a predicate.
1009 See Info node `(gnus)Customizing Articles' for details."
1010 :group 'gnus-article-treat
1011 :link '(custom-manual "(gnus)Customizing Articles")
1012 :type gnus-article-treat-head-custom)
1014 (defcustom gnus-treat-date-local nil
1015 "Display the Date in the local timezone.
1016 Valid values are nil, t, `head', `last', an integer or a predicate.
1017 See Info node `(gnus)Customizing Articles' for details."
1018 :group 'gnus-article-treat
1019 :link '(custom-manual "(gnus)Customizing Articles")
1020 :type gnus-article-treat-head-custom)
1022 (defcustom gnus-treat-date-english nil
1023 "Display the Date in a format that can be read aloud in English.
1024 Valid values are nil, t, `head', `last', an integer or a predicate.
1025 See Info node `(gnus)Customizing Articles' for details."
1026 :group 'gnus-article-treat
1027 :link '(custom-manual "(gnus)Customizing Articles")
1028 :type gnus-article-treat-head-custom)
1030 (defcustom gnus-treat-date-lapsed nil
1031 "Display the Date header in a way that says how much time has elapsed.
1032 Valid values are nil, t, `head', `last', an integer or a predicate.
1033 See Info node `(gnus)Customizing Articles' for details."
1034 :group 'gnus-article-treat
1035 :link '(custom-manual "(gnus)Customizing Articles")
1036 :type gnus-article-treat-head-custom)
1038 (defcustom gnus-treat-date-original nil
1039 "Display the date in the original timezone.
1040 Valid values are nil, t, `head', `last', an integer or a predicate.
1041 See Info node `(gnus)Customizing Articles' for details."
1042 :group 'gnus-article-treat
1043 :link '(custom-manual "(gnus)Customizing Articles")
1044 :type gnus-article-treat-head-custom)
1046 (defcustom gnus-treat-date-iso8601 nil
1047 "Display the date in the ISO8601 format.
1048 Valid values are nil, t, `head', `last', an integer or a predicate.
1049 See Info node `(gnus)Customizing Articles' for details."
1051 :group 'gnus-article-treat
1052 :link '(custom-manual "(gnus)Customizing Articles")
1053 :type gnus-article-treat-head-custom)
1055 (defcustom gnus-treat-date-user-defined nil
1056 "Display the date in a user-defined format.
1057 The format is defined by the `gnus-article-time-format' variable.
1058 Valid values are nil, t, `head', `last', an integer or a predicate.
1059 See Info node `(gnus)Customizing Articles' for details."
1060 :group 'gnus-article-treat
1061 :link '(custom-manual "(gnus)Customizing Articles")
1062 :type gnus-article-treat-head-custom)
1064 (defcustom gnus-treat-strip-headers-in-body t
1065 "Strip the X-No-Archive header line from the beginning of the body.
1066 Valid values are nil, t, `head', `last', an integer or a predicate.
1067 See Info node `(gnus)Customizing Articles' for details."
1069 :group 'gnus-article-treat
1070 :link '(custom-manual "(gnus)Customizing Articles")
1071 :type gnus-article-treat-custom)
1073 (defcustom gnus-treat-strip-trailing-blank-lines nil
1074 "Strip trailing blank lines.
1075 Valid values are nil, t, `head', `last', an integer or a predicate.
1076 See Info node `(gnus)Customizing Articles' for details."
1077 :group 'gnus-article-treat
1078 :link '(custom-manual "(gnus)Customizing Articles")
1079 :type gnus-article-treat-custom)
1081 (defcustom gnus-treat-strip-leading-blank-lines nil
1082 "Strip leading blank lines.
1083 Valid values are nil, t, `head', `last', an integer or a predicate.
1084 See Info node `(gnus)Customizing Articles' for details."
1085 :group 'gnus-article-treat
1086 :link '(custom-manual "(gnus)Customizing Articles")
1087 :type gnus-article-treat-custom)
1089 (defcustom gnus-treat-strip-multiple-blank-lines nil
1090 "Strip multiple blank lines.
1091 Valid values are nil, t, `head', `last', an integer or a predicate.
1092 See Info node `(gnus)Customizing Articles' for details."
1093 :group 'gnus-article-treat
1094 :link '(custom-manual "(gnus)Customizing Articles")
1095 :type gnus-article-treat-custom)
1097 (defcustom gnus-treat-unfold-headers 'head
1098 "Unfold folded header lines.
1099 Valid values are nil, t, `head', `last', an integer or a predicate.
1100 See Info node `(gnus)Customizing Articles' for details."
1101 :group 'gnus-article-treat
1102 :link '(custom-manual "(gnus)Customizing Articles")
1103 :type gnus-article-treat-custom)
1105 (defcustom gnus-treat-fold-headers nil
1107 Valid values are nil, t, `head', `last', an integer or a predicate.
1108 See Info node `(gnus)Customizing Articles' for details."
1109 :group 'gnus-article-treat
1110 :link '(custom-manual "(gnus)Customizing Articles")
1111 :type gnus-article-treat-custom)
1113 (defcustom gnus-treat-fold-newsgroups 'head
1114 "Fold the Newsgroups and Followup-To headers.
1115 Valid values are nil, t, `head', `last', an integer or a predicate.
1116 See Info node `(gnus)Customizing Articles' for details."
1117 :group 'gnus-article-treat
1118 :link '(custom-manual "(gnus)Customizing Articles")
1119 :type gnus-article-treat-custom)
1121 (defcustom gnus-treat-overstrike t
1122 "Treat overstrike highlighting.
1123 Valid values are nil, t, `head', `last', an integer or a predicate.
1124 See Info node `(gnus)Customizing Articles' for details."
1125 :group 'gnus-article-treat
1126 :link '(custom-manual "(gnus)Customizing Articles")
1127 :type gnus-article-treat-custom)
1128 (put 'gnus-treat-overstrike 'highlight t)
1130 (defcustom gnus-treat-display-xface
1131 (and (not noninteractive)
1132 (or (and (fboundp 'image-type-available-p)
1133 (image-type-available-p 'xbm)
1134 (string-match "^0x" (shell-command-to-string "uncompface")))
1135 (and (featurep 'xemacs)
1138 "Display X-Face headers.
1139 Valid values are nil, t, `head', `last', an integer or a predicate.
1140 See Info node `(gnus)Customizing Articles' and Info node
1141 `(gnus)X-Face' for details."
1142 :group 'gnus-article-treat
1144 :link '(custom-manual "(gnus)Customizing Articles")
1145 :link '(custom-manual "(gnus)X-Face")
1146 :type gnus-article-treat-head-custom)
1147 (put 'gnus-treat-display-xface 'highlight t)
1149 (defcustom gnus-treat-display-grey-xface
1150 (and (not noninteractive)
1151 (string-match "^0x" (shell-command-to-string "uncompface"))
1153 "Display grey X-Face headers.
1154 Valid values are nil, t."
1155 :group 'gnus-article-treat
1158 (put 'gnus-treat-display-grey-xface 'highlight t)
1160 (defcustom gnus-treat-display-smileys
1161 (if (or (and (featurep 'xemacs)
1163 (and (fboundp 'image-type-available-p)
1164 (image-type-available-p 'pbm)))
1167 Valid values are nil, t, `head', `last', an integer or a predicate.
1168 See Info node `(gnus)Customizing Articles' and Info node
1169 `(gnus)Smileys' for details."
1170 :group 'gnus-article-treat
1172 :link '(custom-manual "(gnus)Customizing Articles")
1173 :link '(custom-manual "(gnus)Smileys")
1174 :type gnus-article-treat-custom)
1175 (put 'gnus-treat-display-smileys 'highlight t)
1177 (defcustom gnus-treat-from-picon
1178 (if (and (gnus-image-type-available-p 'xpm)
1179 (gnus-picons-installed-p))
1181 "Display picons in the From header.
1182 Valid values are nil, t, `head', `last', an integer or a predicate.
1183 See Info node `(gnus)Customizing Articles' and Info node
1184 `(gnus)Picons' for details."
1185 :group 'gnus-article-treat
1187 :link '(custom-manual "(gnus)Customizing Articles")
1188 :link '(custom-manual "(gnus)Picons")
1189 :type gnus-article-treat-head-custom)
1190 (put 'gnus-treat-from-picon 'highlight t)
1192 (defcustom gnus-treat-mail-picon
1193 (if (and (gnus-image-type-available-p 'xpm)
1194 (gnus-picons-installed-p))
1196 "Display picons in To and Cc headers.
1197 Valid values are nil, t, `head', `last', an integer or a predicate.
1198 See Info node `(gnus)Customizing Articles' and Info node
1199 `(gnus)Picons' for details."
1200 :group 'gnus-article-treat
1202 :link '(custom-manual "(gnus)Customizing Articles")
1203 :link '(custom-manual "(gnus)Picons")
1204 :type gnus-article-treat-head-custom)
1205 (put 'gnus-treat-mail-picon 'highlight t)
1207 (defcustom gnus-treat-newsgroups-picon
1208 (if (and (gnus-image-type-available-p 'xpm)
1209 (gnus-picons-installed-p))
1211 "Display picons in the Newsgroups and Followup-To headers.
1212 Valid values are nil, t, `head', `last', an integer or a predicate.
1213 See Info node `(gnus)Customizing Articles' and Info node
1214 `(gnus)Picons' for details."
1215 :group 'gnus-article-treat
1217 :link '(custom-manual "(gnus)Customizing Articles")
1218 :link '(custom-manual "(gnus)Picons")
1219 :type gnus-article-treat-head-custom)
1220 (put 'gnus-treat-newsgroups-picon 'highlight t)
1222 (defcustom gnus-treat-body-boundary
1223 (if (or gnus-treat-newsgroups-picon
1224 gnus-treat-mail-picon
1225 gnus-treat-from-picon)
1227 "Draw a boundary at the end of the headers.
1228 Valid values are nil, t, `head', `last', an integer or a predicate.
1229 See Info node `(gnus)Customizing Articles' for details."
1231 :group 'gnus-article-treat
1232 :link '(custom-manual "(gnus)Customizing Articles")
1233 :type gnus-article-treat-custom)
1235 (defcustom gnus-treat-capitalize-sentences nil
1236 "Capitalize sentence-starting words.
1237 Valid values are nil, t, `head', `last', an integer or a predicate.
1238 See Info node `(gnus)Customizing Articles' for details."
1240 :group 'gnus-article-treat
1241 :link '(custom-manual "(gnus)Customizing Articles")
1242 :type gnus-article-treat-custom)
1244 (defcustom gnus-treat-fill-long-lines nil
1246 Valid values are nil, t, `head', `last', an integer or a predicate.
1247 See Info node `(gnus)Customizing Articles' for details."
1248 :group 'gnus-article-treat
1249 :link '(custom-manual "(gnus)Customizing Articles")
1250 :type gnus-article-treat-custom)
1252 (defcustom gnus-treat-play-sounds nil
1254 Valid values are nil, t, `head', `last', an integer or a predicate.
1255 See Info node `(gnus)Customizing Articles' for details."
1257 :group 'gnus-article-treat
1258 :link '(custom-manual "(gnus)Customizing Articles")
1259 :type gnus-article-treat-custom)
1261 (defcustom gnus-treat-translate nil
1262 "Translate articles from one language to another.
1263 Valid values are nil, t, `head', `last', an integer or a predicate.
1264 See Info node `(gnus)Customizing Articles' for details."
1266 :group 'gnus-article-treat
1267 :link '(custom-manual "(gnus)Customizing Articles")
1268 :type gnus-article-treat-custom)
1270 (defcustom gnus-treat-x-pgp-sig nil
1272 To automatically treat X-PGP-Sig, set it to head.
1273 Valid values are nil, t, `head', `last', an integer or a predicate.
1274 See Info node `(gnus)Customizing Articles' for details."
1275 :group 'gnus-article-treat
1276 :group 'mime-security
1277 :link '(custom-manual "(gnus)Customizing Articles")
1278 :type gnus-article-treat-custom)
1280 (defvar gnus-article-encrypt-protocol-alist
1281 '(("PGP" . mml2015-self-encrypt)))
1283 ;; Set to nil if more than one protocol added to
1284 ;; gnus-article-encrypt-protocol-alist.
1285 (defcustom gnus-article-encrypt-protocol "PGP"
1286 "The protocol used for encrypt articles.
1287 It is a string, such as \"PGP\". If nil, ask user."
1289 :group 'mime-security)
1291 (defvar gnus-article-wash-function nil
1292 "Function used for converting HTML into text.")
1294 ;;; Internal variables
1296 (defvar gnus-english-month-names
1297 '("January" "February" "March" "April" "May" "June" "July" "August"
1298 "September" "October" "November" "December"))
1300 (defvar article-goto-body-goes-to-point-min-p nil)
1301 (defvar gnus-article-wash-types nil)
1302 (defvar gnus-article-emphasis-alist nil)
1303 (defvar gnus-article-image-alist nil)
1305 (defvar gnus-article-mime-handle-alist-1 nil)
1306 (defvar gnus-treatment-function-alist
1307 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1308 (gnus-treat-strip-banner gnus-article-strip-banner)
1309 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1310 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1311 (gnus-treat-buttonize gnus-article-add-buttons)
1312 (gnus-treat-fill-article gnus-article-fill-cited-article)
1313 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1314 (gnus-treat-strip-cr gnus-article-remove-cr)
1315 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1316 (gnus-treat-date-ut gnus-article-date-ut)
1317 (gnus-treat-date-local gnus-article-date-local)
1318 (gnus-treat-date-english gnus-article-date-english)
1319 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1320 (gnus-treat-date-original gnus-article-date-original)
1321 (gnus-treat-date-user-defined gnus-article-date-user)
1322 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1323 (gnus-treat-display-xface gnus-article-display-x-face)
1324 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1325 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1326 (gnus-treat-hide-signature gnus-article-hide-signature)
1327 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1328 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1329 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1330 (gnus-treat-strip-pem gnus-article-hide-pem)
1331 (gnus-treat-from-picon gnus-treat-from-picon)
1332 (gnus-treat-mail-picon gnus-treat-mail-picon)
1333 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1334 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1335 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1336 (gnus-treat-strip-trailing-blank-lines
1337 gnus-article-remove-trailing-blank-lines)
1338 (gnus-treat-strip-leading-blank-lines
1339 gnus-article-strip-leading-blank-lines)
1340 (gnus-treat-strip-multiple-blank-lines
1341 gnus-article-strip-multiple-blank-lines)
1342 (gnus-treat-overstrike gnus-article-treat-overstrike)
1343 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1344 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1345 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1346 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1347 (gnus-treat-display-smileys gnus-treat-smiley)
1348 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1349 (gnus-treat-emphasize gnus-article-emphasize)
1350 (gnus-treat-hide-citation gnus-article-hide-citation)
1351 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1352 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1353 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1354 (gnus-treat-play-sounds gnus-earcon-display)))
1356 (defvar gnus-article-mime-handle-alist nil)
1357 (defvar article-lapsed-timer nil)
1358 (defvar gnus-article-current-summary nil)
1360 (defvar gnus-article-mode-syntax-table
1361 (let ((table (copy-syntax-table text-mode-syntax-table)))
1362 ;; This causes the citation match run O(2^n).
1363 ;; (modify-syntax-entry ?- "w" table)
1364 (modify-syntax-entry ?> ")<" table)
1365 (modify-syntax-entry ?< "(>" table)
1366 ;; make M-. in article buffers work for `foo' strings
1367 (modify-syntax-entry ?' " " table)
1368 (modify-syntax-entry ?` " " table)
1370 "Syntax table used in article mode buffers.
1371 Initialized from `text-mode-syntax-table.")
1373 (defvar gnus-save-article-buffer nil)
1375 (defvar gnus-article-mode-line-format-alist
1376 (nconc '((?w (gnus-article-wash-status) ?s)
1377 (?m (gnus-article-mime-part-status) ?s))
1378 gnus-summary-mode-line-format-alist))
1380 (defvar gnus-number-of-articles-to-be-saved nil)
1382 (defvar gnus-inhibit-hiding nil)
1384 ;;; Macros for dealing with the article buffer.
1386 (defmacro gnus-with-article-headers (&rest forms)
1388 (set-buffer gnus-article-buffer)
1390 (let ((buffer-read-only nil)
1391 (inhibit-point-motion-hooks t)
1392 (case-fold-search t))
1393 (article-narrow-to-head)
1396 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1397 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1399 (defmacro gnus-with-article-buffer (&rest forms)
1401 (set-buffer gnus-article-buffer)
1402 (let ((buffer-read-only nil))
1405 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1406 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1408 (defun gnus-article-goto-header (header)
1409 "Go to HEADER, which is a regular expression."
1410 (re-search-forward (concat "^\\(" header "\\):") nil t))
1412 (defsubst gnus-article-hide-text (b e props)
1413 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1414 (gnus-add-text-properties-when 'article-type nil b e props)
1415 (when (memq 'intangible props)
1417 (max (1- b) (point-min))
1418 b 'intangible (cddr (memq 'intangible props)))))
1420 (defsubst gnus-article-unhide-text (b e)
1421 "Remove hidden text properties from region between B and E."
1422 (remove-text-properties b e gnus-hidden-properties)
1423 (when (memq 'intangible gnus-hidden-properties)
1424 (put-text-property (max (1- b) (point-min))
1425 b 'intangible nil)))
1427 (defun gnus-article-hide-text-type (b e type)
1428 "Hide text of TYPE between B and E."
1429 (gnus-add-wash-type type)
1430 (gnus-article-hide-text
1431 b e (cons 'article-type (cons type gnus-hidden-properties))))
1433 (defun gnus-article-unhide-text-type (b e type)
1434 "Unhide text of TYPE between B and E."
1435 (gnus-delete-wash-type type)
1436 (remove-text-properties
1437 b e (cons 'article-type (cons type gnus-hidden-properties)))
1438 (when (memq 'intangible gnus-hidden-properties)
1439 (put-text-property (max (1- b) (point-min))
1440 b 'intangible nil)))
1442 (defun gnus-article-hide-text-of-type (type)
1443 "Hide text of TYPE in the current buffer."
1445 (let ((b (point-min))
1447 (while (setq b (text-property-any b e 'article-type type))
1448 (add-text-properties b (incf b) gnus-hidden-properties)))))
1450 (defun gnus-article-delete-text-of-type (type)
1451 "Delete text of TYPE in the current buffer."
1453 (let ((b (point-min)))
1454 (while (setq b (text-property-any b (point-max) 'article-type type))
1456 b (or (text-property-not-all b (point-max) 'article-type type)
1459 (defun gnus-article-delete-invisible-text ()
1460 "Delete all invisible text in the current buffer."
1462 (let ((b (point-min)))
1463 (while (setq b (text-property-any b (point-max) 'invisible t))
1465 b (or (text-property-not-all b (point-max) 'invisible t)
1468 (defun gnus-article-text-type-exists-p (type)
1469 "Say whether any text of type TYPE exists in the buffer."
1470 (text-property-any (point-min) (point-max) 'article-type type))
1472 (defsubst gnus-article-header-rank ()
1473 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1474 (let ((list gnus-sorted-header-list)
1477 (when (looking-at (car list))
1479 (setq list (cdr list))
1483 (defun article-hide-headers (&optional arg delete)
1484 "Hide unwanted headers and possibly sort them as well."
1486 ;; This function might be inhibited.
1487 (unless gnus-inhibit-hiding
1490 (let ((buffer-read-only nil)
1491 (case-fold-search t)
1492 (max (1+ (length gnus-sorted-header-list)))
1493 (ignored (when (not gnus-visible-headers)
1494 (cond ((stringp gnus-ignored-headers)
1495 gnus-ignored-headers)
1496 ((listp gnus-ignored-headers)
1497 (mapconcat 'identity gnus-ignored-headers
1500 (cond ((stringp gnus-visible-headers)
1501 gnus-visible-headers)
1502 ((and gnus-visible-headers
1503 (listp gnus-visible-headers))
1504 (mapconcat 'identity gnus-visible-headers "\\|"))))
1505 (inhibit-point-motion-hooks t)
1507 ;; First we narrow to just the headers.
1508 (article-narrow-to-head)
1509 ;; Hide any "From " lines at the beginning of (mail) articles.
1510 (while (looking-at "From ")
1513 (delete-region (point-min) (point)))
1514 ;; Then treat the rest of the header lines.
1515 ;; Then we use the two regular expressions
1516 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1517 ;; select which header lines is to remain visible in the
1519 (while (re-search-forward "^[^ \t:]*:" nil t)
1521 ;; Mark the rank of the header.
1523 (point) (1+ (point)) 'message-rank
1524 (if (or (and visible (looking-at visible))
1526 (not (looking-at ignored))))
1527 (gnus-article-header-rank)
1530 (message-sort-headers-1)
1531 (when (setq beg (text-property-any
1532 (point-min) (point-max) 'message-rank (+ 2 max)))
1533 ;; We delete the unwanted headers.
1534 (gnus-add-wash-type 'headers)
1535 (add-text-properties (point-min) (+ 5 (point-min))
1536 '(article-type headers dummy-invisible t))
1537 (delete-region beg (point-max))))))))
1539 (defun article-hide-boring-headers (&optional arg)
1540 "Toggle hiding of headers that aren't very interesting.
1541 If given a negative prefix, always show; if given a positive prefix,
1543 (interactive (gnus-article-hidden-arg))
1544 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1545 (not gnus-show-all-headers))
1548 (let ((buffer-read-only nil)
1549 (list gnus-boring-article-headers)
1550 (inhibit-point-motion-hooks t)
1552 (article-narrow-to-head)
1554 (setq elem (pop list))
1555 (goto-char (point-min))
1557 ;; Hide empty headers.
1559 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1561 (gnus-article-hide-text-type
1562 (progn (beginning-of-line) (point))
1565 (if (re-search-forward "^[^ \t]" nil t)
1569 ;; Hide boring Newsgroups header.
1570 ((eq elem 'newsgroups)
1571 (when (gnus-string-equal
1572 (gnus-fetch-field "newsgroups")
1573 (gnus-group-real-name
1574 (if (boundp 'gnus-newsgroup-name)
1577 (gnus-article-hide-header "newsgroups")))
1578 ((eq elem 'to-address)
1579 (let ((to (message-fetch-field "to"))
1581 (gnus-parameter-to-address
1582 (if (boundp 'gnus-newsgroup-name)
1583 gnus-newsgroup-name ""))))
1584 (when (and to to-address
1587 ;; only one address in To
1588 (nth 1 (mail-extract-address-components to))
1590 (gnus-article-hide-header "to"))))
1591 ((eq elem 'followup-to)
1592 (when (gnus-string-equal
1593 (message-fetch-field "followup-to")
1594 (message-fetch-field "newsgroups"))
1595 (gnus-article-hide-header "followup-to")))
1596 ((eq elem 'reply-to)
1597 (let ((from (message-fetch-field "from"))
1598 (reply-to (message-fetch-field "reply-to")))
1603 (nth 1 (mail-extract-address-components from))
1604 (nth 1 (mail-extract-address-components reply-to)))))
1605 (gnus-article-hide-header "reply-to"))))
1607 (let ((date (message-fetch-field "date")))
1609 (< (days-between (current-time-string) date)
1611 (gnus-article-hide-header "date"))))
1613 (let ((to (message-fetch-field "to"))
1614 (cc (message-fetch-field "cc")))
1615 (when (> (length to) 1024)
1616 (gnus-article-hide-header "to"))
1617 (when (> (length cc) 1024)
1618 (gnus-article-hide-header "cc"))))
1622 (goto-char (point-min))
1623 (while (re-search-forward "^to:" nil t)
1624 (setq to-count (1+ to-count)))
1625 (when (> to-count 1)
1626 (while (> to-count 0)
1627 (goto-char (point-min))
1629 (re-search-forward "^to:" nil nil to-count)
1631 (narrow-to-region (point) (point-max))
1632 (gnus-article-hide-header "to"))
1633 (setq to-count (1- to-count))))
1634 (goto-char (point-min))
1635 (while (re-search-forward "^cc:" nil t)
1636 (setq cc-count (1+ cc-count)))
1637 (when (> cc-count 1)
1638 (while (> cc-count 0)
1639 (goto-char (point-min))
1641 (re-search-forward "^cc:" nil nil cc-count)
1643 (narrow-to-region (point) (point-max))
1644 (gnus-article-hide-header "cc"))
1645 (setq cc-count (1- cc-count)))))))))))))
1647 (defun gnus-article-hide-header (header)
1649 (goto-char (point-min))
1650 (when (re-search-forward (concat "^" header ":") nil t)
1651 (gnus-article-hide-text-type
1652 (progn (beginning-of-line) (point))
1655 (if (re-search-forward "^[^ \t]" nil t)
1660 (defvar gnus-article-normalized-header-length 40
1661 "Length of normalized headers.")
1663 (defun article-normalize-headers ()
1664 "Make all header lines 40 characters long."
1666 (let ((buffer-read-only nil)
1670 (article-narrow-to-head)
1673 ((< (setq column (- (gnus-point-at-eol) (point)))
1674 gnus-article-normalized-header-length)
1676 (insert (make-string
1677 (- gnus-article-normalized-header-length column)
1679 ((> column gnus-article-normalized-header-length)
1680 (gnus-put-text-property
1682 (forward-char gnus-article-normalized-header-length)
1689 (forward-line 1))))))
1691 (defun article-treat-dumbquotes ()
1692 "Translate M****s*** sm*rtq**t*s into proper text.
1693 Note that this function guesses whether a character is a sm*rtq**t* or
1694 not, so it should only be used interactively.
1696 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1697 in an attempt to provide more quoting characters. If you see
1698 something like \\222 or \\264 where you're expecting some kind of
1699 apostrophe or quotation mark, then try this wash."
1701 (article-translate-strings gnus-article-dumbquotes-map))
1703 (defun article-translate-characters (from to)
1704 "Translate all characters in the body of the article according to FROM and TO.
1705 FROM is a string of characters to translate from; to is a string of
1706 characters to translate to."
1708 (when (article-goto-body)
1709 (let ((buffer-read-only nil)
1710 (x (make-string 225 ?x))
1712 (while (< (incf i) (length x))
1715 (while (< i (length from))
1716 (aset x (aref from i) (aref to i))
1718 (translate-region (point) (point-max) x)))))
1720 (defun article-translate-strings (map)
1721 "Translate all string in the body of the article according to MAP.
1722 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1724 (when (article-goto-body)
1725 (let ((buffer-read-only nil)
1727 (while (setq elem (pop map))
1729 (while (search-forward (car elem) nil t)
1730 (replace-match (cadr elem)))))))))
1732 (defun article-treat-overstrike ()
1733 "Translate overstrikes into bold text."
1736 (when (article-goto-body)
1737 (let ((buffer-read-only nil))
1738 (while (search-forward "\b" nil t)
1739 (let ((next (char-after))
1740 (previous (char-after (- (point) 2))))
1741 ;; We do the boldification/underlining by hiding the
1742 ;; overstrikes and putting the proper text property
1746 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1747 (put-text-property (point) (1+ (point)) 'face 'bold))
1749 (gnus-article-hide-text-type
1750 (1- (point)) (1+ (point)) 'overstrike)
1752 (- (point) 2) (1- (point)) 'face 'underline))
1754 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1756 (point) (1+ (point)) 'face 'underline)))))))))
1758 (defun gnus-article-treat-unfold-headers ()
1759 "Unfold folded message headers.
1760 Only the headers that fit into the current window width will be
1763 (gnus-with-article-headers
1767 (mail-header-narrow-to-field)
1768 (let ((header (buffer-substring (point-min) (point-max))))
1771 (goto-char (point-min))
1772 (while (re-search-forward "\n[\t ]" nil t)
1773 (replace-match " " t t)))
1774 (setq length (- (point-max) (point-min) 1)))
1775 (when (< length (window-width))
1776 (while (re-search-forward "\n[\t ]" nil t)
1777 (replace-match " " t t)))
1778 (goto-char (point-max)))))))
1780 (defun gnus-article-treat-fold-headers ()
1781 "Fold message headers."
1783 (gnus-with-article-headers
1786 (mail-header-narrow-to-field)
1787 (mail-header-fold-field)
1788 (goto-char (point-max))))))
1790 (defun gnus-treat-smiley ()
1791 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1793 (gnus-with-article-buffer
1794 (if (memq 'smiley gnus-article-wash-types)
1795 (gnus-delete-images 'smiley)
1797 (let ((images (smiley-region (point) (point-max))))
1799 (gnus-add-wash-type 'smiley)
1800 (dolist (image images)
1801 (gnus-add-image 'smiley image)))))))
1803 (defun gnus-article-remove-images ()
1804 "Remove all images from the article buffer."
1806 (gnus-with-article-buffer
1807 (dolist (elem gnus-article-image-alist)
1808 (gnus-delete-images (car elem)))))
1810 (defun gnus-article-treat-fold-newsgroups ()
1811 "Unfold folded message headers.
1812 Only the headers that fit into the current window width will be
1815 (gnus-with-article-headers
1816 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1818 (mail-header-narrow-to-field)
1819 (while (re-search-forward ", *" nil t)
1820 (replace-match ", " t t))
1821 (mail-header-fold-field)
1822 (goto-char (point-max))))))
1824 (defun gnus-article-treat-body-boundary ()
1825 "Place a boundary line at the end of the headers."
1827 (when (and gnus-body-boundary-delimiter
1828 (> (length gnus-body-boundary-delimiter) 0))
1829 (gnus-with-article-headers
1830 (goto-char (point-max))
1831 (let ((start (point)))
1832 (insert "X-Boundary: ")
1833 (gnus-add-text-properties start (point) '(invisible t intangible t))
1835 (while (>= (1- (window-width)) (length str))
1836 (setq str (concat str gnus-body-boundary-delimiter)))
1837 (substring str 0 (1- (window-width))))
1839 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1841 (defun article-fill-long-lines ()
1842 "Fill lines that are wider than the window width."
1845 (let ((buffer-read-only nil)
1846 (width (window-width (get-buffer-window (current-buffer)))))
1849 (let ((adaptive-fill-mode nil)) ;Why? -sm
1852 (when (>= (current-column) (min fill-column width))
1853 (narrow-to-region (min (1+ (point)) (point-max)) (gnus-point-at-bol))
1854 (let ((goback (point-marker)))
1855 (fill-paragraph nil)
1856 (goto-char (marker-position goback)))
1858 (forward-line 1)))))))
1860 (defun article-capitalize-sentences ()
1861 "Capitalize the first word in each sentence."
1864 (let ((buffer-read-only nil)
1865 (paragraph-start "^[\n\^L]"))
1869 (forward-sentence)))))
1871 (defun article-remove-cr ()
1872 "Remove trailing CRs and then translate remaining CRs into LFs."
1875 (let ((buffer-read-only nil))
1876 (goto-char (point-min))
1877 (while (re-search-forward "\r+$" nil t)
1878 (replace-match "" t t))
1879 (goto-char (point-min))
1880 (while (search-forward "\r" nil t)
1881 (replace-match "\n" t t)))))
1883 (defun article-remove-trailing-blank-lines ()
1884 "Remove all trailing blank lines from the article."
1887 (let ((buffer-read-only nil))
1888 (goto-char (point-max))
1892 (while (and (not (bobp))
1893 (looking-at "^[ \t]*$")
1894 (not (gnus-annotation-in-region-p
1895 (point) (gnus-point-at-eol))))
1900 (defun article-display-x-face (&optional force)
1901 "Look for an X-Face header and display it if present."
1902 (interactive (list 'force))
1903 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1904 (gnus-with-article-headers
1905 ;; Delete the old process, if any.
1906 (when (process-status "article-x-face")
1907 (delete-process "article-x-face"))
1908 (if (memq 'xface gnus-article-wash-types)
1909 ;; We have already displayed X-Faces, so we remove them
1911 (gnus-delete-images 'xface)
1913 (let (x-faces from face grey)
1915 (when (and wash-face-p
1917 (goto-char (point-min))
1918 (not (re-search-forward
1919 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
1920 (gnus-buffer-live-p gnus-original-article-buffer))
1921 ;; If type `W f', use gnus-original-article-buffer,
1922 ;; otherwise use the current buffer because displaying
1923 ;; RFC822 parts calls this function too.
1924 (set-buffer gnus-original-article-buffer))
1926 (mail-narrow-to-head)
1927 (if gnus-treat-display-grey-xface
1929 (while (gnus-article-goto-header "X-Face\\(-[0-9]+\\)?")
1930 (if (match-beginning 2)
1933 (push (cons (- (string-to-number (match-string 2)))
1934 (mail-header-field-value))
1936 (push (cons 0 (mail-header-field-value)) x-faces)))
1937 (dolist (x-face (prog1
1939 (sort x-faces 'car-less-than-car)
1941 (setq x-faces nil)))
1942 (push (cdr x-face) x-faces)))
1943 (while (gnus-article-goto-header "X-Face")
1944 (push (mail-header-field-value) x-faces)))
1945 (setq from (message-fetch-field "from"))))
1947 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
1950 (setq image (gnus-create-image xpm 'xpm t))
1951 (gnus-article-goto-header "from")
1953 (insert "From: [no `from' set]\n")
1955 (gnus-add-wash-type 'xface)
1956 (gnus-add-image 'xface image)
1957 (gnus-put-image image)))
1958 ;; Sending multiple EOFs to xv doesn't work, so we only do a
1959 ;; single external face.
1960 (when (stringp gnus-article-x-face-command)
1961 (setq x-faces (list (car x-faces))))
1962 (while (and (setq face (pop x-faces))
1963 gnus-article-x-face-command
1965 ;; Check whether this face is censored.
1966 (not gnus-article-x-face-too-ugly)
1967 (and gnus-article-x-face-too-ugly from
1968 (not (string-match gnus-article-x-face-too-ugly
1970 ;; We display the face.
1971 (if (symbolp gnus-article-x-face-command)
1972 ;; The command is a lisp function, so we call it.
1973 (if (gnus-functionp gnus-article-x-face-command)
1974 (funcall gnus-article-x-face-command face)
1975 (error "%s is not a function" gnus-article-x-face-command))
1976 ;; The command is a string, so we interpret the command
1977 ;; as a, well, command, and fork it off.
1978 (let ((process-connection-type nil))
1979 (process-kill-without-query
1981 "article-x-face" nil shell-file-name shell-command-switch
1982 gnus-article-x-face-command))
1985 (process-send-region "article-x-face"
1986 (point-min) (point-max)))
1987 (process-send-eof "article-x-face"))))))))))
1989 (defun article-decode-mime-words ()
1990 "Decode all MIME-encoded words in the article."
1993 (set-buffer gnus-article-buffer)
1994 (let ((inhibit-point-motion-hooks t)
1996 (mail-parse-charset gnus-newsgroup-charset)
1997 (mail-parse-ignored-charsets
1998 (save-excursion (set-buffer gnus-summary-buffer)
1999 gnus-newsgroup-ignored-charsets)))
2000 (mail-decode-encoded-word-region (point-min) (point-max)))))
2002 (defun article-decode-charset (&optional prompt)
2003 "Decode charset-encoded text in the article.
2004 If PROMPT (the prefix), prompt for a coding system to use."
2006 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2008 (mail-parse-charset gnus-newsgroup-charset)
2009 (mail-parse-ignored-charsets
2010 (save-excursion (condition-case nil
2011 (set-buffer gnus-summary-buffer)
2013 gnus-newsgroup-ignored-charsets))
2014 ct cte ctl charset format)
2017 (article-narrow-to-head)
2018 (setq ct (message-fetch-field "Content-Type" t)
2019 cte (message-fetch-field "Content-Transfer-Encoding" t)
2020 ctl (and ct (ignore-errors
2021 (mail-header-parse-content-type ct)))
2024 (mm-read-coding-system "Charset to decode: "))
2026 (mail-content-type-get ctl 'charset)))
2027 format (and ctl (mail-content-type-get ctl 'format)))
2029 (setq cte (mail-header-strip cte)))
2030 (if (and ctl (not (string-match "/" (car ctl))))
2032 (goto-char (point-max)))
2035 (narrow-to-region (point) (point-max))
2036 (when (and (eq mail-parse-charset 'gnus-decoded)
2037 (eq (mm-body-7-or-8) '8bit))
2038 ;; The text code could have been decoded.
2039 (setq charset mail-parse-charset))
2040 (when (and (or (not ctl)
2041 (equal (car ctl) "text/plain"))
2042 (not format)) ;; article with format will decode later.
2044 charset (and cte (intern (downcase
2045 (gnus-strip-whitespace cte))))
2048 (defun article-decode-encoded-words ()
2049 "Remove encoded-word encoding from headers."
2050 (let ((inhibit-point-motion-hooks t)
2051 (mail-parse-charset gnus-newsgroup-charset)
2052 (mail-parse-ignored-charsets
2053 (save-excursion (condition-case nil
2054 (set-buffer gnus-summary-buffer)
2056 gnus-newsgroup-ignored-charsets))
2059 (article-narrow-to-head)
2060 (funcall gnus-decode-header-function (point-min) (point-max)))))
2062 (defun article-decode-group-name ()
2063 "Decode group names in `Newsgroups:'."
2064 (let ((inhibit-point-motion-hooks t)
2066 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2067 (when (and (or gnus-group-name-charset-method-alist
2068 gnus-group-name-charset-group-alist)
2069 (gnus-buffer-live-p gnus-original-article-buffer))
2070 (when (nnmail-fetch-field "Newsgroups")
2071 (nnheader-replace-header "Newsgroups"
2072 (gnus-decode-newsgroups
2073 (with-current-buffer
2074 gnus-original-article-buffer
2075 (nnmail-fetch-field "Newsgroups"))
2076 gnus-newsgroup-name method)))
2077 (when (nnmail-fetch-field "Followup-To")
2078 (nnheader-replace-header "Followup-To"
2079 (gnus-decode-newsgroups
2080 (with-current-buffer
2081 gnus-original-article-buffer
2082 (nnmail-fetch-field "Followup-To"))
2083 gnus-newsgroup-name method))))))
2085 (defun article-de-quoted-unreadable (&optional force read-charset)
2086 "Translate a quoted-printable-encoded article.
2087 If FORCE, decode the article whether it is marked as quoted-printable
2089 If READ-CHARSET, ask for a coding system."
2090 (interactive (list 'force current-prefix-arg))
2092 (let ((buffer-read-only nil) type charset)
2093 (if (gnus-buffer-live-p gnus-original-article-buffer)
2094 (with-current-buffer gnus-original-article-buffer
2096 (gnus-fetch-field "content-transfer-encoding"))
2097 (let* ((ct (gnus-fetch-field "content-type"))
2100 (mail-header-parse-content-type ct)))))
2101 (setq charset (and ctl
2102 (mail-content-type-get ctl 'charset)))
2103 (if (stringp charset)
2104 (setq charset (intern (downcase charset)))))))
2106 (setq charset (mm-read-coding-system "Charset: " charset)))
2108 (setq charset gnus-newsgroup-charset))
2110 (and type (let ((case-fold-search t))
2111 (string-match "quoted-printable" type))))
2113 (quoted-printable-decode-region
2114 (point) (point-max) (mm-charset-to-coding-system charset))))))
2116 (defun article-de-base64-unreadable (&optional force read-charset)
2117 "Translate a base64 article.
2118 If FORCE, decode the article whether it is marked as base64 not.
2119 If READ-CHARSET, ask for a coding system."
2120 (interactive (list 'force current-prefix-arg))
2122 (let ((buffer-read-only nil) type charset)
2123 (if (gnus-buffer-live-p gnus-original-article-buffer)
2124 (with-current-buffer gnus-original-article-buffer
2126 (gnus-fetch-field "content-transfer-encoding"))
2127 (let* ((ct (gnus-fetch-field "content-type"))
2130 (mail-header-parse-content-type ct)))))
2131 (setq charset (and ctl
2132 (mail-content-type-get ctl 'charset)))
2133 (if (stringp charset)
2134 (setq charset (intern (downcase charset)))))))
2136 (setq charset (mm-read-coding-system "Charset: " charset)))
2138 (setq charset gnus-newsgroup-charset))
2140 (and type (let ((case-fold-search t))
2141 (string-match "base64" type))))
2144 (narrow-to-region (point) (point-max))
2145 (base64-decode-region (point-min) (point-max))
2146 (mm-decode-coding-region
2147 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2152 (defun article-decode-HZ ()
2153 "Translate a HZ-encoded article."
2157 (let ((buffer-read-only nil))
2158 (rfc1843-decode-region (point-min) (point-max)))))
2160 (defun article-unsplit-urls ()
2161 "Remove the newlines that some other mailers insert into URLs."
2164 (let ((buffer-read-only nil))
2165 (goto-char (point-min))
2166 (while (re-search-forward
2167 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2168 (replace-match "\\1\\3" t)))
2169 (when (and gnus-display-mime-function (interactive-p))
2170 (funcall gnus-display-mime-function))))
2173 (defun article-wash-html (&optional read-charset)
2174 "Format an html article.
2175 If READ-CHARSET, ask for a coding system."
2178 (let ((buffer-read-only nil)
2180 (if (gnus-buffer-live-p gnus-original-article-buffer)
2181 (with-current-buffer gnus-original-article-buffer
2182 (let* ((ct (gnus-fetch-field "content-type"))
2185 (mail-header-parse-content-type ct)))))
2186 (setq charset (and ctl
2187 (mail-content-type-get ctl 'charset)))
2188 (if (stringp charset)
2189 (setq charset (intern (downcase charset)))))))
2191 (setq charset (mm-read-coding-system "Charset: " charset)))
2193 (setq charset gnus-newsgroup-charset))
2195 (save-window-excursion
2197 (narrow-to-region (point) (point-max))
2198 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2199 (entry (assq func mm-text-html-washer-alist)))
2201 (setq func (cdr entry)))
2203 ((gnus-functionp func)
2206 (apply (car func) (cdr func))))))))))
2208 (defun gnus-article-wash-html-with-w3 ()
2209 "Wash the current buffer with w3."
2211 (let ((w3-strict-width (window-width))
2212 (url-standalone-mode t)
2213 (url-gateway-unplugged t)
2214 (w3-honor-stylesheets nil))
2216 (w3-region (point-min) (point-max))
2219 (defun gnus-article-wash-html-with-w3m ()
2220 "Wash the current buffer with emacs-w3m."
2223 (narrow-to-region (point) (point-max))
2224 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2227 (w3m-display-inline-images mm-inline-text-html-with-images)
2228 w3m-force-redisplay)
2229 (w3m-region (point-min) (point-max)))
2230 (when mm-inline-text-html-with-w3m-keymap
2231 (add-text-properties
2232 (point-min) (point-max)
2233 (nconc (mm-w3m-local-map-property)
2234 '(mm-inline-text-html-with-w3m t))))))
2236 (defun article-hide-list-identifiers ()
2237 "Remove list identifies from the Subject header.
2238 The `gnus-list-identifiers' variable specifies what to do."
2240 (let ((inhibit-point-motion-hooks t)
2241 (regexp (if (consp gnus-list-identifiers)
2242 (mapconcat 'identity gnus-list-identifiers " *\\|")
2243 gnus-list-identifiers))
2248 (article-narrow-to-head)
2249 (goto-char (point-min))
2250 (while (re-search-forward
2251 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2253 (delete-region (match-beginning 2) (match-end 0))
2254 (beginning-of-line))
2255 (when (re-search-forward
2256 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2257 (delete-region (match-beginning 1) (match-end 1))))))))
2259 (defun article-hide-pgp ()
2260 "Remove any PGP headers and signatures in the current article."
2264 (let ((inhibit-point-motion-hooks t)
2265 buffer-read-only beg end)
2267 ;; Hide the "header".
2268 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2269 (gnus-add-wash-type 'pgp)
2270 (delete-region (match-beginning 0) (match-end 0))
2271 ;; Remove armor headers (rfc2440 6.2)
2272 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2275 ;; Hide the actual signature.
2276 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2277 (setq end (1+ (match-beginning 0)))
2280 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2282 ;; Perhaps we shouldn't hide to the end of the buffer
2283 ;; if there is no end to the signature?
2285 ;; Hide "- " PGP quotation markers.
2287 (narrow-to-region beg end)
2288 (goto-char (point-min))
2289 (while (re-search-forward "^- " nil t)
2291 (match-beginning 0) (match-end 0)))
2293 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2295 (defun article-hide-pem (&optional arg)
2296 "Toggle hiding of any PEM headers and signatures in the current article.
2297 If given a negative prefix, always show; if given a positive prefix,
2299 (interactive (gnus-article-hidden-arg))
2300 (unless (gnus-article-check-hidden-text 'pem arg)
2302 (let (buffer-read-only end)
2303 (goto-char (point-min))
2304 ;; Hide the horrendously ugly "header".
2305 (when (and (search-forward
2306 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2308 (setq end (1+ (match-beginning 0))))
2309 (gnus-add-wash-type 'pem)
2310 (gnus-article-hide-text-type
2312 (if (search-forward "\n\n" nil t)
2316 ;; Hide the trailer as well
2317 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2319 (gnus-article-hide-text-type
2320 (match-beginning 0) (match-end 0) 'pem)))))))
2322 (defun article-strip-banner ()
2323 "Strip the banner specified by the `banner' group parameter."
2327 (let ((inhibit-point-motion-hooks t)
2328 (banner (gnus-parameter-banner gnus-newsgroup-name))
2329 (gnus-signature-limit nil)
2330 buffer-read-only beg end)
2331 (when (and gnus-article-address-banner-alist
2334 (let ((from (save-restriction
2336 (article-narrow-to-head)
2337 (mail-fetch-field "from"))))
2340 (caar (mail-header-parse-addresses from))))
2342 (dolist (pair gnus-article-address-banner-alist)
2343 (when (string-match (car pair) from)
2344 (throw 'found (cdr pair)))))))))
2348 ((eq banner 'signature)
2349 (when (gnus-article-narrow-to-signature)
2352 (delete-region (point) (point-max))))
2354 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2355 (while (re-search-forward banner nil t)
2356 (delete-region (match-beginning 0) (match-end 0)))))
2358 (while (re-search-forward banner nil t)
2359 (delete-region (match-beginning 0) (match-end 0))))))))))
2361 (defun article-babel ()
2362 "Translate article using an online translation service."
2366 (set-buffer gnus-article-buffer)
2367 (when (article-goto-body)
2368 (let* ((buffer-read-only nil)
2371 (orig (buffer-substring start end))
2372 (trans (babel-as-string orig)))
2374 (narrow-to-region start end)
2375 (delete-region start end)
2378 (defun article-hide-signature (&optional arg)
2379 "Hide the signature in the current article.
2380 If given a negative prefix, always show; if given a positive prefix,
2382 (interactive (gnus-article-hidden-arg))
2383 (unless (gnus-article-check-hidden-text 'signature arg)
2386 (let ((buffer-read-only nil))
2387 (when (gnus-article-narrow-to-signature)
2388 (gnus-article-hide-text-type
2389 (point-min) (point-max) 'signature))))))
2390 (gnus-set-mode-line 'article))
2392 (defun article-strip-headers-in-body ()
2393 "Strip offensive headers from bodies."
2397 (let ((case-fold-search t))
2398 (when (looking-at "x-no-archive:")
2399 (gnus-delete-line)))))
2401 (defun article-strip-leading-blank-lines ()
2402 "Remove all blank lines from the beginning of the article."
2405 (let ((inhibit-point-motion-hooks t)
2407 (when (article-goto-body)
2408 (while (and (not (eobp))
2409 (looking-at "[ \t]*$"))
2410 (gnus-delete-line))))))
2412 (defun article-narrow-to-head ()
2413 "Narrow the buffer to the head of the message.
2414 Point is left at the beginning of the narrowed-to region."
2416 (goto-char (point-min))
2417 (if (search-forward "\n\n" nil 1)
2420 (goto-char (point-min)))
2422 (defun article-goto-body ()
2423 "Place point at the start of the body."
2424 (goto-char (point-min))
2426 ;; This variable is only bound when dealing with separate
2428 (article-goto-body-goes-to-point-min-p
2430 ((search-forward "\n\n" nil t)
2433 (goto-char (point-max))
2436 (defun article-strip-multiple-blank-lines ()
2437 "Replace consecutive blank lines with one empty line."
2440 (let ((inhibit-point-motion-hooks t)
2442 ;; First make all blank lines empty.
2444 (while (re-search-forward "^[ \t]+$" nil t)
2445 (unless (gnus-annotation-in-region-p
2446 (match-beginning 0) (match-end 0))
2447 (replace-match "" nil t)))
2448 ;; Then replace multiple empty lines with a single empty line.
2450 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2451 (unless (gnus-annotation-in-region-p
2452 (match-beginning 0) (match-end 0))
2453 (delete-region (match-beginning 1) (match-end 1)))))))
2455 (defun article-strip-leading-space ()
2456 "Remove all white space from the beginning of the lines in the article."
2459 (let ((inhibit-point-motion-hooks t)
2462 (while (re-search-forward "^[ \t]+" nil t)
2463 (replace-match "" t t)))))
2465 (defun article-strip-trailing-space ()
2466 "Remove all white space from the end of the lines in the article."
2469 (let ((inhibit-point-motion-hooks t)
2472 (while (re-search-forward "[ \t]+$" nil t)
2473 (replace-match "" t t)))))
2475 (defun article-strip-blank-lines ()
2476 "Strip leading, trailing and multiple blank lines."
2478 (article-strip-leading-blank-lines)
2479 (article-remove-trailing-blank-lines)
2480 (article-strip-multiple-blank-lines))
2482 (defun article-strip-all-blank-lines ()
2483 "Strip all blank lines."
2486 (let ((inhibit-point-motion-hooks t)
2489 (while (re-search-forward "^[ \t]*\n" nil t)
2490 (replace-match "" t t)))))
2492 (defun gnus-article-narrow-to-signature ()
2493 "Narrow to the signature; return t if a signature is found, else nil."
2494 (let ((inhibit-point-motion-hooks t))
2495 (when (gnus-article-search-signature)
2497 ;; Check whether we have some limits to what we consider
2498 ;; to be a signature.
2499 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2500 (list gnus-signature-limit)))
2502 (while (setq limit (pop limits))
2503 (if (or (and (integerp limit)
2504 (< (- (point-max) (point)) limit))
2506 (< (count-lines (point) (point-max)) limit))
2507 (and (gnus-functionp limit)
2509 (and (stringp limit)
2510 (not (re-search-forward limit nil t))))
2511 () ; This limit did not succeed.
2515 (narrow-to-region (point) (point-max))
2518 (defun gnus-article-search-signature ()
2519 "Search the current buffer for the signature separator.
2520 Put point at the beginning of the signature separator."
2521 (let ((cur (point)))
2522 (goto-char (point-max))
2523 (if (if (stringp gnus-signature-separator)
2524 (re-search-backward gnus-signature-separator nil t)
2525 (let ((seps gnus-signature-separator))
2527 (not (re-search-backward (car seps) nil t)))
2534 (defun gnus-article-hidden-arg ()
2535 "Return the current prefix arg as a number, or 0 if no prefix."
2536 (list (if current-prefix-arg
2537 (prefix-numeric-value current-prefix-arg)
2540 (defun gnus-article-check-hidden-text (type arg)
2541 "Return nil if hiding is necessary.
2542 Arg can be nil or a number. nil and positive means hide, negative
2543 means show, 0 means toggle."
2546 (let ((hide (gnus-article-hidden-text-p type)))
2552 (gnus-article-show-hidden-text type)
2555 (if (eq hide 'hidden)
2557 (gnus-article-show-hidden-text type)
2561 (defun gnus-article-hidden-text-p (type)
2562 "Say whether the current buffer contains hidden text of type TYPE."
2563 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2565 (not (get-text-property pos 'invisible))
2566 (not (get-text-property pos 'dummy-invisible)))
2568 (text-property-any (1+ pos) (point-max) 'article-type type)))
2573 (defun gnus-article-show-hidden-text (type &optional dummy)
2574 "Show all hidden text of type TYPE.
2575 Originally it is hide instead of DUMMY."
2576 (let ((buffer-read-only nil)
2577 (inhibit-point-motion-hooks t))
2578 (gnus-remove-text-properties-when
2580 (point-min) (point-max)
2581 (cons 'article-type (cons type
2582 gnus-hidden-properties)))
2583 (gnus-delete-wash-type type)))
2585 (defconst article-time-units
2586 `((year . ,(* 365.25 24 60 60))
2587 (week . ,(* 7 24 60 60))
2588 (day . ,(* 24 60 60))
2592 "Mapping from time units to seconds.")
2594 (defun article-date-ut (&optional type highlight header)
2595 "Convert DATE date to universal time in the current article.
2596 If TYPE is `local', convert to local time; if it is `lapsed', output
2597 how much time has lapsed since DATE. For `lapsed', the value of
2598 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2599 should replace the \"Date:\" one, or should be added below it."
2600 (interactive (list 'ut t))
2601 (let* ((header (or header
2602 (message-fetch-field "date")
2604 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2607 ((not gnus-article-date-lapsed-new-header)
2613 (date (if (vectorp header) (mail-header-date header)
2615 (inhibit-point-motion-hooks t)
2620 (article-narrow-to-head)
2621 (when (re-search-forward tdate-regexp nil t)
2622 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2623 date (or (get-text-property (gnus-point-at-bol)
2626 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2628 (when (and date (not (string= date "")))
2629 (goto-char (point-min))
2630 (let ((buffer-read-only nil))
2631 ;; Delete any old Date headers.
2632 (while (re-search-forward date-regexp nil t)
2634 (delete-region (progn (beginning-of-line) (point))
2635 (progn (forward-line 1) (point)))
2636 (delete-region (progn (beginning-of-line) (point))
2637 (progn (end-of-line) (point)))
2638 (setq pos (point))))
2639 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2641 (if pos (goto-char pos))
2642 (insert (article-make-date-line date (or type 'ut)))
2648 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2649 (put-text-property (match-beginning 1) (1+ (match-end 1))
2650 'original-date date)
2651 (put-text-property (match-beginning 1) (1+ (match-end 1))
2653 (put-text-property (match-beginning 2) (match-end 2)
2656 (defun article-make-date-line (date type)
2657 "Return a DATE line of TYPE."
2658 (unless (memq type '(local ut original user iso8601 lapsed english))
2659 (error "Unknown conversion type: %s" type))
2661 (let ((time (date-to-time date)))
2663 ;; Convert to the local timezone.
2665 (let ((tz (car (current-time-zone time))))
2666 (format "Date: %s %s%02d%02d" (current-time-string time)
2667 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2668 (/ (% (abs tz) 3600) 60))))
2669 ;; Convert to Universal Time.
2672 (current-time-string
2673 (let* ((e (parse-time-string date))
2674 (tm (apply 'encode-time e))
2676 (ls (- (cadr tm) (car (current-time-zone time)))))
2677 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2678 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2681 ;; Get the original date from the article.
2682 ((eq type 'original)
2683 (concat "Date: " (if (string-match "\n+$" date)
2684 (substring date 0 (match-beginning 0))
2686 ;; Let the user define the format.
2688 (let ((format (or (condition-case nil
2689 (with-current-buffer gnus-summary-buffer
2690 gnus-article-time-format)
2692 gnus-article-time-format)))
2693 (if (gnus-functionp format)
2694 (funcall format time)
2695 (concat "Date: " (format-time-string format time)))))
2698 (let ((tz (car (current-time-zone time))))
2701 (format-time-string "%Y%m%dT%H%M%S" time)
2702 (format "%s%02d%02d"
2703 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2704 (/ (% (abs tz) 3600) 60)))))
2705 ;; Do an X-Sent lapsed format.
2707 ;; If the date is seriously mangled, the timezone functions are
2708 ;; liable to bug out, so we ignore all errors.
2709 (let* ((now (current-time))
2710 (real-time (subtract-time now time))
2711 (real-sec (and real-time
2712 (+ (* (float (car real-time)) 65536)
2714 (sec (and real-time (abs real-sec)))
2724 ;; This is a bit convoluted, but basically we go
2725 ;; through the time units for years, weeks, etc,
2726 ;; and divide things to see whether that results
2727 ;; in positive answers.
2730 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2731 ;; The (remaining) seconds are too few to
2732 ;; be divided into this time unit.
2734 ;; It's big enough, so we output it.
2735 (setq sec (- sec (* num (cdr unit))))
2737 (concat (if prev ", " "") (int-to-string
2739 " " (symbol-name (car unit))
2740 (if (> num 1) "s" ""))
2742 article-time-units "")
2743 ;; If dates are odd, then it might appear like the
2744 ;; article was sent in the future.
2747 " in the future"))))))
2748 ;; Display the date in proper English
2750 (let ((dtime (decode-time time)))
2753 (number-to-string (nth 3 dtime))
2754 (let ((digit (% (nth 3 dtime) 10)))
2756 ((memq (nth 3 dtime) '(11 12 13)) "th")
2762 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2764 (number-to-string (nth 5 dtime))
2766 (format "%02d" (nth 2 dtime))
2768 (format "%02d" (nth 1 dtime)))))))
2770 (format "Date: %s (from Gnus)" date))))
2772 (defun article-date-local (&optional highlight)
2773 "Convert the current article date to the local timezone."
2774 (interactive (list t))
2775 (article-date-ut 'local highlight))
2777 (defun article-date-english (&optional highlight)
2778 "Convert the current article date to something that is proper English."
2779 (interactive (list t))
2780 (article-date-ut 'english highlight))
2782 (defun article-date-original (&optional highlight)
2783 "Convert the current article date to what it was originally.
2784 This is only useful if you have used some other date conversion
2785 function and want to see what the date was before converting."
2786 (interactive (list t))
2787 (article-date-ut 'original highlight))
2789 (defun article-date-lapsed (&optional highlight)
2790 "Convert the current article date to time lapsed since it was sent."
2791 (interactive (list t))
2792 (article-date-ut 'lapsed highlight))
2794 (defun article-update-date-lapsed ()
2795 "Function to be run from a timer to update the lapsed time line."
2796 (let (deactivate-mark)
2801 (set-buffer (window-buffer w))
2802 (when (eq major-mode 'gnus-article-mode)
2803 (goto-char (point-min))
2804 (when (re-search-forward "^X-Sent:" nil t)
2805 (article-date-lapsed t))))
2808 (defun gnus-start-date-timer (&optional n)
2809 "Start a timer to update the X-Sent header in the article buffers.
2810 The numerical prefix says how frequently (in seconds) the function
2815 (gnus-stop-date-timer)
2816 (setq article-lapsed-timer
2817 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2819 (defun gnus-stop-date-timer ()
2820 "Stop the X-Sent timer."
2822 (when article-lapsed-timer
2823 (nnheader-cancel-timer article-lapsed-timer)
2824 (setq article-lapsed-timer nil)))
2826 (defun article-date-user (&optional highlight)
2827 "Convert the current article date to the user-defined format.
2828 This format is defined by the `gnus-article-time-format' variable."
2829 (interactive (list t))
2830 (article-date-ut 'user highlight))
2832 (defun article-date-iso8601 (&optional highlight)
2833 "Convert the current article date to ISO8601."
2834 (interactive (list t))
2835 (article-date-ut 'iso8601 highlight))
2837 ;; (defun article-show-all ()
2838 ;; "Show all hidden text in the article buffer."
2841 ;; (let ((buffer-read-only nil))
2842 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2844 (defun article-remove-leading-whitespace ()
2845 "Remove excessive whitespace from all headers."
2849 (let ((buffer-read-only nil))
2850 (article-narrow-to-head)
2851 (goto-char (point-min))
2852 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2853 (delete-region (match-beginning 1) (match-end 1)))))))
2855 (defun article-emphasize (&optional arg)
2856 "Emphasize text according to `gnus-emphasis-alist'."
2857 (interactive (gnus-article-hidden-arg))
2858 (unless (gnus-article-check-hidden-text 'emphasis arg)
2862 (with-current-buffer gnus-summary-buffer
2863 gnus-article-emphasis-alist)
2865 gnus-emphasis-alist))
2866 (buffer-read-only nil)
2867 (props (append '(article-type emphasis)
2868 gnus-hidden-properties))
2869 regexp elem beg invisible visible face)
2872 (while (setq elem (pop alist))
2874 (setq regexp (car elem)
2875 invisible (nth 1 elem)
2876 visible (nth 2 elem)
2878 (while (re-search-forward regexp nil t)
2879 (when (and (match-beginning visible) (match-beginning invisible))
2880 (gnus-article-hide-text
2881 (match-beginning invisible) (match-end invisible) props)
2882 (gnus-article-unhide-text-type
2883 (match-beginning visible) (match-end visible) 'emphasis)
2884 (gnus-put-overlay-excluding-newlines
2885 (match-beginning visible) (match-end visible) 'face face)
2886 (gnus-add-wash-type 'emphasis)
2887 (goto-char (match-end invisible)))))))))
2889 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2890 "Setup newsgroup emphasis alist."
2891 (unless gnus-article-emphasis-alist
2892 (let ((name (and gnus-newsgroup-name
2893 (gnus-group-real-name gnus-newsgroup-name))))
2894 (make-local-variable 'gnus-article-emphasis-alist)
2895 (setq gnus-article-emphasis-alist
2897 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2898 (while (setq elem (pop alist))
2899 (when (and name (string-match (car elem) name))
2901 highlight (copy-sequence (cdr elem)))))
2903 (copy-sequence highlight-words)
2904 (if gnus-newsgroup-name
2905 (copy-sequence (gnus-group-find-parameter
2906 gnus-newsgroup-name 'highlight-words t)))
2907 gnus-emphasis-alist)))))
2910 (defvar gnus-summary-article-menu)
2911 (defvar gnus-summary-post-menu))
2913 ;;; Saving functions.
2915 (defun gnus-article-save (save-buffer file &optional num)
2916 "Save the currently selected article."
2917 (unless gnus-save-all-headers
2918 ;; Remove headers according to `gnus-saved-headers'.
2919 (let ((gnus-visible-headers
2920 (or gnus-saved-headers gnus-visible-headers))
2921 (gnus-article-buffer save-buffer))
2923 (set-buffer save-buffer)
2924 (article-hide-headers 1 t))))
2925 (save-window-excursion
2926 (if (not gnus-default-article-saver)
2927 (error "No default saver is defined")
2928 ;; !!! Magic! The saving functions all save
2929 ;; `gnus-save-article-buffer' (or so they think), but we
2930 ;; bind that variable to our save-buffer.
2931 (set-buffer gnus-article-buffer)
2932 (let* ((gnus-save-article-buffer save-buffer)
2935 ((not gnus-prompt-before-saving) 'default)
2936 ((eq gnus-prompt-before-saving 'always) nil)
2938 (gnus-number-of-articles-to-be-saved
2939 (when (eq gnus-prompt-before-saving t)
2941 (set-buffer gnus-article-current-summary)
2942 (funcall gnus-default-article-saver filename)))))
2944 (defun gnus-read-save-file-name (prompt &optional filename
2945 function group headers variable)
2947 (funcall function group headers (symbol-value variable)))
2952 ((eq filename 'default)
2958 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2961 (if (and gnus-number-of-articles-to-be-saved
2962 (> gnus-number-of-articles-to-be-saved 1))
2963 (format "these %d articles"
2964 gnus-number-of-articles-to-be-saved)
2967 ;; Let the split methods have their say.
2969 ;; No split name was found.
2972 (concat prompt " (default "
2973 (file-name-nondirectory default-name) ") ")
2974 (file-name-directory default-name)
2976 ;; A single group name is returned.
2977 ((stringp split-name)
2979 (funcall function split-name headers
2980 (symbol-value variable)))
2982 (concat prompt " (default "
2983 (file-name-nondirectory default-name) ") ")
2984 (file-name-directory default-name)
2986 ;; A single split name was found
2987 ((= 1 (length split-name))
2988 (let* ((name (expand-file-name
2990 gnus-article-save-directory))
2991 (dir (cond ((file-directory-p name)
2992 (file-name-as-directory name))
2993 ((file-exists-p name) name)
2994 (t gnus-article-save-directory))))
2996 (concat prompt " (default " name ") ")
2998 ;; A list of splits was found.
3000 (setq split-name (nreverse split-name))
3002 (let ((file-name-history
3003 (nconc split-name file-name-history)))
3007 (concat prompt " (`M-p' for defaults) ")
3008 gnus-article-save-directory
3010 gnus-article-save-directory)))
3011 (car (push result file-name-history)))))))
3012 ;; Create the directory.
3013 (gnus-make-directory (file-name-directory file))
3014 ;; If we have read a directory, we append the default file name.
3015 (when (file-directory-p file)
3016 (setq file (expand-file-name (file-name-nondirectory
3018 (file-name-as-directory file))))
3019 ;; Possibly translate some characters.
3020 (nnheader-translate-file-chars file))))))
3021 (gnus-make-directory (file-name-directory result))
3022 (set variable result)))
3024 (defun gnus-article-archive-name (group)
3025 "Return the first instance of an \"Archive-name\" in the current buffer."
3026 (let ((case-fold-search t))
3027 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3028 (nnheader-concat gnus-article-save-directory
3029 (match-string 1)))))
3031 (defun gnus-article-nndoc-name (group)
3032 "If GROUP is an nndoc group, return the name of the parent group."
3033 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3034 (gnus-group-get-parameter group 'save-article-group)))
3036 (defun gnus-summary-save-in-rmail (&optional filename)
3037 "Append this article to Rmail file.
3038 Optional argument FILENAME specifies file name.
3039 Directory to save to is default to `gnus-article-save-directory'."
3040 (setq filename (gnus-read-save-file-name
3041 "Save %s in rmail file:" filename
3042 gnus-rmail-save-name gnus-newsgroup-name
3043 gnus-current-headers 'gnus-newsgroup-last-rmail))
3044 (gnus-eval-in-buffer-window gnus-save-article-buffer
3048 (gnus-output-to-rmail filename))))
3051 (defun gnus-summary-save-in-mail (&optional filename)
3052 "Append this article to Unix mail file.
3053 Optional argument FILENAME specifies file name.
3054 Directory to save to is default to `gnus-article-save-directory'."
3055 (setq filename (gnus-read-save-file-name
3056 "Save %s in Unix mail file:" filename
3057 gnus-mail-save-name gnus-newsgroup-name
3058 gnus-current-headers 'gnus-newsgroup-last-mail))
3059 (gnus-eval-in-buffer-window gnus-save-article-buffer
3063 (if (and (file-readable-p filename)
3064 (mail-file-babyl-p filename))
3065 (rmail-output-to-rmail-file filename t)
3066 (gnus-output-to-mail filename)))))
3069 (defun gnus-summary-save-in-file (&optional filename overwrite)
3070 "Append this article to file.
3071 Optional argument FILENAME specifies file name.
3072 Directory to save to is default to `gnus-article-save-directory'."
3073 (setq filename (gnus-read-save-file-name
3074 "Save %s in file:" filename
3075 gnus-file-save-name gnus-newsgroup-name
3076 gnus-current-headers 'gnus-newsgroup-last-file))
3077 (gnus-eval-in-buffer-window gnus-save-article-buffer
3081 (when (and overwrite
3082 (file-exists-p filename))
3083 (delete-file filename))
3084 (gnus-output-to-file filename))))
3087 (defun gnus-summary-write-to-file (&optional filename)
3088 "Write this article to a file, overwriting it if the file exists.
3089 Optional argument FILENAME specifies file name.
3090 The directory to save in defaults to `gnus-article-save-directory'."
3091 (gnus-summary-save-in-file nil t))
3093 (defun gnus-summary-save-body-in-file (&optional filename)
3094 "Append this article body to a file.
3095 Optional argument FILENAME specifies file name.
3096 The directory to save in defaults to `gnus-article-save-directory'."
3097 (setq filename (gnus-read-save-file-name
3098 "Save %s body in file:" filename
3099 gnus-file-save-name gnus-newsgroup-name
3100 gnus-current-headers 'gnus-newsgroup-last-file))
3101 (gnus-eval-in-buffer-window gnus-save-article-buffer
3105 (when (article-goto-body)
3106 (narrow-to-region (point) (point-max)))
3107 (gnus-output-to-file filename))))
3110 (defun gnus-summary-save-in-pipe (&optional command)
3111 "Pipe this article to subprocess."
3113 (cond ((and (eq command 'default)
3114 gnus-last-shell-command)
3115 gnus-last-shell-command)
3120 "Shell command on %s: "
3121 (if (and gnus-number-of-articles-to-be-saved
3122 (> gnus-number-of-articles-to-be-saved 1))
3123 (format "these %d articles"
3124 gnus-number-of-articles-to-be-saved)
3126 gnus-last-shell-command))))
3127 (when (string-equal command "")
3128 (if gnus-last-shell-command
3129 (setq command gnus-last-shell-command)
3130 (error "A command is required")))
3131 (gnus-eval-in-buffer-window gnus-article-buffer
3134 (shell-command-on-region (point-min) (point-max) command nil)))
3135 (setq gnus-last-shell-command command))
3137 (defun gnus-summary-pipe-to-muttprint (&optional command)
3138 "Pipe this article to muttprint."
3139 (setq command (read-string
3140 "Print using command: " gnus-summary-muttprint-program
3141 nil gnus-summary-muttprint-program))
3142 (gnus-summary-save-in-pipe command))
3144 ;;; Article file names when saving.
3146 (defun gnus-capitalize-newsgroup (newsgroup)
3147 "Capitalize NEWSGROUP name."
3148 (when (not (zerop (length newsgroup)))
3149 (concat (char-to-string (upcase (aref newsgroup 0)))
3150 (substring newsgroup 1))))
3152 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3153 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3154 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3155 Otherwise, it is like ~/News/news/group/num."
3158 (concat (if (gnus-use-long-file-name 'not-save)
3159 (gnus-capitalize-newsgroup newsgroup)
3160 (gnus-newsgroup-directory-form newsgroup))
3161 "/" (int-to-string (mail-header-number headers)))
3162 gnus-article-save-directory)))
3164 (string-equal (file-name-directory default)
3165 (file-name-directory last-file))
3166 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3168 (or last-file default))))
3170 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3171 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3172 If variable `gnus-use-long-file-name' is non-nil, it is
3173 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3176 (concat (if (gnus-use-long-file-name 'not-save)
3178 (gnus-newsgroup-directory-form newsgroup))
3179 "/" (int-to-string (mail-header-number headers)))
3180 gnus-article-save-directory)))
3182 (string-equal (file-name-directory default)
3183 (file-name-directory last-file))
3184 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3186 (or last-file default))))
3188 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3189 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3190 If variable `gnus-use-long-file-name' is non-nil, it is
3191 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3194 (if (gnus-use-long-file-name 'not-save)
3197 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3199 gnus-article-save-directory)))
3201 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3202 "Generate file name from sender."
3203 (let ((from (mail-header-from headers)))
3205 (if (and from (string-match "\\([^ <]+\\)@" from))
3206 (match-string 1 from)
3208 gnus-article-save-directory)))
3210 (defun article-verify-x-pgp-sig ()
3213 (if (gnus-buffer-live-p gnus-original-article-buffer)
3214 (let ((sig (with-current-buffer gnus-original-article-buffer
3215 (gnus-fetch-field "X-PGP-Sig")))
3219 (mml2015-clear-verify-function))
3221 (insert-buffer gnus-original-article-buffer)
3222 (setq items (split-string sig))
3223 (message-narrow-to-head)
3224 (let ((inhibit-point-motion-hooks t)
3225 (case-fold-search t))
3226 ;; Don't verify multiple headers.
3227 (setq headers (mapconcat (lambda (header)
3229 (mail-fetch-field header) "\n"))
3230 (split-string (nth 1 items) ",") "")))
3231 (delete-region (point-min) (point-max))
3232 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3233 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3238 (if (looking-at "^-")
3241 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3242 (insert "Version: " (car items) "\n\n")
3243 (insert (mapconcat 'identity (cddr items) "\n"))
3244 (insert "\n-----END PGP SIGNATURE-----\n")
3245 (let ((mm-security-handle (list (format "multipart/signed"))))
3246 (mml2015-clean-buffer)
3247 (let ((coding-system-for-write (or gnus-newsgroup-charset
3249 (funcall (mml2015-clear-verify-function)))
3251 (or (mm-handle-multipart-ctl-parameter
3252 mm-security-handle 'gnus-details)
3253 (mm-handle-multipart-ctl-parameter
3254 mm-security-handle 'gnus-info)))))
3256 (let (buffer-read-only bface eface)
3258 (message-narrow-to-head)
3259 (goto-char (point-max))
3261 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3262 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3263 (message-remove-header "X-Gnus-PGP-Verify")
3264 (if (re-search-forward "^X-PGP-Sig:" nil t)
3266 (goto-char (point-max)))
3267 (narrow-to-region (point) (point))
3268 (insert "X-Gnus-PGP-Verify: " info "\n")
3269 (goto-char (point-min))
3272 (if (not (looking-at "^[ \t]"))
3276 (goto-char (point-min))
3277 (when (looking-at "\\([^:]+\\): *")
3278 (put-text-property (match-beginning 1) (1+ (match-end 1))
3280 (put-text-property (match-end 0) (point-max)
3281 'face eface)))))))))
3283 (defun article-verify-cancel-lock ()
3284 "Verify Cancel-Lock header."
3286 (if (gnus-buffer-live-p gnus-original-article-buffer)
3287 (canlock-verify gnus-original-article-buffer)))
3294 (setq afunc (car func)
3297 gfunc (intern (format "gnus-%s" func))))
3299 (when (fboundp afunc)
3300 `(lambda (&optional interactive &rest args)
3301 ,(documentation afunc t)
3302 (interactive (list t))
3304 (set-buffer gnus-article-buffer)
3306 (call-interactively ',afunc)
3307 (apply ',afunc args))))))))
3308 '(article-hide-headers
3309 article-verify-x-pgp-sig
3310 article-verify-cancel-lock
3311 article-hide-boring-headers
3312 article-treat-overstrike
3313 article-fill-long-lines
3314 article-capitalize-sentences
3316 article-remove-leading-whitespace
3317 article-display-x-face
3318 article-de-quoted-unreadable
3319 article-de-base64-unreadable
3322 article-unsplit-urls
3323 article-hide-list-identifiers
3325 article-strip-banner
3328 article-hide-signature
3329 article-strip-headers-in-body
3330 article-remove-trailing-blank-lines
3331 article-strip-leading-blank-lines
3332 article-strip-multiple-blank-lines
3333 article-strip-leading-space
3334 article-strip-trailing-space
3335 article-strip-blank-lines
3336 article-strip-all-blank-lines
3338 article-date-english
3339 article-date-iso8601
3340 article-date-original
3342 article-decode-mime-words
3343 article-decode-charset
3344 article-decode-encoded-words
3348 article-treat-dumbquotes
3349 article-normalize-headers
3350 ;; (article-show-all . gnus-article-show-all-headers)
3354 ;;; Gnus article mode
3357 (put 'gnus-article-mode 'mode-class 'special)
3359 (set-keymap-parent gnus-article-mode-map widget-keymap)
3361 (gnus-define-keys gnus-article-mode-map
3362 " " gnus-article-goto-next-page
3363 "\177" gnus-article-goto-prev-page
3364 [delete] gnus-article-goto-prev-page
3365 [backspace] gnus-article-goto-prev-page
3366 "\C-c^" gnus-article-refer-article
3367 "h" gnus-article-show-summary
3368 "s" gnus-article-show-summary
3369 "\C-c\C-m" gnus-article-mail
3370 "?" gnus-article-describe-briefly
3371 "e" gnus-summary-edit-article
3372 "<" beginning-of-buffer
3374 "\C-c\C-i" gnus-info-find-node
3376 "R" gnus-article-reply-with-original
3377 "F" gnus-article-followup-with-original
3378 "\C-hk" gnus-article-describe-key
3379 "\C-hc" gnus-article-describe-key-briefly
3381 "\C-d" gnus-article-read-summary-keys
3382 "\M-*" gnus-article-read-summary-keys
3383 "\M-#" gnus-article-read-summary-keys
3384 "\M-^" gnus-article-read-summary-keys
3385 "\M-g" gnus-article-read-summary-keys)
3387 (substitute-key-definition
3388 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3390 (defun gnus-article-make-menu-bar ()
3391 (unless (boundp 'gnus-article-commands-menu)
3392 (gnus-summary-make-menu-bar))
3393 (gnus-turn-off-edit-menu 'article)
3394 (unless (boundp 'gnus-article-article-menu)
3396 gnus-article-article-menu gnus-article-mode-map ""
3398 ["Scroll forwards" gnus-article-goto-next-page t]
3399 ["Scroll backwards" gnus-article-goto-prev-page t]
3400 ["Show summary" gnus-article-show-summary t]
3401 ["Fetch Message-ID at point" gnus-article-refer-article t]
3402 ["Mail to address at point" gnus-article-mail t]
3403 ["Send a bug report" gnus-bug t]))
3406 gnus-article-treatment-menu gnus-article-mode-map ""
3407 ;; Fixme: this should use :active (and maybe :visible).
3409 ["Hide headers" gnus-article-hide-headers t]
3410 ["Hide signature" gnus-article-hide-signature t]
3411 ["Hide citation" gnus-article-hide-citation t]
3412 ["Treat overstrike" gnus-article-treat-overstrike t]
3413 ["Remove carriage return" gnus-article-remove-cr t]
3414 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3415 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3416 ["Remove base64" gnus-article-de-base64-unreadable t]
3417 ["Treat html" gnus-article-wash-html t]
3418 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3419 ["Decode HZ" gnus-article-decode-HZ t]))
3421 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3423 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3425 (gnus-run-hooks 'gnus-article-menu-hook)))
3427 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3430 (defun gnus-article-mode ()
3431 "Major mode for displaying an article.
3433 All normal editing commands are switched off.
3435 The following commands are available in addition to all summary mode
3437 \\<gnus-article-mode-map>
3438 \\[gnus-article-next-page]\t Scroll the article one page forwards
3439 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3440 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3441 \\[gnus-article-show-summary]\t Display the summary buffer
3442 \\[gnus-article-mail]\t Send a reply to the address near point
3443 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3444 \\[gnus-info-find-node]\t Go to the Gnus info node"
3446 (gnus-simplify-mode-line)
3447 (setq mode-name "Article")
3448 (setq major-mode 'gnus-article-mode)
3449 (make-local-variable 'minor-mode-alist)
3450 (use-local-map gnus-article-mode-map)
3451 (when (gnus-visual-p 'article-menu 'menu)
3452 (gnus-article-make-menu-bar))
3453 (gnus-update-format-specifications nil 'article-mode)
3454 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3455 (make-local-variable 'gnus-page-broken)
3456 (make-local-variable 'gnus-button-marker-list)
3457 (make-local-variable 'gnus-article-current-summary)
3458 (make-local-variable 'gnus-article-mime-handles)
3459 (make-local-variable 'gnus-article-decoded-p)
3460 (make-local-variable 'gnus-article-mime-handle-alist)
3461 (make-local-variable 'gnus-article-wash-types)
3462 (make-local-variable 'gnus-article-image-alist)
3463 (make-local-variable 'gnus-article-charset)
3464 (make-local-variable 'gnus-article-ignored-charsets)
3465 (gnus-set-default-directory)
3466 (buffer-disable-undo)
3467 (setq buffer-read-only t)
3468 (set-syntax-table gnus-article-mode-syntax-table)
3469 (mm-enable-multibyte)
3470 (gnus-run-hooks 'gnus-article-mode-hook))
3472 (defun gnus-article-setup-buffer ()
3473 "Initialize the article buffer."
3474 (let* ((name (if gnus-single-article-buffer "*Article*"
3475 (concat "*Article " gnus-newsgroup-name "*")))
3477 (progn (string-match "\\*Article" name)
3478 (concat " *Original Article"
3479 (substring name (match-end 0))))))
3480 (setq gnus-article-buffer name)
3481 (setq gnus-original-article-buffer original)
3482 (setq gnus-article-mime-handle-alist nil)
3483 ;; This might be a variable local to the summary buffer.
3484 (unless gnus-single-article-buffer
3486 (set-buffer gnus-summary-buffer)
3487 (setq gnus-article-buffer name)
3488 (setq gnus-original-article-buffer original)
3489 (gnus-set-global-variables)))
3490 (gnus-article-setup-highlight-words)
3491 ;; Init original article buffer.
3493 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3494 (mm-enable-multibyte)
3495 (setq major-mode 'gnus-original-article-mode)
3496 (make-local-variable 'gnus-original-article))
3497 (if (get-buffer name)
3500 (when gnus-article-mime-handles
3501 (mm-destroy-parts gnus-article-mime-handles)
3502 (setq gnus-article-mime-handles nil))
3503 ;; Set it to nil in article-buffer!
3504 (setq gnus-article-mime-handle-alist nil)
3505 (buffer-disable-undo)
3506 (setq buffer-read-only t)
3507 (unless (eq major-mode 'gnus-article-mode)
3508 (gnus-article-mode))
3511 (set-buffer (gnus-get-buffer-create name))
3513 (make-local-variable 'gnus-summary-buffer)
3514 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3515 (current-buffer)))))
3517 ;; Set article window start at LINE, where LINE is the number of lines
3518 ;; from the head of the article.
3519 (defun gnus-article-set-window-start (&optional line)
3521 (gnus-get-buffer-window gnus-article-buffer t)
3523 (set-buffer gnus-article-buffer)
3524 (goto-char (point-min))
3527 (gnus-message 6 "Moved to bookmark")
3528 (search-forward "\n\n" nil t)
3532 (defun gnus-article-prepare (article &optional all-headers header)
3533 "Prepare ARTICLE in article mode buffer.
3534 ARTICLE should either be an article number or a Message-ID.
3535 If ARTICLE is an id, HEADER should be the article headers.
3536 If ALL-HEADERS is non-nil, no headers are hidden."
3538 ;; Make sure we start in a summary buffer.
3539 (unless (eq major-mode 'gnus-summary-mode)
3540 (set-buffer gnus-summary-buffer))
3541 (setq gnus-summary-buffer (current-buffer))
3542 (let* ((gnus-article (if header (mail-header-number header) article))
3543 (summary-buffer (current-buffer))
3544 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3545 (group gnus-newsgroup-name)
3548 (gnus-article-setup-buffer)
3549 (set-buffer gnus-article-buffer)
3550 ;; Deactivate active regions.
3551 (when (and (boundp 'transient-mark-mode)
3552 transient-mark-mode)
3553 (setq mark-active nil))
3554 (if (not (setq result (let ((buffer-read-only nil))
3555 (gnus-request-article-this-buffer
3557 ;; There is no such article.
3559 (when (and (numberp article)
3560 (not (memq article gnus-newsgroup-sparse)))
3561 (setq gnus-article-current
3562 (cons gnus-newsgroup-name article))
3563 (set-buffer gnus-summary-buffer)
3564 (setq gnus-current-article article)
3565 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3567 (gnus-summary-set-agent-mark article)
3568 (message "Message marked for downloading"))
3569 (gnus-summary-mark-article article gnus-canceled-mark)
3570 (unless (memq article gnus-newsgroup-sparse)
3571 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3572 (if (or (eq result 'pseudo)
3573 (eq result 'nneething))
3576 (set-buffer summary-buffer)
3577 (push article gnus-newsgroup-history)
3578 (setq gnus-last-article gnus-current-article
3579 gnus-current-article 0
3580 gnus-current-headers nil
3581 gnus-article-current nil)
3582 (if (eq result 'nneething)
3583 (gnus-configure-windows 'summary)
3584 (gnus-configure-windows 'article))
3585 (gnus-set-global-variables))
3586 (let ((gnus-article-mime-handle-alist-1
3587 gnus-article-mime-handle-alist))
3588 (gnus-set-mode-line 'article)))
3589 ;; The result from the `request' was an actual article -
3590 ;; or at least some text that is now displayed in the
3592 (when (and (numberp article)
3593 (not (eq article gnus-current-article)))
3594 ;; Seems like a new article has been selected.
3595 ;; `gnus-current-article' must be an article number.
3597 (set-buffer summary-buffer)
3598 (push article gnus-newsgroup-history)
3599 (setq gnus-last-article gnus-current-article
3600 gnus-current-article article
3601 gnus-current-headers
3602 (gnus-summary-article-header gnus-current-article)
3603 gnus-article-current
3604 (cons gnus-newsgroup-name gnus-current-article))
3605 (unless (vectorp gnus-current-headers)
3606 (setq gnus-current-headers nil))
3607 (gnus-summary-goto-subject gnus-current-article)
3608 (when (gnus-summary-show-thread)
3609 ;; If the summary buffer really was folded, the
3610 ;; previous goto may not actually have gone to
3611 ;; the right article, but the thread root instead.
3613 (gnus-summary-goto-subject gnus-current-article))
3614 (gnus-run-hooks 'gnus-mark-article-hook)
3615 (gnus-set-mode-line 'summary)
3616 (when (gnus-visual-p 'article-highlight 'highlight)
3617 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3618 ;; Set the global newsgroup variables here.
3619 (gnus-set-global-variables)
3620 (setq gnus-have-all-headers
3621 (or all-headers gnus-show-all-headers))))
3623 (gnus-configure-windows 'article))
3624 (when (or (numberp article)
3626 (gnus-article-prepare-display)
3628 (goto-char (point-min))
3629 (setq gnus-page-broken
3630 (when gnus-break-pages
3631 (gnus-narrow-to-page)
3633 (let ((gnus-article-mime-handle-alist-1
3634 gnus-article-mime-handle-alist))
3635 (gnus-set-mode-line 'article))
3639 (set-window-point (get-buffer-window (current-buffer)) (point))
3640 (gnus-configure-windows 'article)
3644 (defun gnus-article-prepare-display ()
3645 "Make the current buffer look like a nice article."
3646 ;; Hooks for getting information from the article.
3647 ;; This hook must be called before being narrowed.
3648 (let ((gnus-article-buffer (current-buffer))
3650 (unless (eq major-mode 'gnus-article-mode)
3651 (gnus-article-mode))
3652 (setq buffer-read-only nil
3653 gnus-article-wash-types nil
3654 gnus-article-image-alist nil)
3655 (gnus-run-hooks 'gnus-tmp-internal-hook)
3656 (when gnus-display-mime-function
3657 (funcall gnus-display-mime-function))
3658 (gnus-run-hooks 'gnus-article-prepare-hook)))
3661 ;;; Gnus MIME viewing functions
3664 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3665 "Format of the MIME buttons.
3667 Valid specifiers include:
3669 %T MIME type, along with additional info
3670 %n The `name' parameter
3671 %d The description, if any
3672 %l The length of the encoded part
3673 %p The part identifier number
3674 %e Dots if the part isn't displayed
3676 General format specifiers can also be used. See Info node
3677 `(gnus)Formatting Variables'.")
3679 (defvar gnus-mime-button-line-format-alist
3680 '((?t gnus-tmp-type ?s)
3681 (?T gnus-tmp-type-long ?s)
3682 (?n gnus-tmp-name ?s)
3683 (?d gnus-tmp-description ?s)
3685 (?l gnus-tmp-length ?d)
3686 (?e gnus-tmp-dots ?s)))
3688 (defvar gnus-mime-button-commands
3689 '((gnus-article-press-button "\r" "Toggle Display")
3690 (gnus-mime-view-part "v" "View Interactively...")
3691 (gnus-mime-view-part-as-type "t" "View As Type...")
3692 (gnus-mime-view-part-as-charset "C" "View As charset...")
3693 (gnus-mime-save-part "o" "Save...")
3694 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3695 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3696 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3697 (gnus-mime-view-part-internally "E" "View Internally")
3698 (gnus-mime-view-part-externally "e" "View Externally")
3699 (gnus-mime-print-part "p" "Print")
3700 (gnus-mime-pipe-part "|" "Pipe To Command...")
3701 (gnus-mime-action-on-part "." "Take action on the part")))
3703 (defun gnus-article-mime-part-status ()
3704 (if gnus-article-mime-handle-alist-1
3705 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3707 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3710 (defvar gnus-mime-button-map
3711 (let ((map (make-sparse-keymap)))
3712 (unless (>= (string-to-number emacs-version) 21)
3713 ;; XEmacs doesn't care.
3714 (set-keymap-parent map gnus-article-mode-map))
3715 (define-key map gnus-mouse-2 'gnus-article-push-button)
3716 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3717 (dolist (c gnus-mime-button-commands)
3718 (define-key map (cadr c) (car c)))
3721 (defun gnus-mime-button-menu (event)
3722 "Construct a context-sensitive menu of MIME commands."
3724 (save-window-excursion
3725 (let ((pos (event-start event)))
3726 (select-window (posn-window pos))
3727 (goto-char (posn-point pos))
3728 (gnus-article-check-buffer)
3729 (let ((response (x-popup-menu
3731 ("" ,@(mapcar (lambda (c)
3732 (cons (caddr c) (car c)))
3733 gnus-mime-button-commands))))))
3735 (call-interactively response))))))
3737 (defun gnus-mime-view-all-parts (&optional handles)
3738 "View all the MIME parts."
3740 (save-current-buffer
3741 (set-buffer gnus-article-buffer)
3742 (let ((handles (or handles gnus-article-mime-handles))
3743 (mail-parse-charset gnus-newsgroup-charset)
3744 (mail-parse-ignored-charsets
3745 (with-current-buffer gnus-summary-buffer
3746 gnus-newsgroup-ignored-charsets)))
3748 (mm-remove-parts handles)
3749 (goto-char (point-min))
3750 (or (search-forward "\n\n") (goto-char (point-max)))
3751 (let (buffer-read-only)
3752 (delete-region (point) (point-max))
3753 (mm-display-parts handles))))))
3755 (defun gnus-mime-save-part-and-strip ()
3756 "Save the MIME part under point then replace it with an external body."
3758 (gnus-article-check-buffer)
3759 (let* ((data (get-text-property (point) 'gnus-data))
3761 (handles gnus-article-mime-handles))
3762 (if (mm-multiple-handles gnus-article-mime-handles)
3763 (error "This function is not implemented"))
3764 (setq file (and data (mm-save-part data)))
3766 (with-current-buffer (mm-handle-buffer data)
3768 (insert "Content-Type: " (mm-handle-media-type data))
3769 (mml-insert-parameter-string (cdr (mm-handle-type data))
3772 (insert "Content-ID: " (message-make-message-id) "\n")
3773 (insert "Content-Transfer-Encoding: binary\n")
3776 (cdr (mm-make-handle nil
3777 `("message/external-body"
3778 (access-type . "LOCAL-FILE")
3780 (set-buffer gnus-summary-buffer)
3781 (gnus-article-edit-article
3784 (let ((mail-parse-charset (or gnus-article-charset
3785 ',gnus-newsgroup-charset))
3786 (mail-parse-ignored-charsets
3787 (or gnus-article-ignored-charsets
3788 ',gnus-newsgroup-ignored-charsets))
3789 (mbl mml-buffer-list))
3790 (setq mml-buffer-list nil)
3791 (insert-buffer gnus-original-article-buffer)
3792 (mime-to-mml ',handles)
3793 (setq gnus-article-mime-handles nil)
3794 (let ((mbl1 mml-buffer-list))
3795 (setq mml-buffer-list mbl)
3796 (set (make-local-variable 'mml-buffer-list) mbl1))
3797 ;; LOCAL argument of add-hook differs between GNU Emacs
3798 ;; and XEmacs. make-local-hook makes sure they are local.
3799 (make-local-hook 'kill-buffer-hook)
3800 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3801 `(lambda (no-highlight)
3802 (let ((mail-parse-charset (or gnus-article-charset
3803 ',gnus-newsgroup-charset))
3804 (message-options message-options)
3805 (message-options-set-recipient)
3806 (mail-parse-ignored-charsets
3807 (or gnus-article-ignored-charsets
3808 ',gnus-newsgroup-ignored-charsets)))
3810 (mml-destroy-buffers)
3811 (remove-hook 'kill-buffer-hook
3812 'mml-destroy-buffers t)
3813 (kill-local-variable 'mml-buffer-list))
3814 (gnus-summary-edit-article-done
3815 ,(or (mail-header-references gnus-current-headers) "")
3816 ,(gnus-group-read-only-p)
3817 ,gnus-summary-buffer no-highlight))))))
3819 (defun gnus-mime-save-part ()
3820 "Save the MIME part under point."
3822 (gnus-article-check-buffer)
3823 (let ((data (get-text-property (point) 'gnus-data)))
3825 (mm-save-part data))))
3827 (defun gnus-mime-pipe-part ()
3828 "Pipe the MIME part under point to a process."
3830 (gnus-article-check-buffer)
3831 (let ((data (get-text-property (point) 'gnus-data)))
3833 (mm-pipe-part data))))
3835 (defun gnus-mime-view-part ()
3836 "Interactively choose a viewing method for the MIME part under point."
3838 (gnus-article-check-buffer)
3839 (let ((data (get-text-property (point) 'gnus-data)))
3841 (setq gnus-article-mime-handles
3843 gnus-article-mime-handles (setq data (copy-sequence data))))
3844 (mm-interactively-view-part data))))
3846 (defun gnus-mime-view-part-as-type-internal ()
3847 (gnus-article-check-buffer)
3848 (let* ((name (mail-content-type-get
3849 (mm-handle-type (get-text-property (point) 'gnus-data))
3851 (def-type (and name (mm-default-file-encoding name))))
3852 (and def-type (cons def-type 0))))
3854 (defun gnus-mime-view-part-as-type (&optional mime-type)
3855 "Choose a MIME media type, and view the part as such."
3858 (setq mime-type (completing-read
3859 "View as MIME type: "
3860 (mapcar #'list (mailcap-mime-types))
3862 (gnus-mime-view-part-as-type-internal))))
3863 (gnus-article-check-buffer)
3864 (let ((handle (get-text-property (point) 'gnus-data)))
3867 (mm-make-handle (mm-handle-buffer handle)
3868 (cons mime-type (cdr (mm-handle-type handle)))
3869 (mm-handle-encoding handle)
3870 (mm-handle-undisplayer handle)
3871 (mm-handle-disposition handle)
3872 (mm-handle-description handle)
3874 (mm-handle-id handle)))
3875 (setq gnus-article-mime-handles
3876 (mm-merge-handles gnus-article-mime-handles handle))
3877 (gnus-mm-display-part handle))))
3879 (defun gnus-mime-copy-part (&optional handle)
3880 "Put the MIME part under point into a new buffer."
3882 (gnus-article-check-buffer)
3883 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3884 (contents (and handle (mm-get-part handle)))
3886 (file-name-nondirectory
3888 (mail-content-type-get (mm-handle-type handle) 'name)
3889 (mail-content-type-get (mm-handle-disposition handle)
3892 (buffer (and base (generate-new-buffer base))))
3894 (switch-to-buffer buffer)
3896 ;; We do it this way to make `normal-mode' set the appropriate mode.
3899 (setq buffer-file-name (expand-file-name base))
3901 (setq buffer-file-name nil))
3902 (goto-char (point-min)))))
3904 (defun gnus-mime-print-part (&optional handle filename)
3905 "Print the MIME part under point."
3906 (interactive (list nil (ps-print-preprint current-prefix-arg)))
3907 (gnus-article-check-buffer)
3908 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3909 (contents (and handle (mm-get-part handle)))
3910 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
3911 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
3916 (with-temp-file file
3918 (call-process shell-file-name nil
3919 (generate-new-buffer " *mm*")
3921 shell-command-switch
3923 printer file (mm-handle-type handle))))
3927 (gnus-print-buffer))
3928 (ps-despool filename)))))
3930 (defun gnus-mime-inline-part (&optional handle arg)
3931 "Insert the MIME part under point into the current buffer."
3932 (interactive (list nil current-prefix-arg))
3933 (gnus-article-check-buffer)
3934 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3939 (if (and (not arg) (mm-handle-undisplayer handle))
3940 (mm-remove-part handle)
3941 (setq contents (mm-get-part handle))
3944 (setq charset (or (mail-content-type-get
3945 (mm-handle-type handle) 'charset)
3946 gnus-newsgroup-charset)))
3948 (if (mm-handle-undisplayer handle)
3949 (mm-remove-part handle))
3952 gnus-summary-show-article-charset-alist))
3953 (mm-read-coding-system "Charset: ")))))
3955 (mm-insert-inline handle
3957 (setq charset (mm-charset-to-coding-system
3959 (not (eq charset 'ascii)))
3960 (mm-decode-coding-string contents charset)
3964 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3965 "Insert the MIME part under point into the current buffer using the
3967 (interactive (list nil current-prefix-arg))
3968 (gnus-article-check-buffer)
3969 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3974 (if (mm-handle-undisplayer handle)
3975 (mm-remove-part handle))
3976 (let ((gnus-newsgroup-charset
3978 gnus-summary-show-article-charset-alist))
3979 (mm-read-coding-system "Charset: ")))
3980 (gnus-newsgroup-ignored-charsets 'gnus-all))
3981 (gnus-article-press-button)))))
3983 (defun gnus-mime-view-part-externally (&optional handle)
3984 "View the MIME part under point with an external viewer."
3986 (gnus-article-check-buffer)
3987 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3988 (mm-user-display-methods nil)
3989 (mm-inlined-types nil)
3990 (mail-parse-charset gnus-newsgroup-charset)
3991 (mail-parse-ignored-charsets
3992 (save-excursion (set-buffer gnus-summary-buffer)
3993 gnus-newsgroup-ignored-charsets)))
3995 (if (mm-handle-undisplayer handle)
3996 (mm-remove-part handle)
3997 (mm-display-part handle)))))
3999 (defun gnus-mime-view-part-internally (&optional handle)
4000 "View the MIME part under point with an internal viewer.
4001 If no internal viewer is available, use an external viewer."
4003 (gnus-article-check-buffer)
4004 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4005 (mm-inlined-types '(".*"))
4006 (mm-inline-large-images t)
4007 (mail-parse-charset gnus-newsgroup-charset)
4008 (mail-parse-ignored-charsets
4009 (save-excursion (set-buffer gnus-summary-buffer)
4010 gnus-newsgroup-ignored-charsets)))
4012 (if (mm-handle-undisplayer handle)
4013 (mm-remove-part handle)
4014 (mm-display-part handle)))))
4016 (defun gnus-mime-action-on-part (&optional action)
4017 "Do something with the MIME attachment at \(point\)."
4019 (list (completing-read "Action: " gnus-mime-action-alist)))
4020 (gnus-article-check-buffer)
4021 (let ((action-pair (assoc action gnus-mime-action-alist)))
4023 (funcall (cdr action-pair)))))
4025 (defun gnus-article-part-wrapper (n function)
4026 (save-current-buffer
4027 (set-buffer gnus-article-buffer)
4028 (when (> n (length gnus-article-mime-handle-alist))
4029 (error "No such part"))
4030 (gnus-article-goto-part n)
4031 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4032 (funcall function handle))))
4034 (defun gnus-article-pipe-part (n)
4035 "Pipe MIME part N, which is the numerical prefix."
4037 (gnus-article-part-wrapper n 'mm-pipe-part))
4039 (defun gnus-article-save-part (n)
4040 "Save MIME part N, which is the numerical prefix."
4042 (gnus-article-part-wrapper n 'mm-save-part))
4044 (defun gnus-article-interactively-view-part (n)
4045 "View MIME part N interactively, which is the numerical prefix."
4047 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4049 (defun gnus-article-copy-part (n)
4050 "Copy MIME part N, which is the numerical prefix."
4052 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4054 (defun gnus-article-view-part-as-charset (n)
4055 "Copy MIME part N, which is the numerical prefix."
4057 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4059 (defun gnus-article-view-part-externally (n)
4060 "View MIME part N externally, which is the numerical prefix."
4062 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4064 (defun gnus-article-inline-part (n)
4065 "Inline MIME part N, which is the numerical prefix."
4067 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4069 (defun gnus-article-mime-match-handle-first (condition)
4071 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4072 (while (setq ihandle (pop alist))
4074 ((functionp condition)
4075 (funcall condition (cdr ihandle)))
4076 ((eq condition 'undisplayed)
4077 (not (or (mm-handle-undisplayer (cdr ihandle))
4078 (equal (mm-handle-media-type (cdr ihandle))
4079 "multipart/alternative"))))
4080 ((eq condition 'undisplayed-alternative)
4081 (not (mm-handle-undisplayer (cdr ihandle))))
4083 (gnus-article-goto-part (car ihandle))
4084 (or (not n) (< (car ihandle) n)))
4085 (setq n (car ihandle))))
4089 (defun gnus-article-view-part (&optional n)
4090 "View MIME part N, which is the numerical prefix."
4092 (save-current-buffer
4093 (set-buffer gnus-article-buffer)
4094 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4095 gnus-article-mime-match-handle-function)))
4096 (when (> n (length gnus-article-mime-handle-alist))
4097 (error "No such part"))
4098 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4099 (when (gnus-article-goto-part n)
4100 (if (equal (car handle) "multipart/alternative")
4101 (gnus-article-press-button)
4102 (when (eq (gnus-mm-display-part handle) 'internal)
4103 (gnus-set-window-start)))))))
4105 (defsubst gnus-article-mime-total-parts ()
4106 (if (bufferp (car gnus-article-mime-handles))
4108 (1- (length gnus-article-mime-handles))))
4110 (defun gnus-mm-display-part (handle)
4111 "Display HANDLE and fix MIME button."
4112 (let ((id (get-text-property (point) 'gnus-part))
4117 (let ((window (selected-window))
4118 (mail-parse-charset gnus-newsgroup-charset)
4119 (mail-parse-ignored-charsets
4120 (if (gnus-buffer-live-p gnus-summary-buffer)
4122 (set-buffer gnus-summary-buffer)
4123 gnus-newsgroup-ignored-charsets)
4127 (let ((win (gnus-get-buffer-window (current-buffer) t))
4130 (select-window win))
4133 (if (mm-handle-displayed-p handle)
4134 ;; This will remove the part.
4135 (mm-display-part handle)
4137 (narrow-to-region (point)
4138 (if (eobp) (point) (1+ (point))))
4139 (mm-display-part handle)
4140 ;; We narrow to the part itself and
4141 ;; then call the treatment functions.
4142 (goto-char (point-min))
4144 (narrow-to-region (point) (point-max))
4147 (gnus-article-mime-total-parts)
4148 (mm-handle-media-type handle)))))
4149 (if (window-live-p window)
4150 (select-window window)))))
4152 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4153 (gnus-insert-mime-button
4154 handle id (list (mm-handle-displayed-p handle)))
4155 (goto-char point))))
4157 (defun gnus-article-goto-part (n)
4158 "Go to MIME part N."
4159 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4161 (goto-char point))))
4163 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4164 (let ((gnus-tmp-name
4165 (or (mail-content-type-get (mm-handle-type handle) 'name)
4166 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4167 (mail-content-type-get (mm-handle-type handle) 'url)
4169 (gnus-tmp-type (mm-handle-media-type handle))
4170 (gnus-tmp-description
4171 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4174 (if (if displayed (car displayed)
4175 (mm-handle-displayed-p handle))
4177 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4179 gnus-tmp-type-long b e)
4180 (when (string-match ".*/" gnus-tmp-name)
4181 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4182 (setq gnus-tmp-type-long (concat gnus-tmp-type
4183 (and (not (equal gnus-tmp-name ""))
4184 (concat "; " gnus-tmp-name))))
4185 (unless (equal gnus-tmp-description "")
4186 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4191 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4192 `(,@(gnus-local-map-property gnus-mime-button-map)
4193 gnus-callback gnus-mm-display-part
4194 gnus-part ,gnus-tmp-id
4195 article-type annotation
4198 (widget-convert-button
4201 :action 'gnus-widget-press-button
4202 :button-keymap gnus-mime-button-map
4204 (lambda (widget/window &optional overlay pos)
4205 ;; Needed to properly clear the message due to a bug in
4206 ;; wid-edit (XEmacs only).
4207 (if (boundp 'help-echo-owns-message)
4208 (setq help-echo-owns-message t))
4210 "%S: %s the MIME part; %S: more options"
4211 (aref gnus-mouse-2 0)
4212 ;; XEmacs will get a single widget arg; Emacs 21 will get
4213 ;; window, overlay, position.
4214 (if (mm-handle-displayed-p
4216 (with-current-buffer (gnus-overlay-buffer overlay)
4217 (widget-get (widget-at (gnus-overlay-start overlay))
4219 (widget-get widget/window :mime-handle)))
4221 (aref gnus-down-mouse-3 0))))))
4223 (defun gnus-widget-press-button (elems el)
4224 (goto-char (widget-get elems :from))
4225 (gnus-article-press-button))
4227 (defvar gnus-displaying-mime nil)
4229 (defun gnus-display-mime (&optional ihandles)
4230 "Display the MIME parts."
4232 (save-selected-window
4233 (let ((window (get-buffer-window gnus-article-buffer))
4236 (select-window window)
4237 ;; We have to do this since selecting the window
4238 ;; may change the point. So we set the window point.
4239 (set-window-point window point)))
4240 (let* ((handles (or ihandles (mm-dissect-buffer
4241 nil gnus-article-loose-mime)
4243 buffer-read-only handle name type b e display)
4244 (when (and (not ihandles)
4245 (not gnus-displaying-mime))
4246 ;; Top-level call; we clean up.
4247 (when gnus-article-mime-handles
4248 (mm-destroy-parts gnus-article-mime-handles)
4249 (setq gnus-article-mime-handle-alist nil));; A trick.
4250 (setq gnus-article-mime-handles handles)
4251 ;; We allow users to glean info from the handles.
4252 (when gnus-article-mime-part-function
4253 (gnus-mime-part-function handles)))
4255 (or (not (stringp (car handles)))
4258 (when (and (not ihandles)
4259 (not gnus-displaying-mime))
4260 ;; Clean up for mime parts.
4262 (delete-region (point) (point-max)))
4263 (let ((gnus-displaying-mime t))
4264 (gnus-mime-display-part handles)))
4267 (narrow-to-region (point) (point-max))
4268 (gnus-treat-article nil 1 1)
4271 ;; Highlight the headers.
4275 (narrow-to-region (point-min) (point))
4276 (gnus-treat-article 'head))))))))
4278 (defvar gnus-mime-display-multipart-as-mixed nil)
4279 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4280 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4282 (defun gnus-mime-display-part (handle)
4285 ((not (stringp (car handle)))
4286 (gnus-mime-display-single handle))
4287 ;; User-defined multipart
4288 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4289 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4291 ;; multipart/alternative
4292 ((and (equal (car handle) "multipart/alternative")
4293 (not (or gnus-mime-display-multipart-as-mixed
4294 gnus-mime-display-multipart-alternative-as-mixed)))
4295 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4296 (push (cons id handle) gnus-article-mime-handle-alist)
4297 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4298 ;; multipart/related
4299 ((and (equal (car handle) "multipart/related")
4300 (not (or gnus-mime-display-multipart-as-mixed
4301 gnus-mime-display-multipart-related-as-mixed)))
4302 ;;;!!!We should find the start part, but we just default
4303 ;;;!!!to the first part.
4304 ;;(gnus-mime-display-part (cadr handle))
4305 ;;;!!! Most multipart/related is an HTML message plus images.
4306 ;;;!!! Unfortunately we are unable to let W3 display those
4307 ;;;!!! included images, so we just display it as a mixed multipart.
4308 ;;(gnus-mime-display-mixed (cdr handle))
4309 ;;;!!! No, w3 can display everything just fine.
4310 (gnus-mime-display-part (cadr handle)))
4311 ((equal (car handle) "multipart/signed")
4312 (gnus-add-wash-type 'signed)
4313 (gnus-mime-display-security handle))
4314 ((equal (car handle) "multipart/encrypted")
4315 (gnus-add-wash-type 'encrypted)
4316 (gnus-mime-display-security handle))
4317 ;; Other multiparts are handled like multipart/mixed.
4319 (gnus-mime-display-mixed (cdr handle)))))
4321 (defun gnus-mime-part-function (handles)
4322 (if (stringp (car handles))
4323 (mapcar 'gnus-mime-part-function (cdr handles))
4324 (funcall gnus-article-mime-part-function handles)))
4326 (defun gnus-mime-display-mixed (handles)
4327 (mapcar 'gnus-mime-display-part handles))
4329 (defun gnus-mime-display-single (handle)
4330 (let ((type (mm-handle-media-type handle))
4331 (ignored gnus-ignored-mime-types)
4338 (when (string-match (pop ignored) type)
4339 (throw 'ignored nil)))
4340 (if (and (setq not-attachment
4341 (and (not (mm-inline-override-p handle))
4342 (or (not (mm-handle-disposition handle))
4343 (equal (car (mm-handle-disposition handle))
4345 (mm-attachment-override-p handle))))
4346 (mm-automatic-display-p handle)
4348 (mm-inlinable-p handle)
4349 (mm-inlined-p handle))
4350 (mm-automatic-external-display-p type)))
4352 (when (equal (mm-handle-media-supertype handle) "text")
4354 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4356 (push (cons id handle) gnus-article-mime-handle-alist)
4357 (when (or (not display)
4358 (not (gnus-unbuttonized-mime-type-p type)))
4359 ;(gnus-article-insert-newline)
4360 (gnus-insert-mime-button
4361 handle id (list (or display (and not-attachment text))))
4362 (gnus-article-insert-newline)
4363 ;(gnus-article-insert-newline)
4364 ;; Remember modify the number of forward lines.
4372 (let ((mail-parse-charset gnus-newsgroup-charset)
4373 (mail-parse-ignored-charsets
4374 (save-excursion (condition-case ()
4375 (set-buffer gnus-summary-buffer)
4377 gnus-newsgroup-ignored-charsets)))
4378 (mm-display-part handle t))
4379 (goto-char (point-max)))
4380 ((and text not-attachment)
4384 (gnus-article-insert-newline)
4385 (mm-insert-inline handle (mm-get-part handle))
4386 (goto-char (point-max))))
4390 (narrow-to-region beg (point))
4393 (gnus-article-mime-total-parts)
4394 (mm-handle-media-type handle)))))))))
4396 (defun gnus-unbuttonized-mime-type-p (type)
4397 "Say whether TYPE is to be unbuttonized."
4398 (unless gnus-inhibit-mime-unbuttonizing
4400 (let ((types gnus-unbuttonized-mime-types))
4402 (when (string-match (pop types) type)
4403 (throw 'found t)))))
4405 (let ((types gnus-buttonized-mime-types))
4407 (when (string-match (pop types) type)
4408 (throw 'found t)))))))))
4410 (defun gnus-article-insert-newline ()
4411 "Insert a newline, but mark it as undeletable."
4412 (gnus-put-text-property
4413 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4415 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4416 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4419 handle buffer-read-only from props begend not-pref)
4420 (save-window-excursion
4423 (narrow-to-region (car ibegend)
4426 (goto-char (car ibegend))
4429 (delete-region (point-min) (point-max))
4430 (mm-remove-parts handles))
4431 (setq begend (list (point-marker)))
4433 (unless (setq not-pref (cadr (member preferred ihandles)))
4434 (setq not-pref (car ihandles)))
4437 (not (gnus-unbuttonized-mime-type-p
4438 "multipart/alternative")))
4439 (gnus-add-text-properties
4442 (insert (format "%d. " id))
4446 (unless ,(not ibegend)
4447 (setq gnus-article-mime-handle-alist
4448 ',gnus-article-mime-handle-alist))
4449 (gnus-mime-display-alternative
4450 ',ihandles ',not-pref ',begend ,id))
4451 ,@(gnus-local-map-property gnus-mime-button-map)
4452 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4453 face ,gnus-article-button-face
4456 (widget-convert-button 'link from (point)
4457 :action 'gnus-widget-press-button
4458 :button-keymap gnus-widget-button-keymap)
4460 (while (setq handle (pop handles))
4461 (gnus-add-text-properties
4464 (insert (format "(%c) %-18s"
4465 (if (equal handle preferred) ?* ? )
4466 (mm-handle-media-type handle)))
4470 (unless ,(not ibegend)
4471 (setq gnus-article-mime-handle-alist
4472 ',gnus-article-mime-handle-alist))
4473 (gnus-mime-display-alternative
4474 ',ihandles ',handle ',begend ,id))
4475 ,@(gnus-local-map-property gnus-mime-button-map)
4476 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4477 face ,gnus-article-button-face
4480 (widget-convert-button 'link from (point)
4481 :action 'gnus-widget-press-button
4482 :button-keymap gnus-widget-button-keymap)
4486 (if (stringp (car preferred))
4487 (gnus-display-mime preferred)
4488 (let ((mail-parse-charset gnus-newsgroup-charset)
4489 (mail-parse-ignored-charsets
4490 (save-excursion (set-buffer gnus-summary-buffer)
4491 gnus-newsgroup-ignored-charsets)))
4492 (mm-display-part preferred)
4496 (narrow-to-region (car begend) (point-max))
4498 nil (length gnus-article-mime-handle-alist)
4499 (gnus-article-mime-total-parts)
4500 (mm-handle-media-type handle))))))
4501 (goto-char (point-max))
4502 (setcdr begend (point-marker)))))
4504 (goto-char point))))
4506 (defconst gnus-article-wash-status-strings
4507 (let ((alist '((cite "c" "Possible hidden citation text"
4508 " " "All citation text visible")
4509 (headers "h" "Hidden headers"
4510 " " "All headers visible.")
4511 (pgp "p" "Encrypted or signed message status hidden"
4512 " " "No hidden encryption nor digital signature status")
4513 (signature "s" "Signature has been hidden"
4514 " " "Signature is visible")
4515 (overstrike "o" "Overstrike (^H) characters applied"
4516 " " "No overstrike characters applied")
4517 (emphasis "e" "/*_Emphasis_*/ characters applied"
4518 " " "No /*_emphasis_*/ characters applied")))
4520 (dolist (entry alist result)
4521 (let ((key (nth 0 entry))
4522 (on (copy-sequence (nth 1 entry)))
4523 (on-help (nth 2 entry))
4524 (off (copy-sequence (nth 3 entry)))
4525 (off-help (nth 4 entry)))
4526 (put-text-property 0 1 'help-echo on-help on)
4527 (put-text-property 0 1 'help-echo off-help off)
4528 (push (list key on off) result))))
4529 "Alist of strings describing wash status in the mode line.
4530 Each entry has the form (KEY ON OF), where the KEY is a symbol
4531 representing the particular washing function, ON is the string to use
4532 in the article mode line when the washing function is active, and OFF
4533 is the string to use when it is inactive.")
4535 (defun gnus-article-wash-status-entry (key value)
4536 (let ((entry (assoc key gnus-article-wash-status-strings)))
4537 (if value (nth 1 entry) (nth 2 entry))))
4539 (defun gnus-article-wash-status ()
4540 "Return a string which display status of article washing."
4542 (set-buffer gnus-article-buffer)
4543 (let ((cite (memq 'cite gnus-article-wash-types))
4544 (headers (memq 'headers gnus-article-wash-types))
4545 (boring (memq 'boring-headers gnus-article-wash-types))
4546 (pgp (memq 'pgp gnus-article-wash-types))
4547 (pem (memq 'pem gnus-article-wash-types))
4548 (signed (memq 'signed gnus-article-wash-types))
4549 (encrypted (memq 'encrypted gnus-article-wash-types))
4550 (signature (memq 'signature gnus-article-wash-types))
4551 (overstrike (memq 'overstrike gnus-article-wash-types))
4552 (emphasis (memq 'emphasis gnus-article-wash-types)))
4554 (gnus-article-wash-status-entry 'cite cite)
4555 (gnus-article-wash-status-entry 'headers (or headers boring))
4556 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4557 (gnus-article-wash-status-entry 'signature signature)
4558 (gnus-article-wash-status-entry 'overstrike overstrike)
4559 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4561 (defun gnus-add-wash-type (type)
4562 "Add a washing of TYPE to the current status."
4563 (add-to-list 'gnus-article-wash-types type))
4565 (defun gnus-delete-wash-type (type)
4566 "Add a washing of TYPE to the current status."
4567 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4569 (defun gnus-add-image (category image)
4570 "Add IMAGE of CATEGORY to the list of displayed images."
4571 (let ((entry (assq category gnus-article-image-alist)))
4573 (setq entry (list category))
4574 (push entry gnus-article-image-alist))
4575 (nconc entry (list image))))
4577 (defun gnus-delete-images (category)
4578 "Delete all images in CATEGORY."
4579 (let ((entry (assq category gnus-article-image-alist)))
4580 (dolist (image (cdr entry))
4581 (gnus-remove-image image))
4582 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4583 (gnus-delete-wash-type category)))
4585 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4587 (defun gnus-article-maybe-hide-headers ()
4588 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4589 Provided for backwards compatibility."
4590 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4591 (not (save-excursion (set-buffer gnus-summary-buffer)
4592 gnus-have-all-headers)))
4593 (not gnus-inhibit-hiding))
4594 (gnus-article-hide-headers)))
4598 (defun gnus-output-to-file (file-name)
4599 "Append the current article to a file named FILE-NAME."
4600 (let ((artbuf (current-buffer)))
4602 (insert-buffer-substring artbuf)
4603 ;; Append newline at end of the buffer as separator, and then
4605 (goto-char (point-max))
4607 (let ((file-name-coding-system nnmail-pathname-coding-system))
4608 (mm-append-to-file (point-min) (point-max) file-name))
4611 (defun gnus-narrow-to-page (&optional arg)
4612 "Narrow the article buffer to a page.
4613 If given a numerical ARG, move forward ARG pages."
4615 (setq arg (if arg (prefix-numeric-value arg) 0))
4617 (set-buffer gnus-article-buffer)
4618 (goto-char (point-min))
4620 ;; Remove any old next/prev buttons.
4621 (when (gnus-visual-p 'page-marker)
4622 (let ((buffer-read-only nil))
4623 (gnus-remove-text-with-property 'gnus-prev)
4624 (gnus-remove-text-with-property 'gnus-next)))
4627 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4629 (re-search-forward page-delimiter nil 'move arg)))
4630 (goto-char (match-end 0)))
4633 (if (re-search-forward page-delimiter nil 'move)
4636 (when (and (gnus-visual-p 'page-marker)
4637 (not (= (point-min) 1)))
4639 (goto-char (point-min))
4640 (gnus-insert-prev-page-button)))
4641 (when (and (gnus-visual-p 'page-marker)
4642 (< (+ (point-max) 2) (buffer-size)))
4644 (goto-char (point-max))
4645 (gnus-insert-next-page-button)))))
4647 ;; Article mode commands
4649 (defun gnus-article-goto-next-page ()
4650 "Show the next page of the article."
4652 (when (gnus-article-next-page)
4653 (goto-char (point-min))
4654 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4656 (defun gnus-article-goto-prev-page ()
4657 "Show the next page of the article."
4659 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4660 (gnus-article-prev-page nil)))
4662 (defun gnus-article-next-page (&optional lines)
4663 "Show the next page of the current article.
4664 If end of article, return non-nil. Otherwise return nil.
4665 Argument LINES specifies lines to be scrolled up."
4667 (move-to-window-line -1)
4670 (and (pos-visible-in-window-p) ;Not continuation line.
4672 ;; Nothing in this page.
4673 (if (or (not gnus-page-broken)
4676 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4678 (gnus-narrow-to-page 1) ;Go to next page.
4680 ;; More in this page.
4681 (let ((scroll-in-place nil))
4685 ;; Long lines may cause an end-of-buffer error.
4686 (goto-char (point-max)))))
4687 (move-to-window-line 0)
4690 (defun gnus-article-prev-page (&optional lines)
4691 "Show previous page of current article.
4692 Argument LINES specifies lines to be scrolled down."
4694 (move-to-window-line 0)
4695 (if (and gnus-page-broken
4697 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4699 (gnus-narrow-to-page -1) ;Go to previous page.
4700 (goto-char (point-max))
4702 (let ((scroll-in-place nil))
4706 (beginning-of-buffer
4707 (goto-char (point-min))))
4708 (move-to-window-line 0)))))
4710 (defun gnus-article-refer-article ()
4711 "Read article specified by message-id around point."
4713 (let ((point (point)))
4714 (search-forward ">" nil t) ;Move point to end of "<....>".
4715 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4716 (let ((message-id (match-string 1)))
4718 (set-buffer gnus-summary-buffer)
4719 (gnus-summary-refer-article message-id))
4721 (error "No references around point"))))
4723 (defun gnus-article-show-summary ()
4724 "Reconfigure windows to show summary buffer."
4726 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4727 (error "There is no summary buffer for this article buffer")
4728 (gnus-article-set-globals)
4729 (gnus-configure-windows 'article)
4730 (gnus-summary-goto-subject gnus-current-article)
4731 (gnus-summary-position-point)))
4733 (defun gnus-article-describe-briefly ()
4734 "Describe article mode commands briefly."
4736 (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")))
4738 (defun gnus-article-summary-command ()
4739 "Execute the last keystroke in the summary buffer."
4741 (let ((obuf (current-buffer))
4742 (owin (current-window-configuration))
4744 (switch-to-buffer gnus-article-current-summary 'norecord)
4745 (setq func (lookup-key (current-local-map) (this-command-keys)))
4746 (call-interactively func)
4748 (set-window-configuration owin)
4749 (set-window-point (get-buffer-window (current-buffer)) (point))))
4751 (defun gnus-article-summary-command-nosave ()
4752 "Execute the last keystroke in the summary buffer."
4755 (pop-to-buffer gnus-article-current-summary 'norecord)
4756 (setq func (lookup-key (current-local-map) (this-command-keys)))
4757 (call-interactively func)))
4759 (defun gnus-article-check-buffer ()
4760 "Beep if not in an article buffer."
4761 (unless (equal major-mode 'gnus-article-mode)
4762 (error "Command invoked outside of a Gnus article buffer")))
4764 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4765 "Read a summary buffer key sequence and execute it from the article buffer."
4767 (gnus-article-check-buffer)
4769 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4770 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4771 "=" "^" "\M-^" "|"))
4777 '("n" "Gn" "p" "Gp"))
4780 (set-buffer gnus-article-current-summary)
4781 (let (gnus-pick-mode)
4782 (push (or key last-command-event) unread-command-events)
4783 (setq keys (if (featurep 'xemacs)
4784 (events-to-keys (read-key-sequence nil))
4785 (read-key-sequence nil)))))
4789 (if (or (member keys nosaves)
4790 (member keys nosave-but-article)
4791 (member keys nosave-in-article))
4793 (save-window-excursion
4794 (pop-to-buffer gnus-article-current-summary 'norecord)
4795 ;; We disable the pick minor mode commands.
4796 (let (gnus-pick-mode)
4797 (setq func (lookup-key (current-local-map) keys))))
4801 (unless (member keys nosave-in-article)
4802 (set-buffer gnus-article-current-summary))
4803 (call-interactively func)
4804 (setq new-sum-point (point)))
4805 (when (member keys nosave-but-article)
4806 (pop-to-buffer gnus-article-buffer 'norecord)))
4807 ;; These commands should restore window configuration.
4808 (let ((obuf (current-buffer))
4809 (owin (current-window-configuration))
4811 (summary gnus-article-current-summary)
4812 func in-buffer selected)
4813 (if not-restore-window
4814 (pop-to-buffer summary 'norecord)
4815 (switch-to-buffer summary 'norecord))
4816 (setq in-buffer (current-buffer))
4817 ;; We disable the pick minor mode commands.
4818 (if (and (setq func (let (gnus-pick-mode)
4819 (lookup-key (current-local-map) keys)))
4822 (call-interactively func)
4823 (setq new-sum-point (point))
4824 (when (eq in-buffer (current-buffer))
4825 (setq selected (gnus-summary-select-article))
4827 (unless not-restore-window
4828 (set-window-configuration owin))
4829 (when (eq selected 'old)
4831 (set-window-start (get-buffer-window (current-buffer))
4833 (set-window-point (get-buffer-window (current-buffer))
4835 (let ((win (get-buffer-window gnus-article-current-summary)))
4837 (set-window-point win new-sum-point)))) )
4838 (switch-to-buffer gnus-article-buffer)
4841 (defun gnus-article-describe-key (key)
4842 "Display documentation of the function invoked by KEY. KEY is a string."
4843 (interactive "kDescribe key: ")
4844 (gnus-article-check-buffer)
4845 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4847 (set-buffer gnus-article-current-summary)
4848 (let (gnus-pick-mode)
4849 (if (featurep 'xemacs)
4851 (push (elt key 0) unread-command-events)
4852 (setq key (events-to-keys
4853 (read-key-sequence "Describe key: "))))
4854 (setq unread-command-events
4856 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4857 (string-to-list key)))
4858 (setq key (read-key-sequence "Describe key: "))))
4860 (describe-key key)))
4862 (defun gnus-article-describe-key-briefly (key &optional insert)
4863 "Display documentation of the function invoked by KEY. KEY is a string."
4864 (interactive "kDescribe key: \nP")
4865 (gnus-article-check-buffer)
4866 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4868 (set-buffer gnus-article-current-summary)
4869 (let (gnus-pick-mode)
4870 (if (featurep 'xemacs)
4872 (push (elt key 0) unread-command-events)
4873 (setq key (events-to-keys
4874 (read-key-sequence "Describe key: "))))
4875 (setq unread-command-events
4877 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4878 (string-to-list key)))
4879 (setq key (read-key-sequence "Describe key: "))))
4880 (describe-key-briefly key insert))
4881 (describe-key-briefly key insert)))
4883 (defun gnus-article-reply-with-original (&optional wide)
4884 "Start composing a reply mail to the current message.
4885 The text in the region will be yanked. If the region isn't active,
4886 the entire article will be yanked."
4888 (let ((article (cdr gnus-article-current)) cont)
4890 (with-current-buffer gnus-summary-buffer
4891 (gnus-summary-reply (list (list article)) wide))
4892 (setq cont (buffer-substring (point) (mark t)))
4893 ;; Deactivate active regions.
4894 (when (and (boundp 'transient-mark-mode)
4895 transient-mark-mode)
4896 (setq mark-active nil))
4897 (with-current-buffer gnus-summary-buffer
4899 (list (list article cont)) wide)))))
4901 (defun gnus-article-followup-with-original ()
4902 "Compose a followup to the current article.
4903 The text in the region will be yanked. If the region isn't active,
4904 the entire article will be yanked."
4906 (let ((article (cdr gnus-article-current)) cont)
4908 (with-current-buffer gnus-summary-buffer
4909 (gnus-summary-followup (list (list article))))
4910 (setq cont (buffer-substring (point) (mark t)))
4911 ;; Deactivate active regions.
4912 (when (and (boundp 'transient-mark-mode)
4913 transient-mark-mode)
4914 (setq mark-active nil))
4915 (with-current-buffer gnus-summary-buffer
4916 (gnus-summary-followup
4917 (list (list article cont)))))))
4919 (defun gnus-article-hide (&optional arg force)
4920 "Hide all the gruft in the current article.
4921 This means that PGP stuff, signatures, cited text and (some)
4922 headers will be hidden.
4923 If given a prefix, show the hidden text instead."
4924 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4925 (gnus-article-hide-headers arg)
4926 (gnus-article-hide-list-identifiers arg)
4927 (gnus-article-hide-pgp arg)
4928 (gnus-article-hide-citation-maybe arg force)
4929 (gnus-article-hide-signature arg))
4931 (defun gnus-article-maybe-highlight ()
4932 "Do some article highlighting if article highlighting is requested."
4933 (when (gnus-visual-p 'article-highlight 'highlight)
4934 (gnus-article-highlight-some)))
4936 (defun gnus-check-group-server ()
4937 ;; Make sure the connection to the server is alive.
4938 (unless (gnus-server-opened
4939 (gnus-find-method-for-group gnus-newsgroup-name))
4940 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4941 (gnus-request-group gnus-newsgroup-name t)))
4944 (autoload 'nneething-get-file-name "nneething"))
4946 (defun gnus-request-article-this-buffer (article group)
4947 "Get an article and insert it into this buffer."
4948 (let (do-update-line sparse-header)
4952 (gnus-kill-all-overlays)
4953 (setq group (or group gnus-newsgroup-name))
4955 ;; Using `gnus-request-article' directly will insert the article into
4956 ;; `nntp-server-buffer' - so we'll save some time by not having to
4957 ;; copy it from the server buffer into the article buffer.
4959 ;; We only request an article by message-id when we do not have the
4960 ;; headers for it, so we'll have to get those.
4961 (when (stringp article)
4962 (gnus-read-header article))
4964 ;; If the article number is negative, that means that this article
4965 ;; doesn't belong in this newsgroup (possibly), so we find its
4966 ;; message-id and request it by id instead of number.
4967 (when (and (numberp article)
4969 (get-buffer gnus-summary-buffer)
4970 (gnus-buffer-exists-p gnus-summary-buffer))
4972 (set-buffer gnus-summary-buffer)
4973 (let ((header (gnus-summary-article-header article)))
4976 ((memq article gnus-newsgroup-sparse)
4977 ;; This is a sparse gap article.
4978 (setq do-update-line article)
4979 (setq article (mail-header-id header))
4980 (setq sparse-header (gnus-read-header article))
4981 (setq gnus-newsgroup-sparse
4982 (delq article gnus-newsgroup-sparse)))
4984 ;; It's a real article.
4985 (setq article (mail-header-id header)))
4987 ;; It is an extracted pseudo-article.
4988 (setq article 'pseudo)
4989 (gnus-request-pseudo-article header))))
4991 (let ((method (gnus-find-method-for-group
4992 gnus-newsgroup-name)))
4993 (when (and (eq (car method) 'nneething)
4995 (let ((dir (nneething-get-file-name
4996 (mail-header-id header))))
4997 (when (and (stringp dir)
4998 (file-directory-p dir))
4999 (setq article 'nneething)
5000 (gnus-group-enter-directory dir))))))))
5003 ;; Refuse to select canceled articles.
5004 ((and (numberp article)
5006 (get-buffer gnus-summary-buffer)
5007 (gnus-buffer-exists-p gnus-summary-buffer)
5008 (eq (cdr (save-excursion
5009 (set-buffer gnus-summary-buffer)
5010 (assq article gnus-newsgroup-reads)))
5011 gnus-canceled-mark))
5013 ;; We first check `gnus-original-article-buffer'.
5014 ((and (get-buffer gnus-original-article-buffer)
5017 (set-buffer gnus-original-article-buffer)
5018 (and (equal (car gnus-original-article) group)
5019 (eq (cdr gnus-original-article) article))))
5020 (insert-buffer-substring gnus-original-article-buffer)
5022 ;; Check the backlog.
5023 ((and gnus-keep-backlog
5024 (gnus-backlog-request-article group article (current-buffer)))
5026 ;; Check asynchronous pre-fetch.
5027 ((gnus-async-request-fetched-article group article (current-buffer))
5028 (gnus-async-prefetch-next group article gnus-summary-buffer)
5029 (when (and (numberp article) gnus-keep-backlog)
5030 (gnus-backlog-enter-article group article (current-buffer)))
5033 ((and gnus-use-cache
5035 (gnus-cache-request-article article group))
5037 ;; Check the agent cache.
5038 ((and gnus-agent gnus-agent-cache gnus-plugged
5040 (gnus-agent-request-article article group))
5042 ;; Get the article and put into the article buffer.
5043 ((or (stringp article)
5045 (let ((gnus-override-method gnus-override-method)
5046 (methods (and (stringp article)
5047 gnus-refer-article-method))
5048 (backend (car (gnus-find-method-for-group
5049 gnus-newsgroup-name)))
5051 (buffer-read-only nil))
5052 (if (or (not (listp methods))
5053 (and (symbolp (car methods))
5054 (assq (car methods) nnoo-definition-alist)))
5055 (setq methods (list methods)))
5056 (when (and (null gnus-override-method)
5058 (setq gnus-override-method (pop methods)))
5060 (when (eq gnus-override-method 'current)
5061 (setq gnus-override-method
5062 (with-current-buffer gnus-summary-buffer
5063 gnus-current-select-method)))
5065 (gnus-kill-all-overlays)
5066 (let ((gnus-newsgroup-name group))
5067 (gnus-check-group-server))
5069 ((gnus-request-article article group (current-buffer))
5070 (when (numberp article)
5071 (gnus-async-prefetch-next group article
5072 gnus-summary-buffer)
5073 (when gnus-keep-backlog
5074 (gnus-backlog-enter-article
5075 group article (current-buffer))))
5076 (setq result 'article))
5078 (setq gnus-override-method (pop methods)))
5079 ((not (string-match "^400 "
5080 (nnheader-get-report backend)))
5081 ;; If we get 400 server disconnect, reconnect and
5082 ;; retry; otherwise, assume the article has expired.
5083 (setq result 'done))))
5084 (and (eq result 'article) 'article)))
5088 ;; Associate this article with the current summary buffer.
5089 (setq gnus-article-current-summary gnus-summary-buffer)
5091 ;; Take the article from the original article buffer
5092 ;; and place it in the buffer it's supposed to be in.
5093 (when (and (get-buffer gnus-article-buffer)
5094 (equal (buffer-name (current-buffer))
5095 (buffer-name (get-buffer gnus-article-buffer))))
5097 (if (get-buffer gnus-original-article-buffer)
5098 (set-buffer gnus-original-article-buffer)
5099 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5100 (buffer-disable-undo)
5101 (setq major-mode 'gnus-original-article-mode)
5102 (setq buffer-read-only t))
5103 (let (buffer-read-only)
5105 (insert-buffer-substring gnus-article-buffer))
5106 (setq gnus-original-article (cons group article)))
5109 (run-hooks 'gnus-article-decode-hook)
5110 ;; Mark article as decoded or not.
5111 (setq gnus-article-decoded-p gnus-article-decode-hook))
5113 ;; Update sparse articles.
5114 (when (and do-update-line
5115 (or (numberp article)
5117 (let ((buf (current-buffer)))
5118 (set-buffer gnus-summary-buffer)
5119 (gnus-summary-update-article do-update-line sparse-header)
5120 (gnus-summary-goto-subject do-update-line nil t)
5121 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5123 (set-buffer buf))))))
5129 (defcustom gnus-article-edit-mode-hook nil
5130 "Hook run in article edit mode buffers."
5131 :group 'gnus-article-various
5134 (defvar gnus-article-edit-done-function nil)
5136 (defvar gnus-article-edit-mode-map nil)
5138 ;; Should we be using derived.el for this?
5139 (unless gnus-article-edit-mode-map
5140 (setq gnus-article-edit-mode-map (make-keymap))
5141 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5144 (gnus-define-keys gnus-article-edit-mode-map
5145 "\C-c?" describe-mode
5146 "\C-c\C-c" gnus-article-edit-done
5147 "\C-c\C-k" gnus-article-edit-exit
5148 "\C-c\C-f\C-t" message-goto-to
5149 "\C-c\C-f\C-o" message-goto-from
5150 "\C-c\C-f\C-b" message-goto-bcc
5151 ;;"\C-c\C-f\C-w" message-goto-fcc
5152 "\C-c\C-f\C-c" message-goto-cc
5153 "\C-c\C-f\C-s" message-goto-subject
5154 "\C-c\C-f\C-r" message-goto-reply-to
5155 "\C-c\C-f\C-n" message-goto-newsgroups
5156 "\C-c\C-f\C-d" message-goto-distribution
5157 "\C-c\C-f\C-f" message-goto-followup-to
5158 "\C-c\C-f\C-m" message-goto-mail-followup-to
5159 "\C-c\C-f\C-k" message-goto-keywords
5160 "\C-c\C-f\C-u" message-goto-summary
5161 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5162 "\C-c\C-f\C-a" message-gen-unsubscribed-mft
5163 "\C-c\C-b" message-goto-body
5164 "\C-c\C-i" message-goto-signature
5166 "\C-c\C-t" message-insert-to
5167 "\C-c\C-n" message-insert-newsgroups
5168 "\C-c\C-o" message-sort-headers
5169 "\C-c\C-e" message-elide-region
5170 "\C-c\C-v" message-delete-not-region
5171 "\C-c\C-z" message-kill-to-signature
5172 "\M-\r" message-newline-and-reformat
5173 "\C-c\C-a" mml-attach-file
5174 "\C-a" message-beginning-of-line
5176 "\M-;" comment-region)
5178 (gnus-define-keys (gnus-article-edit-wash-map
5179 "\C-c\C-w" gnus-article-edit-mode-map)
5180 "f" gnus-article-edit-full-stops))
5183 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5185 ["Fetch To" message-insert-to t]
5186 ["Fetch Newsgroups" message-insert-newsgroups t]
5188 ["To" message-goto-to t]
5189 ["From" message-goto-from t]
5190 ["Subject" message-goto-subject t]
5191 ["Cc" message-goto-cc t]
5192 ["Reply-To" message-goto-reply-to t]
5193 ["Summary" message-goto-summary t]
5194 ["Keywords" message-goto-keywords t]
5195 ["Newsgroups" message-goto-newsgroups t]
5196 ["Followup-To" message-goto-followup-to t]
5197 ["Mail-Followup-To" message-goto-mail-followup-to t]
5198 ["Distribution" message-goto-distribution t]
5199 ["Body" message-goto-body t]
5200 ["Signature" message-goto-signature t]))
5202 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5203 "Major mode for editing articles.
5204 This is an extended text-mode.
5206 \\{gnus-article-edit-mode-map}"
5207 (make-local-variable 'gnus-article-edit-done-function)
5208 (make-local-variable 'gnus-prev-winconf)
5209 (set (make-local-variable 'font-lock-defaults)
5210 '(message-font-lock-keywords t))
5211 (set (make-local-variable 'mail-header-separator) "")
5212 (easy-menu-add message-mode-field-menu message-mode-map)
5214 (setq buffer-read-only nil)
5215 (buffer-enable-undo)
5218 (defun gnus-article-edit (&optional force)
5219 "Edit the current article.
5220 This will have permanent effect only in mail groups.
5221 If FORCE is non-nil, allow editing of articles even in read-only
5224 (when (and (not force)
5225 (gnus-group-read-only-p))
5226 (error "The current newsgroup does not support article editing"))
5227 (gnus-article-date-original)
5228 (gnus-article-edit-article
5230 `(lambda (no-highlight)
5232 (gnus-summary-edit-article-done
5233 ,(or (mail-header-references gnus-current-headers) "")
5234 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5236 (defun gnus-article-edit-article (start-func exit-func)
5237 "Start editing the contents of the current article buffer."
5238 (let ((winconf (current-window-configuration)))
5239 (set-buffer gnus-article-buffer)
5240 (gnus-article-edit-mode)
5241 (funcall start-func)
5242 (set-buffer-modified-p nil)
5243 (gnus-configure-windows 'edit-article)
5244 (setq gnus-article-edit-done-function exit-func)
5245 (setq gnus-prev-winconf winconf)
5246 (gnus-message 6 "C-c C-c to end edits")))
5248 (defun gnus-article-edit-done (&optional arg)
5249 "Update the article edits and exit."
5251 (let ((func gnus-article-edit-done-function)
5252 (buf (current-buffer))
5253 (start (window-start))
5255 (winconf gnus-prev-winconf))
5256 (widen) ;; Widen it in case that users narrowed the buffer.
5259 ;; The cache and backlog have to be flushed somewhat.
5260 (when gnus-keep-backlog
5261 (gnus-backlog-remove-article
5262 (car gnus-article-current) (cdr gnus-article-current)))
5263 ;; Flush original article as well.
5265 (when (get-buffer gnus-original-article-buffer)
5266 (set-buffer gnus-original-article-buffer)
5267 (setq gnus-original-article nil)))
5268 (when gnus-use-cache
5269 (gnus-cache-update-article
5270 (car gnus-article-current) (cdr gnus-article-current)))
5271 ;; We remove all text props from the article buffer.
5272 (kill-all-local-variables)
5273 (gnus-set-text-properties (point-min) (point-max) nil)
5275 (set-window-configuration winconf)
5277 (set-window-start (get-buffer-window buf) start)
5278 (set-window-point (get-buffer-window buf) (point))))
5280 (defun gnus-article-edit-exit ()
5281 "Exit the article editing without updating."
5283 (when (or (not (buffer-modified-p))
5284 (yes-or-no-p "Article modified; kill anyway? "))
5285 (let ((curbuf (current-buffer))
5287 (window-start (window-start)))
5289 (if (gnus-buffer-live-p gnus-original-article-buffer)
5290 (insert-buffer gnus-original-article-buffer))
5291 (let ((winconf gnus-prev-winconf))
5292 (kill-all-local-variables)
5294 (set-window-configuration winconf)
5295 ;; Tippy-toe some to make sure that point remains where it was.
5296 (save-current-buffer
5298 (set-window-start (get-buffer-window (current-buffer)) window-start)
5301 (defun gnus-article-edit-full-stops ()
5302 "Interactively repair spacing at end of sentences."
5305 (goto-char (point-min))
5306 (search-forward-regexp "^$" nil t)
5307 (let ((case-fold-search nil))
5308 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5311 ;;; Article highlights
5314 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5316 ;;; Internal Variables:
5318 (defcustom gnus-button-url-regexp
5319 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5320 "\\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:]]\\)"
5321 "\\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\\)\\)")
5322 "Regular expression that matches URLs."
5323 :group 'gnus-article-buttons
5326 (defcustom gnus-button-man-handler 'manual-entry
5327 "Function to use for displaying man pages.
5328 The function must take at least one argument with a string naming the
5330 :type '(choice (function-item :tag "Man" manual-entry)
5331 (function-item :tag "Woman" woman)
5332 (function :tag "Other"))
5333 :group 'gnus-article-buttons)
5335 (defcustom gnus-button-prefer-mid-or-mail 'guess
5336 "What to do when the button on a string as \"foo123@bar.com\" is pushed.
5337 Strings like this can be either a message ID or a mail address. If the
5338 variable is set to the symbol `ask', query the user what do do. If it is the
5339 symbol `guess', Gnus will do a guess and query the user what do do if it is
5340 ambiguous. If it is one of the sybols `mid' or `mail', Gnus will always assume
5341 that the string is a message ID or a mail address, respectivly. See the
5342 variable `gnus-button-guessed-mid-regexp' for details concerning the
5344 ;; FIXME: doc-string could/should be improved.
5345 :group 'gnus-article-buttons
5346 :type '(choice (const ask)
5351 (defcustom gnus-button-guessed-mid-regexp
5353 "^<?\\(slrn\\|Pine\\.\\)"
5354 "\\|\\.fsf@\\|\\.fsf_-_@\\|\\.ln@"
5355 "\\|@4ax\\.com\\|@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de"
5356 "\\|^<?.*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*@")
5357 "Regular expression that matches message IDs and not mail addresses."
5358 ;; TODO: Incorporate more matches from
5359 ;; <URL:http://piology.org/perl/id-or-mail.pl.html>. I.e. translate the
5360 ;; Perl-REs to Elisp-REs.
5361 :group 'gnus-article-buttons
5364 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5365 (let* ((pref gnus-button-prefer-mid-or-mail)
5366 (url-mid (concat "news" ":" mid-or-mail))
5367 (url-mailto (concat "mailto" ":" mid-or-mail)))
5368 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5369 ;; If it looks like a MID (well known readers or servers) use 'mid,
5370 ;; otherwise 'ask the user.
5371 (if (eq pref 'guess)
5372 (if (string-match gnus-button-guessed-mid-regexp mid-or-mail)
5376 (save-window-excursion
5377 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5380 (cond ((eq pref 'mid)
5381 (gnus-message 9 "calling `gnus-button-handle-news' %s" url-mid)
5382 (gnus-button-handle-news url-mid))
5384 (gnus-message 9 "calling `gnus-url-mailto' %s" url-mailto)
5385 (gnus-url-mailto url-mailto)))))
5387 (defun gnus-button-handle-custom (url)
5388 "Follow a Custom URL."
5389 (customize-apropos (gnus-url-unhex-string url)))
5391 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5393 (defun gnus-button-handle-describe-function (url)
5394 "Call describe-function when pushing the corresponding URL button."
5397 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5399 (defun gnus-button-handle-describe-variable (url)
5400 "Call describe-variable when pushing the corresponding URL button."
5403 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5405 ;; FIXME: Is is possible to implement this? Else it should be removed here
5406 ;; and in `gnus-button-alist'.
5407 (defun gnus-button-handle-describe-key (url)
5408 "Call describe-key when pushing the corresponding URL button."
5409 (error "not implemented"))
5411 (defun gnus-button-handle-apropos (url)
5412 "Call apropos when pushing the corresponding URL button."
5413 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5415 (defun gnus-button-handle-apropos-command (url)
5416 "Call apropos when pushing the corresponding URL button."
5418 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5420 (defun gnus-button-handle-apropos-variable (url)
5421 "Call apropos when pushing the corresponding URL button."
5423 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5424 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5426 (defcustom gnus-button-man-level 5
5427 "*Integer that says how many man-related buttons Gnus will show.
5428 The higher the number, the more buttons will appear and the more false
5429 positves are possible. Note that you can set this variable local to
5430 specifific groups. Setting it higher in Unix groups is probably a good idea.
5431 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5432 how to set variables in specific groups."
5433 :group 'gnus-article-buttons
5434 :link '(custom-manual "(gnus)Group Parameters")
5437 (defcustom gnus-button-emacs-level 5
5438 "*Integer that says how many emacs-related buttons Gnus will show.
5439 The higher the number, the more buttons will appear and the more false
5440 positves are possible. Note that you can set this variable local to
5441 specifific groups. Setting it higher in Emacs or Gnus related groups is
5442 probably a good idea.See Info node `(gnus)Group Parameters' and the variable
5443 `gnus-parameters' on how to set variables in specific groups."
5444 :group 'gnus-article-buttons
5445 :link '(custom-manual "(gnus)Group Parameters")
5448 (defcustom gnus-button-mail-level 5
5449 "*Integer that says how many buttons for message IDs or mail addresses will appear.
5450 The higher the number, the more buttons will appear and the more false
5451 positves are possible."
5452 :group 'gnus-article-buttons
5455 (defcustom gnus-button-alist
5456 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5457 0 t gnus-button-handle-news 3)
5458 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5459 gnus-button-handle-news 2)
5460 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5462 gnus-button-fetch-group 4)
5463 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5464 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5465 t gnus-button-message-id 3)
5466 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5467 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5468 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5470 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5471 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2)
5473 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5474 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
5475 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5476 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
5477 ;; Emacs help commands
5478 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5479 ;; regexp doesn't match arguments containing ` '.
5480 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
5481 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5482 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
5483 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5484 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
5485 ("\\W\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5486 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
5487 ("\\W\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5488 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
5489 ("\\W\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+" 0
5490 ;; this regexp needs to be fixed!
5491 (>= gnus-button-emacs-level 9) gnus-button-handle-describe-key 2)
5492 ;; This is how URLs _should_ be embedded in text...
5493 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5495 (gnus-button-url-regexp 0 t browse-url 0)
5497 ("\\b\\([a-z][a-z]+\\)([0-9])\\W" 0
5498 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
5499 gnus-button-handle-man 1)
5500 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
5501 ("\\b\\([a-zA-Z][-_.a-zA-Z0-9]+\\)([0-9])\\W" 0
5502 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
5503 gnus-button-handle-man 1)
5504 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm), SoWWWAnchor(3iv)
5505 ("\\b\\([a-zA-Z][-_.:a-zA-Z0-9]+\\)([0-9][a-z]*)\\W" 0
5506 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
5507 ;; MID or mail: To avoid too many false positives we don't try to catch
5508 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
5509 ;; at least one dot. TLD must contain two or three chars or be a know TLD
5510 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
5511 ;; so that non-ambiguous entries (see above) match first.
5512 ("\\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"
5513 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1))
5514 "*Alist of regexps matching buttons in article bodies.
5516 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5517 REGEXP: is the string matching text around the button (can also be lisp
5518 expression evaluating to a string),
5519 BUTTON: is the number of the regexp grouping actually matching the button,
5520 FORM: is a lisp expression which must eval to true for the button to
5522 CALLBACK: is the function to call when the user push this button, and each
5523 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5525 CALLBACK can also be a variable, in that case the value of that
5526 variable it the real callback function."
5527 :group 'gnus-article-buttons
5528 :type '(repeat (list (choice regexp variable)
5529 (integer :tag "Button")
5531 (function :tag "Callback")
5534 (integer :tag "Regexp group")))))
5536 (defcustom gnus-header-button-alist
5537 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5538 0 t gnus-button-message-id 0)
5539 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5540 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5541 0 t gnus-button-mailto 0)
5542 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
5543 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
5544 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
5545 ("^[^:]+:" "\\bmailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5546 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5547 gnus-button-message-id 3))
5548 "*Alist of headers and regexps to match buttons in article heads.
5550 This alist is very similar to `gnus-button-alist', except that each
5551 alist has an additional HEADER element first in each entry:
5553 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5555 HEADER is a regexp to match a header. For a fuller explanation, see
5556 `gnus-button-alist'."
5557 :group 'gnus-article-buttons
5558 :group 'gnus-article-headers
5559 :type '(repeat (list (regexp :tag "Header")
5561 (integer :tag "Button")
5563 (function :tag "Callback")
5566 (integer :tag "Regexp group")))))
5568 (defvar gnus-button-regexp nil)
5569 (defvar gnus-button-marker-list nil)
5570 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5572 (defvar gnus-button-last nil)
5573 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5577 (defun gnus-article-push-button (event)
5578 "Check text under the mouse pointer for a callback function.
5579 If the text under the mouse pointer has a `gnus-callback' property,
5580 call it with the value of the `gnus-data' text property."
5582 (set-buffer (window-buffer (posn-window (event-start event))))
5583 (let* ((pos (posn-point (event-start event)))
5584 (data (get-text-property pos 'gnus-data))
5585 (fun (get-text-property pos 'gnus-callback)))
5588 (funcall fun data))))
5590 (defun gnus-article-press-button ()
5591 "Check text at point for a callback function.
5592 If the text at point has a `gnus-callback' property,
5593 call it with the value of the `gnus-data' text property."
5595 (let* ((data (get-text-property (point) 'gnus-data))
5596 (fun (get-text-property (point) 'gnus-callback)))
5598 (funcall fun data))))
5600 (defun gnus-article-highlight (&optional force)
5601 "Highlight current article.
5602 This function calls `gnus-article-highlight-headers',
5603 `gnus-article-highlight-citation',
5604 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5605 do the highlighting. See the documentation for those functions."
5606 (interactive (list 'force))
5607 (gnus-article-highlight-headers)
5608 (gnus-article-highlight-citation force)
5609 (gnus-article-highlight-signature)
5610 (gnus-article-add-buttons force)
5611 (gnus-article-add-buttons-to-head))
5613 (defun gnus-article-highlight-some (&optional force)
5614 "Highlight current article.
5615 This function calls `gnus-article-highlight-headers',
5616 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5617 do the highlighting. See the documentation for those functions."
5618 (interactive (list 'force))
5619 (gnus-article-highlight-headers)
5620 (gnus-article-highlight-signature)
5621 (gnus-article-add-buttons))
5623 (defun gnus-article-highlight-headers ()
5624 "Highlight article headers as specified by `gnus-header-face-alist'."
5627 (set-buffer gnus-article-buffer)
5629 (let ((alist gnus-header-face-alist)
5630 (buffer-read-only nil)
5631 (case-fold-search t)
5632 (inhibit-point-motion-hooks t)
5633 entry regexp header-face field-face from hpoints fpoints)
5634 (article-narrow-to-head)
5635 (while (setq entry (pop alist))
5636 (goto-char (point-min))
5637 (setq regexp (concat "^\\("
5638 (if (string-equal "" (nth 0 entry))
5642 header-face (nth 1 entry)
5643 field-face (nth 2 entry))
5644 (while (and (re-search-forward regexp nil t)
5648 (unless (search-forward ":" nil t)
5650 (when (and header-face
5651 (not (memq (point) hpoints)))
5652 (push (point) hpoints)
5653 (gnus-put-text-property from (point) 'face header-face))
5654 (when (and field-face
5655 (not (memq (setq from (point)) fpoints)))
5657 (if (re-search-forward "^[^ \t]" nil t)
5659 (goto-char (point-max)))
5660 (gnus-put-text-property from (point) 'face field-face))))))))
5662 (defun gnus-article-highlight-signature ()
5663 "Highlight the signature in an article.
5664 It does this by highlighting everything after
5665 `gnus-signature-separator' using `gnus-signature-face'."
5668 (set-buffer gnus-article-buffer)
5669 (let ((buffer-read-only nil)
5670 (inhibit-point-motion-hooks t))
5672 (when (and gnus-signature-face
5673 (gnus-article-narrow-to-signature))
5674 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5675 'face gnus-signature-face)
5677 (gnus-article-search-signature)
5678 (let ((start (match-beginning 0))
5679 (end (set-marker (make-marker) (1+ (match-end 0)))))
5680 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5683 (defun gnus-button-in-region-p (b e prop)
5684 "Say whether PROP exists in the region."
5685 (text-property-not-all b e prop nil))
5687 (defun gnus-article-add-buttons (&optional force)
5688 "Find external references in the article and make buttons of them.
5689 \"External references\" are things like Message-IDs and URLs, as
5690 specified by `gnus-button-alist'."
5691 (interactive (list 'force))
5693 (set-buffer gnus-article-buffer)
5694 (let ((buffer-read-only nil)
5695 (inhibit-point-motion-hooks t)
5696 (case-fold-search t)
5697 (alist gnus-button-alist)
5699 ;; Remove all old markers.
5700 (let (marker entry new-list)
5701 (while (setq marker (pop gnus-button-marker-list))
5702 (if (or (< marker (point-min)) (>= marker (point-max)))
5703 (push marker new-list)
5705 (when (setq entry (gnus-button-entry))
5706 (put-text-property (match-beginning (nth 1 entry))
5707 (match-end (nth 1 entry))
5708 'gnus-callback nil))
5709 (set-marker marker nil)))
5710 (setq gnus-button-marker-list new-list))
5711 ;; We skip the headers.
5714 (while (setq entry (pop alist))
5715 (setq regexp (eval (car entry)))
5717 (while (re-search-forward regexp nil t)
5718 (let* ((start (and entry (match-beginning (nth 1 entry))))
5719 (end (and entry (match-end (nth 1 entry))))
5720 (from (match-beginning 0)))
5721 (when (and (or (eq t (nth 2 entry))
5722 (eval (nth 2 entry)))
5723 (not (gnus-button-in-region-p
5724 start end 'gnus-callback)))
5725 ;; That optional form returned non-nil, so we add the
5727 (gnus-article-add-button
5728 start end 'gnus-button-push
5729 (car (push (set-marker (make-marker) from)
5730 gnus-button-marker-list))))))))))
5732 ;; Add buttons to the head of an article.
5733 (defun gnus-article-add-buttons-to-head ()
5734 "Add buttons to the head of the article."
5737 (set-buffer gnus-article-buffer)
5739 (let ((buffer-read-only nil)
5740 (inhibit-point-motion-hooks t)
5741 (case-fold-search t)
5742 (alist gnus-header-button-alist)
5744 (article-narrow-to-head)
5746 ;; Each alist entry.
5747 (setq entry (car alist)
5749 (goto-char (point-min))
5750 (while (re-search-forward (car entry) nil t)
5751 ;; Each header matching the entry.
5752 (setq beg (match-beginning 0))
5753 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5754 (match-beginning 0))
5757 (while (re-search-forward (eval (nth 1 entry)) end t)
5758 ;; Each match within a header.
5759 (let* ((entry (cdr entry))
5760 (start (match-beginning (nth 1 entry)))
5761 (end (match-end (nth 1 entry)))
5762 (form (nth 2 entry)))
5763 (goto-char (match-end 0))
5765 (gnus-article-add-button
5766 start end (nth 3 entry)
5767 (buffer-substring (match-beginning (nth 4 entry))
5768 (match-end (nth 4 entry)))))))
5769 (goto-char end)))))))
5771 ;;; External functions:
5773 (defun gnus-article-add-button (from to fun &optional data)
5774 "Create a button between FROM and TO with callback FUN and data DATA."
5775 (when gnus-article-button-face
5776 (gnus-overlay-put (gnus-make-overlay from to)
5777 'face gnus-article-button-face))
5778 (gnus-add-text-properties
5780 (nconc (and gnus-article-mouse-face
5781 (list gnus-mouse-face-prop gnus-article-mouse-face))
5782 (list 'gnus-callback fun)
5783 (and data (list 'gnus-data data))))
5784 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5785 :button-keymap gnus-widget-button-keymap))
5787 ;;; Internal functions:
5789 (defun gnus-article-set-globals ()
5791 (set-buffer gnus-summary-buffer)
5792 (gnus-set-global-variables)))
5794 (defun gnus-signature-toggle (end)
5796 (set-buffer gnus-article-buffer)
5797 (let ((buffer-read-only nil)
5798 (inhibit-point-motion-hooks t))
5799 (if (text-property-any end (point-max) 'article-type 'signature)
5801 (gnus-delete-wash-type 'signature)
5802 (gnus-remove-text-properties-when
5803 'article-type 'signature end (point-max)
5804 (cons 'article-type (cons 'signature
5805 gnus-hidden-properties))))
5806 (gnus-add-wash-type 'signature)
5807 (gnus-add-text-properties-when
5808 'article-type nil end (point-max)
5809 (cons 'article-type (cons 'signature
5810 gnus-hidden-properties)))))
5811 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5812 (gnus-set-mode-line 'article))))
5814 (defun gnus-button-entry ()
5815 ;; Return the first entry in `gnus-button-alist' matching this place.
5816 (let ((alist gnus-button-alist)
5819 (setq entry (pop alist))
5820 (if (looking-at (eval (car entry)))
5825 (defun gnus-button-push (marker)
5826 ;; Push button starting at MARKER.
5829 (let* ((entry (gnus-button-entry))
5830 (inhibit-point-motion-hooks t)
5832 (args (mapcar (lambda (group)
5833 (let ((string (match-string group)))
5834 (gnus-set-text-properties
5835 0 (length string) nil string)
5842 (fboundp (symbol-value fun)))
5843 (apply (symbol-value fun) args))
5845 (gnus-message 1 "You must define `%S' to use this button"
5846 (cons fun args)))))))
5848 (defun gnus-parse-news-url (url)
5849 (let (scheme server group message-id articles)
5852 (goto-char (point-min))
5853 (when (looking-at "\\([A-Za-z]+\\):")
5854 (setq scheme (match-string 1))
5855 (goto-char (match-end 0)))
5856 (when (looking-at "//\\([^/]+\\)/")
5857 (setq server (match-string 1))
5858 (goto-char (match-end 0)))
5861 ((looking-at "\\(.*@.*\\)")
5862 (setq message-id (match-string 1)))
5863 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5864 (setq group (match-string 1)
5865 articles (split-string (match-string 2) "-")))
5866 ((looking-at "\\([^/]+\\)/?")
5867 (setq group (match-string 1)))
5869 (error "Unknown news URL syntax"))))
5870 (list scheme server group message-id articles)))
5872 (defun gnus-button-handle-news (url)
5874 (destructuring-bind (scheme server group message-id articles)
5875 (gnus-parse-news-url url)
5879 (set-buffer gnus-summary-buffer)
5881 (let ((gnus-refer-article-method (list (list 'nntp server))))
5882 (gnus-summary-refer-article message-id))
5883 (gnus-summary-refer-article message-id))))
5885 (gnus-button-fetch-group url)))))
5887 (defun gnus-button-handle-man (url)
5889 (funcall gnus-button-man-handler url))
5891 (defun gnus-button-handle-info (url)
5892 "Fetch an info URL."
5894 "^\\([^:/]+\\)?/\\(.*\\)"
5896 (gnus-info-find-node
5897 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5900 (gnus-url-unhex-string (match-string 2 url))))
5901 (error "Can't parse %s" url)))
5903 (defun gnus-button-message-id (message-id)
5906 (set-buffer gnus-summary-buffer)
5907 (gnus-summary-refer-article message-id)))
5909 (defun gnus-button-fetch-group (address)
5910 "Fetch GROUP specified by ADDRESS."
5911 (if (not (string-match "[:/]" address))
5912 ;; This is just a simple group url.
5913 (gnus-group-read-ephemeral-group address gnus-select-method)
5916 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5918 (error "Can't parse %s" address)
5919 (gnus-group-read-ephemeral-group
5920 (match-string 4 address)
5921 `(nntp ,(match-string 1 address)
5922 (nntp-address ,(match-string 1 address))
5923 (nntp-port-number ,(if (match-end 3)
5924 (match-string 3 address)
5927 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5929 (defun gnus-url-parse-query-string (query &optional downcase)
5930 (let (retval pairs cur key val)
5931 (setq pairs (split-string query "&"))
5933 (setq cur (car pairs)
5935 (if (not (string-match "=" cur))
5937 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5938 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
5940 (setq key (downcase key)))
5941 (setq cur (assoc key retval))
5943 (setcdr cur (cons val (cdr cur)))
5944 (setq retval (cons (list key val) retval)))))
5947 (defun gnus-url-mailto (url)
5948 ;; Send mail to someone
5949 (when (string-match "mailto:/*\\(.*\\)" url)
5950 (setq url (substring url (match-beginning 1) nil)))
5951 (let (to args subject func)
5952 (if (string-match (regexp-quote "?") url)
5953 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5954 args (gnus-url-parse-query-string
5955 (substring url (match-end 0) nil) t))
5956 (setq to (gnus-url-unhex-string url)))
5957 (setq args (cons (list "to" to) args)
5958 subject (cdr-safe (assoc "subject" args)))
5961 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5964 (message-position-on-field (caar args)))
5965 (insert (mapconcat 'identity (cdar args) ", "))
5966 (setq args (cdr args)))
5969 (message-goto-subject))))
5971 (defun gnus-button-embedded-url (address)
5972 "Activate ADDRESS with `browse-url'."
5973 (browse-url (gnus-strip-whitespace address)))
5975 ;;; Next/prev buttons in the article buffer.
5977 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5978 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5980 (defvar gnus-prev-page-map
5981 (let ((map (make-sparse-keymap)))
5982 (unless (>= emacs-major-version 21)
5983 ;; XEmacs doesn't care.
5984 (set-keymap-parent map gnus-article-mode-map))
5985 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5986 (define-key map "\r" 'gnus-button-prev-page)
5989 (defun gnus-insert-prev-page-button ()
5991 (buffer-read-only nil))
5993 gnus-prev-page-line-format nil
5994 `(,@(gnus-local-map-property gnus-prev-page-map)
5996 gnus-callback gnus-article-button-prev-page
5997 article-type annotation))
5998 (widget-convert-button
6000 :action 'gnus-button-prev-page
6001 :button-keymap gnus-prev-page-map)))
6003 (defvar gnus-prev-page-map
6004 (let ((map (make-sparse-keymap)))
6005 (unless (>= emacs-major-version 21)
6006 ;; XEmacs doesn't care.
6007 (set-keymap-parent map gnus-article-mode-map))
6008 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6009 (define-key map "\r" 'gnus-button-prev-page)
6012 (defvar gnus-next-page-map
6013 (let ((map (make-sparse-keymap)))
6014 (unless (>= emacs-major-version 21)
6015 ;; XEmacs doesn't care.
6016 (set-keymap-parent map gnus-article-mode-map))
6017 (define-key map gnus-mouse-2 'gnus-button-next-page)
6018 (define-key map "\r" 'gnus-button-next-page)
6021 (defun gnus-button-next-page (&optional args more-args)
6022 "Go to the next page."
6024 (let ((win (selected-window)))
6025 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6026 (gnus-article-next-page)
6027 (select-window win)))
6029 (defun gnus-button-prev-page (&optional args more-args)
6030 "Go to the prev page."
6032 (let ((win (selected-window)))
6033 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6034 (gnus-article-prev-page)
6035 (select-window win)))
6037 (defun gnus-insert-next-page-button ()
6039 (buffer-read-only nil))
6040 (gnus-eval-format gnus-next-page-line-format nil
6041 `(,@(gnus-local-map-property gnus-next-page-map)
6043 gnus-callback gnus-article-button-next-page
6044 article-type annotation))
6045 (widget-convert-button
6047 :action 'gnus-button-next-page
6048 :button-keymap gnus-next-page-map)))
6050 (defun gnus-article-button-next-page (arg)
6051 "Go to the next page."
6053 (let ((win (selected-window)))
6054 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6055 (gnus-article-next-page)
6056 (select-window win)))
6058 (defun gnus-article-button-prev-page (arg)
6059 "Go to the prev page."
6061 (let ((win (selected-window)))
6062 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6063 (gnus-article-prev-page)
6064 (select-window win)))
6066 (defvar gnus-decode-header-methods
6067 '(mail-decode-encoded-word-region)
6068 "List of methods used to decode headers.
6070 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6071 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6072 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6073 whose names match REGEXP.
6076 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6077 mail-decode-encoded-word-region
6078 (\"chinese\" . rfc1843-decode-region))
6081 (defvar gnus-decode-header-methods-cache nil)
6083 (defun gnus-multi-decode-header (start end)
6084 "Apply the functions from `gnus-encoded-word-methods' that match."
6085 (unless (and gnus-decode-header-methods-cache
6086 (eq gnus-newsgroup-name
6087 (car gnus-decode-header-methods-cache)))
6088 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6091 (nconc gnus-decode-header-methods-cache (list x))
6092 (if (and gnus-newsgroup-name
6093 (string-match (car x) gnus-newsgroup-name))
6094 (nconc gnus-decode-header-methods-cache
6096 gnus-decode-header-methods))
6097 (let ((xlist gnus-decode-header-methods-cache))
6100 (narrow-to-region start end)
6102 (funcall (pop xlist) (point-min) (point-max))))))
6105 ;;; Treatment top-level handling.
6108 (defun gnus-treat-article (condition &optional part-number total-parts type)
6109 (let ((length (- (point-max) (point-min)))
6110 (alist gnus-treatment-function-alist)
6111 (article-goto-body-goes-to-point-min-p t)
6115 (let ((list gnus-article-treat-types))
6117 (when (string-match (pop list) type)
6118 (throw 'found t)))))))
6119 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6121 (gnus-run-hooks 'gnus-part-display-hook)
6122 (while (setq elem (pop alist))
6125 (if (gnus-buffer-live-p gnus-summary-buffer)
6126 (set-buffer gnus-summary-buffer))
6127 (symbol-value (car elem))))
6128 (when (and (or (consp val)
6130 (gnus-treat-predicate val)
6131 (or (not (get (car elem) 'highlight))
6134 (funcall (cadr elem)))))))
6136 ;; Dynamic variables.
6138 (defvar part-number)
6139 (defvar total-parts)
6144 (defun gnus-treat-predicate (val)
6149 (stringp (car val)))
6150 (apply 'gnus-or (mapcar `(lambda (s)
6151 (string-match s ,(or gnus-newsgroup-name "")))
6154 (let ((pred (pop val)))
6157 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6159 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6161 (not (gnus-treat-predicate (car val))))
6163 (equal (car val) type))
6165 (error "%S is not a valid predicate" pred)))))
6173 (eq part-number total-parts))
6177 (error "%S is not a valid value" val))))
6179 (defun gnus-article-encrypt-body (protocol &optional n)
6180 "Encrypt the article body."
6183 (or gnus-article-encrypt-protocol
6184 (completing-read "Encrypt protocol: "
6185 gnus-article-encrypt-protocol-alist
6187 current-prefix-arg))
6188 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6190 (error (format "Can't find the encrypt protocol %s" protocol)))
6191 (if (member gnus-newsgroup-name '("nndraft:delayed"
6194 (error "Can't encrypt the article in group %s"
6195 gnus-newsgroup-name))
6196 (gnus-summary-iterate n
6198 (set-buffer gnus-summary-buffer)
6199 (let ((mail-parse-charset gnus-newsgroup-charset)
6200 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6201 (summary-buffer gnus-summary-buffer)
6203 (gnus-set-global-variables)
6204 (when (gnus-group-read-only-p)
6205 (error "The current newsgroup does not support article encrypt"))
6206 (gnus-summary-show-article t)
6208 (or (mail-header-references gnus-current-headers) ""))
6209 (set-buffer gnus-article-buffer)
6210 (let* ((buffer-read-only nil)
6212 (mapcar (lambda (field)
6213 (and (save-restriction
6214 (message-narrow-to-head)
6215 (goto-char (point-min))
6216 (search-forward field nil t))
6218 (message-narrow-to-field)
6219 (buffer-substring (point-min) (point-max))
6220 (delete-region (point-min) (point-max))
6222 '("Content-Type:" "Content-Transfer-Encoding:"
6223 "Content-Disposition:"))))
6224 (message-narrow-to-head)
6225 (message-remove-header "MIME-Version")
6226 (goto-char (point-max))
6227 (setq point (point))
6228 (insert (apply 'concat headers))
6230 (narrow-to-region point (point-max))
6231 (let ((message-options message-options))
6232 (message-options-set 'message-sender user-mail-address)
6233 (message-options-set 'message-recipients user-mail-address)
6234 (message-options-set 'message-sign-encrypt 'not)
6236 (goto-char (point-min))
6237 (insert "MIME-Version: 1.0\n")
6239 (gnus-summary-edit-article-done
6240 references nil summary-buffer t))
6241 (when gnus-keep-backlog
6242 (gnus-backlog-remove-article
6243 (car gnus-article-current) (cdr gnus-article-current)))
6245 (when (get-buffer gnus-original-article-buffer)
6246 (set-buffer gnus-original-article-buffer)
6247 (setq gnus-original-article nil)))
6248 (when gnus-use-cache
6249 (gnus-cache-update-article
6250 (car gnus-article-current) (cdr gnus-article-current))))))))
6252 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6253 "The following specs can be used:
6254 %t The security MIME type
6257 %D Details if button is pressed")
6259 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6260 "The following specs can be used:
6261 %t The security MIME type
6264 %D Details if button is pressed")
6266 (defvar gnus-mime-security-button-line-format-alist
6267 '((?t gnus-tmp-type ?s)
6268 (?i gnus-tmp-info ?s)
6269 (?d gnus-tmp-details ?s)
6270 (?D gnus-tmp-pressed-details ?s)))
6272 (defvar gnus-mime-security-button-map
6273 (let ((map (make-sparse-keymap)))
6274 (unless (>= (string-to-number emacs-version) 21)
6275 (set-keymap-parent map gnus-article-mode-map))
6276 (define-key map gnus-mouse-2 'gnus-article-push-button)
6277 (define-key map "\r" 'gnus-article-press-button)
6280 (defvar gnus-mime-security-details-buffer nil)
6282 (defvar gnus-mime-security-button-pressed nil)
6284 (defvar gnus-mime-security-show-details-inline t
6285 "If non-nil, show details in the article buffer.")
6287 (defun gnus-mime-security-verify-or-decrypt (handle)
6288 (mm-remove-parts (cdr handle))
6289 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6290 point buffer-read-only)
6292 (goto-char (car region)))
6294 (narrow-to-region (point) (point))
6295 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6296 (let* ((mm-verify-option 'known)
6297 (mm-decrypt-option 'known)
6298 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6299 (unless (eq nparts (cdr handle))
6300 (mm-destroy-parts (cdr handle))
6301 (setcdr handle nparts))))
6302 (setq point (point))
6303 (gnus-mime-display-security handle)
6304 (goto-char (point-max)))
6306 (delete-region (point) (cdr region))
6307 (set-marker (car region) nil)
6308 (set-marker (cdr region) nil))
6311 (defun gnus-mime-security-show-details (handle)
6312 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6314 (if gnus-mime-security-show-details-inline
6315 (let ((gnus-mime-security-button-pressed t)
6316 (gnus-mime-security-button-line-format
6317 (get-text-property (point) 'gnus-line-format))
6320 (while (eq (get-text-property (point) 'gnus-line-format)
6321 gnus-mime-security-button-line-format)
6325 (narrow-to-region (point) (point))
6326 (gnus-insert-mime-security-button handle))
6327 (delete-region (point)
6328 (or (text-property-not-all
6331 gnus-mime-security-button-line-format)
6333 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6334 (with-current-buffer gnus-mime-security-details-buffer
6337 (setq gnus-mime-security-details-buffer
6338 (gnus-get-buffer-create "*MIME Security Details*")))
6339 (with-current-buffer gnus-mime-security-details-buffer
6341 (goto-char (point-min)))
6342 (pop-to-buffer gnus-mime-security-details-buffer))
6343 (gnus-message 5 "No details."))))
6345 (defun gnus-mime-security-press-button (handle)
6346 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6347 (gnus-mime-security-show-details handle)
6348 (gnus-mime-security-verify-or-decrypt handle)))
6350 (defun gnus-insert-mime-security-button (handle &optional displayed)
6351 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6354 (or (nth 2 (assoc protocol mm-verify-function-alist))
6355 (nth 2 (assoc protocol mm-decrypt-function-alist))
6357 (if (equal (car handle) "multipart/signed")
6358 " Signed" " Encrypted")
6361 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6364 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6365 gnus-tmp-pressed-details
6367 (setq gnus-tmp-details
6368 (if gnus-tmp-details
6369 (concat "\n" gnus-tmp-details) ""))
6370 (setq gnus-tmp-pressed-details
6371 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6376 gnus-mime-security-button-line-format
6377 gnus-mime-security-button-line-format-alist
6378 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6379 gnus-callback gnus-mime-security-press-button
6380 gnus-line-format ,gnus-mime-security-button-line-format
6381 article-type annotation
6384 (widget-convert-button
6387 :action 'gnus-widget-press-button
6388 :button-keymap gnus-mime-security-button-map
6390 (lambda (widget/window &optional overlay pos)
6391 ;; Needed to properly clear the message due to a bug in
6392 ;; wid-edit (XEmacs only).
6393 (if (boundp 'help-echo-owns-message)
6394 (setq help-echo-owns-message t))
6397 (aref gnus-mouse-2 0))))))
6399 (defun gnus-mime-display-security (handle)
6401 (narrow-to-region (point) (point))
6402 (unless (gnus-unbuttonized-mime-type-p (car handle))
6403 (gnus-insert-mime-security-button handle))
6404 (gnus-mime-display-mixed (cdr handle))
6407 (unless (gnus-unbuttonized-mime-type-p (car handle))
6408 (let ((gnus-mime-security-button-line-format
6409 gnus-mime-security-button-end-line-format))
6410 (gnus-insert-mime-security-button handle)))
6411 (mm-set-handle-multipart-parameter
6413 (cons (set-marker (make-marker) (point-min))
6414 (set-marker (make-marker) (point-max))))))
6420 (run-hooks 'gnus-art-load-hook)
6422 ;;; gnus-art.el ends here