1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
43 (autoload 'gnus-msg-mail "gnus-msg" nil t)
44 (autoload 'gnus-button-mailto "gnus-msg")
45 (autoload 'gnus-button-reply "gnus-msg" nil t)
47 (defgroup gnus-article nil
49 :link '(custom-manual "(gnus)The Article Buffer")
52 (defgroup gnus-article-treat nil
53 "Treating article parts."
54 :link '(custom-manual "(gnus)Article Hiding")
57 (defgroup gnus-article-hiding nil
58 "Hiding article parts."
59 :link '(custom-manual "(gnus)Article Hiding")
62 (defgroup gnus-article-highlight nil
63 "Article highlighting."
64 :link '(custom-manual "(gnus)Article Highlighting")
68 (defgroup gnus-article-signature nil
70 :link '(custom-manual "(gnus)Article Signature")
73 (defgroup gnus-article-headers nil
75 :link '(custom-manual "(gnus)Hiding Headers")
78 (defgroup gnus-article-washing nil
79 "Special commands on articles."
80 :link '(custom-manual "(gnus)Article Washing")
83 (defgroup gnus-article-emphasis nil
84 "Fontisizing articles."
85 :link '(custom-manual "(gnus)Article Fontisizing")
88 (defgroup gnus-article-saving nil
90 :link '(custom-manual "(gnus)Saving Articles")
93 (defgroup gnus-article-mime nil
94 "Worshiping the MIME wonder."
95 :link '(custom-manual "(gnus)Using MIME")
98 (defgroup gnus-article-buttons nil
99 "Pushable buttons in the article buffer."
100 :link '(custom-manual "(gnus)Article Buttons")
101 :group 'gnus-article)
103 (defgroup gnus-article-various nil
104 "Other article options."
105 :link '(custom-manual "(gnus)Misc Article")
106 :group 'gnus-article)
108 (defcustom gnus-ignored-headers
109 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
110 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
111 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
112 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
113 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
114 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face"
115 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
116 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
117 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
118 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
119 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
120 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
121 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
122 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
123 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
124 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
125 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
126 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
127 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
128 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
129 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
130 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
131 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
132 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
133 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
134 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
135 "^X-Received:" "^Content-length:" "X-precedence:"
136 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
137 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
138 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
139 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
140 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
141 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:"
142 "^X-Request-PGP:" "^X-Fingerprint:" "^X-WRIEnvto:" "^X-WRIEnvfrom:"
143 "^X-Virus-Scanned:" "^X-Delivery-Agent:" "^Posted-Date:" "^X-Gateway:"
144 "^X-Local-Origin:" "^X-Local-Destination:" "^X-UserInfo1:"
145 "^X-Received-Date:" "^X-Hashcash:")
146 "*All headers that start with this regexp will be hidden.
147 This variable can also be a list of regexps of headers to be ignored.
148 If `gnus-visible-headers' is non-nil, this variable will be ignored."
149 :type '(choice :custom-show nil
152 :group 'gnus-article-hiding)
154 (defcustom gnus-visible-headers
155 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
156 "*All headers that do not match this regexp will be hidden.
157 This variable can also be a list of regexp of headers to remain visible.
158 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
159 :type '(repeat :value-to-internal (lambda (widget value)
160 (custom-split-regexp-maybe value))
161 :match (lambda (widget value)
163 (widget-editable-list-match widget value)))
165 :group 'gnus-article-hiding)
167 (defcustom gnus-sorted-header-list
168 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
169 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
170 "*This variable is a list of regular expressions.
171 If it is non-nil, headers that match the regular expressions will
172 be placed first in the article buffer in the sequence specified by
174 :type '(repeat regexp)
175 :group 'gnus-article-hiding)
177 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
178 "Headers that are only to be displayed if they have interesting data.
179 Possible values in this list are:
181 'empty Headers with no content.
182 'newsgroups Newsgroup identical to Gnus group.
183 'to-address To identical to To-address.
184 'followup-to Followup-to identical to Newsgroups.
185 'reply-to Reply-to identical to From.
186 'date Date less than four days old.
187 'long-to To and/or Cc longer than 1024 characters.
188 'many-to Multiple To and/or Cc."
189 :type '(set (const :tag "Headers with no content." empty)
190 (const :tag "Newsgroups identical to Gnus group." newsgroups)
191 (const :tag "To identical to To-address." to-address)
192 (const :tag "Followup-to identical to Newsgroups." followup-to)
193 (const :tag "Reply-to identical to From." reply-to)
194 (const :tag "Date less than four days old." date)
195 (const :tag "To and/or Cc longer than 1024 characters." long-to)
196 (const :tag "Multiple To and/or Cc headers." many-to))
197 :group 'gnus-article-hiding)
199 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
200 "Regexp matching signature separator.
201 This can also be a list of regexps. In that case, it will be checked
202 from head to tail looking for a separator. Searches will be done from
203 the end of the buffer."
204 :type '(repeat string)
205 :group 'gnus-article-signature)
207 (defcustom gnus-signature-limit nil
208 "Provide a limit to what is considered a signature.
209 If it is a number, no signature may not be longer (in characters) than
210 that number. If it is a floating point number, no signature may be
211 longer (in lines) than that number. If it is a function, the function
212 will be called without any parameters, and if it returns nil, there is
213 no signature in the buffer. If it is a string, it will be used as a
214 regexp. If it matches, the text in question is not a signature."
215 :type '(choice (integer :value 200)
217 (function :value fun)
218 (regexp :value ".*"))
219 :group 'gnus-article-signature)
221 (defcustom gnus-hidden-properties '(invisible t intangible t)
222 "Property list to use for hiding text."
224 :group 'gnus-article-hiding)
226 ;; Fixme: This isn't the right thing for mixed graphical and and
227 ;; non-graphical frames in a session.
228 (defcustom gnus-article-x-face-command
229 (if (featurep 'xemacs)
230 (if (or (gnus-image-type-available-p 'xface)
231 (gnus-image-type-available-p 'pbm))
232 'gnus-display-x-face-in-from
233 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
234 (if (gnus-image-type-available-p 'pbm)
235 'gnus-display-x-face-in-from
236 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
238 "*String or function to be executed to display an X-Face header.
239 If it is a string, the command will be executed in a sub-shell
240 asynchronously. The compressed face will be piped to this command."
241 :type `(choice string
242 (function-item gnus-display-x-face-in-from)
246 :group 'gnus-article-washing)
248 (defcustom gnus-article-x-face-too-ugly nil
249 "Regexp matching posters whose face shouldn't be shown automatically."
250 :type '(choice regexp (const nil))
251 :group 'gnus-article-washing)
253 (defcustom gnus-article-banner-alist nil
254 "Banner alist for stripping.
256 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
258 :type '(repeat (cons symbol regexp))
259 :group 'gnus-article-washing)
261 (gnus-define-group-parameter
264 "Alist of regexps (to match group names) and banner."
265 :variable-group gnus-article-washing
267 '(choice :tag "Banner"
269 (const :tag "Remove signature" signature)
270 (symbol :tag "Item in `gnus-article-banner-alist'" none)
272 (const :tag "None" nil))
274 "If non-nil, specify how to remove `banners' from articles.
276 Symbol `signature' means to remove signatures delimited by
277 `gnus-signature-separator'. Any other symbol is used to look up a
278 regular expression to match the banner in `gnus-article-banner-alist'.
279 A string is used as a regular expression to match the banner
282 (defcustom gnus-article-address-banner-alist nil
283 "Alist of mail addresses and banners.
284 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
285 to match a mail address in the From: header, BANNER is one of a symbol
286 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
287 If ADDRESS matches author's mail address, it will remove things like
288 advertisements. For example:
290 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
294 (regexp :tag "Address")
295 (choice :tag "Banner" :value nil
296 (const :tag "Remove signature" signature)
297 (symbol :tag "Item in `gnus-article-banner-alist'" none)
299 (const :tag "None" nil))))
300 :group 'gnus-article-washing)
302 (defcustom gnus-emphasis-alist
304 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
309 ("_/" "/_" underline-italic)
310 ("_\\*" "\\*_" underline-bold)
311 ("\\*/" "/\\*" bold-italic)
312 ("_\\*/" "/\\*_" underline-bold-italic))))
316 (format format (car spec) (cadr spec))
317 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
319 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
320 2 3 gnus-emphasis-strikethru)
321 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
322 2 3 gnus-emphasis-underline)))
323 "*Alist that says how to fontify certain phrases.
324 Each item looks like this:
326 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
328 The first element is a regular expression to be matched. The second
329 is a number that says what regular expression grouping used to find
330 the entire emphasized word. The third is a number that says what
331 regexp grouping should be displayed and highlighted. The fourth
332 is the face used for highlighting."
333 :type '(repeat (list :value ("" 0 0 default)
335 (integer :tag "Match group")
336 (integer :tag "Emphasize group")
338 :group 'gnus-article-emphasis)
340 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
341 "A regexp to describe whitespace which should not be emphasized.
342 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
343 The former avoids underlining of leading and trailing whitespace,
344 and the latter avoids underlining any whitespace at all."
346 :group 'gnus-article-emphasis
349 (defface gnus-emphasis-bold '((t (:bold t)))
350 "Face used for displaying strong emphasized text (*word*)."
351 :group 'gnus-article-emphasis)
353 (defface gnus-emphasis-italic '((t (:italic t)))
354 "Face used for displaying italic emphasized text (/word/)."
355 :group 'gnus-article-emphasis)
357 (defface gnus-emphasis-underline '((t (:underline t)))
358 "Face used for displaying underlined emphasized text (_word_)."
359 :group 'gnus-article-emphasis)
361 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
362 "Face used for displaying underlined bold emphasized text (_*word*_)."
363 :group 'gnus-article-emphasis)
365 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
366 "Face used for displaying underlined italic emphasized text (_/word/_)."
367 :group 'gnus-article-emphasis)
369 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
370 "Face used for displaying bold italic emphasized text (/*word*/)."
371 :group 'gnus-article-emphasis)
373 (defface gnus-emphasis-underline-bold-italic
374 '((t (:bold t :italic t :underline t)))
375 "Face used for displaying underlined bold italic emphasized text.
376 Example: (_/*word*/_)."
377 :group 'gnus-article-emphasis)
379 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
380 "Face used for displaying strike-through text (-word-)."
381 :group 'gnus-article-emphasis)
383 (defface gnus-emphasis-highlight-words
384 '((t (:background "black" :foreground "yellow")))
385 "Face used for displaying highlighted words."
386 :group 'gnus-article-emphasis)
388 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
389 "Format for display of Date headers in article bodies.
390 See `format-time-string' for the possible values.
392 The variable can also be function, which should return a complete Date
393 header. The function is called with one argument, the time, which can
394 be fed to `format-time-string'."
395 :type '(choice string symbol)
396 :link '(custom-manual "(gnus)Article Date")
397 :group 'gnus-article-washing)
400 (autoload 'mail-extract-address-components "mail-extr"))
402 (defcustom gnus-save-all-headers t
403 "*If non-nil, don't remove any headers before saving."
404 :group 'gnus-article-saving
407 (defcustom gnus-prompt-before-saving 'always
408 "*This variable says how much prompting is to be done when saving articles.
409 If it is nil, no prompting will be done, and the articles will be
410 saved to the default files. If this variable is `always', each and
411 every article that is saved will be preceded by a prompt, even when
412 saving large batches of articles. If this variable is neither nil not
413 `always', there the user will be prompted once for a file name for
414 each invocation of the saving commands."
415 :group 'gnus-article-saving
416 :type '(choice (item always)
417 (item :tag "never" nil)
418 (sexp :tag "once" :format "%t\n" :value t)))
420 (defcustom gnus-saved-headers gnus-visible-headers
421 "Headers to keep if `gnus-save-all-headers' is nil.
422 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
423 If that variable is nil, however, all headers that match this regexp
424 will be kept while the rest will be deleted before saving."
425 :group 'gnus-article-saving
428 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
429 "A function to save articles in your favourite format.
430 The function must be interactively callable (in other words, it must
431 be an Emacs command).
433 Gnus provides the following functions:
435 * gnus-summary-save-in-rmail (Rmail format)
436 * gnus-summary-save-in-mail (Unix mail format)
437 * gnus-summary-save-in-folder (MH folder)
438 * gnus-summary-save-in-file (article format)
439 * gnus-summary-save-body-in-file (article body)
440 * gnus-summary-save-in-vm (use VM's folder format)
441 * gnus-summary-write-to-file (article format -- overwrite)."
442 :group 'gnus-article-saving
443 :type '(radio (function-item gnus-summary-save-in-rmail)
444 (function-item gnus-summary-save-in-mail)
445 (function-item gnus-summary-save-in-folder)
446 (function-item gnus-summary-save-in-file)
447 (function-item gnus-summary-save-body-in-file)
448 (function-item gnus-summary-save-in-vm)
449 (function-item gnus-summary-write-to-file)))
451 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
452 "A function generating a file name to save articles in Rmail format.
453 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
454 :group 'gnus-article-saving
457 (defcustom gnus-mail-save-name 'gnus-plain-save-name
458 "A function generating a file name to save articles in Unix mail format.
459 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
460 :group 'gnus-article-saving
463 (defcustom gnus-folder-save-name 'gnus-folder-save-name
464 "A function generating a file name to save articles in MH folder.
465 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
466 :group 'gnus-article-saving
469 (defcustom gnus-file-save-name 'gnus-numeric-save-name
470 "A function generating a file name to save articles in article format.
471 The function is called with NEWSGROUP, HEADERS, and optional
473 :group 'gnus-article-saving
476 (defcustom gnus-split-methods
477 '((gnus-article-archive-name)
478 (gnus-article-nndoc-name))
479 "*Variable used to suggest where articles are to be saved.
480 For instance, if you would like to save articles related to Gnus in
481 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
482 you could set this variable to something like:
484 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
485 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
487 This variable is an alist where the where the key is the match and the
488 value is a list of possible files to save in if the match is non-nil.
490 If the match is a string, it is used as a regexp match on the
491 article. If the match is a symbol, that symbol will be funcalled
492 from the buffer of the article to be saved with the newsgroup as the
493 parameter. If it is a list, it will be evaled in the same buffer.
495 If this form or function returns a string, this string will be used as
496 a possible file name; and if it returns a non-nil list, that list will
497 be used as possible file names."
498 :group 'gnus-article-saving
499 :type '(repeat (choice (list :value (fun) function)
500 (cons :value ("" "") regexp (repeat string))
503 (defcustom gnus-page-delimiter "^\^L"
504 "*Regexp describing what to use as article page delimiters.
505 The default value is \"^\^L\", which is a form linefeed at the
506 beginning of a line."
508 :group 'gnus-article-various)
510 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
511 "*The format specification for the article mode line.
512 See `gnus-summary-mode-line-format' for a closer description.
514 The following additional specs are available:
516 %w The article washing status.
517 %m The number of MIME parts in the article."
519 :group 'gnus-article-various)
521 (defcustom gnus-article-mode-hook nil
522 "*A hook for Gnus article mode."
524 :group 'gnus-article-various)
526 (when (featurep 'xemacs)
527 ;; Extracted from gnus-xmas-define in order to preserve user settings
528 (when (fboundp 'turn-off-scroll-in-place)
529 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
530 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
531 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
533 (defcustom gnus-article-menu-hook nil
534 "*Hook run after the creation of the article mode menu."
536 :group 'gnus-article-various)
538 (defcustom gnus-article-prepare-hook nil
539 "*A hook called after an article has been prepared in the article buffer."
541 :group 'gnus-article-various)
543 (defcustom gnus-article-hide-pgp-hook nil
544 "*A hook called after successfully hiding a PGP signature."
546 :group 'gnus-article-various)
548 (defcustom gnus-article-button-face 'bold
549 "Face used for highlighting buttons in the article buffer.
551 An article button is a piece of text that you can activate by pressing
552 `RET' or `mouse-2' above it."
554 :group 'gnus-article-buttons)
556 (defcustom gnus-article-mouse-face 'highlight
557 "Face used for mouse highlighting in the article buffer.
559 Article buttons will be displayed in this face when the cursor is
562 :group 'gnus-article-buttons)
564 (defcustom gnus-signature-face 'gnus-signature-face
565 "Face used for highlighting a signature in the article buffer.
566 Obsolete; use the face `gnus-signature-face' for customizations instead."
568 :group 'gnus-article-highlight
569 :group 'gnus-article-signature)
571 (defface gnus-signature-face
574 "Face used for highlighting a signature in the article buffer."
575 :group 'gnus-article-highlight
576 :group 'gnus-article-signature)
578 (defface gnus-header-from-face
581 (:foreground "spring green"))
584 (:foreground "red3"))
587 "Face used for displaying from headers."
588 :group 'gnus-article-headers
589 :group 'gnus-article-highlight)
591 (defface gnus-header-subject-face
594 (:foreground "SeaGreen3"))
597 (:foreground "red4"))
599 (:bold t :italic t)))
600 "Face used for displaying subject headers."
601 :group 'gnus-article-headers
602 :group 'gnus-article-highlight)
604 (defface gnus-header-newsgroups-face
607 (:foreground "yellow" :italic t))
610 (:foreground "MidnightBlue" :italic t))
613 "Face used for displaying newsgroups headers."
614 :group 'gnus-article-headers
615 :group 'gnus-article-highlight)
617 (defface gnus-header-name-face
620 (:foreground "SeaGreen"))
623 (:foreground "maroon"))
626 "Face used for displaying header names."
627 :group 'gnus-article-headers
628 :group 'gnus-article-highlight)
630 (defface gnus-header-content-face
633 (:foreground "forest green" :italic t))
636 (:foreground "indianred4" :italic t))
638 (:italic t))) "Face used for displaying header content."
639 :group 'gnus-article-headers
640 :group 'gnus-article-highlight)
642 (defcustom gnus-header-face-alist
643 '(("From" nil gnus-header-from-face)
644 ("Subject" nil gnus-header-subject-face)
645 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
646 ("" gnus-header-name-face gnus-header-content-face))
647 "*Controls highlighting of article header.
649 An alist of the form (HEADER NAME CONTENT).
651 HEADER is a regular expression which should match the name of an
652 header header and NAME and CONTENT are either face names or nil.
654 The name of each header field will be displayed using the face
655 specified by the first element in the list where HEADER match the
656 header name and NAME is non-nil. Similarly, the content will be
657 displayed by the first non-nil matching CONTENT face."
658 :group 'gnus-article-headers
659 :group 'gnus-article-highlight
660 :type '(repeat (list (regexp :tag "Header")
662 (item :tag "skip" nil)
663 (face :value default))
664 (choice :tag "Content"
665 (item :tag "skip" nil)
666 (face :value default)))))
668 (defcustom gnus-article-decode-hook
669 '(article-decode-charset article-decode-encoded-words
670 article-decode-group-name)
671 "*Hook run to decode charsets in articles."
672 :group 'gnus-article-headers
675 (defcustom gnus-display-mime-function 'gnus-display-mime
676 "Function to display MIME articles."
677 :group 'gnus-article-mime
680 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
681 "Function used to decode headers.")
683 (defvar gnus-article-dumbquotes-map
703 "Table for MS-to-Latin1 translation.")
705 (defcustom gnus-ignored-mime-types nil
706 "List of MIME types that should be ignored by Gnus."
708 :group 'gnus-article-mime
709 :type '(repeat regexp))
711 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
712 "List of MIME types that should not be given buttons when rendered inline.
713 See also `gnus-buttonized-mime-types' which may override this variable."
715 :group 'gnus-article-mime
716 :type '(repeat regexp))
718 (defcustom gnus-buttonized-mime-types nil
719 "List of MIME types that should be given buttons when rendered inline.
720 If set, this variable overrides `gnus-unbuttonized-mime-types'.
721 To see e.g. security buttons you could set this to
722 `(\"multipart/signed\")'."
724 :group 'gnus-article-mime
725 :type '(repeat regexp))
727 (defcustom gnus-inhibit-mime-unbuttonizing nil
728 "If non-nil, all MIME parts get buttons.
729 When nil (the default value), then some MIME parts do not get buttons,
730 as described by the variables `gnus-buttonized-mime-types' and
731 `gnus-unbuttonized-mime-types'."
735 (defcustom gnus-body-boundary-delimiter "_"
736 "String used to delimit header and body.
737 This variable is used by `gnus-article-treat-body-boundary' which can
738 be controlled by `gnus-treat-body-boundary'."
739 :group 'gnus-article-various
740 :type '(choice (item :tag "None" :value nil)
743 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
744 "Defines the location of the faces database.
745 For information on obtaining this database of pretty pictures, please
746 see http://www.cs.indiana.edu/picons/ftp/index.html"
747 :type '(repeat directory)
748 :link '(url-link :tag "download"
749 "http://www.cs.indiana.edu/picons/ftp/index.html")
750 :link '(custom-manual "(gnus)Picons")
753 (defun gnus-picons-installed-p ()
754 "Say whether picons are installed on your machine."
755 (let ((installed nil))
756 (dolist (database gnus-picon-databases)
757 (when (file-exists-p database)
761 (defcustom gnus-article-mime-part-function nil
762 "Function called with a MIME handle as the argument.
763 This is meant for people who want to do something automatic based
764 on parts -- for instance, adding Vcard info to a database."
765 :group 'gnus-article-mime
768 (defcustom gnus-mime-multipart-functions nil
769 "An alist of MIME types to functions to display them."
771 :group 'gnus-article-mime
774 (defcustom gnus-article-date-lapsed-new-header nil
775 "Whether the X-Sent and Date headers can coexist.
776 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
777 either replace the old \"Date:\" header (if this variable is nil), or
778 be added below it (otherwise)."
780 :group 'gnus-article-headers
783 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
784 "Function called with a MIME handle as the argument.
785 This is meant for people who want to view first matched part.
786 For `undisplayed-alternative' (default), the first undisplayed
787 part or alternative part is used. For `undisplayed', the first
788 undisplayed part is used. For a function, the first part which
789 the function return `t' is used. For `nil', the first part is
792 :group 'gnus-article-mime
794 (item :tag "first" :value nil)
795 (item :tag "undisplayed" :value undisplayed)
796 (item :tag "undisplayed or alternative"
797 :value undisplayed-alternative)
800 (defcustom gnus-mime-action-alist
801 '(("save to file" . gnus-mime-save-part)
802 ("save and strip" . gnus-mime-save-part-and-strip)
803 ("display as text" . gnus-mime-inline-part)
804 ("view the part" . gnus-mime-view-part)
805 ("pipe to command" . gnus-mime-pipe-part)
806 ("toggle display" . gnus-article-press-button)
807 ("toggle display" . gnus-article-view-part-as-charset)
808 ("view as type" . gnus-mime-view-part-as-type)
809 ("view internally" . gnus-mime-view-part-internally)
810 ("view externally" . gnus-mime-view-part-externally))
811 "An alist of actions that run on the MIME attachment."
812 :group 'gnus-article-mime
813 :type '(repeat (cons (string :tag "name")
817 ;;; The treatment variables
820 (defvar gnus-part-display-hook nil
821 "Hook called on parts that are to receive treatment.")
823 (defvar gnus-article-treat-custom
824 '(choice (const :tag "Off" nil)
826 (const :tag "Header" head)
827 (const :tag "Last" last)
828 (integer :tag "Less")
829 (repeat :tag "Groups" regexp)
830 (sexp :tag "Predicate")))
832 (defvar gnus-article-treat-head-custom
833 '(choice (const :tag "Off" nil)
834 (const :tag "Header" head)))
836 (defvar gnus-article-treat-types '("text/plain")
839 (defvar gnus-inhibit-treatment nil
840 "Whether to inhibit treatment.")
842 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
843 "Highlight the signature.
844 Valid values are nil, t, `head', `last', an integer or a predicate.
845 See Info node `(gnus)Customizing Articles'."
846 :group 'gnus-article-treat
847 :link '(custom-manual "(gnus)Customizing Articles")
848 :type gnus-article-treat-custom)
849 (put 'gnus-treat-highlight-signature 'highlight t)
851 (defcustom gnus-treat-buttonize 100000
853 Valid values are nil, t, `head', `last', an integer or a predicate.
854 See Info node `(gnus)Customizing Articles'."
855 :group 'gnus-article-treat
856 :link '(custom-manual "(gnus)Customizing Articles")
857 :type gnus-article-treat-custom)
858 (put 'gnus-treat-buttonize 'highlight t)
860 (defcustom gnus-treat-buttonize-head 'head
861 "Add buttons to the head.
862 Valid values are nil, t, `head', `last', an integer or a predicate.
863 See Info node `(gnus)Customizing Articles' for details."
864 :group 'gnus-article-treat
865 :link '(custom-manual "(gnus)Customizing Articles")
866 :type gnus-article-treat-head-custom)
867 (put 'gnus-treat-buttonize-head 'highlight t)
869 (defcustom gnus-treat-emphasize
870 (and (or window-system
872 (>= (string-to-number emacs-version) 21))
875 Valid values are nil, t, `head', `last', an integer or a predicate.
876 See Info node `(gnus)Customizing Articles' for details."
877 :group 'gnus-article-treat
878 :link '(custom-manual "(gnus)Customizing Articles")
879 :type gnus-article-treat-custom)
880 (put 'gnus-treat-emphasize 'highlight t)
882 (defcustom gnus-treat-strip-cr nil
883 "Remove carriage returns.
884 Valid values are nil, t, `head', `last', an integer or a predicate.
885 See Info node `(gnus)Customizing Articles' for details."
886 :group 'gnus-article-treat
887 :link '(custom-manual "(gnus)Customizing Articles")
888 :type gnus-article-treat-custom)
890 (defcustom gnus-treat-unsplit-urls nil
891 "Remove newlines from within URLs.
892 Valid values are nil, t, `head', `last', an integer or a predicate.
893 See Info node `(gnus)Customizing Articles' for details."
894 :group 'gnus-article-treat
895 :link '(custom-manual "(gnus)Customizing Articles")
896 :type gnus-article-treat-custom)
898 (defcustom gnus-treat-leading-whitespace nil
899 "Remove leading whitespace in headers.
900 Valid values are nil, t, `head', `last', an integer or a predicate.
901 See Info node `(gnus)Customizing Articles' for details."
902 :group 'gnus-article-treat
903 :link '(custom-manual "(gnus)Customizing Articles")
904 :type gnus-article-treat-custom)
906 (defcustom gnus-treat-hide-headers 'head
908 Valid values are nil, t, `head', `last', an integer or a predicate.
909 See Info node `(gnus)Customizing Articles' for details."
910 :group 'gnus-article-treat
911 :link '(custom-manual "(gnus)Customizing Articles")
912 :type gnus-article-treat-head-custom)
914 (defcustom gnus-treat-hide-boring-headers nil
915 "Hide boring headers.
916 Valid values are nil, t, `head', `last', an integer or a predicate.
917 See Info node `(gnus)Customizing Articles' for details."
918 :group 'gnus-article-treat
919 :link '(custom-manual "(gnus)Customizing Articles")
920 :type gnus-article-treat-head-custom)
922 (defcustom gnus-treat-hide-signature nil
924 Valid values are nil, t, `head', `last', an integer or a predicate.
925 See Info node `(gnus)Customizing Articles' for details."
926 :group 'gnus-article-treat
927 :link '(custom-manual "(gnus)Customizing Articles")
928 :type gnus-article-treat-custom)
930 (defcustom gnus-treat-fill-article nil
932 Valid values are nil, t, `head', `last', an integer or a predicate.
933 See Info node `(gnus)Customizing Articles' for details."
934 :group 'gnus-article-treat
935 :link '(custom-manual "(gnus)Customizing Articles")
936 :type gnus-article-treat-custom)
938 (defcustom gnus-treat-hide-citation nil
940 Valid values are nil, t, `head', `last', an integer or a predicate.
941 See Info node `(gnus)Customizing Articles' for details."
942 :group 'gnus-article-treat
943 :link '(custom-manual "(gnus)Customizing Articles")
944 :type gnus-article-treat-custom)
946 (defcustom gnus-treat-hide-citation-maybe nil
948 Valid values are nil, t, `head', `last', an integer or a predicate.
949 See Info node `(gnus)Customizing Articles' for details."
950 :group 'gnus-article-treat
951 :link '(custom-manual "(gnus)Customizing Articles")
952 :type gnus-article-treat-custom)
954 (defcustom gnus-treat-strip-list-identifiers 'head
955 "Strip list identifiers from `gnus-list-identifiers`.
956 Valid values are nil, t, `head', `last', an integer or a predicate.
957 See Info node `(gnus)Customizing Articles' for details."
959 :group 'gnus-article-treat
960 :link '(custom-manual "(gnus)Customizing Articles")
961 :type gnus-article-treat-custom)
963 (defcustom gnus-treat-strip-pgp t
964 "Strip PGP signatures.
965 Valid values are nil, t, `head', `last', an integer or a predicate.
966 See Info node `(gnus)Customizing Articles' for details."
967 :group 'gnus-article-treat
968 :link '(custom-manual "(gnus)Customizing Articles")
969 :type gnus-article-treat-custom)
971 (defcustom gnus-treat-strip-pem nil
972 "Strip PEM signatures.
973 Valid values are nil, t, `head', `last', an integer or a predicate.
974 See Info node `(gnus)Customizing Articles' for details."
975 :group 'gnus-article-treat
976 :link '(custom-manual "(gnus)Customizing Articles")
977 :type gnus-article-treat-custom)
979 (defcustom gnus-treat-strip-banner t
980 "Strip banners from articles.
981 The banner to be stripped is specified in the `banner' group parameter.
982 Valid values are nil, t, `head', `last', an integer or a predicate.
983 See Info node `(gnus)Customizing Articles' for details."
984 :group 'gnus-article-treat
985 :link '(custom-manual "(gnus)Customizing Articles")
986 :type gnus-article-treat-custom)
988 (defcustom gnus-treat-highlight-headers 'head
989 "Highlight the headers.
990 Valid values are nil, t, `head', `last', an integer or a predicate.
991 See Info node `(gnus)Customizing Articles' for details."
992 :group 'gnus-article-treat
993 :link '(custom-manual "(gnus)Customizing Articles")
994 :type gnus-article-treat-head-custom)
995 (put 'gnus-treat-highlight-headers 'highlight t)
997 (defcustom gnus-treat-highlight-citation t
998 "Highlight cited text.
999 Valid values are nil, t, `head', `last', an integer or a predicate.
1000 See Info node `(gnus)Customizing Articles' for details."
1001 :group 'gnus-article-treat
1002 :link '(custom-manual "(gnus)Customizing Articles")
1003 :type gnus-article-treat-custom)
1004 (put 'gnus-treat-highlight-citation 'highlight t)
1006 (defcustom gnus-treat-date-ut nil
1007 "Display the Date in UT (GMT).
1008 Valid values are nil, t, `head', `last', an integer or a predicate.
1009 See Info node `(gnus)Customizing Articles' for details."
1010 :group 'gnus-article-treat
1011 :link '(custom-manual "(gnus)Customizing Articles")
1012 :type gnus-article-treat-head-custom)
1014 (defcustom gnus-treat-date-local nil
1015 "Display the Date in the local timezone.
1016 Valid values are nil, t, `head', `last', an integer or a predicate.
1017 See Info node `(gnus)Customizing Articles' for details."
1018 :group 'gnus-article-treat
1019 :link '(custom-manual "(gnus)Customizing Articles")
1020 :type gnus-article-treat-head-custom)
1022 (defcustom gnus-treat-date-english nil
1023 "Display the Date in a format that can be read aloud in English.
1024 Valid values are nil, t, `head', `last', an integer or a predicate.
1025 See Info node `(gnus)Customizing Articles' for details."
1026 :group 'gnus-article-treat
1027 :link '(custom-manual "(gnus)Customizing Articles")
1028 :type gnus-article-treat-head-custom)
1030 (defcustom gnus-treat-date-lapsed nil
1031 "Display the Date header in a way that says how much time has elapsed.
1032 Valid values are nil, t, `head', `last', an integer or a predicate.
1033 See Info node `(gnus)Customizing Articles' for details."
1034 :group 'gnus-article-treat
1035 :link '(custom-manual "(gnus)Customizing Articles")
1036 :type gnus-article-treat-head-custom)
1038 (defcustom gnus-treat-date-original nil
1039 "Display the date in the original timezone.
1040 Valid values are nil, t, `head', `last', an integer or a predicate.
1041 See Info node `(gnus)Customizing Articles' for details."
1042 :group 'gnus-article-treat
1043 :link '(custom-manual "(gnus)Customizing Articles")
1044 :type gnus-article-treat-head-custom)
1046 (defcustom gnus-treat-date-iso8601 nil
1047 "Display the date in the ISO8601 format.
1048 Valid values are nil, t, `head', `last', an integer or a predicate.
1049 See Info node `(gnus)Customizing Articles' for details."
1051 :group 'gnus-article-treat
1052 :link '(custom-manual "(gnus)Customizing Articles")
1053 :type gnus-article-treat-head-custom)
1055 (defcustom gnus-treat-date-user-defined nil
1056 "Display the date in a user-defined format.
1057 The format is defined by the `gnus-article-time-format' variable.
1058 Valid values are nil, t, `head', `last', an integer or a predicate.
1059 See Info node `(gnus)Customizing Articles' for details."
1060 :group 'gnus-article-treat
1061 :link '(custom-manual "(gnus)Customizing Articles")
1062 :type gnus-article-treat-head-custom)
1064 (defcustom gnus-treat-strip-headers-in-body t
1065 "Strip the X-No-Archive header line from the beginning of the body.
1066 Valid values are nil, t, `head', `last', an integer or a predicate.
1067 See Info node `(gnus)Customizing Articles' for details."
1069 :group 'gnus-article-treat
1070 :link '(custom-manual "(gnus)Customizing Articles")
1071 :type gnus-article-treat-custom)
1073 (defcustom gnus-treat-strip-trailing-blank-lines nil
1074 "Strip trailing blank lines.
1075 Valid values are nil, t, `head', `last', an integer or a predicate.
1076 See Info node `(gnus)Customizing Articles' for details."
1077 :group 'gnus-article-treat
1078 :link '(custom-manual "(gnus)Customizing Articles")
1079 :type gnus-article-treat-custom)
1081 (defcustom gnus-treat-strip-leading-blank-lines nil
1082 "Strip leading blank lines.
1083 Valid values are nil, t, `head', `last', an integer or a predicate.
1084 See Info node `(gnus)Customizing Articles' for details."
1085 :group 'gnus-article-treat
1086 :link '(custom-manual "(gnus)Customizing Articles")
1087 :type gnus-article-treat-custom)
1089 (defcustom gnus-treat-strip-multiple-blank-lines nil
1090 "Strip multiple blank lines.
1091 Valid values are nil, t, `head', `last', an integer or a predicate.
1092 See Info node `(gnus)Customizing Articles' for details."
1093 :group 'gnus-article-treat
1094 :link '(custom-manual "(gnus)Customizing Articles")
1095 :type gnus-article-treat-custom)
1097 (defcustom gnus-treat-unfold-headers 'head
1098 "Unfold folded header lines.
1099 Valid values are nil, t, `head', `last', an integer or a predicate.
1100 See Info node `(gnus)Customizing Articles' for details."
1101 :group 'gnus-article-treat
1102 :link '(custom-manual "(gnus)Customizing Articles")
1103 :type gnus-article-treat-custom)
1105 (defcustom gnus-treat-fold-headers nil
1107 Valid values are nil, t, `head', `last', an integer or a predicate.
1108 See Info node `(gnus)Customizing Articles' for details."
1109 :group 'gnus-article-treat
1110 :link '(custom-manual "(gnus)Customizing Articles")
1111 :type gnus-article-treat-custom)
1113 (defcustom gnus-treat-fold-newsgroups 'head
1114 "Fold the Newsgroups and Followup-To headers.
1115 Valid values are nil, t, `head', `last', an integer or a predicate.
1116 See Info node `(gnus)Customizing Articles' for details."
1117 :group 'gnus-article-treat
1118 :link '(custom-manual "(gnus)Customizing Articles")
1119 :type gnus-article-treat-custom)
1121 (defcustom gnus-treat-overstrike t
1122 "Treat overstrike highlighting.
1123 Valid values are nil, t, `head', `last', an integer or a predicate.
1124 See Info node `(gnus)Customizing Articles' for details."
1125 :group 'gnus-article-treat
1126 :link '(custom-manual "(gnus)Customizing Articles")
1127 :type gnus-article-treat-custom)
1128 (put 'gnus-treat-overstrike 'highlight t)
1130 (defcustom gnus-treat-display-xface
1131 (and (not noninteractive)
1132 (or (and (fboundp 'image-type-available-p)
1133 (image-type-available-p 'xbm)
1134 (string-match "^0x" (shell-command-to-string "uncompface")))
1135 (and (featurep 'xemacs)
1138 "Display X-Face headers.
1139 Valid values are nil, t, `head', `last', an integer or a predicate.
1140 See Info node `(gnus)Customizing Articles' and Info node
1141 `(gnus)X-Face' for details."
1142 :group 'gnus-article-treat
1144 :link '(custom-manual "(gnus)Customizing Articles")
1145 :link '(custom-manual "(gnus)X-Face")
1146 :type gnus-article-treat-head-custom)
1147 (put 'gnus-treat-display-xface 'highlight t)
1149 (defcustom gnus-treat-display-grey-xface
1150 (and (not noninteractive)
1151 (string-match "^0x" (shell-command-to-string "uncompface"))
1153 "Display grey X-Face headers.
1154 Valid values are nil, t."
1155 :group 'gnus-article-treat
1158 (put 'gnus-treat-display-grey-xface 'highlight t)
1160 (defcustom gnus-treat-display-smileys
1161 (if (or (and (featurep 'xemacs)
1163 (and (fboundp 'image-type-available-p)
1164 (image-type-available-p 'pbm)))
1167 Valid values are nil, t, `head', `last', an integer or a predicate.
1168 See Info node `(gnus)Customizing Articles' and Info node
1169 `(gnus)Smileys' for details."
1170 :group 'gnus-article-treat
1172 :link '(custom-manual "(gnus)Customizing Articles")
1173 :link '(custom-manual "(gnus)Smileys")
1174 :type gnus-article-treat-custom)
1175 (put 'gnus-treat-display-smileys 'highlight t)
1177 (defcustom gnus-treat-from-picon
1178 (if (and (gnus-image-type-available-p 'xpm)
1179 (gnus-picons-installed-p))
1181 "Display picons in the From header.
1182 Valid values are nil, t, `head', `last', an integer or a predicate.
1183 See Info node `(gnus)Customizing Articles' and Info node
1184 `(gnus)Picons' for details."
1185 :group 'gnus-article-treat
1187 :link '(custom-manual "(gnus)Customizing Articles")
1188 :link '(custom-manual "(gnus)Picons")
1189 :type gnus-article-treat-head-custom)
1190 (put 'gnus-treat-from-picon 'highlight t)
1192 (defcustom gnus-treat-mail-picon
1193 (if (and (gnus-image-type-available-p 'xpm)
1194 (gnus-picons-installed-p))
1196 "Display picons in To and Cc headers.
1197 Valid values are nil, t, `head', `last', an integer or a predicate.
1198 See Info node `(gnus)Customizing Articles' and Info node
1199 `(gnus)Picons' for details."
1200 :group 'gnus-article-treat
1202 :link '(custom-manual "(gnus)Customizing Articles")
1203 :link '(custom-manual "(gnus)Picons")
1204 :type gnus-article-treat-head-custom)
1205 (put 'gnus-treat-mail-picon 'highlight t)
1207 (defcustom gnus-treat-newsgroups-picon
1208 (if (and (gnus-image-type-available-p 'xpm)
1209 (gnus-picons-installed-p))
1211 "Display picons in the Newsgroups and Followup-To headers.
1212 Valid values are nil, t, `head', `last', an integer or a predicate.
1213 See Info node `(gnus)Customizing Articles' and Info node
1214 `(gnus)Picons' for details."
1215 :group 'gnus-article-treat
1217 :link '(custom-manual "(gnus)Customizing Articles")
1218 :link '(custom-manual "(gnus)Picons")
1219 :type gnus-article-treat-head-custom)
1220 (put 'gnus-treat-newsgroups-picon 'highlight t)
1222 (defcustom gnus-treat-body-boundary
1223 (if (or gnus-treat-newsgroups-picon
1224 gnus-treat-mail-picon
1225 gnus-treat-from-picon)
1227 "Draw a boundary at the end of the headers.
1228 Valid values are nil, t, `head', `last', an integer or a predicate.
1229 See Info node `(gnus)Customizing Articles' for details."
1231 :group 'gnus-article-treat
1232 :link '(custom-manual "(gnus)Customizing Articles")
1233 :type gnus-article-treat-custom)
1235 (defcustom gnus-treat-capitalize-sentences nil
1236 "Capitalize sentence-starting words.
1237 Valid values are nil, t, `head', `last', an integer or a predicate.
1238 See Info node `(gnus)Customizing Articles' for details."
1240 :group 'gnus-article-treat
1241 :link '(custom-manual "(gnus)Customizing Articles")
1242 :type gnus-article-treat-custom)
1244 (defcustom gnus-treat-fill-long-lines nil
1246 Valid values are nil, t, `head', `last', an integer or a predicate.
1247 See Info node `(gnus)Customizing Articles' for details."
1248 :group 'gnus-article-treat
1249 :link '(custom-manual "(gnus)Customizing Articles")
1250 :type gnus-article-treat-custom)
1252 (defcustom gnus-treat-play-sounds nil
1254 Valid values are nil, t, `head', `last', an integer or a predicate.
1255 See Info node `(gnus)Customizing Articles' for details."
1257 :group 'gnus-article-treat
1258 :link '(custom-manual "(gnus)Customizing Articles")
1259 :type gnus-article-treat-custom)
1261 (defcustom gnus-treat-translate nil
1262 "Translate articles from one language to another.
1263 Valid values are nil, t, `head', `last', an integer or a predicate.
1264 See Info node `(gnus)Customizing Articles' for details."
1266 :group 'gnus-article-treat
1267 :link '(custom-manual "(gnus)Customizing Articles")
1268 :type gnus-article-treat-custom)
1270 (defcustom gnus-treat-x-pgp-sig nil
1272 To automatically treat X-PGP-Sig, set it to head.
1273 Valid values are nil, t, `head', `last', an integer or a predicate.
1274 See Info node `(gnus)Customizing Articles' for details."
1275 :group 'gnus-article-treat
1276 :group 'mime-security
1277 :link '(custom-manual "(gnus)Customizing Articles")
1278 :type gnus-article-treat-custom)
1280 (defvar gnus-article-encrypt-protocol-alist
1281 '(("PGP" . mml2015-self-encrypt)))
1283 ;; Set to nil if more than one protocol added to
1284 ;; gnus-article-encrypt-protocol-alist.
1285 (defcustom gnus-article-encrypt-protocol "PGP"
1286 "The protocol used for encrypt articles.
1287 It is a string, such as \"PGP\". If nil, ask user."
1289 :group 'mime-security)
1291 (defvar gnus-article-wash-function nil
1292 "Function used for converting HTML into text.")
1294 ;;; Internal variables
1296 (defvar gnus-english-month-names
1297 '("January" "February" "March" "April" "May" "June" "July" "August"
1298 "September" "October" "November" "December"))
1300 (defvar article-goto-body-goes-to-point-min-p nil)
1301 (defvar gnus-article-wash-types nil)
1302 (defvar gnus-article-emphasis-alist nil)
1303 (defvar gnus-article-image-alist nil)
1305 (defvar gnus-article-mime-handle-alist-1 nil)
1306 (defvar gnus-treatment-function-alist
1307 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1308 (gnus-treat-strip-banner gnus-article-strip-banner)
1309 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1310 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1311 (gnus-treat-buttonize gnus-article-add-buttons)
1312 (gnus-treat-fill-article gnus-article-fill-cited-article)
1313 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1314 (gnus-treat-strip-cr gnus-article-remove-cr)
1315 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1316 (gnus-treat-date-ut gnus-article-date-ut)
1317 (gnus-treat-date-local gnus-article-date-local)
1318 (gnus-treat-date-english gnus-article-date-english)
1319 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1320 (gnus-treat-date-original gnus-article-date-original)
1321 (gnus-treat-date-user-defined gnus-article-date-user)
1322 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1323 (gnus-treat-display-xface gnus-article-display-x-face)
1324 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1325 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1326 (gnus-treat-hide-signature gnus-article-hide-signature)
1327 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1328 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1329 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1330 (gnus-treat-strip-pem gnus-article-hide-pem)
1331 (gnus-treat-from-picon gnus-treat-from-picon)
1332 (gnus-treat-mail-picon gnus-treat-mail-picon)
1333 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1334 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1335 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1336 (gnus-treat-strip-trailing-blank-lines
1337 gnus-article-remove-trailing-blank-lines)
1338 (gnus-treat-strip-leading-blank-lines
1339 gnus-article-strip-leading-blank-lines)
1340 (gnus-treat-strip-multiple-blank-lines
1341 gnus-article-strip-multiple-blank-lines)
1342 (gnus-treat-overstrike gnus-article-treat-overstrike)
1343 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1344 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1345 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1346 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1347 (gnus-treat-display-smileys gnus-treat-smiley)
1348 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1349 (gnus-treat-emphasize gnus-article-emphasize)
1350 (gnus-treat-hide-citation gnus-article-hide-citation)
1351 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1352 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1353 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1354 (gnus-treat-play-sounds gnus-earcon-display)))
1356 (defvar gnus-article-mime-handle-alist nil)
1357 (defvar article-lapsed-timer nil)
1358 (defvar gnus-article-current-summary nil)
1360 (defvar gnus-article-mode-syntax-table
1361 (let ((table (copy-syntax-table text-mode-syntax-table)))
1362 ;; This causes the citation match run O(2^n).
1363 ;; (modify-syntax-entry ?- "w" table)
1364 (modify-syntax-entry ?> ")<" table)
1365 (modify-syntax-entry ?< "(>" table)
1366 ;; make M-. in article buffers work for `foo' strings
1367 (modify-syntax-entry ?' " " table)
1368 (modify-syntax-entry ?` " " table)
1370 "Syntax table used in article mode buffers.
1371 Initialized from `text-mode-syntax-table.")
1373 (defvar gnus-save-article-buffer nil)
1375 (defvar gnus-article-mode-line-format-alist
1376 (nconc '((?w (gnus-article-wash-status) ?s)
1377 (?m (gnus-article-mime-part-status) ?s))
1378 gnus-summary-mode-line-format-alist))
1380 (defvar gnus-number-of-articles-to-be-saved nil)
1382 (defvar gnus-inhibit-hiding nil)
1384 ;;; Macros for dealing with the article buffer.
1386 (defmacro gnus-with-article-headers (&rest forms)
1388 (set-buffer gnus-article-buffer)
1390 (let ((buffer-read-only nil)
1391 (inhibit-point-motion-hooks t)
1392 (case-fold-search t))
1393 (article-narrow-to-head)
1396 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1397 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1399 (defmacro gnus-with-article-buffer (&rest forms)
1401 (set-buffer gnus-article-buffer)
1402 (let ((buffer-read-only nil))
1405 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1406 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1408 (defun gnus-article-goto-header (header)
1409 "Go to HEADER, which is a regular expression."
1410 (re-search-forward (concat "^\\(" header "\\):") nil t))
1412 (defsubst gnus-article-hide-text (b e props)
1413 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1414 (gnus-add-text-properties-when 'article-type nil b e props)
1415 (when (memq 'intangible props)
1417 (max (1- b) (point-min))
1418 b 'intangible (cddr (memq 'intangible props)))))
1420 (defsubst gnus-article-unhide-text (b e)
1421 "Remove hidden text properties from region between B and E."
1422 (remove-text-properties b e gnus-hidden-properties)
1423 (when (memq 'intangible gnus-hidden-properties)
1424 (put-text-property (max (1- b) (point-min))
1425 b 'intangible nil)))
1427 (defun gnus-article-hide-text-type (b e type)
1428 "Hide text of TYPE between B and E."
1429 (gnus-add-wash-type type)
1430 (gnus-article-hide-text
1431 b e (cons 'article-type (cons type gnus-hidden-properties))))
1433 (defun gnus-article-unhide-text-type (b e type)
1434 "Unhide text of TYPE between B and E."
1435 (gnus-delete-wash-type type)
1436 (remove-text-properties
1437 b e (cons 'article-type (cons type gnus-hidden-properties)))
1438 (when (memq 'intangible gnus-hidden-properties)
1439 (put-text-property (max (1- b) (point-min))
1440 b 'intangible nil)))
1442 (defun gnus-article-hide-text-of-type (type)
1443 "Hide text of TYPE in the current buffer."
1445 (let ((b (point-min))
1447 (while (setq b (text-property-any b e 'article-type type))
1448 (add-text-properties b (incf b) gnus-hidden-properties)))))
1450 (defun gnus-article-delete-text-of-type (type)
1451 "Delete text of TYPE in the current buffer."
1453 (let ((b (point-min)))
1454 (while (setq b (text-property-any b (point-max) 'article-type type))
1456 b (or (text-property-not-all b (point-max) 'article-type type)
1459 (defun gnus-article-delete-invisible-text ()
1460 "Delete all invisible text in the current buffer."
1462 (let ((b (point-min)))
1463 (while (setq b (text-property-any b (point-max) 'invisible t))
1465 b (or (text-property-not-all b (point-max) 'invisible t)
1468 (defun gnus-article-text-type-exists-p (type)
1469 "Say whether any text of type TYPE exists in the buffer."
1470 (text-property-any (point-min) (point-max) 'article-type type))
1472 (defsubst gnus-article-header-rank ()
1473 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1474 (let ((list gnus-sorted-header-list)
1477 (if (looking-at (car list))
1479 (setq list (cdr list))
1483 (defun article-hide-headers (&optional arg delete)
1484 "Hide unwanted headers and possibly sort them as well."
1486 ;; This function might be inhibited.
1487 (unless gnus-inhibit-hiding
1490 (let ((buffer-read-only nil)
1491 (case-fold-search t)
1492 (max (1+ (length gnus-sorted-header-list)))
1493 (ignored (when (not gnus-visible-headers)
1494 (cond ((stringp gnus-ignored-headers)
1495 gnus-ignored-headers)
1496 ((listp gnus-ignored-headers)
1497 (mapconcat 'identity gnus-ignored-headers
1500 (cond ((stringp gnus-visible-headers)
1501 gnus-visible-headers)
1502 ((and gnus-visible-headers
1503 (listp gnus-visible-headers))
1504 (mapconcat 'identity gnus-visible-headers "\\|"))))
1505 (inhibit-point-motion-hooks t)
1507 ;; First we narrow to just the headers.
1508 (article-narrow-to-head)
1509 ;; Hide any "From " lines at the beginning of (mail) articles.
1510 (while (looking-at "From ")
1513 (delete-region (point-min) (point)))
1514 ;; Then treat the rest of the header lines.
1515 ;; Then we use the two regular expressions
1516 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1517 ;; select which header lines is to remain visible in the
1519 (while (re-search-forward "^[^ \t:]*:" nil t)
1521 ;; Mark the rank of the header.
1523 (point) (1+ (point)) 'message-rank
1524 (if (or (and visible (looking-at visible))
1526 (not (looking-at ignored))))
1527 (gnus-article-header-rank)
1530 (message-sort-headers-1)
1531 (when (setq beg (text-property-any
1532 (point-min) (point-max) 'message-rank (+ 2 max)))
1533 ;; We delete the unwanted headers.
1534 (gnus-add-wash-type 'headers)
1535 (add-text-properties (point-min) (+ 5 (point-min))
1536 '(article-type headers dummy-invisible t))
1537 (delete-region beg (point-max))))))))
1539 (defun article-hide-boring-headers (&optional arg)
1540 "Toggle hiding of headers that aren't very interesting.
1541 If given a negative prefix, always show; if given a positive prefix,
1543 (interactive (gnus-article-hidden-arg))
1544 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1545 (not gnus-show-all-headers))
1548 (let ((buffer-read-only nil)
1549 (list gnus-boring-article-headers)
1550 (inhibit-point-motion-hooks t)
1552 (article-narrow-to-head)
1554 (setq elem (pop list))
1555 (goto-char (point-min))
1557 ;; Hide empty headers.
1559 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1561 (gnus-article-hide-text-type
1562 (progn (beginning-of-line) (point))
1565 (if (re-search-forward "^[^ \t]" nil t)
1569 ;; Hide boring Newsgroups header.
1570 ((eq elem 'newsgroups)
1571 (when (gnus-string-equal
1572 (gnus-fetch-field "newsgroups")
1573 (gnus-group-real-name
1574 (if (boundp 'gnus-newsgroup-name)
1577 (gnus-article-hide-header "newsgroups")))
1578 ((eq elem 'to-address)
1579 (let ((to (message-fetch-field "to"))
1581 (gnus-parameter-to-address
1582 (if (boundp 'gnus-newsgroup-name)
1583 gnus-newsgroup-name ""))))
1584 (when (and to to-address
1587 ;; only one address in To
1588 (nth 1 (mail-extract-address-components to))
1590 (gnus-article-hide-header "to"))))
1591 ((eq elem 'followup-to)
1592 (when (gnus-string-equal
1593 (message-fetch-field "followup-to")
1594 (message-fetch-field "newsgroups"))
1595 (gnus-article-hide-header "followup-to")))
1596 ((eq elem 'reply-to)
1597 (let ((from (message-fetch-field "from"))
1598 (reply-to (message-fetch-field "reply-to")))
1603 (nth 1 (mail-extract-address-components from))
1604 (nth 1 (mail-extract-address-components reply-to)))))
1605 (gnus-article-hide-header "reply-to"))))
1607 (let ((date (message-fetch-field "date")))
1609 (< (days-between (current-time-string) date)
1611 (gnus-article-hide-header "date"))))
1613 (let ((to (message-fetch-field "to"))
1614 (cc (message-fetch-field "cc")))
1615 (when (> (length to) 1024)
1616 (gnus-article-hide-header "to"))
1617 (when (> (length cc) 1024)
1618 (gnus-article-hide-header "cc"))))
1622 (goto-char (point-min))
1623 (while (re-search-forward "^to:" nil t)
1624 (setq to-count (1+ to-count)))
1625 (when (> to-count 1)
1626 (while (> to-count 0)
1627 (goto-char (point-min))
1629 (re-search-forward "^to:" nil nil to-count)
1631 (narrow-to-region (point) (point-max))
1632 (gnus-article-hide-header "to"))
1633 (setq to-count (1- to-count))))
1634 (goto-char (point-min))
1635 (while (re-search-forward "^cc:" nil t)
1636 (setq cc-count (1+ cc-count)))
1637 (when (> cc-count 1)
1638 (while (> cc-count 0)
1639 (goto-char (point-min))
1641 (re-search-forward "^cc:" nil nil cc-count)
1643 (narrow-to-region (point) (point-max))
1644 (gnus-article-hide-header "cc"))
1645 (setq cc-count (1- cc-count)))))))))))))
1647 (defun gnus-article-hide-header (header)
1649 (goto-char (point-min))
1650 (when (re-search-forward (concat "^" header ":") nil t)
1651 (gnus-article-hide-text-type
1652 (progn (beginning-of-line) (point))
1655 (if (re-search-forward "^[^ \t]" nil t)
1660 (defvar gnus-article-normalized-header-length 40
1661 "Length of normalized headers.")
1663 (defun article-normalize-headers ()
1664 "Make all header lines 40 characters long."
1666 (let ((buffer-read-only nil)
1670 (article-narrow-to-head)
1673 ((< (setq column (- (gnus-point-at-eol) (point)))
1674 gnus-article-normalized-header-length)
1676 (insert (make-string
1677 (- gnus-article-normalized-header-length column)
1679 ((> column gnus-article-normalized-header-length)
1680 (gnus-put-text-property
1682 (forward-char gnus-article-normalized-header-length)
1689 (forward-line 1))))))
1691 (defun article-treat-dumbquotes ()
1692 "Translate M****s*** sm*rtq**t*s into proper text.
1693 Note that this function guesses whether a character is a sm*rtq**t* or
1694 not, so it should only be used interactively.
1696 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1697 in an attempt to provide more quoting characters. If you see
1698 something like \\222 or \\264 where you're expecting some kind of
1699 apostrophe or quotation mark, then try this wash."
1701 (article-translate-strings gnus-article-dumbquotes-map))
1703 (defun article-translate-characters (from to)
1704 "Translate all characters in the body of the article according to FROM and TO.
1705 FROM is a string of characters to translate from; to is a string of
1706 characters to translate to."
1708 (when (article-goto-body)
1709 (let ((buffer-read-only nil)
1710 (x (make-string 225 ?x))
1712 (while (< (incf i) (length x))
1715 (while (< i (length from))
1716 (aset x (aref from i) (aref to i))
1718 (translate-region (point) (point-max) x)))))
1720 (defun article-translate-strings (map)
1721 "Translate all string in the body of the article according to MAP.
1722 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1724 (when (article-goto-body)
1725 (let ((buffer-read-only nil)
1727 (while (setq elem (pop map))
1729 (while (search-forward (car elem) nil t)
1730 (replace-match (cadr elem)))))))))
1732 (defun article-treat-overstrike ()
1733 "Translate overstrikes into bold text."
1736 (when (article-goto-body)
1737 (let ((buffer-read-only nil))
1738 (while (search-forward "\b" nil t)
1739 (let ((next (char-after))
1740 (previous (char-after (- (point) 2))))
1741 ;; We do the boldification/underlining by hiding the
1742 ;; overstrikes and putting the proper text property
1746 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1747 (put-text-property (point) (1+ (point)) 'face 'bold))
1749 (gnus-article-hide-text-type
1750 (1- (point)) (1+ (point)) 'overstrike)
1752 (- (point) 2) (1- (point)) 'face 'underline))
1754 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1756 (point) (1+ (point)) 'face 'underline)))))))))
1758 (defun gnus-article-treat-unfold-headers ()
1759 "Unfold folded message headers.
1760 Only the headers that fit into the current window width will be
1763 (gnus-with-article-headers
1767 (mail-header-narrow-to-field)
1768 (let ((header (buffer-substring (point-min) (point-max))))
1771 (goto-char (point-min))
1772 (while (re-search-forward "\n[\t ]" nil t)
1773 (replace-match " " t t)))
1774 (setq length (- (point-max) (point-min) 1)))
1775 (when (< length (window-width))
1776 (while (re-search-forward "\n[\t ]" nil t)
1777 (replace-match " " t t)))
1778 (goto-char (point-max)))))))
1780 (defun gnus-article-treat-fold-headers ()
1781 "Fold message headers."
1783 (gnus-with-article-headers
1786 (mail-header-narrow-to-field)
1787 (mail-header-fold-field)
1788 (goto-char (point-max))))))
1790 (defun gnus-treat-smiley ()
1791 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1793 (gnus-with-article-buffer
1794 (if (memq 'smiley gnus-article-wash-types)
1795 (gnus-delete-images 'smiley)
1797 (let ((images (smiley-region (point) (point-max))))
1799 (gnus-add-wash-type 'smiley)
1800 (dolist (image images)
1801 (gnus-add-image 'smiley image)))))))
1803 (defun gnus-article-remove-images ()
1804 "Remove all images from the article buffer."
1806 (gnus-with-article-buffer
1807 (dolist (elem gnus-article-image-alist)
1808 (gnus-delete-images (car elem)))))
1810 (defun gnus-article-treat-fold-newsgroups ()
1811 "Unfold folded message headers.
1812 Only the headers that fit into the current window width will be
1815 (gnus-with-article-headers
1816 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1818 (mail-header-narrow-to-field)
1819 (while (re-search-forward ", *" nil t)
1820 (replace-match ", " t t))
1821 (mail-header-fold-field)
1822 (goto-char (point-max))))))
1824 (defun gnus-article-treat-body-boundary ()
1825 "Place a boundary line at the end of the headers."
1827 (when (and gnus-body-boundary-delimiter
1828 (> (length gnus-body-boundary-delimiter) 0))
1829 (gnus-with-article-headers
1830 (goto-char (point-max))
1831 (let ((start (point)))
1832 (insert "X-Boundary: ")
1833 (gnus-add-text-properties start (point) '(invisible t intangible t))
1835 (while (>= (1- (window-width)) (length str))
1836 (setq str (concat str gnus-body-boundary-delimiter)))
1837 (substring str 0 (1- (window-width))))
1839 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1841 (defun article-fill-long-lines ()
1842 "Fill lines that are wider than the window width."
1845 (let ((buffer-read-only nil)
1846 (width (window-width (get-buffer-window (current-buffer)))))
1849 (let ((adaptive-fill-mode nil)) ;Why? -sm
1852 (when (>= (current-column) (min fill-column width))
1853 (narrow-to-region (min (1+ (point)) (point-max)) (gnus-point-at-bol))
1854 (let ((goback (point-marker)))
1855 (fill-paragraph nil)
1856 (goto-char (marker-position goback)))
1858 (forward-line 1)))))))
1860 (defun article-capitalize-sentences ()
1861 "Capitalize the first word in each sentence."
1864 (let ((buffer-read-only nil)
1865 (paragraph-start "^[\n\^L]"))
1869 (forward-sentence)))))
1871 (defun article-remove-cr ()
1872 "Remove trailing CRs and then translate remaining CRs into LFs."
1875 (let ((buffer-read-only nil))
1876 (goto-char (point-min))
1877 (while (re-search-forward "\r+$" nil t)
1878 (replace-match "" t t))
1879 (goto-char (point-min))
1880 (while (search-forward "\r" nil t)
1881 (replace-match "\n" t t)))))
1883 (defun article-remove-trailing-blank-lines ()
1884 "Remove all trailing blank lines from the article."
1887 (let ((buffer-read-only nil))
1888 (goto-char (point-max))
1892 (while (and (not (bobp))
1893 (looking-at "^[ \t]*$")
1894 (not (gnus-annotation-in-region-p
1895 (point) (gnus-point-at-eol))))
1900 (defun article-display-x-face (&optional force)
1901 "Look for an X-Face header and display it if present."
1902 (interactive (list 'force))
1903 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1904 (gnus-with-article-headers
1905 ;; Delete the old process, if any.
1906 (when (process-status "article-x-face")
1907 (delete-process "article-x-face"))
1908 (if (memq 'xface gnus-article-wash-types)
1909 ;; We have already displayed X-Faces, so we remove them
1911 (gnus-delete-images 'xface)
1913 (let (x-faces from face grey)
1915 (when (and wash-face-p
1917 (goto-char (point-min))
1918 (not (re-search-forward
1919 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
1920 (gnus-buffer-live-p gnus-original-article-buffer))
1921 ;; If type `W f', use gnus-original-article-buffer,
1922 ;; otherwise use the current buffer because displaying
1923 ;; RFC822 parts calls this function too.
1924 (set-buffer gnus-original-article-buffer))
1926 (mail-narrow-to-head)
1927 (if gnus-treat-display-grey-xface
1929 (while (gnus-article-goto-header "X-Face\\(-[0-9]+\\)?")
1930 (if (match-beginning 2)
1933 (push (cons (- (string-to-number (match-string 2)))
1934 (mail-header-field-value))
1936 (push (cons 0 (mail-header-field-value)) x-faces)))
1937 (dolist (x-face (prog1
1939 (sort x-faces 'car-less-than-car)
1941 (setq x-faces nil)))
1942 (push (cdr x-face) x-faces)))
1943 (while (gnus-article-goto-header "X-Face")
1944 (push (mail-header-field-value) x-faces)))
1945 (setq from (message-fetch-field "from"))))
1947 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
1950 (setq image (gnus-create-image xpm 'xpm t))
1951 (gnus-article-goto-header "from")
1953 (insert "From: [no `from' set]\n")
1955 (gnus-add-wash-type 'xface)
1956 (gnus-add-image 'xface image)
1957 (gnus-put-image image)))
1958 ;; Sending multiple EOFs to xv doesn't work, so we only do a
1959 ;; single external face.
1960 (when (stringp gnus-article-x-face-command)
1961 (setq x-faces (list (car x-faces))))
1962 (while (and (setq face (pop x-faces))
1963 gnus-article-x-face-command
1965 ;; Check whether this face is censored.
1966 (not gnus-article-x-face-too-ugly)
1967 (and gnus-article-x-face-too-ugly from
1968 (not (string-match gnus-article-x-face-too-ugly
1970 ;; We display the face.
1971 (if (symbolp gnus-article-x-face-command)
1972 ;; The command is a lisp function, so we call it.
1973 (if (gnus-functionp gnus-article-x-face-command)
1974 (funcall gnus-article-x-face-command face)
1975 (error "%s is not a function" gnus-article-x-face-command))
1976 ;; The command is a string, so we interpret the command
1977 ;; as a, well, command, and fork it off.
1978 (let ((process-connection-type nil))
1979 (process-kill-without-query
1981 "article-x-face" nil shell-file-name shell-command-switch
1982 gnus-article-x-face-command))
1985 (process-send-region "article-x-face"
1986 (point-min) (point-max)))
1987 (process-send-eof "article-x-face"))))))))))
1989 (defun article-decode-mime-words ()
1990 "Decode all MIME-encoded words in the article."
1993 (set-buffer gnus-article-buffer)
1994 (let ((inhibit-point-motion-hooks t)
1996 (mail-parse-charset gnus-newsgroup-charset)
1997 (mail-parse-ignored-charsets
1998 (save-excursion (set-buffer gnus-summary-buffer)
1999 gnus-newsgroup-ignored-charsets)))
2000 (mail-decode-encoded-word-region (point-min) (point-max)))))
2002 (defun article-decode-charset (&optional prompt)
2003 "Decode charset-encoded text in the article.
2004 If PROMPT (the prefix), prompt for a coding system to use."
2006 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2008 (mail-parse-charset gnus-newsgroup-charset)
2009 (mail-parse-ignored-charsets
2010 (save-excursion (condition-case nil
2011 (set-buffer gnus-summary-buffer)
2013 gnus-newsgroup-ignored-charsets))
2014 ct cte ctl charset format)
2017 (article-narrow-to-head)
2018 (setq ct (message-fetch-field "Content-Type" t)
2019 cte (message-fetch-field "Content-Transfer-Encoding" t)
2020 ctl (and ct (ignore-errors
2021 (mail-header-parse-content-type ct)))
2024 (mm-read-coding-system "Charset to decode: "))
2026 (mail-content-type-get ctl 'charset)))
2027 format (and ctl (mail-content-type-get ctl 'format)))
2029 (setq cte (mail-header-strip cte)))
2030 (if (and ctl (not (string-match "/" (car ctl))))
2032 (goto-char (point-max)))
2035 (narrow-to-region (point) (point-max))
2036 (when (and (eq mail-parse-charset 'gnus-decoded)
2037 (eq (mm-body-7-or-8) '8bit))
2038 ;; The text code could have been decoded.
2039 (setq charset mail-parse-charset))
2040 (when (and (or (not ctl)
2041 (equal (car ctl) "text/plain"))
2042 (not format)) ;; article with format will decode later.
2044 charset (and cte (intern (downcase
2045 (gnus-strip-whitespace cte))))
2048 (defun article-decode-encoded-words ()
2049 "Remove encoded-word encoding from headers."
2050 (let ((inhibit-point-motion-hooks t)
2051 (mail-parse-charset gnus-newsgroup-charset)
2052 (mail-parse-ignored-charsets
2053 (save-excursion (condition-case nil
2054 (set-buffer gnus-summary-buffer)
2056 gnus-newsgroup-ignored-charsets))
2059 (article-narrow-to-head)
2060 (funcall gnus-decode-header-function (point-min) (point-max)))))
2062 (defun article-decode-group-name ()
2063 "Decode group names in `Newsgroups:'."
2064 (let ((inhibit-point-motion-hooks t)
2066 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2067 (when (and (or gnus-group-name-charset-method-alist
2068 gnus-group-name-charset-group-alist)
2069 (gnus-buffer-live-p gnus-original-article-buffer))
2070 (when (nnmail-fetch-field "Newsgroups")
2071 (nnheader-replace-header "Newsgroups"
2072 (gnus-decode-newsgroups
2073 (with-current-buffer
2074 gnus-original-article-buffer
2075 (nnmail-fetch-field "Newsgroups"))
2076 gnus-newsgroup-name method)))
2077 (when (nnmail-fetch-field "Followup-To")
2078 (nnheader-replace-header "Followup-To"
2079 (gnus-decode-newsgroups
2080 (with-current-buffer
2081 gnus-original-article-buffer
2082 (nnmail-fetch-field "Followup-To"))
2083 gnus-newsgroup-name method))))))
2085 (defun article-de-quoted-unreadable (&optional force read-charset)
2086 "Translate a quoted-printable-encoded article.
2087 If FORCE, decode the article whether it is marked as quoted-printable
2089 If READ-CHARSET, ask for a coding system."
2090 (interactive (list 'force current-prefix-arg))
2092 (let ((buffer-read-only nil) type charset)
2093 (if (gnus-buffer-live-p gnus-original-article-buffer)
2094 (with-current-buffer gnus-original-article-buffer
2096 (gnus-fetch-field "content-transfer-encoding"))
2097 (let* ((ct (gnus-fetch-field "content-type"))
2100 (mail-header-parse-content-type ct)))))
2101 (setq charset (and ctl
2102 (mail-content-type-get ctl 'charset)))
2103 (if (stringp charset)
2104 (setq charset (intern (downcase charset)))))))
2106 (setq charset (mm-read-coding-system "Charset: " charset)))
2108 (setq charset gnus-newsgroup-charset))
2110 (and type (let ((case-fold-search t))
2111 (string-match "quoted-printable" type))))
2113 (quoted-printable-decode-region
2114 (point) (point-max) (mm-charset-to-coding-system charset))))))
2116 (defun article-de-base64-unreadable (&optional force read-charset)
2117 "Translate a base64 article.
2118 If FORCE, decode the article whether it is marked as base64 not.
2119 If READ-CHARSET, ask for a coding system."
2120 (interactive (list 'force current-prefix-arg))
2122 (let ((buffer-read-only nil) type charset)
2123 (if (gnus-buffer-live-p gnus-original-article-buffer)
2124 (with-current-buffer gnus-original-article-buffer
2126 (gnus-fetch-field "content-transfer-encoding"))
2127 (let* ((ct (gnus-fetch-field "content-type"))
2130 (mail-header-parse-content-type ct)))))
2131 (setq charset (and ctl
2132 (mail-content-type-get ctl 'charset)))
2133 (if (stringp charset)
2134 (setq charset (intern (downcase charset)))))))
2136 (setq charset (mm-read-coding-system "Charset: " charset)))
2138 (setq charset gnus-newsgroup-charset))
2140 (and type (let ((case-fold-search t))
2141 (string-match "base64" type))))
2144 (narrow-to-region (point) (point-max))
2145 (base64-decode-region (point-min) (point-max))
2146 (mm-decode-coding-region
2147 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2152 (defun article-decode-HZ ()
2153 "Translate a HZ-encoded article."
2157 (let ((buffer-read-only nil))
2158 (rfc1843-decode-region (point-min) (point-max)))))
2160 (defun article-unsplit-urls ()
2161 "Remove the newlines that some other mailers insert into URLs."
2164 (let ((buffer-read-only nil))
2165 (goto-char (point-min))
2166 (while (re-search-forward
2167 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2168 (replace-match "\\1\\3" t)))
2169 (when (and gnus-display-mime-function (interactive-p))
2170 (funcall gnus-display-mime-function))))
2173 (defun article-wash-html (&optional read-charset)
2174 "Format an html article.
2175 If READ-CHARSET, ask for a coding system."
2178 (let ((buffer-read-only nil)
2180 (if (gnus-buffer-live-p gnus-original-article-buffer)
2181 (with-current-buffer gnus-original-article-buffer
2182 (let* ((ct (gnus-fetch-field "content-type"))
2185 (mail-header-parse-content-type ct)))))
2186 (setq charset (and ctl
2187 (mail-content-type-get ctl 'charset)))
2188 (if (stringp charset)
2189 (setq charset (intern (downcase charset)))))))
2191 (setq charset (mm-read-coding-system "Charset: " charset)))
2193 (setq charset gnus-newsgroup-charset))
2195 (save-window-excursion
2197 (narrow-to-region (point) (point-max))
2198 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2199 (entry (assq func mm-text-html-washer-alist)))
2201 (setq func (cdr entry)))
2203 ((gnus-functionp func)
2206 (apply (car func) (cdr func))))))))))
2208 (defun gnus-article-wash-html-with-w3 ()
2209 "Wash the current buffer with w3."
2211 (let ((w3-strict-width (window-width))
2212 (url-standalone-mode t)
2213 (url-gateway-unplugged t)
2214 (w3-honor-stylesheets nil))
2216 (w3-region (point-min) (point-max))
2219 (defun gnus-article-wash-html-with-w3m ()
2220 "Wash the current buffer with emacs-w3m."
2223 (narrow-to-region (point) (point-max))
2224 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2227 (w3m-display-inline-images mm-inline-text-html-with-images)
2228 w3m-force-redisplay)
2229 (w3m-region (point-min) (point-max)))
2230 (when mm-inline-text-html-with-w3m-keymap
2231 (add-text-properties
2232 (point-min) (point-max)
2233 (nconc (mm-w3m-local-map-property)
2234 '(mm-inline-text-html-with-w3m t))))))
2236 (defun article-hide-list-identifiers ()
2237 "Remove list identifies from the Subject header.
2238 The `gnus-list-identifiers' variable specifies what to do."
2240 (let ((inhibit-point-motion-hooks t)
2241 (regexp (if (consp gnus-list-identifiers)
2242 (mapconcat 'identity gnus-list-identifiers " *\\|")
2243 gnus-list-identifiers))
2248 (article-narrow-to-head)
2249 (goto-char (point-min))
2250 (while (re-search-forward
2251 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2253 (delete-region (match-beginning 2) (match-end 0))
2254 (beginning-of-line))
2255 (when (re-search-forward
2256 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2257 (delete-region (match-beginning 1) (match-end 1))))))))
2259 (defun article-hide-pgp ()
2260 "Remove any PGP headers and signatures in the current article."
2264 (let ((inhibit-point-motion-hooks t)
2265 buffer-read-only beg end)
2267 ;; Hide the "header".
2268 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2269 (gnus-add-wash-type 'pgp)
2270 (delete-region (match-beginning 0) (match-end 0))
2271 ;; Remove armor headers (rfc2440 6.2)
2272 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2275 ;; Hide the actual signature.
2276 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2277 (setq end (1+ (match-beginning 0)))
2280 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2282 ;; Perhaps we shouldn't hide to the end of the buffer
2283 ;; if there is no end to the signature?
2285 ;; Hide "- " PGP quotation markers.
2287 (narrow-to-region beg end)
2288 (goto-char (point-min))
2289 (while (re-search-forward "^- " nil t)
2291 (match-beginning 0) (match-end 0)))
2293 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2295 (defun article-hide-pem (&optional arg)
2296 "Toggle hiding of any PEM headers and signatures in the current article.
2297 If given a negative prefix, always show; if given a positive prefix,
2299 (interactive (gnus-article-hidden-arg))
2300 (unless (gnus-article-check-hidden-text 'pem arg)
2302 (let (buffer-read-only end)
2303 (goto-char (point-min))
2304 ;; Hide the horrendously ugly "header".
2305 (when (and (search-forward
2306 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2308 (setq end (1+ (match-beginning 0))))
2309 (gnus-add-wash-type 'pem)
2310 (gnus-article-hide-text-type
2312 (if (search-forward "\n\n" nil t)
2316 ;; Hide the trailer as well
2317 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2319 (gnus-article-hide-text-type
2320 (match-beginning 0) (match-end 0) 'pem)))))))
2322 (defun article-strip-banner ()
2323 "Strip the banner specified by the `banner' group parameter."
2327 (let ((inhibit-point-motion-hooks t)
2328 (banner (gnus-parameter-banner gnus-newsgroup-name))
2329 (gnus-signature-limit nil)
2330 buffer-read-only beg end)
2331 (when (and gnus-article-address-banner-alist
2334 (let ((from (save-restriction
2336 (article-narrow-to-head)
2337 (mail-fetch-field "from"))))
2340 (caar (mail-header-parse-addresses from))))
2342 (dolist (pair gnus-article-address-banner-alist)
2343 (when (string-match (car pair) from)
2344 (throw 'found (cdr pair)))))))))
2348 ((eq banner 'signature)
2349 (when (gnus-article-narrow-to-signature)
2352 (delete-region (point) (point-max))))
2354 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2355 (while (re-search-forward banner nil t)
2356 (delete-region (match-beginning 0) (match-end 0)))))
2358 (while (re-search-forward banner nil t)
2359 (delete-region (match-beginning 0) (match-end 0))))))))))
2361 (defun article-babel ()
2362 "Translate article using an online translation service."
2366 (set-buffer gnus-article-buffer)
2367 (when (article-goto-body)
2368 (let* ((buffer-read-only nil)
2371 (orig (buffer-substring start end))
2372 (trans (babel-as-string orig)))
2374 (narrow-to-region start end)
2375 (delete-region start end)
2378 (defun article-hide-signature (&optional arg)
2379 "Hide the signature in the current article.
2380 If given a negative prefix, always show; if given a positive prefix,
2382 (interactive (gnus-article-hidden-arg))
2383 (unless (gnus-article-check-hidden-text 'signature arg)
2386 (let ((buffer-read-only nil))
2387 (when (gnus-article-narrow-to-signature)
2388 (gnus-article-hide-text-type
2389 (point-min) (point-max) 'signature))))))
2390 (gnus-set-mode-line 'article))
2392 (defun article-strip-headers-in-body ()
2393 "Strip offensive headers from bodies."
2397 (let ((case-fold-search t))
2398 (when (looking-at "x-no-archive:")
2399 (gnus-delete-line)))))
2401 (defun article-strip-leading-blank-lines ()
2402 "Remove all blank lines from the beginning of the article."
2405 (let ((inhibit-point-motion-hooks t)
2407 (when (article-goto-body)
2408 (while (and (not (eobp))
2409 (looking-at "[ \t]*$"))
2410 (gnus-delete-line))))))
2412 (defun article-narrow-to-head ()
2413 "Narrow the buffer to the head of the message.
2414 Point is left at the beginning of the narrowed-to region."
2416 (goto-char (point-min))
2417 (if (search-forward "\n\n" nil 1)
2420 (goto-char (point-min)))
2422 (defun article-goto-body ()
2423 "Place point at the start of the body."
2424 (goto-char (point-min))
2426 ;; This variable is only bound when dealing with separate
2428 (article-goto-body-goes-to-point-min-p
2430 ((search-forward "\n\n" nil t)
2433 (goto-char (point-max))
2436 (defun article-strip-multiple-blank-lines ()
2437 "Replace consecutive blank lines with one empty line."
2440 (let ((inhibit-point-motion-hooks t)
2442 ;; First make all blank lines empty.
2444 (while (re-search-forward "^[ \t]+$" nil t)
2445 (unless (gnus-annotation-in-region-p
2446 (match-beginning 0) (match-end 0))
2447 (replace-match "" nil t)))
2448 ;; Then replace multiple empty lines with a single empty line.
2450 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2451 (unless (gnus-annotation-in-region-p
2452 (match-beginning 0) (match-end 0))
2453 (delete-region (match-beginning 1) (match-end 1)))))))
2455 (defun article-strip-leading-space ()
2456 "Remove all white space from the beginning of the lines in the article."
2459 (let ((inhibit-point-motion-hooks t)
2462 (while (re-search-forward "^[ \t]+" nil t)
2463 (replace-match "" t t)))))
2465 (defun article-strip-trailing-space ()
2466 "Remove all white space from the end of the lines in the article."
2469 (let ((inhibit-point-motion-hooks t)
2472 (while (re-search-forward "[ \t]+$" nil t)
2473 (replace-match "" t t)))))
2475 (defun article-strip-blank-lines ()
2476 "Strip leading, trailing and multiple blank lines."
2478 (article-strip-leading-blank-lines)
2479 (article-remove-trailing-blank-lines)
2480 (article-strip-multiple-blank-lines))
2482 (defun article-strip-all-blank-lines ()
2483 "Strip all blank lines."
2486 (let ((inhibit-point-motion-hooks t)
2489 (while (re-search-forward "^[ \t]*\n" nil t)
2490 (replace-match "" t t)))))
2492 (defun gnus-article-narrow-to-signature ()
2493 "Narrow to the signature; return t if a signature is found, else nil."
2494 (let ((inhibit-point-motion-hooks t))
2495 (when (gnus-article-search-signature)
2497 ;; Check whether we have some limits to what we consider
2498 ;; to be a signature.
2499 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2500 (list gnus-signature-limit)))
2502 (while (setq limit (pop limits))
2503 (if (or (and (integerp limit)
2504 (< (- (point-max) (point)) limit))
2506 (< (count-lines (point) (point-max)) limit))
2507 (and (gnus-functionp limit)
2509 (and (stringp limit)
2510 (not (re-search-forward limit nil t))))
2511 () ; This limit did not succeed.
2515 (narrow-to-region (point) (point-max))
2518 (defun gnus-article-search-signature ()
2519 "Search the current buffer for the signature separator.
2520 Put point at the beginning of the signature separator."
2521 (let ((cur (point)))
2522 (goto-char (point-max))
2523 (if (if (stringp gnus-signature-separator)
2524 (re-search-backward gnus-signature-separator nil t)
2525 (let ((seps gnus-signature-separator))
2527 (not (re-search-backward (car seps) nil t)))
2534 (defun gnus-article-hidden-arg ()
2535 "Return the current prefix arg as a number, or 0 if no prefix."
2536 (list (if current-prefix-arg
2537 (prefix-numeric-value current-prefix-arg)
2540 (defun gnus-article-check-hidden-text (type arg)
2541 "Return nil if hiding is necessary.
2542 Arg can be nil or a number. nil and positive means hide, negative
2543 means show, 0 means toggle."
2546 (let ((hide (gnus-article-hidden-text-p type)))
2552 (gnus-article-show-hidden-text type)
2555 (if (eq hide 'hidden)
2557 (gnus-article-show-hidden-text type)
2561 (defun gnus-article-hidden-text-p (type)
2562 "Say whether the current buffer contains hidden text of type TYPE."
2563 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2565 (not (get-text-property pos 'invisible))
2566 (not (get-text-property pos 'dummy-invisible)))
2568 (text-property-any (1+ pos) (point-max) 'article-type type)))
2573 (defun gnus-article-show-hidden-text (type &optional dummy)
2574 "Show all hidden text of type TYPE.
2575 Originally it is hide instead of DUMMY."
2576 (let ((buffer-read-only nil)
2577 (inhibit-point-motion-hooks t))
2578 (gnus-remove-text-properties-when
2580 (point-min) (point-max)
2581 (cons 'article-type (cons type
2582 gnus-hidden-properties)))
2583 (gnus-delete-wash-type type)))
2585 (defconst article-time-units
2586 `((year . ,(* 365.25 24 60 60))
2587 (week . ,(* 7 24 60 60))
2588 (day . ,(* 24 60 60))
2592 "Mapping from time units to seconds.")
2594 (defun gnus-article-forward-header ()
2595 "Move point to the start of the next header.
2596 If the current header is a continuation header, this can be several
2601 (if (looking-at "[ \t]+[^ \t]")
2605 (defun article-date-ut (&optional type highlight header)
2606 "Convert DATE date to universal time in the current article.
2607 If TYPE is `local', convert to local time; if it is `lapsed', output
2608 how much time has lapsed since DATE. For `lapsed', the value of
2609 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2610 should replace the \"Date:\" one, or should be added below it."
2611 (interactive (list 'ut t))
2612 (let* ((header (or header
2613 (message-fetch-field "date")
2615 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2618 ((not gnus-article-date-lapsed-new-header)
2624 (date (if (vectorp header) (mail-header-date header)
2626 (inhibit-point-motion-hooks t)
2631 (article-narrow-to-head)
2632 (when (re-search-forward tdate-regexp nil t)
2633 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2634 date (or (get-text-property (gnus-point-at-bol)
2637 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2639 (when (and date (not (string= date "")))
2640 (goto-char (point-min))
2641 (let ((buffer-read-only nil))
2642 ;; Delete any old Date headers.
2643 (while (re-search-forward date-regexp nil t)
2645 (delete-region (progn (beginning-of-line) (point))
2646 (progn (gnus-article-forward-header)
2648 (delete-region (progn (beginning-of-line) (point))
2649 (progn (gnus-article-forward-header)
2652 (setq pos (point))))
2653 (when (and (not pos)
2654 (re-search-forward tdate-regexp nil t))
2658 (insert (article-make-date-line date (or type 'ut)))
2664 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2665 (put-text-property (match-beginning 1) (1+ (match-end 1))
2666 'original-date date)
2667 (put-text-property (match-beginning 1) (1+ (match-end 1))
2669 (put-text-property (match-beginning 2) (match-end 2)
2672 (defun article-make-date-line (date type)
2673 "Return a DATE line of TYPE."
2674 (unless (memq type '(local ut original user iso8601 lapsed english))
2675 (error "Unknown conversion type: %s" type))
2677 (let ((time (date-to-time date)))
2679 ;; Convert to the local timezone.
2681 (let ((tz (car (current-time-zone time))))
2682 (format "Date: %s %s%02d%02d" (current-time-string time)
2683 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2684 (/ (% (abs tz) 3600) 60))))
2685 ;; Convert to Universal Time.
2688 (current-time-string
2689 (let* ((e (parse-time-string date))
2690 (tm (apply 'encode-time e))
2692 (ls (- (cadr tm) (car (current-time-zone time)))))
2693 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2694 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2697 ;; Get the original date from the article.
2698 ((eq type 'original)
2699 (concat "Date: " (if (string-match "\n+$" date)
2700 (substring date 0 (match-beginning 0))
2702 ;; Let the user define the format.
2704 (let ((format (or (condition-case nil
2705 (with-current-buffer gnus-summary-buffer
2706 gnus-article-time-format)
2708 gnus-article-time-format)))
2709 (if (gnus-functionp format)
2710 (funcall format time)
2711 (concat "Date: " (format-time-string format time)))))
2714 (let ((tz (car (current-time-zone time))))
2717 (format-time-string "%Y%m%dT%H%M%S" time)
2718 (format "%s%02d%02d"
2719 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2720 (/ (% (abs tz) 3600) 60)))))
2721 ;; Do an X-Sent lapsed format.
2723 ;; If the date is seriously mangled, the timezone functions are
2724 ;; liable to bug out, so we ignore all errors.
2725 (let* ((now (current-time))
2726 (real-time (subtract-time now time))
2727 (real-sec (and real-time
2728 (+ (* (float (car real-time)) 65536)
2730 (sec (and real-time (abs real-sec)))
2740 ;; This is a bit convoluted, but basically we go
2741 ;; through the time units for years, weeks, etc,
2742 ;; and divide things to see whether that results
2743 ;; in positive answers.
2746 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2747 ;; The (remaining) seconds are too few to
2748 ;; be divided into this time unit.
2750 ;; It's big enough, so we output it.
2751 (setq sec (- sec (* num (cdr unit))))
2753 (concat (if prev ", " "") (int-to-string
2755 " " (symbol-name (car unit))
2756 (if (> num 1) "s" ""))
2758 article-time-units "")
2759 ;; If dates are odd, then it might appear like the
2760 ;; article was sent in the future.
2763 " in the future"))))))
2764 ;; Display the date in proper English
2766 (let ((dtime (decode-time time)))
2769 (number-to-string (nth 3 dtime))
2770 (let ((digit (% (nth 3 dtime) 10)))
2772 ((memq (nth 3 dtime) '(11 12 13)) "th")
2778 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2780 (number-to-string (nth 5 dtime))
2782 (format "%02d" (nth 2 dtime))
2784 (format "%02d" (nth 1 dtime)))))))
2786 (format "Date: %s (from Gnus)" date))))
2788 (defun article-date-local (&optional highlight)
2789 "Convert the current article date to the local timezone."
2790 (interactive (list t))
2791 (article-date-ut 'local highlight))
2793 (defun article-date-english (&optional highlight)
2794 "Convert the current article date to something that is proper English."
2795 (interactive (list t))
2796 (article-date-ut 'english highlight))
2798 (defun article-date-original (&optional highlight)
2799 "Convert the current article date to what it was originally.
2800 This is only useful if you have used some other date conversion
2801 function and want to see what the date was before converting."
2802 (interactive (list t))
2803 (article-date-ut 'original highlight))
2805 (defun article-date-lapsed (&optional highlight)
2806 "Convert the current article date to time lapsed since it was sent."
2807 (interactive (list t))
2808 (article-date-ut 'lapsed highlight))
2810 (defun article-update-date-lapsed ()
2811 "Function to be run from a timer to update the lapsed time line."
2812 (let (deactivate-mark)
2817 (set-buffer (window-buffer w))
2818 (when (eq major-mode 'gnus-article-mode)
2819 (goto-char (point-min))
2820 (when (re-search-forward "^X-Sent:" nil t)
2821 (article-date-lapsed t))))
2824 (defun gnus-start-date-timer (&optional n)
2825 "Start a timer to update the X-Sent header in the article buffers.
2826 The numerical prefix says how frequently (in seconds) the function
2831 (gnus-stop-date-timer)
2832 (setq article-lapsed-timer
2833 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2835 (defun gnus-stop-date-timer ()
2836 "Stop the X-Sent timer."
2838 (when article-lapsed-timer
2839 (nnheader-cancel-timer article-lapsed-timer)
2840 (setq article-lapsed-timer nil)))
2842 (defun article-date-user (&optional highlight)
2843 "Convert the current article date to the user-defined format.
2844 This format is defined by the `gnus-article-time-format' variable."
2845 (interactive (list t))
2846 (article-date-ut 'user highlight))
2848 (defun article-date-iso8601 (&optional highlight)
2849 "Convert the current article date to ISO8601."
2850 (interactive (list t))
2851 (article-date-ut 'iso8601 highlight))
2853 ;; (defun article-show-all ()
2854 ;; "Show all hidden text in the article buffer."
2857 ;; (let ((buffer-read-only nil))
2858 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2860 (defun article-remove-leading-whitespace ()
2861 "Remove excessive whitespace from all headers."
2865 (let ((buffer-read-only nil))
2866 (article-narrow-to-head)
2867 (goto-char (point-min))
2868 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2869 (delete-region (match-beginning 1) (match-end 1)))))))
2871 (defun article-emphasize (&optional arg)
2872 "Emphasize text according to `gnus-emphasis-alist'."
2873 (interactive (gnus-article-hidden-arg))
2874 (unless (gnus-article-check-hidden-text 'emphasis arg)
2878 (with-current-buffer gnus-summary-buffer
2879 gnus-article-emphasis-alist)
2881 gnus-emphasis-alist))
2882 (buffer-read-only nil)
2883 (props (append '(article-type emphasis)
2884 gnus-hidden-properties))
2885 regexp elem beg invisible visible face)
2888 (while (setq elem (pop alist))
2890 (setq regexp (car elem)
2891 invisible (nth 1 elem)
2892 visible (nth 2 elem)
2894 (while (re-search-forward regexp nil t)
2895 (when (and (match-beginning visible) (match-beginning invisible))
2896 (gnus-article-hide-text
2897 (match-beginning invisible) (match-end invisible) props)
2898 (gnus-article-unhide-text-type
2899 (match-beginning visible) (match-end visible) 'emphasis)
2900 (gnus-put-overlay-excluding-newlines
2901 (match-beginning visible) (match-end visible) 'face face)
2902 (gnus-add-wash-type 'emphasis)
2903 (goto-char (match-end invisible)))))))))
2905 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2906 "Setup newsgroup emphasis alist."
2907 (unless gnus-article-emphasis-alist
2908 (let ((name (and gnus-newsgroup-name
2909 (gnus-group-real-name gnus-newsgroup-name))))
2910 (make-local-variable 'gnus-article-emphasis-alist)
2911 (setq gnus-article-emphasis-alist
2913 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2914 (while (setq elem (pop alist))
2915 (when (and name (string-match (car elem) name))
2917 highlight (copy-sequence (cdr elem)))))
2919 (copy-sequence highlight-words)
2920 (if gnus-newsgroup-name
2921 (copy-sequence (gnus-group-find-parameter
2922 gnus-newsgroup-name 'highlight-words t)))
2923 gnus-emphasis-alist)))))
2926 (defvar gnus-summary-article-menu)
2927 (defvar gnus-summary-post-menu))
2929 ;;; Saving functions.
2931 (defun gnus-article-save (save-buffer file &optional num)
2932 "Save the currently selected article."
2933 (unless gnus-save-all-headers
2934 ;; Remove headers according to `gnus-saved-headers'.
2935 (let ((gnus-visible-headers
2936 (or gnus-saved-headers gnus-visible-headers))
2937 (gnus-article-buffer save-buffer))
2939 (set-buffer save-buffer)
2940 (article-hide-headers 1 t))))
2941 (save-window-excursion
2942 (if (not gnus-default-article-saver)
2943 (error "No default saver is defined")
2944 ;; !!! Magic! The saving functions all save
2945 ;; `gnus-save-article-buffer' (or so they think), but we
2946 ;; bind that variable to our save-buffer.
2947 (set-buffer gnus-article-buffer)
2948 (let* ((gnus-save-article-buffer save-buffer)
2951 ((not gnus-prompt-before-saving) 'default)
2952 ((eq gnus-prompt-before-saving 'always) nil)
2954 (gnus-number-of-articles-to-be-saved
2955 (when (eq gnus-prompt-before-saving t)
2957 (set-buffer gnus-article-current-summary)
2958 (funcall gnus-default-article-saver filename)))))
2960 (defun gnus-read-save-file-name (prompt &optional filename
2961 function group headers variable)
2963 (funcall function group headers (symbol-value variable)))
2968 ((eq filename 'default)
2974 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2977 (if (and gnus-number-of-articles-to-be-saved
2978 (> gnus-number-of-articles-to-be-saved 1))
2979 (format "these %d articles"
2980 gnus-number-of-articles-to-be-saved)
2983 ;; Let the split methods have their say.
2985 ;; No split name was found.
2988 (concat prompt " (default "
2989 (file-name-nondirectory default-name) ") ")
2990 (file-name-directory default-name)
2992 ;; A single group name is returned.
2993 ((stringp split-name)
2995 (funcall function split-name headers
2996 (symbol-value variable)))
2998 (concat prompt " (default "
2999 (file-name-nondirectory default-name) ") ")
3000 (file-name-directory default-name)
3002 ;; A single split name was found
3003 ((= 1 (length split-name))
3004 (let* ((name (expand-file-name
3006 gnus-article-save-directory))
3007 (dir (cond ((file-directory-p name)
3008 (file-name-as-directory name))
3009 ((file-exists-p name) name)
3010 (t gnus-article-save-directory))))
3012 (concat prompt " (default " name ") ")
3014 ;; A list of splits was found.
3016 (setq split-name (nreverse split-name))
3018 (let ((file-name-history
3019 (nconc split-name file-name-history)))
3023 (concat prompt " (`M-p' for defaults) ")
3024 gnus-article-save-directory
3026 gnus-article-save-directory)))
3027 (car (push result file-name-history)))))))
3028 ;; Create the directory.
3029 (gnus-make-directory (file-name-directory file))
3030 ;; If we have read a directory, we append the default file name.
3031 (when (file-directory-p file)
3032 (setq file (expand-file-name (file-name-nondirectory
3034 (file-name-as-directory file))))
3035 ;; Possibly translate some characters.
3036 (nnheader-translate-file-chars file))))))
3037 (gnus-make-directory (file-name-directory result))
3038 (set variable result)))
3040 (defun gnus-article-archive-name (group)
3041 "Return the first instance of an \"Archive-name\" in the current buffer."
3042 (let ((case-fold-search t))
3043 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3044 (nnheader-concat gnus-article-save-directory
3045 (match-string 1)))))
3047 (defun gnus-article-nndoc-name (group)
3048 "If GROUP is an nndoc group, return the name of the parent group."
3049 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3050 (gnus-group-get-parameter group 'save-article-group)))
3052 (defun gnus-summary-save-in-rmail (&optional filename)
3053 "Append this article to Rmail file.
3054 Optional argument FILENAME specifies file name.
3055 Directory to save to is default to `gnus-article-save-directory'."
3056 (setq filename (gnus-read-save-file-name
3057 "Save %s in rmail file:" filename
3058 gnus-rmail-save-name gnus-newsgroup-name
3059 gnus-current-headers 'gnus-newsgroup-last-rmail))
3060 (gnus-eval-in-buffer-window gnus-save-article-buffer
3064 (gnus-output-to-rmail filename))))
3067 (defun gnus-summary-save-in-mail (&optional filename)
3068 "Append this article to Unix mail file.
3069 Optional argument FILENAME specifies file name.
3070 Directory to save to is default to `gnus-article-save-directory'."
3071 (setq filename (gnus-read-save-file-name
3072 "Save %s in Unix mail file:" filename
3073 gnus-mail-save-name gnus-newsgroup-name
3074 gnus-current-headers 'gnus-newsgroup-last-mail))
3075 (gnus-eval-in-buffer-window gnus-save-article-buffer
3079 (if (and (file-readable-p filename)
3080 (mail-file-babyl-p filename))
3081 (rmail-output-to-rmail-file filename t)
3082 (gnus-output-to-mail filename)))))
3085 (defun gnus-summary-save-in-file (&optional filename overwrite)
3086 "Append this article to file.
3087 Optional argument FILENAME specifies file name.
3088 Directory to save to is default to `gnus-article-save-directory'."
3089 (setq filename (gnus-read-save-file-name
3090 "Save %s in file:" filename
3091 gnus-file-save-name gnus-newsgroup-name
3092 gnus-current-headers 'gnus-newsgroup-last-file))
3093 (gnus-eval-in-buffer-window gnus-save-article-buffer
3097 (when (and overwrite
3098 (file-exists-p filename))
3099 (delete-file filename))
3100 (gnus-output-to-file filename))))
3103 (defun gnus-summary-write-to-file (&optional filename)
3104 "Write this article to a file, overwriting it if the file exists.
3105 Optional argument FILENAME specifies file name.
3106 The directory to save in defaults to `gnus-article-save-directory'."
3107 (gnus-summary-save-in-file nil t))
3109 (defun gnus-summary-save-body-in-file (&optional filename)
3110 "Append this article body to a file.
3111 Optional argument FILENAME specifies file name.
3112 The directory to save in defaults to `gnus-article-save-directory'."
3113 (setq filename (gnus-read-save-file-name
3114 "Save %s body in file:" filename
3115 gnus-file-save-name gnus-newsgroup-name
3116 gnus-current-headers 'gnus-newsgroup-last-file))
3117 (gnus-eval-in-buffer-window gnus-save-article-buffer
3121 (when (article-goto-body)
3122 (narrow-to-region (point) (point-max)))
3123 (gnus-output-to-file filename))))
3126 (defun gnus-summary-save-in-pipe (&optional command)
3127 "Pipe this article to subprocess."
3129 (cond ((and (eq command 'default)
3130 gnus-last-shell-command)
3131 gnus-last-shell-command)
3136 "Shell command on %s: "
3137 (if (and gnus-number-of-articles-to-be-saved
3138 (> gnus-number-of-articles-to-be-saved 1))
3139 (format "these %d articles"
3140 gnus-number-of-articles-to-be-saved)
3142 gnus-last-shell-command))))
3143 (when (string-equal command "")
3144 (if gnus-last-shell-command
3145 (setq command gnus-last-shell-command)
3146 (error "A command is required")))
3147 (gnus-eval-in-buffer-window gnus-article-buffer
3150 (shell-command-on-region (point-min) (point-max) command nil)))
3151 (setq gnus-last-shell-command command))
3153 (defun gnus-summary-pipe-to-muttprint (&optional command)
3154 "Pipe this article to muttprint."
3155 (setq command (read-string
3156 "Print using command: " gnus-summary-muttprint-program
3157 nil gnus-summary-muttprint-program))
3158 (gnus-summary-save-in-pipe command))
3160 ;;; Article file names when saving.
3162 (defun gnus-capitalize-newsgroup (newsgroup)
3163 "Capitalize NEWSGROUP name."
3164 (when (not (zerop (length newsgroup)))
3165 (concat (char-to-string (upcase (aref newsgroup 0)))
3166 (substring newsgroup 1))))
3168 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3169 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3170 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3171 Otherwise, it is like ~/News/news/group/num."
3174 (concat (if (gnus-use-long-file-name 'not-save)
3175 (gnus-capitalize-newsgroup newsgroup)
3176 (gnus-newsgroup-directory-form newsgroup))
3177 "/" (int-to-string (mail-header-number headers)))
3178 gnus-article-save-directory)))
3180 (string-equal (file-name-directory default)
3181 (file-name-directory last-file))
3182 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3184 (or last-file default))))
3186 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3187 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3188 If variable `gnus-use-long-file-name' is non-nil, it is
3189 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3192 (concat (if (gnus-use-long-file-name 'not-save)
3194 (gnus-newsgroup-directory-form newsgroup))
3195 "/" (int-to-string (mail-header-number headers)))
3196 gnus-article-save-directory)))
3198 (string-equal (file-name-directory default)
3199 (file-name-directory last-file))
3200 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3202 (or last-file default))))
3204 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3205 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3206 If variable `gnus-use-long-file-name' is non-nil, it is
3207 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3210 (if (gnus-use-long-file-name 'not-save)
3213 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3215 gnus-article-save-directory)))
3217 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3218 "Generate file name from sender."
3219 (let ((from (mail-header-from headers)))
3221 (if (and from (string-match "\\([^ <]+\\)@" from))
3222 (match-string 1 from)
3224 gnus-article-save-directory)))
3226 (defun article-verify-x-pgp-sig ()
3229 (if (gnus-buffer-live-p gnus-original-article-buffer)
3230 (let ((sig (with-current-buffer gnus-original-article-buffer
3231 (gnus-fetch-field "X-PGP-Sig")))
3235 (mml2015-clear-verify-function))
3237 (insert-buffer gnus-original-article-buffer)
3238 (setq items (split-string sig))
3239 (message-narrow-to-head)
3240 (let ((inhibit-point-motion-hooks t)
3241 (case-fold-search t))
3242 ;; Don't verify multiple headers.
3243 (setq headers (mapconcat (lambda (header)
3245 (mail-fetch-field header) "\n"))
3246 (split-string (nth 1 items) ",") "")))
3247 (delete-region (point-min) (point-max))
3248 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3249 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3254 (if (looking-at "^-")
3257 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3258 (insert "Version: " (car items) "\n\n")
3259 (insert (mapconcat 'identity (cddr items) "\n"))
3260 (insert "\n-----END PGP SIGNATURE-----\n")
3261 (let ((mm-security-handle (list (format "multipart/signed"))))
3262 (mml2015-clean-buffer)
3263 (let ((coding-system-for-write (or gnus-newsgroup-charset
3265 (funcall (mml2015-clear-verify-function)))
3267 (or (mm-handle-multipart-ctl-parameter
3268 mm-security-handle 'gnus-details)
3269 (mm-handle-multipart-ctl-parameter
3270 mm-security-handle 'gnus-info)))))
3272 (let (buffer-read-only bface eface)
3274 (message-narrow-to-head)
3275 (goto-char (point-max))
3277 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3278 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3279 (message-remove-header "X-Gnus-PGP-Verify")
3280 (if (re-search-forward "^X-PGP-Sig:" nil t)
3282 (goto-char (point-max)))
3283 (narrow-to-region (point) (point))
3284 (insert "X-Gnus-PGP-Verify: " info "\n")
3285 (goto-char (point-min))
3288 (if (not (looking-at "^[ \t]"))
3292 (goto-char (point-min))
3293 (when (looking-at "\\([^:]+\\): *")
3294 (put-text-property (match-beginning 1) (1+ (match-end 1))
3296 (put-text-property (match-end 0) (point-max)
3297 'face eface)))))))))
3299 (defun article-verify-cancel-lock ()
3300 "Verify Cancel-Lock header."
3302 (if (gnus-buffer-live-p gnus-original-article-buffer)
3303 (canlock-verify gnus-original-article-buffer)))
3310 (setq afunc (car func)
3313 gfunc (intern (format "gnus-%s" func))))
3315 (when (fboundp afunc)
3316 `(lambda (&optional interactive &rest args)
3317 ,(documentation afunc t)
3318 (interactive (list t))
3320 (set-buffer gnus-article-buffer)
3322 (call-interactively ',afunc)
3323 (apply ',afunc args))))))))
3324 '(article-hide-headers
3325 article-verify-x-pgp-sig
3326 article-verify-cancel-lock
3327 article-hide-boring-headers
3328 article-treat-overstrike
3329 article-fill-long-lines
3330 article-capitalize-sentences
3332 article-remove-leading-whitespace
3333 article-display-x-face
3334 article-de-quoted-unreadable
3335 article-de-base64-unreadable
3338 article-unsplit-urls
3339 article-hide-list-identifiers
3341 article-strip-banner
3344 article-hide-signature
3345 article-strip-headers-in-body
3346 article-remove-trailing-blank-lines
3347 article-strip-leading-blank-lines
3348 article-strip-multiple-blank-lines
3349 article-strip-leading-space
3350 article-strip-trailing-space
3351 article-strip-blank-lines
3352 article-strip-all-blank-lines
3354 article-date-english
3355 article-date-iso8601
3356 article-date-original
3358 article-decode-mime-words
3359 article-decode-charset
3360 article-decode-encoded-words
3364 article-treat-dumbquotes
3365 article-normalize-headers
3366 ;; (article-show-all . gnus-article-show-all-headers)
3370 ;;; Gnus article mode
3373 (put 'gnus-article-mode 'mode-class 'special)
3375 (set-keymap-parent gnus-article-mode-map widget-keymap)
3377 (gnus-define-keys gnus-article-mode-map
3378 " " gnus-article-goto-next-page
3379 "\177" gnus-article-goto-prev-page
3380 [delete] gnus-article-goto-prev-page
3381 [backspace] gnus-article-goto-prev-page
3382 "\C-c^" gnus-article-refer-article
3383 "h" gnus-article-show-summary
3384 "s" gnus-article-show-summary
3385 "\C-c\C-m" gnus-article-mail
3386 "?" gnus-article-describe-briefly
3387 "e" gnus-summary-edit-article
3388 "<" beginning-of-buffer
3390 "\C-c\C-i" gnus-info-find-node
3392 "R" gnus-article-reply-with-original
3393 "F" gnus-article-followup-with-original
3394 "\C-hk" gnus-article-describe-key
3395 "\C-hc" gnus-article-describe-key-briefly
3397 "\C-d" gnus-article-read-summary-keys
3398 "\M-*" gnus-article-read-summary-keys
3399 "\M-#" gnus-article-read-summary-keys
3400 "\M-^" gnus-article-read-summary-keys
3401 "\M-g" gnus-article-read-summary-keys)
3403 (substitute-key-definition
3404 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3406 (defun gnus-article-make-menu-bar ()
3407 (unless (boundp 'gnus-article-commands-menu)
3408 (gnus-summary-make-menu-bar))
3409 (gnus-turn-off-edit-menu 'article)
3410 (unless (boundp 'gnus-article-article-menu)
3412 gnus-article-article-menu gnus-article-mode-map ""
3414 ["Scroll forwards" gnus-article-goto-next-page t]
3415 ["Scroll backwards" gnus-article-goto-prev-page t]
3416 ["Show summary" gnus-article-show-summary t]
3417 ["Fetch Message-ID at point" gnus-article-refer-article t]
3418 ["Mail to address at point" gnus-article-mail t]
3419 ["Send a bug report" gnus-bug t]))
3422 gnus-article-treatment-menu gnus-article-mode-map ""
3423 ;; Fixme: this should use :active (and maybe :visible).
3425 ["Hide headers" gnus-article-hide-headers t]
3426 ["Hide signature" gnus-article-hide-signature t]
3427 ["Hide citation" gnus-article-hide-citation t]
3428 ["Treat overstrike" gnus-article-treat-overstrike t]
3429 ["Remove carriage return" gnus-article-remove-cr t]
3430 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3431 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3432 ["Remove base64" gnus-article-de-base64-unreadable t]
3433 ["Treat html" gnus-article-wash-html t]
3434 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3435 ["Decode HZ" gnus-article-decode-HZ t]))
3437 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3439 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3441 (gnus-run-hooks 'gnus-article-menu-hook)))
3443 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3446 (defun gnus-article-mode ()
3447 "Major mode for displaying an article.
3449 All normal editing commands are switched off.
3451 The following commands are available in addition to all summary mode
3453 \\<gnus-article-mode-map>
3454 \\[gnus-article-next-page]\t Scroll the article one page forwards
3455 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3456 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3457 \\[gnus-article-show-summary]\t Display the summary buffer
3458 \\[gnus-article-mail]\t Send a reply to the address near point
3459 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3460 \\[gnus-info-find-node]\t Go to the Gnus info node"
3462 (gnus-simplify-mode-line)
3463 (setq mode-name "Article")
3464 (setq major-mode 'gnus-article-mode)
3465 (make-local-variable 'minor-mode-alist)
3466 (use-local-map gnus-article-mode-map)
3467 (when (gnus-visual-p 'article-menu 'menu)
3468 (gnus-article-make-menu-bar))
3469 (gnus-update-format-specifications nil 'article-mode)
3470 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3471 (make-local-variable 'gnus-page-broken)
3472 (make-local-variable 'gnus-button-marker-list)
3473 (make-local-variable 'gnus-article-current-summary)
3474 (make-local-variable 'gnus-article-mime-handles)
3475 (make-local-variable 'gnus-article-decoded-p)
3476 (make-local-variable 'gnus-article-mime-handle-alist)
3477 (make-local-variable 'gnus-article-wash-types)
3478 (make-local-variable 'gnus-article-image-alist)
3479 (make-local-variable 'gnus-article-charset)
3480 (make-local-variable 'gnus-article-ignored-charsets)
3481 (gnus-set-default-directory)
3482 (buffer-disable-undo)
3483 (setq buffer-read-only t)
3484 (set-syntax-table gnus-article-mode-syntax-table)
3485 (mm-enable-multibyte)
3486 (gnus-run-hooks 'gnus-article-mode-hook))
3488 (defun gnus-article-setup-buffer ()
3489 "Initialize the article buffer."
3490 (let* ((name (if gnus-single-article-buffer "*Article*"
3491 (concat "*Article " gnus-newsgroup-name "*")))
3493 (progn (string-match "\\*Article" name)
3494 (concat " *Original Article"
3495 (substring name (match-end 0))))))
3496 (setq gnus-article-buffer name)
3497 (setq gnus-original-article-buffer original)
3498 (setq gnus-article-mime-handle-alist nil)
3499 ;; This might be a variable local to the summary buffer.
3500 (unless gnus-single-article-buffer
3502 (set-buffer gnus-summary-buffer)
3503 (setq gnus-article-buffer name)
3504 (setq gnus-original-article-buffer original)
3505 (gnus-set-global-variables)))
3506 (gnus-article-setup-highlight-words)
3507 ;; Init original article buffer.
3509 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3510 (mm-enable-multibyte)
3511 (setq major-mode 'gnus-original-article-mode)
3512 (make-local-variable 'gnus-original-article))
3513 (if (get-buffer name)
3516 (when (and gnus-article-edit-mode
3519 (y-or-n-p "Article mode edit in progress; discard? ")))
3520 (error "Action aborted"))
3521 (set (make-local-variable 'gnus-article-edit-mode) nil)
3522 (when gnus-article-mime-handles
3523 (mm-destroy-parts gnus-article-mime-handles)
3524 (setq gnus-article-mime-handles nil))
3525 ;; Set it to nil in article-buffer!
3526 (setq gnus-article-mime-handle-alist nil)
3527 (buffer-disable-undo)
3528 (setq buffer-read-only t)
3529 (unless (eq major-mode 'gnus-article-mode)
3530 (gnus-article-mode))
3533 (set-buffer (gnus-get-buffer-create name))
3535 (make-local-variable 'gnus-summary-buffer)
3536 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3537 (current-buffer)))))
3539 ;; Set article window start at LINE, where LINE is the number of lines
3540 ;; from the head of the article.
3541 (defun gnus-article-set-window-start (&optional line)
3543 (gnus-get-buffer-window gnus-article-buffer t)
3545 (set-buffer gnus-article-buffer)
3546 (goto-char (point-min))
3549 (gnus-message 6 "Moved to bookmark")
3550 (search-forward "\n\n" nil t)
3554 (defun gnus-article-prepare (article &optional all-headers header)
3555 "Prepare ARTICLE in article mode buffer.
3556 ARTICLE should either be an article number or a Message-ID.
3557 If ARTICLE is an id, HEADER should be the article headers.
3558 If ALL-HEADERS is non-nil, no headers are hidden."
3560 ;; Make sure we start in a summary buffer.
3561 (unless (eq major-mode 'gnus-summary-mode)
3562 (set-buffer gnus-summary-buffer))
3563 (setq gnus-summary-buffer (current-buffer))
3564 (let* ((gnus-article (if header (mail-header-number header) article))
3565 (summary-buffer (current-buffer))
3566 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3567 (group gnus-newsgroup-name)
3570 (gnus-article-setup-buffer)
3571 (set-buffer gnus-article-buffer)
3572 ;; Deactivate active regions.
3573 (when (and (boundp 'transient-mark-mode)
3574 transient-mark-mode)
3575 (setq mark-active nil))
3576 (if (not (setq result (let ((buffer-read-only nil))
3577 (gnus-request-article-this-buffer
3579 ;; There is no such article.
3581 (when (and (numberp article)
3582 (not (memq article gnus-newsgroup-sparse)))
3583 (setq gnus-article-current
3584 (cons gnus-newsgroup-name article))
3585 (set-buffer gnus-summary-buffer)
3586 (setq gnus-current-article article)
3587 (if (memq article gnus-newsgroup-undownloaded)
3589 (gnus-summary-set-agent-mark article)
3590 (message "Message marked for downloading"))
3591 (gnus-summary-mark-article article gnus-canceled-mark)
3592 (unless (memq article gnus-newsgroup-sparse)
3593 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3594 (if (or (eq result 'pseudo)
3595 (eq result 'nneething))
3598 (set-buffer summary-buffer)
3599 (push article gnus-newsgroup-history)
3600 (setq gnus-last-article gnus-current-article
3601 gnus-current-article 0
3602 gnus-current-headers nil
3603 gnus-article-current nil)
3604 (if (eq result 'nneething)
3605 (gnus-configure-windows 'summary)
3606 (gnus-configure-windows 'article))
3607 (gnus-set-global-variables))
3608 (let ((gnus-article-mime-handle-alist-1
3609 gnus-article-mime-handle-alist))
3610 (gnus-set-mode-line 'article)))
3611 ;; The result from the `request' was an actual article -
3612 ;; or at least some text that is now displayed in the
3614 (when (and (numberp article)
3615 (not (eq article gnus-current-article)))
3616 ;; Seems like a new article has been selected.
3617 ;; `gnus-current-article' must be an article number.
3619 (set-buffer summary-buffer)
3620 (push article gnus-newsgroup-history)
3621 (setq gnus-last-article gnus-current-article
3622 gnus-current-article article
3623 gnus-current-headers
3624 (gnus-summary-article-header gnus-current-article)
3625 gnus-article-current
3626 (cons gnus-newsgroup-name gnus-current-article))
3627 (unless (vectorp gnus-current-headers)
3628 (setq gnus-current-headers nil))
3629 (gnus-summary-goto-subject gnus-current-article)
3630 (when (gnus-summary-show-thread)
3631 ;; If the summary buffer really was folded, the
3632 ;; previous goto may not actually have gone to
3633 ;; the right article, but the thread root instead.
3635 (gnus-summary-goto-subject gnus-current-article))
3636 (gnus-run-hooks 'gnus-mark-article-hook)
3637 (gnus-set-mode-line 'summary)
3638 (when (gnus-visual-p 'article-highlight 'highlight)
3639 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3640 ;; Set the global newsgroup variables here.
3641 (gnus-set-global-variables)
3642 (setq gnus-have-all-headers
3643 (or all-headers gnus-show-all-headers))))
3645 (gnus-configure-windows 'article))
3646 (when (or (numberp article)
3648 (gnus-article-prepare-display)
3650 (goto-char (point-min))
3651 (setq gnus-page-broken
3652 (when gnus-break-pages
3653 (gnus-narrow-to-page)
3655 (let ((gnus-article-mime-handle-alist-1
3656 gnus-article-mime-handle-alist))
3657 (gnus-set-mode-line 'article))
3661 (set-window-point (get-buffer-window (current-buffer)) (point))
3662 (gnus-configure-windows 'article)
3666 (defun gnus-article-prepare-display ()
3667 "Make the current buffer look like a nice article."
3668 ;; Hooks for getting information from the article.
3669 ;; This hook must be called before being narrowed.
3670 (let ((gnus-article-buffer (current-buffer))
3672 (unless (eq major-mode 'gnus-article-mode)
3673 (gnus-article-mode))
3674 (setq buffer-read-only nil
3675 gnus-article-wash-types nil
3676 gnus-article-image-alist nil)
3677 (gnus-run-hooks 'gnus-tmp-internal-hook)
3678 (when gnus-display-mime-function
3679 (funcall gnus-display-mime-function))
3680 (gnus-run-hooks 'gnus-article-prepare-hook)))
3683 ;;; Gnus MIME viewing functions
3686 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3687 "Format of the MIME buttons.
3689 Valid specifiers include:
3691 %T MIME type, along with additional info
3692 %n The `name' parameter
3693 %d The description, if any
3694 %l The length of the encoded part
3695 %p The part identifier number
3696 %e Dots if the part isn't displayed
3698 General format specifiers can also be used. See Info node
3699 `(gnus)Formatting Variables'.")
3701 (defvar gnus-mime-button-line-format-alist
3702 '((?t gnus-tmp-type ?s)
3703 (?T gnus-tmp-type-long ?s)
3704 (?n gnus-tmp-name ?s)
3705 (?d gnus-tmp-description ?s)
3707 (?l gnus-tmp-length ?d)
3708 (?e gnus-tmp-dots ?s)))
3710 (defvar gnus-mime-button-commands
3711 '((gnus-article-press-button "\r" "Toggle Display")
3712 (gnus-mime-view-part "v" "View Interactively...")
3713 (gnus-mime-view-part-as-type "t" "View As Type...")
3714 (gnus-mime-view-part-as-charset "C" "View As charset...")
3715 (gnus-mime-save-part "o" "Save...")
3716 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3717 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3718 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3719 (gnus-mime-view-part-internally "E" "View Internally")
3720 (gnus-mime-view-part-externally "e" "View Externally")
3721 (gnus-mime-print-part "p" "Print")
3722 (gnus-mime-pipe-part "|" "Pipe To Command...")
3723 (gnus-mime-action-on-part "." "Take action on the part")))
3725 (defun gnus-article-mime-part-status ()
3726 (if gnus-article-mime-handle-alist-1
3727 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3729 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3732 (defvar gnus-mime-button-map
3733 (let ((map (make-sparse-keymap)))
3734 (unless (>= (string-to-number emacs-version) 21)
3735 ;; XEmacs doesn't care.
3736 (set-keymap-parent map gnus-article-mode-map))
3737 (define-key map gnus-mouse-2 'gnus-article-push-button)
3738 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3739 (dolist (c gnus-mime-button-commands)
3740 (define-key map (cadr c) (car c)))
3743 (defun gnus-mime-button-menu (event)
3744 "Construct a context-sensitive menu of MIME commands."
3746 (save-window-excursion
3747 (let ((pos (event-start event)))
3748 (select-window (posn-window pos))
3749 (goto-char (posn-point pos))
3750 (gnus-article-check-buffer)
3751 (let ((response (x-popup-menu
3753 ("" ,@(mapcar (lambda (c)
3754 (cons (caddr c) (car c)))
3755 gnus-mime-button-commands))))))
3757 (call-interactively response))))))
3759 (defun gnus-mime-view-all-parts (&optional handles)
3760 "View all the MIME parts."
3762 (save-current-buffer
3763 (set-buffer gnus-article-buffer)
3764 (let ((handles (or handles gnus-article-mime-handles))
3765 (mail-parse-charset gnus-newsgroup-charset)
3766 (mail-parse-ignored-charsets
3767 (with-current-buffer gnus-summary-buffer
3768 gnus-newsgroup-ignored-charsets)))
3770 (mm-remove-parts handles)
3771 (goto-char (point-min))
3772 (or (search-forward "\n\n") (goto-char (point-max)))
3773 (let (buffer-read-only)
3774 (delete-region (point) (point-max))
3775 (mm-display-parts handles))))))
3777 (defun gnus-mime-save-part-and-strip ()
3778 "Save the MIME part under point then replace it with an external body."
3780 (gnus-article-check-buffer)
3781 (let* ((data (get-text-property (point) 'gnus-data))
3783 (handles gnus-article-mime-handles))
3784 (if (mm-multiple-handles gnus-article-mime-handles)
3785 (error "This function is not implemented"))
3786 (setq file (and data (mm-save-part data)))
3788 (with-current-buffer (mm-handle-buffer data)
3790 (insert "Content-Type: " (mm-handle-media-type data))
3791 (mml-insert-parameter-string (cdr (mm-handle-type data))
3794 (insert "Content-ID: " (message-make-message-id) "\n")
3795 (insert "Content-Transfer-Encoding: binary\n")
3798 (cdr (mm-make-handle nil
3799 `("message/external-body"
3800 (access-type . "LOCAL-FILE")
3802 (set-buffer gnus-summary-buffer)
3803 (gnus-article-edit-article
3806 (let ((mail-parse-charset (or gnus-article-charset
3807 ',gnus-newsgroup-charset))
3808 (mail-parse-ignored-charsets
3809 (or gnus-article-ignored-charsets
3810 ',gnus-newsgroup-ignored-charsets))
3811 (mbl mml-buffer-list))
3812 (setq mml-buffer-list nil)
3813 (insert-buffer gnus-original-article-buffer)
3814 (mime-to-mml ',handles)
3815 (setq gnus-article-mime-handles nil)
3816 (let ((mbl1 mml-buffer-list))
3817 (setq mml-buffer-list mbl)
3818 (set (make-local-variable 'mml-buffer-list) mbl1))
3819 ;; LOCAL argument of add-hook differs between GNU Emacs
3820 ;; and XEmacs. make-local-hook makes sure they are local.
3821 (make-local-hook 'kill-buffer-hook)
3822 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3823 `(lambda (no-highlight)
3824 (let ((mail-parse-charset (or gnus-article-charset
3825 ',gnus-newsgroup-charset))
3826 (message-options message-options)
3827 (message-options-set-recipient)
3828 (mail-parse-ignored-charsets
3829 (or gnus-article-ignored-charsets
3830 ',gnus-newsgroup-ignored-charsets)))
3832 (mml-destroy-buffers)
3833 (remove-hook 'kill-buffer-hook
3834 'mml-destroy-buffers t)
3835 (kill-local-variable 'mml-buffer-list))
3836 (gnus-summary-edit-article-done
3837 ,(or (mail-header-references gnus-current-headers) "")
3838 ,(gnus-group-read-only-p)
3839 ,gnus-summary-buffer no-highlight))))))
3841 (defun gnus-mime-save-part ()
3842 "Save the MIME part under point."
3844 (gnus-article-check-buffer)
3845 (let ((data (get-text-property (point) 'gnus-data)))
3847 (mm-save-part data))))
3849 (defun gnus-mime-pipe-part ()
3850 "Pipe the MIME part under point to a process."
3852 (gnus-article-check-buffer)
3853 (let ((data (get-text-property (point) 'gnus-data)))
3855 (mm-pipe-part data))))
3857 (defun gnus-mime-view-part ()
3858 "Interactively choose a viewing method for the MIME part under point."
3860 (gnus-article-check-buffer)
3861 (let ((data (get-text-property (point) 'gnus-data)))
3863 (setq gnus-article-mime-handles
3865 gnus-article-mime-handles (setq data (copy-sequence data))))
3866 (mm-interactively-view-part data))))
3868 (defun gnus-mime-view-part-as-type-internal ()
3869 (gnus-article-check-buffer)
3870 (let* ((name (mail-content-type-get
3871 (mm-handle-type (get-text-property (point) 'gnus-data))
3873 (def-type (and name (mm-default-file-encoding name))))
3874 (and def-type (cons def-type 0))))
3876 (defun gnus-mime-view-part-as-type (&optional mime-type)
3877 "Choose a MIME media type, and view the part as such."
3880 (setq mime-type (completing-read
3881 "View as MIME type: "
3882 (mapcar #'list (mailcap-mime-types))
3884 (gnus-mime-view-part-as-type-internal))))
3885 (gnus-article-check-buffer)
3886 (let ((handle (get-text-property (point) 'gnus-data)))
3889 (mm-make-handle (mm-handle-buffer handle)
3890 (cons mime-type (cdr (mm-handle-type handle)))
3891 (mm-handle-encoding handle)
3892 (mm-handle-undisplayer handle)
3893 (mm-handle-disposition handle)
3894 (mm-handle-description handle)
3896 (mm-handle-id handle)))
3897 (setq gnus-article-mime-handles
3898 (mm-merge-handles gnus-article-mime-handles handle))
3899 (gnus-mm-display-part handle))))
3901 (defun gnus-mime-copy-part (&optional handle)
3902 "Put the MIME part under point into a new buffer."
3904 (gnus-article-check-buffer)
3905 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3906 (contents (and handle (mm-get-part handle)))
3908 (file-name-nondirectory
3910 (mail-content-type-get (mm-handle-type handle) 'name)
3911 (mail-content-type-get (mm-handle-disposition handle)
3914 (buffer (and base (generate-new-buffer base))))
3916 (switch-to-buffer buffer)
3918 ;; We do it this way to make `normal-mode' set the appropriate mode.
3921 (setq buffer-file-name (expand-file-name base))
3923 (setq buffer-file-name nil))
3924 (goto-char (point-min)))))
3926 (defun gnus-mime-print-part (&optional handle filename)
3927 "Print the MIME part under point."
3928 (interactive (list nil (ps-print-preprint current-prefix-arg)))
3929 (gnus-article-check-buffer)
3930 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3931 (contents (and handle (mm-get-part handle)))
3932 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
3933 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
3938 (with-temp-file file
3940 (call-process shell-file-name nil
3941 (generate-new-buffer " *mm*")
3943 shell-command-switch
3945 printer file (mm-handle-type handle))))
3949 (gnus-print-buffer))
3950 (ps-despool filename)))))
3952 (defun gnus-mime-inline-part (&optional handle arg)
3953 "Insert the MIME part under point into the current buffer."
3954 (interactive (list nil current-prefix-arg))
3955 (gnus-article-check-buffer)
3956 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3961 (if (and (not arg) (mm-handle-undisplayer handle))
3962 (mm-remove-part handle)
3963 (setq contents (mm-get-part handle))
3966 (setq charset (or (mail-content-type-get
3967 (mm-handle-type handle) 'charset)
3968 gnus-newsgroup-charset)))
3970 (if (mm-handle-undisplayer handle)
3971 (mm-remove-part handle))
3974 gnus-summary-show-article-charset-alist))
3975 (mm-read-coding-system "Charset: ")))))
3977 (mm-insert-inline handle
3979 (setq charset (mm-charset-to-coding-system
3981 (not (eq charset 'ascii)))
3982 (mm-decode-coding-string contents charset)
3986 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3987 "Insert the MIME part under point into the current buffer using the
3989 (interactive (list nil current-prefix-arg))
3990 (gnus-article-check-buffer)
3991 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3996 (if (mm-handle-undisplayer handle)
3997 (mm-remove-part handle))
3998 (let ((gnus-newsgroup-charset
4000 gnus-summary-show-article-charset-alist))
4001 (mm-read-coding-system "Charset: ")))
4002 (gnus-newsgroup-ignored-charsets 'gnus-all))
4003 (gnus-article-press-button)))))
4005 (defun gnus-mime-view-part-externally (&optional handle)
4006 "View the MIME part under point with an external viewer."
4008 (gnus-article-check-buffer)
4009 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4010 (mm-user-display-methods nil)
4011 (mm-inlined-types nil)
4012 (mail-parse-charset gnus-newsgroup-charset)
4013 (mail-parse-ignored-charsets
4014 (save-excursion (set-buffer gnus-summary-buffer)
4015 gnus-newsgroup-ignored-charsets)))
4017 (if (mm-handle-undisplayer handle)
4018 (mm-remove-part handle)
4019 (mm-display-part handle)))))
4021 (defun gnus-mime-view-part-internally (&optional handle)
4022 "View the MIME part under point with an internal viewer.
4023 If no internal viewer is available, use an external viewer."
4025 (gnus-article-check-buffer)
4026 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4027 (mm-inlined-types '(".*"))
4028 (mm-inline-large-images t)
4029 (mail-parse-charset gnus-newsgroup-charset)
4030 (mail-parse-ignored-charsets
4031 (save-excursion (set-buffer gnus-summary-buffer)
4032 gnus-newsgroup-ignored-charsets)))
4034 (if (mm-handle-undisplayer handle)
4035 (mm-remove-part handle)
4036 (mm-display-part handle)))))
4038 (defun gnus-mime-action-on-part (&optional action)
4039 "Do something with the MIME attachment at \(point\)."
4041 (list (completing-read "Action: " gnus-mime-action-alist)))
4042 (gnus-article-check-buffer)
4043 (let ((action-pair (assoc action gnus-mime-action-alist)))
4045 (funcall (cdr action-pair)))))
4047 (defun gnus-article-part-wrapper (n function)
4048 (save-current-buffer
4049 (set-buffer gnus-article-buffer)
4050 (when (> n (length gnus-article-mime-handle-alist))
4051 (error "No such part"))
4052 (gnus-article-goto-part n)
4053 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4054 (funcall function handle))))
4056 (defun gnus-article-pipe-part (n)
4057 "Pipe MIME part N, which is the numerical prefix."
4059 (gnus-article-part-wrapper n 'mm-pipe-part))
4061 (defun gnus-article-save-part (n)
4062 "Save MIME part N, which is the numerical prefix."
4064 (gnus-article-part-wrapper n 'mm-save-part))
4066 (defun gnus-article-interactively-view-part (n)
4067 "View MIME part N interactively, which is the numerical prefix."
4069 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4071 (defun gnus-article-copy-part (n)
4072 "Copy MIME part N, which is the numerical prefix."
4074 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4076 (defun gnus-article-view-part-as-charset (n)
4077 "Copy MIME part N, which is the numerical prefix."
4079 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4081 (defun gnus-article-view-part-externally (n)
4082 "View MIME part N externally, which is the numerical prefix."
4084 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4086 (defun gnus-article-inline-part (n)
4087 "Inline MIME part N, which is the numerical prefix."
4089 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4091 (defun gnus-article-mime-match-handle-first (condition)
4093 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4094 (while (setq ihandle (pop alist))
4096 ((functionp condition)
4097 (funcall condition (cdr ihandle)))
4098 ((eq condition 'undisplayed)
4099 (not (or (mm-handle-undisplayer (cdr ihandle))
4100 (equal (mm-handle-media-type (cdr ihandle))
4101 "multipart/alternative"))))
4102 ((eq condition 'undisplayed-alternative)
4103 (not (mm-handle-undisplayer (cdr ihandle))))
4105 (gnus-article-goto-part (car ihandle))
4106 (or (not n) (< (car ihandle) n)))
4107 (setq n (car ihandle))))
4111 (defun gnus-article-view-part (&optional n)
4112 "View MIME part N, which is the numerical prefix."
4114 (save-current-buffer
4115 (set-buffer gnus-article-buffer)
4116 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4117 gnus-article-mime-match-handle-function)))
4118 (when (> n (length gnus-article-mime-handle-alist))
4119 (error "No such part"))
4120 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4121 (when (gnus-article-goto-part n)
4122 (if (equal (car handle) "multipart/alternative")
4123 (gnus-article-press-button)
4124 (when (eq (gnus-mm-display-part handle) 'internal)
4125 (gnus-set-window-start)))))))
4127 (defsubst gnus-article-mime-total-parts ()
4128 (if (bufferp (car gnus-article-mime-handles))
4130 (1- (length gnus-article-mime-handles))))
4132 (defun gnus-mm-display-part (handle)
4133 "Display HANDLE and fix MIME button."
4134 (let ((id (get-text-property (point) 'gnus-part))
4139 (let ((window (selected-window))
4140 (mail-parse-charset gnus-newsgroup-charset)
4141 (mail-parse-ignored-charsets
4142 (if (gnus-buffer-live-p gnus-summary-buffer)
4144 (set-buffer gnus-summary-buffer)
4145 gnus-newsgroup-ignored-charsets)
4149 (let ((win (gnus-get-buffer-window (current-buffer) t))
4152 (select-window win))
4155 (if (mm-handle-displayed-p handle)
4156 ;; This will remove the part.
4157 (mm-display-part handle)
4159 (narrow-to-region (point)
4160 (if (eobp) (point) (1+ (point))))
4161 (mm-display-part handle)
4162 ;; We narrow to the part itself and
4163 ;; then call the treatment functions.
4164 (goto-char (point-min))
4166 (narrow-to-region (point) (point-max))
4169 (gnus-article-mime-total-parts)
4170 (mm-handle-media-type handle)))))
4171 (if (window-live-p window)
4172 (select-window window)))))
4174 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4175 (gnus-insert-mime-button
4176 handle id (list (mm-handle-displayed-p handle)))
4177 (goto-char point))))
4179 (defun gnus-article-goto-part (n)
4180 "Go to MIME part N."
4181 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4183 (goto-char point))))
4185 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4186 (let ((gnus-tmp-name
4187 (or (mail-content-type-get (mm-handle-type handle) 'name)
4188 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4189 (mail-content-type-get (mm-handle-type handle) 'url)
4191 (gnus-tmp-type (mm-handle-media-type handle))
4192 (gnus-tmp-description
4193 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4196 (if (if displayed (car displayed)
4197 (mm-handle-displayed-p handle))
4199 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4201 gnus-tmp-type-long b e)
4202 (when (string-match ".*/" gnus-tmp-name)
4203 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4204 (setq gnus-tmp-type-long (concat gnus-tmp-type
4205 (and (not (equal gnus-tmp-name ""))
4206 (concat "; " gnus-tmp-name))))
4207 (unless (equal gnus-tmp-description "")
4208 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4213 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4214 `(,@(gnus-local-map-property gnus-mime-button-map)
4215 gnus-callback gnus-mm-display-part
4216 gnus-part ,gnus-tmp-id
4217 article-type annotation
4220 (widget-convert-button
4223 :action 'gnus-widget-press-button
4224 :button-keymap gnus-mime-button-map
4226 (lambda (widget/window &optional overlay pos)
4227 ;; Needed to properly clear the message due to a bug in
4228 ;; wid-edit (XEmacs only).
4229 (if (boundp 'help-echo-owns-message)
4230 (setq help-echo-owns-message t))
4232 "%S: %s the MIME part; %S: more options"
4233 (aref gnus-mouse-2 0)
4234 ;; XEmacs will get a single widget arg; Emacs 21 will get
4235 ;; window, overlay, position.
4236 (if (mm-handle-displayed-p
4238 (with-current-buffer (gnus-overlay-buffer overlay)
4239 (widget-get (widget-at (gnus-overlay-start overlay))
4241 (widget-get widget/window :mime-handle)))
4243 (aref gnus-down-mouse-3 0))))))
4245 (defun gnus-widget-press-button (elems el)
4246 (goto-char (widget-get elems :from))
4247 (gnus-article-press-button))
4249 (defvar gnus-displaying-mime nil)
4251 (defun gnus-display-mime (&optional ihandles)
4252 "Display the MIME parts."
4254 (save-selected-window
4255 (let ((window (get-buffer-window gnus-article-buffer))
4258 (select-window window)
4259 ;; We have to do this since selecting the window
4260 ;; may change the point. So we set the window point.
4261 (set-window-point window point)))
4262 (let* ((handles (or ihandles (mm-dissect-buffer
4263 nil gnus-article-loose-mime)
4265 buffer-read-only handle name type b e display)
4266 (when (and (not ihandles)
4267 (not gnus-displaying-mime))
4268 ;; Top-level call; we clean up.
4269 (when gnus-article-mime-handles
4270 (mm-destroy-parts gnus-article-mime-handles)
4271 (setq gnus-article-mime-handle-alist nil));; A trick.
4272 (setq gnus-article-mime-handles handles)
4273 ;; We allow users to glean info from the handles.
4274 (when gnus-article-mime-part-function
4275 (gnus-mime-part-function handles)))
4277 (or (not (stringp (car handles)))
4280 (when (and (not ihandles)
4281 (not gnus-displaying-mime))
4282 ;; Clean up for mime parts.
4284 (delete-region (point) (point-max)))
4285 (let ((gnus-displaying-mime t))
4286 (gnus-mime-display-part handles)))
4289 (narrow-to-region (point) (point-max))
4290 (gnus-treat-article nil 1 1)
4293 ;; Highlight the headers.
4297 (narrow-to-region (point-min) (point))
4298 (gnus-treat-article 'head))))))))
4300 (defvar gnus-mime-display-multipart-as-mixed nil)
4301 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4302 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4304 (defun gnus-mime-display-part (handle)
4307 ((not (stringp (car handle)))
4308 (gnus-mime-display-single handle))
4309 ;; User-defined multipart
4310 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4311 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4313 ;; multipart/alternative
4314 ((and (equal (car handle) "multipart/alternative")
4315 (not (or gnus-mime-display-multipart-as-mixed
4316 gnus-mime-display-multipart-alternative-as-mixed)))
4317 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4318 (push (cons id handle) gnus-article-mime-handle-alist)
4319 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4320 ;; multipart/related
4321 ((and (equal (car handle) "multipart/related")
4322 (not (or gnus-mime-display-multipart-as-mixed
4323 gnus-mime-display-multipart-related-as-mixed)))
4324 ;;;!!!We should find the start part, but we just default
4325 ;;;!!!to the first part.
4326 ;;(gnus-mime-display-part (cadr handle))
4327 ;;;!!! Most multipart/related is an HTML message plus images.
4328 ;;;!!! Unfortunately we are unable to let W3 display those
4329 ;;;!!! included images, so we just display it as a mixed multipart.
4330 ;;(gnus-mime-display-mixed (cdr handle))
4331 ;;;!!! No, w3 can display everything just fine.
4332 (gnus-mime-display-part (cadr handle)))
4333 ((equal (car handle) "multipart/signed")
4334 (gnus-add-wash-type 'signed)
4335 (gnus-mime-display-security handle))
4336 ((equal (car handle) "multipart/encrypted")
4337 (gnus-add-wash-type 'encrypted)
4338 (gnus-mime-display-security handle))
4339 ;; Other multiparts are handled like multipart/mixed.
4341 (gnus-mime-display-mixed (cdr handle)))))
4343 (defun gnus-mime-part-function (handles)
4344 (if (stringp (car handles))
4345 (mapcar 'gnus-mime-part-function (cdr handles))
4346 (funcall gnus-article-mime-part-function handles)))
4348 (defun gnus-mime-display-mixed (handles)
4349 (mapcar 'gnus-mime-display-part handles))
4351 (defun gnus-mime-display-single (handle)
4352 (let ((type (mm-handle-media-type handle))
4353 (ignored gnus-ignored-mime-types)
4360 (when (string-match (pop ignored) type)
4361 (throw 'ignored nil)))
4362 (if (and (setq not-attachment
4363 (and (not (mm-inline-override-p handle))
4364 (or (not (mm-handle-disposition handle))
4365 (equal (car (mm-handle-disposition handle))
4367 (mm-attachment-override-p handle))))
4368 (mm-automatic-display-p handle)
4370 (mm-inlinable-p handle)
4371 (mm-inlined-p handle))
4372 (mm-automatic-external-display-p type)))
4374 (when (equal (mm-handle-media-supertype handle) "text")
4376 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4378 (push (cons id handle) gnus-article-mime-handle-alist)
4379 (when (or (not display)
4380 (not (gnus-unbuttonized-mime-type-p type)))
4381 ;(gnus-article-insert-newline)
4382 (gnus-insert-mime-button
4383 handle id (list (or display (and not-attachment text))))
4384 (gnus-article-insert-newline)
4385 ;(gnus-article-insert-newline)
4386 ;; Remember modify the number of forward lines.
4394 (let ((mail-parse-charset gnus-newsgroup-charset)
4395 (mail-parse-ignored-charsets
4396 (save-excursion (condition-case ()
4397 (set-buffer gnus-summary-buffer)
4399 gnus-newsgroup-ignored-charsets)))
4400 (mm-display-part handle t))
4401 (goto-char (point-max)))
4402 ((and text not-attachment)
4406 (gnus-article-insert-newline)
4407 (mm-insert-inline handle (mm-get-part handle))
4408 (goto-char (point-max))))
4412 (narrow-to-region beg (point))
4415 (gnus-article-mime-total-parts)
4416 (mm-handle-media-type handle)))))))))
4418 (defun gnus-unbuttonized-mime-type-p (type)
4419 "Say whether TYPE is to be unbuttonized."
4420 (unless gnus-inhibit-mime-unbuttonizing
4422 (let ((types gnus-unbuttonized-mime-types))
4424 (when (string-match (pop types) type)
4425 (throw 'found t)))))
4427 (let ((types gnus-buttonized-mime-types))
4429 (when (string-match (pop types) type)
4430 (throw 'found t)))))))))
4432 (defun gnus-article-insert-newline ()
4433 "Insert a newline, but mark it as undeletable."
4434 (gnus-put-text-property
4435 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4437 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4438 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4441 handle buffer-read-only from props begend not-pref)
4442 (save-window-excursion
4445 (narrow-to-region (car ibegend)
4448 (goto-char (car ibegend))
4451 (delete-region (point-min) (point-max))
4452 (mm-remove-parts handles))
4453 (setq begend (list (point-marker)))
4455 (unless (setq not-pref (cadr (member preferred ihandles)))
4456 (setq not-pref (car ihandles)))
4459 (not (gnus-unbuttonized-mime-type-p
4460 "multipart/alternative")))
4461 (gnus-add-text-properties
4464 (insert (format "%d. " id))
4468 (unless ,(not ibegend)
4469 (setq gnus-article-mime-handle-alist
4470 ',gnus-article-mime-handle-alist))
4471 (gnus-mime-display-alternative
4472 ',ihandles ',not-pref ',begend ,id))
4473 ,@(gnus-local-map-property gnus-mime-button-map)
4474 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4475 face ,gnus-article-button-face
4478 (widget-convert-button 'link from (point)
4479 :action 'gnus-widget-press-button
4480 :button-keymap gnus-widget-button-keymap)
4482 (while (setq handle (pop handles))
4483 (gnus-add-text-properties
4486 (insert (format "(%c) %-18s"
4487 (if (equal handle preferred) ?* ? )
4488 (mm-handle-media-type handle)))
4492 (unless ,(not ibegend)
4493 (setq gnus-article-mime-handle-alist
4494 ',gnus-article-mime-handle-alist))
4495 (gnus-mime-display-alternative
4496 ',ihandles ',handle ',begend ,id))
4497 ,@(gnus-local-map-property gnus-mime-button-map)
4498 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4499 face ,gnus-article-button-face
4502 (widget-convert-button 'link from (point)
4503 :action 'gnus-widget-press-button
4504 :button-keymap gnus-widget-button-keymap)
4508 (if (stringp (car preferred))
4509 (gnus-display-mime preferred)
4510 (let ((mail-parse-charset gnus-newsgroup-charset)
4511 (mail-parse-ignored-charsets
4512 (save-excursion (set-buffer gnus-summary-buffer)
4513 gnus-newsgroup-ignored-charsets)))
4514 (mm-display-part preferred)
4518 (narrow-to-region (car begend) (point-max))
4520 nil (length gnus-article-mime-handle-alist)
4521 (gnus-article-mime-total-parts)
4522 (mm-handle-media-type handle))))))
4523 (goto-char (point-max))
4524 (setcdr begend (point-marker)))))
4526 (goto-char point))))
4528 (defconst gnus-article-wash-status-strings
4529 (let ((alist '((cite "c" "Possible hidden citation text"
4530 " " "All citation text visible")
4531 (headers "h" "Hidden headers"
4532 " " "All headers visible.")
4533 (pgp "p" "Encrypted or signed message status hidden"
4534 " " "No hidden encryption nor digital signature status")
4535 (signature "s" "Signature has been hidden"
4536 " " "Signature is visible")
4537 (overstrike "o" "Overstrike (^H) characters applied"
4538 " " "No overstrike characters applied")
4539 (emphasis "e" "/*_Emphasis_*/ characters applied"
4540 " " "No /*_emphasis_*/ characters applied")))
4542 (dolist (entry alist result)
4543 (let ((key (nth 0 entry))
4544 (on (copy-sequence (nth 1 entry)))
4545 (on-help (nth 2 entry))
4546 (off (copy-sequence (nth 3 entry)))
4547 (off-help (nth 4 entry)))
4548 (put-text-property 0 1 'help-echo on-help on)
4549 (put-text-property 0 1 'help-echo off-help off)
4550 (push (list key on off) result))))
4551 "Alist of strings describing wash status in the mode line.
4552 Each entry has the form (KEY ON OF), where the KEY is a symbol
4553 representing the particular washing function, ON is the string to use
4554 in the article mode line when the washing function is active, and OFF
4555 is the string to use when it is inactive.")
4557 (defun gnus-article-wash-status-entry (key value)
4558 (let ((entry (assoc key gnus-article-wash-status-strings)))
4559 (if value (nth 1 entry) (nth 2 entry))))
4561 (defun gnus-article-wash-status ()
4562 "Return a string which display status of article washing."
4564 (set-buffer gnus-article-buffer)
4565 (let ((cite (memq 'cite gnus-article-wash-types))
4566 (headers (memq 'headers gnus-article-wash-types))
4567 (boring (memq 'boring-headers gnus-article-wash-types))
4568 (pgp (memq 'pgp gnus-article-wash-types))
4569 (pem (memq 'pem gnus-article-wash-types))
4570 (signed (memq 'signed gnus-article-wash-types))
4571 (encrypted (memq 'encrypted gnus-article-wash-types))
4572 (signature (memq 'signature gnus-article-wash-types))
4573 (overstrike (memq 'overstrike gnus-article-wash-types))
4574 (emphasis (memq 'emphasis gnus-article-wash-types)))
4576 (gnus-article-wash-status-entry 'cite cite)
4577 (gnus-article-wash-status-entry 'headers (or headers boring))
4578 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4579 (gnus-article-wash-status-entry 'signature signature)
4580 (gnus-article-wash-status-entry 'overstrike overstrike)
4581 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4583 (defun gnus-add-wash-type (type)
4584 "Add a washing of TYPE to the current status."
4585 (add-to-list 'gnus-article-wash-types type))
4587 (defun gnus-delete-wash-type (type)
4588 "Add a washing of TYPE to the current status."
4589 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4591 (defun gnus-add-image (category image)
4592 "Add IMAGE of CATEGORY to the list of displayed images."
4593 (let ((entry (assq category gnus-article-image-alist)))
4595 (setq entry (list category))
4596 (push entry gnus-article-image-alist))
4597 (nconc entry (list image))))
4599 (defun gnus-delete-images (category)
4600 "Delete all images in CATEGORY."
4601 (let ((entry (assq category gnus-article-image-alist)))
4602 (dolist (image (cdr entry))
4603 (gnus-remove-image image))
4604 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4605 (gnus-delete-wash-type category)))
4607 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4609 (defun gnus-article-maybe-hide-headers ()
4610 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4611 Provided for backwards compatibility."
4612 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4613 (not (save-excursion (set-buffer gnus-summary-buffer)
4614 gnus-have-all-headers)))
4615 (not gnus-inhibit-hiding))
4616 (gnus-article-hide-headers)))
4620 (defun gnus-output-to-file (file-name)
4621 "Append the current article to a file named FILE-NAME."
4622 (let ((artbuf (current-buffer)))
4624 (insert-buffer-substring artbuf)
4625 ;; Append newline at end of the buffer as separator, and then
4627 (goto-char (point-max))
4629 (let ((file-name-coding-system nnmail-pathname-coding-system))
4630 (mm-append-to-file (point-min) (point-max) file-name))
4633 (defun gnus-narrow-to-page (&optional arg)
4634 "Narrow the article buffer to a page.
4635 If given a numerical ARG, move forward ARG pages."
4637 (setq arg (if arg (prefix-numeric-value arg) 0))
4639 (set-buffer gnus-article-buffer)
4640 (goto-char (point-min))
4642 ;; Remove any old next/prev buttons.
4643 (when (gnus-visual-p 'page-marker)
4644 (let ((buffer-read-only nil))
4645 (gnus-remove-text-with-property 'gnus-prev)
4646 (gnus-remove-text-with-property 'gnus-next)))
4649 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4651 (re-search-forward page-delimiter nil 'move arg)))
4652 (goto-char (match-end 0)))
4655 (if (re-search-forward page-delimiter nil 'move)
4658 (when (and (gnus-visual-p 'page-marker)
4659 (not (= (point-min) 1)))
4661 (goto-char (point-min))
4662 (gnus-insert-prev-page-button)))
4663 (when (and (gnus-visual-p 'page-marker)
4664 (< (+ (point-max) 2) (buffer-size)))
4666 (goto-char (point-max))
4667 (gnus-insert-next-page-button)))))
4669 ;; Article mode commands
4671 (defun gnus-article-goto-next-page ()
4672 "Show the next page of the article."
4674 (when (gnus-article-next-page)
4675 (goto-char (point-min))
4676 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4678 (defun gnus-article-goto-prev-page ()
4679 "Show the next page of the article."
4681 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4682 (gnus-article-prev-page nil)))
4684 (defun gnus-article-next-page (&optional lines)
4685 "Show the next page of the current article.
4686 If end of article, return non-nil. Otherwise return nil.
4687 Argument LINES specifies lines to be scrolled up."
4689 (move-to-window-line -1)
4692 (and (pos-visible-in-window-p) ;Not continuation line.
4694 ;; Nothing in this page.
4695 (if (or (not gnus-page-broken)
4698 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4700 (gnus-narrow-to-page 1) ;Go to next page.
4702 ;; More in this page.
4703 (let ((scroll-in-place nil))
4707 ;; Long lines may cause an end-of-buffer error.
4708 (goto-char (point-max)))))
4709 (move-to-window-line 0)
4712 (defun gnus-article-prev-page (&optional lines)
4713 "Show previous page of current article.
4714 Argument LINES specifies lines to be scrolled down."
4716 (move-to-window-line 0)
4717 (if (and gnus-page-broken
4719 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4721 (gnus-narrow-to-page -1) ;Go to previous page.
4722 (goto-char (point-max))
4724 (let ((scroll-in-place nil))
4728 (beginning-of-buffer
4729 (goto-char (point-min))))
4730 (move-to-window-line 0)))))
4732 (defun gnus-article-refer-article ()
4733 "Read article specified by message-id around point."
4735 (let ((point (point)))
4736 (search-forward ">" nil t) ;Move point to end of "<....>".
4737 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4738 (let ((message-id (match-string 1)))
4740 (set-buffer gnus-summary-buffer)
4741 (gnus-summary-refer-article message-id))
4743 (error "No references around point"))))
4745 (defun gnus-article-show-summary ()
4746 "Reconfigure windows to show summary buffer."
4748 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4749 (error "There is no summary buffer for this article buffer")
4750 (gnus-article-set-globals)
4751 (gnus-configure-windows 'article)
4752 (gnus-summary-goto-subject gnus-current-article)
4753 (gnus-summary-position-point)))
4755 (defun gnus-article-describe-briefly ()
4756 "Describe article mode commands briefly."
4758 (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")))
4760 (defun gnus-article-summary-command ()
4761 "Execute the last keystroke in the summary buffer."
4763 (let ((obuf (current-buffer))
4764 (owin (current-window-configuration))
4766 (switch-to-buffer gnus-article-current-summary 'norecord)
4767 (setq func (lookup-key (current-local-map) (this-command-keys)))
4768 (call-interactively func)
4770 (set-window-configuration owin)
4771 (set-window-point (get-buffer-window (current-buffer)) (point))))
4773 (defun gnus-article-summary-command-nosave ()
4774 "Execute the last keystroke in the summary buffer."
4777 (pop-to-buffer gnus-article-current-summary 'norecord)
4778 (setq func (lookup-key (current-local-map) (this-command-keys)))
4779 (call-interactively func)))
4781 (defun gnus-article-check-buffer ()
4782 "Beep if not in an article buffer."
4783 (unless (equal major-mode 'gnus-article-mode)
4784 (error "Command invoked outside of a Gnus article buffer")))
4786 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4787 "Read a summary buffer key sequence and execute it from the article buffer."
4789 (gnus-article-check-buffer)
4791 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4792 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4793 "=" "^" "\M-^" "|"))
4799 '("n" "Gn" "p" "Gp"))
4802 (set-buffer gnus-article-current-summary)
4803 (let (gnus-pick-mode)
4804 (push (or key last-command-event) unread-command-events)
4805 (setq keys (if (featurep 'xemacs)
4806 (events-to-keys (read-key-sequence nil))
4807 (read-key-sequence nil)))))
4811 (if (or (member keys nosaves)
4812 (member keys nosave-but-article)
4813 (member keys nosave-in-article))
4815 (save-window-excursion
4816 (pop-to-buffer gnus-article-current-summary 'norecord)
4817 ;; We disable the pick minor mode commands.
4818 (let (gnus-pick-mode)
4819 (setq func (lookup-key (current-local-map) keys))))
4823 (unless (member keys nosave-in-article)
4824 (set-buffer gnus-article-current-summary))
4825 (call-interactively func)
4826 (setq new-sum-point (point)))
4827 (when (member keys nosave-but-article)
4828 (pop-to-buffer gnus-article-buffer 'norecord)))
4829 ;; These commands should restore window configuration.
4830 (let ((obuf (current-buffer))
4831 (owin (current-window-configuration))
4833 (summary gnus-article-current-summary)
4834 func in-buffer selected)
4835 (if not-restore-window
4836 (pop-to-buffer summary 'norecord)
4837 (switch-to-buffer summary 'norecord))
4838 (setq in-buffer (current-buffer))
4839 ;; We disable the pick minor mode commands.
4840 (if (and (setq func (let (gnus-pick-mode)
4841 (lookup-key (current-local-map) keys)))
4844 (call-interactively func)
4845 (setq new-sum-point (point))
4846 (when (eq in-buffer (current-buffer))
4847 (setq selected (gnus-summary-select-article))
4849 (unless not-restore-window
4850 (set-window-configuration owin))
4851 (when (eq selected 'old)
4853 (set-window-start (get-buffer-window (current-buffer))
4855 (set-window-point (get-buffer-window (current-buffer))
4857 (let ((win (get-buffer-window gnus-article-current-summary)))
4859 (set-window-point win new-sum-point)))) )
4860 (switch-to-buffer gnus-article-buffer)
4863 (defun gnus-article-describe-key (key)
4864 "Display documentation of the function invoked by KEY. KEY is a string."
4865 (interactive "kDescribe key: ")
4866 (gnus-article-check-buffer)
4867 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4869 (set-buffer gnus-article-current-summary)
4870 (let (gnus-pick-mode)
4871 (if (featurep 'xemacs)
4873 (push (elt key 0) unread-command-events)
4874 (setq key (events-to-keys
4875 (read-key-sequence "Describe key: "))))
4876 (setq unread-command-events
4878 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4879 (string-to-list key)))
4880 (setq key (read-key-sequence "Describe key: "))))
4882 (describe-key key)))
4884 (defun gnus-article-describe-key-briefly (key &optional insert)
4885 "Display documentation of the function invoked by KEY. KEY is a string."
4886 (interactive "kDescribe key: \nP")
4887 (gnus-article-check-buffer)
4888 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4890 (set-buffer gnus-article-current-summary)
4891 (let (gnus-pick-mode)
4892 (if (featurep 'xemacs)
4894 (push (elt key 0) unread-command-events)
4895 (setq key (events-to-keys
4896 (read-key-sequence "Describe key: "))))
4897 (setq unread-command-events
4899 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4900 (string-to-list key)))
4901 (setq key (read-key-sequence "Describe key: "))))
4902 (describe-key-briefly key insert))
4903 (describe-key-briefly key insert)))
4905 (defun gnus-article-reply-with-original (&optional wide)
4906 "Start composing a reply mail to the current message.
4907 The text in the region will be yanked. If the region isn't active,
4908 the entire article will be yanked."
4910 (let ((article (cdr gnus-article-current)) cont)
4912 (with-current-buffer gnus-summary-buffer
4913 (gnus-summary-reply (list (list article)) wide))
4914 (setq cont (buffer-substring (point) (mark t)))
4915 ;; Deactivate active regions.
4916 (when (and (boundp 'transient-mark-mode)
4917 transient-mark-mode)
4918 (setq mark-active nil))
4919 (with-current-buffer gnus-summary-buffer
4921 (list (list article cont)) wide)))))
4923 (defun gnus-article-followup-with-original ()
4924 "Compose a followup to the current article.
4925 The text in the region will be yanked. If the region isn't active,
4926 the entire article will be yanked."
4928 (let ((article (cdr gnus-article-current)) cont)
4930 (with-current-buffer gnus-summary-buffer
4931 (gnus-summary-followup (list (list article))))
4932 (setq cont (buffer-substring (point) (mark t)))
4933 ;; Deactivate active regions.
4934 (when (and (boundp 'transient-mark-mode)
4935 transient-mark-mode)
4936 (setq mark-active nil))
4937 (with-current-buffer gnus-summary-buffer
4938 (gnus-summary-followup
4939 (list (list article cont)))))))
4941 (defun gnus-article-hide (&optional arg force)
4942 "Hide all the gruft in the current article.
4943 This means that PGP stuff, signatures, cited text and (some)
4944 headers will be hidden.
4945 If given a prefix, show the hidden text instead."
4946 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4947 (gnus-article-hide-headers arg)
4948 (gnus-article-hide-list-identifiers arg)
4949 (gnus-article-hide-pgp arg)
4950 (gnus-article-hide-citation-maybe arg force)
4951 (gnus-article-hide-signature arg))
4953 (defun gnus-article-maybe-highlight ()
4954 "Do some article highlighting if article highlighting is requested."
4955 (when (gnus-visual-p 'article-highlight 'highlight)
4956 (gnus-article-highlight-some)))
4958 (defun gnus-check-group-server ()
4959 ;; Make sure the connection to the server is alive.
4960 (unless (gnus-server-opened
4961 (gnus-find-method-for-group gnus-newsgroup-name))
4962 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4963 (gnus-request-group gnus-newsgroup-name t)))
4966 (autoload 'nneething-get-file-name "nneething"))
4968 (defun gnus-request-article-this-buffer (article group)
4969 "Get an article and insert it into this buffer."
4970 (let (do-update-line sparse-header)
4974 (gnus-kill-all-overlays)
4975 (setq group (or group gnus-newsgroup-name))
4977 ;; Using `gnus-request-article' directly will insert the article into
4978 ;; `nntp-server-buffer' - so we'll save some time by not having to
4979 ;; copy it from the server buffer into the article buffer.
4981 ;; We only request an article by message-id when we do not have the
4982 ;; headers for it, so we'll have to get those.
4983 (when (stringp article)
4984 (gnus-read-header article))
4986 ;; If the article number is negative, that means that this article
4987 ;; doesn't belong in this newsgroup (possibly), so we find its
4988 ;; message-id and request it by id instead of number.
4989 (when (and (numberp article)
4991 (get-buffer gnus-summary-buffer)
4992 (gnus-buffer-exists-p gnus-summary-buffer))
4994 (set-buffer gnus-summary-buffer)
4995 (let ((header (gnus-summary-article-header article)))
4998 ((memq article gnus-newsgroup-sparse)
4999 ;; This is a sparse gap article.
5000 (setq do-update-line article)
5001 (setq article (mail-header-id header))
5002 (setq sparse-header (gnus-read-header article))
5003 (setq gnus-newsgroup-sparse
5004 (delq article gnus-newsgroup-sparse)))
5006 ;; It's a real article.
5007 (setq article (mail-header-id header)))
5009 ;; It is an extracted pseudo-article.
5010 (setq article 'pseudo)
5011 (gnus-request-pseudo-article header))))
5013 (let ((method (gnus-find-method-for-group
5014 gnus-newsgroup-name)))
5015 (when (and (eq (car method) 'nneething)
5017 (let ((dir (nneething-get-file-name
5018 (mail-header-id header))))
5019 (when (and (stringp dir)
5020 (file-directory-p dir))
5021 (setq article 'nneething)
5022 (gnus-group-enter-directory dir))))))))
5025 ;; Refuse to select canceled articles.
5026 ((and (numberp article)
5028 (get-buffer gnus-summary-buffer)
5029 (gnus-buffer-exists-p gnus-summary-buffer)
5030 (eq (cdr (save-excursion
5031 (set-buffer gnus-summary-buffer)
5032 (assq article gnus-newsgroup-reads)))
5033 gnus-canceled-mark))
5035 ;; We first check `gnus-original-article-buffer'.
5036 ((and (get-buffer gnus-original-article-buffer)
5039 (set-buffer gnus-original-article-buffer)
5040 (and (equal (car gnus-original-article) group)
5041 (eq (cdr gnus-original-article) article))))
5042 (insert-buffer-substring gnus-original-article-buffer)
5044 ;; Check the backlog.
5045 ((and gnus-keep-backlog
5046 (gnus-backlog-request-article group article (current-buffer)))
5048 ;; Check asynchronous pre-fetch.
5049 ((gnus-async-request-fetched-article group article (current-buffer))
5050 (gnus-async-prefetch-next group article gnus-summary-buffer)
5051 (when (and (numberp article) gnus-keep-backlog)
5052 (gnus-backlog-enter-article group article (current-buffer)))
5055 ((and gnus-use-cache
5057 (gnus-cache-request-article article group))
5059 ;; Check the agent cache.
5060 ((and gnus-agent gnus-agent-cache gnus-plugged
5062 (gnus-agent-request-article article group))
5064 ;; Get the article and put into the article buffer.
5065 ((or (stringp article)
5067 (let ((gnus-override-method gnus-override-method)
5068 (methods (and (stringp article)
5069 gnus-refer-article-method))
5070 (backend (car (gnus-find-method-for-group
5071 gnus-newsgroup-name)))
5073 (buffer-read-only nil))
5074 (if (or (not (listp methods))
5075 (and (symbolp (car methods))
5076 (assq (car methods) nnoo-definition-alist)))
5077 (setq methods (list methods)))
5078 (when (and (null gnus-override-method)
5080 (setq gnus-override-method (pop methods)))
5082 (when (eq gnus-override-method 'current)
5083 (setq gnus-override-method
5084 (with-current-buffer gnus-summary-buffer
5085 gnus-current-select-method)))
5087 (gnus-kill-all-overlays)
5088 (let ((gnus-newsgroup-name group))
5089 (gnus-check-group-server))
5091 ((gnus-request-article article group (current-buffer))
5092 (when (numberp article)
5093 (gnus-async-prefetch-next group article
5094 gnus-summary-buffer)
5095 (when gnus-keep-backlog
5096 (gnus-backlog-enter-article
5097 group article (current-buffer))))
5098 (setq result 'article))
5100 (setq gnus-override-method (pop methods)))
5101 ((not (string-match "^400 "
5102 (nnheader-get-report backend)))
5103 ;; If we get 400 server disconnect, reconnect and
5104 ;; retry; otherwise, assume the article has expired.
5105 (setq result 'done))))
5106 (and (eq result 'article) 'article)))
5110 ;; Associate this article with the current summary buffer.
5111 (setq gnus-article-current-summary gnus-summary-buffer)
5113 ;; Take the article from the original article buffer
5114 ;; and place it in the buffer it's supposed to be in.
5115 (when (and (get-buffer gnus-article-buffer)
5116 (equal (buffer-name (current-buffer))
5117 (buffer-name (get-buffer gnus-article-buffer))))
5119 (if (get-buffer gnus-original-article-buffer)
5120 (set-buffer gnus-original-article-buffer)
5121 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5122 (buffer-disable-undo)
5123 (setq major-mode 'gnus-original-article-mode)
5124 (setq buffer-read-only t))
5125 (let (buffer-read-only)
5127 (insert-buffer-substring gnus-article-buffer))
5128 (setq gnus-original-article (cons group article)))
5131 (run-hooks 'gnus-article-decode-hook)
5132 ;; Mark article as decoded or not.
5133 (setq gnus-article-decoded-p gnus-article-decode-hook))
5135 ;; Update sparse articles.
5136 (when (and do-update-line
5137 (or (numberp article)
5139 (let ((buf (current-buffer)))
5140 (set-buffer gnus-summary-buffer)
5141 (gnus-summary-update-article do-update-line sparse-header)
5142 (gnus-summary-goto-subject do-update-line nil t)
5143 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5145 (set-buffer buf))))))
5151 (defcustom gnus-article-edit-mode-hook nil
5152 "Hook run in article edit mode buffers."
5153 :group 'gnus-article-various
5156 (defvar gnus-article-edit-done-function nil)
5158 (defvar gnus-article-edit-mode-map nil)
5159 (defvar gnus-article-edit-mode nil)
5161 ;; Should we be using derived.el for this?
5162 (unless gnus-article-edit-mode-map
5163 (setq gnus-article-edit-mode-map (make-keymap))
5164 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5166 (gnus-define-keys gnus-article-edit-mode-map
5167 "\C-c?" describe-mode
5168 "\C-c\C-c" gnus-article-edit-done
5169 "\C-c\C-k" gnus-article-edit-exit
5170 "\C-c\C-f\C-t" message-goto-to
5171 "\C-c\C-f\C-o" message-goto-from
5172 "\C-c\C-f\C-b" message-goto-bcc
5173 ;;"\C-c\C-f\C-w" message-goto-fcc
5174 "\C-c\C-f\C-c" message-goto-cc
5175 "\C-c\C-f\C-s" message-goto-subject
5176 "\C-c\C-f\C-r" message-goto-reply-to
5177 "\C-c\C-f\C-n" message-goto-newsgroups
5178 "\C-c\C-f\C-d" message-goto-distribution
5179 "\C-c\C-f\C-f" message-goto-followup-to
5180 "\C-c\C-f\C-m" message-goto-mail-followup-to
5181 "\C-c\C-f\C-k" message-goto-keywords
5182 "\C-c\C-f\C-u" message-goto-summary
5183 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5184 "\C-c\C-f\C-a" message-gen-unsubscribed-mft
5185 "\C-c\C-b" message-goto-body
5186 "\C-c\C-i" message-goto-signature
5188 "\C-c\C-t" message-insert-to
5189 "\C-c\C-n" message-insert-newsgroups
5190 "\C-c\C-o" message-sort-headers
5191 "\C-c\C-e" message-elide-region
5192 "\C-c\C-v" message-delete-not-region
5193 "\C-c\C-z" message-kill-to-signature
5194 "\M-\r" message-newline-and-reformat
5195 "\C-c\C-a" mml-attach-file
5196 "\C-a" message-beginning-of-line
5198 "\M-;" comment-region)
5200 (gnus-define-keys (gnus-article-edit-wash-map
5201 "\C-c\C-w" gnus-article-edit-mode-map)
5202 "f" gnus-article-edit-full-stops))
5205 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5207 ["Fetch To" message-insert-to t]
5208 ["Fetch Newsgroups" message-insert-newsgroups t]
5210 ["To" message-goto-to t]
5211 ["From" message-goto-from t]
5212 ["Subject" message-goto-subject t]
5213 ["Cc" message-goto-cc t]
5214 ["Reply-To" message-goto-reply-to t]
5215 ["Summary" message-goto-summary t]
5216 ["Keywords" message-goto-keywords t]
5217 ["Newsgroups" message-goto-newsgroups t]
5218 ["Followup-To" message-goto-followup-to t]
5219 ["Mail-Followup-To" message-goto-mail-followup-to t]
5220 ["Distribution" message-goto-distribution t]
5221 ["Body" message-goto-body t]
5222 ["Signature" message-goto-signature t]))
5224 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5225 "Major mode for editing articles.
5226 This is an extended text-mode.
5228 \\{gnus-article-edit-mode-map}"
5229 (make-local-variable 'gnus-article-edit-done-function)
5230 (make-local-variable 'gnus-prev-winconf)
5231 (set (make-local-variable 'font-lock-defaults)
5232 '(message-font-lock-keywords t))
5233 (set (make-local-variable 'mail-header-separator) "")
5234 (set (make-local-variable 'gnus-article-edit-mode) t)
5235 (easy-menu-add message-mode-field-menu message-mode-map)
5237 (setq buffer-read-only nil)
5238 (buffer-enable-undo)
5241 (defun gnus-article-edit (&optional force)
5242 "Edit the current article.
5243 This will have permanent effect only in mail groups.
5244 If FORCE is non-nil, allow editing of articles even in read-only
5247 (when (and (not force)
5248 (gnus-group-read-only-p))
5249 (error "The current newsgroup does not support article editing"))
5250 (gnus-article-date-original)
5251 (gnus-article-edit-article
5253 `(lambda (no-highlight)
5255 (gnus-summary-edit-article-done
5256 ,(or (mail-header-references gnus-current-headers) "")
5257 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5259 (defun gnus-article-edit-article (start-func exit-func)
5260 "Start editing the contents of the current article buffer."
5261 (let ((winconf (current-window-configuration)))
5262 (set-buffer gnus-article-buffer)
5263 (gnus-article-edit-mode)
5264 (funcall start-func)
5265 (set-buffer-modified-p nil)
5266 (gnus-configure-windows 'edit-article)
5267 (setq gnus-article-edit-done-function exit-func)
5268 (setq gnus-prev-winconf winconf)
5269 (gnus-message 6 "C-c C-c to end edits")))
5271 (defun gnus-article-edit-done (&optional arg)
5272 "Update the article edits and exit."
5274 (let ((func gnus-article-edit-done-function)
5275 (buf (current-buffer))
5276 (start (window-start))
5278 (winconf gnus-prev-winconf))
5279 (widen) ;; Widen it in case that users narrowed the buffer.
5282 ;; The cache and backlog have to be flushed somewhat.
5283 (when gnus-keep-backlog
5284 (gnus-backlog-remove-article
5285 (car gnus-article-current) (cdr gnus-article-current)))
5286 ;; Flush original article as well.
5288 (when (get-buffer gnus-original-article-buffer)
5289 (set-buffer gnus-original-article-buffer)
5290 (setq gnus-original-article nil)))
5291 (when gnus-use-cache
5292 (gnus-cache-update-article
5293 (car gnus-article-current) (cdr gnus-article-current)))
5294 ;; We remove all text props from the article buffer.
5295 (kill-all-local-variables)
5296 (gnus-set-text-properties (point-min) (point-max) nil)
5298 (set-window-configuration winconf)
5300 (set-window-start (get-buffer-window buf) start)
5301 (set-window-point (get-buffer-window buf) (point))))
5303 (defun gnus-article-edit-exit ()
5304 "Exit the article editing without updating."
5306 (when (or (not (buffer-modified-p))
5307 (yes-or-no-p "Article modified; kill anyway? "))
5308 (let ((curbuf (current-buffer))
5310 (window-start (window-start)))
5312 (if (gnus-buffer-live-p gnus-original-article-buffer)
5313 (insert-buffer gnus-original-article-buffer))
5314 (let ((winconf gnus-prev-winconf))
5315 (kill-all-local-variables)
5317 (set-window-configuration winconf)
5318 ;; Tippy-toe some to make sure that point remains where it was.
5319 (save-current-buffer
5321 (set-window-start (get-buffer-window (current-buffer)) window-start)
5324 (defun gnus-article-edit-full-stops ()
5325 "Interactively repair spacing at end of sentences."
5328 (goto-char (point-min))
5329 (search-forward-regexp "^$" nil t)
5330 (let ((case-fold-search nil))
5331 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5334 ;;; Article highlights
5337 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5339 ;;; Internal Variables:
5341 (defcustom gnus-button-url-regexp
5342 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5343 "\\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:]]\\)"
5344 "\\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\\)\\)")
5345 "Regular expression that matches URLs."
5346 :group 'gnus-article-buttons
5349 (defcustom gnus-button-valid-fqdn-regexp
5350 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
5352 "\\([a-z][a-z]" ;; two letter country TDLs
5353 "\\|biz\\|com\\|edu\\|gov\\|int\\|mil\\|net\\|org"
5354 "\\|aero\\|coop\\|info\\|name\\|museum"
5355 "\\|arpa\\|pro\\|uucp\\|bitnet\\|bofh" ;; old style?
5357 "Regular expression that matches a valid FQDN."
5358 :group 'gnus-article-buttons
5361 (defcustom gnus-button-man-handler 'manual-entry
5362 "Function to use for displaying man pages.
5363 The function must take at least one argument with a string naming the
5365 :type '(choice (function-item :tag "Man" manual-entry)
5366 (function-item :tag "Woman" woman)
5367 (function :tag "Other"))
5368 :group 'gnus-article-buttons)
5370 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5371 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5372 If the default site is too slow, try to find a CTAN mirror, see
5373 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5374 the variable `gnus-button-handle-ctan'."
5375 :group 'gnus-article-buttons
5376 :link '(custom-manual "(gnus)Group Parameters")
5377 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5378 (const "http://tug.ctan.org/tex-archive/")
5379 (const "http://www.dante.de/CTAN/")
5380 (string :tag "Other")))
5382 (defcustom gnus-button-ctan-handler 'browse-url
5383 "Function to use for displaying CTAN links.
5384 The function must take one argument, the string naming the URL."
5385 :type '(choice (function-item :tag "Browse Url" browse-url)
5386 (function :tag "Other"))
5387 :group 'gnus-article-buttons)
5389 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5390 "Bogus strings removed from CTAN URLs."
5391 :group 'gnus-article-buttons
5392 :type '(choice (const "^/?tex-archive/\\|/")
5393 (regexp :tag "Other")))
5395 (defcustom gnus-button-mid-or-mail-regexp
5396 (concat "\\b\\(<?[a-zA-Z0-9][^<>\")!;:,{}\n\t ]*@"
5397 gnus-button-valid-fqdn-regexp
5399 "Regular expression that matches a message ID or a mail address."
5400 :group 'gnus-article-buttons
5403 (defcustom gnus-button-prefer-mid-or-mail 'guess
5404 "What to do when the button on a string as \"foo123@bar.com\" is pushed.
5405 Strings like this can be either a message ID or a mail address. If the
5406 variable is set to the symbol `ask', query the user what do do. If it is the
5407 symbol `guess', Gnus will do a guess and query the user what do do if it is
5408 ambiguous. See the variable `gnus-button-guessed-mid-regexp' for details
5409 concerning the guessing. If it is one of the sybols `mid' or `mail', Gnus
5410 will always assume that the string is a message ID or a mail address,
5412 ;; FIXME: doc-string could/should be improved.
5413 :group 'gnus-article-buttons
5414 :type '(choice (const ask)
5419 (defcustom gnus-button-guessed-mid-regexp
5421 "^<?\\(slrn\\|Pine\\.\\)"
5422 "\\|\\.fsf@\\|\\.fsf_-_@\\|\\.ln@"
5423 "\\|@4ax\\.com\\|@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de"
5424 "\\|^<?.*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*@")
5425 "Regular expression that matches message IDs and not mail addresses."
5426 ;; TODO: Incorporate more matches from
5427 ;; <URL:http://piology.org/perl/id-or-mail.pl.html>. I.e. translate the
5428 ;; Perl-REs to Elisp-REs.
5429 :group 'gnus-article-buttons
5432 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5433 (let* ((pref gnus-button-prefer-mid-or-mail)
5434 (url-mid (concat "news" ":" mid-or-mail))
5435 (url-mailto (concat "mailto" ":" mid-or-mail)))
5436 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5437 ;; If it looks like a MID (well known readers or servers) use 'mid,
5438 ;; otherwise 'ask the user.
5439 (if (eq pref 'guess)
5440 (if (string-match gnus-button-guessed-mid-regexp mid-or-mail)
5444 (save-window-excursion
5445 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5448 (cond ((eq pref 'mid)
5449 (gnus-message 9 "calling `gnus-button-handle-news' %s" url-mid)
5450 (gnus-button-handle-news url-mid))
5452 (gnus-message 9 "calling `gnus-url-mailto' %s" url-mailto)
5453 (gnus-url-mailto url-mailto)))))
5455 (defun gnus-button-handle-custom (url)
5456 "Follow a Custom URL."
5457 (customize-apropos (gnus-url-unhex-string url)))
5459 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5461 (defun gnus-button-handle-describe-function (url)
5462 "Call describe-function when pushing the corresponding URL button."
5465 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5467 (defun gnus-button-handle-describe-variable (url)
5468 "Call describe-variable when pushing the corresponding URL button."
5471 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5473 ;; FIXME: Is is possible to implement this? Else it should be removed here
5474 ;; and in `gnus-button-alist'.
5475 (defun gnus-button-handle-describe-key (url)
5476 "Call describe-key when pushing the corresponding URL button."
5477 (error "not implemented"))
5479 (defun gnus-button-handle-apropos (url)
5480 "Call apropos when pushing the corresponding URL button."
5481 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5483 (defun gnus-button-handle-apropos-command (url)
5484 "Call apropos when pushing the corresponding URL button."
5486 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5488 (defun gnus-button-handle-apropos-variable (url)
5489 "Call apropos when pushing the corresponding URL button."
5491 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5492 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5494 (defun gnus-button-handle-apropos-documentation (url)
5495 "Call apropos when pushing the corresponding URL button."
5497 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
5498 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5500 (defun gnus-button-handle-ctan (url)
5501 "Call `browse-url' when pushing a CTAN URL button."
5503 gnus-button-ctan-handler
5506 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
5508 (defcustom gnus-button-tex-level 5
5509 "*Integer that says how many TeX-related buttons Gnus will show.
5510 The higher the number, the more buttons will appear and the more false
5511 positives are possible. Note that you can set this variable local to
5512 specifific groups. Setting it higher in TeX groups is probably a good idea.
5513 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5514 how to set variables in specific groups."
5515 :group 'gnus-article-buttons
5516 :link '(custom-manual "(gnus)Group Parameters")
5519 (defcustom gnus-button-man-level 5
5520 "*Integer that says how many man-related buttons Gnus will show.
5521 The higher the number, the more buttons will appear and the more false
5522 positives are possible. Note that you can set this variable local to
5523 specifific groups. Setting it higher in Unix groups is probably a good idea.
5524 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5525 how to set variables in specific groups."
5526 :group 'gnus-article-buttons
5527 :link '(custom-manual "(gnus)Group Parameters")
5530 (defcustom gnus-button-emacs-level 5
5531 "*Integer that says how many emacs-related buttons Gnus will show.
5532 The higher the number, the more buttons will appear and the more false
5533 positives are possible. Note that you can set this variable local to
5534 specifific groups. Setting it higher in Emacs or Gnus related groups is
5535 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
5536 `gnus-parameters' on how to set variables in specific groups."
5537 :group 'gnus-article-buttons
5538 :link '(custom-manual "(gnus)Group Parameters")
5541 (defcustom gnus-button-mail-level 5
5542 "*Integer that says how many buttons for message IDs or mail addresses will appear.
5543 The higher the number, the more buttons will appear and the more false
5544 positives are possible."
5545 :group 'gnus-article-buttons
5548 (defcustom gnus-button-alist
5549 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5550 0 t gnus-button-handle-news 3)
5551 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5552 gnus-button-handle-news 2)
5553 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5555 gnus-button-fetch-group 4)
5556 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5557 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5558 t gnus-button-message-id 3)
5559 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5560 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5561 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5563 ("\\bCTAN:[ \t\n]*\\([^>)!;:,\n\t ]*\\)" 0 (>= gnus-button-tex-level 1)
5564 gnus-button-handle-ctan 1)
5566 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5567 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2)
5569 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5570 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
5571 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5572 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
5573 ;; Emacs help commands
5574 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5575 ;; regexp doesn't match arguments containing ` '.
5576 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
5577 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5578 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
5579 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5580 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
5581 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5582 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
5583 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5584 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
5585 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5586 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
5587 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+" 0
5588 ;; this regexp needs to be fixed!
5589 (>= gnus-button-emacs-level 9) gnus-button-handle-describe-key 2)
5590 ;; This is how URLs _should_ be embedded in text...
5591 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5593 (gnus-button-url-regexp 0 t browse-url 0)
5595 ("\\b\\([a-z][a-z]+\\)([1-9])\\W" 0
5596 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
5597 gnus-button-handle-man 1)
5598 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
5599 ("\\b\\([a-zA-Z][-_.a-zA-Z0-9]+\\)([1-9])\\W" 0
5600 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
5601 gnus-button-handle-man 1)
5602 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
5603 ;; SoWWWAnchor(3iv), XSelectInput(3X11)
5604 ("\\b\\([a-zA-Z][-_.:a-zA-Z0-9]+\\)([1-9][X1a-z]*)\\W" 0
5605 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
5606 ;; MID or mail: To avoid too many false positives we don't try to catch
5607 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
5608 ;; at least one dot. TLD must contain two or three chars or be a know TLD
5609 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
5610 ;; so that non-ambiguous entries (see above) match first.
5611 (gnus-button-mid-or-mail-regexp
5612 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1))
5613 "*Alist of regexps matching buttons in article bodies.
5615 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5616 REGEXP: is the string matching text around the button (can also be lisp
5617 expression evaluating to a string),
5618 BUTTON: is the number of the regexp grouping actually matching the button,
5619 FORM: is a lisp expression which must eval to true for the button to
5621 CALLBACK: is the function to call when the user push this button, and each
5622 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5624 CALLBACK can also be a variable, in that case the value of that
5625 variable it the real callback function."
5626 :group 'gnus-article-buttons
5627 :type '(repeat (list (choice regexp variable)
5628 (integer :tag "Button")
5630 (function :tag "Callback")
5633 (integer :tag "Regexp group")))))
5635 (defcustom gnus-header-button-alist
5636 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5637 0 t gnus-button-message-id 0)
5638 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5639 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5640 0 t gnus-button-mailto 0)
5641 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
5642 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
5643 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
5644 ("^[^:]+:" "\\bmailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5645 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5646 gnus-button-message-id 3))
5647 "*Alist of headers and regexps to match buttons in article heads.
5649 This alist is very similar to `gnus-button-alist', except that each
5650 alist has an additional HEADER element first in each entry:
5652 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5654 HEADER is a regexp to match a header. For a fuller explanation, see
5655 `gnus-button-alist'."
5656 :group 'gnus-article-buttons
5657 :group 'gnus-article-headers
5658 :type '(repeat (list (regexp :tag "Header")
5660 (integer :tag "Button")
5662 (function :tag "Callback")
5665 (integer :tag "Regexp group")))))
5667 (defvar gnus-button-regexp nil)
5668 (defvar gnus-button-marker-list nil)
5669 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5671 (defvar gnus-button-last nil)
5672 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5676 (defun gnus-article-push-button (event)
5677 "Check text under the mouse pointer for a callback function.
5678 If the text under the mouse pointer has a `gnus-callback' property,
5679 call it with the value of the `gnus-data' text property."
5681 (set-buffer (window-buffer (posn-window (event-start event))))
5682 (let* ((pos (posn-point (event-start event)))
5683 (data (get-text-property pos 'gnus-data))
5684 (fun (get-text-property pos 'gnus-callback)))
5687 (funcall fun data))))
5689 (defun gnus-article-press-button ()
5690 "Check text at point for a callback function.
5691 If the text at point has a `gnus-callback' property,
5692 call it with the value of the `gnus-data' text property."
5694 (let* ((data (get-text-property (point) 'gnus-data))
5695 (fun (get-text-property (point) 'gnus-callback)))
5697 (funcall fun data))))
5699 (defun gnus-article-highlight (&optional force)
5700 "Highlight current article.
5701 This function calls `gnus-article-highlight-headers',
5702 `gnus-article-highlight-citation',
5703 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5704 do the highlighting. See the documentation for those functions."
5705 (interactive (list 'force))
5706 (gnus-article-highlight-headers)
5707 (gnus-article-highlight-citation force)
5708 (gnus-article-highlight-signature)
5709 (gnus-article-add-buttons force)
5710 (gnus-article-add-buttons-to-head))
5712 (defun gnus-article-highlight-some (&optional force)
5713 "Highlight current article.
5714 This function calls `gnus-article-highlight-headers',
5715 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5716 do the highlighting. See the documentation for those functions."
5717 (interactive (list 'force))
5718 (gnus-article-highlight-headers)
5719 (gnus-article-highlight-signature)
5720 (gnus-article-add-buttons))
5722 (defun gnus-article-highlight-headers ()
5723 "Highlight article headers as specified by `gnus-header-face-alist'."
5726 (set-buffer gnus-article-buffer)
5728 (let ((alist gnus-header-face-alist)
5729 (buffer-read-only nil)
5730 (case-fold-search t)
5731 (inhibit-point-motion-hooks t)
5732 entry regexp header-face field-face from hpoints fpoints)
5733 (article-narrow-to-head)
5734 (while (setq entry (pop alist))
5735 (goto-char (point-min))
5736 (setq regexp (concat "^\\("
5737 (if (string-equal "" (nth 0 entry))
5741 header-face (nth 1 entry)
5742 field-face (nth 2 entry))
5743 (while (and (re-search-forward regexp nil t)
5747 (unless (search-forward ":" nil t)
5749 (when (and header-face
5750 (not (memq (point) hpoints)))
5751 (push (point) hpoints)
5752 (gnus-put-text-property from (point) 'face header-face))
5753 (when (and field-face
5754 (not (memq (setq from (point)) fpoints)))
5756 (if (re-search-forward "^[^ \t]" nil t)
5758 (goto-char (point-max)))
5759 (gnus-put-text-property from (point) 'face field-face))))))))
5761 (defun gnus-article-highlight-signature ()
5762 "Highlight the signature in an article.
5763 It does this by highlighting everything after
5764 `gnus-signature-separator' using `gnus-signature-face'."
5767 (set-buffer gnus-article-buffer)
5768 (let ((buffer-read-only nil)
5769 (inhibit-point-motion-hooks t))
5771 (when (and gnus-signature-face
5772 (gnus-article-narrow-to-signature))
5773 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5774 'face gnus-signature-face)
5776 (gnus-article-search-signature)
5777 (let ((start (match-beginning 0))
5778 (end (set-marker (make-marker) (1+ (match-end 0)))))
5779 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5782 (defun gnus-button-in-region-p (b e prop)
5783 "Say whether PROP exists in the region."
5784 (text-property-not-all b e prop nil))
5786 (defun gnus-article-add-buttons (&optional force)
5787 "Find external references in the article and make buttons of them.
5788 \"External references\" are things like Message-IDs and URLs, as
5789 specified by `gnus-button-alist'."
5790 (interactive (list 'force))
5792 (set-buffer gnus-article-buffer)
5793 (let ((buffer-read-only nil)
5794 (inhibit-point-motion-hooks t)
5795 (case-fold-search t)
5796 (alist gnus-button-alist)
5798 ;; Remove all old markers.
5799 (let (marker entry new-list)
5800 (while (setq marker (pop gnus-button-marker-list))
5801 (if (or (< marker (point-min)) (>= marker (point-max)))
5802 (push marker new-list)
5804 (when (setq entry (gnus-button-entry))
5805 (put-text-property (match-beginning (nth 1 entry))
5806 (match-end (nth 1 entry))
5807 'gnus-callback nil))
5808 (set-marker marker nil)))
5809 (setq gnus-button-marker-list new-list))
5810 ;; We skip the headers.
5813 (while (setq entry (pop alist))
5814 (setq regexp (eval (car entry)))
5816 (while (re-search-forward regexp nil t)
5817 (let* ((start (and entry (match-beginning (nth 1 entry))))
5818 (end (and entry (match-end (nth 1 entry))))
5819 (from (match-beginning 0)))
5820 (when (and (or (eq t (nth 2 entry))
5821 (eval (nth 2 entry)))
5822 (not (gnus-button-in-region-p
5823 start end 'gnus-callback)))
5824 ;; That optional form returned non-nil, so we add the
5826 (gnus-article-add-button
5827 start end 'gnus-button-push
5828 (car (push (set-marker (make-marker) from)
5829 gnus-button-marker-list))))))))))
5831 ;; Add buttons to the head of an article.
5832 (defun gnus-article-add-buttons-to-head ()
5833 "Add buttons to the head of the article."
5836 (set-buffer gnus-article-buffer)
5838 (let ((buffer-read-only nil)
5839 (inhibit-point-motion-hooks t)
5840 (case-fold-search t)
5841 (alist gnus-header-button-alist)
5843 (article-narrow-to-head)
5845 ;; Each alist entry.
5846 (setq entry (car alist)
5848 (goto-char (point-min))
5849 (while (re-search-forward (car entry) nil t)
5850 ;; Each header matching the entry.
5851 (setq beg (match-beginning 0))
5852 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5853 (match-beginning 0))
5856 (while (re-search-forward (eval (nth 1 entry)) end t)
5857 ;; Each match within a header.
5858 (let* ((entry (cdr entry))
5859 (start (match-beginning (nth 1 entry)))
5860 (end (match-end (nth 1 entry)))
5861 (form (nth 2 entry)))
5862 (goto-char (match-end 0))
5864 (gnus-article-add-button
5865 start end (nth 3 entry)
5866 (buffer-substring (match-beginning (nth 4 entry))
5867 (match-end (nth 4 entry)))))))
5868 (goto-char end)))))))
5870 ;;; External functions:
5872 (defun gnus-article-add-button (from to fun &optional data)
5873 "Create a button between FROM and TO with callback FUN and data DATA."
5874 (when gnus-article-button-face
5875 (gnus-overlay-put (gnus-make-overlay from to)
5876 'face gnus-article-button-face))
5877 (gnus-add-text-properties
5879 (nconc (and gnus-article-mouse-face
5880 (list gnus-mouse-face-prop gnus-article-mouse-face))
5881 (list 'gnus-callback fun)
5882 (and data (list 'gnus-data data))))
5883 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5884 :button-keymap gnus-widget-button-keymap))
5886 ;;; Internal functions:
5888 (defun gnus-article-set-globals ()
5890 (set-buffer gnus-summary-buffer)
5891 (gnus-set-global-variables)))
5893 (defun gnus-signature-toggle (end)
5895 (set-buffer gnus-article-buffer)
5896 (let ((buffer-read-only nil)
5897 (inhibit-point-motion-hooks t))
5898 (if (text-property-any end (point-max) 'article-type 'signature)
5900 (gnus-delete-wash-type 'signature)
5901 (gnus-remove-text-properties-when
5902 'article-type 'signature end (point-max)
5903 (cons 'article-type (cons 'signature
5904 gnus-hidden-properties))))
5905 (gnus-add-wash-type 'signature)
5906 (gnus-add-text-properties-when
5907 'article-type nil end (point-max)
5908 (cons 'article-type (cons 'signature
5909 gnus-hidden-properties)))))
5910 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5911 (gnus-set-mode-line 'article))))
5913 (defun gnus-button-entry ()
5914 ;; Return the first entry in `gnus-button-alist' matching this place.
5915 (let ((alist gnus-button-alist)
5918 (setq entry (pop alist))
5919 (if (looking-at (eval (car entry)))
5924 (defun gnus-button-push (marker)
5925 ;; Push button starting at MARKER.
5928 (let* ((entry (gnus-button-entry))
5929 (inhibit-point-motion-hooks t)
5931 (args (mapcar (lambda (group)
5932 (let ((string (match-string group)))
5933 (gnus-set-text-properties
5934 0 (length string) nil string)
5941 (fboundp (symbol-value fun)))
5942 (apply (symbol-value fun) args))
5944 (gnus-message 1 "You must define `%S' to use this button"
5945 (cons fun args)))))))
5947 (defun gnus-parse-news-url (url)
5948 (let (scheme server group message-id articles)
5951 (goto-char (point-min))
5952 (when (looking-at "\\([A-Za-z]+\\):")
5953 (setq scheme (match-string 1))
5954 (goto-char (match-end 0)))
5955 (when (looking-at "//\\([^/]+\\)/")
5956 (setq server (match-string 1))
5957 (goto-char (match-end 0)))
5960 ((looking-at "\\(.*@.*\\)")
5961 (setq message-id (match-string 1)))
5962 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5963 (setq group (match-string 1)
5964 articles (split-string (match-string 2) "-")))
5965 ((looking-at "\\([^/]+\\)/?")
5966 (setq group (match-string 1)))
5968 (error "Unknown news URL syntax"))))
5969 (list scheme server group message-id articles)))
5971 (defun gnus-button-handle-news (url)
5973 (destructuring-bind (scheme server group message-id articles)
5974 (gnus-parse-news-url url)
5978 (set-buffer gnus-summary-buffer)
5980 (let ((gnus-refer-article-method (list (list 'nntp server))))
5981 (gnus-summary-refer-article message-id))
5982 (gnus-summary-refer-article message-id))))
5984 (gnus-button-fetch-group url)))))
5986 (defun gnus-button-handle-man (url)
5988 (funcall gnus-button-man-handler url))
5990 (defun gnus-button-handle-info (url)
5991 "Fetch an info URL."
5993 "^\\([^:/]+\\)?/\\(.*\\)"
5995 (gnus-info-find-node
5996 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5999 (gnus-url-unhex-string (match-string 2 url))))
6000 (error "Can't parse %s" url)))
6002 (defun gnus-button-message-id (message-id)
6005 (set-buffer gnus-summary-buffer)
6006 (gnus-summary-refer-article message-id)))
6008 (defun gnus-button-fetch-group (address)
6009 "Fetch GROUP specified by ADDRESS."
6010 (if (not (string-match "[:/]" address))
6011 ;; This is just a simple group url.
6012 (gnus-group-read-ephemeral-group address gnus-select-method)
6015 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6017 (error "Can't parse %s" address)
6018 (gnus-group-read-ephemeral-group
6019 (match-string 4 address)
6020 `(nntp ,(match-string 1 address)
6021 (nntp-address ,(match-string 1 address))
6022 (nntp-port-number ,(if (match-end 3)
6023 (match-string 3 address)
6026 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6028 (defun gnus-url-parse-query-string (query &optional downcase)
6029 (let (retval pairs cur key val)
6030 (setq pairs (split-string query "&"))
6032 (setq cur (car pairs)
6034 (if (not (string-match "=" cur))
6036 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6037 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6039 (setq key (downcase key)))
6040 (setq cur (assoc key retval))
6042 (setcdr cur (cons val (cdr cur)))
6043 (setq retval (cons (list key val) retval)))))
6046 (defun gnus-url-mailto (url)
6047 ;; Send mail to someone
6048 (when (string-match "mailto:/*\\(.*\\)" url)
6049 (setq url (substring url (match-beginning 1) nil)))
6050 (let (to args subject func)
6051 (if (string-match (regexp-quote "?") url)
6052 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6053 args (gnus-url-parse-query-string
6054 (substring url (match-end 0) nil) t))
6055 (setq to (gnus-url-unhex-string url)))
6056 (setq args (cons (list "to" to) args)
6057 subject (cdr-safe (assoc "subject" args)))
6060 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6063 (message-position-on-field (caar args)))
6064 (insert (mapconcat 'identity (cdar args) ", "))
6065 (setq args (cdr args)))
6068 (message-goto-subject))))
6070 (defun gnus-button-embedded-url (address)
6071 "Activate ADDRESS with `browse-url'."
6072 (browse-url (gnus-strip-whitespace address)))
6074 ;;; Next/prev buttons in the article buffer.
6076 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6077 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6079 (defvar gnus-prev-page-map
6080 (let ((map (make-sparse-keymap)))
6081 (unless (>= emacs-major-version 21)
6082 ;; XEmacs doesn't care.
6083 (set-keymap-parent map gnus-article-mode-map))
6084 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6085 (define-key map "\r" 'gnus-button-prev-page)
6088 (defun gnus-insert-prev-page-button ()
6090 (buffer-read-only nil))
6092 gnus-prev-page-line-format nil
6093 `(,@(gnus-local-map-property gnus-prev-page-map)
6095 gnus-callback gnus-article-button-prev-page
6096 article-type annotation))
6097 (widget-convert-button
6099 :action 'gnus-button-prev-page
6100 :button-keymap gnus-prev-page-map)))
6102 (defvar gnus-prev-page-map
6103 (let ((map (make-sparse-keymap)))
6104 (unless (>= emacs-major-version 21)
6105 ;; XEmacs doesn't care.
6106 (set-keymap-parent map gnus-article-mode-map))
6107 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6108 (define-key map "\r" 'gnus-button-prev-page)
6111 (defvar gnus-next-page-map
6112 (let ((map (make-sparse-keymap)))
6113 (unless (>= emacs-major-version 21)
6114 ;; XEmacs doesn't care.
6115 (set-keymap-parent map gnus-article-mode-map))
6116 (define-key map gnus-mouse-2 'gnus-button-next-page)
6117 (define-key map "\r" 'gnus-button-next-page)
6120 (defun gnus-button-next-page (&optional args more-args)
6121 "Go to the next page."
6123 (let ((win (selected-window)))
6124 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6125 (gnus-article-next-page)
6126 (select-window win)))
6128 (defun gnus-button-prev-page (&optional args more-args)
6129 "Go to the prev page."
6131 (let ((win (selected-window)))
6132 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6133 (gnus-article-prev-page)
6134 (select-window win)))
6136 (defun gnus-insert-next-page-button ()
6138 (buffer-read-only nil))
6139 (gnus-eval-format gnus-next-page-line-format nil
6140 `(,@(gnus-local-map-property gnus-next-page-map)
6142 gnus-callback gnus-article-button-next-page
6143 article-type annotation))
6144 (widget-convert-button
6146 :action 'gnus-button-next-page
6147 :button-keymap gnus-next-page-map)))
6149 (defun gnus-article-button-next-page (arg)
6150 "Go to the next page."
6152 (let ((win (selected-window)))
6153 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6154 (gnus-article-next-page)
6155 (select-window win)))
6157 (defun gnus-article-button-prev-page (arg)
6158 "Go to the prev page."
6160 (let ((win (selected-window)))
6161 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6162 (gnus-article-prev-page)
6163 (select-window win)))
6165 (defvar gnus-decode-header-methods
6166 '(mail-decode-encoded-word-region)
6167 "List of methods used to decode headers.
6169 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6170 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6171 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6172 whose names match REGEXP.
6175 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6176 mail-decode-encoded-word-region
6177 (\"chinese\" . rfc1843-decode-region))
6180 (defvar gnus-decode-header-methods-cache nil)
6182 (defun gnus-multi-decode-header (start end)
6183 "Apply the functions from `gnus-encoded-word-methods' that match."
6184 (unless (and gnus-decode-header-methods-cache
6185 (eq gnus-newsgroup-name
6186 (car gnus-decode-header-methods-cache)))
6187 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6190 (nconc gnus-decode-header-methods-cache (list x))
6191 (if (and gnus-newsgroup-name
6192 (string-match (car x) gnus-newsgroup-name))
6193 (nconc gnus-decode-header-methods-cache
6195 gnus-decode-header-methods))
6196 (let ((xlist gnus-decode-header-methods-cache))
6199 (narrow-to-region start end)
6201 (funcall (pop xlist) (point-min) (point-max))))))
6204 ;;; Treatment top-level handling.
6207 (defun gnus-treat-article (condition &optional part-number total-parts type)
6208 (let ((length (- (point-max) (point-min)))
6209 (alist gnus-treatment-function-alist)
6210 (article-goto-body-goes-to-point-min-p t)
6214 (let ((list gnus-article-treat-types))
6216 (when (string-match (pop list) type)
6217 (throw 'found t)))))))
6218 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6220 (gnus-run-hooks 'gnus-part-display-hook)
6221 (while (setq elem (pop alist))
6224 (if (gnus-buffer-live-p gnus-summary-buffer)
6225 (set-buffer gnus-summary-buffer))
6226 (symbol-value (car elem))))
6227 (when (and (or (consp val)
6229 (gnus-treat-predicate val)
6230 (or (not (get (car elem) 'highlight))
6233 (funcall (cadr elem)))))))
6235 ;; Dynamic variables.
6237 (defvar part-number)
6238 (defvar total-parts)
6243 (defun gnus-treat-predicate (val)
6248 (stringp (car val)))
6249 (apply 'gnus-or (mapcar `(lambda (s)
6250 (string-match s ,(or gnus-newsgroup-name "")))
6253 (let ((pred (pop val)))
6256 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6258 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6260 (not (gnus-treat-predicate (car val))))
6262 (equal (car val) type))
6264 (error "%S is not a valid predicate" pred)))))
6272 (eq part-number total-parts))
6276 (error "%S is not a valid value" val))))
6278 (defun gnus-article-encrypt-body (protocol &optional n)
6279 "Encrypt the article body."
6282 (or gnus-article-encrypt-protocol
6283 (completing-read "Encrypt protocol: "
6284 gnus-article-encrypt-protocol-alist
6286 current-prefix-arg))
6287 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6289 (error (format "Can't find the encrypt protocol %s" protocol)))
6290 (if (member gnus-newsgroup-name '("nndraft:delayed"
6293 (error "Can't encrypt the article in group %s"
6294 gnus-newsgroup-name))
6295 (gnus-summary-iterate n
6297 (set-buffer gnus-summary-buffer)
6298 (let ((mail-parse-charset gnus-newsgroup-charset)
6299 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6300 (summary-buffer gnus-summary-buffer)
6302 (gnus-set-global-variables)
6303 (when (gnus-group-read-only-p)
6304 (error "The current newsgroup does not support article encrypt"))
6305 (gnus-summary-show-article t)
6307 (or (mail-header-references gnus-current-headers) ""))
6308 (set-buffer gnus-article-buffer)
6309 (let* ((buffer-read-only nil)
6311 (mapcar (lambda (field)
6312 (and (save-restriction
6313 (message-narrow-to-head)
6314 (goto-char (point-min))
6315 (search-forward field nil t))
6317 (message-narrow-to-field)
6318 (buffer-substring (point-min) (point-max))
6319 (delete-region (point-min) (point-max))
6321 '("Content-Type:" "Content-Transfer-Encoding:"
6322 "Content-Disposition:"))))
6323 (message-narrow-to-head)
6324 (message-remove-header "MIME-Version")
6325 (goto-char (point-max))
6326 (setq point (point))
6327 (insert (apply 'concat headers))
6329 (narrow-to-region point (point-max))
6330 (let ((message-options message-options))
6331 (message-options-set 'message-sender user-mail-address)
6332 (message-options-set 'message-recipients user-mail-address)
6333 (message-options-set 'message-sign-encrypt 'not)
6335 (goto-char (point-min))
6336 (insert "MIME-Version: 1.0\n")
6338 (gnus-summary-edit-article-done
6339 references nil summary-buffer t))
6340 (when gnus-keep-backlog
6341 (gnus-backlog-remove-article
6342 (car gnus-article-current) (cdr gnus-article-current)))
6344 (when (get-buffer gnus-original-article-buffer)
6345 (set-buffer gnus-original-article-buffer)
6346 (setq gnus-original-article nil)))
6347 (when gnus-use-cache
6348 (gnus-cache-update-article
6349 (car gnus-article-current) (cdr gnus-article-current))))))))
6351 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6352 "The following specs can be used:
6353 %t The security MIME type
6356 %D Details if button is pressed")
6358 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6359 "The following specs can be used:
6360 %t The security MIME type
6363 %D Details if button is pressed")
6365 (defvar gnus-mime-security-button-line-format-alist
6366 '((?t gnus-tmp-type ?s)
6367 (?i gnus-tmp-info ?s)
6368 (?d gnus-tmp-details ?s)
6369 (?D gnus-tmp-pressed-details ?s)))
6371 (defvar gnus-mime-security-button-map
6372 (let ((map (make-sparse-keymap)))
6373 (unless (>= (string-to-number emacs-version) 21)
6374 (set-keymap-parent map gnus-article-mode-map))
6375 (define-key map gnus-mouse-2 'gnus-article-push-button)
6376 (define-key map "\r" 'gnus-article-press-button)
6379 (defvar gnus-mime-security-details-buffer nil)
6381 (defvar gnus-mime-security-button-pressed nil)
6383 (defvar gnus-mime-security-show-details-inline t
6384 "If non-nil, show details in the article buffer.")
6386 (defun gnus-mime-security-verify-or-decrypt (handle)
6387 (mm-remove-parts (cdr handle))
6388 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6389 point buffer-read-only)
6391 (goto-char (car region)))
6393 (narrow-to-region (point) (point))
6394 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6395 (let* ((mm-verify-option 'known)
6396 (mm-decrypt-option 'known)
6397 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6398 (unless (eq nparts (cdr handle))
6399 (mm-destroy-parts (cdr handle))
6400 (setcdr handle nparts))))
6401 (setq point (point))
6402 (gnus-mime-display-security handle)
6403 (goto-char (point-max)))
6405 (delete-region (point) (cdr region))
6406 (set-marker (car region) nil)
6407 (set-marker (cdr region) nil))
6410 (defun gnus-mime-security-show-details (handle)
6411 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6413 (if gnus-mime-security-show-details-inline
6414 (let ((gnus-mime-security-button-pressed t)
6415 (gnus-mime-security-button-line-format
6416 (get-text-property (point) 'gnus-line-format))
6419 (while (eq (get-text-property (point) 'gnus-line-format)
6420 gnus-mime-security-button-line-format)
6424 (narrow-to-region (point) (point))
6425 (gnus-insert-mime-security-button handle))
6426 (delete-region (point)
6427 (or (text-property-not-all
6430 gnus-mime-security-button-line-format)
6432 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6433 (with-current-buffer gnus-mime-security-details-buffer
6436 (setq gnus-mime-security-details-buffer
6437 (gnus-get-buffer-create "*MIME Security Details*")))
6438 (with-current-buffer gnus-mime-security-details-buffer
6440 (goto-char (point-min)))
6441 (pop-to-buffer gnus-mime-security-details-buffer))
6442 (gnus-message 5 "No details."))))
6444 (defun gnus-mime-security-press-button (handle)
6445 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6446 (gnus-mime-security-show-details handle)
6447 (gnus-mime-security-verify-or-decrypt handle)))
6449 (defun gnus-insert-mime-security-button (handle &optional displayed)
6450 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6453 (or (nth 2 (assoc protocol mm-verify-function-alist))
6454 (nth 2 (assoc protocol mm-decrypt-function-alist))
6456 (if (equal (car handle) "multipart/signed")
6457 " Signed" " Encrypted")
6460 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6463 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6464 gnus-tmp-pressed-details
6466 (setq gnus-tmp-details
6467 (if gnus-tmp-details
6468 (concat "\n" gnus-tmp-details) ""))
6469 (setq gnus-tmp-pressed-details
6470 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6475 gnus-mime-security-button-line-format
6476 gnus-mime-security-button-line-format-alist
6477 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6478 gnus-callback gnus-mime-security-press-button
6479 gnus-line-format ,gnus-mime-security-button-line-format
6480 article-type annotation
6483 (widget-convert-button
6486 :action 'gnus-widget-press-button
6487 :button-keymap gnus-mime-security-button-map
6489 (lambda (widget/window &optional overlay pos)
6490 ;; Needed to properly clear the message due to a bug in
6491 ;; wid-edit (XEmacs only).
6492 (if (boundp 'help-echo-owns-message)
6493 (setq help-echo-owns-message t))
6496 (aref gnus-mouse-2 0))))))
6498 (defun gnus-mime-display-security (handle)
6500 (narrow-to-region (point) (point))
6501 (unless (gnus-unbuttonized-mime-type-p (car handle))
6502 (gnus-insert-mime-security-button handle))
6503 (gnus-mime-display-mixed (cdr handle))
6506 (unless (gnus-unbuttonized-mime-type-p (car handle))
6507 (let ((gnus-mime-security-button-line-format
6508 gnus-mime-security-button-end-line-format))
6509 (gnus-insert-mime-security-button handle)))
6510 (mm-set-handle-multipart-parameter
6512 (cons (set-marker (make-marker) (point-min))
6513 (set-marker (make-marker) (point-max))))))
6519 (run-hooks 'gnus-art-load-hook)
6521 ;;; gnus-art.el ends here