1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
46 (autoload 'gnus-msg-mail "gnus-msg" nil t)
47 (autoload 'gnus-button-mailto "gnus-msg")
48 (autoload 'gnus-button-reply "gnus-msg" nil t)
50 (defgroup gnus-article nil
52 :link '(custom-manual "(gnus)The Article Buffer")
55 (defgroup gnus-article-treat nil
56 "Treating article parts."
57 :link '(custom-manual "(gnus)Article Hiding")
60 (defgroup gnus-article-hiding nil
61 "Hiding article parts."
62 :link '(custom-manual "(gnus)Article Hiding")
65 (defgroup gnus-article-highlight nil
66 "Article highlighting."
67 :link '(custom-manual "(gnus)Article Highlighting")
71 (defgroup gnus-article-signature nil
73 :link '(custom-manual "(gnus)Article Signature")
76 (defgroup gnus-article-headers nil
78 :link '(custom-manual "(gnus)Hiding Headers")
81 (defgroup gnus-article-washing nil
82 "Special commands on articles."
83 :link '(custom-manual "(gnus)Article Washing")
86 (defgroup gnus-article-emphasis nil
87 "Fontisizing articles."
88 :link '(custom-manual "(gnus)Article Fontisizing")
91 (defgroup gnus-article-saving nil
93 :link '(custom-manual "(gnus)Saving Articles")
96 (defgroup gnus-article-mime nil
97 "Worshiping the MIME wonder."
98 :link '(custom-manual "(gnus)Using MIME")
101 (defgroup gnus-article-buttons nil
102 "Pushable buttons in the article buffer."
103 :link '(custom-manual "(gnus)Article Buttons")
104 :group 'gnus-article)
106 (defgroup gnus-article-various nil
107 "Other article options."
108 :link '(custom-manual "(gnus)Misc Article")
109 :group 'gnus-article)
111 (defcustom gnus-ignored-headers
114 (concat "^" header ":"))
115 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
116 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
117 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
118 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
119 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
120 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
121 "X-Attribution" "X-Originating-IP" "Delivered-To"
122 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
123 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
124 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
125 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
126 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
127 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
128 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
129 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
130 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
131 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
132 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
133 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
134 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
135 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
136 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
137 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
138 "List-[A-Za-z]+" "X-Listprocessor-Version"
139 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
140 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
141 "X-Received" "Content-length" "X-precedence"
142 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
143 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
144 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
145 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
146 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
147 "X-Content-length" "X-Posting-Agent" "Original-Received"
148 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
149 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
150 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
151 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
152 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
153 "*All headers that start with this regexp will be hidden.
154 This variable can also be a list of regexps of headers to be ignored.
155 If `gnus-visible-headers' is non-nil, this variable will be ignored."
156 :type '(choice :custom-show nil
159 :group 'gnus-article-hiding)
161 (defcustom gnus-visible-headers
162 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
163 "*All headers that do not match this regexp will be hidden.
164 This variable can also be a list of regexp of headers to remain visible.
165 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
166 :type '(repeat :value-to-internal (lambda (widget value)
167 (custom-split-regexp-maybe value))
168 :match (lambda (widget value)
170 (widget-editable-list-match widget value)))
172 :group 'gnus-article-hiding)
174 (defcustom gnus-sorted-header-list
175 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
176 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
177 "*This variable is a list of regular expressions.
178 If it is non-nil, headers that match the regular expressions will
179 be placed first in the article buffer in the sequence specified by
181 :type '(repeat regexp)
182 :group 'gnus-article-hiding)
184 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
185 "Headers that are only to be displayed if they have interesting data.
186 Possible values in this list are:
188 'empty Headers with no content.
189 'newsgroups Newsgroup identical to Gnus group.
190 'to-address To identical to To-address.
191 'to-list To identical to To-list.
192 'cc-list CC identical to To-list.
193 'followup-to Followup-to identical to Newsgroups.
194 'reply-to Reply-to identical to From.
195 'date Date less than four days old.
196 'long-to To and/or Cc longer than 1024 characters.
197 'many-to Multiple To and/or Cc."
198 :type '(set (const :tag "Headers with no content." empty)
199 (const :tag "Newsgroups identical to Gnus group." newsgroups)
200 (const :tag "To identical to To-address." to-address)
201 (const :tag "To identical to To-list." to-list)
202 (const :tag "CC identical to To-list." cc-list)
203 (const :tag "Followup-to identical to Newsgroups." followup-to)
204 (const :tag "Reply-to identical to From." reply-to)
205 (const :tag "Date less than four days old." date)
206 (const :tag "To and/or Cc longer than 1024 characters." long-to)
207 (const :tag "Multiple To and/or Cc headers." many-to))
208 :group 'gnus-article-hiding)
210 (defcustom gnus-article-skip-boring nil
211 "Skip over text that is not worth reading.
212 By default, if you set this t, then Gnus will display citations and
213 signatures, but will never scroll down to show you a page consisting
214 only of boring text. Boring text is controlled by
215 `gnus-article-boring-faces'."
217 :group 'gnus-article-hiding)
219 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
220 "Regexp matching signature separator.
221 This can also be a list of regexps. In that case, it will be checked
222 from head to tail looking for a separator. Searches will be done from
223 the end of the buffer."
224 :type '(repeat string)
225 :group 'gnus-article-signature)
227 (defcustom gnus-signature-limit nil
228 "Provide a limit to what is considered a signature.
229 If it is a number, no signature may not be longer (in characters) than
230 that number. If it is a floating point number, no signature may be
231 longer (in lines) than that number. If it is a function, the function
232 will be called without any parameters, and if it returns nil, there is
233 no signature in the buffer. If it is a string, it will be used as a
234 regexp. If it matches, the text in question is not a signature."
235 :type '(choice (integer :value 200)
237 (function :value fun)
238 (regexp :value ".*"))
239 :group 'gnus-article-signature)
241 (defcustom gnus-hidden-properties '(invisible t intangible t)
242 "Property list to use for hiding text."
244 :group 'gnus-article-hiding)
246 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
247 ;; frames in a session.
248 (defcustom gnus-article-x-face-command
249 (if (featurep 'xemacs)
250 (if (or (gnus-image-type-available-p 'xface)
251 (gnus-image-type-available-p 'pbm))
252 'gnus-display-x-face-in-from
253 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
254 (if (gnus-image-type-available-p 'pbm)
255 'gnus-display-x-face-in-from
256 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
258 "*String or function to be executed to display an X-Face header.
259 If it is a string, the command will be executed in a sub-shell
260 asynchronously. The compressed face will be piped to this command."
261 :type `(choice string
262 (function-item gnus-display-x-face-in-from)
266 :group 'gnus-article-washing)
268 (defcustom gnus-article-x-face-too-ugly nil
269 "Regexp matching posters whose face shouldn't be shown automatically."
270 :type '(choice regexp (const nil))
271 :group 'gnus-article-washing)
273 (defcustom gnus-article-banner-alist nil
274 "Banner alist for stripping.
276 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
278 :type '(repeat (cons symbol regexp))
279 :group 'gnus-article-washing)
281 (gnus-define-group-parameter
284 "Alist of regexps (to match group names) and banner."
285 :variable-group gnus-article-washing
287 '(choice :tag "Banner"
289 (const :tag "Remove signature" signature)
290 (symbol :tag "Item in `gnus-article-banner-alist'" none)
292 (const :tag "None" nil))
294 "If non-nil, specify how to remove `banners' from articles.
296 Symbol `signature' means to remove signatures delimited by
297 `gnus-signature-separator'. Any other symbol is used to look up a
298 regular expression to match the banner in `gnus-article-banner-alist'.
299 A string is used as a regular expression to match the banner
302 (defcustom gnus-article-address-banner-alist nil
303 "Alist of mail addresses and banners.
304 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
305 to match a mail address in the From: header, BANNER is one of a symbol
306 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
307 If ADDRESS matches author's mail address, it will remove things like
308 advertisements. For example:
310 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
314 (regexp :tag "Address")
315 (choice :tag "Banner" :value nil
316 (const :tag "Remove signature" signature)
317 (symbol :tag "Item in `gnus-article-banner-alist'" none)
319 (const :tag "None" nil))))
320 :group 'gnus-article-washing)
322 (defcustom gnus-emphasis-alist
324 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
329 ("_/" "/_" underline-italic)
330 ("_\\*" "\\*_" underline-bold)
331 ("\\*/" "/\\*" bold-italic)
332 ("_\\*/" "/\\*_" underline-bold-italic))))
336 (format format (car spec) (cadr spec))
337 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
339 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
340 2 3 gnus-emphasis-strikethru)
341 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
342 2 3 gnus-emphasis-underline)))
343 "*Alist that says how to fontify certain phrases.
344 Each item looks like this:
346 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
348 The first element is a regular expression to be matched. The second
349 is a number that says what regular expression grouping used to find
350 the entire emphasized word. The third is a number that says what
351 regexp grouping should be displayed and highlighted. The fourth
352 is the face used for highlighting."
353 :type '(repeat (list :value ("" 0 0 default)
355 (integer :tag "Match group")
356 (integer :tag "Emphasize group")
358 :group 'gnus-article-emphasis)
360 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
361 "A regexp to describe whitespace which should not be emphasized.
362 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
363 The former avoids underlining of leading and trailing whitespace,
364 and the latter avoids underlining any whitespace at all."
366 :group 'gnus-article-emphasis
369 (defface gnus-emphasis-bold '((t (:bold t)))
370 "Face used for displaying strong emphasized text (*word*)."
371 :group 'gnus-article-emphasis)
373 (defface gnus-emphasis-italic '((t (:italic t)))
374 "Face used for displaying italic emphasized text (/word/)."
375 :group 'gnus-article-emphasis)
377 (defface gnus-emphasis-underline '((t (:underline t)))
378 "Face used for displaying underlined emphasized text (_word_)."
379 :group 'gnus-article-emphasis)
381 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
382 "Face used for displaying underlined bold emphasized text (_*word*_)."
383 :group 'gnus-article-emphasis)
385 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
386 "Face used for displaying underlined italic emphasized text (_/word/_)."
387 :group 'gnus-article-emphasis)
389 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
390 "Face used for displaying bold italic emphasized text (/*word*/)."
391 :group 'gnus-article-emphasis)
393 (defface gnus-emphasis-underline-bold-italic
394 '((t (:bold t :italic t :underline t)))
395 "Face used for displaying underlined bold italic emphasized text.
396 Example: (_/*word*/_)."
397 :group 'gnus-article-emphasis)
399 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
400 '((t (:strikethru t)))
401 '((t (:strike-through t))))
402 "Face used for displaying strike-through text (-word-)."
403 :group 'gnus-article-emphasis)
405 (defface gnus-emphasis-highlight-words
406 '((t (:background "black" :foreground "yellow")))
407 "Face used for displaying highlighted words."
408 :group 'gnus-article-emphasis)
410 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
411 "Format for display of Date headers in article bodies.
412 See `format-time-string' for the possible values.
414 The variable can also be function, which should return a complete Date
415 header. The function is called with one argument, the time, which can
416 be fed to `format-time-string'."
417 :type '(choice string symbol)
418 :link '(custom-manual "(gnus)Article Date")
419 :group 'gnus-article-washing)
422 (autoload 'mail-extract-address-components "mail-extr"))
424 (defcustom gnus-save-all-headers t
425 "*If non-nil, don't remove any headers before saving."
426 :group 'gnus-article-saving
429 (defcustom gnus-prompt-before-saving 'always
430 "*This variable says how much prompting is to be done when saving articles.
431 If it is nil, no prompting will be done, and the articles will be
432 saved to the default files. If this variable is `always', each and
433 every article that is saved will be preceded by a prompt, even when
434 saving large batches of articles. If this variable is neither nil not
435 `always', there the user will be prompted once for a file name for
436 each invocation of the saving commands."
437 :group 'gnus-article-saving
438 :type '(choice (item always)
439 (item :tag "never" nil)
440 (sexp :tag "once" :format "%t\n" :value t)))
442 (defcustom gnus-saved-headers gnus-visible-headers
443 "Headers to keep if `gnus-save-all-headers' is nil.
444 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
445 If that variable is nil, however, all headers that match this regexp
446 will be kept while the rest will be deleted before saving."
447 :group 'gnus-article-saving
450 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
451 "A function to save articles in your favourite format.
452 The function must be interactively callable (in other words, it must
453 be an Emacs command).
455 Gnus provides the following functions:
457 * gnus-summary-save-in-rmail (Rmail format)
458 * gnus-summary-save-in-mail (Unix mail format)
459 * gnus-summary-save-in-folder (MH folder)
460 * gnus-summary-save-in-file (article format)
461 * gnus-summary-save-body-in-file (article body)
462 * gnus-summary-save-in-vm (use VM's folder format)
463 * gnus-summary-write-to-file (article format -- overwrite)."
464 :group 'gnus-article-saving
465 :type '(radio (function-item gnus-summary-save-in-rmail)
466 (function-item gnus-summary-save-in-mail)
467 (function-item gnus-summary-save-in-folder)
468 (function-item gnus-summary-save-in-file)
469 (function-item gnus-summary-save-body-in-file)
470 (function-item gnus-summary-save-in-vm)
471 (function-item gnus-summary-write-to-file)))
473 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
474 "A function generating a file name to save articles in Rmail format.
475 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
476 :group 'gnus-article-saving
479 (defcustom gnus-mail-save-name 'gnus-plain-save-name
480 "A function generating a file name to save articles in Unix mail format.
481 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
482 :group 'gnus-article-saving
485 (defcustom gnus-folder-save-name 'gnus-folder-save-name
486 "A function generating a file name to save articles in MH folder.
487 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
488 :group 'gnus-article-saving
491 (defcustom gnus-file-save-name 'gnus-numeric-save-name
492 "A function generating a file name to save articles in article format.
493 The function is called with NEWSGROUP, HEADERS, and optional
495 :group 'gnus-article-saving
498 (defcustom gnus-split-methods
499 '((gnus-article-archive-name)
500 (gnus-article-nndoc-name))
501 "*Variable used to suggest where articles are to be saved.
502 For instance, if you would like to save articles related to Gnus in
503 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
504 you could set this variable to something like:
506 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
507 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
509 This variable is an alist where the where the key is the match and the
510 value is a list of possible files to save in if the match is non-nil.
512 If the match is a string, it is used as a regexp match on the
513 article. If the match is a symbol, that symbol will be funcalled
514 from the buffer of the article to be saved with the newsgroup as the
515 parameter. If it is a list, it will be evaled in the same buffer.
517 If this form or function returns a string, this string will be used as
518 a possible file name; and if it returns a non-nil list, that list will
519 be used as possible file names."
520 :group 'gnus-article-saving
521 :type '(repeat (choice (list :value (fun) function)
522 (cons :value ("" "") regexp (repeat string))
525 (defcustom gnus-page-delimiter "^\^L"
526 "*Regexp describing what to use as article page delimiters.
527 The default value is \"^\^L\", which is a form linefeed at the
528 beginning of a line."
530 :group 'gnus-article-various)
532 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
533 "*The format specification for the article mode line.
534 See `gnus-summary-mode-line-format' for a closer description.
536 The following additional specs are available:
538 %w The article washing status.
539 %m The number of MIME parts in the article."
541 :group 'gnus-article-various)
543 (defcustom gnus-article-mode-hook nil
544 "*A hook for Gnus article mode."
546 :group 'gnus-article-various)
548 (when (featurep 'xemacs)
549 ;; Extracted from gnus-xmas-define in order to preserve user settings
550 (when (fboundp 'turn-off-scroll-in-place)
551 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
552 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
553 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
555 (defcustom gnus-article-menu-hook nil
556 "*Hook run after the creation of the article mode menu."
558 :group 'gnus-article-various)
560 (defcustom gnus-article-prepare-hook nil
561 "*A hook called after an article has been prepared in the article buffer."
563 :group 'gnus-article-various)
565 (make-obsolete-variable 'gnus-article-hide-pgp-hook
566 "This variable is obsolete in Gnus 5.10.")
568 (defcustom gnus-article-button-face 'bold
569 "Face used for highlighting buttons in the article buffer.
571 An article button is a piece of text that you can activate by pressing
572 `RET' or `mouse-2' above it."
574 :group 'gnus-article-buttons)
576 (defcustom gnus-article-mouse-face 'highlight
577 "Face used for mouse highlighting in the article buffer.
579 Article buttons will be displayed in this face when the cursor is
582 :group 'gnus-article-buttons)
584 (defcustom gnus-signature-face 'gnus-signature-face
585 "Face used for highlighting a signature in the article buffer.
586 Obsolete; use the face `gnus-signature-face' for customizations instead."
588 :group 'gnus-article-highlight
589 :group 'gnus-article-signature)
591 (defface gnus-signature-face
594 "Face used for highlighting a signature in the article buffer."
595 :group 'gnus-article-highlight
596 :group 'gnus-article-signature)
598 (defface gnus-header-from-face
601 (:foreground "spring green"))
604 (:foreground "red3"))
607 "Face used for displaying from headers."
608 :group 'gnus-article-headers
609 :group 'gnus-article-highlight)
611 (defface gnus-header-subject-face
614 (:foreground "SeaGreen3"))
617 (:foreground "red4"))
619 (:bold t :italic t)))
620 "Face used for displaying subject headers."
621 :group 'gnus-article-headers
622 :group 'gnus-article-highlight)
624 (defface gnus-header-newsgroups-face
627 (:foreground "yellow" :italic t))
630 (:foreground "MidnightBlue" :italic t))
633 "Face used for displaying newsgroups headers.
634 In the default setup this face is only used for crossposted
636 :group 'gnus-article-headers
637 :group 'gnus-article-highlight)
639 (defface gnus-header-name-face
642 (:foreground "SeaGreen"))
645 (:foreground "maroon"))
648 "Face used for displaying header names."
649 :group 'gnus-article-headers
650 :group 'gnus-article-highlight)
652 (defface gnus-header-content-face
655 (:foreground "forest green" :italic t))
658 (:foreground "indianred4" :italic t))
660 (:italic t))) "Face used for displaying header content."
661 :group 'gnus-article-headers
662 :group 'gnus-article-highlight)
664 (defcustom gnus-header-face-alist
665 '(("From" nil gnus-header-from-face)
666 ("Subject" nil gnus-header-subject-face)
667 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
668 ("" gnus-header-name-face gnus-header-content-face))
669 "*Controls highlighting of article headers.
671 An alist of the form (HEADER NAME CONTENT).
673 HEADER is a regular expression which should match the name of a
674 header and NAME and CONTENT are either face names or nil.
676 The name of each header field will be displayed using the face
677 specified by the first element in the list where HEADER matches
678 the header name and NAME is non-nil. Similarly, the content will
679 be displayed by the first non-nil matching CONTENT face."
680 :group 'gnus-article-headers
681 :group 'gnus-article-highlight
682 :type '(repeat (list (regexp :tag "Header")
684 (item :tag "skip" nil)
685 (face :value default))
686 (choice :tag "Content"
687 (item :tag "skip" nil)
688 (face :value default)))))
690 (defcustom gnus-article-decode-hook
691 '(article-decode-charset article-decode-encoded-words
692 article-decode-group-name article-decode-idna-rhs)
693 "*Hook run to decode charsets in articles."
694 :group 'gnus-article-headers
697 (defcustom gnus-display-mime-function 'gnus-display-mime
698 "Function to display MIME articles."
699 :group 'gnus-article-mime
702 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
703 "Function used to decode headers.")
705 (defvar gnus-article-dumbquotes-map
725 "Table for MS-to-Latin1 translation.")
727 (defcustom gnus-ignored-mime-types nil
728 "List of MIME types that should be ignored by Gnus."
730 :group 'gnus-article-mime
731 :type '(repeat regexp))
733 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
734 "List of MIME types that should not be given buttons when rendered inline.
735 See also `gnus-buttonized-mime-types' which may override this variable.
736 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
738 :group 'gnus-article-mime
739 :type '(repeat regexp))
741 (defcustom gnus-buttonized-mime-types nil
742 "List of MIME types that should be given buttons when rendered inline.
743 If set, this variable overrides `gnus-unbuttonized-mime-types'.
744 To see e.g. security buttons you could set this to
745 `(\"multipart/signed\")'.
746 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
748 :group 'gnus-article-mime
749 :type '(repeat regexp))
751 (defcustom gnus-inhibit-mime-unbuttonizing nil
752 "If non-nil, all MIME parts get buttons.
753 When nil (the default value), then some MIME parts do not get buttons,
754 as described by the variables `gnus-buttonized-mime-types' and
755 `gnus-unbuttonized-mime-types'."
759 (defcustom gnus-body-boundary-delimiter "_"
760 "String used to delimit header and body.
761 This variable is used by `gnus-article-treat-body-boundary' which can
762 be controlled by `gnus-treat-body-boundary'."
763 :group 'gnus-article-various
764 :type '(choice (item :tag "None" :value nil)
767 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
768 "Defines the location of the faces database.
769 For information on obtaining this database of pretty pictures, please
770 see http://www.cs.indiana.edu/picons/ftp/index.html"
771 :type '(repeat directory)
772 :link '(url-link :tag "download"
773 "http://www.cs.indiana.edu/picons/ftp/index.html")
774 :link '(custom-manual "(gnus)Picons")
777 (defun gnus-picons-installed-p ()
778 "Say whether picons are installed on your machine."
779 (let ((installed nil))
780 (dolist (database gnus-picon-databases)
781 (when (file-exists-p database)
785 (defcustom gnus-article-mime-part-function nil
786 "Function called with a MIME handle as the argument.
787 This is meant for people who want to do something automatic based
788 on parts -- for instance, adding Vcard info to a database."
789 :group 'gnus-article-mime
792 (defcustom gnus-mime-multipart-functions nil
793 "An alist of MIME types to functions to display them."
795 :group 'gnus-article-mime
798 (defcustom gnus-article-date-lapsed-new-header nil
799 "Whether the X-Sent and Date headers can coexist.
800 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
801 either replace the old \"Date:\" header (if this variable is nil), or
802 be added below it (otherwise)."
804 :group 'gnus-article-headers
807 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
808 "Function called with a MIME handle as the argument.
809 This is meant for people who want to view first matched part.
810 For `undisplayed-alternative' (default), the first undisplayed
811 part or alternative part is used. For `undisplayed', the first
812 undisplayed part is used. For a function, the first part which
813 the function return t is used. For nil, the first part is
816 :group 'gnus-article-mime
818 (item :tag "first" :value nil)
819 (item :tag "undisplayed" :value undisplayed)
820 (item :tag "undisplayed or alternative"
821 :value undisplayed-alternative)
824 (defcustom gnus-mime-action-alist
825 '(("save to file" . gnus-mime-save-part)
826 ("save and strip" . gnus-mime-save-part-and-strip)
827 ("delete part" . gnus-mime-delete-part)
828 ("display as text" . gnus-mime-inline-part)
829 ("view the part" . gnus-mime-view-part)
830 ("pipe to command" . gnus-mime-pipe-part)
831 ("toggle display" . gnus-article-press-button)
832 ("toggle display" . gnus-article-view-part-as-charset)
833 ("view as type" . gnus-mime-view-part-as-type)
834 ("view internally" . gnus-mime-view-part-internally)
835 ("view externally" . gnus-mime-view-part-externally))
836 "An alist of actions that run on the MIME attachment."
837 :group 'gnus-article-mime
838 :type '(repeat (cons (string :tag "name")
842 ;;; The treatment variables
845 (defvar gnus-part-display-hook nil
846 "Hook called on parts that are to receive treatment.")
848 (defvar gnus-article-treat-custom
849 '(choice (const :tag "Off" nil)
851 (const :tag "Header" head)
852 (const :tag "Last" last)
853 (integer :tag "Less")
854 (repeat :tag "Groups" regexp)
855 (sexp :tag "Predicate")))
857 (defvar gnus-article-treat-head-custom
858 '(choice (const :tag "Off" nil)
859 (const :tag "Header" head)))
861 (defvar gnus-article-treat-types '("text/plain")
864 (defvar gnus-inhibit-treatment nil
865 "Whether to inhibit treatment.")
867 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
868 "Highlight the signature.
869 Valid values are nil, t, `head', `last', an integer or a predicate.
870 See Info node `(gnus)Customizing Articles'."
871 :group 'gnus-article-treat
872 :link '(custom-manual "(gnus)Customizing Articles")
873 :type gnus-article-treat-custom)
874 (put 'gnus-treat-highlight-signature 'highlight t)
876 (defcustom gnus-treat-buttonize 100000
878 Valid values are nil, t, `head', `last', an integer or a predicate.
879 See Info node `(gnus)Customizing Articles'."
880 :group 'gnus-article-treat
881 :link '(custom-manual "(gnus)Customizing Articles")
882 :type gnus-article-treat-custom)
883 (put 'gnus-treat-buttonize 'highlight t)
885 (defcustom gnus-treat-buttonize-head 'head
886 "Add buttons to the head.
887 Valid values are nil, t, `head', `last', an integer or a predicate.
888 See Info node `(gnus)Customizing Articles' for details."
889 :group 'gnus-article-treat
890 :link '(custom-manual "(gnus)Customizing Articles")
891 :type gnus-article-treat-head-custom)
892 (put 'gnus-treat-buttonize-head 'highlight t)
894 (defcustom gnus-treat-emphasize
895 (and (or window-system
897 (>= (string-to-number emacs-version) 21))
900 Valid values are nil, t, `head', `last', an integer or a predicate.
901 See Info node `(gnus)Customizing Articles' for details."
902 :group 'gnus-article-treat
903 :link '(custom-manual "(gnus)Customizing Articles")
904 :type gnus-article-treat-custom)
905 (put 'gnus-treat-emphasize 'highlight t)
907 (defcustom gnus-treat-strip-cr nil
908 "Remove carriage returns.
909 Valid values are nil, t, `head', `last', an integer or a predicate.
910 See Info node `(gnus)Customizing Articles' for details."
911 :group 'gnus-article-treat
912 :link '(custom-manual "(gnus)Customizing Articles")
913 :type gnus-article-treat-custom)
915 (defcustom gnus-treat-unsplit-urls nil
916 "Remove newlines from within URLs.
917 Valid values are nil, t, `head', `last', an integer or a predicate.
918 See Info node `(gnus)Customizing Articles' for details."
919 :group 'gnus-article-treat
920 :link '(custom-manual "(gnus)Customizing Articles")
921 :type gnus-article-treat-custom)
923 (defcustom gnus-treat-leading-whitespace nil
924 "Remove leading whitespace in headers.
925 Valid values are nil, t, `head', `last', an integer or a predicate.
926 See Info node `(gnus)Customizing Articles' for details."
927 :group 'gnus-article-treat
928 :link '(custom-manual "(gnus)Customizing Articles")
929 :type gnus-article-treat-custom)
931 (defcustom gnus-treat-hide-headers 'head
933 Valid values are nil, t, `head', `last', an integer or a predicate.
934 See Info node `(gnus)Customizing Articles' for details."
935 :group 'gnus-article-treat
936 :link '(custom-manual "(gnus)Customizing Articles")
937 :type gnus-article-treat-head-custom)
939 (defcustom gnus-treat-hide-boring-headers nil
940 "Hide boring headers.
941 Valid values are nil, t, `head', `last', an integer or a predicate.
942 See Info node `(gnus)Customizing Articles' for details."
943 :group 'gnus-article-treat
944 :link '(custom-manual "(gnus)Customizing Articles")
945 :type gnus-article-treat-head-custom)
947 (defcustom gnus-treat-hide-signature nil
949 Valid values are nil, t, `head', `last', an integer or a predicate.
950 See Info node `(gnus)Customizing Articles' for details."
951 :group 'gnus-article-treat
952 :link '(custom-manual "(gnus)Customizing Articles")
953 :type gnus-article-treat-custom)
955 (defcustom gnus-treat-fill-article nil
957 Valid values are nil, t, `head', `last', an integer or a predicate.
958 See Info node `(gnus)Customizing Articles' for details."
959 :group 'gnus-article-treat
960 :link '(custom-manual "(gnus)Customizing Articles")
961 :type gnus-article-treat-custom)
963 (defcustom gnus-treat-hide-citation nil
965 Valid values are nil, t, `head', `last', an integer or a predicate.
966 See Info node `(gnus)Customizing Articles' for details."
967 :group 'gnus-article-treat
968 :link '(custom-manual "(gnus)Customizing Articles")
969 :type gnus-article-treat-custom)
971 (defcustom gnus-treat-hide-citation-maybe nil
973 Valid values are nil, t, `head', `last', an integer or a predicate.
974 See Info node `(gnus)Customizing Articles' for details."
975 :group 'gnus-article-treat
976 :link '(custom-manual "(gnus)Customizing Articles")
977 :type gnus-article-treat-custom)
979 (defcustom gnus-treat-strip-list-identifiers 'head
980 "Strip list identifiers from `gnus-list-identifiers`.
981 Valid values are nil, t, `head', `last', an integer or a predicate.
982 See Info node `(gnus)Customizing Articles' for details."
984 :group 'gnus-article-treat
985 :link '(custom-manual "(gnus)Customizing Articles")
986 :type gnus-article-treat-custom)
988 (make-obsolete-variable 'gnus-treat-strip-pgp
989 "This option is obsolete in Gnus 5.10.")
991 (defcustom gnus-treat-strip-pem nil
992 "Strip PEM signatures.
993 Valid values are nil, t, `head', `last', an integer or a predicate.
994 See Info node `(gnus)Customizing Articles' for details."
995 :group 'gnus-article-treat
996 :link '(custom-manual "(gnus)Customizing Articles")
997 :type gnus-article-treat-custom)
999 (defcustom gnus-treat-strip-banner t
1000 "Strip banners from articles.
1001 The banner to be stripped is specified in the `banner' group parameter.
1002 Valid values are nil, t, `head', `last', an integer or a predicate.
1003 See Info node `(gnus)Customizing Articles' for details."
1004 :group 'gnus-article-treat
1005 :link '(custom-manual "(gnus)Customizing Articles")
1006 :type gnus-article-treat-custom)
1008 (defcustom gnus-treat-highlight-headers 'head
1009 "Highlight the headers.
1010 Valid values are nil, t, `head', `last', an integer or a predicate.
1011 See Info node `(gnus)Customizing Articles' for details."
1012 :group 'gnus-article-treat
1013 :link '(custom-manual "(gnus)Customizing Articles")
1014 :type gnus-article-treat-head-custom)
1015 (put 'gnus-treat-highlight-headers 'highlight t)
1017 (defcustom gnus-treat-highlight-citation t
1018 "Highlight cited text.
1019 Valid values are nil, t, `head', `last', an integer or a predicate.
1020 See Info node `(gnus)Customizing Articles' for details."
1021 :group 'gnus-article-treat
1022 :link '(custom-manual "(gnus)Customizing Articles")
1023 :type gnus-article-treat-custom)
1024 (put 'gnus-treat-highlight-citation 'highlight t)
1026 (defcustom gnus-treat-date-ut nil
1027 "Display the Date in UT (GMT).
1028 Valid values are nil, t, `head', `last', an integer or a predicate.
1029 See Info node `(gnus)Customizing Articles' for details."
1030 :group 'gnus-article-treat
1031 :link '(custom-manual "(gnus)Customizing Articles")
1032 :type gnus-article-treat-head-custom)
1034 (defcustom gnus-treat-date-local nil
1035 "Display the Date in the local timezone.
1036 Valid values are nil, t, `head', `last', an integer or a predicate.
1037 See Info node `(gnus)Customizing Articles' for details."
1038 :group 'gnus-article-treat
1039 :link '(custom-manual "(gnus)Customizing Articles")
1040 :type gnus-article-treat-head-custom)
1042 (defcustom gnus-treat-date-english nil
1043 "Display the Date in a format that can be read aloud in English.
1044 Valid values are nil, t, `head', `last', an integer or a predicate.
1045 See Info node `(gnus)Customizing Articles' for details."
1046 :group 'gnus-article-treat
1047 :link '(custom-manual "(gnus)Customizing Articles")
1048 :type gnus-article-treat-head-custom)
1050 (defcustom gnus-treat-date-lapsed nil
1051 "Display the Date header in a way that says how much time has elapsed.
1052 Valid values are nil, t, `head', `last', an integer or a predicate.
1053 See Info node `(gnus)Customizing Articles' for details."
1054 :group 'gnus-article-treat
1055 :link '(custom-manual "(gnus)Customizing Articles")
1056 :type gnus-article-treat-head-custom)
1058 (defcustom gnus-treat-date-original nil
1059 "Display the date in the original timezone.
1060 Valid values are nil, t, `head', `last', an integer or a predicate.
1061 See Info node `(gnus)Customizing Articles' for details."
1062 :group 'gnus-article-treat
1063 :link '(custom-manual "(gnus)Customizing Articles")
1064 :type gnus-article-treat-head-custom)
1066 (defcustom gnus-treat-date-iso8601 nil
1067 "Display the date in the ISO8601 format.
1068 Valid values are nil, t, `head', `last', an integer or a predicate.
1069 See Info node `(gnus)Customizing Articles' for details."
1071 :group 'gnus-article-treat
1072 :link '(custom-manual "(gnus)Customizing Articles")
1073 :type gnus-article-treat-head-custom)
1075 (defcustom gnus-treat-date-user-defined nil
1076 "Display the date in a user-defined format.
1077 The format is defined by the `gnus-article-time-format' variable.
1078 Valid values are nil, t, `head', `last', an integer or a predicate.
1079 See Info node `(gnus)Customizing Articles' for details."
1080 :group 'gnus-article-treat
1081 :link '(custom-manual "(gnus)Customizing Articles")
1082 :type gnus-article-treat-head-custom)
1084 (defcustom gnus-treat-strip-headers-in-body t
1085 "Strip the X-No-Archive header line from the beginning of the body.
1086 Valid values are nil, t, `head', `last', an integer or a predicate.
1087 See Info node `(gnus)Customizing Articles' for details."
1089 :group 'gnus-article-treat
1090 :link '(custom-manual "(gnus)Customizing Articles")
1091 :type gnus-article-treat-custom)
1093 (defcustom gnus-treat-strip-trailing-blank-lines nil
1094 "Strip trailing blank lines.
1095 Valid values are nil, t, `head', `last', an integer or a predicate.
1096 See Info node `(gnus)Customizing Articles' for details."
1097 :group 'gnus-article-treat
1098 :link '(custom-manual "(gnus)Customizing Articles")
1099 :type gnus-article-treat-custom)
1101 (defcustom gnus-treat-strip-leading-blank-lines nil
1102 "Strip leading blank lines.
1103 Valid values are nil, t, `head', `last', an integer or a predicate.
1104 See Info node `(gnus)Customizing Articles' for details."
1105 :group 'gnus-article-treat
1106 :link '(custom-manual "(gnus)Customizing Articles")
1107 :type gnus-article-treat-custom)
1109 (defcustom gnus-treat-strip-multiple-blank-lines nil
1110 "Strip multiple blank lines.
1111 Valid values are nil, t, `head', `last', an integer or a predicate.
1112 See Info node `(gnus)Customizing Articles' for details."
1113 :group 'gnus-article-treat
1114 :link '(custom-manual "(gnus)Customizing Articles")
1115 :type gnus-article-treat-custom)
1117 (defcustom gnus-treat-unfold-headers 'head
1118 "Unfold folded header lines.
1119 Valid values are nil, t, `head', `last', an integer or a predicate.
1120 See Info node `(gnus)Customizing Articles' for details."
1121 :group 'gnus-article-treat
1122 :link '(custom-manual "(gnus)Customizing Articles")
1123 :type gnus-article-treat-custom)
1125 (defcustom gnus-treat-fold-headers nil
1127 Valid values are nil, t, `head', `last', an integer or a predicate.
1128 See Info node `(gnus)Customizing Articles' for details."
1129 :group 'gnus-article-treat
1130 :link '(custom-manual "(gnus)Customizing Articles")
1131 :type gnus-article-treat-custom)
1133 (defcustom gnus-treat-fold-newsgroups 'head
1134 "Fold the Newsgroups and Followup-To headers.
1135 Valid values are nil, t, `head', `last', an integer or a predicate.
1136 See Info node `(gnus)Customizing Articles' for details."
1137 :group 'gnus-article-treat
1138 :link '(custom-manual "(gnus)Customizing Articles")
1139 :type gnus-article-treat-custom)
1141 (defcustom gnus-treat-overstrike t
1142 "Treat overstrike highlighting.
1143 Valid values are nil, t, `head', `last', an integer or a predicate.
1144 See Info node `(gnus)Customizing Articles' for details."
1145 :group 'gnus-article-treat
1146 :link '(custom-manual "(gnus)Customizing Articles")
1147 :type gnus-article-treat-custom)
1148 (put 'gnus-treat-overstrike 'highlight t)
1150 (make-obsolete-variable 'gnus-treat-display-xface
1151 'gnus-treat-display-x-face)
1153 (defcustom gnus-treat-display-x-face
1154 (and (not noninteractive)
1155 (or (and (fboundp 'image-type-available-p)
1156 (image-type-available-p 'xbm)
1157 (string-match "^0x" (shell-command-to-string "uncompface"))
1158 (executable-find "icontopbm"))
1159 (and (featurep 'xemacs)
1162 "Display X-Face headers.
1163 Valid values are nil, t, `head', `last', an integer or a predicate.
1164 See Info node `(gnus)Customizing Articles' and Info node
1165 `(gnus)X-Face' for details."
1166 :group 'gnus-article-treat
1168 :link '(custom-manual "(gnus)Customizing Articles")
1169 :link '(custom-manual "(gnus)X-Face")
1170 :type gnus-article-treat-head-custom
1171 :set (lambda (symbol value)
1174 (cond ((or (boundp symbol) (get symbol 'saved-value))
1176 ((boundp 'gnus-treat-display-xface)
1178 ** gnus-treat-display-xface is an obsolete variable;\
1179 use gnus-treat-display-x-face instead")
1180 (default-value 'gnus-treat-display-xface))
1181 ((get 'gnus-treat-display-xface 'saved-value)
1183 ** gnus-treat-display-xface is an obsolete variable;\
1184 use gnus-treat-display-x-face instead")
1185 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1188 (put 'gnus-treat-display-x-face 'highlight t)
1190 (defcustom gnus-treat-display-face
1191 (and (not noninteractive)
1192 (or (and (fboundp 'image-type-available-p)
1193 (image-type-available-p 'png))
1194 (and (featurep 'xemacs)
1197 "Display Face headers.
1198 Valid values are nil, t, `head', `last', an integer or a predicate.
1199 See Info node `(gnus)Customizing Articles' and Info node
1200 `(gnus)X-Face' for details."
1201 :group 'gnus-article-treat
1203 :link '(custom-manual "(gnus)Customizing Articles")
1204 :link '(custom-manual "(gnus)X-Face")
1205 :type gnus-article-treat-head-custom)
1206 (put 'gnus-treat-display-face 'highlight t)
1208 (defcustom gnus-treat-display-smileys
1209 (if (or (and (featurep 'xemacs)
1211 (and (fboundp 'image-type-available-p)
1212 (image-type-available-p 'pbm)))
1215 Valid values are nil, t, `head', `last', an integer or a predicate.
1216 See Info node `(gnus)Customizing Articles' and Info node
1217 `(gnus)Smileys' for details."
1218 :group 'gnus-article-treat
1220 :link '(custom-manual "(gnus)Customizing Articles")
1221 :link '(custom-manual "(gnus)Smileys")
1222 :type gnus-article-treat-custom)
1223 (put 'gnus-treat-display-smileys 'highlight t)
1225 (defcustom gnus-treat-from-picon
1226 (if (and (gnus-image-type-available-p 'xpm)
1227 (gnus-picons-installed-p))
1229 "Display picons in the From header.
1230 Valid values are nil, t, `head', `last', an integer or a predicate.
1231 See Info node `(gnus)Customizing Articles' and Info node
1232 `(gnus)Picons' for details."
1233 :group 'gnus-article-treat
1235 :link '(custom-manual "(gnus)Customizing Articles")
1236 :link '(custom-manual "(gnus)Picons")
1237 :type gnus-article-treat-head-custom)
1238 (put 'gnus-treat-from-picon 'highlight t)
1240 (defcustom gnus-treat-mail-picon
1241 (if (and (gnus-image-type-available-p 'xpm)
1242 (gnus-picons-installed-p))
1244 "Display picons in To and Cc headers.
1245 Valid values are nil, t, `head', `last', an integer or a predicate.
1246 See Info node `(gnus)Customizing Articles' and Info node
1247 `(gnus)Picons' for details."
1248 :group 'gnus-article-treat
1250 :link '(custom-manual "(gnus)Customizing Articles")
1251 :link '(custom-manual "(gnus)Picons")
1252 :type gnus-article-treat-head-custom)
1253 (put 'gnus-treat-mail-picon 'highlight t)
1255 (defcustom gnus-treat-newsgroups-picon
1256 (if (and (gnus-image-type-available-p 'xpm)
1257 (gnus-picons-installed-p))
1259 "Display picons in the Newsgroups and Followup-To headers.
1260 Valid values are nil, t, `head', `last', an integer or a predicate.
1261 See Info node `(gnus)Customizing Articles' and Info node
1262 `(gnus)Picons' for details."
1263 :group 'gnus-article-treat
1265 :link '(custom-manual "(gnus)Customizing Articles")
1266 :link '(custom-manual "(gnus)Picons")
1267 :type gnus-article-treat-head-custom)
1268 (put 'gnus-treat-newsgroups-picon 'highlight t)
1270 (defcustom gnus-treat-body-boundary
1271 (if (or gnus-treat-newsgroups-picon
1272 gnus-treat-mail-picon
1273 gnus-treat-from-picon)
1275 "Draw a boundary at the end of the headers.
1276 Valid values are nil, t, `head', `last', an integer or a predicate.
1277 See Info node `(gnus)Customizing Articles' for details."
1279 :group 'gnus-article-treat
1280 :link '(custom-manual "(gnus)Customizing Articles")
1281 :type gnus-article-treat-custom)
1283 (defcustom gnus-treat-capitalize-sentences nil
1284 "Capitalize sentence-starting words.
1285 Valid values are nil, t, `head', `last', an integer or a predicate.
1286 See Info node `(gnus)Customizing Articles' for details."
1288 :group 'gnus-article-treat
1289 :link '(custom-manual "(gnus)Customizing Articles")
1290 :type gnus-article-treat-custom)
1292 (defcustom gnus-treat-wash-html nil
1294 Valid values are nil, t, `head', `last', an integer or a predicate.
1295 See Info node `(gnus)Customizing Articles' for details."
1296 :group 'gnus-article-treat
1297 :link '(custom-manual "(gnus)Customizing Articles")
1298 :type gnus-article-treat-custom)
1300 (defcustom gnus-treat-fill-long-lines nil
1302 Valid values are nil, t, `head', `last', an integer or a predicate.
1303 See Info node `(gnus)Customizing Articles' for details."
1304 :group 'gnus-article-treat
1305 :link '(custom-manual "(gnus)Customizing Articles")
1306 :type gnus-article-treat-custom)
1308 (defcustom gnus-treat-play-sounds nil
1310 Valid values are nil, t, `head', `last', an integer or a predicate.
1311 See Info node `(gnus)Customizing Articles' for details."
1313 :group 'gnus-article-treat
1314 :link '(custom-manual "(gnus)Customizing Articles")
1315 :type gnus-article-treat-custom)
1317 (defcustom gnus-treat-translate nil
1318 "Translate articles from one language to another.
1319 Valid values are nil, t, `head', `last', an integer or a predicate.
1320 See Info node `(gnus)Customizing Articles' for details."
1322 :group 'gnus-article-treat
1323 :link '(custom-manual "(gnus)Customizing Articles")
1324 :type gnus-article-treat-custom)
1326 (defcustom gnus-treat-x-pgp-sig nil
1328 To automatically treat X-PGP-Sig, set it to head.
1329 Valid values are nil, t, `head', `last', an integer or a predicate.
1330 See Info node `(gnus)Customizing Articles' for details."
1331 :group 'gnus-article-treat
1332 :group 'mime-security
1333 :link '(custom-manual "(gnus)Customizing Articles")
1334 :type gnus-article-treat-custom)
1336 (defvar gnus-article-encrypt-protocol-alist
1337 '(("PGP" . mml2015-self-encrypt)))
1339 ;; Set to nil if more than one protocol added to
1340 ;; gnus-article-encrypt-protocol-alist.
1341 (defcustom gnus-article-encrypt-protocol "PGP"
1342 "The protocol used for encrypt articles.
1343 It is a string, such as \"PGP\". If nil, ask user."
1345 :group 'mime-security)
1347 (defvar gnus-article-wash-function nil
1348 "Function used for converting HTML into text.")
1350 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1351 (mm-coding-system-p 'utf-8)
1352 (executable-find idna-program))
1353 "Whether IDNA decoding of headers is used when viewing messages.
1354 This requires GNU Libidn, and by default only enabled if it is found."
1355 :group 'gnus-article-headers
1358 (defcustom gnus-article-over-scroll nil
1359 "If non-nil, allow scrolling the article buffer even when there no more text."
1360 :group 'gnus-article
1363 ;;; Internal variables
1365 (defvar gnus-english-month-names
1366 '("January" "February" "March" "April" "May" "June" "July" "August"
1367 "September" "October" "November" "December"))
1369 (defvar article-goto-body-goes-to-point-min-p nil)
1370 (defvar gnus-article-wash-types nil)
1371 (defvar gnus-article-emphasis-alist nil)
1372 (defvar gnus-article-image-alist nil)
1374 (defvar gnus-article-mime-handle-alist-1 nil)
1375 (defvar gnus-treatment-function-alist
1376 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1377 (gnus-treat-strip-banner gnus-article-strip-banner)
1378 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1379 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1380 (gnus-treat-buttonize gnus-article-add-buttons)
1381 (gnus-treat-fill-article gnus-article-fill-cited-article)
1382 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1383 (gnus-treat-strip-cr gnus-article-remove-cr)
1384 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1385 (gnus-treat-date-ut gnus-article-date-ut)
1386 (gnus-treat-date-local gnus-article-date-local)
1387 (gnus-treat-date-english gnus-article-date-english)
1388 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1389 (gnus-treat-date-original gnus-article-date-original)
1390 (gnus-treat-date-user-defined gnus-article-date-user)
1391 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1392 (gnus-treat-display-x-face gnus-article-display-x-face)
1393 (gnus-treat-display-face gnus-article-display-face)
1394 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1395 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1396 (gnus-treat-hide-signature gnus-article-hide-signature)
1397 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1398 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1399 (gnus-treat-strip-pem gnus-article-hide-pem)
1400 (gnus-treat-from-picon gnus-treat-from-picon)
1401 (gnus-treat-mail-picon gnus-treat-mail-picon)
1402 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1403 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1404 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1405 (gnus-treat-strip-trailing-blank-lines
1406 gnus-article-remove-trailing-blank-lines)
1407 (gnus-treat-strip-leading-blank-lines
1408 gnus-article-strip-leading-blank-lines)
1409 (gnus-treat-strip-multiple-blank-lines
1410 gnus-article-strip-multiple-blank-lines)
1411 (gnus-treat-overstrike gnus-article-treat-overstrike)
1412 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1413 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1414 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1415 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1416 (gnus-treat-display-smileys gnus-treat-smiley)
1417 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1418 (gnus-treat-wash-html gnus-article-wash-html)
1419 (gnus-treat-emphasize gnus-article-emphasize)
1420 (gnus-treat-hide-citation gnus-article-hide-citation)
1421 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1422 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1423 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1424 (gnus-treat-play-sounds gnus-earcon-display)))
1426 (defvar gnus-article-mime-handle-alist nil)
1427 (defvar article-lapsed-timer nil)
1428 (defvar gnus-article-current-summary nil)
1430 (defvar gnus-article-mode-syntax-table
1431 (let ((table (copy-syntax-table text-mode-syntax-table)))
1432 ;; This causes the citation match run O(2^n).
1433 ;; (modify-syntax-entry ?- "w" table)
1434 (modify-syntax-entry ?> ")<" table)
1435 (modify-syntax-entry ?< "(>" table)
1436 ;; make M-. in article buffers work for `foo' strings
1437 (modify-syntax-entry ?' " " table)
1438 (modify-syntax-entry ?` " " table)
1440 "Syntax table used in article mode buffers.
1441 Initialized from `text-mode-syntax-table.")
1443 (defvar gnus-save-article-buffer nil)
1445 (defvar gnus-article-mode-line-format-alist
1446 (nconc '((?w (gnus-article-wash-status) ?s)
1447 (?m (gnus-article-mime-part-status) ?s))
1448 gnus-summary-mode-line-format-alist))
1450 (defvar gnus-number-of-articles-to-be-saved nil)
1452 (defvar gnus-inhibit-hiding nil)
1454 ;;; Macros for dealing with the article buffer.
1456 (defmacro gnus-with-article-headers (&rest forms)
1458 (set-buffer gnus-article-buffer)
1460 (let ((buffer-read-only nil)
1461 (inhibit-point-motion-hooks t)
1462 (case-fold-search t))
1463 (article-narrow-to-head)
1466 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1467 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1469 (defmacro gnus-with-article-buffer (&rest forms)
1471 (set-buffer gnus-article-buffer)
1472 (let ((buffer-read-only nil))
1475 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1476 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1478 (defun gnus-article-goto-header (header)
1479 "Go to HEADER, which is a regular expression."
1480 (re-search-forward (concat "^\\(" header "\\):") nil t))
1482 (defsubst gnus-article-hide-text (b e props)
1483 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1484 (gnus-add-text-properties-when 'article-type nil b e props)
1485 (when (memq 'intangible props)
1487 (max (1- b) (point-min))
1488 b 'intangible (cddr (memq 'intangible props)))))
1490 (defsubst gnus-article-unhide-text (b e)
1491 "Remove hidden text properties from region between B and E."
1492 (remove-text-properties b e gnus-hidden-properties)
1493 (when (memq 'intangible gnus-hidden-properties)
1494 (put-text-property (max (1- b) (point-min))
1495 b 'intangible nil)))
1497 (defun gnus-article-hide-text-type (b e type)
1498 "Hide text of TYPE between B and E."
1499 (gnus-add-wash-type type)
1500 (gnus-article-hide-text
1501 b e (cons 'article-type (cons type gnus-hidden-properties))))
1503 (defun gnus-article-unhide-text-type (b e type)
1504 "Unhide text of TYPE between B and E."
1505 (gnus-delete-wash-type type)
1506 (remove-text-properties
1507 b e (cons 'article-type (cons type gnus-hidden-properties)))
1508 (when (memq 'intangible gnus-hidden-properties)
1509 (put-text-property (max (1- b) (point-min))
1510 b 'intangible nil)))
1512 (defun gnus-article-hide-text-of-type (type)
1513 "Hide text of TYPE in the current buffer."
1515 (let ((b (point-min))
1517 (while (setq b (text-property-any b e 'article-type type))
1518 (add-text-properties b (incf b) gnus-hidden-properties)))))
1520 (defun gnus-article-delete-text-of-type (type)
1521 "Delete text of TYPE in the current buffer."
1523 (let ((b (point-min)))
1524 (while (setq b (text-property-any b (point-max) 'article-type type))
1526 b (or (text-property-not-all b (point-max) 'article-type type)
1529 (defun gnus-article-delete-invisible-text ()
1530 "Delete all invisible text in the current buffer."
1532 (let ((b (point-min)))
1533 (while (setq b (text-property-any b (point-max) 'invisible t))
1535 b (or (text-property-not-all b (point-max) 'invisible t)
1538 (defun gnus-article-text-type-exists-p (type)
1539 "Say whether any text of type TYPE exists in the buffer."
1540 (text-property-any (point-min) (point-max) 'article-type type))
1542 (defsubst gnus-article-header-rank ()
1543 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1544 (let ((list gnus-sorted-header-list)
1547 (if (looking-at (car list))
1549 (setq list (cdr list))
1553 (defun article-hide-headers (&optional arg delete)
1554 "Hide unwanted headers and possibly sort them as well."
1556 ;; This function might be inhibited.
1557 (unless gnus-inhibit-hiding
1560 (let ((buffer-read-only nil)
1561 (case-fold-search t)
1562 (max (1+ (length gnus-sorted-header-list)))
1563 (ignored (when (not gnus-visible-headers)
1564 (cond ((stringp gnus-ignored-headers)
1565 gnus-ignored-headers)
1566 ((listp gnus-ignored-headers)
1567 (mapconcat 'identity gnus-ignored-headers
1570 (cond ((stringp gnus-visible-headers)
1571 gnus-visible-headers)
1572 ((and gnus-visible-headers
1573 (listp gnus-visible-headers))
1574 (mapconcat 'identity gnus-visible-headers "\\|"))))
1575 (inhibit-point-motion-hooks t)
1577 ;; First we narrow to just the headers.
1578 (article-narrow-to-head)
1579 ;; Hide any "From " lines at the beginning of (mail) articles.
1580 (while (looking-at "From ")
1583 (delete-region (point-min) (point)))
1584 ;; Then treat the rest of the header lines.
1585 ;; Then we use the two regular expressions
1586 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1587 ;; select which header lines is to remain visible in the
1589 (while (re-search-forward "^[^ \t:]*:" nil t)
1591 ;; Mark the rank of the header.
1593 (point) (1+ (point)) 'message-rank
1594 (if (or (and visible (looking-at visible))
1596 (not (looking-at ignored))))
1597 (gnus-article-header-rank)
1600 (message-sort-headers-1)
1601 (when (setq beg (text-property-any
1602 (point-min) (point-max) 'message-rank (+ 2 max)))
1603 ;; We delete the unwanted headers.
1604 (gnus-add-wash-type 'headers)
1605 (add-text-properties (point-min) (+ 5 (point-min))
1606 '(article-type headers dummy-invisible t))
1607 (delete-region beg (point-max))))))))
1609 (defun article-hide-boring-headers (&optional arg)
1610 "Toggle hiding of headers that aren't very interesting.
1611 If given a negative prefix, always show; if given a positive prefix,
1613 (interactive (gnus-article-hidden-arg))
1614 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1615 (not gnus-show-all-headers))
1618 (let ((buffer-read-only nil)
1619 (list gnus-boring-article-headers)
1620 (inhibit-point-motion-hooks t)
1622 (article-narrow-to-head)
1624 (setq elem (pop list))
1625 (goto-char (point-min))
1627 ;; Hide empty headers.
1629 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1631 (gnus-article-hide-text-type
1635 (if (re-search-forward "^[^ \t]" nil t)
1639 ;; Hide boring Newsgroups header.
1640 ((eq elem 'newsgroups)
1641 (when (gnus-string-equal
1642 (gnus-fetch-field "newsgroups")
1643 (gnus-group-real-name
1644 (if (boundp 'gnus-newsgroup-name)
1647 (gnus-article-hide-header "newsgroups")))
1648 ((eq elem 'to-address)
1649 (let ((to (message-fetch-field "to"))
1651 (gnus-parameter-to-address
1652 (if (boundp 'gnus-newsgroup-name)
1653 gnus-newsgroup-name ""))))
1654 (when (and to to-address
1657 ;; only one address in To
1658 (nth 1 (mail-extract-address-components to))
1660 (gnus-article-hide-header "to"))))
1662 (let ((to (message-fetch-field "to"))
1664 (gnus-parameter-to-list
1665 (if (boundp 'gnus-newsgroup-name)
1666 gnus-newsgroup-name ""))))
1667 (when (and to to-list
1670 ;; only one address in To
1671 (nth 1 (mail-extract-address-components to))
1673 (gnus-article-hide-header "to"))))
1675 (let ((cc (message-fetch-field "cc"))
1677 (gnus-parameter-to-list
1678 (if (boundp 'gnus-newsgroup-name)
1679 gnus-newsgroup-name ""))))
1680 (when (and cc to-list
1683 ;; only one address in CC
1684 (nth 1 (mail-extract-address-components cc))
1686 (gnus-article-hide-header "cc"))))
1687 ((eq elem 'followup-to)
1688 (when (gnus-string-equal
1689 (message-fetch-field "followup-to")
1690 (message-fetch-field "newsgroups"))
1691 (gnus-article-hide-header "followup-to")))
1692 ((eq elem 'reply-to)
1693 (if (gnus-group-find-parameter
1694 gnus-newsgroup-name 'broken-reply-to)
1695 (gnus-article-hide-header "reply-to")
1696 (let ((from (message-fetch-field "from"))
1697 (reply-to (message-fetch-field "reply-to")))
1704 (lambda (x) (downcase (cadr x)))
1705 (mail-extract-address-components from t))
1708 (lambda (x) (downcase (cadr x)))
1709 (mail-extract-address-components reply-to t))
1711 (gnus-article-hide-header "reply-to")))))
1713 (let ((date (message-fetch-field "date")))
1715 (< (days-between (current-time-string) date)
1717 (gnus-article-hide-header "date"))))
1719 (let ((to (message-fetch-field "to"))
1720 (cc (message-fetch-field "cc")))
1721 (when (> (length to) 1024)
1722 (gnus-article-hide-header "to"))
1723 (when (> (length cc) 1024)
1724 (gnus-article-hide-header "cc"))))
1728 (goto-char (point-min))
1729 (while (re-search-forward "^to:" nil t)
1730 (setq to-count (1+ to-count)))
1731 (when (> to-count 1)
1732 (while (> to-count 0)
1733 (goto-char (point-min))
1735 (re-search-forward "^to:" nil nil to-count)
1737 (narrow-to-region (point) (point-max))
1738 (gnus-article-hide-header "to"))
1739 (setq to-count (1- to-count))))
1740 (goto-char (point-min))
1741 (while (re-search-forward "^cc:" nil t)
1742 (setq cc-count (1+ cc-count)))
1743 (when (> cc-count 1)
1744 (while (> cc-count 0)
1745 (goto-char (point-min))
1747 (re-search-forward "^cc:" nil nil cc-count)
1749 (narrow-to-region (point) (point-max))
1750 (gnus-article-hide-header "cc"))
1751 (setq cc-count (1- cc-count)))))))))))))
1753 (defun gnus-article-hide-header (header)
1755 (goto-char (point-min))
1756 (when (re-search-forward (concat "^" header ":") nil t)
1757 (gnus-article-hide-text-type
1761 (if (re-search-forward "^[^ \t]" nil t)
1766 (defvar gnus-article-normalized-header-length 40
1767 "Length of normalized headers.")
1769 (defun article-normalize-headers ()
1770 "Make all header lines 40 characters long."
1772 (let ((buffer-read-only nil)
1776 (article-narrow-to-head)
1779 ((< (setq column (- (gnus-point-at-eol) (point)))
1780 gnus-article-normalized-header-length)
1782 (insert (make-string
1783 (- gnus-article-normalized-header-length column)
1785 ((> column gnus-article-normalized-header-length)
1786 (gnus-put-text-property
1788 (forward-char gnus-article-normalized-header-length)
1795 (forward-line 1))))))
1797 (defun article-treat-dumbquotes ()
1798 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1799 Note that this function guesses whether a character is a sm*rtq**t* or
1800 not, so it should only be used interactively.
1802 Sm*rtq**t*s are M****s***'s unilateral extension to the
1803 iso-8859-1 character map in an attempt to provide more quoting
1804 characters. If you see something like \\222 or \\264 where
1805 you're expecting some kind of apostrophe or quotation mark, then
1808 (article-translate-strings gnus-article-dumbquotes-map))
1810 (defun article-translate-characters (from to)
1811 "Translate all characters in the body of the article according to FROM and TO.
1812 FROM is a string of characters to translate from; to is a string of
1813 characters to translate to."
1815 (when (article-goto-body)
1816 (let ((buffer-read-only nil)
1817 (x (make-string 225 ?x))
1819 (while (< (incf i) (length x))
1822 (while (< i (length from))
1823 (aset x (aref from i) (aref to i))
1825 (translate-region (point) (point-max) x)))))
1827 (defun article-translate-strings (map)
1828 "Translate all string in the body of the article according to MAP.
1829 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1831 (when (article-goto-body)
1832 (let ((buffer-read-only nil)
1834 (while (setq elem (pop map))
1836 (while (search-forward (car elem) nil t)
1837 (replace-match (cadr elem)))))))))
1839 (defun article-treat-overstrike ()
1840 "Translate overstrikes into bold text."
1843 (when (article-goto-body)
1844 (let ((buffer-read-only nil))
1845 (while (search-forward "\b" nil t)
1846 (let ((next (char-after))
1847 (previous (char-after (- (point) 2))))
1848 ;; We do the boldification/underlining by hiding the
1849 ;; overstrikes and putting the proper text property
1853 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1854 (put-text-property (point) (1+ (point)) 'face 'bold))
1856 (gnus-article-hide-text-type
1857 (1- (point)) (1+ (point)) 'overstrike)
1859 (- (point) 2) (1- (point)) 'face 'underline))
1861 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1863 (point) (1+ (point)) 'face 'underline)))))))))
1865 (defun gnus-article-treat-unfold-headers ()
1866 "Unfold folded message headers.
1867 Only the headers that fit into the current window width will be
1870 (gnus-with-article-headers
1874 (mail-header-narrow-to-field)
1875 (let ((header (buffer-string)))
1878 (goto-char (point-min))
1879 (while (re-search-forward "\n[\t ]" nil t)
1880 (replace-match " " t t)))
1881 (setq length (- (point-max) (point-min) 1)))
1882 (when (< length (window-width))
1883 (while (re-search-forward "\n[\t ]" nil t)
1884 (replace-match " " t t)))
1885 (goto-char (point-max)))))))
1887 (defun gnus-article-treat-fold-headers ()
1888 "Fold message headers."
1890 (gnus-with-article-headers
1893 (mail-header-narrow-to-field)
1894 (mail-header-fold-field)
1895 (goto-char (point-max))))))
1897 (defun gnus-treat-smiley ()
1898 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1900 (gnus-with-article-buffer
1901 (if (memq 'smiley gnus-article-wash-types)
1902 (gnus-delete-images 'smiley)
1904 (let ((images (smiley-region (point) (point-max))))
1906 (gnus-add-wash-type 'smiley)
1907 (dolist (image images)
1908 (gnus-add-image 'smiley image)))))))
1910 (defun gnus-article-remove-images ()
1911 "Remove all images from the article buffer."
1913 (gnus-with-article-buffer
1914 (dolist (elem gnus-article-image-alist)
1915 (gnus-delete-images (car elem)))))
1917 (defun gnus-article-treat-fold-newsgroups ()
1918 "Unfold folded message headers.
1919 Only the headers that fit into the current window width will be
1922 (gnus-with-article-headers
1923 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1925 (mail-header-narrow-to-field)
1926 (while (re-search-forward ", *" nil t)
1927 (replace-match ", " t t))
1928 (mail-header-fold-field)
1929 (goto-char (point-max))))))
1931 (defun gnus-article-treat-body-boundary ()
1932 "Place a boundary line at the end of the headers."
1934 (when (and gnus-body-boundary-delimiter
1935 (> (length gnus-body-boundary-delimiter) 0))
1936 (gnus-with-article-headers
1937 (goto-char (point-max))
1938 (let ((start (point)))
1939 (insert "X-Boundary: ")
1940 (gnus-add-text-properties start (point) '(invisible t intangible t))
1942 (while (>= (1- (window-width)) (length str))
1943 (setq str (concat str gnus-body-boundary-delimiter)))
1944 (substring str 0 (1- (window-width))))
1946 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1948 (defun article-fill-long-lines ()
1949 "Fill lines that are wider than the window width."
1952 (let ((buffer-read-only nil)
1953 (width (window-width (get-buffer-window (current-buffer)))))
1956 (let ((adaptive-fill-mode nil)) ;Why? -sm
1959 (when (>= (current-column) (min fill-column width))
1960 (narrow-to-region (min (1+ (point)) (point-max))
1961 (gnus-point-at-bol))
1962 (let ((goback (point-marker)))
1963 (fill-paragraph nil)
1964 (goto-char (marker-position goback)))
1966 (forward-line 1)))))))
1968 (defun article-capitalize-sentences ()
1969 "Capitalize the first word in each sentence."
1972 (let ((buffer-read-only nil)
1973 (paragraph-start "^[\n\^L]"))
1977 (forward-sentence)))))
1979 (defun article-remove-cr ()
1980 "Remove trailing CRs and then translate remaining CRs into LFs."
1983 (let ((buffer-read-only nil))
1984 (goto-char (point-min))
1985 (while (re-search-forward "\r+$" nil t)
1986 (replace-match "" t t))
1987 (goto-char (point-min))
1988 (while (search-forward "\r" nil t)
1989 (replace-match "\n" t t)))))
1991 (defun article-remove-trailing-blank-lines ()
1992 "Remove all trailing blank lines from the article."
1995 (let ((buffer-read-only nil))
1996 (goto-char (point-max))
2000 (while (and (not (bobp))
2001 (looking-at "^[ \t]*$")
2002 (not (gnus-annotation-in-region-p
2003 (point) (gnus-point-at-eol))))
2008 (defun article-display-face ()
2009 "Display any Face headers in the header."
2011 (let ((wash-face-p buffer-read-only))
2012 (gnus-with-article-headers
2013 ;; When displaying parts, this function can be called several times on
2014 ;; the same article, without any intended toggle semantic (as typing `W
2015 ;; D d' would have). So face deletion must occur only when we come from
2016 ;; an interactive command, that is when the *Article* buffer is
2018 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2019 (gnus-delete-images 'face)
2022 (when (and wash-face-p
2024 (goto-char (point-min))
2025 (not (re-search-forward "^Face:[\t ]*" nil t)))
2026 (gnus-buffer-live-p gnus-original-article-buffer))
2027 (set-buffer gnus-original-article-buffer))
2029 (mail-narrow-to-head)
2030 (while (gnus-article-goto-header "Face")
2031 (push (mail-header-field-value) faces))))
2032 (while (setq face (pop faces))
2033 (let ((png (gnus-convert-face-to-png face))
2036 (setq image (gnus-create-image png 'png t))
2037 (gnus-article-goto-header "from")
2039 (insert "From: [no `from' set]\n")
2041 (gnus-add-wash-type 'face)
2042 (gnus-add-image 'face image)
2043 (gnus-put-image image nil 'face))))))
2046 (defun article-display-x-face (&optional force)
2047 "Look for an X-Face header and display it if present."
2048 (interactive (list 'force))
2049 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2050 (gnus-with-article-headers
2051 ;; Delete the old process, if any.
2052 (when (process-status "article-x-face")
2053 (delete-process "article-x-face"))
2054 ;; See the comment in `article-display-face'.
2055 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2056 ;; We have already displayed X-Faces, so we remove them
2058 (gnus-delete-images 'xface)
2060 (let (x-faces from face)
2062 (when (and wash-face-p
2064 (goto-char (point-min))
2065 (not (re-search-forward
2066 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2067 (gnus-buffer-live-p gnus-original-article-buffer))
2068 ;; If type `W f', use gnus-original-article-buffer,
2069 ;; otherwise use the current buffer because displaying
2070 ;; RFC822 parts calls this function too.
2071 (set-buffer gnus-original-article-buffer))
2073 (mail-narrow-to-head)
2074 (while (gnus-article-goto-header "X-Face")
2075 (push (mail-header-field-value) x-faces))
2076 (setq from (message-fetch-field "from"))))
2077 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2078 ;; single external face.
2079 (when (stringp gnus-article-x-face-command)
2080 (setq x-faces (list (car x-faces))))
2081 (while (and (setq face (pop x-faces))
2082 gnus-article-x-face-command
2084 ;; Check whether this face is censored.
2085 (not gnus-article-x-face-too-ugly)
2086 (and gnus-article-x-face-too-ugly from
2087 (not (string-match gnus-article-x-face-too-ugly
2089 ;; We display the face.
2090 (cond ((stringp gnus-article-x-face-command)
2091 ;; The command is a string, so we interpret the command
2092 ;; as a, well, command, and fork it off.
2093 (let ((process-connection-type nil))
2094 (process-kill-without-query
2096 "article-x-face" nil shell-file-name
2097 shell-command-switch gnus-article-x-face-command))
2100 (process-send-region "article-x-face"
2101 (point-min) (point-max)))
2102 (process-send-eof "article-x-face")))
2103 ((functionp gnus-article-x-face-command)
2104 ;; The command is a lisp function, so we call it.
2105 (funcall gnus-article-x-face-command face))
2107 (error "%s is not a function"
2108 gnus-article-x-face-command)))))))))
2110 (defun article-decode-mime-words ()
2111 "Decode all MIME-encoded words in the article."
2114 (set-buffer gnus-article-buffer)
2115 (let ((inhibit-point-motion-hooks t)
2117 (mail-parse-charset gnus-newsgroup-charset)
2118 (mail-parse-ignored-charsets
2119 (save-excursion (set-buffer gnus-summary-buffer)
2120 gnus-newsgroup-ignored-charsets)))
2121 (mail-decode-encoded-word-region (point-min) (point-max)))))
2123 (defun article-decode-charset (&optional prompt)
2124 "Decode charset-encoded text in the article.
2125 If PROMPT (the prefix), prompt for a coding system to use."
2127 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2129 (mail-parse-charset gnus-newsgroup-charset)
2130 (mail-parse-ignored-charsets
2131 (save-excursion (condition-case nil
2132 (set-buffer gnus-summary-buffer)
2134 gnus-newsgroup-ignored-charsets))
2135 ct cte ctl charset format)
2138 (article-narrow-to-head)
2139 (setq ct (message-fetch-field "Content-Type" t)
2140 cte (message-fetch-field "Content-Transfer-Encoding" t)
2141 ctl (and ct (ignore-errors
2142 (mail-header-parse-content-type ct)))
2145 (mm-read-coding-system "Charset to decode: "))
2147 (mail-content-type-get ctl 'charset)))
2148 format (and ctl (mail-content-type-get ctl 'format)))
2150 (setq cte (mail-header-strip cte)))
2151 (if (and ctl (not (string-match "/" (car ctl))))
2153 (goto-char (point-max)))
2156 (narrow-to-region (point) (point-max))
2157 (when (and (eq mail-parse-charset 'gnus-decoded)
2158 (eq (mm-body-7-or-8) '8bit))
2159 ;; The text code could have been decoded.
2160 (setq charset mail-parse-charset))
2161 (when (and (or (not ctl)
2162 (equal (car ctl) "text/plain"))
2163 (not format)) ;; article with format will decode later.
2165 charset (and cte (intern (downcase
2166 (gnus-strip-whitespace cte))))
2169 (defun article-decode-encoded-words ()
2170 "Remove encoded-word encoding from headers."
2171 (let ((inhibit-point-motion-hooks t)
2172 (mail-parse-charset gnus-newsgroup-charset)
2173 (mail-parse-ignored-charsets
2174 (save-excursion (condition-case nil
2175 (set-buffer gnus-summary-buffer)
2177 gnus-newsgroup-ignored-charsets))
2180 (article-narrow-to-head)
2181 (funcall gnus-decode-header-function (point-min) (point-max)))))
2183 (defun article-decode-group-name ()
2184 "Decode group names in `Newsgroups:'."
2185 (let ((inhibit-point-motion-hooks t)
2187 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2188 (when (and (or gnus-group-name-charset-method-alist
2189 gnus-group-name-charset-group-alist)
2190 (gnus-buffer-live-p gnus-original-article-buffer))
2192 (article-narrow-to-head)
2193 (with-current-buffer gnus-original-article-buffer
2194 (goto-char (point-min)))
2195 (while (re-search-forward
2196 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2197 (replace-match (save-match-data
2198 (gnus-decode-newsgroups
2199 ;; XXX how to use data in article buffer?
2200 (with-current-buffer gnus-original-article-buffer
2202 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2205 gnus-newsgroup-name method))
2207 (goto-char (point-min))
2208 (with-current-buffer gnus-original-article-buffer
2209 (goto-char (point-min)))
2210 (while (re-search-forward
2211 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2212 (replace-match (save-match-data
2213 (gnus-decode-newsgroups
2214 ;; XXX how to use data in article buffer?
2215 (with-current-buffer gnus-original-article-buffer
2217 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2220 gnus-newsgroup-name method))
2223 (autoload 'idna-to-unicode "idna")
2225 (defun article-decode-idna-rhs ()
2226 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2229 (let ((inhibit-point-motion-hooks t)
2231 (article-narrow-to-head)
2232 (goto-char (point-min))
2233 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2235 (when (save-match-data
2236 (and (setq ace (match-string 1))
2238 (and (re-search-backward "^[^ \t]" nil t)
2239 (looking-at "From\\|To\\|Cc")))
2240 (save-excursion (backward-char)
2241 (message-idna-inside-rhs-p))
2242 (setq unicode (idna-to-unicode ace))))
2243 (unless (string= ace unicode)
2244 (replace-match unicode nil nil nil 1)))))))))
2246 (defun article-de-quoted-unreadable (&optional force read-charset)
2247 "Translate a quoted-printable-encoded article.
2248 If FORCE, decode the article whether it is marked as quoted-printable
2250 If READ-CHARSET, ask for a coding system."
2251 (interactive (list 'force current-prefix-arg))
2253 (let ((buffer-read-only nil) type charset)
2254 (if (gnus-buffer-live-p gnus-original-article-buffer)
2255 (with-current-buffer gnus-original-article-buffer
2257 (gnus-fetch-field "content-transfer-encoding"))
2258 (let* ((ct (gnus-fetch-field "content-type"))
2261 (mail-header-parse-content-type ct)))))
2262 (setq charset (and ctl
2263 (mail-content-type-get ctl 'charset)))
2264 (if (stringp charset)
2265 (setq charset (intern (downcase charset)))))))
2267 (setq charset (mm-read-coding-system "Charset: " charset)))
2269 (setq charset gnus-newsgroup-charset))
2271 (and type (let ((case-fold-search t))
2272 (string-match "quoted-printable" type))))
2274 (quoted-printable-decode-region
2275 (point) (point-max) (mm-charset-to-coding-system charset))))))
2277 (defun article-de-base64-unreadable (&optional force read-charset)
2278 "Translate a base64 article.
2279 If FORCE, decode the article whether it is marked as base64 not.
2280 If READ-CHARSET, ask for a coding system."
2281 (interactive (list 'force current-prefix-arg))
2283 (let ((buffer-read-only nil) type charset)
2284 (if (gnus-buffer-live-p gnus-original-article-buffer)
2285 (with-current-buffer gnus-original-article-buffer
2287 (gnus-fetch-field "content-transfer-encoding"))
2288 (let* ((ct (gnus-fetch-field "content-type"))
2291 (mail-header-parse-content-type ct)))))
2292 (setq charset (and ctl
2293 (mail-content-type-get ctl 'charset)))
2294 (if (stringp charset)
2295 (setq charset (intern (downcase charset)))))))
2297 (setq charset (mm-read-coding-system "Charset: " charset)))
2299 (setq charset gnus-newsgroup-charset))
2301 (and type (let ((case-fold-search t))
2302 (string-match "base64" type))))
2305 (narrow-to-region (point) (point-max))
2306 (base64-decode-region (point-min) (point-max))
2307 (mm-decode-coding-region
2308 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2313 (defun article-decode-HZ ()
2314 "Translate a HZ-encoded article."
2318 (let ((buffer-read-only nil))
2319 (rfc1843-decode-region (point-min) (point-max)))))
2321 (defun article-unsplit-urls ()
2322 "Remove the newlines that some other mailers insert into URLs."
2325 (let ((buffer-read-only nil))
2326 (goto-char (point-min))
2327 (while (re-search-forward
2328 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2329 (replace-match "\\1\\3" t)))
2330 (when (interactive-p)
2331 (gnus-treat-article nil))))
2334 (defun article-wash-html (&optional read-charset)
2335 "Format an HTML article.
2336 If READ-CHARSET, ask for a coding system."
2339 (let ((buffer-read-only nil)
2341 (when (gnus-buffer-live-p gnus-original-article-buffer)
2342 (with-current-buffer gnus-original-article-buffer
2343 (let* ((ct (gnus-fetch-field "content-type"))
2346 (mail-header-parse-content-type ct)))))
2347 (setq charset (and ctl
2348 (mail-content-type-get ctl 'charset)))
2349 (when (stringp charset)
2350 (setq charset (intern (downcase charset)))))))
2352 (setq charset (mm-read-coding-system "Charset: " charset)))
2354 (setq charset gnus-newsgroup-charset))
2356 (save-window-excursion
2358 (narrow-to-region (point) (point-max))
2359 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2360 (entry (assq func mm-text-html-washer-alist)))
2362 (setq func (cdr entry)))
2367 (apply (car func) (cdr func))))))))))
2369 (defun gnus-article-wash-html-with-w3 ()
2370 "Wash the current buffer with w3."
2372 (let ((w3-strict-width (window-width))
2373 (url-standalone-mode t)
2374 (url-gateway-unplugged t)
2375 (w3-honor-stylesheets nil))
2377 (w3-region (point-min) (point-max))
2380 (defun gnus-article-wash-html-with-w3m ()
2381 "Wash the current buffer with emacs-w3m."
2384 (narrow-to-region (point) (point-max))
2385 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2388 w3m-force-redisplay)
2389 (w3m-region (point-min) (point-max)))
2390 (when mm-inline-text-html-with-w3m-keymap
2391 (add-text-properties
2392 (point-min) (point-max)
2393 (nconc (mm-w3m-local-map-property)
2394 '(mm-inline-text-html-with-w3m t))))))
2396 (defun article-hide-list-identifiers ()
2397 "Remove list identifies from the Subject header.
2398 The `gnus-list-identifiers' variable specifies what to do."
2400 (let ((inhibit-point-motion-hooks t)
2401 (regexp (if (consp gnus-list-identifiers)
2402 (mapconcat 'identity gnus-list-identifiers " *\\|")
2403 gnus-list-identifiers))
2408 (article-narrow-to-head)
2409 (goto-char (point-min))
2410 (while (re-search-forward
2411 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2413 (delete-region (match-beginning 2) (match-end 0))
2414 (beginning-of-line))
2415 (when (re-search-forward
2416 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2417 (delete-region (match-beginning 1) (match-end 1))))))))
2419 (defun article-hide-pem (&optional arg)
2420 "Toggle hiding of any PEM headers and signatures in the current article.
2421 If given a negative prefix, always show; if given a positive prefix,
2423 (interactive (gnus-article-hidden-arg))
2424 (unless (gnus-article-check-hidden-text 'pem arg)
2426 (let (buffer-read-only end)
2427 (goto-char (point-min))
2428 ;; Hide the horrendously ugly "header".
2429 (when (and (search-forward
2430 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2432 (setq end (1+ (match-beginning 0))))
2433 (gnus-add-wash-type 'pem)
2434 (gnus-article-hide-text-type
2436 (if (search-forward "\n\n" nil t)
2440 ;; Hide the trailer as well
2441 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2443 (gnus-article-hide-text-type
2444 (match-beginning 0) (match-end 0) 'pem)))))))
2446 (defun article-strip-banner ()
2447 "Strip the banners specified by the `banner' group parameter and by
2448 `gnus-article-address-banner-alist'."
2452 (let ((inhibit-point-motion-hooks t))
2453 (when (gnus-parameter-banner gnus-newsgroup-name)
2454 (article-really-strip-banner
2455 (gnus-parameter-banner gnus-newsgroup-name)))
2456 (when gnus-article-address-banner-alist
2457 (article-really-strip-banner
2458 (let ((from (save-restriction
2460 (article-narrow-to-head)
2461 (mail-fetch-field "from"))))
2464 (caar (mail-header-parse-addresses from))))
2466 (dolist (pair gnus-article-address-banner-alist)
2467 (when (string-match (car pair) from)
2468 (throw 'found (cdr pair)))))))))))))
2470 (defun article-really-strip-banner (banner)
2471 "Strip the banner specified by the argument."
2474 (let ((inhibit-point-motion-hooks t)
2475 (gnus-signature-limit nil)
2479 ((eq banner 'signature)
2480 (when (gnus-article-narrow-to-signature)
2483 (delete-region (point) (point-max))))
2485 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2486 (while (re-search-forward banner nil t)
2487 (delete-region (match-beginning 0) (match-end 0)))))
2489 (while (re-search-forward banner nil t)
2490 (delete-region (match-beginning 0) (match-end 0)))))))))
2492 (defun article-babel ()
2493 "Translate article using an online translation service."
2497 (set-buffer gnus-article-buffer)
2498 (when (article-goto-body)
2499 (let* ((buffer-read-only nil)
2502 (orig (buffer-substring start end))
2503 (trans (babel-as-string orig)))
2505 (narrow-to-region start end)
2506 (delete-region start end)
2509 (defun article-hide-signature (&optional arg)
2510 "Hide the signature in the current article.
2511 If given a negative prefix, always show; if given a positive prefix,
2513 (interactive (gnus-article-hidden-arg))
2514 (unless (gnus-article-check-hidden-text 'signature arg)
2517 (let ((buffer-read-only nil))
2518 (when (gnus-article-narrow-to-signature)
2519 (gnus-article-hide-text-type
2520 (point-min) (point-max) 'signature))))))
2521 (gnus-set-mode-line 'article))
2523 (defun article-strip-headers-in-body ()
2524 "Strip offensive headers from bodies."
2528 (let ((case-fold-search t))
2529 (when (looking-at "x-no-archive:")
2530 (gnus-delete-line)))))
2532 (defun article-strip-leading-blank-lines ()
2533 "Remove all blank lines from the beginning of the article."
2536 (let ((inhibit-point-motion-hooks t)
2538 (when (article-goto-body)
2539 (while (and (not (eobp))
2540 (looking-at "[ \t]*$"))
2541 (gnus-delete-line))))))
2543 (defun article-narrow-to-head ()
2544 "Narrow the buffer to the head of the message.
2545 Point is left at the beginning of the narrowed-to region."
2547 (goto-char (point-min))
2548 (if (search-forward "\n\n" nil 1)
2551 (goto-char (point-min)))
2553 (defun article-goto-body ()
2554 "Place point at the start of the body."
2555 (goto-char (point-min))
2557 ;; This variable is only bound when dealing with separate
2559 (article-goto-body-goes-to-point-min-p
2561 ((search-forward "\n\n" nil t)
2564 (goto-char (point-max))
2567 (defun article-strip-multiple-blank-lines ()
2568 "Replace consecutive blank lines with one empty line."
2571 (let ((inhibit-point-motion-hooks t)
2573 ;; First make all blank lines empty.
2575 (while (re-search-forward "^[ \t]+$" nil t)
2576 (unless (gnus-annotation-in-region-p
2577 (match-beginning 0) (match-end 0))
2578 (replace-match "" nil t)))
2579 ;; Then replace multiple empty lines with a single empty line.
2581 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2582 (unless (gnus-annotation-in-region-p
2583 (match-beginning 0) (match-end 0))
2584 (delete-region (match-beginning 1) (match-end 1)))))))
2586 (defun article-strip-leading-space ()
2587 "Remove all white space from the beginning of the lines in the article."
2590 (let ((inhibit-point-motion-hooks t)
2593 (while (re-search-forward "^[ \t]+" nil t)
2594 (replace-match "" t t)))))
2596 (defun article-strip-trailing-space ()
2597 "Remove all white space from the end of the lines in the article."
2600 (let ((inhibit-point-motion-hooks t)
2603 (while (re-search-forward "[ \t]+$" nil t)
2604 (replace-match "" t t)))))
2606 (defun article-strip-blank-lines ()
2607 "Strip leading, trailing and multiple blank lines."
2609 (article-strip-leading-blank-lines)
2610 (article-remove-trailing-blank-lines)
2611 (article-strip-multiple-blank-lines))
2613 (defun article-strip-all-blank-lines ()
2614 "Strip all blank lines."
2617 (let ((inhibit-point-motion-hooks t)
2620 (while (re-search-forward "^[ \t]*\n" nil t)
2621 (replace-match "" t t)))))
2623 (defun gnus-article-narrow-to-signature ()
2624 "Narrow to the signature; return t if a signature is found, else nil."
2625 (let ((inhibit-point-motion-hooks t))
2626 (when (gnus-article-search-signature)
2628 ;; Check whether we have some limits to what we consider
2629 ;; to be a signature.
2630 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2631 (list gnus-signature-limit)))
2633 (while (setq limit (pop limits))
2634 (if (or (and (integerp limit)
2635 (< (- (point-max) (point)) limit))
2637 (< (count-lines (point) (point-max)) limit))
2638 (and (functionp limit)
2640 (and (stringp limit)
2641 (not (re-search-forward limit nil t))))
2642 () ; This limit did not succeed.
2646 (narrow-to-region (point) (point-max))
2649 (defun gnus-article-search-signature ()
2650 "Search the current buffer for the signature separator.
2651 Put point at the beginning of the signature separator."
2652 (let ((cur (point)))
2653 (goto-char (point-max))
2654 (if (if (stringp gnus-signature-separator)
2655 (re-search-backward gnus-signature-separator nil t)
2656 (let ((seps gnus-signature-separator))
2658 (not (re-search-backward (car seps) nil t)))
2665 (defun gnus-article-hidden-arg ()
2666 "Return the current prefix arg as a number, or 0 if no prefix."
2667 (list (if current-prefix-arg
2668 (prefix-numeric-value current-prefix-arg)
2671 (defun gnus-article-check-hidden-text (type arg)
2672 "Return nil if hiding is necessary.
2673 Arg can be nil or a number. nil and positive means hide, negative
2674 means show, 0 means toggle."
2677 (let ((hide (gnus-article-hidden-text-p type)))
2683 (gnus-article-show-hidden-text type)
2686 (if (eq hide 'hidden)
2688 (gnus-article-show-hidden-text type)
2692 (defun gnus-article-hidden-text-p (type)
2693 "Say whether the current buffer contains hidden text of type TYPE."
2694 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2696 (not (get-text-property pos 'invisible))
2697 (not (get-text-property pos 'dummy-invisible)))
2699 (text-property-any (1+ pos) (point-max) 'article-type type)))
2704 (defun gnus-article-show-hidden-text (type &optional dummy)
2705 "Show all hidden text of type TYPE.
2706 Originally it is hide instead of DUMMY."
2707 (let ((buffer-read-only nil)
2708 (inhibit-point-motion-hooks t))
2709 (gnus-remove-text-properties-when
2711 (point-min) (point-max)
2712 (cons 'article-type (cons type
2713 gnus-hidden-properties)))
2714 (gnus-delete-wash-type type)))
2716 (defconst article-time-units
2717 `((year . ,(* 365.25 24 60 60))
2718 (week . ,(* 7 24 60 60))
2719 (day . ,(* 24 60 60))
2723 "Mapping from time units to seconds.")
2725 (defun gnus-article-forward-header ()
2726 "Move point to the start of the next header.
2727 If the current header is a continuation header, this can be several
2732 (if (looking-at "[ \t]+[^ \t]")
2736 (defun article-date-ut (&optional type highlight header)
2737 "Convert DATE date to universal time in the current article.
2738 If TYPE is `local', convert to local time; if it is `lapsed', output
2739 how much time has lapsed since DATE. For `lapsed', the value of
2740 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2741 should replace the \"Date:\" one, or should be added below it."
2742 (interactive (list 'ut t))
2743 (let* ((header (or header
2744 (message-fetch-field "date")
2746 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2749 ((not gnus-article-date-lapsed-new-header)
2755 (date (if (vectorp header) (mail-header-date header)
2757 (inhibit-point-motion-hooks t)
2762 (article-narrow-to-head)
2763 (when (re-search-forward tdate-regexp nil t)
2764 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2765 date (or (get-text-property (gnus-point-at-bol)
2768 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2770 (when (and date (not (string= date "")))
2771 (goto-char (point-min))
2772 (let ((buffer-read-only nil))
2773 ;; Delete any old Date headers.
2774 (while (re-search-forward date-regexp nil t)
2776 (delete-region (progn (beginning-of-line) (point))
2777 (progn (gnus-article-forward-header)
2779 (delete-region (progn (beginning-of-line) (point))
2780 (progn (gnus-article-forward-header)
2783 (setq pos (point))))
2784 (when (and (not pos)
2785 (re-search-forward tdate-regexp nil t))
2789 (insert (article-make-date-line date (or type 'ut)))
2795 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2796 (put-text-property (match-beginning 1) (1+ (match-end 1))
2797 'original-date date)
2798 (put-text-property (match-beginning 1) (1+ (match-end 1))
2800 (put-text-property (match-beginning 2) (match-end 2)
2803 (defun article-make-date-line (date type)
2804 "Return a DATE line of TYPE."
2805 (unless (memq type '(local ut original user iso8601 lapsed english))
2806 (error "Unknown conversion type: %s" type))
2808 (let ((time (date-to-time date)))
2810 ;; Convert to the local timezone.
2812 (let ((tz (car (current-time-zone time))))
2813 (format "Date: %s %s%02d%02d" (current-time-string time)
2814 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2815 (/ (% (abs tz) 3600) 60))))
2816 ;; Convert to Universal Time.
2819 (current-time-string
2820 (let* ((e (parse-time-string date))
2821 (tm (apply 'encode-time e))
2823 (ls (- (cadr tm) (car (current-time-zone time)))))
2824 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2825 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2828 ;; Get the original date from the article.
2829 ((eq type 'original)
2830 (concat "Date: " (if (string-match "\n+$" date)
2831 (substring date 0 (match-beginning 0))
2833 ;; Let the user define the format.
2835 (let ((format (or (condition-case nil
2836 (with-current-buffer gnus-summary-buffer
2837 gnus-article-time-format)
2839 gnus-article-time-format)))
2840 (if (functionp format)
2841 (funcall format time)
2842 (concat "Date: " (format-time-string format time)))))
2845 (let ((tz (car (current-time-zone time))))
2848 (format-time-string "%Y%m%dT%H%M%S" time)
2849 (format "%s%02d%02d"
2850 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2851 (/ (% (abs tz) 3600) 60)))))
2852 ;; Do an X-Sent lapsed format.
2854 ;; If the date is seriously mangled, the timezone functions are
2855 ;; liable to bug out, so we ignore all errors.
2856 (let* ((now (current-time))
2857 (real-time (subtract-time now time))
2858 (real-sec (and real-time
2859 (+ (* (float (car real-time)) 65536)
2861 (sec (and real-time (abs real-sec)))
2871 ;; This is a bit convoluted, but basically we go
2872 ;; through the time units for years, weeks, etc,
2873 ;; and divide things to see whether that results
2874 ;; in positive answers.
2877 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2878 ;; The (remaining) seconds are too few to
2879 ;; be divided into this time unit.
2881 ;; It's big enough, so we output it.
2882 (setq sec (- sec (* num (cdr unit))))
2884 (concat (if prev ", " "") (int-to-string
2886 " " (symbol-name (car unit))
2887 (if (> num 1) "s" ""))
2889 article-time-units "")
2890 ;; If dates are odd, then it might appear like the
2891 ;; article was sent in the future.
2894 " in the future"))))))
2895 ;; Display the date in proper English
2897 (let ((dtime (decode-time time)))
2900 (number-to-string (nth 3 dtime))
2901 (let ((digit (% (nth 3 dtime) 10)))
2903 ((memq (nth 3 dtime) '(11 12 13)) "th")
2909 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2911 (number-to-string (nth 5 dtime))
2913 (format "%02d" (nth 2 dtime))
2915 (format "%02d" (nth 1 dtime)))))))
2917 (format "Date: %s (from Gnus)" date))))
2919 (defun article-date-local (&optional highlight)
2920 "Convert the current article date to the local timezone."
2921 (interactive (list t))
2922 (article-date-ut 'local highlight))
2924 (defun article-date-english (&optional highlight)
2925 "Convert the current article date to something that is proper English."
2926 (interactive (list t))
2927 (article-date-ut 'english highlight))
2929 (defun article-date-original (&optional highlight)
2930 "Convert the current article date to what it was originally.
2931 This is only useful if you have used some other date conversion
2932 function and want to see what the date was before converting."
2933 (interactive (list t))
2934 (article-date-ut 'original highlight))
2936 (defun article-date-lapsed (&optional highlight)
2937 "Convert the current article date to time lapsed since it was sent."
2938 (interactive (list t))
2939 (article-date-ut 'lapsed highlight))
2941 (defun article-update-date-lapsed ()
2942 "Function to be run from a timer to update the lapsed time line."
2943 (let (deactivate-mark)
2948 (set-buffer (window-buffer w))
2949 (when (eq major-mode 'gnus-article-mode)
2950 (let ((mark (point-marker)))
2951 (goto-char (point-min))
2952 (when (re-search-forward "^X-Sent:" nil t)
2953 (article-date-lapsed t))
2954 (goto-char (marker-position mark))
2955 (move-marker mark nil))))
2958 (defun gnus-start-date-timer (&optional n)
2959 "Start a timer to update the X-Sent header in the article buffers.
2960 The numerical prefix says how frequently (in seconds) the function
2965 (gnus-stop-date-timer)
2966 (setq article-lapsed-timer
2967 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2969 (defun gnus-stop-date-timer ()
2970 "Stop the X-Sent timer."
2972 (when article-lapsed-timer
2973 (nnheader-cancel-timer article-lapsed-timer)
2974 (setq article-lapsed-timer nil)))
2976 (defun article-date-user (&optional highlight)
2977 "Convert the current article date to the user-defined format.
2978 This format is defined by the `gnus-article-time-format' variable."
2979 (interactive (list t))
2980 (article-date-ut 'user highlight))
2982 (defun article-date-iso8601 (&optional highlight)
2983 "Convert the current article date to ISO8601."
2984 (interactive (list t))
2985 (article-date-ut 'iso8601 highlight))
2987 ;; (defun article-show-all ()
2988 ;; "Show all hidden text in the article buffer."
2991 ;; (let ((buffer-read-only nil))
2992 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2994 (defun article-remove-leading-whitespace ()
2995 "Remove excessive whitespace from all headers."
2999 (let ((buffer-read-only nil))
3000 (article-narrow-to-head)
3001 (goto-char (point-min))
3002 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3003 (delete-region (match-beginning 1) (match-end 1)))))))
3005 (defun article-emphasize (&optional arg)
3006 "Emphasize text according to `gnus-emphasis-alist'."
3007 (interactive (gnus-article-hidden-arg))
3008 (unless (gnus-article-check-hidden-text 'emphasis arg)
3012 (with-current-buffer gnus-summary-buffer
3013 gnus-article-emphasis-alist)
3015 gnus-emphasis-alist))
3016 (buffer-read-only nil)
3017 (props (append '(article-type emphasis)
3018 gnus-hidden-properties))
3019 regexp elem beg invisible visible face)
3022 (while (setq elem (pop alist))
3024 (setq regexp (car elem)
3025 invisible (nth 1 elem)
3026 visible (nth 2 elem)
3028 (while (re-search-forward regexp nil t)
3029 (when (and (match-beginning visible) (match-beginning invisible))
3030 (gnus-article-hide-text
3031 (match-beginning invisible) (match-end invisible) props)
3032 (gnus-article-unhide-text-type
3033 (match-beginning visible) (match-end visible) 'emphasis)
3034 (gnus-put-overlay-excluding-newlines
3035 (match-beginning visible) (match-end visible) 'face face)
3036 (gnus-add-wash-type 'emphasis)
3037 (goto-char (match-end invisible)))))))))
3039 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3040 "Setup newsgroup emphasis alist."
3041 (unless gnus-article-emphasis-alist
3042 (let ((name (and gnus-newsgroup-name
3043 (gnus-group-real-name gnus-newsgroup-name))))
3044 (make-local-variable 'gnus-article-emphasis-alist)
3045 (setq gnus-article-emphasis-alist
3047 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3048 (while (setq elem (pop alist))
3049 (when (and name (string-match (car elem) name))
3051 highlight (copy-sequence (cdr elem)))))
3053 (copy-sequence highlight-words)
3054 (if gnus-newsgroup-name
3055 (copy-sequence (gnus-group-find-parameter
3056 gnus-newsgroup-name 'highlight-words t)))
3057 gnus-emphasis-alist)))))
3060 (defvar gnus-summary-article-menu)
3061 (defvar gnus-summary-post-menu))
3063 ;;; Saving functions.
3065 (defun gnus-article-save (save-buffer file &optional num)
3066 "Save the currently selected article."
3067 (unless gnus-save-all-headers
3068 ;; Remove headers according to `gnus-saved-headers'.
3069 (let ((gnus-visible-headers
3070 (or gnus-saved-headers gnus-visible-headers))
3071 (gnus-article-buffer save-buffer))
3073 (set-buffer save-buffer)
3074 (article-hide-headers 1 t))))
3075 (save-window-excursion
3076 (if (not gnus-default-article-saver)
3077 (error "No default saver is defined")
3078 ;; !!! Magic! The saving functions all save
3079 ;; `gnus-save-article-buffer' (or so they think), but we
3080 ;; bind that variable to our save-buffer.
3081 (set-buffer gnus-article-buffer)
3082 (let* ((gnus-save-article-buffer save-buffer)
3085 ((not gnus-prompt-before-saving) 'default)
3086 ((eq gnus-prompt-before-saving 'always) nil)
3088 (gnus-number-of-articles-to-be-saved
3089 (when (eq gnus-prompt-before-saving t)
3091 (set-buffer gnus-article-current-summary)
3092 (funcall gnus-default-article-saver filename)))))
3094 (defun gnus-read-save-file-name (prompt &optional filename
3095 function group headers variable)
3097 (funcall function group headers (symbol-value variable)))
3102 ((eq filename 'default)
3108 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3111 (if (and gnus-number-of-articles-to-be-saved
3112 (> gnus-number-of-articles-to-be-saved 1))
3113 (format "these %d articles"
3114 gnus-number-of-articles-to-be-saved)
3117 ;; Let the split methods have their say.
3119 ;; No split name was found.
3122 (concat prompt " (default "
3123 (file-name-nondirectory default-name) ") ")
3124 (file-name-directory default-name)
3126 ;; A single group name is returned.
3127 ((stringp split-name)
3129 (funcall function split-name headers
3130 (symbol-value variable)))
3132 (concat prompt " (default "
3133 (file-name-nondirectory default-name) ") ")
3134 (file-name-directory default-name)
3136 ;; A single split name was found
3137 ((= 1 (length split-name))
3138 (let* ((name (expand-file-name
3140 gnus-article-save-directory))
3141 (dir (cond ((file-directory-p name)
3142 (file-name-as-directory name))
3143 ((file-exists-p name) name)
3144 (t gnus-article-save-directory))))
3146 (concat prompt " (default " name ") ")
3148 ;; A list of splits was found.
3150 (setq split-name (nreverse split-name))
3152 (let ((file-name-history
3153 (nconc split-name file-name-history)))
3157 (concat prompt " (`M-p' for defaults) ")
3158 gnus-article-save-directory
3160 gnus-article-save-directory)))
3161 (car (push result file-name-history)))))))
3162 ;; Create the directory.
3163 (gnus-make-directory (file-name-directory file))
3164 ;; If we have read a directory, we append the default file name.
3165 (when (file-directory-p file)
3166 (setq file (expand-file-name (file-name-nondirectory
3168 (file-name-as-directory file))))
3169 ;; Possibly translate some characters.
3170 (nnheader-translate-file-chars file))))))
3171 (gnus-make-directory (file-name-directory result))
3172 (set variable result)))
3174 (defun gnus-article-archive-name (group)
3175 "Return the first instance of an \"Archive-name\" in the current buffer."
3176 (let ((case-fold-search t))
3177 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3178 (nnheader-concat gnus-article-save-directory
3179 (match-string 1)))))
3181 (defun gnus-article-nndoc-name (group)
3182 "If GROUP is an nndoc group, return the name of the parent group."
3183 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3184 (gnus-group-get-parameter group 'save-article-group)))
3186 (defun gnus-summary-save-in-rmail (&optional filename)
3187 "Append this article to Rmail file.
3188 Optional argument FILENAME specifies file name.
3189 Directory to save to is default to `gnus-article-save-directory'."
3190 (setq filename (gnus-read-save-file-name
3191 "Save %s in rmail file:" filename
3192 gnus-rmail-save-name gnus-newsgroup-name
3193 gnus-current-headers 'gnus-newsgroup-last-rmail))
3194 (gnus-eval-in-buffer-window gnus-save-article-buffer
3198 (gnus-output-to-rmail filename))))
3201 (defun gnus-summary-save-in-mail (&optional filename)
3202 "Append this article to Unix mail file.
3203 Optional argument FILENAME specifies file name.
3204 Directory to save to is default to `gnus-article-save-directory'."
3205 (setq filename (gnus-read-save-file-name
3206 "Save %s in Unix mail file:" filename
3207 gnus-mail-save-name gnus-newsgroup-name
3208 gnus-current-headers 'gnus-newsgroup-last-mail))
3209 (gnus-eval-in-buffer-window gnus-save-article-buffer
3213 (if (and (file-readable-p filename)
3214 (file-regular-p filename)
3215 (mail-file-babyl-p filename))
3216 (rmail-output-to-rmail-file filename t)
3217 (gnus-output-to-mail filename)))))
3220 (defun gnus-summary-save-in-file (&optional filename overwrite)
3221 "Append this article to file.
3222 Optional argument FILENAME specifies file name.
3223 Directory to save to is default to `gnus-article-save-directory'."
3224 (setq filename (gnus-read-save-file-name
3225 "Save %s in file:" filename
3226 gnus-file-save-name gnus-newsgroup-name
3227 gnus-current-headers 'gnus-newsgroup-last-file))
3228 (gnus-eval-in-buffer-window gnus-save-article-buffer
3232 (when (and overwrite
3233 (file-exists-p filename))
3234 (delete-file filename))
3235 (gnus-output-to-file filename))))
3238 (defun gnus-summary-write-to-file (&optional filename)
3239 "Write this article to a file, overwriting it if the file exists.
3240 Optional argument FILENAME specifies file name.
3241 The directory to save in defaults to `gnus-article-save-directory'."
3242 (gnus-summary-save-in-file nil t))
3244 (defun gnus-summary-save-body-in-file (&optional filename)
3245 "Append this article body to a file.
3246 Optional argument FILENAME specifies file name.
3247 The directory to save in defaults to `gnus-article-save-directory'."
3248 (setq filename (gnus-read-save-file-name
3249 "Save %s body in file:" filename
3250 gnus-file-save-name gnus-newsgroup-name
3251 gnus-current-headers 'gnus-newsgroup-last-file))
3252 (gnus-eval-in-buffer-window gnus-save-article-buffer
3256 (when (article-goto-body)
3257 (narrow-to-region (point) (point-max)))
3258 (gnus-output-to-file filename))))
3261 (defun gnus-summary-save-in-pipe (&optional command)
3262 "Pipe this article to subprocess."
3264 (cond ((and (eq command 'default)
3265 gnus-last-shell-command)
3266 gnus-last-shell-command)
3271 "Shell command on %s: "
3272 (if (and gnus-number-of-articles-to-be-saved
3273 (> gnus-number-of-articles-to-be-saved 1))
3274 (format "these %d articles"
3275 gnus-number-of-articles-to-be-saved)
3277 gnus-last-shell-command))))
3278 (when (string-equal command "")
3279 (if gnus-last-shell-command
3280 (setq command gnus-last-shell-command)
3281 (error "A command is required")))
3282 (gnus-eval-in-buffer-window gnus-article-buffer
3285 (shell-command-on-region (point-min) (point-max) command nil)))
3286 (setq gnus-last-shell-command command))
3288 (defmacro gnus-read-string (prompt &optional initial-contents history
3290 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3291 (if (and (featurep 'xemacs)
3292 (< emacs-minor-version 2))
3293 `(read-string ,prompt ,initial-contents ,history)
3294 `(read-string ,prompt ,initial-contents ,history ,default-value)))
3296 (defun gnus-summary-pipe-to-muttprint (&optional command)
3297 "Pipe this article to muttprint."
3298 (setq command (gnus-read-string
3299 "Print using command: " gnus-summary-muttprint-program
3300 nil gnus-summary-muttprint-program))
3301 (gnus-summary-save-in-pipe command))
3303 ;;; Article file names when saving.
3305 (defun gnus-capitalize-newsgroup (newsgroup)
3306 "Capitalize NEWSGROUP name."
3307 (when (not (zerop (length newsgroup)))
3308 (concat (char-to-string (upcase (aref newsgroup 0)))
3309 (substring newsgroup 1))))
3311 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3312 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3313 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3314 Otherwise, it is like ~/News/news/group/num."
3317 (concat (if (gnus-use-long-file-name 'not-save)
3318 (gnus-capitalize-newsgroup newsgroup)
3319 (gnus-newsgroup-directory-form newsgroup))
3320 "/" (int-to-string (mail-header-number headers)))
3321 gnus-article-save-directory)))
3323 (string-equal (file-name-directory default)
3324 (file-name-directory last-file))
3325 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3327 (or last-file default))))
3329 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3330 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3331 If variable `gnus-use-long-file-name' is non-nil, it is
3332 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3335 (concat (if (gnus-use-long-file-name 'not-save)
3337 (gnus-newsgroup-directory-form newsgroup))
3338 "/" (int-to-string (mail-header-number headers)))
3339 gnus-article-save-directory)))
3341 (string-equal (file-name-directory default)
3342 (file-name-directory last-file))
3343 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3345 (or last-file default))))
3347 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3348 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3349 If variable `gnus-use-long-file-name' is non-nil, it is
3350 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3353 (if (gnus-use-long-file-name 'not-save)
3356 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3358 gnus-article-save-directory)))
3360 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3361 "Generate file name from sender."
3362 (let ((from (mail-header-from headers)))
3364 (if (and from (string-match "\\([^ <]+\\)@" from))
3365 (match-string 1 from)
3367 gnus-article-save-directory)))
3369 (defun article-verify-x-pgp-sig ()
3372 (if (gnus-buffer-live-p gnus-original-article-buffer)
3373 (let ((sig (with-current-buffer gnus-original-article-buffer
3374 (gnus-fetch-field "X-PGP-Sig")))
3378 (mml2015-clear-verify-function))
3380 (insert-buffer-substring gnus-original-article-buffer)
3381 (setq items (split-string sig))
3382 (message-narrow-to-head)
3383 (let ((inhibit-point-motion-hooks t)
3384 (case-fold-search t))
3385 ;; Don't verify multiple headers.
3386 (setq headers (mapconcat (lambda (header)
3388 (mail-fetch-field header)
3390 (split-string (nth 1 items) ",") "")))
3391 (delete-region (point-min) (point-max))
3392 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3393 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3398 (if (looking-at "^-")
3401 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3402 (insert "Version: " (car items) "\n\n")
3403 (insert (mapconcat 'identity (cddr items) "\n"))
3404 (insert "\n-----END PGP SIGNATURE-----\n")
3405 (let ((mm-security-handle (list (format "multipart/signed"))))
3406 (mml2015-clean-buffer)
3407 (let ((coding-system-for-write (or gnus-newsgroup-charset
3409 (funcall (mml2015-clear-verify-function)))
3411 (or (mm-handle-multipart-ctl-parameter
3412 mm-security-handle 'gnus-details)
3413 (mm-handle-multipart-ctl-parameter
3414 mm-security-handle 'gnus-info)))))
3416 (let (buffer-read-only bface eface)
3418 (message-narrow-to-head)
3419 (goto-char (point-max))
3421 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3422 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3423 (message-remove-header "X-Gnus-PGP-Verify")
3424 (if (re-search-forward "^X-PGP-Sig:" nil t)
3426 (goto-char (point-max)))
3427 (narrow-to-region (point) (point))
3428 (insert "X-Gnus-PGP-Verify: " info "\n")
3429 (goto-char (point-min))
3432 (if (not (looking-at "^[ \t]"))
3436 (goto-char (point-min))
3437 (when (looking-at "\\([^:]+\\): *")
3438 (put-text-property (match-beginning 1) (1+ (match-end 1))
3440 (put-text-property (match-end 0) (point-max)
3441 'face eface)))))))))
3443 (defun article-verify-cancel-lock ()
3444 "Verify Cancel-Lock header."
3446 (if (gnus-buffer-live-p gnus-original-article-buffer)
3447 (canlock-verify gnus-original-article-buffer)))
3454 (setq afunc (car func)
3457 gfunc (intern (format "gnus-%s" func))))
3459 (when (fboundp afunc)
3460 `(lambda (&optional interactive &rest args)
3461 ,(documentation afunc t)
3462 (interactive (list t))
3464 (set-buffer gnus-article-buffer)
3466 (call-interactively ',afunc)
3467 (apply ',afunc args))))))))
3468 '(article-hide-headers
3469 article-verify-x-pgp-sig
3470 article-verify-cancel-lock
3471 article-hide-boring-headers
3472 article-treat-overstrike
3473 article-fill-long-lines
3474 article-capitalize-sentences
3476 article-remove-leading-whitespace
3477 article-display-x-face
3478 article-display-face
3479 article-de-quoted-unreadable
3480 article-de-base64-unreadable
3483 article-unsplit-urls
3484 article-hide-list-identifiers
3485 article-strip-banner
3488 article-hide-signature
3489 article-strip-headers-in-body
3490 article-remove-trailing-blank-lines
3491 article-strip-leading-blank-lines
3492 article-strip-multiple-blank-lines
3493 article-strip-leading-space
3494 article-strip-trailing-space
3495 article-strip-blank-lines
3496 article-strip-all-blank-lines
3498 article-date-english
3499 article-date-iso8601
3500 article-date-original
3502 article-decode-mime-words
3503 article-decode-charset
3504 article-decode-encoded-words
3508 article-treat-dumbquotes
3509 article-normalize-headers
3510 ;; (article-show-all . gnus-article-show-all-headers)
3514 ;;; Gnus article mode
3517 (put 'gnus-article-mode 'mode-class 'special)
3519 (set-keymap-parent gnus-article-mode-map widget-keymap)
3521 (gnus-define-keys gnus-article-mode-map
3522 " " gnus-article-goto-next-page
3523 "\177" gnus-article-goto-prev-page
3524 [delete] gnus-article-goto-prev-page
3525 [backspace] gnus-article-goto-prev-page
3526 "\C-c^" gnus-article-refer-article
3527 "h" gnus-article-show-summary
3528 "s" gnus-article-show-summary
3529 "\C-c\C-m" gnus-article-mail
3530 "?" gnus-article-describe-briefly
3531 "e" gnus-summary-edit-article
3532 "<" beginning-of-buffer
3534 "\C-c\C-i" gnus-info-find-node
3536 "R" gnus-article-reply-with-original
3537 "F" gnus-article-followup-with-original
3538 "\C-hk" gnus-article-describe-key
3539 "\C-hc" gnus-article-describe-key-briefly
3541 "\C-d" gnus-article-read-summary-keys
3542 "\M-*" gnus-article-read-summary-keys
3543 "\M-#" gnus-article-read-summary-keys
3544 "\M-^" gnus-article-read-summary-keys
3545 "\M-g" gnus-article-read-summary-keys)
3547 (substitute-key-definition
3548 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3550 (defun gnus-article-make-menu-bar ()
3551 (unless (boundp 'gnus-article-commands-menu)
3552 (gnus-summary-make-menu-bar))
3553 (gnus-turn-off-edit-menu 'article)
3554 (unless (boundp 'gnus-article-article-menu)
3556 gnus-article-article-menu gnus-article-mode-map ""
3558 ["Scroll forwards" gnus-article-goto-next-page t]
3559 ["Scroll backwards" gnus-article-goto-prev-page t]
3560 ["Show summary" gnus-article-show-summary t]
3561 ["Fetch Message-ID at point" gnus-article-refer-article t]
3562 ["Mail to address at point" gnus-article-mail t]
3563 ["Send a bug report" gnus-bug t]))
3566 gnus-article-treatment-menu gnus-article-mode-map ""
3567 ;; Fixme: this should use :active (and maybe :visible).
3569 ["Hide headers" gnus-article-hide-headers t]
3570 ["Hide signature" gnus-article-hide-signature t]
3571 ["Hide citation" gnus-article-hide-citation t]
3572 ["Treat overstrike" gnus-article-treat-overstrike t]
3573 ["Remove carriage return" gnus-article-remove-cr t]
3574 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3575 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3576 ["Remove base64" gnus-article-de-base64-unreadable t]
3577 ["Treat html" gnus-article-wash-html t]
3578 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3579 ["Decode HZ" gnus-article-decode-HZ t]))
3581 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3583 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3585 (gnus-run-hooks 'gnus-article-menu-hook)))
3587 (defun gnus-article-mode ()
3588 "Major mode for displaying an article.
3590 All normal editing commands are switched off.
3592 The following commands are available in addition to all summary mode
3594 \\<gnus-article-mode-map>
3595 \\[gnus-article-next-page]\t Scroll the article one page forwards
3596 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3597 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3598 \\[gnus-article-show-summary]\t Display the summary buffer
3599 \\[gnus-article-mail]\t Send a reply to the address near point
3600 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3601 \\[gnus-info-find-node]\t Go to the Gnus info node"
3603 (gnus-simplify-mode-line)
3604 (setq mode-name "Article")
3605 (setq major-mode 'gnus-article-mode)
3606 (make-local-variable 'minor-mode-alist)
3607 (use-local-map gnus-article-mode-map)
3608 (when (gnus-visual-p 'article-menu 'menu)
3609 (gnus-article-make-menu-bar)
3610 (when gnus-summary-tool-bar-map
3611 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3612 (gnus-update-format-specifications nil 'article-mode)
3613 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3614 (set (make-local-variable 'gnus-page-broken) nil)
3615 (make-local-variable 'gnus-button-marker-list)
3616 (make-local-variable 'gnus-article-current-summary)
3617 (make-local-variable 'gnus-article-mime-handles)
3618 (make-local-variable 'gnus-article-decoded-p)
3619 (make-local-variable 'gnus-article-mime-handle-alist)
3620 (make-local-variable 'gnus-article-wash-types)
3621 (make-local-variable 'gnus-article-image-alist)
3622 (make-local-variable 'gnus-article-charset)
3623 (make-local-variable 'gnus-article-ignored-charsets)
3624 (gnus-set-default-directory)
3625 (buffer-disable-undo)
3626 (setq buffer-read-only t)
3627 (set-syntax-table gnus-article-mode-syntax-table)
3628 (mm-enable-multibyte)
3629 (gnus-run-hooks 'gnus-article-mode-hook))
3631 (defun gnus-article-setup-buffer ()
3632 "Initialize the article buffer."
3633 (let* ((name (if gnus-single-article-buffer "*Article*"
3634 (concat "*Article " gnus-newsgroup-name "*")))
3636 (progn (string-match "\\*Article" name)
3637 (concat " *Original Article"
3638 (substring name (match-end 0))))))
3639 (setq gnus-article-buffer name)
3640 (setq gnus-original-article-buffer original)
3641 (setq gnus-article-mime-handle-alist nil)
3642 ;; This might be a variable local to the summary buffer.
3643 (unless gnus-single-article-buffer
3645 (set-buffer gnus-summary-buffer)
3646 (setq gnus-article-buffer name)
3647 (setq gnus-original-article-buffer original)
3648 (gnus-set-global-variables)))
3649 (gnus-article-setup-highlight-words)
3650 ;; Init original article buffer.
3652 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3653 (mm-enable-multibyte)
3654 (setq major-mode 'gnus-original-article-mode)
3655 (make-local-variable 'gnus-original-article))
3656 (if (get-buffer name)
3659 (when (and gnus-article-edit-mode
3662 (y-or-n-p "Article mode edit in progress; discard? ")))
3663 (error "Action aborted"))
3664 (set (make-local-variable 'gnus-article-edit-mode) nil)
3665 (when gnus-article-mime-handles
3666 (mm-destroy-parts gnus-article-mime-handles)
3667 (setq gnus-article-mime-handles nil))
3668 ;; Set it to nil in article-buffer!
3669 (setq gnus-article-mime-handle-alist nil)
3670 (buffer-disable-undo)
3671 (setq buffer-read-only t)
3672 ;; This list just keeps growing if we don't reset it.
3673 (setq gnus-button-marker-list nil)
3674 (unless (eq major-mode 'gnus-article-mode)
3675 (gnus-article-mode))
3678 (set-buffer (gnus-get-buffer-create name))
3680 (make-local-variable 'gnus-summary-buffer)
3681 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3682 (current-buffer)))))
3684 ;; Set article window start at LINE, where LINE is the number of lines
3685 ;; from the head of the article.
3686 (defun gnus-article-set-window-start (&optional line)
3688 (gnus-get-buffer-window gnus-article-buffer t)
3690 (set-buffer gnus-article-buffer)
3691 (goto-char (point-min))
3694 (gnus-message 6 "Moved to bookmark")
3695 (search-forward "\n\n" nil t)
3699 (defun gnus-article-prepare (article &optional all-headers header)
3700 "Prepare ARTICLE in article mode buffer.
3701 ARTICLE should either be an article number or a Message-ID.
3702 If ARTICLE is an id, HEADER should be the article headers.
3703 If ALL-HEADERS is non-nil, no headers are hidden."
3705 ;; Make sure we start in a summary buffer.
3706 (unless (eq major-mode 'gnus-summary-mode)
3707 (set-buffer gnus-summary-buffer))
3708 (setq gnus-summary-buffer (current-buffer))
3709 (let* ((gnus-article (if header (mail-header-number header) article))
3710 (summary-buffer (current-buffer))
3711 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3712 (group gnus-newsgroup-name)
3715 (gnus-article-setup-buffer)
3716 (set-buffer gnus-article-buffer)
3717 ;; Deactivate active regions.
3718 (when (and (boundp 'transient-mark-mode)
3719 transient-mark-mode)
3720 (setq mark-active nil))
3721 (if (not (setq result (let ((buffer-read-only nil))
3722 (gnus-request-article-this-buffer
3724 ;; There is no such article.
3726 (when (and (numberp article)
3727 (not (memq article gnus-newsgroup-sparse)))
3728 (setq gnus-article-current
3729 (cons gnus-newsgroup-name article))
3730 (set-buffer gnus-summary-buffer)
3731 (setq gnus-current-article article)
3732 (if (and (memq article gnus-newsgroup-undownloaded)
3733 (not (gnus-online (gnus-find-method-for-group
3734 gnus-newsgroup-name))))
3736 (gnus-summary-set-agent-mark article)
3737 (message "Message marked for downloading"))
3738 (gnus-summary-mark-article article gnus-canceled-mark)
3739 (unless (memq article gnus-newsgroup-sparse)
3740 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3741 (if (or (eq result 'pseudo)
3742 (eq result 'nneething))
3745 (set-buffer summary-buffer)
3746 (push article gnus-newsgroup-history)
3747 (setq gnus-last-article gnus-current-article
3748 gnus-current-article 0
3749 gnus-current-headers nil
3750 gnus-article-current nil)
3751 (if (eq result 'nneething)
3752 (gnus-configure-windows 'summary)
3753 (gnus-configure-windows 'article))
3754 (gnus-set-global-variables))
3755 (let ((gnus-article-mime-handle-alist-1
3756 gnus-article-mime-handle-alist))
3757 (gnus-set-mode-line 'article)))
3758 ;; The result from the `request' was an actual article -
3759 ;; or at least some text that is now displayed in the
3761 (when (and (numberp article)
3762 (not (eq article gnus-current-article)))
3763 ;; Seems like a new article has been selected.
3764 ;; `gnus-current-article' must be an article number.
3766 (set-buffer summary-buffer)
3767 (push article gnus-newsgroup-history)
3768 (setq gnus-last-article gnus-current-article
3769 gnus-current-article article
3770 gnus-current-headers
3771 (gnus-summary-article-header gnus-current-article)
3772 gnus-article-current
3773 (cons gnus-newsgroup-name gnus-current-article))
3774 (unless (vectorp gnus-current-headers)
3775 (setq gnus-current-headers nil))
3776 (gnus-summary-goto-subject gnus-current-article)
3777 (when (gnus-summary-show-thread)
3778 ;; If the summary buffer really was folded, the
3779 ;; previous goto may not actually have gone to
3780 ;; the right article, but the thread root instead.
3782 (gnus-summary-goto-subject gnus-current-article))
3783 (gnus-run-hooks 'gnus-mark-article-hook)
3784 (gnus-set-mode-line 'summary)
3785 (when (gnus-visual-p 'article-highlight 'highlight)
3786 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3787 ;; Set the global newsgroup variables here.
3788 (gnus-set-global-variables)
3789 (setq gnus-have-all-headers
3790 (or all-headers gnus-show-all-headers))))
3792 (gnus-configure-windows 'article))
3793 (when (or (numberp article)
3795 (gnus-article-prepare-display)
3797 (goto-char (point-min))
3798 (when gnus-break-pages
3799 (gnus-narrow-to-page)))
3800 (let ((gnus-article-mime-handle-alist-1
3801 gnus-article-mime-handle-alist))
3802 (gnus-set-mode-line 'article))
3806 (set-window-point (get-buffer-window (current-buffer)) (point))
3807 (gnus-configure-windows 'article)
3811 (defun gnus-article-prepare-display ()
3812 "Make the current buffer look like a nice article."
3813 ;; Hooks for getting information from the article.
3814 ;; This hook must be called before being narrowed.
3815 (let ((gnus-article-buffer (current-buffer))
3817 (unless (eq major-mode 'gnus-article-mode)
3818 (gnus-article-mode))
3819 (setq buffer-read-only nil
3820 gnus-article-wash-types nil
3821 gnus-article-image-alist nil)
3822 (gnus-run-hooks 'gnus-tmp-internal-hook)
3823 (when gnus-display-mime-function
3824 (funcall gnus-display-mime-function))
3825 (gnus-run-hooks 'gnus-article-prepare-hook)))
3828 ;;; Gnus MIME viewing functions
3831 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3832 "Format of the MIME buttons.
3834 Valid specifiers include:
3836 %T MIME type, along with additional info
3837 %n The `name' parameter
3838 %d The description, if any
3839 %l The length of the encoded part
3840 %p The part identifier number
3841 %e Dots if the part isn't displayed
3843 General format specifiers can also be used. See Info node
3844 `(gnus)Formatting Variables'.")
3846 (defvar gnus-mime-button-line-format-alist
3847 '((?t gnus-tmp-type ?s)
3848 (?T gnus-tmp-type-long ?s)
3849 (?n gnus-tmp-name ?s)
3850 (?d gnus-tmp-description ?s)
3852 (?l gnus-tmp-length ?d)
3853 (?e gnus-tmp-dots ?s)))
3855 (defvar gnus-mime-button-commands
3856 '((gnus-article-press-button "\r" "Toggle Display")
3857 (gnus-mime-view-part "v" "View Interactively...")
3858 (gnus-mime-view-part-as-type "t" "View As Type...")
3859 (gnus-mime-view-part-as-charset "C" "View As charset...")
3860 (gnus-mime-save-part "o" "Save...")
3861 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3862 (gnus-mime-delete-part "d" "Delete part")
3863 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3864 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3865 (gnus-mime-view-part-internally "E" "View Internally")
3866 (gnus-mime-view-part-externally "e" "View Externally")
3867 (gnus-mime-print-part "p" "Print")
3868 (gnus-mime-pipe-part "|" "Pipe To Command...")
3869 (gnus-mime-action-on-part "." "Take action on the part...")))
3871 (defun gnus-article-mime-part-status ()
3872 (if gnus-article-mime-handle-alist-1
3873 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3875 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3878 (defvar gnus-mime-button-map
3879 (let ((map (make-sparse-keymap)))
3880 (unless (>= (string-to-number emacs-version) 21)
3881 ;; XEmacs doesn't care.
3882 (set-keymap-parent map gnus-article-mode-map))
3883 (define-key map gnus-mouse-2 'gnus-article-push-button)
3884 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3885 (dolist (c gnus-mime-button-commands)
3886 (define-key map (cadr c) (car c)))
3890 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
3892 ,@(mapcar (lambda (c)
3893 (vector (caddr c) (car c) :enable t))
3894 gnus-mime-button-commands)))
3897 (define-compiler-macro popup-menu (&whole form
3898 menu &optional position prefix)
3899 (if (and (fboundp 'popup-menu)
3900 (not (memq 'popup-menu (assoc "lmenu" load-history))))
3902 ;; Gnus is probably running under Emacs 20.
3903 `(let* ((menu (cdr ,menu))
3904 (response (x-popup-menu
3906 (cons "" (mapcar (lambda (c)
3907 (cons (caddr c) (car c)))
3910 (call-interactively (nth 3 (assq response menu))))))))
3912 (defun gnus-mime-button-menu (event prefix)
3913 "Construct a context-sensitive menu of MIME commands."
3914 (interactive "e\nP")
3915 (save-window-excursion
3916 (let ((pos (event-start event)))
3917 (select-window (posn-window pos))
3918 (goto-char (posn-point pos))
3919 (gnus-article-check-buffer)
3920 (popup-menu gnus-mime-button-menu nil prefix))))
3922 (defun gnus-mime-view-all-parts (&optional handles)
3923 "View all the MIME parts."
3925 (save-current-buffer
3926 (set-buffer gnus-article-buffer)
3927 (let ((handles (or handles gnus-article-mime-handles))
3928 (mail-parse-charset gnus-newsgroup-charset)
3929 (mail-parse-ignored-charsets
3930 (with-current-buffer gnus-summary-buffer
3931 gnus-newsgroup-ignored-charsets)))
3933 (mm-remove-parts handles)
3934 (goto-char (point-min))
3935 (or (search-forward "\n\n") (goto-char (point-max)))
3936 (let (buffer-read-only)
3937 (delete-region (point) (point-max))
3938 (mm-display-parts handles))))))
3940 (defun gnus-mime-save-part-and-strip ()
3941 "Save the MIME part under point then replace it with an external body."
3943 (gnus-article-check-buffer)
3944 (let* ((data (get-text-property (point) 'gnus-data))
3946 (handles gnus-article-mime-handles))
3947 (if (mm-multiple-handles gnus-article-mime-handles)
3948 (error "This function is not implemented"))
3949 (setq file (and data (mm-save-part data)))
3951 (with-current-buffer (mm-handle-buffer data)
3953 (insert "Content-Type: " (mm-handle-media-type data))
3954 (mml-insert-parameter-string (cdr (mm-handle-type data))
3957 (insert "Content-ID: " (message-make-message-id) "\n")
3958 (insert "Content-Transfer-Encoding: binary\n")
3961 (cdr (mm-make-handle nil
3962 `("message/external-body"
3963 (access-type . "LOCAL-FILE")
3965 (set-buffer gnus-summary-buffer)
3966 (gnus-article-edit-article
3969 (let ((mail-parse-charset (or gnus-article-charset
3970 ',gnus-newsgroup-charset))
3971 (mail-parse-ignored-charsets
3972 (or gnus-article-ignored-charsets
3973 ',gnus-newsgroup-ignored-charsets))
3974 (mbl mml-buffer-list))
3975 (setq mml-buffer-list nil)
3976 (insert-buffer gnus-original-article-buffer)
3977 (mime-to-mml ',handles)
3978 (setq gnus-article-mime-handles nil)
3979 (let ((mbl1 mml-buffer-list))
3980 (setq mml-buffer-list mbl)
3981 (set (make-local-variable 'mml-buffer-list) mbl1))
3982 (gnus-make-local-hook 'kill-buffer-hook)
3983 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3984 `(lambda (no-highlight)
3985 (let ((mail-parse-charset (or gnus-article-charset
3986 ',gnus-newsgroup-charset))
3987 (message-options message-options)
3988 (message-options-set-recipient)
3989 (mail-parse-ignored-charsets
3990 (or gnus-article-ignored-charsets
3991 ',gnus-newsgroup-ignored-charsets)))
3993 (mml-destroy-buffers)
3994 (remove-hook 'kill-buffer-hook
3995 'mml-destroy-buffers t)
3996 (kill-local-variable 'mml-buffer-list))
3997 (gnus-summary-edit-article-done
3998 ,(or (mail-header-references gnus-current-headers) "")
3999 ,(gnus-group-read-only-p)
4000 ,gnus-summary-buffer no-highlight))))))
4002 (defun gnus-mime-delete-part ()
4003 "Delete the MIME part under point.
4004 Replace it with some information about the removed part."
4006 (gnus-article-check-buffer)
4007 (unless (and gnus-novice-user
4008 (not (gnus-yes-or-no-p
4009 "Really delete attachment forever? ")))
4010 (let* ((data (get-text-property (point) 'gnus-data))
4011 (handles gnus-article-mime-handles)
4015 (mail-decode-encoded-word-string (or (mm-handle-description data)
4018 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4020 (type (mm-handle-media-type data)))
4021 (if (mm-multiple-handles gnus-article-mime-handles)
4022 (error "This function is not implemented"))
4023 (with-current-buffer (mm-handle-buffer data)
4024 (let ((bsize (format "%s" (buffer-size))))
4029 "| The following attachment has been deleted:\n"
4031 "| Type: " type "\n"
4032 "| Filename: " filename "\n"
4033 "| Size (encoded): " bsize " Byte\n"
4034 "| Description: " description "\n"
4037 (cdr (mm-make-handle
4038 nil `("text/plain") nil nil
4040 (format "Deleted attachment (%s bytes)" bsize))))))
4041 (set-buffer gnus-summary-buffer)
4042 ;; FIXME: maybe some of the following code (borrowed from
4043 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4044 (gnus-article-edit-article
4047 (let ((mail-parse-charset (or gnus-article-charset
4048 ',gnus-newsgroup-charset))
4049 (mail-parse-ignored-charsets
4050 (or gnus-article-ignored-charsets
4051 ',gnus-newsgroup-ignored-charsets))
4052 (mbl mml-buffer-list))
4053 (setq mml-buffer-list nil)
4054 (insert-buffer gnus-original-article-buffer)
4055 (mime-to-mml ',handles)
4056 (setq gnus-article-mime-handles nil)
4057 (let ((mbl1 mml-buffer-list))
4058 (setq mml-buffer-list mbl)
4059 (set (make-local-variable 'mml-buffer-list) mbl1))
4060 (gnus-make-local-hook 'kill-buffer-hook)
4061 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4062 `(lambda (no-highlight)
4063 (let ((mail-parse-charset (or gnus-article-charset
4064 ',gnus-newsgroup-charset))
4065 (message-options message-options)
4066 (message-options-set-recipient)
4067 (mail-parse-ignored-charsets
4068 (or gnus-article-ignored-charsets
4069 ',gnus-newsgroup-ignored-charsets)))
4071 (mml-destroy-buffers)
4072 (remove-hook 'kill-buffer-hook
4073 'mml-destroy-buffers t)
4074 (kill-local-variable 'mml-buffer-list))
4075 (gnus-summary-edit-article-done
4076 ,(or (mail-header-references gnus-current-headers) "")
4077 ,(gnus-group-read-only-p)
4078 ,gnus-summary-buffer no-highlight)))))
4079 ;; Not in `gnus-mime-save-part-and-strip':
4080 (gnus-article-edit-done)
4081 (gnus-summary-expand-window)
4082 (gnus-summary-show-article))
4084 (defun gnus-mime-save-part ()
4085 "Save the MIME part under point."
4087 (gnus-article-check-buffer)
4088 (let ((data (get-text-property (point) 'gnus-data)))
4090 (mm-save-part data))))
4092 (defun gnus-mime-pipe-part ()
4093 "Pipe the MIME part under point to a process."
4095 (gnus-article-check-buffer)
4096 (let ((data (get-text-property (point) 'gnus-data)))
4098 (mm-pipe-part data))))
4100 (defun gnus-mime-view-part ()
4101 "Interactively choose a viewing method for the MIME part under point."
4103 (gnus-article-check-buffer)
4104 (let ((data (get-text-property (point) 'gnus-data)))
4106 (setq gnus-article-mime-handles
4108 gnus-article-mime-handles (setq data (copy-sequence data))))
4109 (mm-interactively-view-part data))))
4111 (defun gnus-mime-view-part-as-type-internal ()
4112 (gnus-article-check-buffer)
4113 (let* ((name (mail-content-type-get
4114 (mm-handle-type (get-text-property (point) 'gnus-data))
4116 (def-type (and name (mm-default-file-encoding name))))
4117 (and def-type (cons def-type 0))))
4119 (defun gnus-mime-view-part-as-type (&optional mime-type)
4120 "Choose a MIME media type, and view the part as such."
4123 (setq mime-type (completing-read
4124 "View as MIME type: "
4125 (mapcar #'list (mailcap-mime-types))
4127 (gnus-mime-view-part-as-type-internal))))
4128 (gnus-article-check-buffer)
4129 (let ((handle (get-text-property (point) 'gnus-data)))
4132 (mm-make-handle (mm-handle-buffer handle)
4133 (cons mime-type (cdr (mm-handle-type handle)))
4134 (mm-handle-encoding handle)
4135 (mm-handle-undisplayer handle)
4136 (mm-handle-disposition handle)
4137 (mm-handle-description handle)
4139 (mm-handle-id handle)))
4140 (setq gnus-article-mime-handles
4141 (mm-merge-handles gnus-article-mime-handles handle))
4142 (gnus-mm-display-part handle))))
4145 (require 'jka-compr))
4147 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4148 ;; emacs can do that itself.
4150 (defun gnus-mime-jka-compr-maybe-uncompress ()
4151 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4152 The uncompress method used is derived from `buffer-file-name'."
4153 (when (and (fboundp 'jka-compr-installed-p)
4154 (jka-compr-installed-p))
4155 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4157 (let ((basename (file-name-nondirectory buffer-file-name))
4158 (args (jka-compr-info-uncompress-args info))
4159 (prog (jka-compr-info-uncompress-program info))
4160 (message (jka-compr-info-uncompress-message info))
4161 (err-file (jka-compr-make-temp-name)))
4163 (message "%s %s..." message basename))
4165 (unless (memq (apply 'call-process-region
4166 (point-min) (point-max)
4168 t (list t err-file) nil
4170 jka-compr-acceptable-retval-list)
4171 (jka-compr-error prog args basename message err-file))
4172 (jka-compr-delete-temp-file err-file)))))))
4174 (defun gnus-mime-copy-part (&optional handle)
4175 "Put the MIME part under point into a new buffer.
4176 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4179 (gnus-article-check-buffer)
4180 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4181 (contents (and handle (mm-get-part handle)))
4183 (file-name-nondirectory
4185 (mail-content-type-get (mm-handle-type handle) 'name)
4186 (mail-content-type-get (mm-handle-disposition handle)
4189 (buffer (and base (generate-new-buffer base))))
4191 (switch-to-buffer buffer)
4193 ;; We do it this way to make `normal-mode' set the appropriate mode.
4196 (setq buffer-file-name (expand-file-name base))
4197 (gnus-mime-jka-compr-maybe-uncompress)
4199 (setq buffer-file-name nil))
4200 (goto-char (point-min)))))
4202 (defun gnus-mime-print-part (&optional handle filename)
4203 "Print the MIME part under point."
4204 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4205 (gnus-article-check-buffer)
4206 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4207 (contents (and handle (mm-get-part handle)))
4208 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4209 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4214 (mm-save-part-to-file handle file)
4215 (call-process shell-file-name nil
4216 (generate-new-buffer " *mm*")
4218 shell-command-switch
4220 printer file (mm-handle-type handle))))
4224 (gnus-print-buffer))
4225 (ps-despool filename)))))
4227 (defun gnus-mime-inline-part (&optional handle arg)
4228 "Insert the MIME part under point into the current buffer."
4229 (interactive (list nil current-prefix-arg))
4230 (gnus-article-check-buffer)
4231 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4236 (if (and (not arg) (mm-handle-undisplayer handle))
4237 (mm-remove-part handle)
4238 (setq contents (mm-get-part handle))
4241 (setq charset (or (mail-content-type-get
4242 (mm-handle-type handle) 'charset)
4243 gnus-newsgroup-charset)))
4245 (if (mm-handle-undisplayer handle)
4246 (mm-remove-part handle))
4249 gnus-summary-show-article-charset-alist))
4250 (mm-read-coding-system "Charset: ")))))
4252 (mm-insert-inline handle
4254 (setq charset (mm-charset-to-coding-system
4256 (not (eq charset 'ascii)))
4257 (mm-decode-coding-string contents charset)
4261 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4262 "Insert the MIME part under point into the current buffer using the
4264 (interactive (list nil current-prefix-arg))
4265 (gnus-article-check-buffer)
4266 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4271 (if (mm-handle-undisplayer handle)
4272 (mm-remove-part handle))
4273 (let ((gnus-newsgroup-charset
4275 gnus-summary-show-article-charset-alist))
4276 (mm-read-coding-system "Charset: ")))
4277 (gnus-newsgroup-ignored-charsets 'gnus-all))
4278 (gnus-article-press-button)))))
4280 (defun gnus-mime-view-part-externally (&optional handle)
4281 "View the MIME part under point with an external viewer."
4283 (gnus-article-check-buffer)
4284 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4285 (mm-user-display-methods nil)
4286 (mm-inlined-types nil)
4287 (mail-parse-charset gnus-newsgroup-charset)
4288 (mail-parse-ignored-charsets
4289 (save-excursion (set-buffer gnus-summary-buffer)
4290 gnus-newsgroup-ignored-charsets)))
4292 (if (mm-handle-undisplayer handle)
4293 (mm-remove-part handle)
4294 (mm-display-part handle)))))
4296 (defun gnus-mime-view-part-internally (&optional handle)
4297 "View the MIME part under point with an internal viewer.
4298 If no internal viewer is available, use an external viewer."
4300 (gnus-article-check-buffer)
4301 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4302 (mm-inlined-types '(".*"))
4303 (mm-inline-large-images t)
4304 (mail-parse-charset gnus-newsgroup-charset)
4305 (mail-parse-ignored-charsets
4306 (save-excursion (set-buffer gnus-summary-buffer)
4307 gnus-newsgroup-ignored-charsets))
4310 (if (mm-handle-undisplayer handle)
4311 (mm-remove-part handle)
4312 (mm-display-part handle)))))
4314 (defun gnus-mime-action-on-part (&optional action)
4315 "Do something with the MIME attachment at \(point\)."
4317 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4318 (gnus-article-check-buffer)
4319 (let ((action-pair (assoc action gnus-mime-action-alist)))
4321 (funcall (cdr action-pair)))))
4323 (defun gnus-article-part-wrapper (n function)
4324 (save-current-buffer
4325 (set-buffer gnus-article-buffer)
4326 (when (> n (length gnus-article-mime-handle-alist))
4327 (error "No such part"))
4328 (gnus-article-goto-part n)
4329 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4330 (funcall function handle))))
4332 (defun gnus-article-pipe-part (n)
4333 "Pipe MIME part N, which is the numerical prefix."
4335 (gnus-article-part-wrapper n 'mm-pipe-part))
4337 (defun gnus-article-save-part (n)
4338 "Save MIME part N, which is the numerical prefix."
4340 (gnus-article-part-wrapper n 'mm-save-part))
4342 (defun gnus-article-interactively-view-part (n)
4343 "View MIME part N interactively, which is the numerical prefix."
4345 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4347 (defun gnus-article-copy-part (n)
4348 "Copy MIME part N, which is the numerical prefix."
4350 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4352 (defun gnus-article-view-part-as-charset (n)
4353 "View MIME part N using a specified charset.
4354 N is the numerical prefix."
4356 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4358 (defun gnus-article-view-part-externally (n)
4359 "View MIME part N externally, which is the numerical prefix."
4361 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4363 (defun gnus-article-inline-part (n)
4364 "Inline MIME part N, which is the numerical prefix."
4366 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4368 (defun gnus-article-mime-match-handle-first (condition)
4370 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4371 (while (setq ihandle (pop alist))
4373 ((functionp condition)
4374 (funcall condition (cdr ihandle)))
4375 ((eq condition 'undisplayed)
4376 (not (or (mm-handle-undisplayer (cdr ihandle))
4377 (equal (mm-handle-media-type (cdr ihandle))
4378 "multipart/alternative"))))
4379 ((eq condition 'undisplayed-alternative)
4380 (not (mm-handle-undisplayer (cdr ihandle))))
4382 (gnus-article-goto-part (car ihandle))
4383 (or (not n) (< (car ihandle) n)))
4384 (setq n (car ihandle))))
4388 (defun gnus-article-view-part (&optional n)
4389 "View MIME part N, which is the numerical prefix."
4391 (save-current-buffer
4392 (set-buffer gnus-article-buffer)
4393 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4394 gnus-article-mime-match-handle-function)))
4395 (when (> n (length gnus-article-mime-handle-alist))
4396 (error "No such part"))
4397 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4398 (when (gnus-article-goto-part n)
4399 (if (equal (car handle) "multipart/alternative")
4400 (gnus-article-press-button)
4401 (when (eq (gnus-mm-display-part handle) 'internal)
4402 (gnus-set-window-start)))))))
4404 (defsubst gnus-article-mime-total-parts ()
4405 (if (bufferp (car gnus-article-mime-handles))
4407 (1- (length gnus-article-mime-handles))))
4409 (defun gnus-mm-display-part (handle)
4410 "Display HANDLE and fix MIME button."
4411 (let ((id (get-text-property (point) 'gnus-part))
4416 (let ((window (selected-window))
4417 (mail-parse-charset gnus-newsgroup-charset)
4418 (mail-parse-ignored-charsets
4419 (if (gnus-buffer-live-p gnus-summary-buffer)
4421 (set-buffer gnus-summary-buffer)
4422 gnus-newsgroup-ignored-charsets)
4426 (let ((win (gnus-get-buffer-window (current-buffer) t))
4429 (select-window win))
4432 (if (mm-handle-displayed-p handle)
4433 ;; This will remove the part.
4434 (mm-display-part handle)
4436 (narrow-to-region (point)
4437 (if (eobp) (point) (1+ (point))))
4438 (mm-display-part handle)
4439 ;; We narrow to the part itself and
4440 ;; then call the treatment functions.
4441 (goto-char (point-min))
4443 (narrow-to-region (point) (point-max))
4446 (gnus-article-mime-total-parts)
4447 (mm-handle-media-type handle)))))
4448 (if (window-live-p window)
4449 (select-window window)))))
4452 (gnus-insert-mime-button
4453 handle id (list (mm-handle-displayed-p handle)))
4454 (goto-char point))))
4456 (defun gnus-article-goto-part (n)
4457 "Go to MIME part N."
4458 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4460 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4461 (let ((gnus-tmp-name
4462 (or (mail-content-type-get (mm-handle-type handle) 'name)
4463 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4464 (mail-content-type-get (mm-handle-type handle) 'url)
4466 (gnus-tmp-type (mm-handle-media-type handle))
4467 (gnus-tmp-description
4468 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4471 (if (if displayed (car displayed)
4472 (mm-handle-displayed-p handle))
4474 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4476 gnus-tmp-type-long b e)
4477 (when (string-match ".*/" gnus-tmp-name)
4478 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4479 (setq gnus-tmp-type-long (concat gnus-tmp-type
4480 (and (not (equal gnus-tmp-name ""))
4481 (concat "; " gnus-tmp-name))))
4482 (unless (equal gnus-tmp-description "")
4483 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4488 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4489 `(,@(gnus-local-map-property gnus-mime-button-map)
4490 gnus-callback gnus-mm-display-part
4491 gnus-part ,gnus-tmp-id
4492 article-type annotation
4495 ;; Exclude a newline.
4498 (widget-convert-button
4501 :action 'gnus-widget-press-button
4502 :button-keymap gnus-mime-button-map
4504 (lambda (widget/window &optional overlay pos)
4505 ;; Needed to properly clear the message due to a bug in
4506 ;; wid-edit (XEmacs only).
4507 (if (boundp 'help-echo-owns-message)
4508 (setq help-echo-owns-message t))
4510 "%S: %s the MIME part; %S: more options"
4511 (aref gnus-mouse-2 0)
4512 ;; XEmacs will get a single widget arg; Emacs 21 will get
4513 ;; window, overlay, position.
4514 (if (mm-handle-displayed-p
4516 (with-current-buffer (gnus-overlay-buffer overlay)
4517 (widget-get (widget-at (gnus-overlay-start overlay))
4519 (widget-get widget/window :mime-handle)))
4521 (aref gnus-down-mouse-3 0))))))
4523 (defun gnus-widget-press-button (elems el)
4524 (goto-char (widget-get elems :from))
4525 (gnus-article-press-button))
4527 (defvar gnus-displaying-mime nil)
4529 (defun gnus-display-mime (&optional ihandles)
4530 "Display the MIME parts."
4532 (save-selected-window
4533 (let ((window (get-buffer-window gnus-article-buffer))
4536 (select-window window)
4537 ;; We have to do this since selecting the window
4538 ;; may change the point. So we set the window point.
4539 (set-window-point window point)))
4540 (let* ((handles (or ihandles
4541 (mm-dissect-buffer nil gnus-article-loose-mime)
4542 (and gnus-article-emulate-mime
4544 buffer-read-only handle name type b e display)
4545 (when (and (not ihandles)
4546 (not gnus-displaying-mime))
4547 ;; Top-level call; we clean up.
4548 (when gnus-article-mime-handles
4549 (mm-destroy-parts gnus-article-mime-handles)
4550 (setq gnus-article-mime-handle-alist nil));; A trick.
4551 (setq gnus-article-mime-handles handles)
4552 ;; We allow users to glean info from the handles.
4553 (when gnus-article-mime-part-function
4554 (gnus-mime-part-function handles)))
4556 (or (not (stringp (car handles)))
4559 (when (and (not ihandles)
4560 (not gnus-displaying-mime))
4561 ;; Clean up for mime parts.
4563 (delete-region (point) (point-max)))
4564 (let ((gnus-displaying-mime t))
4565 (gnus-mime-display-part handles)))
4568 (narrow-to-region (point) (point-max))
4569 (gnus-treat-article nil 1 1)
4572 ;; Highlight the headers.
4576 (narrow-to-region (point-min) (point))
4577 (gnus-treat-article 'head))))))))
4579 (defcustom gnus-mime-display-multipart-as-mixed nil
4580 "Display \"multipart\" parts as \"multipart/mixed\".
4582 If t, it overrides nil values of
4583 `gnus-mime-display-multipart-alternative-as-mixed' and
4584 `gnus-mime-display-multipart-related-as-mixed'."
4585 :group 'gnus-article-mime
4588 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4589 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4590 :group 'gnus-article-mime
4593 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4594 "Display \"multipart/related\" parts as \"multipart/mixed\".
4596 If displaying \"text/html\" is discouraged \(see
4597 `mm-discouraged-alternatives'\) images or other material inside a
4598 \"multipart/related\" part might be overlooked when this variable is nil."
4599 :group 'gnus-article-mime
4602 (defun gnus-mime-display-part (handle)
4605 ((not (stringp (car handle)))
4606 (gnus-mime-display-single handle))
4607 ;; User-defined multipart
4608 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4609 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4611 ;; multipart/alternative
4612 ((and (equal (car handle) "multipart/alternative")
4613 (not (or gnus-mime-display-multipart-as-mixed
4614 gnus-mime-display-multipart-alternative-as-mixed)))
4615 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4616 (push (cons id handle) gnus-article-mime-handle-alist)
4617 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4618 ;; multipart/related
4619 ((and (equal (car handle) "multipart/related")
4620 (not (or gnus-mime-display-multipart-as-mixed
4621 gnus-mime-display-multipart-related-as-mixed)))
4622 ;;;!!!We should find the start part, but we just default
4623 ;;;!!!to the first part.
4624 ;;(gnus-mime-display-part (cadr handle))
4625 ;;;!!! Most multipart/related is an HTML message plus images.
4626 ;;;!!! Unfortunately we are unable to let W3 display those
4627 ;;;!!! included images, so we just display it as a mixed multipart.
4628 ;;(gnus-mime-display-mixed (cdr handle))
4629 ;;;!!! No, w3 can display everything just fine.
4630 (gnus-mime-display-part (cadr handle)))
4631 ((equal (car handle) "multipart/signed")
4632 (gnus-add-wash-type 'signed)
4633 (gnus-mime-display-security handle))
4634 ((equal (car handle) "multipart/encrypted")
4635 (gnus-add-wash-type 'encrypted)
4636 (gnus-mime-display-security handle))
4637 ;; Other multiparts are handled like multipart/mixed.
4639 (gnus-mime-display-mixed (cdr handle)))))
4641 (defun gnus-mime-part-function (handles)
4642 (if (stringp (car handles))
4643 (mapcar 'gnus-mime-part-function (cdr handles))
4644 (funcall gnus-article-mime-part-function handles)))
4646 (defun gnus-mime-display-mixed (handles)
4647 (mapcar 'gnus-mime-display-part handles))
4649 (defun gnus-mime-display-single (handle)
4650 (let ((type (mm-handle-media-type handle))
4651 (ignored gnus-ignored-mime-types)
4658 (when (string-match (pop ignored) type)
4659 (throw 'ignored nil)))
4660 (if (and (setq not-attachment
4661 (and (not (mm-inline-override-p handle))
4662 (or (not (mm-handle-disposition handle))
4663 (equal (car (mm-handle-disposition handle))
4665 (mm-attachment-override-p handle))))
4666 (mm-automatic-display-p handle)
4668 (mm-inlinable-p handle)
4669 (mm-inlined-p handle))
4670 (mm-automatic-external-display-p type)))
4672 (when (equal (mm-handle-media-supertype handle) "text")
4674 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4676 (push (cons id handle) gnus-article-mime-handle-alist)
4677 (when (or (not display)
4678 (not (gnus-unbuttonized-mime-type-p type)))
4679 ;(gnus-article-insert-newline)
4680 (gnus-insert-mime-button
4681 handle id (list (or display (and not-attachment text))))
4682 (gnus-article-insert-newline)
4683 ;(gnus-article-insert-newline)
4684 ;; Remember modify the number of forward lines.
4692 (let ((mail-parse-charset gnus-newsgroup-charset)
4693 (mail-parse-ignored-charsets
4694 (save-excursion (condition-case ()
4695 (set-buffer gnus-summary-buffer)
4697 gnus-newsgroup-ignored-charsets)))
4698 (mm-display-part handle t))
4699 (goto-char (point-max)))
4700 ((and text not-attachment)
4704 (gnus-article-insert-newline)
4705 (mm-insert-inline handle (mm-get-part handle))
4706 (goto-char (point-max))))
4710 (narrow-to-region beg (point))
4713 (gnus-article-mime-total-parts)
4714 (mm-handle-media-type handle)))))))))
4716 (defun gnus-unbuttonized-mime-type-p (type)
4717 "Say whether TYPE is to be unbuttonized."
4718 (unless gnus-inhibit-mime-unbuttonizing
4720 (let ((types gnus-unbuttonized-mime-types))
4722 (when (string-match (pop types) type)
4723 (throw 'found t)))))
4725 (let ((types gnus-buttonized-mime-types))
4727 (when (string-match (pop types) type)
4728 (throw 'found t)))))))))
4730 (defun gnus-article-insert-newline ()
4731 "Insert a newline, but mark it as undeletable."
4732 (gnus-put-text-property
4733 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4735 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4736 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4739 handle buffer-read-only from props begend not-pref)
4740 (save-window-excursion
4743 (narrow-to-region (car ibegend)
4746 (goto-char (car ibegend))
4749 (delete-region (point-min) (point-max))
4750 (mm-remove-parts handles))
4751 (setq begend (list (point-marker)))
4753 (unless (setq not-pref (cadr (member preferred ihandles)))
4754 (setq not-pref (car ihandles)))
4757 (not (gnus-unbuttonized-mime-type-p
4758 "multipart/alternative")))
4759 (gnus-add-text-properties
4762 (insert (format "%d. " id))
4766 (unless ,(not ibegend)
4767 (setq gnus-article-mime-handle-alist
4768 ',gnus-article-mime-handle-alist))
4769 (gnus-mime-display-alternative
4770 ',ihandles ',not-pref ',begend ,id))
4771 ,@(gnus-local-map-property gnus-mime-button-map)
4772 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4773 face ,gnus-article-button-face
4776 (widget-convert-button 'link from (point)
4777 :action 'gnus-widget-press-button
4778 :button-keymap gnus-widget-button-keymap)
4780 (while (setq handle (pop handles))
4781 (gnus-add-text-properties
4784 (insert (format "(%c) %-18s"
4785 (if (equal handle preferred) ?* ? )
4786 (mm-handle-media-type handle)))
4790 (unless ,(not ibegend)
4791 (setq gnus-article-mime-handle-alist
4792 ',gnus-article-mime-handle-alist))
4793 (gnus-mime-display-alternative
4794 ',ihandles ',handle ',begend ,id))
4795 ,@(gnus-local-map-property gnus-mime-button-map)
4796 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4797 face ,gnus-article-button-face
4800 (widget-convert-button 'link from (point)
4801 :action 'gnus-widget-press-button
4802 :button-keymap gnus-widget-button-keymap)
4806 (if (stringp (car preferred))
4807 (gnus-display-mime preferred)
4808 (let ((mail-parse-charset gnus-newsgroup-charset)
4809 (mail-parse-ignored-charsets
4810 (save-excursion (set-buffer gnus-summary-buffer)
4811 gnus-newsgroup-ignored-charsets)))
4812 (mm-display-part preferred)
4816 (narrow-to-region (car begend) (point-max))
4818 nil (length gnus-article-mime-handle-alist)
4819 (gnus-article-mime-total-parts)
4820 (mm-handle-media-type handle))))))
4821 (goto-char (point-max))
4822 (setcdr begend (point-marker)))))
4824 (goto-char point))))
4826 (defconst gnus-article-wash-status-strings
4827 (let ((alist '((cite "c" "Possible hidden citation text"
4828 " " "All citation text visible")
4829 (headers "h" "Hidden headers"
4830 " " "All headers visible.")
4831 (pgp "p" "Encrypted or signed message status hidden"
4832 " " "No hidden encryption nor digital signature status")
4833 (signature "s" "Signature has been hidden"
4834 " " "Signature is visible")
4835 (overstrike "o" "Overstrike (^H) characters applied"
4836 " " "No overstrike characters applied")
4837 (emphasis "e" "/*_Emphasis_*/ characters applied"
4838 " " "No /*_emphasis_*/ characters applied")))
4840 (dolist (entry alist result)
4841 (let ((key (nth 0 entry))
4842 (on (copy-sequence (nth 1 entry)))
4843 (on-help (nth 2 entry))
4844 (off (copy-sequence (nth 3 entry)))
4845 (off-help (nth 4 entry)))
4846 (put-text-property 0 1 'help-echo on-help on)
4847 (put-text-property 0 1 'help-echo off-help off)
4848 (push (list key on off) result))))
4849 "Alist of strings describing wash status in the mode line.
4850 Each entry has the form (KEY ON OF), where the KEY is a symbol
4851 representing the particular washing function, ON is the string to use
4852 in the article mode line when the washing function is active, and OFF
4853 is the string to use when it is inactive.")
4855 (defun gnus-article-wash-status-entry (key value)
4856 (let ((entry (assoc key gnus-article-wash-status-strings)))
4857 (if value (nth 1 entry) (nth 2 entry))))
4859 (defun gnus-article-wash-status ()
4860 "Return a string which display status of article washing."
4862 (set-buffer gnus-article-buffer)
4863 (let ((cite (memq 'cite gnus-article-wash-types))
4864 (headers (memq 'headers gnus-article-wash-types))
4865 (boring (memq 'boring-headers gnus-article-wash-types))
4866 (pgp (memq 'pgp gnus-article-wash-types))
4867 (pem (memq 'pem gnus-article-wash-types))
4868 (signed (memq 'signed gnus-article-wash-types))
4869 (encrypted (memq 'encrypted gnus-article-wash-types))
4870 (signature (memq 'signature gnus-article-wash-types))
4871 (overstrike (memq 'overstrike gnus-article-wash-types))
4872 (emphasis (memq 'emphasis gnus-article-wash-types)))
4874 (gnus-article-wash-status-entry 'cite cite)
4875 (gnus-article-wash-status-entry 'headers (or headers boring))
4876 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4877 (gnus-article-wash-status-entry 'signature signature)
4878 (gnus-article-wash-status-entry 'overstrike overstrike)
4879 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4881 (defun gnus-add-wash-type (type)
4882 "Add a washing of TYPE to the current status."
4883 (add-to-list 'gnus-article-wash-types type))
4885 (defun gnus-delete-wash-type (type)
4886 "Add a washing of TYPE to the current status."
4887 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4889 (defun gnus-add-image (category image)
4890 "Add IMAGE of CATEGORY to the list of displayed images."
4891 (let ((entry (assq category gnus-article-image-alist)))
4893 (setq entry (list category))
4894 (push entry gnus-article-image-alist))
4895 (nconc entry (list image))))
4897 (defun gnus-delete-images (category)
4898 "Delete all images in CATEGORY."
4899 (let ((entry (assq category gnus-article-image-alist)))
4900 (dolist (image (cdr entry))
4901 (gnus-remove-image image category))
4902 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4903 (gnus-delete-wash-type category)))
4905 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4907 (defun gnus-article-maybe-hide-headers ()
4908 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4909 Provided for backwards compatibility."
4910 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4911 (not (save-excursion (set-buffer gnus-summary-buffer)
4912 gnus-have-all-headers)))
4913 (not gnus-inhibit-hiding))
4914 (gnus-article-hide-headers)))
4918 (defun gnus-output-to-file (file-name)
4919 "Append the current article to a file named FILE-NAME."
4920 (let ((artbuf (current-buffer)))
4922 (insert-buffer-substring artbuf)
4923 ;; Append newline at end of the buffer as separator, and then
4925 (goto-char (point-max))
4927 (let ((file-name-coding-system nnmail-pathname-coding-system))
4928 (mm-append-to-file (point-min) (point-max) file-name))
4931 (defun gnus-narrow-to-page (&optional arg)
4932 "Narrow the article buffer to a page.
4933 If given a numerical ARG, move forward ARG pages."
4935 (setq arg (if arg (prefix-numeric-value arg) 0))
4937 (set-buffer gnus-article-buffer)
4938 (goto-char (point-min))
4940 ;; Remove any old next/prev buttons.
4941 (when (gnus-visual-p 'page-marker)
4942 (let ((buffer-read-only nil))
4943 (gnus-remove-text-with-property 'gnus-prev)
4944 (gnus-remove-text-with-property 'gnus-next)))
4947 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4949 (re-search-forward page-delimiter nil 'move arg)))
4950 (goto-char (match-end 0))
4952 (goto-char (point-min))
4953 (setq gnus-page-broken
4954 (and (re-search-forward page-delimiter nil t) t))))
4955 (when gnus-page-broken
4958 (if (re-search-forward page-delimiter nil 'move)
4961 (when (and (gnus-visual-p 'page-marker)
4962 (not (= (point-min) 1)))
4964 (goto-char (point-min))
4965 (gnus-insert-prev-page-button)))
4966 (when (and (gnus-visual-p 'page-marker)
4967 (< (+ (point-max) 2) (buffer-size)))
4969 (goto-char (point-max))
4970 (gnus-insert-next-page-button))))))
4972 ;; Article mode commands
4974 (defun gnus-article-goto-next-page ()
4975 "Show the next page of the article."
4977 (when (gnus-article-next-page)
4978 (goto-char (point-min))
4979 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4982 (defun gnus-article-goto-prev-page ()
4983 "Show the previous page of the article."
4986 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4987 (gnus-article-prev-page nil)))
4989 ;; This is cleaner but currently breaks `gnus-pick-mode':
4991 ;; (defun gnus-article-goto-next-page ()
4992 ;; "Show the next page of the article."
4994 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
4995 ;; (gnus-summary-next-page)))
4997 ;; (defun gnus-article-goto-prev-page ()
4998 ;; "Show the next page of the article."
5000 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5001 ;; (gnus-summary-prev-page)))
5003 (defun gnus-article-next-page (&optional lines)
5004 "Show the next page of the current article.
5005 If end of article, return non-nil. Otherwise return nil.
5006 Argument LINES specifies lines to be scrolled up."
5008 (move-to-window-line -1)
5011 (and (pos-visible-in-window-p) ;Not continuation line.
5012 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5013 ;; Nothing in this page.
5014 (if (or (not gnus-page-broken)
5018 (eobp)))) ;Real end-of-buffer?
5020 (when gnus-article-over-scroll
5021 (gnus-article-next-page-1 lines))
5023 (gnus-narrow-to-page 1) ;Go to next page.
5025 ;; More in this page.
5026 (gnus-article-next-page-1 lines)
5029 (defun gnus-article-next-page-1 (lines)
5030 (let ((scroll-in-place nil))
5034 ;; Long lines may cause an end-of-buffer error.
5035 (goto-char (point-max)))))
5036 (move-to-window-line 0))
5038 (defun gnus-article-prev-page (&optional lines)
5039 "Show previous page of current article.
5040 Argument LINES specifies lines to be scrolled down."
5042 (move-to-window-line 0)
5043 (if (and gnus-page-broken
5045 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5047 (gnus-narrow-to-page -1) ;Go to previous page.
5048 (goto-char (point-max))
5050 (let ((scroll-in-place nil))
5054 (beginning-of-buffer
5055 (goto-char (point-min))))
5056 (move-to-window-line 0)))))
5058 (defun gnus-article-only-boring-p ()
5059 "Decide whether there is only boring text remaining in the article.
5060 Something \"interesting\" is a word of at least two letters that does
5061 not have a face in `gnus-article-boring-faces'."
5062 (when (and gnus-article-skip-boring
5063 (boundp 'gnus-article-boring-faces)
5064 (symbol-value 'gnus-article-boring-faces))
5067 (while (re-search-forward "\\b\\w\\w" nil t)
5069 (when (not (gnus-intersection
5070 (gnus-faces-at (point))
5071 (symbol-value 'gnus-article-boring-faces)))
5072 (throw 'only-boring nil)))
5073 (throw 'only-boring t)))))
5075 (defun gnus-article-refer-article ()
5076 "Read article specified by message-id around point."
5079 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5080 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5081 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5082 (let ((msg-id (concat "<" (match-string 0) ">")))
5083 (set-buffer gnus-summary-buffer)
5084 (gnus-summary-refer-article msg-id))
5085 (error "No references around point"))))
5087 (defun gnus-article-show-summary ()
5088 "Reconfigure windows to show summary buffer."
5090 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5091 (error "There is no summary buffer for this article buffer")
5092 (gnus-article-set-globals)
5093 (gnus-configure-windows 'article)
5094 (gnus-summary-goto-subject gnus-current-article)
5095 (gnus-summary-position-point)))
5097 (defun gnus-article-describe-briefly ()
5098 "Describe article mode commands briefly."
5100 (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")))
5102 (defun gnus-article-summary-command ()
5103 "Execute the last keystroke in the summary buffer."
5105 (let ((obuf (current-buffer))
5106 (owin (current-window-configuration))
5108 (switch-to-buffer gnus-article-current-summary 'norecord)
5109 (setq func (lookup-key (current-local-map) (this-command-keys)))
5110 (call-interactively func)
5112 (set-window-configuration owin)
5113 (set-window-point (get-buffer-window (current-buffer)) (point))))
5115 (defun gnus-article-summary-command-nosave ()
5116 "Execute the last keystroke in the summary buffer."
5119 (pop-to-buffer gnus-article-current-summary 'norecord)
5120 (setq func (lookup-key (current-local-map) (this-command-keys)))
5121 (call-interactively func)))
5123 (defun gnus-article-check-buffer ()
5124 "Beep if not in an article buffer."
5125 (unless (equal major-mode 'gnus-article-mode)
5126 (error "Command invoked outside of a Gnus article buffer")))
5128 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5129 "Read a summary buffer key sequence and execute it from the article buffer."
5131 (gnus-article-check-buffer)
5133 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5134 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5135 "=" "^" "\M-^" "|"))
5141 '("n" "Gn" "p" "Gp"))
5144 (set-buffer gnus-article-current-summary)
5145 (let (gnus-pick-mode)
5146 (push (or key last-command-event) unread-command-events)
5147 (setq keys (if (featurep 'xemacs)
5148 (events-to-keys (read-key-sequence nil))
5149 (read-key-sequence nil)))))
5153 (if (or (member keys nosaves)
5154 (member keys nosave-but-article)
5155 (member keys nosave-in-article))
5157 (save-window-excursion
5158 (pop-to-buffer gnus-article-current-summary 'norecord)
5159 ;; We disable the pick minor mode commands.
5160 (let (gnus-pick-mode)
5161 (setq func (lookup-key (current-local-map) keys))))
5165 (unless (member keys nosave-in-article)
5166 (set-buffer gnus-article-current-summary))
5167 (call-interactively func)
5168 (setq new-sum-point (point)))
5169 (when (member keys nosave-but-article)
5170 (pop-to-buffer gnus-article-buffer 'norecord)))
5171 ;; These commands should restore window configuration.
5172 (let ((obuf (current-buffer))
5173 (owin (current-window-configuration))
5175 (summary gnus-article-current-summary)
5176 func in-buffer selected)
5177 (if not-restore-window
5178 (pop-to-buffer summary 'norecord)
5179 (switch-to-buffer summary 'norecord))
5180 (setq in-buffer (current-buffer))
5181 ;; We disable the pick minor mode commands.
5182 (if (and (setq func (let (gnus-pick-mode)
5183 (lookup-key (current-local-map) keys)))
5186 (call-interactively func)
5187 (setq new-sum-point (point))
5188 (when (eq in-buffer (current-buffer))
5189 (setq selected (gnus-summary-select-article))
5191 (unless not-restore-window
5192 (set-window-configuration owin))
5193 (when (eq selected 'old)
5195 (set-window-start (get-buffer-window (current-buffer))
5197 (set-window-point (get-buffer-window (current-buffer))
5199 (let ((win (get-buffer-window gnus-article-current-summary)))
5201 (set-window-point win new-sum-point)))) )
5202 (switch-to-buffer gnus-article-buffer)
5205 (defun gnus-article-describe-key (key)
5206 "Display documentation of the function invoked by KEY. KEY is a string."
5207 (interactive "kDescribe key: ")
5208 (gnus-article-check-buffer)
5209 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5211 (set-buffer gnus-article-current-summary)
5212 (let (gnus-pick-mode)
5213 (if (featurep 'xemacs)
5215 (push (elt key 0) unread-command-events)
5216 (setq key (events-to-keys
5217 (read-key-sequence "Describe key: "))))
5218 (setq unread-command-events
5220 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5221 (string-to-list key)))
5222 (setq key (read-key-sequence "Describe key: "))))
5224 (describe-key key)))
5226 (defun gnus-article-describe-key-briefly (key &optional insert)
5227 "Display documentation of the function invoked by KEY. KEY is a string."
5228 (interactive "kDescribe key: \nP")
5229 (gnus-article-check-buffer)
5230 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5232 (set-buffer gnus-article-current-summary)
5233 (let (gnus-pick-mode)
5234 (if (featurep 'xemacs)
5236 (push (elt key 0) unread-command-events)
5237 (setq key (events-to-keys
5238 (read-key-sequence "Describe key: "))))
5239 (setq unread-command-events
5241 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5242 (string-to-list key)))
5243 (setq key (read-key-sequence "Describe key: "))))
5244 (describe-key-briefly key insert))
5245 (describe-key-briefly key insert)))
5247 (defun gnus-article-reply-with-original (&optional wide)
5248 "Start composing a reply mail to the current message.
5249 The text in the region will be yanked. If the region isn't active,
5250 the entire article will be yanked."
5252 (let ((article (cdr gnus-article-current))
5254 (if (not (gnus-mark-active-p))
5255 (with-current-buffer gnus-summary-buffer
5256 (gnus-summary-reply (list (list article)) wide))
5257 (setq contents (buffer-substring (point) (mark t)))
5258 ;; Deactivate active regions.
5259 (when (and (boundp 'transient-mark-mode)
5260 transient-mark-mode)
5261 (setq mark-active nil))
5262 (with-current-buffer gnus-summary-buffer
5264 (list (list article contents)) wide)))))
5266 (defun gnus-article-followup-with-original ()
5267 "Compose a followup to the current article.
5268 The text in the region will be yanked. If the region isn't active,
5269 the entire article will be yanked."
5271 (let ((article (cdr gnus-article-current))
5273 (if (not (gnus-mark-active-p))
5274 (with-current-buffer gnus-summary-buffer
5275 (gnus-summary-followup (list (list article))))
5276 (setq contents (buffer-substring (point) (mark t)))
5277 ;; Deactivate active regions.
5278 (when (and (boundp 'transient-mark-mode)
5279 transient-mark-mode)
5280 (setq mark-active nil))
5281 (with-current-buffer gnus-summary-buffer
5282 (gnus-summary-followup
5283 (list (list article contents)))))))
5285 (defun gnus-article-hide (&optional arg force)
5286 "Hide all the gruft in the current article.
5287 This means that signatures, cited text and (some) headers will be
5289 If given a prefix, show the hidden text instead."
5290 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5291 (gnus-article-hide-headers arg)
5292 (gnus-article-hide-list-identifiers arg)
5293 (gnus-article-hide-citation-maybe arg force)
5294 (gnus-article-hide-signature arg))
5296 (defun gnus-article-maybe-highlight ()
5297 "Do some article highlighting if article highlighting is requested."
5298 (when (gnus-visual-p 'article-highlight 'highlight)
5299 (gnus-article-highlight-some)))
5301 (defun gnus-check-group-server ()
5302 ;; Make sure the connection to the server is alive.
5303 (unless (gnus-server-opened
5304 (gnus-find-method-for-group gnus-newsgroup-name))
5305 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5306 (gnus-request-group gnus-newsgroup-name t)))
5309 (autoload 'nneething-get-file-name "nneething"))
5311 (defun gnus-request-article-this-buffer (article group)
5312 "Get an article and insert it into this buffer."
5313 (let (do-update-line sparse-header)
5317 (gnus-kill-all-overlays)
5318 (setq group (or group gnus-newsgroup-name))
5320 ;; Using `gnus-request-article' directly will insert the article into
5321 ;; `nntp-server-buffer' - so we'll save some time by not having to
5322 ;; copy it from the server buffer into the article buffer.
5324 ;; We only request an article by message-id when we do not have the
5325 ;; headers for it, so we'll have to get those.
5326 (when (stringp article)
5327 (gnus-read-header article))
5329 ;; If the article number is negative, that means that this article
5330 ;; doesn't belong in this newsgroup (possibly), so we find its
5331 ;; message-id and request it by id instead of number.
5332 (when (and (numberp article)
5334 (get-buffer gnus-summary-buffer)
5335 (gnus-buffer-exists-p gnus-summary-buffer))
5337 (set-buffer gnus-summary-buffer)
5338 (let ((header (gnus-summary-article-header article)))
5341 ((memq article gnus-newsgroup-sparse)
5342 ;; This is a sparse gap article.
5343 (setq do-update-line article)
5344 (setq article (mail-header-id header))
5345 (setq sparse-header (gnus-read-header article))
5346 (setq gnus-newsgroup-sparse
5347 (delq article gnus-newsgroup-sparse)))
5349 ;; It's a real article.
5350 (setq article (mail-header-id header)))
5352 ;; It is an extracted pseudo-article.
5353 (setq article 'pseudo)
5354 (gnus-request-pseudo-article header))))
5356 (let ((method (gnus-find-method-for-group
5357 gnus-newsgroup-name)))
5358 (when (and (eq (car method) 'nneething)
5360 (let ((dir (nneething-get-file-name
5361 (mail-header-id header))))
5362 (when (and (stringp dir)
5363 (file-directory-p dir))
5364 (setq article 'nneething)
5365 (gnus-group-enter-directory dir))))))))
5368 ;; Refuse to select canceled articles.
5369 ((and (numberp article)
5371 (get-buffer gnus-summary-buffer)
5372 (gnus-buffer-exists-p gnus-summary-buffer)
5373 (eq (cdr (save-excursion
5374 (set-buffer gnus-summary-buffer)
5375 (assq article gnus-newsgroup-reads)))
5376 gnus-canceled-mark))
5378 ;; We first check `gnus-original-article-buffer'.
5379 ((and (get-buffer gnus-original-article-buffer)
5382 (set-buffer gnus-original-article-buffer)
5383 (and (equal (car gnus-original-article) group)
5384 (eq (cdr gnus-original-article) article))))
5385 (insert-buffer-substring gnus-original-article-buffer)
5387 ;; Check the backlog.
5388 ((and gnus-keep-backlog
5389 (gnus-backlog-request-article group article (current-buffer)))
5391 ;; Check asynchronous pre-fetch.
5392 ((gnus-async-request-fetched-article group article (current-buffer))
5393 (gnus-async-prefetch-next group article gnus-summary-buffer)
5394 (when (and (numberp article) gnus-keep-backlog)
5395 (gnus-backlog-enter-article group article (current-buffer)))
5398 ((and gnus-use-cache
5400 (gnus-cache-request-article article group))
5402 ;; Check the agent cache.
5403 ((gnus-agent-request-article article group)
5405 ;; Get the article and put into the article buffer.
5406 ((or (stringp article)
5408 (let ((gnus-override-method gnus-override-method)
5409 (methods (and (stringp article)
5410 gnus-refer-article-method))
5411 (backend (car (gnus-find-method-for-group
5412 gnus-newsgroup-name)))
5414 (buffer-read-only nil))
5415 (if (or (not (listp methods))
5416 (and (symbolp (car methods))
5417 (assq (car methods) nnoo-definition-alist)))
5418 (setq methods (list methods)))
5419 (when (and (null gnus-override-method)
5421 (setq gnus-override-method (pop methods)))
5423 (when (eq gnus-override-method 'current)
5424 (setq gnus-override-method
5425 (with-current-buffer gnus-summary-buffer
5426 gnus-current-select-method)))
5428 (gnus-kill-all-overlays)
5429 (let ((gnus-newsgroup-name group))
5430 (gnus-check-group-server))
5432 ((gnus-request-article article group (current-buffer))
5433 (when (numberp article)
5434 (gnus-async-prefetch-next group article
5435 gnus-summary-buffer)
5436 (when gnus-keep-backlog
5437 (gnus-backlog-enter-article
5438 group article (current-buffer))))
5439 (setq result 'article))
5441 (setq gnus-override-method (pop methods)))
5442 ((not (string-match "^400 "
5443 (nnheader-get-report backend)))
5444 ;; If we get 400 server disconnect, reconnect and
5445 ;; retry; otherwise, assume the article has expired.
5446 (setq result 'done))))
5447 (and (eq result 'article) 'article)))
5451 ;; Associate this article with the current summary buffer.
5452 (setq gnus-article-current-summary gnus-summary-buffer)
5454 ;; Take the article from the original article buffer
5455 ;; and place it in the buffer it's supposed to be in.
5456 (when (and (get-buffer gnus-article-buffer)
5457 (equal (buffer-name (current-buffer))
5458 (buffer-name (get-buffer gnus-article-buffer))))
5460 (if (get-buffer gnus-original-article-buffer)
5461 (set-buffer gnus-original-article-buffer)
5462 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5463 (buffer-disable-undo)
5464 (setq major-mode 'gnus-original-article-mode)
5465 (setq buffer-read-only t))
5466 (let (buffer-read-only)
5468 (insert-buffer-substring gnus-article-buffer))
5469 (setq gnus-original-article (cons group article)))
5472 (run-hooks 'gnus-article-decode-hook)
5473 ;; Mark article as decoded or not.
5474 (setq gnus-article-decoded-p gnus-article-decode-hook))
5476 ;; Update sparse articles.
5477 (when (and do-update-line
5478 (or (numberp article)
5480 (let ((buf (current-buffer)))
5481 (set-buffer gnus-summary-buffer)
5482 (gnus-summary-update-article do-update-line sparse-header)
5483 (gnus-summary-goto-subject do-update-line nil t)
5484 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5486 (set-buffer buf))))))
5492 (defcustom gnus-article-edit-mode-hook nil
5493 "Hook run in article edit mode buffers."
5494 :group 'gnus-article-various
5497 (defvar gnus-article-edit-done-function nil)
5499 (defvar gnus-article-edit-mode-map nil)
5500 (defvar gnus-article-edit-mode nil)
5502 ;; Should we be using derived.el for this?
5503 (unless gnus-article-edit-mode-map
5504 (setq gnus-article-edit-mode-map (make-keymap))
5505 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5507 (gnus-define-keys gnus-article-edit-mode-map
5508 "\C-c?" describe-mode
5509 "\C-c\C-c" gnus-article-edit-done
5510 "\C-c\C-k" gnus-article-edit-exit
5511 "\C-c\C-f\C-t" message-goto-to
5512 "\C-c\C-f\C-o" message-goto-from
5513 "\C-c\C-f\C-b" message-goto-bcc
5514 ;;"\C-c\C-f\C-w" message-goto-fcc
5515 "\C-c\C-f\C-c" message-goto-cc
5516 "\C-c\C-f\C-s" message-goto-subject
5517 "\C-c\C-f\C-r" message-goto-reply-to
5518 "\C-c\C-f\C-n" message-goto-newsgroups
5519 "\C-c\C-f\C-d" message-goto-distribution
5520 "\C-c\C-f\C-f" message-goto-followup-to
5521 "\C-c\C-f\C-m" message-goto-mail-followup-to
5522 "\C-c\C-f\C-k" message-goto-keywords
5523 "\C-c\C-f\C-u" message-goto-summary
5524 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5525 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5526 "\C-c\C-b" message-goto-body
5527 "\C-c\C-i" message-goto-signature
5529 "\C-c\C-t" message-insert-to
5530 "\C-c\C-n" message-insert-newsgroups
5531 "\C-c\C-o" message-sort-headers
5532 "\C-c\C-e" message-elide-region
5533 "\C-c\C-v" message-delete-not-region
5534 "\C-c\C-z" message-kill-to-signature
5535 "\M-\r" message-newline-and-reformat
5536 "\C-c\C-a" mml-attach-file
5537 "\C-a" message-beginning-of-line
5539 "\M-;" comment-region)
5541 (gnus-define-keys (gnus-article-edit-wash-map
5542 "\C-c\C-w" gnus-article-edit-mode-map)
5543 "f" gnus-article-edit-full-stops))
5546 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5548 ["Fetch To" message-insert-to t]
5549 ["Fetch Newsgroups" message-insert-newsgroups t]
5551 ["To" message-goto-to t]
5552 ["From" message-goto-from t]
5553 ["Subject" message-goto-subject t]
5554 ["Cc" message-goto-cc t]
5555 ["Reply-To" message-goto-reply-to t]
5556 ["Summary" message-goto-summary t]
5557 ["Keywords" message-goto-keywords t]
5558 ["Newsgroups" message-goto-newsgroups t]
5559 ["Followup-To" message-goto-followup-to t]
5560 ["Mail-Followup-To" message-goto-mail-followup-to t]
5561 ["Distribution" message-goto-distribution t]
5562 ["Body" message-goto-body t]
5563 ["Signature" message-goto-signature t]))
5565 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5566 "Major mode for editing articles.
5567 This is an extended text-mode.
5569 \\{gnus-article-edit-mode-map}"
5570 (make-local-variable 'gnus-article-edit-done-function)
5571 (make-local-variable 'gnus-prev-winconf)
5572 (set (make-local-variable 'font-lock-defaults)
5573 '(message-font-lock-keywords t))
5574 (set (make-local-variable 'mail-header-separator) "")
5575 (set (make-local-variable 'gnus-article-edit-mode) t)
5576 (easy-menu-add message-mode-field-menu message-mode-map)
5578 (setq buffer-read-only nil)
5579 (buffer-enable-undo)
5582 (defun gnus-article-edit (&optional force)
5583 "Edit the current article.
5584 This will have permanent effect only in mail groups.
5585 If FORCE is non-nil, allow editing of articles even in read-only
5588 (when (and (not force)
5589 (gnus-group-read-only-p))
5590 (error "The current newsgroup does not support article editing"))
5591 (gnus-article-date-original)
5592 (gnus-article-edit-article
5594 `(lambda (no-highlight)
5596 (gnus-summary-edit-article-done
5597 ,(or (mail-header-references gnus-current-headers) "")
5598 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5600 (defun gnus-article-edit-article (start-func exit-func)
5601 "Start editing the contents of the current article buffer."
5602 (let ((winconf (current-window-configuration)))
5603 (set-buffer gnus-article-buffer)
5604 (gnus-article-edit-mode)
5605 (funcall start-func)
5606 (set-buffer-modified-p nil)
5607 (gnus-configure-windows 'edit-article)
5608 (setq gnus-article-edit-done-function exit-func)
5609 (setq gnus-prev-winconf winconf)
5610 (gnus-message 6 "C-c C-c to end edits")))
5612 (defun gnus-article-edit-done (&optional arg)
5613 "Update the article edits and exit."
5615 (let ((func gnus-article-edit-done-function)
5616 (buf (current-buffer))
5617 (start (window-start))
5619 (winconf gnus-prev-winconf))
5620 (widen) ;; Widen it in case that users narrowed the buffer.
5623 ;; The cache and backlog have to be flushed somewhat.
5624 (when gnus-keep-backlog
5625 (gnus-backlog-remove-article
5626 (car gnus-article-current) (cdr gnus-article-current)))
5627 ;; Flush original article as well.
5629 (when (get-buffer gnus-original-article-buffer)
5630 (set-buffer gnus-original-article-buffer)
5631 (setq gnus-original-article nil)))
5632 (when gnus-use-cache
5633 (gnus-cache-update-article
5634 (car gnus-article-current) (cdr gnus-article-current)))
5635 ;; We remove all text props from the article buffer.
5636 (kill-all-local-variables)
5637 (gnus-set-text-properties (point-min) (point-max) nil)
5639 (set-window-configuration winconf)
5641 (set-window-start (get-buffer-window buf) start)
5642 (set-window-point (get-buffer-window buf) (point)))
5643 (gnus-summary-show-article))
5645 (defun gnus-article-edit-exit ()
5646 "Exit the article editing without updating."
5648 (when (or (not (buffer-modified-p))
5649 (yes-or-no-p "Article modified; kill anyway? "))
5650 (let ((curbuf (current-buffer))
5652 (window-start (window-start)))
5654 (if (gnus-buffer-live-p gnus-original-article-buffer)
5655 (insert-buffer gnus-original-article-buffer))
5656 (let ((winconf gnus-prev-winconf))
5657 (kill-all-local-variables)
5659 (set-window-configuration winconf)
5660 ;; Tippy-toe some to make sure that point remains where it was.
5661 (save-current-buffer
5663 (set-window-start (get-buffer-window (current-buffer)) window-start)
5665 (gnus-summary-show-article)))
5667 (defun gnus-article-edit-full-stops ()
5668 "Interactively repair spacing at end of sentences."
5671 (goto-char (point-min))
5672 (search-forward-regexp "^$" nil t)
5673 (let ((case-fold-search nil))
5674 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5677 ;;; Article highlights
5680 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5682 ;;; Internal Variables:
5684 (defcustom gnus-button-url-regexp
5685 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5686 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~%&*+\\/[:word:]]\\)"
5687 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)\\)")
5688 "Regular expression that matches URLs."
5689 :group 'gnus-article-buttons
5692 (defcustom gnus-button-valid-fqdn-regexp
5693 message-valid-fqdn-regexp
5694 "Regular expression that matches a valid FQDN."
5695 :group 'gnus-article-buttons
5698 (defcustom gnus-button-man-handler 'manual-entry
5699 "Function to use for displaying man pages.
5700 The function must take at least one argument with a string naming the
5702 :type '(choice (function-item :tag "Man" manual-entry)
5703 (function-item :tag "Woman" woman)
5704 (function :tag "Other"))
5705 :group 'gnus-article-buttons)
5707 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5708 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5709 If the default site is too slow, try to find a CTAN mirror, see
5710 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5711 the variable `gnus-button-handle-ctan'."
5712 :group 'gnus-article-buttons
5713 :link '(custom-manual "(gnus)Group Parameters")
5714 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5715 (const "http://tug.ctan.org/tex-archive/")
5716 (const "http://www.dante.de/CTAN/")
5717 (string :tag "Other")))
5719 (defcustom gnus-button-ctan-handler 'browse-url
5720 "Function to use for displaying CTAN links.
5721 The function must take one argument, the string naming the URL."
5722 :type '(choice (function-item :tag "Browse Url" browse-url)
5723 (function :tag "Other"))
5724 :group 'gnus-article-buttons)
5726 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5727 "Bogus strings removed from CTAN URLs."
5728 :group 'gnus-article-buttons
5729 :type '(choice (const "^/?tex-archive/\\|/")
5730 (regexp :tag "Other")))
5732 (defcustom gnus-button-ctan-directory-regexp
5734 "\\("; Cannot use `\(?: ... \)' (compatibility with Emacs 20).
5735 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5736 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5737 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5739 "Regular expression for ctan directories.
5740 It should match all directories in the top level of `gnus-ctan-url'."
5741 :group 'gnus-article-buttons
5744 (defcustom gnus-button-mid-or-mail-regexp
5745 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
5746 gnus-button-valid-fqdn-regexp
5748 "Regular expression that matches a message ID or a mail address."
5749 :group 'gnus-article-buttons
5752 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5753 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5754 Strings like this can be either a message ID or a mail address. If it is one
5755 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5756 message ID or a mail address, respectively. If this variable is set to the
5757 symbol `ask', always query the user what do do. If it is a function, this
5758 function will be called with the string as it's only argument. The function
5759 must return `mid', `mail', `invalid' or `ask'."
5760 :group 'gnus-article-buttons
5761 :type '(choice (function-item :tag "Heuristic function"
5762 gnus-button-mid-or-mail-heuristic)
5767 (defcustom gnus-button-mid-or-mail-heuristic-alist
5768 '((-10.0 . ".+\\$.+@")
5771 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5772 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5773 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5774 (-1.0 . "^[^a-z]+@")
5776 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5777 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5778 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5779 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5782 (-1.0 . "^[0-9][0-9]")
5784 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5785 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5786 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5787 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5789 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5790 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5793 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5795 ;; compensation for TDMA dated mail addresses:
5796 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5798 (-20.0 . "\\.fsf@") ;; Gnus
5801 (-20.0 . "_-_") ;; Subject change in thread
5803 (-20.0 . "\\.ln@") ;; leafnode
5804 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5805 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5807 ;; (5.0 . "") ;; $local_part_len <= 7
5808 (10.0 . "^[^0-9]+@")
5809 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5810 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5813 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5815 (0.5 . "^[A-Z][a-z]")
5816 (0.5 . "^[A-Z][a-z][a-z]")
5817 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5818 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5819 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5821 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5822 address. The REGEXP is processed with `case-fold-search' set to nil."
5823 :group 'gnus-article-buttons
5824 :type '(repeat (cons (number :tag "Rate")
5825 (regexp :tag "Regexp"))))
5827 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5828 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5829 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5830 address, `ask' if unsure and `invalid' if the string is invalid."
5831 (let ((case-fold-search nil)
5832 (list gnus-button-mid-or-mail-heuristic-alist)
5833 (result 0) rate regexp lpartlen elem)
5835 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5836 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5837 ;; Certain special cases...
5840 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$" "\\|"
5841 "^[0-9]+\.[0-9]+\@compuserve")
5843 (gnus-message 8 "`%s' is a known mail address.")
5844 (setq result 'mail))
5845 (when (string-match "@.*@\\| " mid-or-mail)
5846 (gnus-message 8 "`%s' is invalid.")
5847 (setq result 'invalid))
5848 ;; Nothing more to do, if result is not a number here...
5849 (when (numberp result)
5851 (setq elem (car list)
5855 (when (string-match regexp mid-or-mail)
5856 (setq result (+ result rate))
5858 9 "`%s' matched `%s', rate `%s', result `%s'."
5859 mid-or-mail regexp rate result)))
5860 (when (<= lpartlen 7)
5861 (setq result (+ result 5.0))
5862 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
5863 mid-or-mail result))
5864 (when (>= lpartlen 12)
5865 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
5867 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
5868 ;; Long local part should contain realname if e-mail address,
5869 ;; too many digits: message-id.
5870 ;; $score -= 5.0 + 0.1 * $local_part_len;
5871 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
5872 (setq result (+ result rate))
5874 9 "Many digits in `%s', rate `%s', result `%s'."
5875 mid-or-mail rate result))
5876 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
5878 ;; Too few vowels [^aeiouy]{4,}.*\@
5879 (setq result (+ result -5.0))
5881 9 "Few vowels in `%s', rate `%s', result `%s'."
5882 mid-or-mail -5.0 result))
5884 (setq result (+ result 5.0))
5886 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
5887 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
5889 ;; Maybe we should make this a customizable alist: (condition . 'result)
5890 ((< result -10.0) 'mid)
5891 ((> result 10.0) 'mail)
5894 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5895 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
5896 (url-mid (concat "news" ":" mid-or-mail))
5897 (url-mailto (concat "mailto" ":" mid-or-mail)))
5898 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5899 (when (fboundp pref)
5901 ;; get rid of surrounding angles...
5903 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
5904 (if (or (eq 'mid guessed) (eq 'mail guessed))
5908 (save-window-excursion
5909 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5912 (cond ((eq pref 'mid)
5913 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
5914 (gnus-button-handle-news url-mid))
5916 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
5917 (gnus-url-mailto url-mailto))
5918 (t (gnus-message 3 "Invalid string.")))))
5920 (defun gnus-button-handle-custom (url)
5921 "Follow a Custom URL."
5922 (customize-apropos (gnus-url-unhex-string url)))
5924 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5926 ;; FIXME: Maybe we should merge some of the functions that do quite similar
5929 (defun gnus-button-handle-describe-function (url)
5930 "Call `describe-function' when pushing the corresponding URL button."
5933 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5935 (defun gnus-button-handle-describe-variable (url)
5936 "Call `describe-variable' when pushing the corresponding URL button."
5939 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5941 (defun gnus-button-handle-symbol (url)
5942 "Display help on variable or function.
5943 Calls `describe-variable' or `describe-function'."
5944 (let ((sym (intern url)))
5946 ((fboundp sym) (describe-function sym))
5947 ((boundp sym) (describe-variable sym))
5948 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
5950 (defun gnus-button-handle-describe-key (url)
5951 "Call `describe-key' when pushing the corresponding URL button."
5953 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5954 (keys (ignore-errors (eval `(kbd ,key-string)))))
5957 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5959 (defun gnus-button-handle-apropos (url)
5960 "Call `apropos' when pushing the corresponding URL button."
5961 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5963 (defun gnus-button-handle-apropos-command (url)
5964 "Call `apropos' when pushing the corresponding URL button."
5966 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5968 (defun gnus-button-handle-apropos-variable (url)
5969 "Call `apropos' when pushing the corresponding URL button."
5971 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5972 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5974 (defun gnus-button-handle-apropos-documentation (url)
5975 "Call `apropos' when pushing the corresponding URL button."
5977 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
5978 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5980 (defun gnus-button-handle-library (url)
5981 "Call `locate-library' when pushing the corresponding URL button."
5982 (gnus-message 9 "url=`%s'" url)
5983 (let* ((lib (locate-library url))
5984 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
5986 (gnus-message 1 "Cannot locale library `%s'." url)
5987 (find-file-read-only file))))
5989 (defun gnus-button-handle-ctan (url)
5990 "Call `browse-url' when pushing a CTAN URL button."
5992 gnus-button-ctan-handler
5995 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
5997 (defcustom gnus-button-tex-level 5
5998 "*Integer that says how many TeX-related buttons Gnus will show.
5999 The higher the number, the more buttons will appear and the more false
6000 positives are possible. Note that you can set this variable local to
6001 specific groups. Setting it higher in TeX groups is probably a good idea.
6002 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6003 how to set variables in specific groups."
6004 :group 'gnus-article-buttons
6005 :link '(custom-manual "(gnus)Group Parameters")
6008 (defcustom gnus-button-man-level 5
6009 "*Integer that says how many man-related buttons Gnus will show.
6010 The higher the number, the more buttons will appear and the more false
6011 positives are possible. Note that you can set this variable local to
6012 specific groups. Setting it higher in Unix groups is probably a good idea.
6013 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6014 how to set variables in specific groups."
6015 :group 'gnus-article-buttons
6016 :link '(custom-manual "(gnus)Group Parameters")
6019 (defcustom gnus-button-emacs-level 5
6020 "*Integer that says how many emacs-related buttons Gnus will show.
6021 The higher the number, the more buttons will appear and the more false
6022 positives are possible. Note that you can set this variable local to
6023 specific groups. Setting it higher in Emacs or Gnus related groups is
6024 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6025 `gnus-parameters' on how to set variables in specific groups."
6026 :group 'gnus-article-buttons
6027 :link '(custom-manual "(gnus)Group Parameters")
6030 (defcustom gnus-button-message-level 5
6031 "*Integer that says how many buttons for news or mail messages will appear.
6032 The higher the number, the more buttons will appear and the more false
6033 positives are possible."
6034 ;; mail addresses, MIDs, URLs for news, ...
6035 :group 'gnus-article-buttons
6038 (defcustom gnus-button-browse-level 5
6039 "*Integer that says how many buttons for browsing will appear.
6040 The higher the number, the more buttons will appear and the more false
6041 positives are possible."
6042 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6043 :group 'gnus-article-buttons
6046 (defcustom gnus-button-alist
6047 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6048 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6049 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6050 gnus-button-handle-news 2)
6051 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6052 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6053 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6054 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6055 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6056 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6057 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6058 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6059 ("mailto:\\([-a-z.@_+0-9%=?&]+\\)"
6060 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6061 ("\\bmailto:\\([^ \n\t]+\\)"
6062 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6064 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6065 gnus-button-ctan-directory-regexp
6066 "[^][>)!;:,'\n\t ]+\\)")
6067 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6068 ((concat "\\btex-archive/\\("
6069 gnus-button-ctan-directory-regexp
6070 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6071 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6074 gnus-button-ctan-directory-regexp
6075 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6076 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6077 ;; This is info (home-grown style) <info://foo/bar+baz>
6078 ("\\binfo://\\([^'\">\n\t ]+\\)"
6079 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6080 ;; Info GNOME style <info:foo#bar_baz>
6081 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6082 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6083 ;; Info KDE style <info:(foo)bar baz>
6084 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6085 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6086 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6087 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6088 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6089 ;; Info links like `C-h i d m CC Mode RET'
6090 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6092 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6093 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6094 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6095 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6096 ;; Emacs help commands
6097 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6098 ;; regexp doesn't match arguments containing ` '.
6099 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6100 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6101 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6102 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6103 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6104 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6105 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6106 ;; The following entries may lead to many false positives so don't enable
6107 ;; them by default (use a high button level):
6108 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6109 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6110 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6111 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6112 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6113 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6114 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6115 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6116 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6117 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6118 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6119 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6120 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6121 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6122 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6123 ;; Unlike the other regexps we really have to require quoting
6124 ;; here to determine where it ends.
6125 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6126 ;; This is how URLs _should_ be embedded in text (RFC 1738)...
6127 ("<URL: *\\([^<>]*\\)>"
6128 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6130 (gnus-button-url-regexp
6131 0 (>= gnus-button-browse-level 0) browse-url 0)
6133 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6134 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6135 gnus-button-handle-man 1)
6136 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6137 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6138 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6139 gnus-button-handle-man 1)
6140 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6141 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6142 ("\\b\\([a-z][-+_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6143 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6144 ;; MID or mail: To avoid too many false positives we don't try to catch
6145 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6146 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6147 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6148 ;; so that non-ambiguous entries (see above) match first.
6149 (gnus-button-mid-or-mail-regexp
6150 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6151 "*Alist of regexps matching buttons in article bodies.
6153 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6154 REGEXP: is the string (case insensitive) matching text around the button (can
6155 also be Lisp expression evaluating to a string),
6156 BUTTON: is the number of the regexp grouping actually matching the button,
6157 FORM: is a Lisp expression which must eval to true for the button to
6159 CALLBACK: is the function to call when the user push this button, and each
6160 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6162 CALLBACK can also be a variable, in that case the value of that
6163 variable it the real callback function."
6164 :group 'gnus-article-buttons
6165 :type '(repeat (list (choice regexp variable sexp)
6166 (integer :tag "Button")
6168 (function :tag "Callback")
6171 (integer :tag "Regexp group")))))
6173 (defcustom gnus-header-button-alist
6174 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6175 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6176 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6177 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6178 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6179 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6180 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6181 0 (>= gnus-button-browse-level 0) browse-url 0)
6182 ("^Subject:" gnus-button-url-regexp
6183 0 (>= gnus-button-browse-level 0) browse-url 0)
6184 ("^[^:]+:" gnus-button-url-regexp
6185 0 (>= gnus-button-browse-level 0) browse-url 0)
6186 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&]+\\)"
6187 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6188 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6189 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6190 "*Alist of headers and regexps to match buttons in article heads.
6192 This alist is very similar to `gnus-button-alist', except that each
6193 alist has an additional HEADER element first in each entry:
6195 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6197 HEADER is a regexp to match a header. For a fuller explanation, see
6198 `gnus-button-alist'."
6199 :group 'gnus-article-buttons
6200 :group 'gnus-article-headers
6201 :type '(repeat (list (regexp :tag "Header")
6202 (choice regexp variable)
6203 (integer :tag "Button")
6205 (function :tag "Callback")
6208 (integer :tag "Regexp group")))))
6210 (defvar gnus-button-regexp nil)
6211 (defvar gnus-button-marker-list nil)
6212 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6214 (defvar gnus-button-last nil)
6215 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6219 (defun gnus-article-push-button (event)
6220 "Check text under the mouse pointer for a callback function.
6221 If the text under the mouse pointer has a `gnus-callback' property,
6222 call it with the value of the `gnus-data' text property."
6224 (set-buffer (window-buffer (posn-window (event-start event))))
6225 (let* ((pos (posn-point (event-start event)))
6226 (data (get-text-property pos 'gnus-data))
6227 (fun (get-text-property pos 'gnus-callback)))
6230 (funcall fun data))))
6232 (defun gnus-article-press-button ()
6233 "Check text at point for a callback function.
6234 If the text at point has a `gnus-callback' property,
6235 call it with the value of the `gnus-data' text property."
6237 (let ((data (get-text-property (point) 'gnus-data))
6238 (fun (get-text-property (point) 'gnus-callback)))
6240 (funcall fun data))))
6242 (defun gnus-article-highlight (&optional force)
6243 "Highlight current article.
6244 This function calls `gnus-article-highlight-headers',
6245 `gnus-article-highlight-citation',
6246 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6247 do the highlighting. See the documentation for those functions."
6248 (interactive (list 'force))
6249 (gnus-article-highlight-headers)
6250 (gnus-article-highlight-citation force)
6251 (gnus-article-highlight-signature)
6252 (gnus-article-add-buttons force)
6253 (gnus-article-add-buttons-to-head))
6255 (defun gnus-article-highlight-some (&optional force)
6256 "Highlight current article.
6257 This function calls `gnus-article-highlight-headers',
6258 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6259 do the highlighting. See the documentation for those functions."
6260 (interactive (list 'force))
6261 (gnus-article-highlight-headers)
6262 (gnus-article-highlight-signature)
6263 (gnus-article-add-buttons))
6265 (defun gnus-article-highlight-headers ()
6266 "Highlight article headers as specified by `gnus-header-face-alist'."
6269 (set-buffer gnus-article-buffer)
6271 (let ((alist gnus-header-face-alist)
6272 (buffer-read-only nil)
6273 (case-fold-search t)
6274 (inhibit-point-motion-hooks t)
6275 entry regexp header-face field-face from hpoints fpoints)
6276 (article-narrow-to-head)
6277 (while (setq entry (pop alist))
6278 (goto-char (point-min))
6279 (setq regexp (concat "^\\("
6280 (if (string-equal "" (nth 0 entry))
6284 header-face (nth 1 entry)
6285 field-face (nth 2 entry))
6286 (while (and (re-search-forward regexp nil t)
6290 (unless (search-forward ":" nil t)
6292 (when (and header-face
6293 (not (memq (point) hpoints)))
6294 (push (point) hpoints)
6295 (gnus-put-text-property from (point) 'face header-face))
6296 (when (and field-face
6297 (not (memq (setq from (point)) fpoints)))
6299 (if (re-search-forward "^[^ \t]" nil t)
6301 (goto-char (point-max)))
6302 (gnus-put-text-property from (point) 'face field-face))))))))
6304 (defun gnus-article-highlight-signature ()
6305 "Highlight the signature in an article.
6306 It does this by highlighting everything after
6307 `gnus-signature-separator' using `gnus-signature-face'."
6310 (set-buffer gnus-article-buffer)
6311 (let ((buffer-read-only nil)
6312 (inhibit-point-motion-hooks t))
6314 (when (and gnus-signature-face
6315 (gnus-article-narrow-to-signature))
6316 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6317 'face gnus-signature-face)
6319 (gnus-article-search-signature)
6320 (let ((start (match-beginning 0))
6321 (end (set-marker (make-marker) (1+ (match-end 0)))))
6322 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6325 (defun gnus-button-in-region-p (b e prop)
6326 "Say whether PROP exists in the region."
6327 (text-property-not-all b e prop nil))
6329 (defun gnus-article-add-buttons (&optional force)
6330 "Find external references in the article and make buttons of them.
6331 \"External references\" are things like Message-IDs and URLs, as
6332 specified by `gnus-button-alist'."
6333 (interactive (list 'force))
6335 (set-buffer gnus-article-buffer)
6336 (let ((buffer-read-only nil)
6337 (inhibit-point-motion-hooks t)
6338 (case-fold-search t)
6339 (alist gnus-button-alist)
6341 ;; Remove all old markers.
6342 (let (marker entry new-list)
6343 (while (setq marker (pop gnus-button-marker-list))
6344 (if (or (< marker (point-min)) (>= marker (point-max)))
6345 (push marker new-list)
6347 (when (setq entry (gnus-button-entry))
6348 (put-text-property (match-beginning (nth 1 entry))
6349 (match-end (nth 1 entry))
6350 'gnus-callback nil))
6351 (set-marker marker nil)))
6352 (setq gnus-button-marker-list new-list))
6353 ;; We skip the headers.
6356 (while (setq entry (pop alist))
6357 (setq regexp (eval (car entry)))
6359 (while (re-search-forward regexp nil t)
6360 (let* ((start (and entry (match-beginning (nth 1 entry))))
6361 (end (and entry (match-end (nth 1 entry))))
6362 (from (match-beginning 0)))
6363 (when (and (or (eq t (nth 2 entry))
6364 (eval (nth 2 entry)))
6365 (not (gnus-button-in-region-p
6366 start end 'gnus-callback)))
6367 ;; That optional form returned non-nil, so we add the
6369 (gnus-article-add-button
6370 start end 'gnus-button-push
6371 (car (push (set-marker (make-marker) from)
6372 gnus-button-marker-list))))))))))
6374 ;; Add buttons to the head of an article.
6375 (defun gnus-article-add-buttons-to-head ()
6376 "Add buttons to the head of the article."
6379 (set-buffer gnus-article-buffer)
6381 (let ((buffer-read-only nil)
6382 (inhibit-point-motion-hooks t)
6383 (case-fold-search t)
6384 (alist gnus-header-button-alist)
6386 (article-narrow-to-head)
6388 ;; Each alist entry.
6389 (setq entry (car alist)
6391 (goto-char (point-min))
6392 (while (re-search-forward (car entry) nil t)
6393 ;; Each header matching the entry.
6394 (setq beg (match-beginning 0))
6395 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6396 (match-beginning 0))
6399 (while (re-search-forward (eval (nth 1 entry)) end t)
6400 ;; Each match within a header.
6401 (let* ((entry (cdr entry))
6402 (start (match-beginning (nth 1 entry)))
6403 (end (match-end (nth 1 entry)))
6404 (form (nth 2 entry)))
6405 (goto-char (match-end 0))
6407 (gnus-article-add-button
6408 start end (nth 3 entry)
6409 (buffer-substring (match-beginning (nth 4 entry))
6410 (match-end (nth 4 entry)))))))
6411 (goto-char end)))))))
6413 ;;; External functions:
6415 (defun gnus-article-add-button (from to fun &optional data)
6416 "Create a button between FROM and TO with callback FUN and data DATA."
6417 (when gnus-article-button-face
6418 (gnus-overlay-put (gnus-make-overlay from to)
6419 'face gnus-article-button-face))
6420 (gnus-add-text-properties
6422 (nconc (and gnus-article-mouse-face
6423 (list gnus-mouse-face-prop gnus-article-mouse-face))
6424 (list 'gnus-callback fun)
6425 (and data (list 'gnus-data data))))
6426 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6427 :button-keymap gnus-widget-button-keymap))
6429 ;;; Internal functions:
6431 (defun gnus-article-set-globals ()
6433 (set-buffer gnus-summary-buffer)
6434 (gnus-set-global-variables)))
6436 (defun gnus-signature-toggle (end)
6438 (set-buffer gnus-article-buffer)
6439 (let ((buffer-read-only nil)
6440 (inhibit-point-motion-hooks t))
6441 (if (text-property-any end (point-max) 'article-type 'signature)
6443 (gnus-delete-wash-type 'signature)
6444 (gnus-remove-text-properties-when
6445 'article-type 'signature end (point-max)
6446 (cons 'article-type (cons 'signature
6447 gnus-hidden-properties))))
6448 (gnus-add-wash-type 'signature)
6449 (gnus-add-text-properties-when
6450 'article-type nil end (point-max)
6451 (cons 'article-type (cons 'signature
6452 gnus-hidden-properties)))))
6453 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6454 (gnus-set-mode-line 'article))))
6456 (defun gnus-button-entry ()
6457 ;; Return the first entry in `gnus-button-alist' matching this place.
6458 (let ((alist gnus-button-alist)
6461 (setq entry (pop alist))
6462 (if (looking-at (eval (car entry)))
6467 (defun gnus-button-push (marker)
6468 ;; Push button starting at MARKER.
6471 (let* ((entry (gnus-button-entry))
6472 (inhibit-point-motion-hooks t)
6474 (args (mapcar (lambda (group)
6475 (let ((string (match-string group)))
6476 (gnus-set-text-properties
6477 0 (length string) nil string)
6484 (fboundp (symbol-value fun)))
6485 (apply (symbol-value fun) args))
6487 (gnus-message 1 "You must define `%S' to use this button"
6488 (cons fun args)))))))
6490 (defun gnus-parse-news-url (url)
6491 (let (scheme server group message-id articles)
6494 (goto-char (point-min))
6495 (when (looking-at "\\([A-Za-z]+\\):")
6496 (setq scheme (match-string 1))
6497 (goto-char (match-end 0)))
6498 (when (looking-at "//\\([^/]+\\)/")
6499 (setq server (match-string 1))
6500 (goto-char (match-end 0)))
6503 ((looking-at "\\(.*@.*\\)")
6504 (setq message-id (match-string 1)))
6505 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6506 (setq group (match-string 1)
6507 articles (split-string (match-string 2) "-")))
6508 ((looking-at "\\([^/]+\\)/?")
6509 (setq group (match-string 1)))
6511 (error "Unknown news URL syntax"))))
6512 (list scheme server group message-id articles)))
6514 (defun gnus-button-handle-news (url)
6516 (destructuring-bind (scheme server group message-id articles)
6517 (gnus-parse-news-url url)
6521 (set-buffer gnus-summary-buffer)
6523 (let ((gnus-refer-article-method (list (list 'nntp server))))
6524 (gnus-summary-refer-article message-id))
6525 (gnus-summary-refer-article message-id))))
6527 (gnus-button-fetch-group url)))))
6529 (defun gnus-button-handle-man (url)
6531 (funcall gnus-button-man-handler url))
6533 (defun gnus-button-handle-info-url (url)
6534 "Fetch an info URL."
6535 (setq url (mm-subst-char-in-string ?+ ?\ url))
6537 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6538 (gnus-info-find-node
6539 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6541 ")" (gnus-url-unhex-string (match-string 2 url)))))
6542 ((string-match "([^)\"]+)[^\"]+" url)
6544 (gnus-replace-in-string
6545 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6546 (gnus-info-find-node url))
6547 (t (error "Can't parse %s" url))))
6549 (defun gnus-button-handle-info-url-gnome (url)
6550 "Fetch GNOME style info URL."
6551 (setq url (mm-subst-char-in-string ?_ ?\ url))
6552 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6553 (gnus-info-find-node
6555 (gnus-url-unhex-string
6556 (match-string 1 url))
6558 (or (gnus-url-unhex-string
6559 (match-string 2 url))
6561 (error "Can't parse %s" url)))
6563 (defun gnus-button-handle-info-url-kde (url)
6564 "Fetch KDE style info URL."
6565 (gnus-info-find-node (gnus-url-unhex-string url)))
6567 (defun gnus-button-handle-info-keystrokes (url)
6568 "Call `info' when pushing the corresponding URL button."
6569 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6574 (defun gnus-button-message-id (message-id)
6577 (set-buffer gnus-summary-buffer)
6578 (gnus-summary-refer-article message-id)))
6580 (defun gnus-button-fetch-group (address)
6581 "Fetch GROUP specified by ADDRESS."
6582 (if (not (string-match "[:/]" address))
6583 ;; This is just a simple group url.
6584 (gnus-group-read-ephemeral-group address gnus-select-method)
6587 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6589 (error "Can't parse %s" address)
6590 (gnus-group-read-ephemeral-group
6591 (match-string 4 address)
6592 `(nntp ,(match-string 1 address)
6593 (nntp-address ,(match-string 1 address))
6594 (nntp-port-number ,(if (match-end 3)
6595 (match-string 3 address)
6598 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6600 (defun gnus-url-parse-query-string (query &optional downcase)
6601 (let (retval pairs cur key val)
6602 (setq pairs (split-string query "&"))
6604 (setq cur (car pairs)
6606 (if (not (string-match "=" cur))
6608 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6609 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6611 (setq key (downcase key)))
6612 (setq cur (assoc key retval))
6614 (setcdr cur (cons val (cdr cur)))
6615 (setq retval (cons (list key val) retval)))))
6618 (defun gnus-url-mailto (url)
6619 ;; Send mail to someone
6620 (when (string-match "mailto:/*\\(.*\\)" url)
6621 (setq url (substring url (match-beginning 1) nil)))
6622 (let (to args subject func)
6623 (setq args (gnus-url-parse-query-string
6624 (if (string-match "^\\?" url)
6626 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6627 (concat "to=" (match-string 1 url) "&"
6628 (match-string 2 url))
6629 (concat "to=" url)))
6631 subject (cdr-safe (assoc "subject" args)))
6634 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6637 (message-position-on-field (caar args)))
6638 (insert (gnus-replace-in-string
6639 (mapconcat 'identity (reverse (cdar args)) ", ")
6641 (setq args (cdr args)))
6644 (message-goto-subject))))
6646 (defun gnus-button-embedded-url (address)
6647 "Activate ADDRESS with `browse-url'."
6648 (browse-url (gnus-strip-whitespace address)))
6650 ;;; Next/prev buttons in the article buffer.
6652 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6653 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6655 (defvar gnus-prev-page-map
6656 (let ((map (make-sparse-keymap)))
6657 (unless (>= emacs-major-version 21)
6658 ;; XEmacs doesn't care.
6659 (set-keymap-parent map gnus-article-mode-map))
6660 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6661 (define-key map "\r" 'gnus-button-prev-page)
6664 (defun gnus-insert-prev-page-button ()
6666 (buffer-read-only nil))
6668 gnus-prev-page-line-format nil
6669 `(,@(gnus-local-map-property gnus-prev-page-map)
6671 gnus-callback gnus-article-button-prev-page
6672 article-type annotation))
6673 (widget-convert-button
6675 ;; Exclude a newline.
6678 :action 'gnus-button-prev-page
6679 :button-keymap gnus-prev-page-map)))
6681 (defvar gnus-prev-page-map
6682 (let ((map (make-sparse-keymap)))
6683 (unless (>= emacs-major-version 21)
6684 ;; XEmacs doesn't care.
6685 (set-keymap-parent map gnus-article-mode-map))
6686 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6687 (define-key map "\r" 'gnus-button-prev-page)
6690 (defvar gnus-next-page-map
6691 (let ((map (make-sparse-keymap)))
6692 (unless (>= emacs-major-version 21)
6693 ;; XEmacs doesn't care.
6694 (set-keymap-parent map gnus-article-mode-map))
6695 (define-key map gnus-mouse-2 'gnus-button-next-page)
6696 (define-key map "\r" 'gnus-button-next-page)
6699 (defun gnus-button-next-page (&optional args more-args)
6700 "Go to the next page."
6702 (let ((win (selected-window)))
6703 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6704 (gnus-article-next-page)
6705 (select-window win)))
6707 (defun gnus-button-prev-page (&optional args more-args)
6708 "Go to the prev page."
6710 (let ((win (selected-window)))
6711 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6712 (gnus-article-prev-page)
6713 (select-window win)))
6715 (defun gnus-insert-next-page-button ()
6717 (buffer-read-only nil))
6718 (gnus-eval-format gnus-next-page-line-format nil
6719 `(,@(gnus-local-map-property gnus-next-page-map)
6721 gnus-callback gnus-article-button-next-page
6722 article-type annotation))
6723 (widget-convert-button
6725 ;; Exclude a newline.
6728 :action 'gnus-button-next-page
6729 :button-keymap gnus-next-page-map)))
6731 (defun gnus-article-button-next-page (arg)
6732 "Go to the next page."
6734 (let ((win (selected-window)))
6735 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6736 (gnus-article-next-page)
6737 (select-window win)))
6739 (defun gnus-article-button-prev-page (arg)
6740 "Go to the prev page."
6742 (let ((win (selected-window)))
6743 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6744 (gnus-article-prev-page)
6745 (select-window win)))
6747 (defvar gnus-decode-header-methods
6748 '(mail-decode-encoded-word-region)
6749 "List of methods used to decode headers.
6751 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6752 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6753 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6754 whose names match REGEXP.
6757 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6758 mail-decode-encoded-word-region
6759 (\"chinese\" . rfc1843-decode-region))
6762 (defvar gnus-decode-header-methods-cache nil)
6764 (defun gnus-multi-decode-header (start end)
6765 "Apply the functions from `gnus-encoded-word-methods' that match."
6766 (unless (and gnus-decode-header-methods-cache
6767 (eq gnus-newsgroup-name
6768 (car gnus-decode-header-methods-cache)))
6769 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6772 (nconc gnus-decode-header-methods-cache (list x))
6773 (if (and gnus-newsgroup-name
6774 (string-match (car x) gnus-newsgroup-name))
6775 (nconc gnus-decode-header-methods-cache
6777 gnus-decode-header-methods))
6778 (let ((xlist gnus-decode-header-methods-cache))
6781 (narrow-to-region start end)
6783 (funcall (pop xlist) (point-min) (point-max))))))
6786 ;;; Treatment top-level handling.
6789 (defun gnus-treat-article (condition &optional part-number total-parts type)
6790 (let ((length (- (point-max) (point-min)))
6791 (alist gnus-treatment-function-alist)
6792 (article-goto-body-goes-to-point-min-p t)
6796 (let ((list gnus-article-treat-types))
6798 (when (string-match (pop list) type)
6799 (throw 'found t)))))))
6800 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6802 (gnus-run-hooks 'gnus-part-display-hook)
6803 (dolist (elem alist)
6806 (when (gnus-buffer-live-p gnus-summary-buffer)
6807 (set-buffer gnus-summary-buffer))
6808 (symbol-value (car elem))))
6809 (when (and (or (consp val)
6811 (gnus-treat-predicate val)
6812 (or (not (get (car elem) 'highlight))
6815 (funcall (cadr elem)))))))
6817 ;; Dynamic variables.
6819 (defvar part-number)
6820 (defvar total-parts)
6825 (defun gnus-treat-predicate (val)
6832 (stringp (car val)))
6833 (apply 'gnus-or (mapcar `(lambda (s)
6834 (string-match s ,(or gnus-newsgroup-name "")))
6837 (let ((pred (pop val)))
6840 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6842 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6844 (not (gnus-treat-predicate (car val))))
6846 (equal (car val) type))
6848 (error "%S is not a valid predicate" pred)))))
6854 (eq part-number total-parts))
6858 (error "%S is not a valid value" val))))
6860 (defun gnus-article-encrypt-body (protocol &optional n)
6861 "Encrypt the article body."
6864 (or gnus-article-encrypt-protocol
6865 (completing-read "Encrypt protocol: "
6866 gnus-article-encrypt-protocol-alist
6868 current-prefix-arg))
6869 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6871 (error (format "Can't find the encrypt protocol %s" protocol)))
6872 (if (member gnus-newsgroup-name '("nndraft:delayed"
6875 (error "Can't encrypt the article in group %s"
6876 gnus-newsgroup-name))
6877 (gnus-summary-iterate n
6879 (set-buffer gnus-summary-buffer)
6880 (let ((mail-parse-charset gnus-newsgroup-charset)
6881 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6882 (summary-buffer gnus-summary-buffer)
6884 (gnus-set-global-variables)
6885 (when (gnus-group-read-only-p)
6886 (error "The current newsgroup does not support article encrypt"))
6887 (gnus-summary-show-article t)
6889 (or (mail-header-references gnus-current-headers) ""))
6890 (set-buffer gnus-article-buffer)
6891 (let* ((buffer-read-only nil)
6893 (mapcar (lambda (field)
6894 (and (save-restriction
6895 (message-narrow-to-head)
6896 (goto-char (point-min))
6897 (search-forward field nil t))
6899 (message-narrow-to-field)
6901 (delete-region (point-min) (point-max))
6903 '("Content-Type:" "Content-Transfer-Encoding:"
6904 "Content-Disposition:"))))
6905 (message-narrow-to-head)
6906 (message-remove-header "MIME-Version")
6907 (goto-char (point-max))
6908 (setq point (point))
6909 (insert (apply 'concat headers))
6911 (narrow-to-region point (point-max))
6912 (let ((message-options message-options))
6913 (message-options-set 'message-sender user-mail-address)
6914 (message-options-set 'message-recipients user-mail-address)
6915 (message-options-set 'message-sign-encrypt 'not)
6917 (goto-char (point-min))
6918 (insert "MIME-Version: 1.0\n")
6920 (gnus-summary-edit-article-done
6921 references nil summary-buffer t))
6922 (when gnus-keep-backlog
6923 (gnus-backlog-remove-article
6924 (car gnus-article-current) (cdr gnus-article-current)))
6926 (when (get-buffer gnus-original-article-buffer)
6927 (set-buffer gnus-original-article-buffer)
6928 (setq gnus-original-article nil)))
6929 (when gnus-use-cache
6930 (gnus-cache-update-article
6931 (car gnus-article-current) (cdr gnus-article-current))))))))
6933 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6934 "The following specs can be used:
6935 %t The security MIME type
6938 %D Details if button is pressed")
6940 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6941 "The following specs can be used:
6942 %t The security MIME type
6945 %D Details if button is pressed")
6947 (defvar gnus-mime-security-button-line-format-alist
6948 '((?t gnus-tmp-type ?s)
6949 (?i gnus-tmp-info ?s)
6950 (?d gnus-tmp-details ?s)
6951 (?D gnus-tmp-pressed-details ?s)))
6953 (defvar gnus-mime-security-button-map
6954 (let ((map (make-sparse-keymap)))
6955 (unless (>= (string-to-number emacs-version) 21)
6956 (set-keymap-parent map gnus-article-mode-map))
6957 (define-key map gnus-mouse-2 'gnus-article-push-button)
6958 (define-key map "\r" 'gnus-article-press-button)
6961 (defvar gnus-mime-security-details-buffer nil)
6963 (defvar gnus-mime-security-button-pressed nil)
6965 (defvar gnus-mime-security-show-details-inline t
6966 "If non-nil, show details in the article buffer.")
6968 (defun gnus-mime-security-verify-or-decrypt (handle)
6969 (mm-remove-parts (cdr handle))
6970 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6971 point buffer-read-only)
6973 (goto-char (car region)))
6975 (narrow-to-region (point) (point))
6976 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6977 (let* ((mm-verify-option 'known)
6978 (mm-decrypt-option 'known)
6979 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6980 (unless (eq nparts (cdr handle))
6981 (mm-destroy-parts (cdr handle))
6982 (setcdr handle nparts))))
6983 (setq point (point))
6984 (gnus-mime-display-security handle)
6985 (goto-char (point-max)))
6987 (delete-region (point) (cdr region))
6988 (set-marker (car region) nil)
6989 (set-marker (cdr region) nil))
6992 (defun gnus-mime-security-show-details (handle)
6993 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6995 (gnus-message 5 "No details.")
6996 (if gnus-mime-security-show-details-inline
6997 (let ((gnus-mime-security-button-pressed
6998 (not (get-text-property (point) 'gnus-mime-details)))
6999 (gnus-mime-security-button-line-format
7000 (get-text-property (point) 'gnus-line-format))
7003 (while (eq (get-text-property (point) 'gnus-line-format)
7004 gnus-mime-security-button-line-format)
7008 (narrow-to-region (point) (point))
7009 (gnus-insert-mime-security-button handle))
7010 (delete-region (point)
7011 (or (text-property-not-all
7014 gnus-mime-security-button-line-format)
7017 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7018 (with-current-buffer gnus-mime-security-details-buffer
7021 (setq gnus-mime-security-details-buffer
7022 (gnus-get-buffer-create "*MIME Security Details*")))
7023 (with-current-buffer gnus-mime-security-details-buffer
7025 (goto-char (point-min)))
7026 (pop-to-buffer gnus-mime-security-details-buffer)))))
7028 (defun gnus-mime-security-press-button (handle)
7030 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7031 (gnus-mime-security-show-details handle)
7032 (gnus-mime-security-verify-or-decrypt handle))))
7034 (defun gnus-insert-mime-security-button (handle &optional displayed)
7035 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7038 (or (nth 2 (assoc protocol mm-verify-function-alist))
7039 (nth 2 (assoc protocol mm-decrypt-function-alist))
7041 (if (equal (car handle) "multipart/signed")
7042 " Signed" " Encrypted")
7045 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7048 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7049 gnus-tmp-pressed-details
7051 (setq gnus-tmp-details
7052 (if gnus-tmp-details
7053 (concat "\n" gnus-tmp-details)
7055 (setq gnus-tmp-pressed-details
7056 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7061 gnus-mime-security-button-line-format
7062 gnus-mime-security-button-line-format-alist
7063 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7064 gnus-callback gnus-mime-security-press-button
7065 gnus-line-format ,gnus-mime-security-button-line-format
7066 gnus-mime-details ,gnus-mime-security-button-pressed
7067 article-type annotation
7070 ;; Exclude a newline.
7073 (widget-convert-button
7076 :action 'gnus-widget-press-button
7077 :button-keymap gnus-mime-security-button-map
7079 (lambda (widget/window &optional overlay pos)
7080 ;; Needed to properly clear the message due to a bug in
7081 ;; wid-edit (XEmacs only).
7082 (when (boundp 'help-echo-owns-message)
7083 (setq help-echo-owns-message t))
7086 (aref gnus-mouse-2 0))))))
7088 (defun gnus-mime-display-security (handle)
7090 (narrow-to-region (point) (point))
7091 (unless (gnus-unbuttonized-mime-type-p (car handle))
7092 (gnus-insert-mime-security-button handle))
7093 (gnus-mime-display-mixed (cdr handle))
7096 (unless (gnus-unbuttonized-mime-type-p (car handle))
7097 (let ((gnus-mime-security-button-line-format
7098 gnus-mime-security-button-end-line-format))
7099 (gnus-insert-mime-security-button handle)))
7100 (mm-set-handle-multipart-parameter
7102 (cons (set-marker (make-marker) (point-min))
7103 (set-marker (make-marker) (point-max))))))
7109 (run-hooks 'gnus-art-load-hook)
7111 ;;; gnus-art.el ends here