1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
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))
34 ;; Avoid the "Recursive load suspected" error in Emacs 21.1.
36 (let ((recursive-load-depth-limit 100))
49 (autoload 'gnus-msg-mail "gnus-msg" nil t)
50 (autoload 'gnus-button-mailto "gnus-msg")
51 (autoload 'gnus-button-reply "gnus-msg" nil t)
52 (autoload 'parse-time-string "parse-time" nil nil)
53 (autoload 'ansi-color-apply-on-region "ansi-color")
55 (defgroup gnus-article nil
57 :link '(custom-manual "(gnus)Article Buffer")
60 (defgroup gnus-article-treat nil
61 "Treating article parts."
62 :link '(custom-manual "(gnus)Article Hiding")
65 (defgroup gnus-article-hiding nil
66 "Hiding article parts."
67 :link '(custom-manual "(gnus)Article Hiding")
70 (defgroup gnus-article-highlight nil
71 "Article highlighting."
72 :link '(custom-manual "(gnus)Article Highlighting")
76 (defgroup gnus-article-signature nil
78 :link '(custom-manual "(gnus)Article Signature")
81 (defgroup gnus-article-headers nil
83 :link '(custom-manual "(gnus)Hiding Headers")
86 (defgroup gnus-article-washing nil
87 "Special commands on articles."
88 :link '(custom-manual "(gnus)Article Washing")
91 (defgroup gnus-article-emphasis nil
92 "Fontisizing articles."
93 :link '(custom-manual "(gnus)Article Fontisizing")
96 (defgroup gnus-article-saving nil
98 :link '(custom-manual "(gnus)Saving Articles")
101 (defgroup gnus-article-mime nil
102 "Worshiping the MIME wonder."
103 :link '(custom-manual "(gnus)Using MIME")
104 :group 'gnus-article)
106 (defgroup gnus-article-buttons nil
107 "Pushable buttons in the article buffer."
108 :link '(custom-manual "(gnus)Article Buttons")
109 :group 'gnus-article)
111 (defgroup gnus-article-various nil
112 "Other article options."
113 :link '(custom-manual "(gnus)Misc Article")
114 :group 'gnus-article)
116 (defcustom gnus-ignored-headers
119 (concat "^" header ":"))
120 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
121 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
122 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
123 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
124 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
125 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
126 "X-Attribution" "X-Originating-IP" "Delivered-To"
127 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
128 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
129 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
130 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
131 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
132 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
133 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
134 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
135 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
136 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
137 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
138 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
139 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
140 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
141 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
142 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
143 "List-[A-Za-z]+" "X-Listprocessor-Version"
144 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
145 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
146 "X-Received" "Content-length" "X-precedence"
147 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
148 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
149 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
150 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
151 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
152 "X-Content-length" "X-Posting-Agent" "Original-Received"
153 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
154 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
155 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
156 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
157 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
158 "*All headers that start with this regexp will be hidden.
159 This variable can also be a list of regexps of headers to be ignored.
160 If `gnus-visible-headers' is non-nil, this variable will be ignored."
161 :type '(choice :custom-show nil
164 :group 'gnus-article-hiding)
166 (defcustom gnus-visible-headers
167 "^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:"
168 "*All headers that do not match this regexp will be hidden.
169 This variable can also be a list of regexp of headers to remain visible.
170 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
171 :type '(repeat :value-to-internal (lambda (widget value)
172 (custom-split-regexp-maybe value))
173 :match (lambda (widget value)
175 (widget-editable-list-match widget value)))
177 :group 'gnus-article-hiding)
179 (defcustom gnus-sorted-header-list
180 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
181 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
182 "*This variable is a list of regular expressions.
183 If it is non-nil, headers that match the regular expressions will
184 be placed first in the article buffer in the sequence specified by
186 :type '(repeat regexp)
187 :group 'gnus-article-hiding)
189 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
190 "Headers that are only to be displayed if they have interesting data.
191 Possible values in this list are:
193 'empty Headers with no content.
194 'newsgroups Newsgroup identical to Gnus group.
195 'to-address To identical to To-address.
196 'to-list To identical to To-list.
197 'cc-list CC identical to To-list.
198 'followup-to Followup-to identical to Newsgroups.
199 'reply-to Reply-to identical to From.
200 'date Date less than four days old.
201 'long-to To and/or Cc longer than 1024 characters.
202 'many-to Multiple To and/or Cc."
203 :type '(set (const :tag "Headers with no content." empty)
204 (const :tag "Newsgroups identical to Gnus group." newsgroups)
205 (const :tag "To identical to To-address." to-address)
206 (const :tag "To identical to To-list." to-list)
207 (const :tag "CC identical to To-list." cc-list)
208 (const :tag "Followup-to identical to Newsgroups." followup-to)
209 (const :tag "Reply-to identical to From." reply-to)
210 (const :tag "Date less than four days old." date)
211 (const :tag "To and/or Cc longer than 1024 characters." long-to)
212 (const :tag "Multiple To and/or Cc headers." many-to))
213 :group 'gnus-article-hiding)
215 (defcustom gnus-article-skip-boring nil
216 "Skip over text that is not worth reading.
217 By default, if you set this t, then Gnus will display citations and
218 signatures, but will never scroll down to show you a page consisting
219 only of boring text. Boring text is controlled by
220 `gnus-article-boring-faces'."
223 :group 'gnus-article-hiding)
225 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
226 "Regexp matching signature separator.
227 This can also be a list of regexps. In that case, it will be checked
228 from head to tail looking for a separator. Searches will be done from
229 the end of the buffer."
230 :type '(repeat string)
231 :group 'gnus-article-signature)
233 (defcustom gnus-signature-limit nil
234 "Provide a limit to what is considered a signature.
235 If it is a number, no signature may not be longer (in characters) than
236 that number. If it is a floating point number, no signature may be
237 longer (in lines) than that number. If it is a function, the function
238 will be called without any parameters, and if it returns nil, there is
239 no signature in the buffer. If it is a string, it will be used as a
240 regexp. If it matches, the text in question is not a signature.
242 This can also be a list of the above values."
243 :type '(choice (integer :value 200)
245 (function :value fun)
246 (regexp :value ".*"))
247 :group 'gnus-article-signature)
249 (defcustom gnus-hidden-properties '(invisible t intangible t)
250 "Property list to use for hiding text."
252 :group 'gnus-article-hiding)
254 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
255 ;; frames in a session.
256 (defcustom gnus-article-x-face-command
257 (if (featurep 'xemacs)
258 (if (or (gnus-image-type-available-p 'xface)
259 (gnus-image-type-available-p 'pbm))
260 'gnus-display-x-face-in-from
261 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
262 (if (gnus-image-type-available-p 'pbm)
263 'gnus-display-x-face-in-from
264 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
266 "*String or function to be executed to display an X-Face header.
267 If it is a string, the command will be executed in a sub-shell
268 asynchronously. The compressed face will be piped to this command."
269 :type `(choice string
270 (function-item gnus-display-x-face-in-from)
274 :group 'gnus-article-washing)
276 (defcustom gnus-article-x-face-too-ugly nil
277 "Regexp matching posters whose face shouldn't be shown automatically."
278 :type '(choice regexp (const nil))
279 :group 'gnus-article-washing)
281 (defcustom gnus-article-banner-alist nil
282 "Banner alist for stripping.
284 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
286 :type '(repeat (cons symbol regexp))
287 :group 'gnus-article-washing)
289 (gnus-define-group-parameter
292 "Alist of regexps (to match group names) and banner."
293 :variable-group gnus-article-washing
295 '(choice :tag "Banner"
297 (const :tag "Remove signature" signature)
298 (symbol :tag "Item in `gnus-article-banner-alist'" none)
300 (const :tag "None" nil))
302 "If non-nil, specify how to remove `banners' from articles.
304 Symbol `signature' means to remove signatures delimited by
305 `gnus-signature-separator'. Any other symbol is used to look up a
306 regular expression to match the banner in `gnus-article-banner-alist'.
307 A string is used as a regular expression to match the banner
310 (defcustom gnus-article-address-banner-alist nil
311 "Alist of mail addresses and banners.
312 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
313 to match a mail address in the From: header, BANNER is one of a symbol
314 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
315 If ADDRESS matches author's mail address, it will remove things like
316 advertisements. For example:
318 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
322 (regexp :tag "Address")
323 (choice :tag "Banner" :value nil
324 (const :tag "Remove signature" signature)
325 (symbol :tag "Item in `gnus-article-banner-alist'" none)
327 (const :tag "None" nil))))
329 :group 'gnus-article-washing)
331 (defmacro gnus-emphasis-custom-with-format (&rest body)
333 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
334 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
337 (defun gnus-emphasis-custom-value-to-external (value)
338 (gnus-emphasis-custom-with-format
339 (if (consp (car value))
340 (list (format format (car (car value)) (cdr (car value)))
342 (if (nth 1 value) 2 3)
346 (defun gnus-emphasis-custom-value-to-internal (value)
347 (gnus-emphasis-custom-with-format
348 (let ((regexp (concat "\\`"
349 (format (regexp-quote format)
350 "\\([^()]+\\)" "\\([^()]+\\)")
353 (if (string-match regexp (setq pattern (car value)))
354 (list (cons (match-string 1 pattern) (match-string 2 pattern))
359 (defcustom gnus-emphasis-alist
361 '(("\\*" "\\*" bold nil 2)
364 ("_/" "/_" underline-italic)
365 ("_\\*" "\\*_" underline-bold)
366 ("\\*/" "/\\*" bold-italic)
367 ("_\\*/" "/\\*_" underline-bold-italic))))
369 (gnus-emphasis-custom-with-format
370 (mapcar (lambda (spec)
371 (list (format format (car spec) (cadr spec))
374 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
376 '(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
377 2 3 gnus-emphasis-underline))))
378 "*Alist that says how to fontify certain phrases.
379 Each item looks like this:
381 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
383 The first element is a regular expression to be matched. The second
384 is a number that says what regular expression grouping used to find
385 the entire emphasized word. The third is a number that says what
386 regexp grouping should be displayed and highlighted. The fourth
387 is the face used for highlighting."
391 :format "%[Customizing Style%]\n%v"
393 (group :tag "Default"
394 :value ("" 0 0 default)
397 (let ((value (widget-get
398 (cadr (widget-get (widget-get widget :parent)
401 (if (not (eq (nth 2 value) 'default))
405 (gnus-emphasis-custom-value-to-external value))))
406 (widget-group-value-create widget))
408 (integer :format "Match group: %v")
409 (integer :format "Emphasize group: %v")
412 :value (("_" . "_") nil default)
414 (regexp :format "Start regexp: %v")
415 (regexp :format "End regexp: %v"))
416 (boolean :format "Show start and end patterns: %[%v%]\n"
417 :on " On " :off " Off ")
419 :get (lambda (symbol)
420 (mapcar 'gnus-emphasis-custom-value-to-internal
421 (default-value symbol)))
422 :set (lambda (symbol value)
423 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
425 :group 'gnus-article-emphasis)
427 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
428 "A regexp to describe whitespace which should not be emphasized.
429 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
430 The former avoids underlining of leading and trailing whitespace,
431 and the latter avoids underlining any whitespace at all."
433 :group 'gnus-article-emphasis
436 (defface gnus-emphasis-bold '((t (:bold t)))
437 "Face used for displaying strong emphasized text (*word*)."
438 :group 'gnus-article-emphasis)
440 (defface gnus-emphasis-italic '((t (:italic t)))
441 "Face used for displaying italic emphasized text (/word/)."
442 :group 'gnus-article-emphasis)
444 (defface gnus-emphasis-underline '((t (:underline t)))
445 "Face used for displaying underlined emphasized text (_word_)."
446 :group 'gnus-article-emphasis)
448 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
449 "Face used for displaying underlined bold emphasized text (_*word*_)."
450 :group 'gnus-article-emphasis)
452 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
453 "Face used for displaying underlined italic emphasized text (_/word/_)."
454 :group 'gnus-article-emphasis)
456 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
457 "Face used for displaying bold italic emphasized text (/*word*/)."
458 :group 'gnus-article-emphasis)
460 (defface gnus-emphasis-underline-bold-italic
461 '((t (:bold t :italic t :underline t)))
462 "Face used for displaying underlined bold italic emphasized text.
463 Example: (_/*word*/_)."
464 :group 'gnus-article-emphasis)
466 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
467 '((t (:strikethru t)))
468 '((t (:strike-through t))))
469 "Face used for displaying strike-through text (-word-)."
470 :group 'gnus-article-emphasis)
472 (defface gnus-emphasis-highlight-words
473 '((t (:background "black" :foreground "yellow")))
474 "Face used for displaying highlighted words."
475 :group 'gnus-article-emphasis)
477 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
478 "Format for display of Date headers in article bodies.
479 See `format-time-string' for the possible values.
481 The variable can also be function, which should return a complete Date
482 header. The function is called with one argument, the time, which can
483 be fed to `format-time-string'."
484 :type '(choice string function)
485 :link '(custom-manual "(gnus)Article Date")
486 :group 'gnus-article-washing)
488 (defcustom gnus-save-all-headers t
489 "*If non-nil, don't remove any headers before saving."
490 :group 'gnus-article-saving
493 (defcustom gnus-prompt-before-saving 'always
494 "*This variable says how much prompting is to be done when saving articles.
495 If it is nil, no prompting will be done, and the articles will be
496 saved to the default files. If this variable is `always', each and
497 every article that is saved will be preceded by a prompt, even when
498 saving large batches of articles. If this variable is neither nil not
499 `always', there the user will be prompted once for a file name for
500 each invocation of the saving commands."
501 :group 'gnus-article-saving
502 :type '(choice (item always)
503 (item :tag "never" nil)
504 (sexp :tag "once" :format "%t\n" :value t)))
506 (defcustom gnus-saved-headers gnus-visible-headers
507 "Headers to keep if `gnus-save-all-headers' is nil.
508 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
509 If that variable is nil, however, all headers that match this regexp
510 will be kept while the rest will be deleted before saving."
511 :group 'gnus-article-saving
514 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
515 "A function to save articles in your favourite format.
516 The function must be interactively callable (in other words, it must
517 be an Emacs command).
519 Gnus provides the following functions:
521 * gnus-summary-save-in-rmail (Rmail format)
522 * gnus-summary-save-in-mail (Unix mail format)
523 * gnus-summary-save-in-folder (MH folder)
524 * gnus-summary-save-in-file (article format)
525 * gnus-summary-save-body-in-file (article body)
526 * gnus-summary-save-in-vm (use VM's folder format)
527 * gnus-summary-write-to-file (article format -- overwrite)."
528 :group 'gnus-article-saving
529 :type '(radio (function-item gnus-summary-save-in-rmail)
530 (function-item gnus-summary-save-in-mail)
531 (function-item gnus-summary-save-in-folder)
532 (function-item gnus-summary-save-in-file)
533 (function-item gnus-summary-save-body-in-file)
534 (function-item gnus-summary-save-in-vm)
535 (function-item gnus-summary-write-to-file)))
537 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
538 "A function generating a file name to save articles in Rmail format.
539 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
540 :group 'gnus-article-saving
543 (defcustom gnus-mail-save-name 'gnus-plain-save-name
544 "A function generating a file name to save articles in Unix mail format.
545 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
546 :group 'gnus-article-saving
549 (defcustom gnus-folder-save-name 'gnus-folder-save-name
550 "A function generating a file name to save articles in MH folder.
551 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
552 :group 'gnus-article-saving
555 (defcustom gnus-file-save-name 'gnus-numeric-save-name
556 "A function generating a file name to save articles in article format.
557 The function is called with NEWSGROUP, HEADERS, and optional
559 :group 'gnus-article-saving
562 (defcustom gnus-split-methods
563 '((gnus-article-archive-name)
564 (gnus-article-nndoc-name))
565 "*Variable used to suggest where articles are to be saved.
566 For instance, if you would like to save articles related to Gnus in
567 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
568 you could set this variable to something like:
570 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
571 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
573 This variable is an alist where the key is the match and the
574 value is a list of possible files to save in if the match is
577 If the match is a string, it is used as a regexp match on the
578 article. If the match is a symbol, that symbol will be funcalled
579 from the buffer of the article to be saved with the newsgroup as
580 the parameter. If it is a list, it will be evaled in the same
583 If this form or function returns a string, this string will be
584 used as a possible file name; and if it returns a non-nil list,
585 that list will be used as possible file names."
586 :group 'gnus-article-saving
587 :type '(repeat (choice (list :value (fun) function)
588 (cons :value ("" "") regexp (repeat string))
591 (defcustom gnus-page-delimiter "^\^L"
592 "*Regexp describing what to use as article page delimiters.
593 The default value is \"^\^L\", which is a form linefeed at the
594 beginning of a line."
596 :group 'gnus-article-various)
598 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
599 "*The format specification for the article mode line.
600 See `gnus-summary-mode-line-format' for a closer description.
602 The following additional specs are available:
604 %w The article washing status.
605 %m The number of MIME parts in the article."
607 :group 'gnus-article-various)
609 (defcustom gnus-article-mode-hook nil
610 "*A hook for Gnus article mode."
612 :group 'gnus-article-various)
614 (when (featurep 'xemacs)
615 ;; Extracted from gnus-xmas-define in order to preserve user settings
616 (when (fboundp 'turn-off-scroll-in-place)
617 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
618 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
619 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
621 (defcustom gnus-article-menu-hook nil
622 "*Hook run after the creation of the article mode menu."
624 :group 'gnus-article-various)
626 (defcustom gnus-article-prepare-hook nil
627 "*A hook called after an article has been prepared in the article buffer."
629 :group 'gnus-article-various)
631 (defcustom gnus-copy-article-ignored-headers nil
632 "List of headers to be removed when copying an article.
633 Each element is a regular expression."
634 :version "23.0" ;; No Gnus
635 :type '(repeat regexp)
636 :group 'gnus-article-various)
638 (make-obsolete-variable 'gnus-article-hide-pgp-hook
639 "This variable is obsolete in Gnus 5.10.")
641 (defcustom gnus-article-button-face 'bold
642 "Face used for highlighting buttons in the article buffer.
644 An article button is a piece of text that you can activate by pressing
645 `RET' or `mouse-2' above it."
647 :group 'gnus-article-buttons)
649 (defcustom gnus-article-mouse-face 'highlight
650 "Face used for mouse highlighting in the article buffer.
652 Article buttons will be displayed in this face when the cursor is
655 :group 'gnus-article-buttons)
657 (defcustom gnus-signature-face 'gnus-signature-face
658 "Face used for highlighting a signature in the article buffer.
659 Obsolete; use the face `gnus-signature-face' for customizations instead."
661 :group 'gnus-article-highlight
662 :group 'gnus-article-signature)
664 (defface gnus-signature-face
667 "Face used for highlighting a signature in the article buffer."
668 :group 'gnus-article-highlight
669 :group 'gnus-article-signature)
671 (defface gnus-header-from-face
674 (:foreground "spring green"))
677 (:foreground "red3"))
680 "Face used for displaying from headers."
681 :group 'gnus-article-headers
682 :group 'gnus-article-highlight)
684 (defface gnus-header-subject-face
687 (:foreground "SeaGreen3"))
690 (:foreground "red4"))
692 (:bold t :italic t)))
693 "Face used for displaying subject headers."
694 :group 'gnus-article-headers
695 :group 'gnus-article-highlight)
697 (defface gnus-header-newsgroups-face
700 (:foreground "yellow" :italic t))
703 (:foreground "MidnightBlue" :italic t))
706 "Face used for displaying newsgroups headers.
707 In the default setup this face is only used for crossposted
709 :group 'gnus-article-headers
710 :group 'gnus-article-highlight)
712 (defface gnus-header-name-face
715 (:foreground "SeaGreen"))
718 (:foreground "maroon"))
721 "Face used for displaying header names."
722 :group 'gnus-article-headers
723 :group 'gnus-article-highlight)
725 (defface gnus-header-content-face
728 (:foreground "forest green" :italic t))
731 (:foreground "indianred4" :italic t))
733 (:italic t))) "Face used for displaying header content."
734 :group 'gnus-article-headers
735 :group 'gnus-article-highlight)
737 (defcustom gnus-header-face-alist
738 '(("From" nil gnus-header-from-face)
739 ("Subject" nil gnus-header-subject-face)
740 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
741 ("" gnus-header-name-face gnus-header-content-face))
742 "*Controls highlighting of article headers.
744 An alist of the form (HEADER NAME CONTENT).
746 HEADER is a regular expression which should match the name of a
747 header and NAME and CONTENT are either face names or nil.
749 The name of each header field will be displayed using the face
750 specified by the first element in the list where HEADER matches
751 the header name and NAME is non-nil. Similarly, the content will
752 be displayed by the first non-nil matching CONTENT face."
753 :group 'gnus-article-headers
754 :group 'gnus-article-highlight
755 :type '(repeat (list (regexp :tag "Header")
757 (item :tag "skip" nil)
758 (face :value default))
759 (choice :tag "Content"
760 (item :tag "skip" nil)
761 (face :value default)))))
763 (defcustom gnus-article-decode-hook
764 '(article-decode-charset article-decode-encoded-words
765 article-decode-group-name article-decode-idna-rhs)
766 "*Hook run to decode charsets in articles."
767 :group 'gnus-article-headers
770 (defcustom gnus-display-mime-function 'gnus-display-mime
771 "Function to display MIME articles."
772 :group 'gnus-article-mime
775 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
776 "Function used to decode headers.")
778 (defvar gnus-article-dumbquotes-map
798 "Table for MS-to-Latin1 translation.")
800 (defcustom gnus-ignored-mime-types nil
801 "List of MIME types that should be ignored by Gnus."
803 :group 'gnus-article-mime
804 :type '(repeat regexp))
806 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
807 "List of MIME types that should not be given buttons when rendered inline.
808 See also `gnus-buttonized-mime-types' which may override this variable.
809 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
811 :group 'gnus-article-mime
812 :type '(repeat regexp))
814 (defcustom gnus-buttonized-mime-types nil
815 "List of MIME types that should be given buttons when rendered inline.
816 If set, this variable overrides `gnus-unbuttonized-mime-types'.
817 To see e.g. security buttons you could set this to
818 `(\"multipart/signed\")'.
819 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
821 :group 'gnus-article-mime
822 :type '(repeat regexp))
824 (defcustom gnus-inhibit-mime-unbuttonizing nil
825 "If non-nil, all MIME parts get buttons.
826 When nil (the default value), then some MIME parts do not get buttons,
827 as described by the variables `gnus-buttonized-mime-types' and
828 `gnus-unbuttonized-mime-types'."
830 :group 'gnus-article-mime
833 (defcustom gnus-body-boundary-delimiter "_"
834 "String used to delimit header and body.
835 This variable is used by `gnus-article-treat-body-boundary' which can
836 be controlled by `gnus-treat-body-boundary'."
838 :group 'gnus-article-various
839 :type '(choice (item :tag "None" :value nil)
842 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
844 "Defines the location of the faces database.
845 For information on obtaining this database of pretty pictures, please
846 see http://www.cs.indiana.edu/picons/ftp/index.html"
848 :type '(repeat directory)
849 :link '(url-link :tag "download"
850 "http://www.cs.indiana.edu/picons/ftp/index.html")
851 :link '(custom-manual "(gnus)Picons")
854 (defun gnus-picons-installed-p ()
855 "Say whether picons are installed on your machine."
856 (let ((installed nil))
857 (dolist (database gnus-picon-databases)
858 (when (file-exists-p database)
862 (defcustom gnus-article-mime-part-function nil
863 "Function called with a MIME handle as the argument.
864 This is meant for people who want to do something automatic based
865 on parts -- for instance, adding Vcard info to a database."
866 :group 'gnus-article-mime
869 (defcustom gnus-mime-multipart-functions nil
870 "An alist of MIME types to functions to display them."
872 :group 'gnus-article-mime
873 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
875 (defcustom gnus-article-date-lapsed-new-header nil
876 "Whether the X-Sent and Date headers can coexist.
877 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
878 either replace the old \"Date:\" header (if this variable is nil), or
879 be added below it (otherwise)."
881 :group 'gnus-article-headers
884 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
885 "Function called with a MIME handle as the argument.
886 This is meant for people who want to view first matched part.
887 For `undisplayed-alternative' (default), the first undisplayed
888 part or alternative part is used. For `undisplayed', the first
889 undisplayed part is used. For a function, the first part which
890 the function return t is used. For nil, the first part is
893 :group 'gnus-article-mime
895 (item :tag "first" :value nil)
896 (item :tag "undisplayed" :value undisplayed)
897 (item :tag "undisplayed or alternative"
898 :value undisplayed-alternative)
901 (defcustom gnus-mime-action-alist
902 '(("save to file" . gnus-mime-save-part)
903 ("save and strip" . gnus-mime-save-part-and-strip)
904 ("delete part" . gnus-mime-delete-part)
905 ("display as text" . gnus-mime-inline-part)
906 ("view the part" . gnus-mime-view-part)
907 ("pipe to command" . gnus-mime-pipe-part)
908 ("toggle display" . gnus-article-press-button)
909 ("toggle display" . gnus-article-view-part-as-charset)
910 ("view as type" . gnus-mime-view-part-as-type)
911 ("view internally" . gnus-mime-view-part-internally)
912 ("view externally" . gnus-mime-view-part-externally))
913 "An alist of actions that run on the MIME attachment."
914 :group 'gnus-article-mime
915 :type '(repeat (cons (string :tag "name")
919 ;;; The treatment variables
922 (defvar gnus-part-display-hook nil
923 "Hook called on parts that are to receive treatment.")
925 (defvar gnus-article-treat-custom
926 '(choice (const :tag "Off" nil)
928 (const :tag "Header" head)
929 (const :tag "Last" last)
930 (integer :tag "Less")
931 (repeat :tag "Groups" regexp)
932 (sexp :tag "Predicate")))
934 (defvar gnus-article-treat-head-custom
935 '(choice (const :tag "Off" nil)
936 (const :tag "Header" head)))
938 (defvar gnus-article-treat-types '("text/plain")
941 (defvar gnus-inhibit-treatment nil
942 "Whether to inhibit treatment.")
944 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
945 "Highlight the signature.
946 Valid values are nil, t, `head', `last', an integer or a predicate.
947 See Info node `(gnus)Customizing Articles'."
948 :group 'gnus-article-treat
949 :link '(custom-manual "(gnus)Customizing Articles")
950 :type gnus-article-treat-custom)
951 (put 'gnus-treat-highlight-signature 'highlight t)
953 (defcustom gnus-treat-buttonize 100000
955 Valid values are nil, t, `head', `last', an integer or a predicate.
956 See Info node `(gnus)Customizing Articles'."
957 :group 'gnus-article-treat
958 :link '(custom-manual "(gnus)Customizing Articles")
959 :type gnus-article-treat-custom)
960 (put 'gnus-treat-buttonize 'highlight t)
962 (defcustom gnus-treat-buttonize-head 'head
963 "Add buttons to the head.
964 Valid values are nil, t, `head', `last', an integer or a predicate.
965 See Info node `(gnus)Customizing Articles' for details."
966 :group 'gnus-article-treat
967 :link '(custom-manual "(gnus)Customizing Articles")
968 :type gnus-article-treat-head-custom)
969 (put 'gnus-treat-buttonize-head 'highlight t)
971 (defcustom gnus-treat-emphasize
972 (and (or window-system
976 Valid values are nil, t, `head', `last', an integer or a predicate.
977 See Info node `(gnus)Customizing Articles' for details."
978 :group 'gnus-article-treat
979 :link '(custom-manual "(gnus)Customizing Articles")
980 :type gnus-article-treat-custom)
981 (put 'gnus-treat-emphasize 'highlight t)
983 (defcustom gnus-treat-strip-cr nil
984 "Remove carriage returns.
985 Valid values are nil, t, `head', `last', an integer or a predicate.
986 See Info node `(gnus)Customizing Articles' for details."
988 :group 'gnus-article-treat
989 :link '(custom-manual "(gnus)Customizing Articles")
990 :type gnus-article-treat-custom)
992 (defcustom gnus-treat-unsplit-urls nil
993 "Remove newlines from within URLs.
994 Valid values are nil, t, `head', `last', an integer or a predicate.
995 See Info node `(gnus)Customizing Articles' for details."
997 :group 'gnus-article-treat
998 :link '(custom-manual "(gnus)Customizing Articles")
999 :type gnus-article-treat-custom)
1001 (defcustom gnus-treat-leading-whitespace nil
1002 "Remove leading whitespace in headers.
1003 Valid values are nil, t, `head', `last', an integer or a predicate.
1004 See Info node `(gnus)Customizing Articles' for details."
1006 :group 'gnus-article-treat
1007 :link '(custom-manual "(gnus)Customizing Articles")
1008 :type gnus-article-treat-custom)
1010 (defcustom gnus-treat-hide-headers 'head
1012 Valid values are nil, t, `head', `last', an integer or a predicate.
1013 See Info node `(gnus)Customizing Articles' for details."
1014 :group 'gnus-article-treat
1015 :link '(custom-manual "(gnus)Customizing Articles")
1016 :type gnus-article-treat-head-custom)
1018 (defcustom gnus-treat-hide-boring-headers nil
1019 "Hide boring headers.
1020 Valid values are nil, t, `head', `last', an integer or a predicate.
1021 See Info node `(gnus)Customizing Articles' for details."
1022 :group 'gnus-article-treat
1023 :link '(custom-manual "(gnus)Customizing Articles")
1024 :type gnus-article-treat-head-custom)
1026 (defcustom gnus-treat-hide-signature nil
1027 "Hide the signature.
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-custom)
1034 (defcustom gnus-treat-fill-article nil
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-custom)
1042 (defcustom gnus-treat-hide-citation nil
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-custom)
1050 (defcustom gnus-treat-hide-citation-maybe nil
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-custom)
1058 (defcustom gnus-treat-strip-list-identifiers 'head
1059 "Strip list identifiers from `gnus-list-identifiers`.
1060 Valid values are nil, t, `head', `last', an integer or a predicate.
1061 See Info node `(gnus)Customizing Articles' for details."
1063 :group 'gnus-article-treat
1064 :link '(custom-manual "(gnus)Customizing Articles")
1065 :type gnus-article-treat-custom)
1067 (make-obsolete-variable 'gnus-treat-strip-pgp
1068 "This option is obsolete in Gnus 5.10.")
1070 (defcustom gnus-treat-strip-pem nil
1071 "Strip PEM signatures.
1072 Valid values are nil, t, `head', `last', an integer or a predicate.
1073 See Info node `(gnus)Customizing Articles' for details."
1074 :group 'gnus-article-treat
1075 :link '(custom-manual "(gnus)Customizing Articles")
1076 :type gnus-article-treat-custom)
1078 (defcustom gnus-treat-strip-banner t
1079 "Strip banners from articles.
1080 The banner to be stripped is specified in the `banner' group parameter.
1081 Valid values are nil, t, `head', `last', an integer or a predicate.
1082 See Info node `(gnus)Customizing Articles' for details."
1083 :group 'gnus-article-treat
1084 :link '(custom-manual "(gnus)Customizing Articles")
1085 :type gnus-article-treat-custom)
1087 (defcustom gnus-treat-highlight-headers 'head
1088 "Highlight the headers.
1089 Valid values are nil, t, `head', `last', an integer or a predicate.
1090 See Info node `(gnus)Customizing Articles' for details."
1091 :group 'gnus-article-treat
1092 :link '(custom-manual "(gnus)Customizing Articles")
1093 :type gnus-article-treat-head-custom)
1094 (put 'gnus-treat-highlight-headers 'highlight t)
1096 (defcustom gnus-treat-highlight-citation t
1097 "Highlight cited text.
1098 Valid values are nil, t, `head', `last', an integer or a predicate.
1099 See Info node `(gnus)Customizing Articles' for details."
1100 :group 'gnus-article-treat
1101 :link '(custom-manual "(gnus)Customizing Articles")
1102 :type gnus-article-treat-custom)
1103 (put 'gnus-treat-highlight-citation 'highlight t)
1105 (defcustom gnus-treat-date-ut nil
1106 "Display the Date in UT (GMT).
1107 Valid values are nil, t, `head', `last', an integer or a predicate.
1108 See Info node `(gnus)Customizing Articles' for details."
1109 :group 'gnus-article-treat
1110 :link '(custom-manual "(gnus)Customizing Articles")
1111 :type gnus-article-treat-head-custom)
1113 (defcustom gnus-treat-date-local nil
1114 "Display the Date in the local timezone.
1115 Valid values are nil, t, `head', `last', an integer or a predicate.
1116 See Info node `(gnus)Customizing Articles' for details."
1117 :group 'gnus-article-treat
1118 :link '(custom-manual "(gnus)Customizing Articles")
1119 :type gnus-article-treat-head-custom)
1121 (defcustom gnus-treat-date-english nil
1122 "Display the Date in a format that can be read aloud in English.
1123 Valid values are nil, t, `head', `last', an integer or a predicate.
1124 See Info node `(gnus)Customizing Articles' for details."
1126 :group 'gnus-article-treat
1127 :link '(custom-manual "(gnus)Customizing Articles")
1128 :type gnus-article-treat-head-custom)
1130 (defcustom gnus-treat-date-lapsed nil
1131 "Display the Date header in a way that says how much time has elapsed.
1132 Valid values are nil, t, `head', `last', an integer or a predicate.
1133 See Info node `(gnus)Customizing Articles' for details."
1134 :group 'gnus-article-treat
1135 :link '(custom-manual "(gnus)Customizing Articles")
1136 :type gnus-article-treat-head-custom)
1138 (defcustom gnus-treat-date-original nil
1139 "Display the date in the original timezone.
1140 Valid values are nil, t, `head', `last', an integer or a predicate.
1141 See Info node `(gnus)Customizing Articles' for details."
1142 :group 'gnus-article-treat
1143 :link '(custom-manual "(gnus)Customizing Articles")
1144 :type gnus-article-treat-head-custom)
1146 (defcustom gnus-treat-date-iso8601 nil
1147 "Display the date in the ISO8601 format.
1148 Valid values are nil, t, `head', `last', an integer or a predicate.
1149 See Info node `(gnus)Customizing Articles' for details."
1151 :group 'gnus-article-treat
1152 :link '(custom-manual "(gnus)Customizing Articles")
1153 :type gnus-article-treat-head-custom)
1155 (defcustom gnus-treat-date-user-defined nil
1156 "Display the date in a user-defined format.
1157 The format is defined by the `gnus-article-time-format' variable.
1158 Valid values are nil, t, `head', `last', an integer or a predicate.
1159 See Info node `(gnus)Customizing Articles' for details."
1160 :group 'gnus-article-treat
1161 :link '(custom-manual "(gnus)Customizing Articles")
1162 :type gnus-article-treat-head-custom)
1164 (defcustom gnus-treat-strip-headers-in-body t
1165 "Strip the X-No-Archive header line from the beginning of the body.
1166 Valid values are nil, t, `head', `last', an integer or a predicate.
1167 See Info node `(gnus)Customizing Articles' for details."
1169 :group 'gnus-article-treat
1170 :link '(custom-manual "(gnus)Customizing Articles")
1171 :type gnus-article-treat-custom)
1173 (defcustom gnus-treat-strip-trailing-blank-lines nil
1174 "Strip trailing blank lines.
1175 Valid values are nil, t, `head', `last', an integer or a predicate.
1176 See Info node `(gnus)Customizing Articles' for details."
1177 :group 'gnus-article-treat
1178 :link '(custom-manual "(gnus)Customizing Articles")
1179 :type gnus-article-treat-custom)
1181 (defcustom gnus-treat-strip-leading-blank-lines nil
1182 "Strip leading blank lines.
1183 Valid values are nil, t, `head', `last', an integer or a predicate.
1184 See Info node `(gnus)Customizing Articles' for details."
1185 :group 'gnus-article-treat
1186 :link '(custom-manual "(gnus)Customizing Articles")
1187 :type gnus-article-treat-custom)
1189 (defcustom gnus-treat-strip-multiple-blank-lines nil
1190 "Strip multiple blank lines.
1191 Valid values are nil, t, `head', `last', an integer or a predicate.
1192 See Info node `(gnus)Customizing Articles' for details."
1193 :group 'gnus-article-treat
1194 :link '(custom-manual "(gnus)Customizing Articles")
1195 :type gnus-article-treat-custom)
1197 (defcustom gnus-treat-unfold-headers 'head
1198 "Unfold folded header lines.
1199 Valid values are nil, t, `head', `last', an integer or a predicate.
1200 See Info node `(gnus)Customizing Articles' for details."
1202 :group 'gnus-article-treat
1203 :link '(custom-manual "(gnus)Customizing Articles")
1204 :type gnus-article-treat-custom)
1206 (defcustom gnus-treat-fold-headers nil
1208 Valid values are nil, t, `head', `last', an integer or a predicate.
1209 See Info node `(gnus)Customizing Articles' for details."
1211 :group 'gnus-article-treat
1212 :link '(custom-manual "(gnus)Customizing Articles")
1213 :type gnus-article-treat-custom)
1215 (defcustom gnus-treat-fold-newsgroups 'head
1216 "Fold the Newsgroups and Followup-To headers.
1217 Valid values are nil, t, `head', `last', an integer or a predicate.
1218 See Info node `(gnus)Customizing Articles' for details."
1220 :group 'gnus-article-treat
1221 :link '(custom-manual "(gnus)Customizing Articles")
1222 :type gnus-article-treat-custom)
1224 (defcustom gnus-treat-overstrike t
1225 "Treat overstrike highlighting.
1226 Valid values are nil, t, `head', `last', an integer or a predicate.
1227 See Info node `(gnus)Customizing Articles' for details."
1228 :group 'gnus-article-treat
1229 :link '(custom-manual "(gnus)Customizing Articles")
1230 :type gnus-article-treat-custom)
1231 (put 'gnus-treat-overstrike 'highlight t)
1233 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1234 "Treat ANSI SGR control sequences.
1235 Valid values are nil, t, `head', `last', an integer or a predicate.
1236 See Info node `(gnus)Customizing Articles' for details."
1237 :group 'gnus-article-treat
1238 :link '(custom-manual "(gnus)Customizing Articles")
1239 :type gnus-article-treat-custom)
1241 (make-obsolete-variable 'gnus-treat-display-xface
1242 'gnus-treat-display-x-face)
1244 (defcustom gnus-treat-display-x-face
1245 (and (not noninteractive)
1246 (or (and (fboundp 'image-type-available-p)
1247 (image-type-available-p 'xbm)
1248 (string-match "^0x" (shell-command-to-string "uncompface"))
1249 (executable-find "icontopbm"))
1250 (and (featurep 'xemacs)
1253 "Display X-Face headers.
1254 Valid values are nil, t, `head', `last', an integer or a predicate.
1255 See Info node `(gnus)Customizing Articles' and Info node
1256 `(gnus)X-Face' for details."
1257 :group 'gnus-article-treat
1259 :link '(custom-manual "(gnus)Customizing Articles")
1260 :link '(custom-manual "(gnus)X-Face")
1261 :type gnus-article-treat-head-custom
1262 :set (lambda (symbol value)
1265 (cond ((or (boundp symbol) (get symbol 'saved-value))
1267 ((boundp 'gnus-treat-display-xface)
1269 ** gnus-treat-display-xface is an obsolete variable;\
1270 use gnus-treat-display-x-face instead")
1271 (default-value 'gnus-treat-display-xface))
1272 ((get 'gnus-treat-display-xface 'saved-value)
1274 ** gnus-treat-display-xface is an obsolete variable;\
1275 use gnus-treat-display-x-face instead")
1276 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1279 (put 'gnus-treat-display-x-face 'highlight t)
1281 (defcustom gnus-treat-display-face
1282 (and (not noninteractive)
1283 (or (and (fboundp 'image-type-available-p)
1284 (image-type-available-p 'png))
1285 (and (featurep 'xemacs)
1288 "Display Face headers.
1289 Valid values are nil, t, `head', `last', an integer or a predicate.
1290 See Info node `(gnus)Customizing Articles' and Info node
1291 `(gnus)X-Face' for details."
1292 :group 'gnus-article-treat
1294 :link '(custom-manual "(gnus)Customizing Articles")
1295 :link '(custom-manual "(gnus)X-Face")
1296 :type gnus-article-treat-head-custom)
1297 (put 'gnus-treat-display-face 'highlight t)
1299 (defcustom gnus-treat-display-smileys
1300 (if (or (and (featurep 'xemacs)
1302 (and (fboundp 'image-type-available-p)
1303 (image-type-available-p 'pbm)))
1306 Valid values are nil, t, `head', `last', an integer or a predicate.
1307 See Info node `(gnus)Customizing Articles' and Info node
1308 `(gnus)Smileys' for details."
1309 :group 'gnus-article-treat
1311 :link '(custom-manual "(gnus)Customizing Articles")
1312 :link '(custom-manual "(gnus)Smileys")
1313 :type gnus-article-treat-custom)
1314 (put 'gnus-treat-display-smileys 'highlight t)
1316 (defcustom gnus-treat-from-picon
1317 (if (and (gnus-image-type-available-p 'xpm)
1318 (gnus-picons-installed-p))
1320 "Display picons in the From header.
1321 Valid values are nil, t, `head', `last', an integer or a predicate.
1322 See Info node `(gnus)Customizing Articles' and Info node
1323 `(gnus)Picons' for details."
1325 :group 'gnus-article-treat
1327 :link '(custom-manual "(gnus)Customizing Articles")
1328 :link '(custom-manual "(gnus)Picons")
1329 :type gnus-article-treat-head-custom)
1330 (put 'gnus-treat-from-picon 'highlight t)
1332 (defcustom gnus-treat-mail-picon
1333 (if (and (gnus-image-type-available-p 'xpm)
1334 (gnus-picons-installed-p))
1336 "Display picons in To and Cc headers.
1337 Valid values are nil, t, `head', `last', an integer or a predicate.
1338 See Info node `(gnus)Customizing Articles' and Info node
1339 `(gnus)Picons' for details."
1341 :group 'gnus-article-treat
1343 :link '(custom-manual "(gnus)Customizing Articles")
1344 :link '(custom-manual "(gnus)Picons")
1345 :type gnus-article-treat-head-custom)
1346 (put 'gnus-treat-mail-picon 'highlight t)
1348 (defcustom gnus-treat-newsgroups-picon
1349 (if (and (gnus-image-type-available-p 'xpm)
1350 (gnus-picons-installed-p))
1352 "Display picons in the Newsgroups and Followup-To headers.
1353 Valid values are nil, t, `head', `last', an integer or a predicate.
1354 See Info node `(gnus)Customizing Articles' and Info node
1355 `(gnus)Picons' for details."
1357 :group 'gnus-article-treat
1359 :link '(custom-manual "(gnus)Customizing Articles")
1360 :link '(custom-manual "(gnus)Picons")
1361 :type gnus-article-treat-head-custom)
1362 (put 'gnus-treat-newsgroups-picon 'highlight t)
1364 (defcustom gnus-treat-body-boundary
1365 (if (and (eq window-system 'x)
1366 (or gnus-treat-newsgroups-picon
1367 gnus-treat-mail-picon
1368 gnus-treat-from-picon))
1370 "Draw a boundary at the end of the headers.
1371 Valid values are nil and `head'.
1372 See Info node `(gnus)Customizing Articles' for details."
1374 :group 'gnus-article-treat
1375 :link '(custom-manual "(gnus)Customizing Articles")
1376 :type gnus-article-treat-head-custom)
1378 (defcustom gnus-treat-capitalize-sentences nil
1379 "Capitalize sentence-starting words.
1380 Valid values are nil, t, `head', `last', an integer or a predicate.
1381 See Info node `(gnus)Customizing Articles' for details."
1383 :group 'gnus-article-treat
1384 :link '(custom-manual "(gnus)Customizing Articles")
1385 :type gnus-article-treat-custom)
1387 (defcustom gnus-treat-wash-html nil
1389 Valid values are nil, t, `head', `last', an integer or a predicate.
1390 See Info node `(gnus)Customizing Articles' for details."
1392 :group 'gnus-article-treat
1393 :link '(custom-manual "(gnus)Customizing Articles")
1394 :type gnus-article-treat-custom)
1396 (defcustom gnus-treat-fill-long-lines nil
1398 Valid values are nil, t, `head', `last', an integer or a predicate.
1399 See Info node `(gnus)Customizing Articles' for details."
1400 :group 'gnus-article-treat
1401 :link '(custom-manual "(gnus)Customizing Articles")
1402 :type gnus-article-treat-custom)
1404 (defcustom gnus-treat-play-sounds nil
1406 Valid values are nil, t, `head', `last', an integer or a predicate.
1407 See Info node `(gnus)Customizing Articles' for details."
1409 :group 'gnus-article-treat
1410 :link '(custom-manual "(gnus)Customizing Articles")
1411 :type gnus-article-treat-custom)
1413 (defcustom gnus-treat-translate nil
1414 "Translate articles from one language to another.
1415 Valid values are nil, t, `head', `last', an integer or a predicate.
1416 See Info node `(gnus)Customizing Articles' for details."
1418 :group 'gnus-article-treat
1419 :link '(custom-manual "(gnus)Customizing Articles")
1420 :type gnus-article-treat-custom)
1422 (defcustom gnus-treat-x-pgp-sig nil
1424 To automatically treat X-PGP-Sig, set it to head.
1425 Valid values are nil, t, `head', `last', an integer or a predicate.
1426 See Info node `(gnus)Customizing Articles' for details."
1428 :group 'gnus-article-treat
1429 :group 'mime-security
1430 :link '(custom-manual "(gnus)Customizing Articles")
1431 :type gnus-article-treat-custom)
1433 (defvar gnus-article-encrypt-protocol-alist
1434 '(("PGP" . mml2015-self-encrypt)))
1436 ;; Set to nil if more than one protocol added to
1437 ;; gnus-article-encrypt-protocol-alist.
1438 (defcustom gnus-article-encrypt-protocol "PGP"
1439 "The protocol used for encrypt articles.
1440 It is a string, such as \"PGP\". If nil, ask user."
1443 :group 'mime-security)
1445 (defvar gnus-article-wash-function nil
1446 "Function used for converting HTML into text.")
1448 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1449 (mm-coding-system-p 'utf-8)
1450 (executable-find idna-program))
1451 "Whether IDNA decoding of headers is used when viewing messages.
1452 This requires GNU Libidn, and by default only enabled if it is found."
1454 :group 'gnus-article-headers
1457 (defcustom gnus-article-over-scroll nil
1458 "If non-nil, allow scrolling the article buffer even when there no more text."
1460 :group 'gnus-article
1463 ;;; Internal variables
1465 (defvar gnus-english-month-names
1466 '("January" "February" "March" "April" "May" "June" "July" "August"
1467 "September" "October" "November" "December"))
1469 (defvar gnus-button-regexp nil)
1470 (defvar gnus-button-marker-list nil)
1471 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1473 (defvar gnus-button-last nil)
1474 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1476 (defvar article-goto-body-goes-to-point-min-p nil)
1477 (defvar gnus-article-wash-types nil)
1478 (defvar gnus-article-emphasis-alist nil)
1479 (defvar gnus-article-image-alist nil)
1481 (defvar gnus-article-mime-handle-alist-1 nil)
1482 (defvar gnus-treatment-function-alist
1483 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1484 (gnus-treat-strip-banner gnus-article-strip-banner)
1485 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1486 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1487 (gnus-treat-buttonize gnus-article-add-buttons)
1488 (gnus-treat-fill-article gnus-article-fill-cited-article)
1489 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1490 (gnus-treat-strip-cr gnus-article-remove-cr)
1491 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1492 (gnus-treat-date-ut gnus-article-date-ut)
1493 (gnus-treat-date-local gnus-article-date-local)
1494 (gnus-treat-date-english gnus-article-date-english)
1495 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1496 (gnus-treat-date-original gnus-article-date-original)
1497 (gnus-treat-date-user-defined gnus-article-date-user)
1498 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1499 (gnus-treat-display-x-face gnus-article-display-x-face)
1500 (gnus-treat-display-face gnus-article-display-face)
1501 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1502 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1503 (gnus-treat-hide-signature gnus-article-hide-signature)
1504 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1505 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1506 (gnus-treat-strip-pem gnus-article-hide-pem)
1507 (gnus-treat-from-picon gnus-treat-from-picon)
1508 (gnus-treat-mail-picon gnus-treat-mail-picon)
1509 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1510 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1511 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1512 (gnus-treat-strip-trailing-blank-lines
1513 gnus-article-remove-trailing-blank-lines)
1514 (gnus-treat-strip-leading-blank-lines
1515 gnus-article-strip-leading-blank-lines)
1516 (gnus-treat-strip-multiple-blank-lines
1517 gnus-article-strip-multiple-blank-lines)
1518 (gnus-treat-overstrike gnus-article-treat-overstrike)
1519 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1520 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1521 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1522 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1523 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1524 (gnus-treat-display-smileys gnus-treat-smiley)
1525 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1526 (gnus-treat-wash-html gnus-article-wash-html)
1527 (gnus-treat-emphasize gnus-article-emphasize)
1528 (gnus-treat-hide-citation gnus-article-hide-citation)
1529 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1530 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1531 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1532 (gnus-treat-play-sounds gnus-earcon-display)))
1534 (defvar gnus-article-mime-handle-alist nil)
1535 (defvar article-lapsed-timer nil)
1536 (defvar gnus-article-current-summary nil)
1538 (defvar gnus-article-mode-syntax-table
1539 (let ((table (copy-syntax-table text-mode-syntax-table)))
1540 ;; This causes the citation match run O(2^n).
1541 ;; (modify-syntax-entry ?- "w" table)
1542 (modify-syntax-entry ?> ")<" table)
1543 (modify-syntax-entry ?< "(>" table)
1544 ;; make M-. in article buffers work for `foo' strings
1545 (modify-syntax-entry ?' " " table)
1546 (modify-syntax-entry ?` " " table)
1548 "Syntax table used in article mode buffers.
1549 Initialized from `text-mode-syntax-table.")
1551 (defvar gnus-save-article-buffer nil)
1553 (defvar gnus-article-mode-line-format-alist
1554 (nconc '((?w (gnus-article-wash-status) ?s)
1555 (?m (gnus-article-mime-part-status) ?s))
1556 gnus-summary-mode-line-format-alist))
1558 (defvar gnus-number-of-articles-to-be-saved nil)
1560 (defvar gnus-inhibit-hiding nil)
1562 (defvar gnus-article-edit-mode nil)
1564 ;;; Macros for dealing with the article buffer.
1566 (defmacro gnus-with-article-headers (&rest forms)
1568 (set-buffer gnus-article-buffer)
1570 (let ((inhibit-read-only t)
1571 (inhibit-point-motion-hooks t)
1572 (case-fold-search t))
1573 (article-narrow-to-head)
1576 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1577 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1579 (defmacro gnus-with-article-buffer (&rest forms)
1581 (set-buffer gnus-article-buffer)
1582 (let ((inhibit-read-only t))
1585 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1586 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1588 (defun gnus-article-goto-header (header)
1589 "Go to HEADER, which is a regular expression."
1590 (re-search-forward (concat "^\\(" header "\\):") nil t))
1592 (defsubst gnus-article-hide-text (b e props)
1593 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1594 (gnus-add-text-properties-when 'article-type nil b e props)
1595 (when (memq 'intangible props)
1597 (max (1- b) (point-min))
1598 b 'intangible (cddr (memq 'intangible props)))))
1600 (defsubst gnus-article-unhide-text (b e)
1601 "Remove hidden text properties from region between B and E."
1602 (remove-text-properties b e gnus-hidden-properties)
1603 (when (memq 'intangible gnus-hidden-properties)
1604 (put-text-property (max (1- b) (point-min))
1605 b 'intangible nil)))
1607 (defun gnus-article-hide-text-type (b e type)
1608 "Hide text of TYPE between B and E."
1609 (gnus-add-wash-type type)
1610 (gnus-article-hide-text
1611 b e (cons 'article-type (cons type gnus-hidden-properties))))
1613 (defun gnus-article-unhide-text-type (b e type)
1614 "Unhide text of TYPE between B and E."
1615 (gnus-delete-wash-type type)
1616 (remove-text-properties
1617 b e (cons 'article-type (cons type gnus-hidden-properties)))
1618 (when (memq 'intangible gnus-hidden-properties)
1619 (put-text-property (max (1- b) (point-min))
1620 b 'intangible nil)))
1622 (defun gnus-article-hide-text-of-type (type)
1623 "Hide text of TYPE in the current buffer."
1625 (let ((b (point-min))
1627 (while (setq b (text-property-any b e 'article-type type))
1628 (add-text-properties b (incf b) gnus-hidden-properties)))))
1630 (defun gnus-article-delete-text-of-type (type)
1631 "Delete text of TYPE in the current buffer."
1633 (let ((b (point-min)))
1634 (while (setq b (text-property-any b (point-max) 'article-type type))
1636 b (or (text-property-not-all b (point-max) 'article-type type)
1639 (defun gnus-article-delete-invisible-text ()
1640 "Delete all invisible text in the current buffer."
1642 (let ((b (point-min)))
1643 (while (setq b (text-property-any b (point-max) 'invisible t))
1645 b (or (text-property-not-all b (point-max) 'invisible t)
1648 (defun gnus-article-text-type-exists-p (type)
1649 "Say whether any text of type TYPE exists in the buffer."
1650 (text-property-any (point-min) (point-max) 'article-type type))
1652 (defsubst gnus-article-header-rank ()
1653 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1654 (let ((list gnus-sorted-header-list)
1657 (if (looking-at (car list))
1659 (setq list (cdr list))
1663 (defun article-hide-headers (&optional arg delete)
1664 "Hide unwanted headers and possibly sort them as well."
1666 ;; This function might be inhibited.
1667 (unless gnus-inhibit-hiding
1668 (let ((inhibit-read-only nil)
1669 (case-fold-search t)
1670 (max (1+ (length gnus-sorted-header-list)))
1671 (inhibit-point-motion-hooks t)
1672 (cur (current-buffer))
1673 ignored visible beg)
1675 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1676 ;; group parameters, so we should go to the summary buffer.
1679 (progn (set-buffer gnus-summary-buffer) t)
1681 (setq ignored (when (not gnus-visible-headers)
1682 (cond ((stringp gnus-ignored-headers)
1683 gnus-ignored-headers)
1684 ((listp gnus-ignored-headers)
1685 (mapconcat 'identity
1686 gnus-ignored-headers
1688 visible (cond ((stringp gnus-visible-headers)
1689 gnus-visible-headers)
1690 ((and gnus-visible-headers
1691 (listp gnus-visible-headers))
1692 (mapconcat 'identity
1693 gnus-visible-headers
1697 ;; First we narrow to just the headers.
1698 (article-narrow-to-head)
1699 ;; Hide any "From " lines at the beginning of (mail) articles.
1700 (while (looking-at "From ")
1703 (delete-region (point-min) (point)))
1704 ;; Then treat the rest of the header lines.
1705 ;; Then we use the two regular expressions
1706 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1707 ;; select which header lines is to remain visible in the
1709 (while (re-search-forward "^[^ \t:]*:" nil t)
1711 ;; Mark the rank of the header.
1713 (point) (1+ (point)) 'message-rank
1714 (if (or (and visible (looking-at visible))
1716 (not (looking-at ignored))))
1717 (gnus-article-header-rank)
1720 (message-sort-headers-1)
1721 (when (setq beg (text-property-any
1722 (point-min) (point-max) 'message-rank (+ 2 max)))
1723 ;; We delete the unwanted headers.
1724 (gnus-add-wash-type 'headers)
1725 (add-text-properties (point-min) (+ 5 (point-min))
1726 '(article-type headers dummy-invisible t))
1727 (delete-region beg (point-max))))))))
1729 (defun article-hide-boring-headers (&optional arg)
1730 "Toggle hiding of headers that aren't very interesting.
1731 If given a negative prefix, always show; if given a positive prefix,
1733 (interactive (gnus-article-hidden-arg))
1734 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1735 (not gnus-show-all-headers))
1738 (let ((inhibit-read-only t)
1739 (inhibit-point-motion-hooks t))
1740 (article-narrow-to-head)
1741 (dolist (elem gnus-boring-article-headers)
1742 (goto-char (point-min))
1744 ;; Hide empty headers.
1746 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1748 (gnus-article-hide-text-type
1752 (if (re-search-forward "^[^ \t]" nil t)
1756 ;; Hide boring Newsgroups header.
1757 ((eq elem 'newsgroups)
1758 (when (gnus-string-equal
1759 (gnus-fetch-field "newsgroups")
1760 (gnus-group-real-name
1761 (if (boundp 'gnus-newsgroup-name)
1764 (gnus-article-hide-header "newsgroups")))
1765 ((eq elem 'to-address)
1766 (let ((to (message-fetch-field "to"))
1768 (gnus-parameter-to-address
1769 (if (boundp 'gnus-newsgroup-name)
1770 gnus-newsgroup-name ""))))
1771 (when (and to to-address
1774 ;; only one address in To
1775 (nth 1 (mail-extract-address-components to))
1777 (gnus-article-hide-header "to"))))
1779 (let ((to (message-fetch-field "to"))
1781 (gnus-parameter-to-list
1782 (if (boundp 'gnus-newsgroup-name)
1783 gnus-newsgroup-name ""))))
1784 (when (and to to-list
1787 ;; only one address in To
1788 (nth 1 (mail-extract-address-components to))
1790 (gnus-article-hide-header "to"))))
1792 (let ((cc (message-fetch-field "cc"))
1794 (gnus-parameter-to-list
1795 (if (boundp 'gnus-newsgroup-name)
1796 gnus-newsgroup-name ""))))
1797 (when (and cc to-list
1800 ;; only one address in CC
1801 (nth 1 (mail-extract-address-components cc))
1803 (gnus-article-hide-header "cc"))))
1804 ((eq elem 'followup-to)
1805 (when (gnus-string-equal
1806 (message-fetch-field "followup-to")
1807 (message-fetch-field "newsgroups"))
1808 (gnus-article-hide-header "followup-to")))
1809 ((eq elem 'reply-to)
1810 (if (gnus-group-find-parameter
1811 gnus-newsgroup-name 'broken-reply-to)
1812 (gnus-article-hide-header "reply-to")
1813 (let ((from (message-fetch-field "from"))
1814 (reply-to (message-fetch-field "reply-to")))
1821 (lambda (x) (downcase (cadr x)))
1822 (mail-extract-address-components from t))
1825 (lambda (x) (downcase (cadr x)))
1826 (mail-extract-address-components reply-to t))
1828 (gnus-article-hide-header "reply-to")))))
1830 (let ((date (message-fetch-field "date")))
1832 (< (days-between (current-time-string) date)
1834 (gnus-article-hide-header "date"))))
1836 (let ((to (message-fetch-field "to"))
1837 (cc (message-fetch-field "cc")))
1838 (when (> (length to) 1024)
1839 (gnus-article-hide-header "to"))
1840 (when (> (length cc) 1024)
1841 (gnus-article-hide-header "cc"))))
1845 (goto-char (point-min))
1846 (while (re-search-forward "^to:" nil t)
1847 (setq to-count (1+ to-count)))
1848 (when (> to-count 1)
1849 (while (> to-count 0)
1850 (goto-char (point-min))
1852 (re-search-forward "^to:" nil nil to-count)
1854 (narrow-to-region (point) (point-max))
1855 (gnus-article-hide-header "to"))
1856 (setq to-count (1- to-count))))
1857 (goto-char (point-min))
1858 (while (re-search-forward "^cc:" nil t)
1859 (setq cc-count (1+ cc-count)))
1860 (when (> cc-count 1)
1861 (while (> cc-count 0)
1862 (goto-char (point-min))
1864 (re-search-forward "^cc:" nil nil cc-count)
1866 (narrow-to-region (point) (point-max))
1867 (gnus-article-hide-header "cc"))
1868 (setq cc-count (1- cc-count)))))))))))))
1870 (defun gnus-article-hide-header (header)
1872 (goto-char (point-min))
1873 (when (re-search-forward (concat "^" header ":") nil t)
1874 (gnus-article-hide-text-type
1878 (if (re-search-forward "^[^ \t]" nil t)
1883 (defvar gnus-article-normalized-header-length 40
1884 "Length of normalized headers.")
1886 (defun article-normalize-headers ()
1887 "Make all header lines 40 characters long."
1889 (let ((inhibit-read-only t)
1893 (article-narrow-to-head)
1896 ((< (setq column (- (point-at-eol) (point)))
1897 gnus-article-normalized-header-length)
1899 (insert (make-string
1900 (- gnus-article-normalized-header-length column)
1902 ((> column gnus-article-normalized-header-length)
1903 (gnus-put-text-property
1905 (forward-char gnus-article-normalized-header-length)
1912 (forward-line 1))))))
1914 (defun article-treat-dumbquotes ()
1915 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1916 Note that this function guesses whether a character is a sm*rtq**t* or
1917 not, so it should only be used interactively.
1919 Sm*rtq**t*s are M****s***'s unilateral extension to the
1920 iso-8859-1 character map in an attempt to provide more quoting
1921 characters. If you see something like \\222 or \\264 where
1922 you're expecting some kind of apostrophe or quotation mark, then
1925 (article-translate-strings gnus-article-dumbquotes-map))
1927 (defun article-translate-characters (from to)
1928 "Translate all characters in the body of the article according to FROM and TO.
1929 FROM is a string of characters to translate from; to is a string of
1930 characters to translate to."
1932 (when (article-goto-body)
1933 (let ((inhibit-read-only t)
1934 (x (make-string 225 ?x))
1936 (while (< (incf i) (length x))
1939 (while (< i (length from))
1940 (aset x (aref from i) (aref to i))
1942 (translate-region (point) (point-max) x)))))
1944 (defun article-translate-strings (map)
1945 "Translate all string in the body of the article according to MAP.
1946 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1948 (when (article-goto-body)
1949 (let ((inhibit-read-only t))
1952 (while (search-forward (car elem) nil t)
1953 (replace-match (cadr elem)))))))))
1955 (defun article-treat-overstrike ()
1956 "Translate overstrikes into bold text."
1959 (when (article-goto-body)
1960 (let ((inhibit-read-only t))
1961 (while (search-forward "\b" nil t)
1962 (let ((next (char-after))
1963 (previous (char-after (- (point) 2))))
1964 ;; We do the boldification/underlining by hiding the
1965 ;; overstrikes and putting the proper text property
1969 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1970 (put-text-property (point) (1+ (point)) 'face 'bold))
1972 (gnus-article-hide-text-type
1973 (1- (point)) (1+ (point)) 'overstrike)
1975 (- (point) 2) (1- (point)) 'face 'underline))
1977 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1979 (point) (1+ (point)) 'face 'underline)))))))))
1981 (defun article-treat-ansi-sequences ()
1982 "Translate ANSI SGR control sequences into overlays or extents."
1985 (when (article-goto-body)
1986 (let ((inhibit-read-only t))
1987 (ansi-color-apply-on-region (point) (point-max))))))
1989 (defun gnus-article-treat-unfold-headers ()
1990 "Unfold folded message headers.
1991 Only the headers that fit into the current window width will be
1994 (gnus-with-article-headers
1998 (mail-header-narrow-to-field)
1999 (let ((header (buffer-string)))
2002 (goto-char (point-min))
2003 (while (re-search-forward "\n[\t ]" nil t)
2004 (replace-match " " t t)))
2005 (setq length (- (point-max) (point-min) 1)))
2006 (when (< length (window-width))
2007 (while (re-search-forward "\n[\t ]" nil t)
2008 (replace-match " " t t)))
2009 (goto-char (point-max)))))))
2011 (defun gnus-article-treat-fold-headers ()
2012 "Fold message headers."
2014 (gnus-with-article-headers
2017 (mail-header-narrow-to-field)
2018 (mail-header-fold-field)
2019 (goto-char (point-max))))))
2021 (defun gnus-treat-smiley ()
2022 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2024 (gnus-with-article-buffer
2025 (if (memq 'smiley gnus-article-wash-types)
2026 (gnus-delete-images 'smiley)
2028 (let ((images (smiley-region (point) (point-max))))
2030 (gnus-add-wash-type 'smiley)
2031 (dolist (image images)
2032 (gnus-add-image 'smiley image)))))))
2034 (defun gnus-article-remove-images ()
2035 "Remove all images from the article buffer."
2037 (gnus-with-article-buffer
2038 (dolist (elem gnus-article-image-alist)
2039 (gnus-delete-images (car elem)))))
2041 (defun gnus-article-treat-fold-newsgroups ()
2042 "Unfold folded message headers.
2043 Only the headers that fit into the current window width will be
2046 (gnus-with-article-headers
2047 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2049 (mail-header-narrow-to-field)
2050 (while (re-search-forward ", *" nil t)
2051 (replace-match ", " t t))
2052 (mail-header-fold-field)
2053 (goto-char (point-max))))))
2055 (defun gnus-article-treat-body-boundary ()
2056 "Place a boundary line at the end of the headers."
2058 (when (and gnus-body-boundary-delimiter
2059 (> (length gnus-body-boundary-delimiter) 0))
2060 (gnus-with-article-headers
2061 (goto-char (point-max))
2062 (let ((start (point)))
2063 (insert "X-Boundary: ")
2064 (gnus-add-text-properties start (point) '(invisible t intangible t))
2066 (while (>= (1- (window-width)) (length str))
2067 (setq str (concat str gnus-body-boundary-delimiter)))
2068 (substring str 0 (1- (window-width))))
2070 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2072 (defun article-fill-long-lines ()
2073 "Fill lines that are wider than the window width."
2076 (let ((inhibit-read-only t)
2077 (width (window-width (get-buffer-window (current-buffer)))))
2080 (let ((adaptive-fill-mode nil)) ;Why? -sm
2083 (when (>= (current-column) (min fill-column width))
2084 (narrow-to-region (min (1+ (point)) (point-max))
2086 (let ((goback (point-marker)))
2087 (fill-paragraph nil)
2088 (goto-char (marker-position goback)))
2090 (forward-line 1)))))))
2092 (defun article-capitalize-sentences ()
2093 "Capitalize the first word in each sentence."
2096 (let ((inhibit-read-only t)
2097 (paragraph-start "^[\n\^L]"))
2101 (forward-sentence)))))
2103 (defun article-remove-cr ()
2104 "Remove trailing CRs and then translate remaining CRs into LFs."
2107 (let ((inhibit-read-only t))
2108 (goto-char (point-min))
2109 (while (re-search-forward "\r+$" nil t)
2110 (replace-match "" t t))
2111 (goto-char (point-min))
2112 (while (search-forward "\r" nil t)
2113 (replace-match "\n" t t)))))
2115 (defun article-remove-trailing-blank-lines ()
2116 "Remove all trailing blank lines from the article."
2119 (let ((inhibit-read-only t))
2120 (goto-char (point-max))
2124 (while (and (not (bobp))
2125 (looking-at "^[ \t]*$")
2126 (not (gnus-annotation-in-region-p
2127 (point) (point-at-eol))))
2133 (defvar gnus-face-properties-alist))
2135 (defun article-display-face ()
2136 "Display any Face headers in the header."
2138 (let ((wash-face-p buffer-read-only))
2139 (gnus-with-article-headers
2140 ;; When displaying parts, this function can be called several times on
2141 ;; the same article, without any intended toggle semantic (as typing `W
2142 ;; D d' would have). So face deletion must occur only when we come from
2143 ;; an interactive command, that is when the *Article* buffer is
2145 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2146 (gnus-delete-images 'face)
2149 (when (and wash-face-p
2151 (goto-char (point-min))
2152 (not (re-search-forward "^Face:[\t ]*" nil t)))
2153 (gnus-buffer-live-p gnus-original-article-buffer))
2154 (set-buffer gnus-original-article-buffer))
2156 (mail-narrow-to-head)
2157 (while (gnus-article-goto-header "Face")
2158 (setq faces (nconc faces (list (mail-header-field-value)))))))
2159 (dolist (face faces)
2160 (let ((png (gnus-convert-face-to-png face))
2164 (apply 'gnus-create-image png 'png t
2165 (cdr (assq 'png gnus-face-properties-alist))))
2166 (gnus-article-goto-header "from")
2168 (insert "From: [no `from' set]\n")
2170 (gnus-add-wash-type 'face)
2171 (gnus-add-image 'face image)
2172 (gnus-put-image image nil 'face))))))
2175 (defun article-display-x-face (&optional force)
2176 "Look for an X-Face header and display it if present."
2177 (interactive (list 'force))
2178 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2179 (gnus-with-article-headers
2180 ;; Delete the old process, if any.
2181 (when (process-status "article-x-face")
2182 (delete-process "article-x-face"))
2183 ;; See the comment in `article-display-face'.
2184 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2185 ;; We have already displayed X-Faces, so we remove them
2187 (gnus-delete-images 'xface)
2189 (let (x-faces from face)
2191 (when (and wash-face-p
2193 (goto-char (point-min))
2194 (not (re-search-forward
2195 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2196 (gnus-buffer-live-p gnus-original-article-buffer))
2197 ;; If type `W f', use gnus-original-article-buffer,
2198 ;; otherwise use the current buffer because displaying
2199 ;; RFC822 parts calls this function too.
2200 (set-buffer gnus-original-article-buffer))
2202 (mail-narrow-to-head)
2203 (while (gnus-article-goto-header "X-Face")
2204 (push (mail-header-field-value) x-faces))
2205 (setq from (message-fetch-field "from"))))
2206 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2207 ;; single external face.
2208 (when (stringp gnus-article-x-face-command)
2209 (setq x-faces (list (car x-faces))))
2210 (while (and (setq face (pop x-faces))
2211 gnus-article-x-face-command
2213 ;; Check whether this face is censored.
2214 (not gnus-article-x-face-too-ugly)
2215 (and gnus-article-x-face-too-ugly from
2216 (not (string-match gnus-article-x-face-too-ugly
2218 ;; We display the face.
2219 (cond ((stringp gnus-article-x-face-command)
2220 ;; The command is a string, so we interpret the command
2221 ;; as a, well, command, and fork it off.
2222 (let ((process-connection-type nil))
2223 (process-kill-without-query
2225 "article-x-face" nil shell-file-name
2226 shell-command-switch gnus-article-x-face-command))
2229 (process-send-region "article-x-face"
2230 (point-min) (point-max)))
2231 (process-send-eof "article-x-face")))
2232 ((functionp gnus-article-x-face-command)
2233 ;; The command is a lisp function, so we call it.
2234 (funcall gnus-article-x-face-command face))
2236 (error "%s is not a function"
2237 gnus-article-x-face-command)))))))))
2239 (defun article-decode-mime-words ()
2240 "Decode all MIME-encoded words in the article."
2242 (gnus-with-article-buffer
2243 (let ((inhibit-point-motion-hooks t)
2244 (mail-parse-charset gnus-newsgroup-charset)
2245 (mail-parse-ignored-charsets
2246 (with-current-buffer gnus-summary-buffer
2247 gnus-newsgroup-ignored-charsets)))
2248 (mail-decode-encoded-word-region (point-min) (point-max)))))
2250 (defun article-decode-charset (&optional prompt)
2251 "Decode charset-encoded text in the article.
2252 If PROMPT (the prefix), prompt for a coding system to use."
2254 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2255 (inhibit-read-only t)
2256 (mail-parse-charset gnus-newsgroup-charset)
2257 (mail-parse-ignored-charsets
2258 (save-excursion (condition-case nil
2259 (set-buffer gnus-summary-buffer)
2261 gnus-newsgroup-ignored-charsets))
2262 ct cte ctl charset format)
2265 (article-narrow-to-head)
2266 (setq ct (message-fetch-field "Content-Type" t)
2267 cte (message-fetch-field "Content-Transfer-Encoding" t)
2268 ctl (and ct (ignore-errors
2269 (mail-header-parse-content-type ct)))
2272 (mm-read-coding-system "Charset to decode: "))
2274 (mail-content-type-get ctl 'charset)))
2275 format (and ctl (mail-content-type-get ctl 'format)))
2277 (setq cte (mail-header-strip cte)))
2278 (if (and ctl (not (string-match "/" (car ctl))))
2280 (goto-char (point-max)))
2283 (narrow-to-region (point) (point-max))
2284 (when (and (eq mail-parse-charset 'gnus-decoded)
2285 (eq (mm-body-7-or-8) '8bit))
2286 ;; The text code could have been decoded.
2287 (setq charset mail-parse-charset))
2288 (when (and (or (not ctl)
2289 (equal (car ctl) "text/plain"))
2290 (not format)) ;; article with format will decode later.
2292 charset (and cte (intern (downcase
2293 (gnus-strip-whitespace cte))))
2296 (defun article-decode-encoded-words ()
2297 "Remove encoded-word encoding from headers."
2298 (let ((inhibit-point-motion-hooks t)
2299 (mail-parse-charset gnus-newsgroup-charset)
2300 (mail-parse-ignored-charsets
2301 (save-excursion (condition-case nil
2302 (set-buffer gnus-summary-buffer)
2304 gnus-newsgroup-ignored-charsets))
2305 (inhibit-read-only t))
2307 (article-narrow-to-head)
2308 (funcall gnus-decode-header-function (point-min) (point-max)))))
2310 (defun article-decode-group-name ()
2311 "Decode group names in `Newsgroups:'."
2312 (let ((inhibit-point-motion-hooks t)
2313 (inhibit-read-only t)
2314 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2315 (when (and (or gnus-group-name-charset-method-alist
2316 gnus-group-name-charset-group-alist)
2317 (gnus-buffer-live-p gnus-original-article-buffer))
2319 (article-narrow-to-head)
2320 (with-current-buffer gnus-original-article-buffer
2321 (goto-char (point-min)))
2322 (while (re-search-forward
2323 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2324 (replace-match (save-match-data
2325 (gnus-decode-newsgroups
2326 ;; XXX how to use data in article buffer?
2327 (with-current-buffer gnus-original-article-buffer
2329 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2332 gnus-newsgroup-name method))
2334 (goto-char (point-min))
2335 (with-current-buffer gnus-original-article-buffer
2336 (goto-char (point-min)))
2337 (while (re-search-forward
2338 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2339 (replace-match (save-match-data
2340 (gnus-decode-newsgroups
2341 ;; XXX how to use data in article buffer?
2342 (with-current-buffer gnus-original-article-buffer
2344 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2347 gnus-newsgroup-name method))
2350 (autoload 'idna-to-unicode "idna")
2352 (defun article-decode-idna-rhs ()
2353 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2356 (let ((inhibit-point-motion-hooks t)
2357 (inhibit-read-only t))
2358 (article-narrow-to-head)
2359 (goto-char (point-min))
2360 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2362 (when (save-match-data
2363 (and (setq ace (match-string 1))
2365 (and (re-search-backward "^[^ \t]" nil t)
2366 (looking-at "From\\|To\\|Cc")))
2367 (setq unicode (idna-to-unicode ace))))
2368 (unless (string= ace unicode)
2369 (replace-match unicode nil nil nil 1)))))))))
2371 (defun article-de-quoted-unreadable (&optional force read-charset)
2372 "Translate a quoted-printable-encoded article.
2373 If FORCE, decode the article whether it is marked as quoted-printable
2375 If READ-CHARSET, ask for a coding system."
2376 (interactive (list 'force current-prefix-arg))
2378 (let ((inhibit-read-only t) type charset)
2379 (if (gnus-buffer-live-p gnus-original-article-buffer)
2380 (with-current-buffer gnus-original-article-buffer
2382 (gnus-fetch-field "content-transfer-encoding"))
2383 (let* ((ct (gnus-fetch-field "content-type"))
2386 (mail-header-parse-content-type ct)))))
2387 (setq charset (and ctl
2388 (mail-content-type-get ctl 'charset)))
2389 (if (stringp charset)
2390 (setq charset (intern (downcase charset)))))))
2392 (setq charset (mm-read-coding-system "Charset: " charset)))
2394 (setq charset gnus-newsgroup-charset))
2396 (and type (let ((case-fold-search t))
2397 (string-match "quoted-printable" type))))
2399 (quoted-printable-decode-region
2400 (point) (point-max) (mm-charset-to-coding-system charset))))))
2402 (defun article-de-base64-unreadable (&optional force read-charset)
2403 "Translate a base64 article.
2404 If FORCE, decode the article whether it is marked as base64 not.
2405 If READ-CHARSET, ask for a coding system."
2406 (interactive (list 'force current-prefix-arg))
2408 (let ((inhibit-read-only t) type charset)
2409 (if (gnus-buffer-live-p gnus-original-article-buffer)
2410 (with-current-buffer gnus-original-article-buffer
2412 (gnus-fetch-field "content-transfer-encoding"))
2413 (let* ((ct (gnus-fetch-field "content-type"))
2416 (mail-header-parse-content-type ct)))))
2417 (setq charset (and ctl
2418 (mail-content-type-get ctl 'charset)))
2419 (if (stringp charset)
2420 (setq charset (intern (downcase charset)))))))
2422 (setq charset (mm-read-coding-system "Charset: " charset)))
2424 (setq charset gnus-newsgroup-charset))
2426 (and type (let ((case-fold-search t))
2427 (string-match "base64" type))))
2430 (narrow-to-region (point) (point-max))
2431 (base64-decode-region (point-min) (point-max))
2432 (mm-decode-coding-region
2433 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2438 (defun article-decode-HZ ()
2439 "Translate a HZ-encoded article."
2443 (let ((inhibit-read-only t))
2444 (rfc1843-decode-region (point-min) (point-max)))))
2446 (defun article-unsplit-urls ()
2447 "Remove the newlines that some other mailers insert into URLs."
2450 (let ((inhibit-read-only t))
2451 (goto-char (point-min))
2452 (while (re-search-forward
2453 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2454 (replace-match "\\1\\3" t)))
2455 (when (interactive-p)
2456 (gnus-treat-article nil))))
2459 (defun article-wash-html (&optional read-charset)
2460 "Format an HTML article.
2461 If READ-CHARSET, ask for a coding system."
2464 (let ((inhibit-read-only t)
2466 (when (gnus-buffer-live-p gnus-original-article-buffer)
2467 (with-current-buffer gnus-original-article-buffer
2468 (let* ((ct (gnus-fetch-field "content-type"))
2471 (mail-header-parse-content-type ct)))))
2472 (setq charset (and ctl
2473 (mail-content-type-get ctl 'charset)))
2474 (when (stringp charset)
2475 (setq charset (intern (downcase charset)))))))
2477 (setq charset (mm-read-coding-system "Charset: " charset)))
2479 (setq charset gnus-newsgroup-charset))
2481 (save-window-excursion
2483 (narrow-to-region (point) (point-max))
2484 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2485 (entry (assq func mm-text-html-washer-alist)))
2487 (setq func (cdr entry)))
2492 (apply (car func) (cdr func))))))))))
2494 (defun gnus-article-wash-html-with-w3 ()
2495 "Wash the current buffer with w3."
2497 (let ((w3-strict-width (window-width))
2498 (url-standalone-mode t)
2499 (url-gateway-unplugged t)
2500 (w3-honor-stylesheets nil))
2502 (w3-region (point-min) (point-max))
2505 (defun gnus-article-wash-html-with-w3m ()
2506 "Wash the current buffer with emacs-w3m."
2509 (narrow-to-region (point) (point-max))
2510 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2511 w3m-force-redisplay)
2512 (w3m-region (point-min) (point-max)))
2513 (when (and mm-inline-text-html-with-w3m-keymap
2514 (boundp 'w3m-minor-mode-map)
2516 (add-text-properties
2517 (point-min) (point-max)
2518 (list 'keymap w3m-minor-mode-map
2519 ;; Put the mark meaning this part was rendered by emacs-w3m.
2520 'mm-inline-text-html-with-w3m t)))))
2522 (defun article-hide-list-identifiers ()
2523 "Remove list identifies from the Subject header.
2524 The `gnus-list-identifiers' variable specifies what to do."
2526 (let ((inhibit-point-motion-hooks t)
2527 (regexp (if (consp gnus-list-identifiers)
2528 (mapconcat 'identity gnus-list-identifiers " *\\|")
2529 gnus-list-identifiers))
2530 (inhibit-read-only t))
2534 (article-narrow-to-head)
2535 (goto-char (point-min))
2536 (while (re-search-forward
2537 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2539 (delete-region (match-beginning 2) (match-end 0))
2540 (beginning-of-line))
2541 (when (re-search-forward
2542 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2543 (delete-region (match-beginning 1) (match-end 1))))))))
2545 (defun article-hide-pem (&optional arg)
2546 "Toggle hiding of any PEM headers and signatures in the current article.
2547 If given a negative prefix, always show; if given a positive prefix,
2549 (interactive (gnus-article-hidden-arg))
2550 (unless (gnus-article-check-hidden-text 'pem arg)
2552 (let ((inhibit-read-only t) end)
2553 (goto-char (point-min))
2554 ;; Hide the horrendously ugly "header".
2555 (when (and (search-forward
2556 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2558 (setq end (1+ (match-beginning 0))))
2559 (gnus-add-wash-type 'pem)
2560 (gnus-article-hide-text-type
2562 (if (search-forward "\n\n" nil t)
2566 ;; Hide the trailer as well
2567 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2569 (gnus-article-hide-text-type
2570 (match-beginning 0) (match-end 0) 'pem)))))))
2572 (defun article-strip-banner ()
2573 "Strip the banners specified by the `banner' group parameter and by
2574 `gnus-article-address-banner-alist'."
2578 (let ((inhibit-point-motion-hooks t))
2579 (when (gnus-parameter-banner gnus-newsgroup-name)
2580 (article-really-strip-banner
2581 (gnus-parameter-banner gnus-newsgroup-name)))
2582 (when gnus-article-address-banner-alist
2583 ;; It is necessary to encode from fields before checking,
2584 ;; because `mail-header-parse-addresses' does not work
2585 ;; (reliably) on decoded headers. And more, it is
2586 ;; impossible to use `gnus-fetch-original-field' here,
2587 ;; because `article-strip-banner' may be called in draft
2588 ;; buffers to preview them.
2589 (let ((from (save-restriction
2591 (article-narrow-to-head)
2592 (mail-fetch-field "from"))))
2595 (caar (mail-header-parse-addresses
2596 (mail-encode-encoded-word-string from)))))
2598 (dolist (pair gnus-article-address-banner-alist)
2599 (when (string-match (car pair) from)
2601 (article-really-strip-banner (cdr pair)))))))))))))
2603 (defun article-really-strip-banner (banner)
2604 "Strip the banner specified by the argument."
2607 (let ((inhibit-point-motion-hooks t)
2608 (gnus-signature-limit nil)
2609 (inhibit-read-only t))
2612 ((eq banner 'signature)
2613 (when (gnus-article-narrow-to-signature)
2616 (delete-region (point) (point-max))))
2618 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2619 (while (re-search-forward banner nil t)
2620 (delete-region (match-beginning 0) (match-end 0)))))
2622 (while (re-search-forward banner nil t)
2623 (delete-region (match-beginning 0) (match-end 0)))))))))
2625 (defun article-babel ()
2626 "Translate article using an online translation service."
2629 (gnus-with-article-buffer
2630 (when (article-goto-body)
2631 (let* ((start (point))
2633 (orig (buffer-substring start end))
2634 (trans (babel-as-string orig)))
2636 (narrow-to-region start end)
2637 (delete-region start end)
2640 (defun article-hide-signature (&optional arg)
2641 "Hide the signature in the current article.
2642 If given a negative prefix, always show; if given a positive prefix,
2644 (interactive (gnus-article-hidden-arg))
2645 (unless (gnus-article-check-hidden-text 'signature arg)
2648 (let ((inhibit-read-only t))
2649 (when (gnus-article-narrow-to-signature)
2650 (gnus-article-hide-text-type
2651 (point-min) (point-max) 'signature))))))
2652 (gnus-set-mode-line 'article))
2654 (defun article-strip-headers-in-body ()
2655 "Strip offensive headers from bodies."
2659 (let ((case-fold-search t))
2660 (when (looking-at "x-no-archive:")
2661 (gnus-delete-line)))))
2663 (defun article-strip-leading-blank-lines ()
2664 "Remove all blank lines from the beginning of the article."
2667 (let ((inhibit-point-motion-hooks t)
2668 (inhibit-read-only t))
2669 (when (article-goto-body)
2670 (while (and (not (eobp))
2671 (looking-at "[ \t]*$"))
2672 (gnus-delete-line))))))
2674 (defun article-narrow-to-head ()
2675 "Narrow the buffer to the head of the message.
2676 Point is left at the beginning of the narrowed-to region."
2678 (goto-char (point-min))
2679 (if (search-forward "\n\n" nil 1)
2682 (goto-char (point-min)))
2684 (defun article-goto-body ()
2685 "Place point at the start of the body."
2686 (goto-char (point-min))
2688 ;; This variable is only bound when dealing with separate
2690 (article-goto-body-goes-to-point-min-p
2692 ((search-forward "\n\n" nil t)
2695 (goto-char (point-max))
2698 (defun article-strip-multiple-blank-lines ()
2699 "Replace consecutive blank lines with one empty line."
2702 (let ((inhibit-point-motion-hooks t)
2703 (inhibit-read-only t))
2704 ;; First make all blank lines empty.
2706 (while (re-search-forward "^[ \t]+$" nil t)
2707 (unless (gnus-annotation-in-region-p
2708 (match-beginning 0) (match-end 0))
2709 (replace-match "" nil t)))
2710 ;; Then replace multiple empty lines with a single empty line.
2712 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2713 (unless (gnus-annotation-in-region-p
2714 (match-beginning 0) (match-end 0))
2715 (delete-region (match-beginning 1) (match-end 1)))))))
2717 (defun article-strip-leading-space ()
2718 "Remove all white space from the beginning of the lines in the article."
2721 (let ((inhibit-point-motion-hooks t)
2722 (inhibit-read-only t))
2724 (while (re-search-forward "^[ \t]+" nil t)
2725 (replace-match "" t t)))))
2727 (defun article-strip-trailing-space ()
2728 "Remove all white space from the end of the lines in the article."
2731 (let ((inhibit-point-motion-hooks t)
2732 (inhibit-read-only t))
2734 (while (re-search-forward "[ \t]+$" nil t)
2735 (replace-match "" t t)))))
2737 (defun article-strip-blank-lines ()
2738 "Strip leading, trailing and multiple blank lines."
2740 (article-strip-leading-blank-lines)
2741 (article-remove-trailing-blank-lines)
2742 (article-strip-multiple-blank-lines))
2744 (defun article-strip-all-blank-lines ()
2745 "Strip all blank lines."
2748 (let ((inhibit-point-motion-hooks t)
2749 (inhibit-read-only t))
2751 (while (re-search-forward "^[ \t]*\n" nil t)
2752 (replace-match "" t t)))))
2754 (defun gnus-article-narrow-to-signature ()
2755 "Narrow to the signature; return t if a signature is found, else nil."
2756 (let ((inhibit-point-motion-hooks t))
2757 (when (gnus-article-search-signature)
2759 ;; Check whether we have some limits to what we consider
2760 ;; to be a signature.
2761 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2762 (list gnus-signature-limit)))
2764 (while (setq limit (pop limits))
2765 (if (or (and (integerp limit)
2766 (< (- (point-max) (point)) limit))
2768 (< (count-lines (point) (point-max)) limit))
2769 (and (functionp limit)
2771 (and (stringp limit)
2772 (not (re-search-forward limit nil t))))
2773 () ; This limit did not succeed.
2777 (narrow-to-region (point) (point-max))
2780 (defun gnus-article-search-signature ()
2781 "Search the current buffer for the signature separator.
2782 Put point at the beginning of the signature separator."
2783 (let ((cur (point)))
2784 (goto-char (point-max))
2785 (if (if (stringp gnus-signature-separator)
2786 (re-search-backward gnus-signature-separator nil t)
2787 (let ((seps gnus-signature-separator))
2789 (not (re-search-backward (car seps) nil t)))
2796 (defun gnus-article-hidden-arg ()
2797 "Return the current prefix arg as a number, or 0 if no prefix."
2798 (list (if current-prefix-arg
2799 (prefix-numeric-value current-prefix-arg)
2802 (defun gnus-article-check-hidden-text (type arg)
2803 "Return nil if hiding is necessary.
2804 Arg can be nil or a number. nil and positive means hide, negative
2805 means show, 0 means toggle."
2808 (let ((hide (gnus-article-hidden-text-p type)))
2814 (gnus-article-show-hidden-text type)
2817 (if (eq hide 'hidden)
2819 (gnus-article-show-hidden-text type)
2823 (defun gnus-article-hidden-text-p (type)
2824 "Say whether the current buffer contains hidden text of type TYPE."
2825 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2827 (not (get-text-property pos 'invisible))
2828 (not (get-text-property pos 'dummy-invisible)))
2830 (text-property-any (1+ pos) (point-max) 'article-type type)))
2835 (defun gnus-article-show-hidden-text (type &optional dummy)
2836 "Show all hidden text of type TYPE.
2837 Originally it is hide instead of DUMMY."
2838 (let ((inhibit-read-only t)
2839 (inhibit-point-motion-hooks t))
2840 (gnus-remove-text-properties-when
2842 (point-min) (point-max)
2843 (cons 'article-type (cons type
2844 gnus-hidden-properties)))
2845 (gnus-delete-wash-type type)))
2847 (defconst article-time-units
2848 `((year . ,(* 365.25 24 60 60))
2849 (week . ,(* 7 24 60 60))
2850 (day . ,(* 24 60 60))
2854 "Mapping from time units to seconds.")
2856 (defun gnus-article-forward-header ()
2857 "Move point to the start of the next header.
2858 If the current header is a continuation header, this can be several
2863 (if (looking-at "[ \t]+[^ \t]")
2867 (defun article-date-ut (&optional type highlight)
2868 "Convert DATE date to universal time in the current article.
2869 If TYPE is `local', convert to local time; if it is `lapsed', output
2870 how much time has lapsed since DATE. For `lapsed', the value of
2871 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2872 should replace the \"Date:\" one, or should be added below it."
2873 (interactive (list 'ut t))
2874 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2875 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
2879 (article-lapsed-timer
2883 (case-fold-search t)
2884 (inhibit-read-only t)
2885 (inhibit-point-motion-hooks t)
2886 pos date bface eface)
2890 (goto-char (point-min))
2891 (while (or (setq date (get-text-property (setq pos (point))
2893 (when (setq pos (next-single-property-change
2894 (point) 'original-date))
2895 (setq date (get-text-property pos 'original-date))
2897 (narrow-to-region pos (or (text-property-any pos (point-max)
2900 (goto-char (point-min))
2901 (when (re-search-forward tdate-regexp nil t)
2902 (setq bface (get-text-property (point-at-bol) 'face)
2903 eface (get-text-property (1- (point-at-eol)) 'face)))
2904 (goto-char (point-min))
2906 ;; Delete any old Date headers.
2907 (while (re-search-forward date-regexp nil t)
2909 (delete-region (point-at-bol) (progn
2910 (gnus-article-forward-header)
2912 (delete-region (point-at-bol) (progn
2913 (gnus-article-forward-header)
2916 (setq pos (point))))
2917 (when (and (not pos)
2918 (re-search-forward tdate-regexp nil t))
2920 (gnus-goto-char pos)
2921 (insert (article-make-date-line date (or type 'ut)))
2927 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2928 (put-text-property (match-beginning 1) (1+ (match-end 1))
2930 (put-text-property (match-beginning 2) (match-end 2)
2932 (put-text-property (point-min) (1- (point-max)) 'original-date date)
2933 (goto-char (point-max))
2936 (defun article-make-date-line (date type)
2937 "Return a DATE line of TYPE."
2938 (unless (memq type '(local ut original user iso8601 lapsed english))
2939 (error "Unknown conversion type: %s" type))
2941 (let ((time (date-to-time date)))
2943 ;; Convert to the local timezone.
2945 (concat "Date: " (message-make-date time)))
2946 ;; Convert to Universal Time.
2951 (let* ((e (parse-time-string date))
2952 (tm (apply 'encode-time e))
2954 (ls (- (cadr tm) (car (current-time-zone time)))))
2955 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2956 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2960 ;; Get the original date from the article.
2961 ((eq type 'original)
2962 (concat "Date: " (if (string-match "\n+$" date)
2963 (substring date 0 (match-beginning 0))
2965 ;; Let the user define the format.
2967 (let ((format (or (condition-case nil
2968 (with-current-buffer gnus-summary-buffer
2969 gnus-article-time-format)
2971 gnus-article-time-format)))
2972 (if (functionp format)
2973 (funcall format time)
2974 (concat "Date: " (format-time-string format time)))))
2977 (let ((tz (car (current-time-zone time))))
2980 (format-time-string "%Y%m%dT%H%M%S" time)
2981 (format "%s%02d%02d"
2982 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2983 (/ (% (abs tz) 3600) 60)))))
2984 ;; Do an X-Sent lapsed format.
2986 ;; If the date is seriously mangled, the timezone functions are
2987 ;; liable to bug out, so we ignore all errors.
2988 (let* ((now (current-time))
2989 (real-time (subtract-time now time))
2990 (real-sec (and real-time
2991 (+ (* (float (car real-time)) 65536)
2993 (sec (and real-time (abs real-sec)))
3003 ;; This is a bit convoluted, but basically we go
3004 ;; through the time units for years, weeks, etc,
3005 ;; and divide things to see whether that results
3006 ;; in positive answers.
3009 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3010 ;; The (remaining) seconds are too few to
3011 ;; be divided into this time unit.
3013 ;; It's big enough, so we output it.
3014 (setq sec (- sec (* num (cdr unit))))
3016 (concat (if prev ", " "") (int-to-string
3018 " " (symbol-name (car unit))
3019 (if (> num 1) "s" ""))
3021 article-time-units "")
3022 ;; If dates are odd, then it might appear like the
3023 ;; article was sent in the future.
3026 " in the future"))))))
3027 ;; Display the date in proper English
3029 (let ((dtime (decode-time time)))
3032 (number-to-string (nth 3 dtime))
3033 (let ((digit (% (nth 3 dtime) 10)))
3035 ((memq (nth 3 dtime) '(11 12 13)) "th")
3041 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3043 (number-to-string (nth 5 dtime))
3045 (format "%02d" (nth 2 dtime))
3047 (format "%02d" (nth 1 dtime)))))))
3049 (format "Date: %s (from Gnus)" date))))
3051 (defun article-date-local (&optional highlight)
3052 "Convert the current article date to the local timezone."
3053 (interactive (list t))
3054 (article-date-ut 'local highlight))
3056 (defun article-date-english (&optional highlight)
3057 "Convert the current article date to something that is proper English."
3058 (interactive (list t))
3059 (article-date-ut 'english highlight))
3061 (defun article-date-original (&optional highlight)
3062 "Convert the current article date to what it was originally.
3063 This is only useful if you have used some other date conversion
3064 function and want to see what the date was before converting."
3065 (interactive (list t))
3066 (article-date-ut 'original highlight))
3068 (defun article-date-lapsed (&optional highlight)
3069 "Convert the current article date to time lapsed since it was sent."
3070 (interactive (list t))
3071 (article-date-ut 'lapsed highlight))
3073 (defun article-update-date-lapsed ()
3074 "Function to be run from a timer to update the lapsed time line."
3075 (let (deactivate-mark)
3080 (set-buffer (window-buffer w))
3081 (when (eq major-mode 'gnus-article-mode)
3082 (let ((mark (point-marker)))
3083 (goto-char (point-min))
3084 (when (re-search-forward "^X-Sent:" nil t)
3085 (article-date-lapsed t))
3086 (goto-char (marker-position mark))
3087 (move-marker mark nil))))
3090 (defun gnus-start-date-timer (&optional n)
3091 "Start a timer to update the X-Sent header in the article buffers.
3092 The numerical prefix says how frequently (in seconds) the function
3097 (gnus-stop-date-timer)
3098 (setq article-lapsed-timer
3099 (run-at-time 1 n 'article-update-date-lapsed)))
3101 (defun gnus-stop-date-timer ()
3102 "Stop the X-Sent timer."
3104 (when article-lapsed-timer
3105 (nnheader-cancel-timer article-lapsed-timer)
3106 (setq article-lapsed-timer nil)))
3108 (defun article-date-user (&optional highlight)
3109 "Convert the current article date to the user-defined format.
3110 This format is defined by the `gnus-article-time-format' variable."
3111 (interactive (list t))
3112 (article-date-ut 'user highlight))
3114 (defun article-date-iso8601 (&optional highlight)
3115 "Convert the current article date to ISO8601."
3116 (interactive (list t))
3117 (article-date-ut 'iso8601 highlight))
3119 (defmacro gnus-article-save-original-date (&rest forms)
3120 "Save the original date as a text property and evaluate FORMS."
3121 `(let* ((case-fold-search t)
3123 (goto-char (point-min))
3124 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3127 (date (when (and start
3128 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3130 (buffer-substring-no-properties start
3131 (match-beginning 0)))))
3132 (goto-char (point-max))
3133 (skip-chars-backward "\n")
3134 (put-text-property (point-min) (point) 'original-date date)
3136 (goto-char (point-max))
3137 (skip-chars-backward "\n")
3138 (put-text-property (point-min) (point) 'original-date date)))
3140 ;; (defun article-show-all ()
3141 ;; "Show all hidden text in the article buffer."
3144 ;; (let ((inhibit-read-only t))
3145 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3147 (defun article-remove-leading-whitespace ()
3148 "Remove excessive whitespace from all headers."
3152 (let ((inhibit-read-only t))
3153 (article-narrow-to-head)
3154 (goto-char (point-min))
3155 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3156 (delete-region (match-beginning 1) (match-end 1)))))))
3158 (defun article-emphasize (&optional arg)
3159 "Emphasize text according to `gnus-emphasis-alist'."
3160 (interactive (gnus-article-hidden-arg))
3161 (unless (gnus-article-check-hidden-text 'emphasis arg)
3165 (with-current-buffer gnus-summary-buffer
3166 gnus-article-emphasis-alist)
3168 gnus-emphasis-alist))
3169 (inhibit-read-only t)
3170 (props (append '(article-type emphasis)
3171 gnus-hidden-properties))
3172 regexp elem beg invisible visible face)
3175 (while (setq elem (pop alist))
3177 (setq regexp (car elem)
3178 invisible (nth 1 elem)
3179 visible (nth 2 elem)
3181 (while (re-search-forward regexp nil t)
3182 (when (and (match-beginning visible) (match-beginning invisible))
3183 (gnus-article-hide-text
3184 (match-beginning invisible) (match-end invisible) props)
3185 (gnus-article-unhide-text-type
3186 (match-beginning visible) (match-end visible) 'emphasis)
3187 (gnus-put-overlay-excluding-newlines
3188 (match-beginning visible) (match-end visible) 'face face)
3189 (gnus-add-wash-type 'emphasis)
3190 (goto-char (match-end invisible)))))))))
3192 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3193 "Setup newsgroup emphasis alist."
3194 (unless gnus-article-emphasis-alist
3195 (let ((name (and gnus-newsgroup-name
3196 (gnus-group-real-name gnus-newsgroup-name))))
3197 (make-local-variable 'gnus-article-emphasis-alist)
3198 (setq gnus-article-emphasis-alist
3200 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3201 (while (setq elem (pop alist))
3202 (when (and name (string-match (car elem) name))
3204 highlight (copy-sequence (cdr elem)))))
3206 (copy-sequence highlight-words)
3207 (if gnus-newsgroup-name
3208 (copy-sequence (gnus-group-find-parameter
3209 gnus-newsgroup-name 'highlight-words t)))
3210 gnus-emphasis-alist)))))
3213 (defvar gnus-summary-article-menu)
3214 (defvar gnus-summary-post-menu))
3216 ;;; Saving functions.
3218 (defun gnus-article-save (save-buffer file &optional num)
3219 "Save the currently selected article."
3220 (unless gnus-save-all-headers
3221 ;; Remove headers according to `gnus-saved-headers'.
3222 (let ((gnus-visible-headers
3223 (or gnus-saved-headers gnus-visible-headers))
3224 (gnus-article-buffer save-buffer))
3226 (set-buffer save-buffer)
3227 (article-hide-headers 1 t))))
3228 (save-window-excursion
3229 (if (not gnus-default-article-saver)
3230 (error "No default saver is defined")
3231 ;; !!! Magic! The saving functions all save
3232 ;; `gnus-save-article-buffer' (or so they think), but we
3233 ;; bind that variable to our save-buffer.
3234 (set-buffer gnus-article-buffer)
3235 (let* ((gnus-save-article-buffer save-buffer)
3238 ((not gnus-prompt-before-saving) 'default)
3239 ((eq gnus-prompt-before-saving 'always) nil)
3241 (gnus-number-of-articles-to-be-saved
3242 (when (eq gnus-prompt-before-saving t)
3244 (set-buffer gnus-article-current-summary)
3245 (funcall gnus-default-article-saver filename)))))
3247 (defun gnus-read-save-file-name (prompt &optional filename
3248 function group headers variable)
3250 (funcall function group headers (symbol-value variable)))
3255 ((eq filename 'default)
3261 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3264 (if (and gnus-number-of-articles-to-be-saved
3265 (> gnus-number-of-articles-to-be-saved 1))
3266 (format "these %d articles"
3267 gnus-number-of-articles-to-be-saved)
3270 ;; Let the split methods have their say.
3272 ;; No split name was found.
3275 (concat prompt " (default "
3276 (file-name-nondirectory default-name) ") ")
3277 (file-name-directory default-name)
3279 ;; A single group name is returned.
3280 ((stringp split-name)
3282 (funcall function split-name headers
3283 (symbol-value variable)))
3285 (concat prompt " (default "
3286 (file-name-nondirectory default-name) ") ")
3287 (file-name-directory default-name)
3289 ;; A single split name was found
3290 ((= 1 (length split-name))
3291 (let* ((name (expand-file-name
3293 gnus-article-save-directory))
3294 (dir (cond ((file-directory-p name)
3295 (file-name-as-directory name))
3296 ((file-exists-p name) name)
3297 (t gnus-article-save-directory))))
3299 (concat prompt " (default " name ") ")
3301 ;; A list of splits was found.
3303 (setq split-name (nreverse split-name))
3305 (let ((file-name-history
3306 (nconc split-name file-name-history)))
3310 (concat prompt " (`M-p' for defaults) ")
3311 gnus-article-save-directory
3313 gnus-article-save-directory)))
3314 (car (push result file-name-history)))))))
3315 ;; Create the directory.
3316 (gnus-make-directory (file-name-directory file))
3317 ;; If we have read a directory, we append the default file name.
3318 (when (file-directory-p file)
3319 (setq file (expand-file-name (file-name-nondirectory
3321 (file-name-as-directory file))))
3322 ;; Possibly translate some characters.
3323 (nnheader-translate-file-chars file))))))
3324 (gnus-make-directory (file-name-directory result))
3325 (set variable result)))
3327 (defun gnus-article-archive-name (group)
3328 "Return the first instance of an \"Archive-name\" in the current buffer."
3329 (let ((case-fold-search t))
3330 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3331 (nnheader-concat gnus-article-save-directory
3332 (match-string 1)))))
3334 (defun gnus-article-nndoc-name (group)
3335 "If GROUP is an nndoc group, return the name of the parent group."
3336 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3337 (gnus-group-get-parameter group 'save-article-group)))
3339 (defun gnus-summary-save-in-rmail (&optional filename)
3340 "Append this article to Rmail file.
3341 Optional argument FILENAME specifies file name.
3342 Directory to save to is default to `gnus-article-save-directory'."
3343 (setq filename (gnus-read-save-file-name
3344 "Save %s in rmail file:" filename
3345 gnus-rmail-save-name gnus-newsgroup-name
3346 gnus-current-headers 'gnus-newsgroup-last-rmail))
3347 (gnus-eval-in-buffer-window gnus-save-article-buffer
3351 (gnus-output-to-rmail filename))))
3354 (defun gnus-summary-save-in-mail (&optional filename)
3355 "Append this article to Unix mail file.
3356 Optional argument FILENAME specifies file name.
3357 Directory to save to is default to `gnus-article-save-directory'."
3358 (setq filename (gnus-read-save-file-name
3359 "Save %s in Unix mail file:" filename
3360 gnus-mail-save-name gnus-newsgroup-name
3361 gnus-current-headers 'gnus-newsgroup-last-mail))
3362 (gnus-eval-in-buffer-window gnus-save-article-buffer
3366 (if (and (file-readable-p filename)
3367 (file-regular-p filename)
3368 (mail-file-babyl-p filename))
3369 (rmail-output-to-rmail-file filename t)
3370 (gnus-output-to-mail filename)))))
3373 (defun gnus-summary-save-in-file (&optional filename overwrite)
3374 "Append this article to file.
3375 Optional argument FILENAME specifies file name.
3376 Directory to save to is default to `gnus-article-save-directory'."
3377 (setq filename (gnus-read-save-file-name
3378 "Save %s in file:" filename
3379 gnus-file-save-name gnus-newsgroup-name
3380 gnus-current-headers 'gnus-newsgroup-last-file))
3381 (gnus-eval-in-buffer-window gnus-save-article-buffer
3385 (when (and overwrite
3386 (file-exists-p filename))
3387 (delete-file filename))
3388 (gnus-output-to-file filename))))
3391 (defun gnus-summary-write-to-file (&optional filename)
3392 "Write this article to a file, overwriting it if the file exists.
3393 Optional argument FILENAME specifies file name.
3394 The directory to save in defaults to `gnus-article-save-directory'."
3395 (gnus-summary-save-in-file nil t))
3397 (defun gnus-summary-save-body-in-file (&optional filename)
3398 "Append this article body to a file.
3399 Optional argument FILENAME specifies file name.
3400 The directory to save in defaults to `gnus-article-save-directory'."
3401 (setq filename (gnus-read-save-file-name
3402 "Save %s body in file:" filename
3403 gnus-file-save-name gnus-newsgroup-name
3404 gnus-current-headers 'gnus-newsgroup-last-file))
3405 (gnus-eval-in-buffer-window gnus-save-article-buffer
3409 (when (article-goto-body)
3410 (narrow-to-region (point) (point-max)))
3411 (gnus-output-to-file filename))))
3414 (defun gnus-summary-save-in-pipe (&optional command)
3415 "Pipe this article to subprocess."
3417 (cond ((and (eq command 'default)
3418 gnus-last-shell-command)
3419 gnus-last-shell-command)
3424 "Shell command on %s: "
3425 (if (and gnus-number-of-articles-to-be-saved
3426 (> gnus-number-of-articles-to-be-saved 1))
3427 (format "these %d articles"
3428 gnus-number-of-articles-to-be-saved)
3430 gnus-last-shell-command))))
3431 (when (string-equal command "")
3432 (if gnus-last-shell-command
3433 (setq command gnus-last-shell-command)
3434 (error "A command is required")))
3435 (gnus-eval-in-buffer-window gnus-article-buffer
3438 (shell-command-on-region (point-min) (point-max) command nil)))
3439 (setq gnus-last-shell-command command))
3441 (defun gnus-summary-pipe-to-muttprint (&optional command)
3442 "Pipe this article to muttprint."
3443 (setq command (read-string
3444 "Print using command: " gnus-summary-muttprint-program
3445 nil gnus-summary-muttprint-program))
3446 (gnus-summary-save-in-pipe command))
3448 ;;; Article file names when saving.
3450 (defun gnus-capitalize-newsgroup (newsgroup)
3451 "Capitalize NEWSGROUP name."
3452 (when (not (zerop (length newsgroup)))
3453 (concat (char-to-string (upcase (aref newsgroup 0)))
3454 (substring newsgroup 1))))
3456 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3457 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3458 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3459 Otherwise, it is like ~/News/news/group/num."
3462 (concat (if (gnus-use-long-file-name 'not-save)
3463 (gnus-capitalize-newsgroup newsgroup)
3464 (gnus-newsgroup-directory-form newsgroup))
3465 "/" (int-to-string (mail-header-number headers)))
3466 gnus-article-save-directory)))
3468 (string-equal (file-name-directory default)
3469 (file-name-directory last-file))
3470 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3472 (or last-file default))))
3474 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3475 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3476 If variable `gnus-use-long-file-name' is non-nil, it is
3477 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3480 (concat (if (gnus-use-long-file-name 'not-save)
3482 (gnus-newsgroup-directory-form newsgroup))
3483 "/" (int-to-string (mail-header-number headers)))
3484 gnus-article-save-directory)))
3486 (string-equal (file-name-directory default)
3487 (file-name-directory last-file))
3488 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3490 (or last-file default))))
3492 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3493 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3494 If variable `gnus-use-long-file-name' is non-nil, it is
3495 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3498 (if (gnus-use-long-file-name 'not-save)
3501 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3503 gnus-article-save-directory)))
3505 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3506 "Generate file name from sender."
3507 (let ((from (mail-header-from headers)))
3509 (if (and from (string-match "\\([^ <]+\\)@" from))
3510 (match-string 1 from)
3512 gnus-article-save-directory)))
3514 (defun article-verify-x-pgp-sig ()
3517 (if (gnus-buffer-live-p gnus-original-article-buffer)
3518 (let ((sig (with-current-buffer gnus-original-article-buffer
3519 (gnus-fetch-field "X-PGP-Sig")))
3523 (mml2015-clear-verify-function))
3525 (insert-buffer-substring gnus-original-article-buffer)
3526 (setq items (split-string sig))
3527 (message-narrow-to-head)
3528 (let ((inhibit-point-motion-hooks t)
3529 (case-fold-search t))
3530 ;; Don't verify multiple headers.
3531 (setq headers (mapconcat (lambda (header)
3533 (mail-fetch-field header)
3535 (split-string (nth 1 items) ",") "")))
3536 (delete-region (point-min) (point-max))
3537 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3538 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3543 (if (looking-at "^-")
3546 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3547 (insert "Version: " (car items) "\n\n")
3548 (insert (mapconcat 'identity (cddr items) "\n"))
3549 (insert "\n-----END PGP SIGNATURE-----\n")
3550 (let ((mm-security-handle (list (format "multipart/signed"))))
3551 (mml2015-clean-buffer)
3552 (let ((coding-system-for-write (or gnus-newsgroup-charset
3554 (funcall (mml2015-clear-verify-function)))
3556 (or (mm-handle-multipart-ctl-parameter
3557 mm-security-handle 'gnus-details)
3558 (mm-handle-multipart-ctl-parameter
3559 mm-security-handle 'gnus-info)))))
3561 (let ((inhibit-read-only t) bface eface)
3563 (message-narrow-to-head)
3564 (goto-char (point-max))
3566 (setq bface (get-text-property (point-at-bol) 'face)
3567 eface (get-text-property (1- (point-at-eol)) 'face))
3568 (message-remove-header "X-Gnus-PGP-Verify")
3569 (if (re-search-forward "^X-PGP-Sig:" nil t)
3571 (goto-char (point-max)))
3572 (narrow-to-region (point) (point))
3573 (insert "X-Gnus-PGP-Verify: " info "\n")
3574 (goto-char (point-min))
3577 (if (not (looking-at "^[ \t]"))
3581 (goto-char (point-min))
3582 (when (looking-at "\\([^:]+\\): *")
3583 (put-text-property (match-beginning 1) (1+ (match-end 1))
3585 (put-text-property (match-end 0) (point-max)
3586 'face eface)))))))))
3588 (defun article-verify-cancel-lock ()
3589 "Verify Cancel-Lock header."
3591 (if (gnus-buffer-live-p gnus-original-article-buffer)
3592 (canlock-verify gnus-original-article-buffer)))
3599 (setq afunc (car func)
3602 gfunc (intern (format "gnus-%s" func))))
3604 (when (fboundp afunc)
3605 `(lambda (&optional interactive &rest args)
3606 ,(documentation afunc t)
3607 (interactive (list t))
3609 (set-buffer gnus-article-buffer)
3611 (call-interactively ',afunc)
3612 (apply ',afunc args))))))))
3613 '(article-hide-headers
3614 article-verify-x-pgp-sig
3615 article-verify-cancel-lock
3616 article-hide-boring-headers
3617 article-treat-overstrike
3618 article-treat-ansi-sequences
3619 article-fill-long-lines
3620 article-capitalize-sentences
3622 article-remove-leading-whitespace
3623 article-display-x-face
3624 article-display-face
3625 article-de-quoted-unreadable
3626 article-de-base64-unreadable
3629 article-unsplit-urls
3630 article-hide-list-identifiers
3631 article-strip-banner
3634 article-hide-signature
3635 article-strip-headers-in-body
3636 article-remove-trailing-blank-lines
3637 article-strip-leading-blank-lines
3638 article-strip-multiple-blank-lines
3639 article-strip-leading-space
3640 article-strip-trailing-space
3641 article-strip-blank-lines
3642 article-strip-all-blank-lines
3644 article-date-english
3645 article-date-iso8601
3646 article-date-original
3648 article-decode-mime-words
3649 article-decode-charset
3650 article-decode-encoded-words
3654 article-treat-dumbquotes
3655 article-normalize-headers
3656 ;; (article-show-all . gnus-article-show-all-headers)
3660 ;;; Gnus article mode
3663 (put 'gnus-article-mode 'mode-class 'special)
3665 (set-keymap-parent gnus-article-mode-map widget-keymap)
3667 (gnus-define-keys gnus-article-mode-map
3668 " " gnus-article-goto-next-page
3669 "\177" gnus-article-goto-prev-page
3670 [delete] gnus-article-goto-prev-page
3671 [backspace] gnus-article-goto-prev-page
3672 "\C-c^" gnus-article-refer-article
3673 "h" gnus-article-show-summary
3674 "s" gnus-article-show-summary
3675 "\C-c\C-m" gnus-article-mail
3676 "?" gnus-article-describe-briefly
3677 "e" gnus-summary-edit-article
3678 "<" beginning-of-buffer
3680 "\C-c\C-i" gnus-info-find-node
3682 "R" gnus-article-reply-with-original
3683 "F" gnus-article-followup-with-original
3684 "\C-hk" gnus-article-describe-key
3685 "\C-hc" gnus-article-describe-key-briefly
3687 "\C-d" gnus-article-read-summary-keys
3688 "\M-*" gnus-article-read-summary-keys
3689 "\M-#" gnus-article-read-summary-keys
3690 "\M-^" gnus-article-read-summary-keys
3691 "\M-g" gnus-article-read-summary-keys)
3693 (substitute-key-definition
3694 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3696 (defun gnus-article-make-menu-bar ()
3697 (unless (boundp 'gnus-article-commands-menu)
3698 (gnus-summary-make-menu-bar))
3699 (gnus-turn-off-edit-menu 'article)
3700 (unless (boundp 'gnus-article-article-menu)
3702 gnus-article-article-menu gnus-article-mode-map ""
3704 ["Scroll forwards" gnus-article-goto-next-page t]
3705 ["Scroll backwards" gnus-article-goto-prev-page t]
3706 ["Show summary" gnus-article-show-summary t]
3707 ["Fetch Message-ID at point" gnus-article-refer-article t]
3708 ["Mail to address at point" gnus-article-mail t]
3709 ["Send a bug report" gnus-bug t]))
3712 gnus-article-treatment-menu gnus-article-mode-map ""
3713 ;; Fixme: this should use :active (and maybe :visible).
3715 ["Hide headers" gnus-article-hide-headers t]
3716 ["Hide signature" gnus-article-hide-signature t]
3717 ["Hide citation" gnus-article-hide-citation t]
3718 ["Treat overstrike" gnus-article-treat-overstrike t]
3719 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3720 ["Remove carriage return" gnus-article-remove-cr t]
3721 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3722 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3723 ["Remove base64" gnus-article-de-base64-unreadable t]
3724 ["Treat html" gnus-article-wash-html t]
3725 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3726 ["Decode HZ" gnus-article-decode-HZ t]))
3728 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3730 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3732 (gnus-run-hooks 'gnus-article-menu-hook)))
3734 (defun gnus-article-mode ()
3735 "Major mode for displaying an article.
3737 All normal editing commands are switched off.
3739 The following commands are available in addition to all summary mode
3741 \\<gnus-article-mode-map>
3742 \\[gnus-article-next-page]\t Scroll the article one page forwards
3743 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3744 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3745 \\[gnus-article-show-summary]\t Display the summary buffer
3746 \\[gnus-article-mail]\t Send a reply to the address near point
3747 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3748 \\[gnus-info-find-node]\t Go to the Gnus info node"
3750 (gnus-simplify-mode-line)
3751 (setq mode-name "Article")
3752 (setq major-mode 'gnus-article-mode)
3753 (make-local-variable 'minor-mode-alist)
3754 (use-local-map gnus-article-mode-map)
3755 (when (gnus-visual-p 'article-menu 'menu)
3756 (gnus-article-make-menu-bar)
3757 (when gnus-summary-tool-bar-map
3758 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3759 (gnus-update-format-specifications nil 'article-mode)
3760 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3761 (set (make-local-variable 'gnus-page-broken) nil)
3762 (make-local-variable 'gnus-button-marker-list)
3763 (make-local-variable 'gnus-article-current-summary)
3764 (make-local-variable 'gnus-article-mime-handles)
3765 (make-local-variable 'gnus-article-decoded-p)
3766 (make-local-variable 'gnus-article-mime-handle-alist)
3767 (make-local-variable 'gnus-article-wash-types)
3768 (make-local-variable 'gnus-article-image-alist)
3769 (make-local-variable 'gnus-article-charset)
3770 (make-local-variable 'gnus-article-ignored-charsets)
3771 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3772 (set (make-local-variable 'show-nonbreak-escape) nil)
3773 (gnus-set-default-directory)
3774 (buffer-disable-undo)
3775 (setq buffer-read-only t
3776 show-trailing-whitespace nil)
3777 (set-syntax-table gnus-article-mode-syntax-table)
3778 (mm-enable-multibyte)
3779 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3781 (defun gnus-article-setup-buffer ()
3782 "Initialize the article buffer."
3783 (let* ((name (if gnus-single-article-buffer "*Article*"
3784 (concat "*Article " gnus-newsgroup-name "*")))
3786 (progn (string-match "\\*Article" name)
3787 (concat " *Original Article"
3788 (substring name (match-end 0))))))
3789 (setq gnus-article-buffer name)
3790 (setq gnus-original-article-buffer original)
3791 (setq gnus-article-mime-handle-alist nil)
3792 ;; This might be a variable local to the summary buffer.
3793 (unless gnus-single-article-buffer
3795 (set-buffer gnus-summary-buffer)
3796 (setq gnus-article-buffer name)
3797 (setq gnus-original-article-buffer original)
3798 (gnus-set-global-variables)))
3799 (gnus-article-setup-highlight-words)
3800 ;; Init original article buffer.
3802 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3803 (mm-enable-multibyte)
3804 (setq major-mode 'gnus-original-article-mode)
3805 (make-local-variable 'gnus-original-article))
3806 (if (and (get-buffer name)
3807 (with-current-buffer name
3808 (if gnus-article-edit-mode
3809 (if (y-or-n-p "Article mode edit in progress; discard? ")
3811 (set-buffer-modified-p nil)
3812 (gnus-kill-buffer name)
3815 (error "Action aborted"))
3819 (set (make-local-variable 'gnus-article-edit-mode) nil)
3820 (when gnus-article-mime-handles
3821 (mm-destroy-parts gnus-article-mime-handles)
3822 (setq gnus-article-mime-handles nil))
3823 ;; Set it to nil in article-buffer!
3824 (setq gnus-article-mime-handle-alist nil)
3825 (buffer-disable-undo)
3826 (setq buffer-read-only t)
3827 ;; This list just keeps growing if we don't reset it.
3828 (setq gnus-button-marker-list nil)
3829 (unless (eq major-mode 'gnus-article-mode)
3830 (gnus-article-mode))
3833 (set-buffer (gnus-get-buffer-create name))
3835 (make-local-variable 'gnus-summary-buffer)
3836 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3837 (current-buffer)))))
3839 ;; Set article window start at LINE, where LINE is the number of lines
3840 ;; from the head of the article.
3841 (defun gnus-article-set-window-start (&optional line)
3843 (gnus-get-buffer-window gnus-article-buffer t)
3845 (set-buffer gnus-article-buffer)
3846 (goto-char (point-min))
3849 (gnus-message 6 "Moved to bookmark")
3850 (search-forward "\n\n" nil t)
3854 (defun gnus-article-prepare (article &optional all-headers header)
3855 "Prepare ARTICLE in article mode buffer.
3856 ARTICLE should either be an article number or a Message-ID.
3857 If ARTICLE is an id, HEADER should be the article headers.
3858 If ALL-HEADERS is non-nil, no headers are hidden."
3860 ;; Make sure we start in a summary buffer.
3861 (unless (eq major-mode 'gnus-summary-mode)
3862 (set-buffer gnus-summary-buffer))
3863 (setq gnus-summary-buffer (current-buffer))
3864 (let* ((gnus-article (if header (mail-header-number header) article))
3865 (summary-buffer (current-buffer))
3866 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3867 (group gnus-newsgroup-name)
3870 (gnus-article-setup-buffer)
3871 (set-buffer gnus-article-buffer)
3872 ;; Deactivate active regions.
3873 (when (and (boundp 'transient-mark-mode)
3874 transient-mark-mode)
3875 (setq mark-active nil))
3876 (if (not (setq result (let ((inhibit-read-only t))
3877 (gnus-request-article-this-buffer
3879 ;; There is no such article.
3881 (when (and (numberp article)
3882 (not (memq article gnus-newsgroup-sparse)))
3883 (setq gnus-article-current
3884 (cons gnus-newsgroup-name article))
3885 (set-buffer gnus-summary-buffer)
3886 (setq gnus-current-article article)
3887 (if (and (memq article gnus-newsgroup-undownloaded)
3888 (not (gnus-online (gnus-find-method-for-group
3889 gnus-newsgroup-name))))
3891 (gnus-summary-set-agent-mark article)
3892 (message "Message marked for downloading"))
3893 (gnus-summary-mark-article article gnus-canceled-mark)
3894 (unless (memq article gnus-newsgroup-sparse)
3895 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3896 (if (or (eq result 'pseudo)
3897 (eq result 'nneething))
3900 (set-buffer summary-buffer)
3901 (push article gnus-newsgroup-history)
3902 (setq gnus-last-article gnus-current-article
3903 gnus-current-article 0
3904 gnus-current-headers nil
3905 gnus-article-current nil)
3906 (if (eq result 'nneething)
3907 (gnus-configure-windows 'summary)
3908 (gnus-configure-windows 'article))
3909 (gnus-set-global-variables))
3910 (let ((gnus-article-mime-handle-alist-1
3911 gnus-article-mime-handle-alist))
3912 (gnus-set-mode-line 'article)))
3913 ;; The result from the `request' was an actual article -
3914 ;; or at least some text that is now displayed in the
3916 (when (and (numberp article)
3917 (not (eq article gnus-current-article)))
3918 ;; Seems like a new article has been selected.
3919 ;; `gnus-current-article' must be an article number.
3921 (set-buffer summary-buffer)
3922 (push article gnus-newsgroup-history)
3923 (setq gnus-last-article gnus-current-article
3924 gnus-current-article article
3925 gnus-current-headers
3926 (gnus-summary-article-header gnus-current-article)
3927 gnus-article-current
3928 (cons gnus-newsgroup-name gnus-current-article))
3929 (unless (vectorp gnus-current-headers)
3930 (setq gnus-current-headers nil))
3931 (gnus-summary-goto-subject gnus-current-article)
3932 (when (gnus-summary-show-thread)
3933 ;; If the summary buffer really was folded, the
3934 ;; previous goto may not actually have gone to
3935 ;; the right article, but the thread root instead.
3937 (gnus-summary-goto-subject gnus-current-article))
3938 (gnus-run-hooks 'gnus-mark-article-hook)
3939 (gnus-set-mode-line 'summary)
3940 (when (gnus-visual-p 'article-highlight 'highlight)
3941 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3942 ;; Set the global newsgroup variables here.
3943 (gnus-set-global-variables)
3944 (setq gnus-have-all-headers
3945 (or all-headers gnus-show-all-headers))))
3947 (gnus-configure-windows 'article))
3948 (when (or (numberp article)
3950 (gnus-article-prepare-display)
3952 (goto-char (point-min))
3953 (when gnus-break-pages
3954 (gnus-narrow-to-page)))
3955 (let ((gnus-article-mime-handle-alist-1
3956 gnus-article-mime-handle-alist))
3957 (gnus-set-mode-line 'article))
3961 (set-window-point (get-buffer-window (current-buffer)) (point))
3962 (gnus-configure-windows 'article)
3966 (defun gnus-article-prepare-display ()
3967 "Make the current buffer look like a nice article."
3968 ;; Hooks for getting information from the article.
3969 ;; This hook must be called before being narrowed.
3970 (let ((gnus-article-buffer (current-buffer))
3972 (inhibit-read-only t))
3973 (unless (eq major-mode 'gnus-article-mode)
3974 (gnus-article-mode))
3975 (setq buffer-read-only nil
3976 gnus-article-wash-types nil
3977 gnus-article-image-alist nil)
3978 (gnus-run-hooks 'gnus-tmp-internal-hook)
3979 (when gnus-display-mime-function
3980 (funcall gnus-display-mime-function))
3981 (gnus-run-hooks 'gnus-article-prepare-hook)))
3984 ;;; Gnus MIME viewing functions
3987 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3988 "Format of the MIME buttons.
3990 Valid specifiers include:
3992 %T MIME type, along with additional info
3993 %n The `name' parameter
3994 %d The description, if any
3995 %l The length of the encoded part
3996 %p The part identifier number
3997 %e Dots if the part isn't displayed
3999 General format specifiers can also be used. See Info node
4000 `(gnus)Formatting Variables'.")
4002 (defvar gnus-mime-button-line-format-alist
4003 '((?t gnus-tmp-type ?s)
4004 (?T gnus-tmp-type-long ?s)
4005 (?n gnus-tmp-name ?s)
4006 (?d gnus-tmp-description ?s)
4008 (?l gnus-tmp-length ?d)
4009 (?e gnus-tmp-dots ?s)))
4011 (defvar gnus-mime-button-commands
4012 '((gnus-article-press-button "\r" "Toggle Display")
4013 (gnus-mime-view-part "v" "View Interactively...")
4014 (gnus-mime-view-part-as-type "t" "View As Type...")
4015 (gnus-mime-view-part-as-charset "C" "View As charset...")
4016 (gnus-mime-save-part "o" "Save...")
4017 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4018 (gnus-mime-delete-part "d" "Delete part")
4019 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4020 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4021 (gnus-mime-view-part-internally "E" "View Internally")
4022 (gnus-mime-view-part-externally "e" "View Externally")
4023 (gnus-mime-print-part "p" "Print")
4024 (gnus-mime-pipe-part "|" "Pipe To Command...")
4025 (gnus-mime-action-on-part "." "Take action on the part...")))
4027 (defun gnus-article-mime-part-status ()
4028 (if gnus-article-mime-handle-alist-1
4029 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4031 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4034 (defvar gnus-mime-button-map
4035 (let ((map (make-sparse-keymap)))
4036 (define-key map gnus-mouse-2 'gnus-article-push-button)
4037 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4038 (dolist (c gnus-mime-button-commands)
4039 (define-key map (cadr c) (car c)))
4043 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4045 ,@(mapcar (lambda (c)
4046 (vector (caddr c) (car c) :enable t))
4047 gnus-mime-button-commands)))
4049 (defun gnus-mime-button-menu (event prefix)
4050 "Construct a context-sensitive menu of MIME commands."
4051 (interactive "e\nP")
4052 (save-window-excursion
4053 (let ((pos (event-start event)))
4054 (select-window (posn-window pos))
4055 (goto-char (posn-point pos))
4056 (gnus-article-check-buffer)
4057 (popup-menu gnus-mime-button-menu nil prefix))))
4059 (defun gnus-mime-view-all-parts (&optional handles)
4060 "View all the MIME parts."
4062 (with-current-buffer gnus-article-buffer
4063 (let ((handles (or handles gnus-article-mime-handles))
4064 (mail-parse-charset gnus-newsgroup-charset)
4065 (mail-parse-ignored-charsets
4066 (with-current-buffer gnus-summary-buffer
4067 gnus-newsgroup-ignored-charsets)))
4069 (mm-remove-parts handles)
4070 (goto-char (point-min))
4071 (or (search-forward "\n\n") (goto-char (point-max)))
4072 (let ((inhibit-read-only t))
4073 (delete-region (point) (point-max))
4074 (mm-display-parts handles))))))
4077 (defsubst gnus-article-edit-part (handles)
4078 "Edit an article in order to delete a mime part.
4079 This function is exclusively used by `gnus-mime-save-part-and-strip'
4080 and `gnus-mime-delete-part', and not provided at run-time normally."
4081 (gnus-article-edit-article
4083 (buffer-disable-undo)
4085 (let ((mail-parse-charset (or gnus-article-charset
4086 ',gnus-newsgroup-charset))
4087 (mail-parse-ignored-charsets
4088 (or gnus-article-ignored-charsets
4089 ',gnus-newsgroup-ignored-charsets))
4090 (mbl mml-buffer-list))
4091 (setq mml-buffer-list nil)
4092 (insert-buffer gnus-original-article-buffer)
4093 (mime-to-mml ',handles)
4094 (setq gnus-article-mime-handles nil)
4095 (let ((mbl1 mml-buffer-list))
4096 (setq mml-buffer-list mbl)
4097 (set (make-local-variable 'mml-buffer-list) mbl1))
4098 (gnus-make-local-hook 'kill-buffer-hook)
4099 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4100 `(lambda (no-highlight)
4101 (let ((mail-parse-charset (or gnus-article-charset
4102 ',gnus-newsgroup-charset))
4103 (message-options message-options)
4104 (message-options-set-recipient)
4105 (mail-parse-ignored-charsets
4106 (or gnus-article-ignored-charsets
4107 ',gnus-newsgroup-ignored-charsets)))
4109 (mml-destroy-buffers)
4110 (remove-hook 'kill-buffer-hook
4111 'mml-destroy-buffers t)
4112 (kill-local-variable 'mml-buffer-list))
4113 (gnus-summary-edit-article-done
4114 ,(or (mail-header-references gnus-current-headers) "")
4115 ,(gnus-group-read-only-p)
4116 ,gnus-summary-buffer no-highlight)))
4117 (gnus-article-edit-done)
4118 (gnus-summary-expand-window)
4119 (gnus-summary-show-article)))
4121 (defun gnus-mime-save-part-and-strip ()
4122 "Save the MIME part under point then replace it with an external body."
4124 (gnus-article-check-buffer)
4125 (when (gnus-group-read-only-p)
4126 (error "The current group does not support deleting of parts"))
4127 (when (mm-complicated-handles gnus-article-mime-handles)
4129 The current article has a complicated MIME structure, giving up..."))
4130 (when (gnus-yes-or-no-p "\
4131 Deleting parts may malfunction or destroy the article; continue? ")
4132 (let* ((data (get-text-property (point) 'gnus-data))
4134 (handles gnus-article-mime-handles))
4135 (setq file (and data (mm-save-part data)))
4137 (with-current-buffer (mm-handle-buffer data)
4139 (insert "Content-Type: " (mm-handle-media-type data))
4140 (mml-insert-parameter-string (cdr (mm-handle-type data))
4143 (insert "Content-ID: " (message-make-message-id) "\n")
4144 (insert "Content-Transfer-Encoding: binary\n")
4147 (cdr (mm-make-handle nil
4148 `("message/external-body"
4149 (access-type . "LOCAL-FILE")
4151 (set-buffer gnus-summary-buffer)
4152 (gnus-article-edit-part handles)))))
4154 (defun gnus-mime-delete-part ()
4155 "Delete the MIME part under point.
4156 Replace it with some information about the removed part."
4158 (gnus-article-check-buffer)
4159 (when (gnus-group-read-only-p)
4160 (error "The current group does not support deleting of parts"))
4161 (when (mm-complicated-handles gnus-article-mime-handles)
4163 The current article has a complicated MIME structure, giving up..."))
4164 (when (gnus-yes-or-no-p "\
4165 Deleting parts may malfunction or destroy the article; continue? ")
4166 (let* ((data (get-text-property (point) 'gnus-data))
4167 (handles gnus-article-mime-handles)
4171 (mail-decode-encoded-word-string (or (mm-handle-description data)
4174 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4176 (type (mm-handle-media-type data)))
4178 (error "No MIME part under point"))
4179 (with-current-buffer (mm-handle-buffer data)
4180 (let ((bsize (format "%s" (buffer-size))))
4185 "| The following attachment has been deleted:\n"
4187 "| Type: " type "\n"
4188 "| Filename: " filename "\n"
4189 "| Size (encoded): " bsize " Byte\n"
4190 "| Description: " description "\n"
4193 (cdr (mm-make-handle
4194 nil `("text/plain") nil nil
4196 (format "Deleted attachment (%s bytes)" bsize))))))
4197 (set-buffer gnus-summary-buffer)
4198 (gnus-article-edit-part handles))))
4200 (defun gnus-mime-save-part ()
4201 "Save the MIME part under point."
4203 (gnus-article-check-buffer)
4204 (let ((data (get-text-property (point) 'gnus-data)))
4206 (mm-save-part data))))
4208 (defun gnus-mime-pipe-part ()
4209 "Pipe the MIME part under point to a process."
4211 (gnus-article-check-buffer)
4212 (let ((data (get-text-property (point) 'gnus-data)))
4214 (mm-pipe-part data))))
4216 (defun gnus-mime-view-part ()
4217 "Interactively choose a viewing method for the MIME part under point."
4219 (gnus-article-check-buffer)
4220 (let ((data (get-text-property (point) 'gnus-data)))
4222 (setq gnus-article-mime-handles
4224 gnus-article-mime-handles (setq data (copy-sequence data))))
4225 (mm-interactively-view-part data))))
4227 (defun gnus-mime-view-part-as-type-internal ()
4228 (gnus-article-check-buffer)
4229 (let* ((name (mail-content-type-get
4230 (mm-handle-type (get-text-property (point) 'gnus-data))
4232 (def-type (and name (mm-default-file-encoding name))))
4233 (and def-type (cons def-type 0))))
4235 (defun gnus-mime-view-part-as-type (&optional mime-type)
4236 "Choose a MIME media type, and view the part as such."
4239 (setq mime-type (completing-read
4240 "View as MIME type: "
4241 (mapcar #'list (mailcap-mime-types))
4243 (gnus-mime-view-part-as-type-internal))))
4244 (gnus-article-check-buffer)
4245 (let ((handle (get-text-property (point) 'gnus-data)))
4248 (mm-make-handle (mm-handle-buffer handle)
4249 (cons mime-type (cdr (mm-handle-type handle)))
4250 (mm-handle-encoding handle)
4251 (mm-handle-undisplayer handle)
4252 (mm-handle-disposition handle)
4253 (mm-handle-description handle)
4255 (mm-handle-id handle)))
4256 (setq gnus-article-mime-handles
4257 (mm-merge-handles gnus-article-mime-handles handle))
4258 (gnus-mm-display-part handle))))
4260 (defun gnus-mime-copy-part (&optional handle arg)
4261 "Put the MIME part under point into a new buffer.
4262 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4264 (interactive (list nil current-prefix-arg))
4265 (gnus-article-check-buffer)
4267 (setq handle (get-text-property (point) 'gnus-data)))
4269 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4271 (mail-content-type-get (mm-handle-disposition handle)
4273 contents dont-decode charset coding-system)
4274 (mm-with-unibyte-buffer
4275 (mm-insert-part handle)
4276 (setq contents (or (condition-case nil
4277 (mm-decompress-buffer filename nil 'sig)
4279 (setq dont-decode t)
4282 (setq filename (cond (filename (file-name-nondirectory filename))
4283 (dont-decode "*raw data*")
4288 (unless (setq charset (mail-content-type-get
4289 (mm-handle-type handle) 'charset))
4290 (unless (setq coding-system (mm-with-unibyte-buffer
4292 (mm-find-buffer-file-coding-system)))
4293 (setq charset gnus-newsgroup-charset))))
4295 (setq charset (or (cdr (assq arg
4296 gnus-summary-show-article-charset-alist))
4297 (mm-read-coding-system "Charset: ")))))
4298 (switch-to-buffer (generate-new-buffer filename))
4299 (if (or coding-system
4301 (setq coding-system (mm-charset-to-coding-system charset))
4302 (not (eq charset 'ascii))))
4304 (mm-enable-multibyte)
4305 (insert (mm-decode-coding-string contents coding-system))
4306 (setq buffer-file-coding-system
4307 (if (boundp 'last-coding-system-used)
4308 (symbol-value 'last-coding-system-used)
4310 (mm-disable-multibyte)
4312 (setq buffer-file-coding-system mm-binary-coding-system))
4313 ;; We do it this way to make `normal-mode' set the appropriate mode.
4316 (setq buffer-file-name (expand-file-name filename))
4318 (setq buffer-file-name nil))
4319 (goto-char (point-min)))))
4321 (defun gnus-mime-print-part (&optional handle filename)
4322 "Print the MIME part under point."
4323 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4324 (gnus-article-check-buffer)
4325 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4326 (contents (and handle (mm-get-part handle)))
4327 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4328 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4333 (mm-save-part-to-file handle file)
4334 (call-process shell-file-name nil
4335 (generate-new-buffer " *mm*")
4337 shell-command-switch
4339 printer file (mm-handle-type handle))))
4343 (gnus-print-buffer))
4344 (ps-despool filename)))))
4346 (defun gnus-mime-inline-part (&optional handle arg)
4347 "Insert the MIME part under point into the current buffer.
4348 Compressed files like .gz and .bz2 are decompressed."
4349 (interactive (list nil current-prefix-arg))
4350 (gnus-article-check-buffer)
4352 (setq handle (get-text-property (point) 'gnus-data)))
4355 (inhibit-read-only t)
4356 contents charset coding-system)
4357 (if (and (not arg) (mm-handle-undisplayer handle))
4358 (mm-remove-part handle)
4359 (mm-with-unibyte-buffer
4360 (mm-insert-part handle)
4362 (or (mm-decompress-buffer
4363 (or (mail-content-type-get (mm-handle-disposition handle)
4365 (mail-content-type-get (mm-handle-disposition handle)
4371 (unless (setq charset (mail-content-type-get
4372 (mm-handle-type handle) 'charset))
4373 (unless (setq coding-system
4374 (mm-with-unibyte-buffer
4376 (mm-find-buffer-file-coding-system)))
4377 (setq charset gnus-newsgroup-charset))))
4379 (if (mm-handle-undisplayer handle)
4380 (mm-remove-part handle))
4383 gnus-summary-show-article-charset-alist))
4384 (mm-read-coding-system "Charset: "))))
4386 (if (mm-handle-undisplayer handle)
4387 (mm-remove-part handle))))
4391 (if (or coding-system
4394 (mm-charset-to-coding-system charset))
4395 (not (eq charset 'ascii))))
4396 (mm-decode-coding-string contents coding-system)
4397 (mm-string-to-multibyte contents)))
4400 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4401 "Insert the MIME part under point into the current buffer using the
4403 (interactive (list nil current-prefix-arg))
4404 (gnus-article-check-buffer)
4405 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4408 (inhibit-read-only t))
4410 (if (mm-handle-undisplayer handle)
4411 (mm-remove-part handle))
4412 (let ((gnus-newsgroup-charset
4414 gnus-summary-show-article-charset-alist))
4415 (mm-read-coding-system "Charset: ")))
4416 (gnus-newsgroup-ignored-charsets 'gnus-all))
4417 (gnus-article-press-button)))))
4419 (defun gnus-mime-view-part-externally (&optional handle)
4420 "View the MIME part under point with an external viewer."
4422 (gnus-article-check-buffer)
4423 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4424 (mm-user-display-methods nil)
4425 (mm-inlined-types nil)
4426 (mail-parse-charset gnus-newsgroup-charset)
4427 (mail-parse-ignored-charsets
4428 (with-current-buffer gnus-summary-buffer
4429 gnus-newsgroup-ignored-charsets)))
4431 (if (mm-handle-undisplayer handle)
4432 (mm-remove-part handle)
4433 (mm-display-part handle)))))
4435 (defun gnus-mime-view-part-internally (&optional handle)
4436 "View the MIME part under point with an internal viewer.
4437 If no internal viewer is available, use an external viewer."
4439 (gnus-article-check-buffer)
4440 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4441 (mm-inlined-types '(".*"))
4442 (mm-inline-large-images t)
4443 (mail-parse-charset gnus-newsgroup-charset)
4444 (mail-parse-ignored-charsets
4445 (with-current-buffer gnus-summary-buffer
4446 gnus-newsgroup-ignored-charsets))
4447 (inhibit-read-only t))
4449 (if (mm-handle-undisplayer handle)
4450 (mm-remove-part handle)
4451 (mm-display-part handle)))))
4453 (defun gnus-mime-action-on-part (&optional action)
4454 "Do something with the MIME attachment at \(point\)."
4456 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4457 (gnus-article-check-buffer)
4458 (let ((action-pair (assoc action gnus-mime-action-alist)))
4460 (funcall (cdr action-pair)))))
4462 (defun gnus-article-part-wrapper (n function)
4463 (with-current-buffer gnus-article-buffer
4464 (when (> n (length gnus-article-mime-handle-alist))
4465 (error "No such part"))
4466 (gnus-article-goto-part n)
4467 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4468 (funcall function handle))))
4470 (defun gnus-article-pipe-part (n)
4471 "Pipe MIME part N, which is the numerical prefix."
4473 (gnus-article-part-wrapper n 'mm-pipe-part))
4475 (defun gnus-article-save-part (n)
4476 "Save MIME part N, which is the numerical prefix."
4478 (gnus-article-part-wrapper n 'mm-save-part))
4480 (defun gnus-article-interactively-view-part (n)
4481 "View MIME part N interactively, which is the numerical prefix."
4483 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4485 (defun gnus-article-copy-part (n)
4486 "Copy MIME part N, which is the numerical prefix."
4488 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4490 (defun gnus-article-view-part-as-charset (n)
4491 "View MIME part N using a specified charset.
4492 N is the numerical prefix."
4494 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4496 (defun gnus-article-view-part-externally (n)
4497 "View MIME part N externally, which is the numerical prefix."
4499 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4501 (defun gnus-article-inline-part (n)
4502 "Inline MIME part N, which is the numerical prefix."
4504 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4506 (defun gnus-article-mime-match-handle-first (condition)
4509 (dolist (ihandle gnus-article-mime-handle-alist)
4511 ((functionp condition)
4512 (funcall condition (cdr ihandle)))
4513 ((eq condition 'undisplayed)
4514 (not (or (mm-handle-undisplayer (cdr ihandle))
4515 (equal (mm-handle-media-type (cdr ihandle))
4516 "multipart/alternative"))))
4517 ((eq condition 'undisplayed-alternative)
4518 (not (mm-handle-undisplayer (cdr ihandle))))
4520 (gnus-article-goto-part (car ihandle))
4521 (or (not n) (< (car ihandle) n)))
4522 (setq n (car ihandle))))
4526 (defun gnus-article-view-part (&optional n)
4527 "View MIME part N, which is the numerical prefix."
4529 (with-current-buffer gnus-article-buffer
4530 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4531 gnus-article-mime-match-handle-function)))
4532 (when (> n (length gnus-article-mime-handle-alist))
4533 (error "No such part"))
4534 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4535 (when (gnus-article-goto-part n)
4536 (if (equal (car handle) "multipart/alternative")
4537 (gnus-article-press-button)
4538 (when (eq (gnus-mm-display-part handle) 'internal)
4539 (gnus-set-window-start)))))))
4541 (defsubst gnus-article-mime-total-parts ()
4542 (if (bufferp (car gnus-article-mime-handles))
4544 (1- (length gnus-article-mime-handles))))
4546 (defun gnus-mm-display-part (handle)
4547 "Display HANDLE and fix MIME button."
4548 (let ((id (get-text-property (point) 'gnus-part))
4550 (inhibit-read-only t))
4553 (let ((window (selected-window))
4554 (mail-parse-charset gnus-newsgroup-charset)
4555 (mail-parse-ignored-charsets
4556 (if (gnus-buffer-live-p gnus-summary-buffer)
4557 (with-current-buffer gnus-summary-buffer
4558 gnus-newsgroup-ignored-charsets)
4562 (let ((win (gnus-get-buffer-window (current-buffer) t))
4565 (select-window win))
4568 (if (mm-handle-displayed-p handle)
4569 ;; This will remove the part.
4570 (mm-display-part handle)
4572 (narrow-to-region (point)
4573 (if (eobp) (point) (1+ (point))))
4574 (mm-display-part handle)
4575 ;; We narrow to the part itself and
4576 ;; then call the treatment functions.
4577 (goto-char (point-min))
4579 (narrow-to-region (point) (point-max))
4582 (gnus-article-mime-total-parts)
4583 (mm-handle-media-type handle)))))
4584 (if (window-live-p window)
4585 (select-window window)))))
4588 (gnus-insert-mime-button
4589 handle id (list (mm-handle-displayed-p handle)))
4590 (goto-char point))))
4592 (defun gnus-article-goto-part (n)
4593 "Go to MIME part N."
4594 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4596 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4597 (let ((gnus-tmp-name
4598 (or (mail-content-type-get (mm-handle-type handle) 'name)
4599 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4600 (mail-content-type-get (mm-handle-type handle) 'url)
4602 (gnus-tmp-type (mm-handle-media-type handle))
4603 (gnus-tmp-description
4604 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4607 (if (if displayed (car displayed)
4608 (mm-handle-displayed-p handle))
4610 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4612 gnus-tmp-type-long b e)
4613 (when (string-match ".*/" gnus-tmp-name)
4614 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4615 (setq gnus-tmp-type-long (concat gnus-tmp-type
4616 (and (not (equal gnus-tmp-name ""))
4617 (concat "; " gnus-tmp-name))))
4618 (unless (equal gnus-tmp-description "")
4619 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4624 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4625 `(keymap ,gnus-mime-button-map
4626 gnus-callback gnus-mm-display-part
4627 gnus-part ,gnus-tmp-id
4628 article-type annotation
4631 ;; Exclude a newline.
4634 (widget-convert-button
4637 :action 'gnus-widget-press-button
4638 :button-keymap gnus-mime-button-map
4640 (lambda (widget/window &optional overlay pos)
4641 ;; Needed to properly clear the message due to a bug in
4642 ;; wid-edit (XEmacs only).
4643 (if (boundp 'help-echo-owns-message)
4644 (setq help-echo-owns-message t))
4646 "%S: %s the MIME part; %S: more options"
4647 (aref gnus-mouse-2 0)
4648 ;; XEmacs will get a single widget arg; Emacs 21 will get
4649 ;; window, overlay, position.
4650 (if (mm-handle-displayed-p
4652 (with-current-buffer (gnus-overlay-buffer overlay)
4653 (widget-get (widget-at (gnus-overlay-start overlay))
4655 (widget-get widget/window :mime-handle)))
4657 (aref gnus-down-mouse-3 0))))))
4659 (defun gnus-widget-press-button (elems el)
4660 (goto-char (widget-get elems :from))
4661 (gnus-article-press-button))
4663 (defvar gnus-displaying-mime nil)
4665 (defun gnus-display-mime (&optional ihandles)
4666 "Display the MIME parts."
4668 (save-selected-window
4669 (let ((window (get-buffer-window gnus-article-buffer))
4672 (select-window window)
4673 ;; We have to do this since selecting the window
4674 ;; may change the point. So we set the window point.
4675 (set-window-point window point)))
4676 (let ((handles ihandles)
4677 (inhibit-read-only t)
4680 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
4681 (when gnus-article-emulate-mime
4682 (mm-uu-dissect-text-parts handles)))
4683 (gnus-article-emulate-mime
4684 (setq handles (mm-uu-dissect))))
4685 (when (and (not ihandles)
4686 (not gnus-displaying-mime))
4687 ;; Top-level call; we clean up.
4688 (when gnus-article-mime-handles
4689 (mm-destroy-parts gnus-article-mime-handles)
4690 (setq gnus-article-mime-handle-alist nil));; A trick.
4691 (setq gnus-article-mime-handles handles)
4692 ;; We allow users to glean info from the handles.
4693 (when gnus-article-mime-part-function
4694 (gnus-mime-part-function handles)))
4696 (or (not (stringp (car handles)))
4699 (when (and (not ihandles)
4700 (not gnus-displaying-mime))
4701 ;; Clean up for mime parts.
4703 (delete-region (point) (point-max)))
4704 (let ((gnus-displaying-mime t))
4705 (gnus-mime-display-part handles)))
4708 (narrow-to-region (point) (point-max))
4709 (gnus-treat-article nil 1 1)
4712 ;; Highlight the headers.
4716 (narrow-to-region (point-min) (point))
4717 (gnus-article-save-original-date
4718 (gnus-treat-article 'head)))))))))
4720 (defcustom gnus-mime-display-multipart-as-mixed nil
4721 "Display \"multipart\" parts as \"multipart/mixed\".
4723 If t, it overrides nil values of
4724 `gnus-mime-display-multipart-alternative-as-mixed' and
4725 `gnus-mime-display-multipart-related-as-mixed'."
4726 :group 'gnus-article-mime
4729 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4730 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4732 :group 'gnus-article-mime
4735 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4736 "Display \"multipart/related\" parts as \"multipart/mixed\".
4738 If displaying \"text/html\" is discouraged \(see
4739 `mm-discouraged-alternatives'\) images or other material inside a
4740 \"multipart/related\" part might be overlooked when this variable is nil."
4742 :group 'gnus-article-mime
4745 (defun gnus-mime-display-part (handle)
4748 ((not (stringp (car handle)))
4749 (gnus-mime-display-single handle))
4750 ;; User-defined multipart
4751 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4752 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4754 ;; multipart/alternative
4755 ((and (equal (car handle) "multipart/alternative")
4756 (not (or gnus-mime-display-multipart-as-mixed
4757 gnus-mime-display-multipart-alternative-as-mixed)))
4758 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4759 (push (cons id handle) gnus-article-mime-handle-alist)
4760 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4761 ;; multipart/related
4762 ((and (equal (car handle) "multipart/related")
4763 (not (or gnus-mime-display-multipart-as-mixed
4764 gnus-mime-display-multipart-related-as-mixed)))
4765 ;;;!!!We should find the start part, but we just default
4766 ;;;!!!to the first part.
4767 ;;(gnus-mime-display-part (cadr handle))
4768 ;;;!!! Most multipart/related is an HTML message plus images.
4769 ;;;!!! Unfortunately we are unable to let W3 display those
4770 ;;;!!! included images, so we just display it as a mixed multipart.
4771 ;;(gnus-mime-display-mixed (cdr handle))
4772 ;;;!!! No, w3 can display everything just fine.
4773 (gnus-mime-display-part (cadr handle)))
4774 ((equal (car handle) "multipart/signed")
4775 (gnus-add-wash-type 'signed)
4776 (gnus-mime-display-security handle))
4777 ((equal (car handle) "multipart/encrypted")
4778 (gnus-add-wash-type 'encrypted)
4779 (gnus-mime-display-security handle))
4780 ;; Other multiparts are handled like multipart/mixed.
4782 (gnus-mime-display-mixed (cdr handle)))))
4784 (defun gnus-mime-part-function (handles)
4785 (if (stringp (car handles))
4786 (mapcar 'gnus-mime-part-function (cdr handles))
4787 (funcall gnus-article-mime-part-function handles)))
4789 (defun gnus-mime-display-mixed (handles)
4790 (mapcar 'gnus-mime-display-part handles))
4792 (defun gnus-mime-display-single (handle)
4793 (let ((type (mm-handle-media-type handle))
4794 (ignored gnus-ignored-mime-types)
4801 (when (string-match (pop ignored) type)
4802 (throw 'ignored nil)))
4803 (if (and (setq not-attachment
4804 (and (not (mm-inline-override-p handle))
4805 (or (not (mm-handle-disposition handle))
4806 (equal (car (mm-handle-disposition handle))
4808 (mm-attachment-override-p handle))))
4809 (mm-automatic-display-p handle)
4811 (mm-inlinable-p handle)
4812 (mm-inlined-p handle))
4813 (mm-automatic-external-display-p type)))
4815 (when (equal (mm-handle-media-supertype handle) "text")
4817 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4819 (push (cons id handle) gnus-article-mime-handle-alist)
4820 (when (or (not display)
4821 (not (gnus-unbuttonized-mime-type-p type)))
4822 (gnus-insert-mime-button
4823 handle id (list (or display (and not-attachment text))))
4824 (gnus-article-insert-newline)
4825 ;; Remember modify the number of forward lines.
4833 (let ((mail-parse-charset gnus-newsgroup-charset)
4834 (mail-parse-ignored-charsets
4835 (save-excursion (condition-case ()
4836 (set-buffer gnus-summary-buffer)
4838 gnus-newsgroup-ignored-charsets)))
4839 (mm-display-part handle t))
4840 (goto-char (point-max)))
4841 ((and text not-attachment)
4845 (gnus-article-insert-newline)
4846 (mm-display-inline handle)
4847 (goto-char (point-max))))
4851 (narrow-to-region beg (point))
4854 (gnus-article-mime-total-parts)
4855 (mm-handle-media-type handle)))))))))
4857 (defun gnus-unbuttonized-mime-type-p (type)
4858 "Say whether TYPE is to be unbuttonized."
4859 (unless gnus-inhibit-mime-unbuttonizing
4861 (let ((types gnus-unbuttonized-mime-types))
4863 (when (string-match (pop types) type)
4864 (throw 'found t)))))
4866 (let ((types gnus-buttonized-mime-types))
4868 (when (string-match (pop types) type)
4869 (throw 'found t)))))))))
4871 (defun gnus-article-insert-newline ()
4872 "Insert a newline, but mark it as undeletable."
4873 (gnus-put-text-property
4874 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4876 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4877 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4880 handle (inhibit-read-only t) from props begend not-pref)
4881 (save-window-excursion
4884 (narrow-to-region (car ibegend)
4887 (goto-char (car ibegend))
4890 (delete-region (point-min) (point-max))
4891 (mm-remove-parts handles))
4892 (setq begend (list (point-marker)))
4894 (unless (setq not-pref (cadr (member preferred ihandles)))
4895 (setq not-pref (car ihandles)))
4898 (not (gnus-unbuttonized-mime-type-p
4899 "multipart/alternative")))
4900 (gnus-add-text-properties
4903 (insert (format "%d. " id))
4907 (unless ,(not ibegend)
4908 (setq gnus-article-mime-handle-alist
4909 ',gnus-article-mime-handle-alist))
4910 (gnus-mime-display-alternative
4911 ',ihandles ',not-pref ',begend ,id))
4912 keymap ,gnus-mime-button-map
4913 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4914 face ,gnus-article-button-face
4917 (widget-convert-button 'link from (point)
4918 :action 'gnus-widget-press-button
4919 :button-keymap gnus-widget-button-keymap)
4921 (while (setq handle (pop handles))
4922 (gnus-add-text-properties
4925 (insert (format "(%c) %-18s"
4926 (if (equal handle preferred) ?* ? )
4927 (mm-handle-media-type handle)))
4931 (unless ,(not ibegend)
4932 (setq gnus-article-mime-handle-alist
4933 ',gnus-article-mime-handle-alist))
4934 (gnus-mime-display-alternative
4935 ',ihandles ',handle ',begend ,id))
4936 keymap ,gnus-mime-button-map
4937 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4938 face ,gnus-article-button-face
4941 (widget-convert-button 'link from (point)
4942 :action 'gnus-widget-press-button
4943 :button-keymap gnus-widget-button-keymap)
4947 (if (stringp (car preferred))
4948 (gnus-display-mime preferred)
4949 (let ((mail-parse-charset gnus-newsgroup-charset)
4950 (mail-parse-ignored-charsets
4951 (with-current-buffer gnus-summary-buffer
4952 gnus-newsgroup-ignored-charsets)))
4953 (mm-display-part preferred)
4957 (narrow-to-region (car begend) (point-max))
4959 nil (length gnus-article-mime-handle-alist)
4960 (gnus-article-mime-total-parts)
4961 (mm-handle-media-type handle))))))
4962 (goto-char (point-max))
4963 (setcdr begend (point-marker)))))
4965 (goto-char point))))
4967 (defconst gnus-article-wash-status-strings
4968 (let ((alist '((cite "c" "Possible hidden citation text"
4969 " " "All citation text visible")
4970 (headers "h" "Hidden headers"
4971 " " "All headers visible.")
4972 (pgp "p" "Encrypted or signed message status hidden"
4973 " " "No hidden encryption nor digital signature status")
4974 (signature "s" "Signature has been hidden"
4975 " " "Signature is visible")
4976 (overstrike "o" "Overstrike (^H) characters applied"
4977 " " "No overstrike characters applied")
4978 (emphasis "e" "/*_Emphasis_*/ characters applied"
4979 " " "No /*_emphasis_*/ characters applied")))
4981 (dolist (entry alist result)
4982 (let ((key (nth 0 entry))
4983 (on (copy-sequence (nth 1 entry)))
4984 (on-help (nth 2 entry))
4985 (off (copy-sequence (nth 3 entry)))
4986 (off-help (nth 4 entry)))
4987 (put-text-property 0 1 'help-echo on-help on)
4988 (put-text-property 0 1 'help-echo off-help off)
4989 (push (list key on off) result))))
4990 "Alist of strings describing wash status in the mode line.
4991 Each entry has the form (KEY ON OF), where the KEY is a symbol
4992 representing the particular washing function, ON is the string to use
4993 in the article mode line when the washing function is active, and OFF
4994 is the string to use when it is inactive.")
4996 (defun gnus-article-wash-status-entry (key value)
4997 (let ((entry (assoc key gnus-article-wash-status-strings)))
4998 (if value (nth 1 entry) (nth 2 entry))))
5000 (defun gnus-article-wash-status ()
5001 "Return a string which display status of article washing."
5002 (with-current-buffer gnus-article-buffer
5003 (let ((cite (memq 'cite gnus-article-wash-types))
5004 (headers (memq 'headers gnus-article-wash-types))
5005 (boring (memq 'boring-headers gnus-article-wash-types))
5006 (pgp (memq 'pgp gnus-article-wash-types))
5007 (pem (memq 'pem gnus-article-wash-types))
5008 (signed (memq 'signed gnus-article-wash-types))
5009 (encrypted (memq 'encrypted gnus-article-wash-types))
5010 (signature (memq 'signature gnus-article-wash-types))
5011 (overstrike (memq 'overstrike gnus-article-wash-types))
5012 (emphasis (memq 'emphasis gnus-article-wash-types)))
5014 (gnus-article-wash-status-entry 'cite cite)
5015 (gnus-article-wash-status-entry 'headers (or headers boring))
5016 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5017 (gnus-article-wash-status-entry 'signature signature)
5018 (gnus-article-wash-status-entry 'overstrike overstrike)
5019 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5021 (defun gnus-add-wash-type (type)
5022 "Add a washing of TYPE to the current status."
5023 (add-to-list 'gnus-article-wash-types type))
5025 (defun gnus-delete-wash-type (type)
5026 "Add a washing of TYPE to the current status."
5027 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5029 (defun gnus-add-image (category image)
5030 "Add IMAGE of CATEGORY to the list of displayed images."
5031 (let ((entry (assq category gnus-article-image-alist)))
5033 (setq entry (list category))
5034 (push entry gnus-article-image-alist))
5035 (nconc entry (list image))))
5037 (defun gnus-delete-images (category)
5038 "Delete all images in CATEGORY."
5039 (let ((entry (assq category gnus-article-image-alist)))
5040 (dolist (image (cdr entry))
5041 (gnus-remove-image image category))
5042 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5043 (gnus-delete-wash-type category)))
5045 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5047 (defun gnus-article-maybe-hide-headers ()
5048 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5049 Provided for backwards compatibility."
5050 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5051 (not (with-current-buffer gnus-summary-buffer
5052 gnus-have-all-headers)))
5053 (not gnus-inhibit-hiding))
5054 (gnus-article-hide-headers)))
5058 (defun gnus-output-to-file (file-name)
5059 "Append the current article to a file named FILE-NAME."
5060 (let ((artbuf (current-buffer)))
5062 (insert-buffer-substring artbuf)
5063 ;; Append newline at end of the buffer as separator, and then
5065 (goto-char (point-max))
5067 (let ((file-name-coding-system nnmail-pathname-coding-system))
5068 (mm-append-to-file (point-min) (point-max) file-name))
5071 (defun gnus-narrow-to-page (&optional arg)
5072 "Narrow the article buffer to a page.
5073 If given a numerical ARG, move forward ARG pages."
5075 (setq arg (if arg (prefix-numeric-value arg) 0))
5077 (set-buffer gnus-article-buffer)
5078 (goto-char (point-min))
5080 ;; Remove any old next/prev buttons.
5081 (when (gnus-visual-p 'page-marker)
5082 (let ((inhibit-read-only t))
5083 (gnus-remove-text-with-property 'gnus-prev)
5084 (gnus-remove-text-with-property 'gnus-next)))
5087 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5089 (re-search-forward page-delimiter nil 'move arg)))
5090 (goto-char (match-end 0))
5092 (goto-char (point-min))
5093 (setq gnus-page-broken
5094 (and (re-search-forward page-delimiter nil t) t))))
5095 (when gnus-page-broken
5098 (if (re-search-forward page-delimiter nil 'move)
5101 (when (and (gnus-visual-p 'page-marker)
5102 (> (point-min) (save-restriction (widen) (point-min))))
5104 (goto-char (point-min))
5105 (gnus-insert-prev-page-button)))
5106 (when (and (gnus-visual-p 'page-marker)
5107 (< (point-max) (save-restriction (widen) (point-max))))
5109 (goto-char (point-max))
5110 (gnus-insert-next-page-button))))))
5112 ;; Article mode commands
5114 (defun gnus-article-goto-next-page ()
5115 "Show the next page of the article."
5117 (when (gnus-article-next-page)
5118 (goto-char (point-min))
5119 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5122 (defun gnus-article-goto-prev-page ()
5123 "Show the previous page of the article."
5126 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5127 (gnus-article-prev-page nil)))
5129 ;; This is cleaner but currently breaks `gnus-pick-mode':
5131 ;; (defun gnus-article-goto-next-page ()
5132 ;; "Show the next page of the article."
5134 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5135 ;; (gnus-summary-next-page)))
5137 ;; (defun gnus-article-goto-prev-page ()
5138 ;; "Show the next page of the article."
5140 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5141 ;; (gnus-summary-prev-page)))
5143 (defun gnus-article-next-page (&optional lines)
5144 "Show the next page of the current article.
5145 If end of article, return non-nil. Otherwise return nil.
5146 Argument LINES specifies lines to be scrolled up."
5148 (move-to-window-line -1)
5151 (and (pos-visible-in-window-p) ;Not continuation line.
5152 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5153 ;; Nothing in this page.
5154 (if (or (not gnus-page-broken)
5159 (eobp)))) ;Real end-of-buffer?
5161 (when gnus-article-over-scroll
5162 (gnus-article-next-page-1 lines))
5164 (gnus-narrow-to-page 1) ;Go to next page.
5166 ;; More in this page.
5167 (gnus-article-next-page-1 lines)
5170 (defun gnus-article-next-page-1 (lines)
5171 (let ((scroll-in-place nil))
5175 ;; Long lines may cause an end-of-buffer error.
5176 (goto-char (point-max)))))
5177 (move-to-window-line 0))
5179 (defun gnus-article-prev-page (&optional lines)
5180 "Show previous page of current article.
5181 Argument LINES specifies lines to be scrolled down."
5183 (move-to-window-line 0)
5184 (if (and gnus-page-broken
5186 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5188 (gnus-narrow-to-page -1) ;Go to previous page.
5189 (goto-char (point-max))
5191 (let ((scroll-in-place nil))
5195 (beginning-of-buffer
5196 (goto-char (point-min))))
5197 (move-to-window-line 0)))))
5199 (defun gnus-article-only-boring-p ()
5200 "Decide whether there is only boring text remaining in the article.
5201 Something \"interesting\" is a word of at least two letters that does
5202 not have a face in `gnus-article-boring-faces'."
5203 (when (and gnus-article-skip-boring
5204 (boundp 'gnus-article-boring-faces)
5205 (symbol-value 'gnus-article-boring-faces))
5208 (while (re-search-forward "\\b\\w\\w" nil t)
5210 (when (not (gnus-intersection
5211 (gnus-faces-at (point))
5212 (symbol-value 'gnus-article-boring-faces)))
5213 (throw 'only-boring nil)))
5214 (throw 'only-boring t)))))
5216 (defun gnus-article-refer-article ()
5217 "Read article specified by message-id around point."
5220 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5221 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5222 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5223 (let ((msg-id (concat "<" (match-string 0) ">")))
5224 (set-buffer gnus-summary-buffer)
5225 (gnus-summary-refer-article msg-id))
5226 (error "No references around point"))))
5228 (defun gnus-article-show-summary ()
5229 "Reconfigure windows to show summary buffer."
5231 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5232 (error "There is no summary buffer for this article buffer")
5233 (gnus-article-set-globals)
5234 (gnus-configure-windows 'article)
5235 (gnus-summary-goto-subject gnus-current-article)
5236 (gnus-summary-position-point)))
5238 (defun gnus-article-describe-briefly ()
5239 "Describe article mode commands briefly."
5241 (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")))
5243 (defun gnus-article-summary-command ()
5244 "Execute the last keystroke in the summary buffer."
5246 (let ((obuf (current-buffer))
5247 (owin (current-window-configuration))
5249 (switch-to-buffer gnus-article-current-summary 'norecord)
5250 (setq func (lookup-key (current-local-map) (this-command-keys)))
5251 (call-interactively func)
5253 (set-window-configuration owin)
5254 (set-window-point (get-buffer-window (current-buffer)) (point))))
5256 (defun gnus-article-summary-command-nosave ()
5257 "Execute the last keystroke in the summary buffer."
5260 (pop-to-buffer gnus-article-current-summary 'norecord)
5261 (setq func (lookup-key (current-local-map) (this-command-keys)))
5262 (call-interactively func)))
5264 (defun gnus-article-check-buffer ()
5265 "Beep if not in an article buffer."
5266 (unless (equal major-mode 'gnus-article-mode)
5267 (error "Command invoked outside of a Gnus article buffer")))
5269 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5270 "Read a summary buffer key sequence and execute it from the article buffer."
5272 (gnus-article-check-buffer)
5274 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5275 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5276 "=" "^" "\M-^" "|"))
5282 '("n" "Gn" "p" "Gp"))
5285 (set-buffer gnus-article-current-summary)
5286 (let (gnus-pick-mode)
5287 (push (or key last-command-event) unread-command-events)
5288 (setq keys (if (featurep 'xemacs)
5289 (events-to-keys (read-key-sequence nil))
5290 (read-key-sequence nil)))))
5294 (if (or (member keys nosaves)
5295 (member keys nosave-but-article)
5296 (member keys nosave-in-article))
5298 (save-window-excursion
5299 (pop-to-buffer gnus-article-current-summary 'norecord)
5300 ;; We disable the pick minor mode commands.
5301 (let (gnus-pick-mode)
5302 (setq func (lookup-key (current-local-map) keys))))
5306 (unless (member keys nosave-in-article)
5307 (set-buffer gnus-article-current-summary))
5308 (call-interactively func)
5309 (setq new-sum-point (point)))
5310 (when (member keys nosave-but-article)
5311 (pop-to-buffer gnus-article-buffer 'norecord)))
5312 ;; These commands should restore window configuration.
5313 (let ((obuf (current-buffer))
5314 (owin (current-window-configuration))
5316 win func in-buffer selected new-sum-start new-sum-hscroll)
5317 (cond (not-restore-window
5318 (pop-to-buffer gnus-article-current-summary 'norecord))
5319 ((setq win (get-buffer-window gnus-article-current-summary))
5320 (select-window win))
5322 (switch-to-buffer gnus-article-current-summary 'norecord)))
5323 (setq in-buffer (current-buffer))
5324 ;; We disable the pick minor mode commands.
5325 (if (and (setq func (let (gnus-pick-mode)
5326 (lookup-key (current-local-map) keys)))
5329 (call-interactively func)
5330 (when (eq win (selected-window))
5331 (setq new-sum-point (point)
5332 new-sum-start (window-start win)
5333 new-sum-hscroll (window-hscroll win)))
5334 (when (eq in-buffer (current-buffer))
5335 (setq selected (gnus-summary-select-article))
5337 (unless not-restore-window
5338 (set-window-configuration owin))
5339 (when (eq selected 'old)
5341 (set-window-start (get-buffer-window (current-buffer))
5343 (set-window-point (get-buffer-window (current-buffer))
5345 (when (and (not not-restore-window)
5347 (set-window-point win new-sum-point)
5348 (set-window-start win new-sum-start)
5349 (set-window-hscroll win new-sum-hscroll))))
5350 (set-window-configuration owin)
5353 (defun gnus-article-describe-key (key)
5354 "Display documentation of the function invoked by KEY. KEY is a string."
5355 (interactive "kDescribe key: ")
5356 (gnus-article-check-buffer)
5357 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5359 (set-buffer gnus-article-current-summary)
5360 (let (gnus-pick-mode)
5361 (if (featurep 'xemacs)
5363 (push (elt key 0) unread-command-events)
5364 (setq key (events-to-keys
5365 (read-key-sequence "Describe key: "))))
5366 (setq unread-command-events
5368 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5369 (string-to-list key)))
5370 (setq key (read-key-sequence "Describe key: "))))
5372 (describe-key key)))
5374 (defun gnus-article-describe-key-briefly (key &optional insert)
5375 "Display documentation of the function invoked by KEY. KEY is a string."
5376 (interactive "kDescribe key: \nP")
5377 (gnus-article-check-buffer)
5378 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5380 (set-buffer gnus-article-current-summary)
5381 (let (gnus-pick-mode)
5382 (if (featurep 'xemacs)
5384 (push (elt key 0) unread-command-events)
5385 (setq key (events-to-keys
5386 (read-key-sequence "Describe key: "))))
5387 (setq unread-command-events
5389 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5390 (string-to-list key)))
5391 (setq key (read-key-sequence "Describe key: "))))
5392 (describe-key-briefly key insert))
5393 (describe-key-briefly key insert)))
5395 (defun gnus-article-reply-with-original (&optional wide)
5396 "Start composing a reply mail to the current message.
5397 The text in the region will be yanked. If the region isn't active,
5398 the entire article will be yanked."
5400 (let ((article (cdr gnus-article-current))
5402 (if (not (gnus-region-active-p))
5403 (with-current-buffer gnus-summary-buffer
5404 (gnus-summary-reply (list (list article)) wide))
5405 (setq contents (buffer-substring (point) (mark t)))
5406 ;; Deactivate active regions.
5407 (when (and (boundp 'transient-mark-mode)
5408 transient-mark-mode)
5409 (setq mark-active nil))
5410 (with-current-buffer gnus-summary-buffer
5412 (list (list article contents)) wide)))))
5414 (defun gnus-article-followup-with-original ()
5415 "Compose a followup to the current article.
5416 The text in the region will be yanked. If the region isn't active,
5417 the entire article will be yanked."
5419 (let ((article (cdr gnus-article-current))
5421 (if (not (gnus-region-active-p))
5422 (with-current-buffer gnus-summary-buffer
5423 (gnus-summary-followup (list (list article))))
5424 (setq contents (buffer-substring (point) (mark t)))
5425 ;; Deactivate active regions.
5426 (when (and (boundp 'transient-mark-mode)
5427 transient-mark-mode)
5428 (setq mark-active nil))
5429 (with-current-buffer gnus-summary-buffer
5430 (gnus-summary-followup
5431 (list (list article contents)))))))
5433 (defun gnus-article-hide (&optional arg force)
5434 "Hide all the gruft in the current article.
5435 This means that signatures, cited text and (some) headers will be
5437 If given a prefix, show the hidden text instead."
5438 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5439 (gnus-article-hide-headers arg)
5440 (gnus-article-hide-list-identifiers arg)
5441 (gnus-article-hide-citation-maybe arg force)
5442 (gnus-article-hide-signature arg))
5444 (defun gnus-article-maybe-highlight ()
5445 "Do some article highlighting if article highlighting is requested."
5446 (when (gnus-visual-p 'article-highlight 'highlight)
5447 (gnus-article-highlight-some)))
5449 (defun gnus-check-group-server ()
5450 ;; Make sure the connection to the server is alive.
5451 (unless (gnus-server-opened
5452 (gnus-find-method-for-group gnus-newsgroup-name))
5453 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5454 (gnus-request-group gnus-newsgroup-name t)))
5457 (autoload 'nneething-get-file-name "nneething"))
5459 (defun gnus-request-article-this-buffer (article group)
5460 "Get an article and insert it into this buffer."
5461 (let (do-update-line sparse-header)
5465 (gnus-kill-all-overlays)
5466 (setq group (or group gnus-newsgroup-name))
5468 ;; Using `gnus-request-article' directly will insert the article into
5469 ;; `nntp-server-buffer' - so we'll save some time by not having to
5470 ;; copy it from the server buffer into the article buffer.
5472 ;; We only request an article by message-id when we do not have the
5473 ;; headers for it, so we'll have to get those.
5474 (when (stringp article)
5475 (gnus-read-header article))
5477 ;; If the article number is negative, that means that this article
5478 ;; doesn't belong in this newsgroup (possibly), so we find its
5479 ;; message-id and request it by id instead of number.
5480 (when (and (numberp article)
5482 (get-buffer gnus-summary-buffer)
5483 (gnus-buffer-exists-p gnus-summary-buffer))
5485 (set-buffer gnus-summary-buffer)
5486 (let ((header (gnus-summary-article-header article)))
5489 ((memq article gnus-newsgroup-sparse)
5490 ;; This is a sparse gap article.
5491 (setq do-update-line article)
5492 (setq article (mail-header-id header))
5493 (setq sparse-header (gnus-read-header article))
5494 (setq gnus-newsgroup-sparse
5495 (delq article gnus-newsgroup-sparse)))
5497 ;; It's a real article.
5498 (setq article (mail-header-id header)))
5500 ;; It is an extracted pseudo-article.
5501 (setq article 'pseudo)
5502 (gnus-request-pseudo-article header))))
5504 (let ((method (gnus-find-method-for-group
5505 gnus-newsgroup-name)))
5506 (when (and (eq (car method) 'nneething)
5508 (let ((dir (nneething-get-file-name
5509 (mail-header-id header))))
5510 (when (and (stringp dir)
5511 (file-directory-p dir))
5512 (setq article 'nneething)
5513 (gnus-group-enter-directory dir))))))))
5516 ;; Refuse to select canceled articles.
5517 ((and (numberp article)
5519 (get-buffer gnus-summary-buffer)
5520 (gnus-buffer-exists-p gnus-summary-buffer)
5521 (eq (cdr (with-current-buffer gnus-summary-buffer
5522 (assq article gnus-newsgroup-reads)))
5523 gnus-canceled-mark))
5525 ;; We first check `gnus-original-article-buffer'.
5526 ((and (get-buffer gnus-original-article-buffer)
5528 (with-current-buffer gnus-original-article-buffer
5529 (and (equal (car gnus-original-article) group)
5530 (eq (cdr gnus-original-article) article))))
5531 (insert-buffer-substring gnus-original-article-buffer)
5533 ;; Check the backlog.
5534 ((and gnus-keep-backlog
5535 (gnus-backlog-request-article group article (current-buffer)))
5537 ;; Check asynchronous pre-fetch.
5538 ((gnus-async-request-fetched-article group article (current-buffer))
5539 (gnus-async-prefetch-next group article gnus-summary-buffer)
5540 (when (and (numberp article) gnus-keep-backlog)
5541 (gnus-backlog-enter-article group article (current-buffer)))
5544 ((and gnus-use-cache
5546 (gnus-cache-request-article article group))
5548 ;; Check the agent cache.
5549 ((gnus-agent-request-article article group)
5551 ;; Get the article and put into the article buffer.
5552 ((or (stringp article)
5554 (let ((gnus-override-method gnus-override-method)
5555 (methods (and (stringp article)
5556 gnus-refer-article-method))
5557 (backend (car (gnus-find-method-for-group
5558 gnus-newsgroup-name)))
5560 (inhibit-read-only t))
5561 (if (or (not (listp methods))
5562 (and (symbolp (car methods))
5563 (assq (car methods) nnoo-definition-alist)))
5564 (setq methods (list methods)))
5565 (when (and (null gnus-override-method)
5567 (setq gnus-override-method (pop methods)))
5569 (when (eq gnus-override-method 'current)
5570 (setq gnus-override-method
5571 (with-current-buffer gnus-summary-buffer
5572 gnus-current-select-method)))
5574 (gnus-kill-all-overlays)
5575 (let ((gnus-newsgroup-name group))
5576 (gnus-check-group-server))
5578 ((gnus-request-article article group (current-buffer))
5579 (when (numberp article)
5580 (gnus-async-prefetch-next group article
5581 gnus-summary-buffer)
5582 (when gnus-keep-backlog
5583 (gnus-backlog-enter-article
5584 group article (current-buffer))))
5585 (setq result 'article))
5587 (setq gnus-override-method (pop methods)))
5588 ((not (string-match "^400 "
5589 (nnheader-get-report backend)))
5590 ;; If we get 400 server disconnect, reconnect and
5591 ;; retry; otherwise, assume the article has expired.
5592 (setq result 'done))))
5593 (and (eq result 'article) 'article)))
5597 ;; Associate this article with the current summary buffer.
5598 (setq gnus-article-current-summary gnus-summary-buffer)
5600 ;; Take the article from the original article buffer
5601 ;; and place it in the buffer it's supposed to be in.
5602 (when (and (get-buffer gnus-article-buffer)
5603 (equal (buffer-name (current-buffer))
5604 (buffer-name (get-buffer gnus-article-buffer))))
5606 (if (get-buffer gnus-original-article-buffer)
5607 (set-buffer gnus-original-article-buffer)
5608 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5609 (buffer-disable-undo)
5610 (setq major-mode 'gnus-original-article-mode)
5611 (setq buffer-read-only t))
5612 (let ((inhibit-read-only t))
5614 (insert-buffer-substring gnus-article-buffer))
5615 (setq gnus-original-article (cons group article)))
5618 (run-hooks 'gnus-article-decode-hook)
5619 ;; Mark article as decoded or not.
5620 (setq gnus-article-decoded-p gnus-article-decode-hook))
5622 ;; Update sparse articles.
5623 (when (and do-update-line
5624 (or (numberp article)
5626 (let ((buf (current-buffer)))
5627 (set-buffer gnus-summary-buffer)
5628 (gnus-summary-update-article do-update-line sparse-header)
5629 (gnus-summary-goto-subject do-update-line nil t)
5630 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5632 (set-buffer buf))))))
5638 (defcustom gnus-article-edit-mode-hook nil
5639 "Hook run in article edit mode buffers."
5640 :group 'gnus-article-various
5643 (defvar gnus-article-edit-done-function nil)
5645 (defvar gnus-article-edit-mode-map nil)
5647 ;; Should we be using derived.el for this?
5648 (unless gnus-article-edit-mode-map
5649 (setq gnus-article-edit-mode-map (make-keymap))
5650 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5652 (gnus-define-keys gnus-article-edit-mode-map
5653 "\C-c?" describe-mode
5654 "\C-c\C-c" gnus-article-edit-done
5655 "\C-c\C-k" gnus-article-edit-exit
5656 "\C-c\C-f\C-t" message-goto-to
5657 "\C-c\C-f\C-o" message-goto-from
5658 "\C-c\C-f\C-b" message-goto-bcc
5659 ;;"\C-c\C-f\C-w" message-goto-fcc
5660 "\C-c\C-f\C-c" message-goto-cc
5661 "\C-c\C-f\C-s" message-goto-subject
5662 "\C-c\C-f\C-r" message-goto-reply-to
5663 "\C-c\C-f\C-n" message-goto-newsgroups
5664 "\C-c\C-f\C-d" message-goto-distribution
5665 "\C-c\C-f\C-f" message-goto-followup-to
5666 "\C-c\C-f\C-m" message-goto-mail-followup-to
5667 "\C-c\C-f\C-k" message-goto-keywords
5668 "\C-c\C-f\C-u" message-goto-summary
5669 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5670 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5671 "\C-c\C-b" message-goto-body
5672 "\C-c\C-i" message-goto-signature
5674 "\C-c\C-t" message-insert-to
5675 "\C-c\C-n" message-insert-newsgroups
5676 "\C-c\C-o" message-sort-headers
5677 "\C-c\C-e" message-elide-region
5678 "\C-c\C-v" message-delete-not-region
5679 "\C-c\C-z" message-kill-to-signature
5680 "\M-\r" message-newline-and-reformat
5681 "\C-c\C-a" mml-attach-file
5682 "\C-a" message-beginning-of-line
5684 "\M-;" comment-region)
5686 (gnus-define-keys (gnus-article-edit-wash-map
5687 "\C-c\C-w" gnus-article-edit-mode-map)
5688 "f" gnus-article-edit-full-stops))
5691 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5693 ["Fetch To" message-insert-to t]
5694 ["Fetch Newsgroups" message-insert-newsgroups t]
5696 ["To" message-goto-to t]
5697 ["From" message-goto-from t]
5698 ["Subject" message-goto-subject t]
5699 ["Cc" message-goto-cc t]
5700 ["Reply-To" message-goto-reply-to t]
5701 ["Summary" message-goto-summary t]
5702 ["Keywords" message-goto-keywords t]
5703 ["Newsgroups" message-goto-newsgroups t]
5704 ["Followup-To" message-goto-followup-to t]
5705 ["Mail-Followup-To" message-goto-mail-followup-to t]
5706 ["Distribution" message-goto-distribution t]
5707 ["Body" message-goto-body t]
5708 ["Signature" message-goto-signature t]))
5710 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5711 "Major mode for editing articles.
5712 This is an extended text-mode.
5714 \\{gnus-article-edit-mode-map}"
5715 (make-local-variable 'gnus-article-edit-done-function)
5716 (make-local-variable 'gnus-prev-winconf)
5717 (set (make-local-variable 'font-lock-defaults)
5718 '(message-font-lock-keywords t))
5719 (set (make-local-variable 'mail-header-separator) "")
5720 (set (make-local-variable 'gnus-article-edit-mode) t)
5721 (easy-menu-add message-mode-field-menu message-mode-map)
5723 (setq buffer-read-only nil)
5724 (buffer-enable-undo)
5727 (defun gnus-article-edit (&optional force)
5728 "Edit the current article.
5729 This will have permanent effect only in mail groups.
5730 If FORCE is non-nil, allow editing of articles even in read-only
5733 (when (and (not force)
5734 (gnus-group-read-only-p))
5735 (error "The current newsgroup does not support article editing"))
5736 (gnus-article-date-original)
5737 (gnus-article-edit-article
5739 `(lambda (no-highlight)
5741 (gnus-summary-edit-article-done
5742 ,(or (mail-header-references gnus-current-headers) "")
5743 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5745 (defun gnus-article-edit-article (start-func exit-func)
5746 "Start editing the contents of the current article buffer."
5747 (let ((winconf (current-window-configuration)))
5748 (set-buffer gnus-article-buffer)
5749 (let ((message-auto-save-directory
5750 ;; Don't associate the article buffer with a draft file.
5752 (gnus-article-edit-mode))
5753 (funcall start-func)
5754 (set-buffer-modified-p nil)
5755 (gnus-configure-windows 'edit-article)
5756 (setq gnus-article-edit-done-function exit-func)
5757 (setq gnus-prev-winconf winconf)
5758 (gnus-message 6 "C-c C-c to end edits")))
5760 (defun gnus-article-edit-done (&optional arg)
5761 "Update the article edits and exit."
5763 (let ((func gnus-article-edit-done-function)
5764 (buf (current-buffer))
5765 (start (window-start))
5767 (winconf gnus-prev-winconf))
5768 (widen) ;; Widen it in case that users narrowed the buffer.
5771 ;; The cache and backlog have to be flushed somewhat.
5772 (when gnus-keep-backlog
5773 (gnus-backlog-remove-article
5774 (car gnus-article-current) (cdr gnus-article-current)))
5775 ;; Flush original article as well.
5777 (when (get-buffer gnus-original-article-buffer)
5778 (set-buffer gnus-original-article-buffer)
5779 (setq gnus-original-article nil)))
5780 (when gnus-use-cache
5781 (gnus-cache-update-article
5782 (car gnus-article-current) (cdr gnus-article-current)))
5783 ;; We remove all text props from the article buffer.
5784 (kill-all-local-variables)
5785 (set-text-properties (point-min) (point-max) nil)
5787 (set-window-configuration winconf)
5789 (set-window-start (get-buffer-window buf) start)
5790 (set-window-point (get-buffer-window buf) (point)))
5791 (gnus-summary-show-article))
5793 (defun gnus-article-edit-exit ()
5794 "Exit the article editing without updating."
5796 (when (or (not (buffer-modified-p))
5797 (yes-or-no-p "Article modified; kill anyway? "))
5798 (let ((curbuf (current-buffer))
5800 (window-start (window-start)))
5802 (if (gnus-buffer-live-p gnus-original-article-buffer)
5803 (insert-buffer gnus-original-article-buffer))
5804 (let ((winconf gnus-prev-winconf))
5805 (kill-all-local-variables)
5807 (set-window-configuration winconf)
5808 ;; Tippy-toe some to make sure that point remains where it was.
5809 (save-current-buffer
5811 (set-window-start (get-buffer-window (current-buffer)) window-start)
5813 (gnus-summary-show-article)))
5815 (defun gnus-article-edit-full-stops ()
5816 "Interactively repair spacing at end of sentences."
5819 (goto-char (point-min))
5820 (search-forward-regexp "^$" nil t)
5821 (let ((case-fold-search nil))
5822 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5825 ;;; Article highlights
5828 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5830 ;;; Internal Variables:
5832 (defcustom gnus-button-url-regexp
5833 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5834 "\\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:]]\\)"
5835 "\\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\\)\\)")
5836 "Regular expression that matches URLs."
5837 :group 'gnus-article-buttons
5840 (defcustom gnus-button-valid-fqdn-regexp
5841 message-valid-fqdn-regexp
5842 "Regular expression that matches a valid FQDN."
5844 :group 'gnus-article-buttons
5847 (defcustom gnus-button-man-handler 'manual-entry
5848 "Function to use for displaying man pages.
5849 The function must take at least one argument with a string naming the
5852 :type '(choice (function-item :tag "Man" manual-entry)
5853 (function-item :tag "Woman" woman)
5854 (function :tag "Other"))
5855 :group 'gnus-article-buttons)
5857 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5858 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5859 If the default site is too slow, try to find a CTAN mirror, see
5860 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5861 the variable `gnus-button-handle-ctan'."
5863 :group 'gnus-article-buttons
5864 :link '(custom-manual "(gnus)Group Parameters")
5865 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5866 (const "http://tug.ctan.org/tex-archive/")
5867 (const "http://www.dante.de/CTAN/")
5868 (string :tag "Other")))
5870 (defcustom gnus-button-ctan-handler 'browse-url
5871 "Function to use for displaying CTAN links.
5872 The function must take one argument, the string naming the URL."
5874 :type '(choice (function-item :tag "Browse Url" browse-url)
5875 (function :tag "Other"))
5876 :group 'gnus-article-buttons)
5878 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5879 "Bogus strings removed from CTAN URLs."
5881 :group 'gnus-article-buttons
5882 :type '(choice (const "^/?tex-archive/\\|/")
5883 (regexp :tag "Other")))
5885 (defcustom gnus-button-ctan-directory-regexp
5888 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5889 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5890 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5892 "Regular expression for ctan directories.
5893 It should match all directories in the top level of `gnus-ctan-url'."
5895 :group 'gnus-article-buttons
5898 (defcustom gnus-button-mid-or-mail-regexp
5899 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
5900 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5901 gnus-button-valid-fqdn-regexp
5903 "Regular expression that matches a message ID or a mail address."
5905 :group 'gnus-article-buttons
5908 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5909 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5910 Strings like this can be either a message ID or a mail address. If it is one
5911 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5912 message ID or a mail address, respectively. If this variable is set to the
5913 symbol `ask', always query the user what do do. If it is a function, this
5914 function will be called with the string as it's only argument. The function
5915 must return `mid', `mail', `invalid' or `ask'."
5917 :group 'gnus-article-buttons
5918 :type '(choice (function-item :tag "Heuristic function"
5919 gnus-button-mid-or-mail-heuristic)
5924 (defcustom gnus-button-mid-or-mail-heuristic-alist
5925 '((-10.0 . ".+\\$.+@")
5928 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5929 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5930 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5931 (-1.0 . "^[^a-z]+@")
5933 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5934 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5935 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5936 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5939 (-1.0 . "^[0-9][0-9]")
5941 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5942 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5943 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5944 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5946 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5947 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5950 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5952 ;; compensation for TDMA dated mail addresses:
5953 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5955 (-20.0 . "\\.fsf@") ;; Gnus
5958 (-20.0 . "_-_") ;; Subject change in thread
5960 (-20.0 . "\\.ln@") ;; leafnode
5961 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5962 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5964 ;; (5.0 . "") ;; $local_part_len <= 7
5965 (10.0 . "^[^0-9]+@")
5966 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5967 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5970 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5972 (0.5 . "^[A-Z][a-z]")
5973 (0.5 . "^[A-Z][a-z][a-z]")
5974 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5975 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5976 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5978 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5979 address. The REGEXP is processed with `case-fold-search' set to nil."
5981 :group 'gnus-article-buttons
5982 :type '(repeat (cons (number :tag "Rate")
5983 (regexp :tag "Regexp"))))
5985 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5986 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5987 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5988 address, `ask' if unsure and `invalid' if the string is invalid."
5989 (let ((case-fold-search nil)
5990 (list gnus-button-mid-or-mail-heuristic-alist)
5991 (result 0) rate regexp lpartlen elem)
5993 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5994 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5995 ;; Certain special cases...
5998 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
5999 "^[0-9]+\\.[0-9]+@compuserve\\|"
6000 "@public\\.gmane\\.org")
6002 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6003 (setq result 'mail))
6004 (when (string-match "@.*@\\| " mid-or-mail)
6005 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6006 (setq result 'invalid))
6007 ;; Nothing more to do, if result is not a number here...
6008 (when (numberp result)
6010 (setq elem (car list)
6014 (when (string-match regexp mid-or-mail)
6015 (setq result (+ result rate))
6017 9 "`%s' matched `%s', rate `%s', result `%s'."
6018 mid-or-mail regexp rate result)))
6019 (when (<= lpartlen 7)
6020 (setq result (+ result 5.0))
6021 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6022 mid-or-mail result))
6023 (when (>= lpartlen 12)
6024 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6026 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6027 ;; Long local part should contain realname if e-mail address,
6028 ;; too many digits: message-id.
6029 ;; $score -= 5.0 + 0.1 * $local_part_len;
6030 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6031 (setq result (+ result rate))
6033 9 "Many digits in `%s', rate `%s', result `%s'."
6034 mid-or-mail rate result))
6035 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6037 ;; Too few vowels [^aeiouy]{4,}.*\@
6038 (setq result (+ result -5.0))
6040 9 "Few vowels in `%s', rate `%s', result `%s'."
6041 mid-or-mail -5.0 result))
6043 (setq result (+ result 5.0))
6045 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6046 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6047 ;; Maybe we should make this a customizable alist: (condition . 'result)
6049 ((symbolp result) result)
6050 ;; Now convert number into proper results:
6051 ((< result -10.0) 'mid)
6052 ((> result 10.0) 'mail)
6055 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6056 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6057 (url-mid (concat "news" ":" mid-or-mail))
6058 (url-mailto (concat "mailto" ":" mid-or-mail)))
6059 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6060 (when (fboundp pref)
6062 ;; get rid of surrounding angles...
6064 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6065 (if (or (eq 'mid guessed) (eq 'mail guessed))
6069 (save-window-excursion
6070 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6073 (cond ((eq pref 'mid)
6074 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6075 (gnus-button-handle-news url-mid))
6077 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6078 (gnus-url-mailto url-mailto))
6079 (t (gnus-message 3 "Invalid string.")))))
6081 (defun gnus-button-handle-custom (url)
6082 "Follow a Custom URL."
6083 (customize-apropos (gnus-url-unhex-string url)))
6085 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6087 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6090 (defun gnus-button-handle-describe-function (url)
6091 "Call `describe-function' when pushing the corresponding URL button."
6094 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6096 (defun gnus-button-handle-describe-variable (url)
6097 "Call `describe-variable' when pushing the corresponding URL button."
6100 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6102 (defun gnus-button-handle-symbol (url)
6103 "Display help on variable or function.
6104 Calls `describe-variable' or `describe-function'."
6105 (let ((sym (intern url)))
6107 ((fboundp sym) (describe-function sym))
6108 ((boundp sym) (describe-variable sym))
6109 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6111 (defun gnus-button-handle-describe-key (url)
6112 "Call `describe-key' when pushing the corresponding URL button."
6114 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6115 (keys (ignore-errors (eval `(kbd ,key-string)))))
6118 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6120 (defun gnus-button-handle-apropos (url)
6121 "Call `apropos' when pushing the corresponding URL button."
6122 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6124 (defun gnus-button-handle-apropos-command (url)
6125 "Call `apropos' when pushing the corresponding URL button."
6127 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6129 (defun gnus-button-handle-apropos-variable (url)
6130 "Call `apropos' when pushing the corresponding URL button."
6132 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6133 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6135 (defun gnus-button-handle-apropos-documentation (url)
6136 "Call `apropos' when pushing the corresponding URL button."
6138 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6139 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6141 (defun gnus-button-handle-library (url)
6142 "Call `locate-library' when pushing the corresponding URL button."
6143 (gnus-message 9 "url=`%s'" url)
6144 (let* ((lib (locate-library url))
6145 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6147 (gnus-message 1 "Cannot locale library `%s'." url)
6148 (find-file-read-only file))))
6150 (defun gnus-button-handle-ctan (url)
6151 "Call `browse-url' when pushing a CTAN URL button."
6153 gnus-button-ctan-handler
6156 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6158 (defcustom gnus-button-tex-level 5
6159 "*Integer that says how many TeX-related buttons Gnus will show.
6160 The higher the number, the more buttons will appear and the more false
6161 positives are possible. Note that you can set this variable local to
6162 specific groups. Setting it higher in TeX groups is probably a good idea.
6163 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6164 how to set variables in specific groups."
6166 :group 'gnus-article-buttons
6167 :link '(custom-manual "(gnus)Group Parameters")
6170 (defcustom gnus-button-man-level 5
6171 "*Integer that says how many man-related buttons Gnus will show.
6172 The higher the number, the more buttons will appear and the more false
6173 positives are possible. Note that you can set this variable local to
6174 specific groups. Setting it higher in Unix groups is probably a good idea.
6175 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6176 how to set variables in specific groups."
6178 :group 'gnus-article-buttons
6179 :link '(custom-manual "(gnus)Group Parameters")
6182 (defcustom gnus-button-emacs-level 5
6183 "*Integer that says how many emacs-related buttons Gnus will show.
6184 The higher the number, the more buttons will appear and the more false
6185 positives are possible. Note that you can set this variable local to
6186 specific groups. Setting it higher in Emacs or Gnus related groups is
6187 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6188 `gnus-parameters' on how to set variables in specific groups."
6190 :group 'gnus-article-buttons
6191 :link '(custom-manual "(gnus)Group Parameters")
6194 (defcustom gnus-button-message-level 5
6195 "*Integer that says how many buttons for news or mail messages will appear.
6196 The higher the number, the more buttons will appear and the more false
6197 positives are possible."
6198 ;; mail addresses, MIDs, URLs for news, ...
6200 :group 'gnus-article-buttons
6203 (defcustom gnus-button-browse-level 5
6204 "*Integer that says how many buttons for browsing will appear.
6205 The higher the number, the more buttons will appear and the more false
6206 positives are possible."
6207 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6209 :group 'gnus-article-buttons
6212 (defcustom gnus-button-alist
6213 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6214 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6215 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6216 gnus-button-handle-news 2)
6217 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6218 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6219 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6220 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6221 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6222 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6223 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6224 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6225 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6226 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6227 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6228 ;; RFC 2368 (The mailto URL scheme)
6229 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6230 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6231 ("\\bmailto:\\([^ \n\t]+\\)"
6232 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6234 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6235 gnus-button-ctan-directory-regexp
6236 "[^][>)!;:,'\n\t ]+\\)")
6237 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6238 ((concat "\\btex-archive/\\("
6239 gnus-button-ctan-directory-regexp
6240 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6241 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6244 gnus-button-ctan-directory-regexp
6245 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6246 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6247 ;; This is info (home-grown style) <info://foo/bar+baz>
6248 ("\\binfo://\\([^'\">\n\t ]+\\)"
6249 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6250 ;; Info GNOME style <info:foo#bar_baz>
6251 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6252 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6253 ;; Info KDE style <info:(foo)bar baz>
6254 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6255 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6256 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6257 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6258 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6259 ;; Info links like `C-h i d m CC Mode RET'
6260 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6262 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6263 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6264 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6265 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6266 ;; Emacs help commands
6267 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6268 ;; regexp doesn't match arguments containing ` '.
6269 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6270 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6271 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6272 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6273 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6274 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6275 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6276 ;; The following entries may lead to many false positives so don't enable
6277 ;; them by default (use a high button level).
6278 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6279 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6280 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6281 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6282 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6283 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6284 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6285 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6286 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6287 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6288 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6289 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6290 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6291 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6292 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6293 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6294 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6295 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6296 ;; Unlike the other regexps we really have to require quoting
6297 ;; here to determine where it ends.
6298 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6299 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6300 ("<URL: *\\([^<>]*\\)>"
6301 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6302 ;; RFC 2396 (2.4.3., delims) ...
6303 ("\"URL: *\\([^\"]*\\)\""
6304 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6305 ;; RFC 2396 (2.4.3., delims) ...
6306 ("\"URL: *\\([^\"]*\\)\""
6307 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6309 (gnus-button-url-regexp
6310 0 (>= gnus-button-browse-level 0) browse-url 0)
6312 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6313 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6314 gnus-button-handle-man 1)
6315 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6316 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6317 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6318 gnus-button-handle-man 1)
6319 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6320 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6321 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6322 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6323 ;; MID or mail: To avoid too many false positives we don't try to catch
6324 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6325 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6326 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6327 ;; so that non-ambiguous entries (see above) match first.
6328 (gnus-button-mid-or-mail-regexp
6329 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6330 "*Alist of regexps matching buttons in article bodies.
6332 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6333 REGEXP: is the string (case insensitive) matching text around the button (can
6334 also be Lisp expression evaluating to a string),
6335 BUTTON: is the number of the regexp grouping actually matching the button,
6336 FORM: is a Lisp expression which must eval to true for the button to
6338 CALLBACK: is the function to call when the user push this button, and each
6339 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6341 CALLBACK can also be a variable, in that case the value of that
6342 variable it the real callback function."
6343 :group 'gnus-article-buttons
6344 :type '(repeat (list (choice regexp variable sexp)
6345 (integer :tag "Button")
6347 (function :tag "Callback")
6350 (integer :tag "Regexp group")))))
6352 (defcustom gnus-header-button-alist
6353 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6354 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6355 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6356 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6357 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6358 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6359 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6360 0 (>= gnus-button-browse-level 0) browse-url 0)
6361 ("^Subject:" gnus-button-url-regexp
6362 0 (>= gnus-button-browse-level 0) browse-url 0)
6363 ("^[^:]+:" gnus-button-url-regexp
6364 0 (>= gnus-button-browse-level 0) browse-url 0)
6365 ("^OpenPGP:.*url=" gnus-button-url-regexp
6366 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6367 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6368 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6369 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6370 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6371 "*Alist of headers and regexps to match buttons in article heads.
6373 This alist is very similar to `gnus-button-alist', except that each
6374 alist has an additional HEADER element first in each entry:
6376 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6378 HEADER is a regexp to match a header. For a fuller explanation, see
6379 `gnus-button-alist'."
6380 :group 'gnus-article-buttons
6381 :group 'gnus-article-headers
6382 :type '(repeat (list (regexp :tag "Header")
6383 (choice regexp variable)
6384 (integer :tag "Button")
6386 (function :tag "Callback")
6389 (integer :tag "Regexp group")))))
6393 (defun gnus-article-push-button (event)
6394 "Check text under the mouse pointer for a callback function.
6395 If the text under the mouse pointer has a `gnus-callback' property,
6396 call it with the value of the `gnus-data' text property."
6398 (set-buffer (window-buffer (posn-window (event-start event))))
6399 (let* ((pos (posn-point (event-start event)))
6400 (data (get-text-property pos 'gnus-data))
6401 (fun (get-text-property pos 'gnus-callback)))
6404 (funcall fun data))))
6406 (defun gnus-article-press-button ()
6407 "Check text at point for a callback function.
6408 If the text at point has a `gnus-callback' property,
6409 call it with the value of the `gnus-data' text property."
6411 (let ((data (get-text-property (point) 'gnus-data))
6412 (fun (get-text-property (point) 'gnus-callback)))
6414 (funcall fun data))))
6416 (defun gnus-article-highlight (&optional force)
6417 "Highlight current article.
6418 This function calls `gnus-article-highlight-headers',
6419 `gnus-article-highlight-citation',
6420 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6421 do the highlighting. See the documentation for those functions."
6422 (interactive (list 'force))
6423 (gnus-article-highlight-headers)
6424 (gnus-article-highlight-citation force)
6425 (gnus-article-highlight-signature)
6426 (gnus-article-add-buttons force)
6427 (gnus-article-add-buttons-to-head))
6429 (defun gnus-article-highlight-some (&optional force)
6430 "Highlight current article.
6431 This function calls `gnus-article-highlight-headers',
6432 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6433 do the highlighting. See the documentation for those functions."
6434 (interactive (list 'force))
6435 (gnus-article-highlight-headers)
6436 (gnus-article-highlight-signature)
6437 (gnus-article-add-buttons))
6439 (defun gnus-article-highlight-headers ()
6440 "Highlight article headers as specified by `gnus-header-face-alist'."
6442 (gnus-with-article-headers
6443 (let (regexp header-face field-face from hpoints fpoints)
6444 (dolist (entry gnus-header-face-alist)
6445 (goto-char (point-min))
6446 (setq regexp (concat "^\\("
6447 (if (string-equal "" (nth 0 entry))
6451 header-face (nth 1 entry)
6452 field-face (nth 2 entry))
6453 (while (and (re-search-forward regexp nil t)
6457 (unless (search-forward ":" nil t)
6459 (when (and header-face
6460 (not (memq (point) hpoints)))
6461 (push (point) hpoints)
6462 (gnus-put-text-property from (point) 'face header-face))
6463 (when (and field-face
6464 (not (memq (setq from (point)) fpoints)))
6466 (if (re-search-forward "^[^ \t]" nil t)
6468 (goto-char (point-max)))
6469 (gnus-put-text-property from (point) 'face field-face)))))))
6471 (defun gnus-article-highlight-signature ()
6472 "Highlight the signature in an article.
6473 It does this by highlighting everything after
6474 `gnus-signature-separator' using `gnus-signature-face'."
6476 (gnus-with-article-buffer
6477 (let ((inhibit-point-motion-hooks t))
6479 (when (and gnus-signature-face
6480 (gnus-article-narrow-to-signature))
6481 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6482 'face gnus-signature-face)
6484 (gnus-article-search-signature)
6485 (let ((start (match-beginning 0))
6486 (end (set-marker (make-marker) (1+ (match-end 0)))))
6487 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6490 (defun gnus-button-in-region-p (b e prop)
6491 "Say whether PROP exists in the region."
6492 (text-property-not-all b e prop nil))
6494 (defun gnus-article-add-buttons (&optional force)
6495 "Find external references in the article and make buttons of them.
6496 \"External references\" are things like Message-IDs and URLs, as
6497 specified by `gnus-button-alist'."
6498 (interactive (list 'force))
6499 (gnus-with-article-buffer
6500 (let ((inhibit-point-motion-hooks t)
6501 (case-fold-search t)
6502 (alist gnus-button-alist)
6504 ;; Remove all old markers.
6505 (let (marker entry new-list)
6506 (while (setq marker (pop gnus-button-marker-list))
6507 (if (or (< marker (point-min)) (>= marker (point-max)))
6508 (push marker new-list)
6510 (when (setq entry (gnus-button-entry))
6511 (put-text-property (match-beginning (nth 1 entry))
6512 (match-end (nth 1 entry))
6513 'gnus-callback nil))
6514 (set-marker marker nil)))
6515 (setq gnus-button-marker-list new-list))
6516 ;; We skip the headers.
6519 (while (setq entry (pop alist))
6520 (setq regexp (eval (car entry)))
6522 (while (re-search-forward regexp nil t)
6523 (let* ((start (and entry (match-beginning (nth 1 entry))))
6524 (end (and entry (match-end (nth 1 entry))))
6525 (from (match-beginning 0)))
6526 (when (and (or (eq t (nth 2 entry))
6527 (eval (nth 2 entry)))
6528 (not (gnus-button-in-region-p
6529 start end 'gnus-callback)))
6530 ;; That optional form returned non-nil, so we add the
6532 (gnus-article-add-button
6533 start end 'gnus-button-push
6534 (car (push (set-marker (make-marker) from)
6535 gnus-button-marker-list))))))))))
6537 ;; Add buttons to the head of an article.
6538 (defun gnus-article-add-buttons-to-head ()
6539 "Add buttons to the head of the article."
6541 (gnus-with-article-headers
6543 (dolist (entry gnus-header-button-alist)
6544 ;; Each alist entry.
6545 (goto-char (point-min))
6546 (while (re-search-forward (car entry) nil t)
6547 ;; Each header matching the entry.
6548 (setq beg (match-beginning 0))
6549 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6550 (match-beginning 0))
6553 (while (re-search-forward (eval (nth 1 entry)) end t)
6554 ;; Each match within a header.
6555 (let* ((entry (cdr entry))
6556 (start (match-beginning (nth 1 entry)))
6557 (end (match-end (nth 1 entry)))
6558 (form (nth 2 entry)))
6559 (goto-char (match-end 0))
6561 (gnus-article-add-button
6562 start end (nth 3 entry)
6563 (buffer-substring (match-beginning (nth 4 entry))
6564 (match-end (nth 4 entry)))))))
6565 (goto-char end))))))
6567 ;;; External functions:
6569 (defun gnus-article-add-button (from to fun &optional data)
6570 "Create a button between FROM and TO with callback FUN and data DATA."
6571 (when gnus-article-button-face
6572 (gnus-overlay-put (gnus-make-overlay from to)
6573 'face gnus-article-button-face))
6574 (gnus-add-text-properties
6576 (nconc (and gnus-article-mouse-face
6577 (list gnus-mouse-face-prop gnus-article-mouse-face))
6578 (list 'gnus-callback fun)
6579 (and data (list 'gnus-data data))))
6580 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6581 :button-keymap gnus-widget-button-keymap))
6583 ;;; Internal functions:
6585 (defun gnus-article-set-globals ()
6586 (with-current-buffer gnus-summary-buffer
6587 (gnus-set-global-variables)))
6589 (defun gnus-signature-toggle (end)
6590 (gnus-with-article-buffer
6591 (let ((inhibit-point-motion-hooks t))
6592 (if (text-property-any end (point-max) 'article-type 'signature)
6594 (gnus-delete-wash-type 'signature)
6595 (gnus-remove-text-properties-when
6596 'article-type 'signature end (point-max)
6597 (cons 'article-type (cons 'signature
6598 gnus-hidden-properties))))
6599 (gnus-add-wash-type 'signature)
6600 (gnus-add-text-properties-when
6601 'article-type nil end (point-max)
6602 (cons 'article-type (cons 'signature
6603 gnus-hidden-properties)))))
6604 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6605 (gnus-set-mode-line 'article))))
6607 (defun gnus-button-entry ()
6608 ;; Return the first entry in `gnus-button-alist' matching this place.
6609 (let ((alist gnus-button-alist)
6612 (setq entry (pop alist))
6613 (if (looking-at (eval (car entry)))
6618 (defun gnus-button-push (marker)
6619 ;; Push button starting at MARKER.
6622 (let* ((entry (gnus-button-entry))
6623 (inhibit-point-motion-hooks t)
6625 (args (mapcar (lambda (group)
6626 (let ((string (match-string group)))
6627 (set-text-properties
6628 0 (length string) nil string)
6635 (fboundp (symbol-value fun)))
6636 (apply (symbol-value fun) args))
6638 (gnus-message 1 "You must define `%S' to use this button"
6639 (cons fun args)))))))
6641 (defun gnus-parse-news-url (url)
6642 (let (scheme server port group message-id articles)
6645 (goto-char (point-min))
6646 (when (looking-at "\\([A-Za-z]+\\):")
6647 (setq scheme (match-string 1))
6648 (goto-char (match-end 0)))
6649 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
6650 (setq server (match-string 1))
6651 (setq port (if (stringp (match-string 3))
6652 (string-to-number (match-string 3))
6654 (goto-char (match-end 0)))
6657 ((looking-at "\\(.*@.*\\)")
6658 (setq message-id (match-string 1)))
6659 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6660 (setq group (match-string 1)
6661 articles (split-string (match-string 2) "-")))
6662 ((looking-at "\\([^/]+\\)/?")
6663 (setq group (match-string 1)))
6665 (error "Unknown news URL syntax"))))
6666 (list scheme server port group message-id articles)))
6668 (defun gnus-button-handle-news (url)
6670 (destructuring-bind (scheme server port group message-id articles)
6671 (gnus-parse-news-url url)
6675 (set-buffer gnus-summary-buffer)
6677 (let ((gnus-refer-article-method
6678 (nconc (list (list 'nntp server))
6679 gnus-refer-article-method))
6680 (nntp-port-number (or port "nntp")))
6681 (gnus-message 7 "Fetching %s with %s"
6682 message-id gnus-refer-article-method)
6683 (gnus-summary-refer-article message-id))
6684 (gnus-summary-refer-article message-id))))
6686 (gnus-button-fetch-group url)))))
6688 (defun gnus-button-handle-man (url)
6690 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6691 (when (eq gnus-button-man-handler 'woman)
6692 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
6693 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6694 (funcall gnus-button-man-handler url))
6696 (defun gnus-button-handle-info-url (url)
6697 "Fetch an info URL."
6698 (setq url (mm-subst-char-in-string ?+ ?\ url))
6700 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6701 (gnus-info-find-node
6702 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6704 ")" (gnus-url-unhex-string (match-string 2 url)))))
6705 ((string-match "([^)\"]+)[^\"]+" url)
6707 (gnus-replace-in-string
6708 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6709 (gnus-info-find-node url))
6710 (t (error "Can't parse %s" url))))
6712 (defun gnus-button-handle-info-url-gnome (url)
6713 "Fetch GNOME style info URL."
6714 (setq url (mm-subst-char-in-string ?_ ?\ url))
6715 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6716 (gnus-info-find-node
6718 (gnus-url-unhex-string
6719 (match-string 1 url))
6721 (or (gnus-url-unhex-string
6722 (match-string 2 url))
6724 (error "Can't parse %s" url)))
6726 (defun gnus-button-handle-info-url-kde (url)
6727 "Fetch KDE style info URL."
6728 (gnus-info-find-node (gnus-url-unhex-string url)))
6730 (defun gnus-button-handle-info-keystrokes (url)
6731 "Call `info' when pushing the corresponding URL button."
6732 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6737 (defun gnus-button-openpgp (url)
6738 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
6740 (mm-url-insert-file-contents-external url)
6741 (pgg-snarf-keys-region (point-min) (point-max))
6742 (pgg-display-output-buffer nil nil nil)))
6744 (defun gnus-button-message-id (message-id)
6746 (with-current-buffer gnus-summary-buffer
6747 (gnus-summary-refer-article message-id)))
6749 (defun gnus-button-fetch-group (address)
6750 "Fetch GROUP specified by ADDRESS."
6751 (if (not (string-match "[:/]" address))
6752 ;; This is just a simple group url.
6753 (gnus-group-read-ephemeral-group address gnus-select-method)
6756 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6758 (error "Can't parse %s" address)
6759 (gnus-group-read-ephemeral-group
6760 (match-string 4 address)
6761 `(nntp ,(match-string 1 address)
6762 (nntp-address ,(match-string 1 address))
6763 (nntp-port-number ,(if (match-end 3)
6764 (match-string 3 address)
6767 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
6769 (defun gnus-url-parse-query-string (query &optional downcase)
6770 (let (retval pairs cur key val)
6771 (setq pairs (split-string query "&"))
6773 (setq cur (car pairs)
6775 (if (not (string-match "=" cur))
6777 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6778 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6780 (setq key (downcase key)))
6781 (setq cur (assoc key retval))
6783 (setcdr cur (cons val (cdr cur)))
6784 (setq retval (cons (list key val) retval)))))
6787 (defun gnus-url-mailto (url)
6788 ;; Send mail to someone
6789 (when (string-match "mailto:/*\\(.*\\)" url)
6790 (setq url (substring url (match-beginning 1) nil)))
6791 (let (to args subject func)
6792 (setq args (gnus-url-parse-query-string
6793 (if (string-match "^\\?" url)
6795 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6796 (concat "to=" (match-string 1 url) "&"
6797 (match-string 2 url))
6798 (concat "to=" url)))
6800 subject (cdr-safe (assoc "subject" args)))
6803 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6806 (message-position-on-field (caar args)))
6807 (insert (gnus-replace-in-string
6808 (mapconcat 'identity (reverse (cdar args)) ", ")
6810 (setq args (cdr args)))
6813 (message-goto-subject))))
6815 (defun gnus-button-embedded-url (address)
6816 "Activate ADDRESS with `browse-url'."
6817 (browse-url (gnus-strip-whitespace address)))
6819 ;;; Next/prev buttons in the article buffer.
6821 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6822 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6824 (defvar gnus-prev-page-map
6825 (let ((map (make-sparse-keymap)))
6826 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6827 (define-key map "\r" 'gnus-button-prev-page)
6830 (defvar gnus-next-page-map
6831 (let ((map (make-sparse-keymap)))
6832 (unless (>= emacs-major-version 21)
6833 ;; XEmacs doesn't care.
6834 (set-keymap-parent map gnus-article-mode-map))
6835 (define-key map gnus-mouse-2 'gnus-button-next-page)
6836 (define-key map "\r" 'gnus-button-next-page)
6839 (defun gnus-insert-prev-page-button ()
6841 (inhibit-read-only t))
6843 gnus-prev-page-line-format nil
6844 `(keymap ,gnus-prev-page-map
6846 gnus-callback gnus-article-button-prev-page
6847 article-type annotation))
6848 (widget-convert-button
6850 ;; Exclude a newline.
6853 :action 'gnus-button-prev-page
6854 :button-keymap gnus-prev-page-map)))
6856 (defun gnus-button-next-page (&optional args more-args)
6857 "Go to the next page."
6859 (let ((win (selected-window)))
6860 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6861 (gnus-article-next-page)
6862 (select-window win)))
6864 (defun gnus-button-prev-page (&optional args more-args)
6865 "Go to the prev page."
6867 (let ((win (selected-window)))
6868 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6869 (gnus-article-prev-page)
6870 (select-window win)))
6872 (defun gnus-insert-next-page-button ()
6874 (inhibit-read-only t))
6875 (gnus-eval-format gnus-next-page-line-format nil
6876 `(keymap ,gnus-next-page-map
6878 gnus-callback gnus-article-button-next-page
6879 article-type annotation))
6880 (widget-convert-button
6882 ;; Exclude a newline.
6885 :action 'gnus-button-next-page
6886 :button-keymap gnus-next-page-map)))
6888 (defun gnus-article-button-next-page (arg)
6889 "Go to the next page."
6891 (let ((win (selected-window)))
6892 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6893 (gnus-article-next-page)
6894 (select-window win)))
6896 (defun gnus-article-button-prev-page (arg)
6897 "Go to the prev page."
6899 (let ((win (selected-window)))
6900 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6901 (gnus-article-prev-page)
6902 (select-window win)))
6904 (defvar gnus-decode-header-methods
6905 '(mail-decode-encoded-word-region)
6906 "List of methods used to decode headers.
6908 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6909 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
6910 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6911 whose names match REGEXP.
6914 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6915 mail-decode-encoded-word-region
6916 (\"chinese\" . rfc1843-decode-region))
6919 (defvar gnus-decode-header-methods-cache nil)
6921 (defun gnus-multi-decode-header (start end)
6922 "Apply the functions from `gnus-encoded-word-methods' that match."
6923 (unless (and gnus-decode-header-methods-cache
6924 (eq gnus-newsgroup-name
6925 (car gnus-decode-header-methods-cache)))
6926 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6929 (nconc gnus-decode-header-methods-cache (list x))
6930 (if (and gnus-newsgroup-name
6931 (string-match (car x) gnus-newsgroup-name))
6932 (nconc gnus-decode-header-methods-cache
6934 gnus-decode-header-methods))
6935 (let ((xlist gnus-decode-header-methods-cache))
6938 (narrow-to-region start end)
6940 (funcall (pop xlist) (point-min) (point-max))))))
6943 ;;; Treatment top-level handling.
6946 (defun gnus-treat-article (condition &optional part-number total-parts type)
6947 (let ((length (- (point-max) (point-min)))
6948 (alist gnus-treatment-function-alist)
6949 (article-goto-body-goes-to-point-min-p t)
6953 (let ((list gnus-article-treat-types))
6955 (when (string-match (pop list) type)
6956 (throw 'found t)))))))
6957 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6959 (gnus-run-hooks 'gnus-part-display-hook)
6960 (dolist (elem alist)
6963 (when (gnus-buffer-live-p gnus-summary-buffer)
6964 (set-buffer gnus-summary-buffer))
6965 (symbol-value (car elem))))
6966 (when (and (or (consp val)
6968 (gnus-treat-predicate val)
6969 (or (not (get (car elem) 'highlight))
6972 (funcall (cadr elem)))))))
6974 ;; Dynamic variables.
6976 (defvar part-number)
6977 (defvar total-parts)
6982 (defun gnus-treat-predicate (val)
6989 (stringp (car val)))
6990 (apply 'gnus-or (mapcar `(lambda (s)
6991 (string-match s ,(or gnus-newsgroup-name "")))
6994 (let ((pred (pop val)))
6997 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6999 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7001 (not (gnus-treat-predicate (car val))))
7003 (equal (car val) type))
7005 (error "%S is not a valid predicate" pred)))))
7011 (eq part-number total-parts))
7015 (error "%S is not a valid value" val))))
7017 (defun gnus-article-encrypt-body (protocol &optional n)
7018 "Encrypt the article body."
7021 (or gnus-article-encrypt-protocol
7022 (completing-read "Encrypt protocol: "
7023 gnus-article-encrypt-protocol-alist
7025 current-prefix-arg))
7026 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7028 (error (format "Can't find the encrypt protocol %s" protocol)))
7029 (if (member gnus-newsgroup-name '("nndraft:delayed"
7032 (error "Can't encrypt the article in group %s"
7033 gnus-newsgroup-name))
7034 (gnus-summary-iterate n
7036 (set-buffer gnus-summary-buffer)
7037 (let ((mail-parse-charset gnus-newsgroup-charset)
7038 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7039 (summary-buffer gnus-summary-buffer)
7041 (gnus-set-global-variables)
7042 (when (gnus-group-read-only-p)
7043 (error "The current newsgroup does not support article encrypt"))
7044 (gnus-summary-show-article t)
7046 (or (mail-header-references gnus-current-headers) ""))
7047 (set-buffer gnus-article-buffer)
7048 (let* ((inhibit-read-only t)
7050 (mapcar (lambda (field)
7051 (and (save-restriction
7052 (message-narrow-to-head)
7053 (goto-char (point-min))
7054 (search-forward field nil t))
7056 (message-narrow-to-field)
7058 (delete-region (point-min) (point-max))
7060 '("Content-Type:" "Content-Transfer-Encoding:"
7061 "Content-Disposition:"))))
7062 (message-narrow-to-head)
7063 (message-remove-header "MIME-Version")
7064 (goto-char (point-max))
7065 (setq point (point))
7066 (insert (apply 'concat headers))
7068 (narrow-to-region point (point-max))
7069 (let ((message-options message-options))
7070 (message-options-set 'message-sender user-mail-address)
7071 (message-options-set 'message-recipients user-mail-address)
7072 (message-options-set 'message-sign-encrypt 'not)
7074 (goto-char (point-min))
7075 (insert "MIME-Version: 1.0\n")
7077 (gnus-summary-edit-article-done
7078 references nil summary-buffer t))
7079 (when gnus-keep-backlog
7080 (gnus-backlog-remove-article
7081 (car gnus-article-current) (cdr gnus-article-current)))
7083 (when (get-buffer gnus-original-article-buffer)
7084 (set-buffer gnus-original-article-buffer)
7085 (setq gnus-original-article nil)))
7086 (when gnus-use-cache
7087 (gnus-cache-update-article
7088 (car gnus-article-current) (cdr gnus-article-current))))))))
7090 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7091 "The following specs can be used:
7092 %t The security MIME type
7095 %D Details if button is pressed")
7097 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7098 "The following specs can be used:
7099 %t The security MIME type
7102 %D Details if button is pressed")
7104 (defvar gnus-mime-security-button-line-format-alist
7105 '((?t gnus-tmp-type ?s)
7106 (?i gnus-tmp-info ?s)
7107 (?d gnus-tmp-details ?s)
7108 (?D gnus-tmp-pressed-details ?s)))
7110 (defvar gnus-mime-security-button-map
7111 (let ((map (make-sparse-keymap)))
7112 (define-key map gnus-mouse-2 'gnus-article-push-button)
7113 (define-key map "\r" 'gnus-article-press-button)
7116 (defvar gnus-mime-security-details-buffer nil)
7118 (defvar gnus-mime-security-button-pressed nil)
7120 (defvar gnus-mime-security-show-details-inline t
7121 "If non-nil, show details in the article buffer.")
7123 (defun gnus-mime-security-verify-or-decrypt (handle)
7124 (mm-remove-parts (cdr handle))
7125 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7126 point (inhibit-read-only t))
7128 (goto-char (car region)))
7130 (narrow-to-region (point) (point))
7131 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7132 (let* ((mm-verify-option 'known)
7133 (mm-decrypt-option 'known)
7134 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7135 (unless (eq nparts (cdr handle))
7136 (mm-destroy-parts (cdr handle))
7137 (setcdr handle nparts))))
7138 (setq point (point))
7139 (gnus-mime-display-security handle)
7140 (goto-char (point-max)))
7142 (delete-region (point) (cdr region))
7143 (set-marker (car region) nil)
7144 (set-marker (cdr region) nil))
7147 (defun gnus-mime-security-show-details (handle)
7148 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7150 (gnus-message 5 "No details.")
7151 (if gnus-mime-security-show-details-inline
7152 (let ((gnus-mime-security-button-pressed
7153 (not (get-text-property (point) 'gnus-mime-details)))
7154 (gnus-mime-security-button-line-format
7155 (get-text-property (point) 'gnus-line-format))
7156 (inhibit-read-only t))
7158 (while (eq (get-text-property (point) 'gnus-line-format)
7159 gnus-mime-security-button-line-format)
7163 (narrow-to-region (point) (point))
7164 (gnus-insert-mime-security-button handle))
7165 (delete-region (point)
7166 (or (text-property-not-all
7169 gnus-mime-security-button-line-format)
7172 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7173 (with-current-buffer gnus-mime-security-details-buffer
7176 (setq gnus-mime-security-details-buffer
7177 (gnus-get-buffer-create "*MIME Security Details*")))
7178 (with-current-buffer gnus-mime-security-details-buffer
7180 (goto-char (point-min)))
7181 (pop-to-buffer gnus-mime-security-details-buffer)))))
7183 (defun gnus-mime-security-press-button (handle)
7185 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7186 (gnus-mime-security-show-details handle)
7187 (gnus-mime-security-verify-or-decrypt handle))))
7189 (defun gnus-insert-mime-security-button (handle &optional displayed)
7190 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7193 (or (nth 2 (assoc protocol mm-verify-function-alist))
7194 (nth 2 (assoc protocol mm-decrypt-function-alist))
7196 (if (equal (car handle) "multipart/signed")
7197 " Signed" " Encrypted")
7200 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7203 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7204 gnus-tmp-pressed-details
7206 (setq gnus-tmp-details
7207 (if gnus-tmp-details
7208 (concat "\n" gnus-tmp-details)
7210 (setq gnus-tmp-pressed-details
7211 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7216 gnus-mime-security-button-line-format
7217 gnus-mime-security-button-line-format-alist
7218 `(keymap ,gnus-mime-security-button-map
7219 gnus-callback gnus-mime-security-press-button
7220 gnus-line-format ,gnus-mime-security-button-line-format
7221 gnus-mime-details ,gnus-mime-security-button-pressed
7222 article-type annotation
7225 ;; Exclude a newline.
7228 (widget-convert-button
7231 :action 'gnus-widget-press-button
7232 :button-keymap gnus-mime-security-button-map
7234 (lambda (widget/window &optional overlay pos)
7235 ;; Needed to properly clear the message due to a bug in
7236 ;; wid-edit (XEmacs only).
7237 (when (boundp 'help-echo-owns-message)
7238 (setq help-echo-owns-message t))
7241 (aref gnus-mouse-2 0))))))
7243 (defun gnus-mime-display-security (handle)
7245 (narrow-to-region (point) (point))
7246 (unless (gnus-unbuttonized-mime-type-p (car handle))
7247 (gnus-insert-mime-security-button handle))
7248 (gnus-mime-display-mixed (cdr handle))
7251 (unless (gnus-unbuttonized-mime-type-p (car handle))
7252 (let ((gnus-mime-security-button-line-format
7253 gnus-mime-security-button-end-line-format))
7254 (gnus-insert-mime-security-button handle)))
7255 (mm-set-handle-multipart-parameter
7257 (cons (set-marker (make-marker) (point-min))
7258 (set-marker (make-marker) (point-max))))))
7264 (run-hooks 'gnus-art-load-hook)
7266 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7267 ;;; gnus-art.el ends here