1 ;;; gnus-art.el --- article mode commands for Semi-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>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
34 (defvar tool-bar-map))
38 ;; Avoid the "Recursive load suspected" error in Emacs 21.1.
40 (let ((recursive-load-depth-limit 100))
47 (when (static-if (featurep 'xemacs)
48 (console-on-window-system-p)
50 (require 'mime-image))
53 ;; Avoid byte-compile warnings.
63 (autoload 'gnus-msg-mail "gnus-msg" nil t)
64 (autoload 'gnus-button-mailto "gnus-msg")
65 (autoload 'gnus-button-reply "gnus-msg" nil t)
66 (autoload 'ansi-color-apply-on-region "ansi-color")
68 (defgroup gnus-article nil
70 :link '(custom-manual "(gnus)Article Buffer")
73 (defgroup gnus-article-treat nil
74 "Treating article parts."
75 :link '(custom-manual "(gnus)Article Hiding")
78 (defgroup gnus-article-hiding nil
79 "Hiding article parts."
80 :link '(custom-manual "(gnus)Article Hiding")
83 (defgroup gnus-article-highlight nil
84 "Article highlighting."
85 :link '(custom-manual "(gnus)Article Highlighting")
89 (defgroup gnus-article-signature nil
91 :link '(custom-manual "(gnus)Article Signature")
94 (defgroup gnus-article-headers nil
96 :link '(custom-manual "(gnus)Hiding Headers")
99 (defgroup gnus-article-washing nil
100 "Special commands on articles."
101 :link '(custom-manual "(gnus)Article Washing")
102 :group 'gnus-article)
104 (defgroup gnus-article-emphasis nil
105 "Fontisizing articles."
106 :link '(custom-manual "(gnus)Article Fontisizing")
107 :group 'gnus-article)
109 (defgroup gnus-article-saving nil
111 :link '(custom-manual "(gnus)Saving Articles")
112 :group 'gnus-article)
114 (defgroup gnus-article-mime nil
115 "Worshiping the MIME wonder."
116 :link '(custom-manual "(gnus)Using MIME")
117 :group 'gnus-article)
119 (defgroup gnus-article-buttons nil
120 "Pushable buttons in the article buffer."
121 :link '(custom-manual "(gnus)Article Buttons")
122 :group 'gnus-article)
124 (defgroup gnus-article-various nil
125 "Other article options."
126 :link '(custom-manual "(gnus)Misc Article")
127 :group 'gnus-article)
129 (defcustom gnus-ignored-headers
132 (concat "^" header ":"))
133 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
134 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
135 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
136 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
137 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
138 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
139 "X-Attribution" "X-Originating-IP" "Delivered-To"
140 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
141 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
142 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
143 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
144 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
145 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
146 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
147 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
148 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
149 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
150 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
151 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
152 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
153 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
154 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
155 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
156 "List-[A-Za-z]+" "X-Listprocessor-Version"
157 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
158 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
159 "X-Received" "Content-length" "X-precedence"
160 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
161 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
162 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
163 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
164 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
165 "X-Content-length" "X-Posting-Agent" "Original-Received"
166 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
167 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
168 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
169 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
170 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
171 "*All headers that start with this regexp will be hidden.
172 This variable can also be a list of regexps of headers to be ignored.
173 If `gnus-visible-headers' is non-nil, this variable will be ignored."
174 :type '(choice :custom-show nil
177 :group 'gnus-article-hiding)
179 (defcustom gnus-visible-headers
180 "^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:"
181 "*All headers that do not match this regexp will be hidden.
182 This variable can also be a list of regexp of headers to remain visible.
183 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
184 :type '(repeat :value-to-internal (lambda (widget value)
185 (custom-split-regexp-maybe value))
186 :match (lambda (widget value)
188 (widget-editable-list-match widget value)))
190 :group 'gnus-article-hiding)
192 (defcustom gnus-sorted-header-list
193 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
194 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
195 "*This variable is a list of regular expressions.
196 If it is non-nil, headers that match the regular expressions will
197 be placed first in the article buffer in the sequence specified by
199 :type '(repeat regexp)
200 :group 'gnus-article-hiding)
202 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
203 "Headers that are only to be displayed if they have interesting data.
204 Possible values in this list are:
206 'empty Headers with no content.
207 'newsgroups Newsgroup identical to Gnus group.
208 'to-address To identical to To-address.
209 'to-list To identical to To-list.
210 'cc-list CC identical to To-list.
211 'followup-to Followup-to identical to Newsgroups.
212 'reply-to Reply-to identical to From.
213 'date Date less than four days old.
214 'long-to To and/or Cc longer than 1024 characters.
215 'many-to Multiple To and/or Cc."
216 :type '(set (const :tag "Headers with no content." empty)
217 (const :tag "Newsgroups identical to Gnus group." newsgroups)
218 (const :tag "To identical to To-address." to-address)
219 (const :tag "To identical to To-list." to-list)
220 (const :tag "CC identical to To-list." cc-list)
221 (const :tag "Followup-to identical to Newsgroups." followup-to)
222 (const :tag "Reply-to identical to From." reply-to)
223 (const :tag "Date less than four days old." date)
224 (const :tag "To and/or Cc longer than 1024 characters." long-to)
225 (const :tag "Multiple To and/or Cc headers." many-to))
226 :group 'gnus-article-hiding)
228 (defcustom gnus-article-skip-boring nil
229 "Skip over text that is not worth reading.
230 By default, if you set this t, then Gnus will display citations and
231 signatures, but will never scroll down to show you a page consisting
232 only of boring text. Boring text is controlled by
233 `gnus-article-boring-faces'."
236 :group 'gnus-article-hiding)
238 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
239 "Regexp matching signature separator.
240 This can also be a list of regexps. In that case, it will be checked
241 from head to tail looking for a separator. Searches will be done from
242 the end of the buffer."
243 :type '(repeat string)
244 :group 'gnus-article-signature)
246 (defcustom gnus-signature-limit nil
247 "Provide a limit to what is considered a signature.
248 If it is a number, no signature may not be longer (in characters) than
249 that number. If it is a floating point number, no signature may be
250 longer (in lines) than that number. If it is a function, the function
251 will be called without any parameters, and if it returns nil, there is
252 no signature in the buffer. If it is a string, it will be used as a
253 regexp. If it matches, the text in question is not a signature.
255 This can also be a list of the above values."
256 :type '(choice (integer :value 200)
258 (function :value fun)
259 (regexp :value ".*"))
260 :group 'gnus-article-signature)
262 (defcustom gnus-hidden-properties '(invisible t intangible t)
263 "Property list to use for hiding text."
265 :group 'gnus-article-hiding)
267 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
268 ;; frames in a session.
269 (defcustom gnus-article-x-face-command
274 (if (or (gnus-image-type-available-p 'xface)
275 (gnus-image-type-available-p 'pbm))
276 'gnus-display-x-face-in-from
277 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
278 ((gnus-image-type-available-p 'pbm)
279 'gnus-display-x-face-in-from)
281 (module-installed-p 'x-face-mule))
282 'x-face-mule-gnus-article-display-x-face)
284 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
286 "*String or function to be executed to display an X-Face header.
287 If it is a string, the command will be executed in a sub-shell
288 asynchronously. The compressed face will be piped to this command."
290 ,@(let ((x-face-mule (if (featurep 'xemacs)
292 (module-installed-p 'x-face-mule))))
296 (if (or (gnus-image-type-available-p 'xface)
297 (gnus-image-type-available-p 'pbm))
298 '(function-item gnus-display-x-face-in-from))
301 x-face-mule-gnus-article-display-x-face))
305 :group 'gnus-article-washing)
307 (defcustom gnus-article-x-face-too-ugly nil
308 "Regexp matching posters whose face shouldn't be shown automatically."
309 :type '(choice regexp (const nil))
310 :group 'gnus-article-washing)
312 (defcustom gnus-article-banner-alist nil
313 "Banner alist for stripping.
315 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
317 :type '(repeat (cons symbol regexp))
318 :group 'gnus-article-washing)
320 (gnus-define-group-parameter
323 "Alist of regexps (to match group names) and banner."
324 :variable-group gnus-article-washing
326 '(choice :tag "Banner"
328 (const :tag "Remove signature" signature)
329 (symbol :tag "Item in `gnus-article-banner-alist'" none)
331 (const :tag "None" nil))
333 "If non-nil, specify how to remove `banners' from articles.
335 Symbol `signature' means to remove signatures delimited by
336 `gnus-signature-separator'. Any other symbol is used to look up a
337 regular expression to match the banner in `gnus-article-banner-alist'.
338 A string is used as a regular expression to match the banner
341 (defcustom gnus-article-address-banner-alist nil
342 "Alist of mail addresses and banners.
343 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
344 to match a mail address in the From: header, BANNER is one of a symbol
345 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
346 If ADDRESS matches author's mail address, it will remove things like
347 advertisements. For example:
349 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
353 (regexp :tag "Address")
354 (choice :tag "Banner" :value nil
355 (const :tag "Remove signature" signature)
356 (symbol :tag "Item in `gnus-article-banner-alist'" none)
358 (const :tag "None" nil))))
360 :group 'gnus-article-washing)
362 (defmacro gnus-emphasis-custom-with-format (&rest body)
364 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
365 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
368 (defun gnus-emphasis-custom-value-to-external (value)
369 (gnus-emphasis-custom-with-format
370 (if (consp (car value))
371 (list (format format (car (car value)) (cdr (car value)))
373 (if (nth 1 value) 2 3)
377 (defun gnus-emphasis-custom-value-to-internal (value)
378 (gnus-emphasis-custom-with-format
379 (let ((regexp (concat "\\`"
380 (format (regexp-quote format)
381 "\\([^()]+\\)" "\\([^()]+\\)")
384 (if (string-match regexp (setq pattern (car value)))
385 (list (cons (match-string 1 pattern) (match-string 2 pattern))
390 (defcustom gnus-emphasis-alist
392 '(("\\*" "\\*" bold nil 2)
395 ("_/" "/_" underline-italic)
396 ("_\\*" "\\*_" underline-bold)
397 ("\\*/" "/\\*" bold-italic)
398 ("_\\*/" "/\\*_" underline-bold-italic))))
400 (gnus-emphasis-custom-with-format
401 (mapcar (lambda (spec)
402 (list (format format (car spec) (cadr spec))
405 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
407 '(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
408 2 3 gnus-emphasis-underline))))
409 "*Alist that says how to fontify certain phrases.
410 Each item looks like this:
412 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
414 The first element is a regular expression to be matched. The second
415 is a number that says what regular expression grouping used to find
416 the entire emphasized word. The third is a number that says what
417 regexp grouping should be displayed and highlighted. The fourth
418 is the face used for highlighting."
422 :format "%[Customizing Style%]\n%v"
424 (group :tag "Default"
425 :value ("" 0 0 default)
428 (let ((value (widget-get
429 (cadr (widget-get (widget-get widget :parent)
432 (if (not (eq (nth 2 value) 'default))
436 (gnus-emphasis-custom-value-to-external value))))
437 (widget-group-value-create widget))
439 (integer :format "Match group: %v")
440 (integer :format "Emphasize group: %v")
443 :value (("_" . "_") nil default)
445 (regexp :format "Start regexp: %v")
446 (regexp :format "End regexp: %v"))
447 (boolean :format "Show start and end patterns: %[%v%]\n"
448 :on " On " :off " Off ")
450 :get (lambda (symbol)
451 (mapcar 'gnus-emphasis-custom-value-to-internal
452 (default-value symbol)))
453 :set (lambda (symbol value)
454 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
456 :group 'gnus-article-emphasis)
458 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
459 "A regexp to describe whitespace which should not be emphasized.
460 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
461 The former avoids underlining of leading and trailing whitespace,
462 and the latter avoids underlining any whitespace at all."
464 :group 'gnus-article-emphasis
467 (defface gnus-emphasis-bold '((t (:bold t)))
468 "Face used for displaying strong emphasized text (*word*)."
469 :group 'gnus-article-emphasis)
471 (defface gnus-emphasis-italic '((t (:italic t)))
472 "Face used for displaying italic emphasized text (/word/)."
473 :group 'gnus-article-emphasis)
475 (defface gnus-emphasis-underline '((t (:underline t)))
476 "Face used for displaying underlined emphasized text (_word_)."
477 :group 'gnus-article-emphasis)
479 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
480 "Face used for displaying underlined bold emphasized text (_*word*_)."
481 :group 'gnus-article-emphasis)
483 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
484 "Face used for displaying underlined italic emphasized text (_/word/_)."
485 :group 'gnus-article-emphasis)
487 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
488 "Face used for displaying bold italic emphasized text (/*word*/)."
489 :group 'gnus-article-emphasis)
491 (defface gnus-emphasis-underline-bold-italic
492 '((t (:bold t :italic t :underline t)))
493 "Face used for displaying underlined bold italic emphasized text.
494 Example: (_/*word*/_)."
495 :group 'gnus-article-emphasis)
497 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
498 '((t (:strikethru t)))
499 '((t (:strike-through t))))
500 "Face used for displaying strike-through text (-word-)."
501 :group 'gnus-article-emphasis)
503 (defface gnus-emphasis-highlight-words
504 '((t (:background "black" :foreground "yellow")))
505 "Face used for displaying highlighted words."
506 :group 'gnus-article-emphasis)
508 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
509 "Format for display of Date headers in article bodies.
510 See `format-time-string' for the possible values.
512 The variable can also be function, which should return a complete Date
513 header. The function is called with one argument, the time, which can
514 be fed to `format-time-string'."
515 :type '(choice string function)
516 :link '(custom-manual "(gnus)Article Date")
517 :group 'gnus-article-washing)
520 (autoload 'mail-extract-address-components "mail-extr"))
522 (defcustom gnus-save-all-headers t
523 "*If non-nil, don't remove any headers before saving."
524 :group 'gnus-article-saving
527 (defcustom gnus-prompt-before-saving 'always
528 "*This variable says how much prompting is to be done when saving articles.
529 If it is nil, no prompting will be done, and the articles will be
530 saved to the default files. If this variable is `always', each and
531 every article that is saved will be preceded by a prompt, even when
532 saving large batches of articles. If this variable is neither nil not
533 `always', there the user will be prompted once for a file name for
534 each invocation of the saving commands."
535 :group 'gnus-article-saving
536 :type '(choice (item always)
537 (item :tag "never" nil)
538 (sexp :tag "once" :format "%t\n" :value t)))
540 (defcustom gnus-saved-headers gnus-visible-headers
541 "Headers to keep if `gnus-save-all-headers' is nil.
542 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
543 If that variable is nil, however, all headers that match this regexp
544 will be kept while the rest will be deleted before saving."
545 :group 'gnus-article-saving
548 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
549 "A function to save articles in your favourite format.
550 The function must be interactively callable (in other words, it must
551 be an Emacs command).
553 Gnus provides the following functions:
555 * gnus-summary-save-in-rmail (Rmail format)
556 * gnus-summary-save-in-mail (Unix mail format)
557 * gnus-summary-save-in-folder (MH folder)
558 * gnus-summary-save-in-file (article format)
559 * gnus-summary-save-body-in-file (article body)
560 * gnus-summary-save-in-vm (use VM's folder format)
561 * gnus-summary-write-to-file (article format -- overwrite)."
562 :group 'gnus-article-saving
563 :type '(radio (function-item gnus-summary-save-in-rmail)
564 (function-item gnus-summary-save-in-mail)
565 (function-item gnus-summary-save-in-folder)
566 (function-item gnus-summary-save-in-file)
567 (function-item gnus-summary-save-body-in-file)
568 (function-item gnus-summary-save-in-vm)
569 (function-item gnus-summary-write-to-file)))
571 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
572 "A function generating a file name to save articles in Rmail format.
573 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
574 :group 'gnus-article-saving
577 (defcustom gnus-mail-save-name 'gnus-plain-save-name
578 "A function generating a file name to save articles in Unix mail format.
579 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
580 :group 'gnus-article-saving
583 (defcustom gnus-folder-save-name 'gnus-folder-save-name
584 "A function generating a file name to save articles in MH folder.
585 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
586 :group 'gnus-article-saving
589 (defcustom gnus-file-save-name 'gnus-numeric-save-name
590 "A function generating a file name to save articles in article format.
591 The function is called with NEWSGROUP, HEADERS, and optional
593 :group 'gnus-article-saving
596 (defcustom gnus-split-methods
597 '((gnus-article-archive-name)
598 (gnus-article-nndoc-name))
599 "*Variable used to suggest where articles are to be saved.
600 For instance, if you would like to save articles related to Gnus in
601 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
602 you could set this variable to something like:
604 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
605 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
607 This variable is an alist where the key is the match and the
608 value is a list of possible files to save in if the match is
611 If the match is a string, it is used as a regexp match on the
612 article. If the match is a symbol, that symbol will be funcalled
613 from the buffer of the article to be saved with the newsgroup as
614 the parameter. If it is a list, it will be evaled in the same
617 If this form or function returns a string, this string will be
618 used as a possible file name; and if it returns a non-nil list,
619 that list will be used as possible file names."
620 :group 'gnus-article-saving
621 :type '(repeat (choice (list :value (fun) function)
622 (cons :value ("" "") regexp (repeat string))
625 (defcustom gnus-article-display-method-for-mime
626 'gnus-article-display-mime-message
627 "Function to display a MIME message.
628 The function is called from the article buffer."
629 :group 'gnus-article-mime
632 (defcustom gnus-article-display-method-for-traditional
633 'gnus-article-display-traditional-message
634 "*Function to display a traditional message.
635 The function is called from the article buffer."
636 :group 'gnus-article-mime
639 (defcustom gnus-page-delimiter "^\^L"
640 "*Regexp describing what to use as article page delimiters.
641 The default value is \"^\^L\", which is a form linefeed at the
642 beginning of a line."
644 :group 'gnus-article-various)
646 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
647 "*The format specification for the article mode line.
648 See `gnus-summary-mode-line-format' for a closer description.
650 The following additional specs are available:
652 %w The article washing status.
653 %m The number of MIME parts in the article."
655 :group 'gnus-article-various)
657 (defcustom gnus-article-mode-hook nil
658 "*A hook for Gnus article mode."
660 :group 'gnus-article-various)
662 (when (featurep 'xemacs)
663 ;; Extracted from gnus-xmas-define in order to preserve user settings
664 (when (fboundp 'turn-off-scroll-in-place)
665 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
666 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
667 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
669 (defcustom gnus-article-menu-hook nil
670 "*Hook run after the creation of the article mode menu."
672 :group 'gnus-article-various)
674 (defcustom gnus-article-prepare-hook nil
675 "*A hook called after an article has been prepared in the article buffer."
677 :group 'gnus-article-various)
679 (defcustom gnus-copy-article-ignored-headers nil
680 "List of headers to be removed when copying an article.
681 Each element is a regular expression."
682 :version "22.0" ;; No Gnus
683 :type '(repeat regexp)
684 :group 'gnus-article-various)
686 (make-obsolete-variable 'gnus-article-hide-pgp-hook
687 "This variable is obsolete in Gnus 5.10.")
689 (defcustom gnus-article-button-face 'bold
690 "Face used for highlighting buttons in the article buffer.
692 An article button is a piece of text that you can activate by pressing
693 `RET' or `mouse-2' above it."
695 :group 'gnus-article-buttons)
697 (defcustom gnus-article-mouse-face 'highlight
698 "Face used for mouse highlighting in the article buffer.
700 Article buttons will be displayed in this face when the cursor is
703 :group 'gnus-article-buttons)
705 (defcustom gnus-signature-face 'gnus-signature-face
706 "Face used for highlighting a signature in the article buffer.
707 Obsolete; use the face `gnus-signature-face' for customizations instead."
709 :group 'gnus-article-highlight
710 :group 'gnus-article-signature)
712 (defface gnus-signature-face
715 "Face used for highlighting a signature in the article buffer."
716 :group 'gnus-article-highlight
717 :group 'gnus-article-signature)
719 (defface gnus-header-from-face
722 (:foreground "spring green"))
725 (:foreground "red3"))
728 "Face used for displaying from headers."
729 :group 'gnus-article-headers
730 :group 'gnus-article-highlight)
732 (defface gnus-header-subject-face
735 (:foreground "SeaGreen3"))
738 (:foreground "red4"))
740 (:bold t :italic t)))
741 "Face used for displaying subject headers."
742 :group 'gnus-article-headers
743 :group 'gnus-article-highlight)
745 (defface gnus-header-newsgroups-face
748 (:foreground "yellow" :italic t))
751 (:foreground "MidnightBlue" :italic t))
754 "Face used for displaying newsgroups headers.
755 In the default setup this face is only used for crossposted
757 :group 'gnus-article-headers
758 :group 'gnus-article-highlight)
760 (defface gnus-header-name-face
763 (:foreground "SeaGreen"))
766 (:foreground "maroon"))
769 "Face used for displaying header names."
770 :group 'gnus-article-headers
771 :group 'gnus-article-highlight)
773 (defface gnus-header-content-face
776 (:foreground "forest green" :italic t))
779 (:foreground "indianred4" :italic t))
782 "Face used for displaying header content."
783 :group 'gnus-article-headers
784 :group 'gnus-article-highlight)
786 (defcustom gnus-header-face-alist
787 '(("From" nil gnus-header-from-face)
788 ("Subject" nil gnus-header-subject-face)
789 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
790 ("" gnus-header-name-face gnus-header-content-face))
791 "*Controls highlighting of article headers.
793 An alist of the form (HEADER NAME CONTENT).
795 HEADER is a regular expression which should match the name of a
796 header and NAME and CONTENT are either face names or nil.
798 The name of each header field will be displayed using the face
799 specified by the first element in the list where HEADER matches
800 the header name and NAME is non-nil. Similarly, the content will
801 be displayed by the first non-nil matching CONTENT face."
802 :group 'gnus-article-headers
803 :group 'gnus-article-highlight
804 :type '(repeat (list (regexp :tag "Header")
806 (item :tag "skip" nil)
807 (face :value default))
808 (choice :tag "Content"
809 (item :tag "skip" nil)
810 (face :value default)))))
812 (defcustom gnus-article-decode-hook
813 '(article-decode-group-name article-decode-idna-rhs)
814 "*Hook run to decode charsets in articles."
815 :group 'gnus-article-headers
818 (defcustom gnus-display-mime-function 'gnus-display-mime
819 "Function to display MIME articles."
820 :group 'gnus-article-mime
823 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
824 "Function used to decode headers.")
826 (defvar gnus-article-dumbquotes-map
846 "Table for MS-to-Latin1 translation.")
848 (defcustom gnus-ignored-mime-types nil
849 "List of MIME types that should be ignored by Gnus."
851 :group 'gnus-article-mime
852 :type '(repeat regexp))
854 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
855 "List of MIME types that should not be given buttons when rendered inline.
856 See also `gnus-buttonized-mime-types' which may override this variable.
857 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
859 :group 'gnus-article-mime
860 :type '(repeat regexp))
862 (defcustom gnus-buttonized-mime-types nil
863 "List of MIME types that should be given buttons when rendered inline.
864 If set, this variable overrides `gnus-unbuttonized-mime-types'.
865 To see e.g. security buttons you could set this to
866 `(\"multipart/signed\")'.
867 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
869 :group 'gnus-article-mime
870 :type '(repeat regexp))
872 (defcustom gnus-inhibit-mime-unbuttonizing nil
873 "If non-nil, all MIME parts get buttons.
874 When nil (the default value), then some MIME parts do not get buttons,
875 as described by the variables `gnus-buttonized-mime-types' and
876 `gnus-unbuttonized-mime-types'."
878 :group 'gnus-article-mime
881 (defcustom gnus-body-boundary-delimiter "_"
882 "String used to delimit header and body.
883 This variable is used by `gnus-article-treat-body-boundary' which can
884 be controlled by `gnus-treat-body-boundary'."
886 :group 'gnus-article-various
887 :type '(choice (item :tag "None" :value nil)
890 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
892 "Defines the location of the faces database.
893 For information on obtaining this database of pretty pictures, please
894 see http://www.cs.indiana.edu/picons/ftp/index.html"
896 :type '(repeat directory)
897 :link '(url-link :tag "download"
898 "http://www.cs.indiana.edu/picons/ftp/index.html")
899 :link '(custom-manual "(gnus)Picons")
902 (defun gnus-picons-installed-p ()
903 "Say whether picons are installed on your machine."
904 (let ((installed nil))
905 (dolist (database gnus-picon-databases)
906 (when (file-exists-p database)
910 (defcustom gnus-article-mime-part-function nil
911 "Function called with a MIME handle as the argument.
912 This is meant for people who want to do something automatic based
913 on parts -- for instance, adding Vcard info to a database."
914 :group 'gnus-article-mime
917 (defcustom gnus-mime-multipart-functions nil
918 "An alist of MIME types to functions to display them."
920 :group 'gnus-article-mime
921 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
923 (defcustom gnus-article-date-lapsed-new-header nil
924 "Whether the X-Sent and Date headers can coexist.
925 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
926 either replace the old \"Date:\" header (if this variable is nil), or
927 be added below it (otherwise)."
929 :group 'gnus-article-headers
932 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
933 "Function called with a MIME handle as the argument.
934 This is meant for people who want to view first matched part.
935 For `undisplayed-alternative' (default), the first undisplayed
936 part or alternative part is used. For `undisplayed', the first
937 undisplayed part is used. For a function, the first part which
938 the function return t is used. For nil, the first part is
941 :group 'gnus-article-mime
943 (item :tag "first" :value nil)
944 (item :tag "undisplayed" :value undisplayed)
945 (item :tag "undisplayed or alternative"
946 :value undisplayed-alternative)
949 (defcustom gnus-mime-action-alist
950 '(("save to file" . gnus-mime-save-part)
951 ("save and strip" . gnus-mime-save-part-and-strip)
952 ("delete part" . gnus-mime-delete-part)
953 ("display as text" . gnus-mime-inline-part)
954 ("view the part" . gnus-mime-view-part)
955 ("pipe to command" . gnus-mime-pipe-part)
956 ("toggle display" . gnus-article-press-button)
957 ("toggle display" . gnus-article-view-part-as-charset)
958 ("view as type" . gnus-mime-view-part-as-type)
959 ("view internally" . gnus-mime-view-part-internally)
960 ("view externally" . gnus-mime-view-part-externally))
961 "An alist of actions that run on the MIME attachment."
962 :group 'gnus-article-mime
963 :type '(repeat (cons (string :tag "name")
967 ;;; The treatment variables
970 (defvar gnus-part-display-hook nil
971 "Hook called on parts that are to receive treatment.")
973 (defvar gnus-article-treat-custom
974 '(choice (const :tag "Off" nil)
976 (const :tag "Header" head)
977 (const :tag "Last" last)
978 (const :tag "Mime" mime)
979 (integer :tag "Less")
980 (repeat :tag "Groups" regexp)
981 (sexp :tag "Predicate")))
983 (defvar gnus-article-treat-head-custom
984 '(choice (const :tag "Off" nil)
985 (const :tag "Header" head)))
987 (defvar gnus-article-treat-types '("text/plain")
990 (defvar gnus-inhibit-treatment nil
991 "Whether to inhibit treatment.")
993 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
994 "Highlight the signature.
995 Valid values are nil, t, `head', `last', an integer or a predicate.
996 See Info node `(gnus)Customizing Articles'."
997 :group 'gnus-article-treat
998 :link '(custom-manual "(gnus)Customizing Articles")
999 :type gnus-article-treat-custom)
1000 (put 'gnus-treat-highlight-signature 'highlight t)
1002 (defcustom gnus-treat-buttonize 100000
1004 Valid values are nil, t, `head', `last', an integer or a predicate.
1005 See Info node `(gnus)Customizing Articles'."
1006 :group 'gnus-article-treat
1007 :link '(custom-manual "(gnus)Customizing Articles")
1008 :type gnus-article-treat-custom)
1009 (put 'gnus-treat-buttonize 'highlight t)
1011 (defcustom gnus-treat-buttonize-head 'head
1012 "Add buttons to the head.
1013 Valid values are nil, t, `head', `last', an integer or a predicate.
1014 See Info node `(gnus)Customizing Articles' for details."
1015 :group 'gnus-article-treat
1016 :link '(custom-manual "(gnus)Customizing Articles")
1017 :type gnus-article-treat-head-custom)
1018 (put 'gnus-treat-buttonize-head 'highlight t)
1020 (defcustom gnus-treat-emphasize
1021 (and (or window-system
1025 Valid values are nil, t, `head', `last', an integer or a predicate.
1026 See Info node `(gnus)Customizing Articles' for details."
1027 :group 'gnus-article-treat
1028 :link '(custom-manual "(gnus)Customizing Articles")
1029 :type gnus-article-treat-custom)
1030 (put 'gnus-treat-emphasize 'highlight t)
1032 (defcustom gnus-treat-strip-cr nil
1033 "Remove carriage returns.
1034 Valid values are nil, t, `head', `last', an integer or a predicate.
1035 See Info node `(gnus)Customizing Articles' for details."
1037 :group 'gnus-article-treat
1038 :link '(custom-manual "(gnus)Customizing Articles")
1039 :type gnus-article-treat-custom)
1041 (defcustom gnus-treat-unsplit-urls nil
1042 "Remove newlines from within URLs.
1043 Valid values are nil, t, `head', `last', an integer or a predicate.
1044 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-leading-whitespace nil
1051 "Remove leading whitespace in headers.
1052 Valid values are nil, t, `head', `last', an integer or a predicate.
1053 See Info node `(gnus)Customizing Articles' for details."
1055 :group 'gnus-article-treat
1056 :link '(custom-manual "(gnus)Customizing Articles")
1057 :type gnus-article-treat-custom)
1059 (defcustom gnus-treat-hide-headers 'head
1061 Valid values are nil, t, `head', `last', an integer or a predicate.
1062 See Info node `(gnus)Customizing Articles' for details."
1063 :group 'gnus-article-treat
1064 :link '(custom-manual "(gnus)Customizing Articles")
1065 :type gnus-article-treat-head-custom)
1067 (defcustom gnus-treat-hide-boring-headers nil
1068 "Hide boring headers.
1069 Valid values are nil, t, `head', `last', an integer or a predicate.
1070 See Info node `(gnus)Customizing Articles' for details."
1071 :group 'gnus-article-treat
1072 :link '(custom-manual "(gnus)Customizing Articles")
1073 :type gnus-article-treat-head-custom)
1075 (defcustom gnus-treat-hide-signature nil
1076 "Hide the signature.
1077 Valid values are nil, t, `head', `last', an integer or a predicate.
1078 See Info node `(gnus)Customizing Articles' for details."
1079 :group 'gnus-article-treat
1080 :link '(custom-manual "(gnus)Customizing Articles")
1081 :type gnus-article-treat-custom)
1083 (defcustom gnus-treat-fill-article nil
1085 Valid values are nil, t, `head', `last', an integer or a predicate.
1086 See Info node `(gnus)Customizing Articles' for details."
1087 :group 'gnus-article-treat
1088 :link '(custom-manual "(gnus)Customizing Articles")
1089 :type gnus-article-treat-custom)
1091 (defcustom gnus-treat-hide-citation nil
1093 Valid values are nil, t, `head', `last', an integer or a predicate.
1094 See Info node `(gnus)Customizing Articles' for details."
1095 :group 'gnus-article-treat
1096 :link '(custom-manual "(gnus)Customizing Articles")
1097 :type gnus-article-treat-custom)
1099 (defcustom gnus-treat-hide-citation-maybe nil
1101 Valid values are nil, t, `head', `last', an integer or a predicate.
1102 See Info node `(gnus)Customizing Articles' for details."
1103 :group 'gnus-article-treat
1104 :link '(custom-manual "(gnus)Customizing Articles")
1105 :type gnus-article-treat-custom)
1107 (defcustom gnus-treat-strip-list-identifiers 'head
1108 "Strip list identifiers from `gnus-list-identifiers`.
1109 Valid values are nil, t, `head', `last', an integer or a predicate.
1110 See Info node `(gnus)Customizing Articles' for details."
1112 :group 'gnus-article-treat
1113 :link '(custom-manual "(gnus)Customizing Articles")
1114 :type gnus-article-treat-custom)
1116 (make-obsolete-variable 'gnus-treat-strip-pgp
1117 "This option is obsolete in Gnus 5.10.")
1119 (defcustom gnus-treat-strip-pem nil
1120 "Strip PEM signatures.
1121 Valid values are nil, t, `head', `last', an integer or a predicate.
1122 See Info node `(gnus)Customizing Articles' for details."
1123 :group 'gnus-article-treat
1124 :link '(custom-manual "(gnus)Customizing Articles")
1125 :type gnus-article-treat-custom)
1127 (defcustom gnus-treat-strip-banner t
1128 "Strip banners from articles.
1129 The banner to be stripped is specified in the `banner' group parameter.
1130 Valid values are nil, t, `head', `last', an integer or a predicate.
1131 See Info node `(gnus)Customizing Articles' for details."
1132 :group 'gnus-article-treat
1133 :link '(custom-manual "(gnus)Customizing Articles")
1134 :type gnus-article-treat-custom)
1136 (defcustom gnus-treat-highlight-headers 'head
1137 "Highlight the headers.
1138 Valid values are nil, t, `head', `last', an integer or a predicate.
1139 See Info node `(gnus)Customizing Articles' for details."
1140 :group 'gnus-article-treat
1141 :link '(custom-manual "(gnus)Customizing Articles")
1142 :type gnus-article-treat-head-custom)
1143 (put 'gnus-treat-highlight-headers 'highlight t)
1145 (defcustom gnus-treat-highlight-citation t
1146 "Highlight cited text.
1147 Valid values are nil, t, `head', `last', an integer or a predicate.
1148 See Info node `(gnus)Customizing Articles' for details."
1149 :group 'gnus-article-treat
1150 :link '(custom-manual "(gnus)Customizing Articles")
1151 :type gnus-article-treat-custom)
1152 (put 'gnus-treat-highlight-citation 'highlight t)
1154 (defcustom gnus-treat-date-ut nil
1155 "Display the Date in UT (GMT).
1156 Valid values are nil, t, `head', `last', an integer or a predicate.
1157 See Info node `(gnus)Customizing Articles' for details."
1158 :group 'gnus-article-treat
1159 :link '(custom-manual "(gnus)Customizing Articles")
1160 :type gnus-article-treat-head-custom)
1162 (defcustom gnus-treat-date-local nil
1163 "Display the Date in the local timezone.
1164 Valid values are nil, t, `head', `last', an integer or a predicate.
1165 See Info node `(gnus)Customizing Articles' for details."
1166 :group 'gnus-article-treat
1167 :link '(custom-manual "(gnus)Customizing Articles")
1168 :type gnus-article-treat-head-custom)
1170 (defcustom gnus-treat-date-english nil
1171 "Display the Date in a format that can be read aloud in English.
1172 Valid values are nil, t, `head', `last', an integer or a predicate.
1173 See Info node `(gnus)Customizing Articles' for details."
1175 :group 'gnus-article-treat
1176 :link '(custom-manual "(gnus)Customizing Articles")
1177 :type gnus-article-treat-head-custom)
1179 (defcustom gnus-treat-date-lapsed nil
1180 "Display the Date header in a way that says how much time has elapsed.
1181 Valid values are nil, t, `head', `last', an integer or a predicate.
1182 See Info node `(gnus)Customizing Articles' for details."
1183 :group 'gnus-article-treat
1184 :link '(custom-manual "(gnus)Customizing Articles")
1185 :type gnus-article-treat-head-custom)
1187 (defcustom gnus-treat-date-original nil
1188 "Display the date in the original timezone.
1189 Valid values are nil, t, `head', `last', an integer or a predicate.
1190 See Info node `(gnus)Customizing Articles' for details."
1191 :group 'gnus-article-treat
1192 :link '(custom-manual "(gnus)Customizing Articles")
1193 :type gnus-article-treat-head-custom)
1195 (defcustom gnus-treat-date-iso8601 nil
1196 "Display the date in the ISO8601 format.
1197 Valid values are nil, t, `head', `last', an integer or a predicate.
1198 See Info node `(gnus)Customizing Articles' for details."
1200 :group 'gnus-article-treat
1201 :link '(custom-manual "(gnus)Customizing Articles")
1202 :type gnus-article-treat-head-custom)
1204 (defcustom gnus-treat-date-user-defined nil
1205 "Display the date in a user-defined format.
1206 The format is defined by the `gnus-article-time-format' variable.
1207 Valid values are nil, t, `head', `last', an integer or a predicate.
1208 See Info node `(gnus)Customizing Articles' for details."
1209 :group 'gnus-article-treat
1210 :link '(custom-manual "(gnus)Customizing Articles")
1211 :type gnus-article-treat-head-custom)
1213 (defcustom gnus-treat-strip-headers-in-body t
1214 "Strip the X-No-Archive header line from the beginning of the body.
1215 Valid values are nil, t, `head', `last', an integer or a predicate.
1216 See Info node `(gnus)Customizing Articles' for details."
1218 :group 'gnus-article-treat
1219 :link '(custom-manual "(gnus)Customizing Articles")
1220 :type gnus-article-treat-custom)
1222 (defcustom gnus-treat-strip-trailing-blank-lines nil
1223 "Strip trailing blank lines.
1224 Valid values are nil, t, `head', `last', an integer or a predicate.
1225 See Info node `(gnus)Customizing Articles' for details."
1226 :group 'gnus-article-treat
1227 :link '(custom-manual "(gnus)Customizing Articles")
1228 :type gnus-article-treat-custom)
1230 (defcustom gnus-treat-strip-leading-blank-lines nil
1231 "Strip leading blank lines.
1232 Valid values are nil, t, `head', `last', an integer or a predicate.
1233 See Info node `(gnus)Customizing Articles' for details."
1234 :group 'gnus-article-treat
1235 :link '(custom-manual "(gnus)Customizing Articles")
1236 :type gnus-article-treat-custom)
1238 (defcustom gnus-treat-strip-multiple-blank-lines nil
1239 "Strip multiple blank lines.
1240 Valid values are nil, t, `head', `last', an integer or a predicate.
1241 See Info node `(gnus)Customizing Articles' for details."
1242 :group 'gnus-article-treat
1243 :link '(custom-manual "(gnus)Customizing Articles")
1244 :type gnus-article-treat-custom)
1246 (defcustom gnus-treat-unfold-headers 'head
1247 "Unfold folded header lines.
1248 Valid values are nil, t, `head', `last', an integer or a predicate.
1249 See Info node `(gnus)Customizing Articles' for details."
1251 :group 'gnus-article-treat
1252 :link '(custom-manual "(gnus)Customizing Articles")
1253 :type gnus-article-treat-custom)
1255 (defcustom gnus-treat-fold-headers nil
1257 Valid values are nil, t, `head', `last', an integer or a predicate.
1258 See Info node `(gnus)Customizing Articles' for details."
1260 :group 'gnus-article-treat
1261 :link '(custom-manual "(gnus)Customizing Articles")
1262 :type gnus-article-treat-custom)
1264 (defcustom gnus-treat-fold-newsgroups 'head
1265 "Fold the Newsgroups and Followup-To headers.
1266 Valid values are nil, t, `head', `last', an integer or a predicate.
1267 See Info node `(gnus)Customizing Articles' for details."
1269 :group 'gnus-article-treat
1270 :link '(custom-manual "(gnus)Customizing Articles")
1271 :type gnus-article-treat-custom)
1273 (defcustom gnus-treat-overstrike t
1274 "Treat overstrike highlighting.
1275 Valid values are nil, t, `head', `last', an integer or a predicate.
1276 See Info node `(gnus)Customizing Articles' for details."
1277 :group 'gnus-article-treat
1278 :link '(custom-manual "(gnus)Customizing Articles")
1279 :type gnus-article-treat-custom)
1280 (put 'gnus-treat-overstrike 'highlight t)
1282 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1283 "Treat ANSI SGR control sequences.
1284 Valid values are nil, t, `head', `last', an integer or a predicate.
1285 See Info node `(gnus)Customizing Articles' for details."
1286 :group 'gnus-article-treat
1287 :link '(custom-manual "(gnus)Customizing Articles")
1288 :type gnus-article-treat-custom)
1290 (make-obsolete-variable 'gnus-treat-display-xface
1291 'gnus-treat-display-x-face)
1293 (defcustom gnus-treat-display-x-face
1294 (and (not noninteractive)
1295 (or (eq gnus-article-x-face-command
1296 'x-face-mule-gnus-article-display-x-face)
1297 (and (fboundp 'image-type-available-p)
1298 (image-type-available-p 'xbm)
1299 (string-match "^0x" (shell-command-to-string "uncompface"))
1300 (executable-find "icontopbm"))
1301 (and (featurep 'xemacs)
1304 "Display X-Face headers.
1305 Valid values are nil, t, `head', `last', an integer or a predicate.
1306 See Info node `(gnus)Customizing Articles' and Info node
1307 `(gnus)X-Face' for details."
1308 :group 'gnus-article-treat
1310 :link '(custom-manual "(gnus)Customizing Articles")
1311 :link '(custom-manual "(gnus)X-Face")
1312 :type gnus-article-treat-head-custom
1313 :set (lambda (symbol value)
1316 (cond ((or (boundp symbol) (get symbol 'saved-value))
1318 ((boundp 'gnus-treat-display-xface)
1320 ** gnus-treat-display-xface is an obsolete variable;\
1321 use gnus-treat-display-x-face instead")
1322 (default-value 'gnus-treat-display-xface))
1323 ((get 'gnus-treat-display-xface 'saved-value)
1325 ** gnus-treat-display-xface is an obsolete variable;\
1326 use gnus-treat-display-x-face instead")
1327 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1330 (put 'gnus-treat-display-x-face 'highlight t)
1332 (defcustom gnus-article-should-use-smiley-mule
1333 (not (or (featurep 'xemacs)
1334 (gnus-image-type-available-p 'xpm)
1335 (gnus-image-type-available-p 'pbm)))
1336 "Non-nil means use `smiley-mule' to show smileys rather than `smiley'.
1337 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1338 even if your Emacs supports images. It has no effect on XEmacs."
1339 :group 'gnus-article-various
1341 :get (lambda (symbol)
1342 (and (not noninteractive)
1343 (default-value symbol)
1344 (not (featurep 'xemacs))
1345 (module-installed-p 'smiley-mule)
1347 :set (lambda (symbol value)
1348 (set-default symbol (and (not noninteractive)
1350 (not (featurep 'xemacs))
1351 (module-installed-p 'smiley-mule)
1354 (defvar gnus-article-smiley-mule-loaded-p nil
1355 "Internal variable used to say whether `smiley-mule' is loaded (whether
1356 smiley functions are not overridden by `smiley').")
1358 (defcustom gnus-treat-display-face
1359 (and (not noninteractive)
1360 (or (and (fboundp 'image-type-available-p)
1361 (image-type-available-p 'png))
1362 (and (featurep 'xemacs)
1365 "Display Face headers.
1366 Valid values are nil, t, `head', `last', an integer or a predicate.
1367 See Info node `(gnus)Customizing Articles' and Info node
1368 `(gnus)X-Face' for details."
1369 :group 'gnus-article-treat
1371 :link '(custom-manual "(gnus)Customizing Articles")
1372 :link '(custom-manual "(gnus)X-Face")
1373 :type gnus-article-treat-head-custom)
1374 (put 'gnus-treat-display-face 'highlight t)
1376 (defcustom gnus-treat-display-smileys
1377 (if (and (not noninteractive)
1378 (or (and (featurep 'xemacs)
1380 (gnus-image-type-available-p 'xpm)
1381 (gnus-image-type-available-p 'pbm)
1382 (and (not (featurep 'xemacs))
1384 (module-installed-p 'smiley-mule))))
1388 Valid values are nil, t, `head', `last', an integer or a predicate.
1389 See Info node `(gnus)Customizing Articles' and Info node
1390 `(gnus)Smileys' for details."
1391 :group 'gnus-article-treat
1393 :link '(custom-manual "(gnus)Customizing Articles")
1394 :link '(custom-manual "(gnus)Smileys")
1395 :type gnus-article-treat-custom)
1396 (put 'gnus-treat-display-smileys 'highlight t)
1398 (defcustom gnus-treat-from-picon
1399 (if (and (gnus-image-type-available-p 'xpm)
1400 (gnus-picons-installed-p))
1402 "Display picons in the From header.
1403 Valid values are nil, t, `head', `last', an integer or a predicate.
1404 See Info node `(gnus)Customizing Articles' and Info node
1405 `(gnus)Picons' for details."
1407 :group 'gnus-article-treat
1409 :link '(custom-manual "(gnus)Customizing Articles")
1410 :link '(custom-manual "(gnus)Picons")
1411 :type gnus-article-treat-head-custom)
1412 (put 'gnus-treat-from-picon 'highlight t)
1414 (defcustom gnus-treat-mail-picon
1415 (if (and (gnus-image-type-available-p 'xpm)
1416 (gnus-picons-installed-p))
1418 "Display picons in To and Cc headers.
1419 Valid values are nil, t, `head', `last', an integer or a predicate.
1420 See Info node `(gnus)Customizing Articles' and Info node
1421 `(gnus)Picons' for details."
1423 :group 'gnus-article-treat
1425 :link '(custom-manual "(gnus)Customizing Articles")
1426 :link '(custom-manual "(gnus)Picons")
1427 :type gnus-article-treat-head-custom)
1428 (put 'gnus-treat-mail-picon 'highlight t)
1430 (defcustom gnus-treat-newsgroups-picon
1431 (if (and (gnus-image-type-available-p 'xpm)
1432 (gnus-picons-installed-p))
1434 "Display picons in the Newsgroups and Followup-To headers.
1435 Valid values are nil, t, `head', `last', an integer or a predicate.
1436 See Info node `(gnus)Customizing Articles' and Info node
1437 `(gnus)Picons' for details."
1439 :group 'gnus-article-treat
1441 :link '(custom-manual "(gnus)Customizing Articles")
1442 :link '(custom-manual "(gnus)Picons")
1443 :type gnus-article-treat-head-custom)
1444 (put 'gnus-treat-newsgroups-picon 'highlight t)
1446 (defcustom gnus-treat-body-boundary
1447 (if (and (eq window-system 'x)
1448 (or gnus-treat-newsgroups-picon
1449 gnus-treat-mail-picon
1450 gnus-treat-from-picon))
1452 "Draw a boundary at the end of the headers.
1453 Valid values are nil and `head'.
1454 See Info node `(gnus)Customizing Articles' for details."
1456 :group 'gnus-article-treat
1457 :link '(custom-manual "(gnus)Customizing Articles")
1458 :type gnus-article-treat-head-custom)
1460 (defcustom gnus-treat-capitalize-sentences nil
1461 "Capitalize sentence-starting words.
1462 Valid values are nil, t, `head', `last', an integer or a predicate.
1463 See Info node `(gnus)Customizing Articles' for details."
1465 :group 'gnus-article-treat
1466 :link '(custom-manual "(gnus)Customizing Articles")
1467 :type gnus-article-treat-custom)
1469 (defcustom gnus-treat-wash-html nil
1471 Valid values are nil, t, `head', `last', an integer or a predicate.
1472 See Info node `(gnus)Customizing Articles' for details."
1474 :group 'gnus-article-treat
1475 :link '(custom-manual "(gnus)Customizing Articles")
1476 :type gnus-article-treat-custom)
1478 (defcustom gnus-treat-fill-long-lines nil
1480 Valid values are nil, t, `head', `last', an integer or a predicate.
1481 See Info node `(gnus)Customizing Articles' for details."
1482 :group 'gnus-article-treat
1483 :link '(custom-manual "(gnus)Customizing Articles")
1484 :type gnus-article-treat-custom)
1486 (defcustom gnus-treat-play-sounds nil
1488 Valid values are nil, t, `head', `last', an integer or a predicate.
1489 See Info node `(gnus)Customizing Articles' for details."
1491 :group 'gnus-article-treat
1492 :link '(custom-manual "(gnus)Customizing Articles")
1493 :type gnus-article-treat-custom)
1495 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1496 "Decode an article as `default-mime-charset'. For instance, if you want to
1497 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1498 you could set this variable to something like: nil for don't decode, t for
1499 decode the body, '(or header t) for the whole article, etc."
1500 :group 'gnus-article-treat
1501 :type '(radio (const :tag "Off" nil)
1502 (const :tag "Decode body" t)
1503 (const :tag "Decode all" (or head t))))
1505 (defcustom gnus-treat-translate nil
1506 "Translate articles from one language to another.
1507 Valid values are nil, t, `head', `last', an integer or a predicate.
1508 See Info node `(gnus)Customizing Articles' for details."
1510 :group 'gnus-article-treat
1511 :link '(custom-manual "(gnus)Customizing Articles")
1512 :type gnus-article-treat-custom)
1514 (defcustom gnus-treat-x-pgp-sig nil
1516 To automatically treat X-PGP-Sig, set it to head.
1517 Valid values are nil, t, `head', `last', an integer or a predicate.
1518 See Info node `(gnus)Customizing Articles' for details."
1520 :group 'gnus-article-treat
1521 :group 'mime-security
1522 :type gnus-article-treat-custom)
1524 (defcustom gnus-treat-monafy nil
1525 "Display body part with mona font.
1526 Valid values are nil, t, `head', `last', an integer or a predicate.
1527 See Info node `(gnus)Customizing Articles' for details."
1528 :group 'gnus-article-treat
1529 :group 'mime-security
1530 :link '(custom-manual "(gnus)Customizing Articles")
1531 :type gnus-article-treat-custom)
1533 (defvar gnus-article-encrypt-protocol-alist
1534 '(("PGP" . mml2015-self-encrypt)))
1536 ;; Set to nil if more than one protocol added to
1537 ;; gnus-article-encrypt-protocol-alist.
1538 (defcustom gnus-article-encrypt-protocol "PGP"
1539 "The protocol used for encrypt articles.
1540 It is a string, such as \"PGP\". If nil, ask user."
1543 :group 'mime-security)
1545 (defvar gnus-article-wash-function nil
1546 "Function used for converting HTML into text.")
1548 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1549 (mm-coding-system-p 'utf-8)
1550 (executable-find idna-program))
1551 "Whether IDNA decoding of headers is used when viewing messages.
1552 This requires GNU Libidn, and by default only enabled if it is found."
1554 :group 'gnus-article-headers
1557 (defcustom gnus-article-over-scroll nil
1558 "If non-nil, allow scrolling the article buffer even when there no more text."
1560 :group 'gnus-article
1563 ;;; Internal variables
1565 (defvar gnus-english-month-names
1566 '("January" "February" "March" "April" "May" "June" "July" "August"
1567 "September" "October" "November" "December"))
1569 (defvar gnus-button-regexp nil)
1570 (defvar gnus-button-marker-list nil)
1571 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1573 (defvar gnus-button-last nil)
1574 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1576 (defvar article-goto-body-goes-to-point-min-p nil)
1577 (defvar gnus-article-wash-types nil)
1578 (defvar gnus-article-emphasis-alist nil)
1579 (defvar gnus-article-image-alist nil)
1581 (defvar gnus-article-mime-handle-alist-1 nil)
1582 (defvar gnus-treatment-function-alist
1583 '((gnus-treat-decode-article-as-default-mime-charset
1584 gnus-article-decode-article-as-default-mime-charset)
1585 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1586 (gnus-treat-monafy gnus-article-monafy)
1587 (gnus-treat-strip-banner gnus-article-strip-banner)
1588 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1589 (gnus-treat-buttonize gnus-article-add-buttons)
1590 (gnus-treat-fill-article gnus-article-fill-cited-article)
1591 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1592 (gnus-treat-strip-cr gnus-article-remove-cr)
1593 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1594 (gnus-treat-date-ut gnus-article-date-ut)
1595 (gnus-treat-date-local gnus-article-date-local)
1596 (gnus-treat-date-english gnus-article-date-english)
1597 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1598 (gnus-treat-date-original gnus-article-date-original)
1599 (gnus-treat-date-user-defined gnus-article-date-user)
1600 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1601 (gnus-treat-display-face gnus-article-display-face)
1602 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1603 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1604 (gnus-treat-hide-signature gnus-article-hide-signature)
1605 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1606 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1607 (gnus-treat-strip-pem gnus-article-hide-pem)
1608 (gnus-treat-from-picon gnus-treat-from-picon)
1609 (gnus-treat-mail-picon gnus-treat-mail-picon)
1610 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1611 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1612 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1613 (gnus-treat-strip-trailing-blank-lines
1614 gnus-article-remove-trailing-blank-lines)
1615 (gnus-treat-strip-leading-blank-lines
1616 gnus-article-strip-leading-blank-lines)
1617 (gnus-treat-strip-multiple-blank-lines
1618 gnus-article-strip-multiple-blank-lines)
1619 (gnus-treat-overstrike gnus-article-treat-overstrike)
1620 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1621 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1622 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1623 ;; Displaying X-Face should be done after unfolding headers
1624 ;; to protect bitmap lines.
1625 (gnus-treat-display-x-face gnus-article-display-x-face)
1626 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1627 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1628 (gnus-treat-display-smileys gnus-treat-smiley)
1629 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1630 (gnus-treat-wash-html gnus-article-wash-html)
1631 (gnus-treat-emphasize gnus-article-emphasize)
1632 (gnus-treat-hide-citation gnus-article-hide-citation)
1633 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1634 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1635 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1636 (gnus-treat-play-sounds gnus-earcon-display)))
1638 (defvar gnus-article-mime-handle-alist nil)
1639 (defvar article-lapsed-timer nil)
1640 (defvar gnus-article-current-summary nil)
1642 (defvar gnus-article-mode-syntax-table
1643 (let ((table (copy-syntax-table text-mode-syntax-table)))
1644 ;; This causes the citation match run O(2^n).
1645 ;; (modify-syntax-entry ?- "w" table)
1646 (modify-syntax-entry ?> ")<" table)
1647 (modify-syntax-entry ?< "(>" table)
1648 ;; make M-. in article buffers work for `foo' strings
1649 (modify-syntax-entry ?' " " table)
1650 (modify-syntax-entry ?` " " table)
1652 "Syntax table used in article mode buffers.
1653 Initialized from `text-mode-syntax-table.")
1655 (defvar gnus-save-article-buffer nil)
1657 (defvar gnus-article-mode-line-format-alist
1658 (nconc '((?w (gnus-article-wash-status) ?s)
1659 (?m (gnus-article-mime-part-status) ?s))
1660 gnus-summary-mode-line-format-alist))
1662 (defvar gnus-number-of-articles-to-be-saved nil)
1664 (defvar gnus-inhibit-hiding nil)
1666 (defvar gnus-article-edit-mode nil)
1668 ;;; Macros for dealing with the article buffer.
1670 (defmacro gnus-with-article-headers (&rest forms)
1672 (set-buffer gnus-article-buffer)
1674 (let ((inhibit-read-only t)
1675 (inhibit-point-motion-hooks t)
1676 (case-fold-search t))
1677 (article-narrow-to-head)
1680 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1681 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1683 (defmacro gnus-with-article-buffer (&rest forms)
1685 (set-buffer gnus-article-buffer)
1686 (let ((inhibit-read-only t))
1689 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1690 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1692 (defun gnus-article-goto-header (header)
1693 "Go to HEADER, which is a regular expression."
1694 (re-search-forward (concat "^\\(" header "\\):") nil t))
1696 (defsubst gnus-article-hide-text (b e props)
1697 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1698 (gnus-add-text-properties-when 'article-type nil b e props)
1699 (when (memq 'intangible props)
1701 (max (1- b) (point-min))
1702 b 'intangible (cddr (memq 'intangible props)))))
1704 (defsubst gnus-article-unhide-text (b e)
1705 "Remove hidden text properties from region between B and E."
1706 (remove-text-properties b e gnus-hidden-properties)
1707 (when (memq 'intangible gnus-hidden-properties)
1708 (put-text-property (max (1- b) (point-min))
1709 b 'intangible nil)))
1711 (defun gnus-article-hide-text-type (b e type)
1712 "Hide text of TYPE between B and E."
1713 (gnus-add-wash-type type)
1714 (gnus-article-hide-text
1715 b e (cons 'article-type (cons type gnus-hidden-properties))))
1717 (defun gnus-article-unhide-text-type (b e type)
1718 "Unhide text of TYPE between B and E."
1719 (gnus-delete-wash-type type)
1720 (remove-text-properties
1721 b e (cons 'article-type (cons type gnus-hidden-properties)))
1722 (when (memq 'intangible gnus-hidden-properties)
1723 (put-text-property (max (1- b) (point-min))
1724 b 'intangible nil)))
1726 (defun gnus-article-hide-text-of-type (type)
1727 "Hide text of TYPE in the current buffer."
1729 (let ((b (point-min))
1731 (while (setq b (text-property-any b e 'article-type type))
1732 (add-text-properties b (incf b) gnus-hidden-properties)))))
1734 (defun gnus-article-delete-text-of-type (type)
1735 "Delete text of TYPE in the current buffer."
1737 (let ((b (point-min)))
1738 (while (setq b (text-property-any b (point-max) 'article-type type))
1740 b (or (text-property-not-all b (point-max) 'article-type type)
1743 (defun gnus-article-delete-invisible-text ()
1744 "Delete all invisible text in the current buffer."
1746 (let ((b (point-min)))
1747 (while (setq b (text-property-any b (point-max) 'invisible t))
1749 b (or (text-property-not-all b (point-max) 'invisible t)
1752 (defun gnus-article-text-type-exists-p (type)
1753 "Say whether any text of type TYPE exists in the buffer."
1754 (text-property-any (point-min) (point-max) 'article-type type))
1756 (defsubst gnus-article-header-rank ()
1757 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1758 (let ((list gnus-sorted-header-list)
1761 (if (looking-at (car list))
1763 (setq list (cdr list))
1767 (defun article-hide-headers (&optional arg delete)
1768 "Hide unwanted headers and possibly sort them as well."
1769 (interactive (gnus-article-hidden-arg))
1770 ;; Lars said that this function might be inhibited.
1771 (if (gnus-article-check-hidden-text 'headers arg)
1773 ;; Show boring headers as well.
1774 (gnus-article-show-hidden-text 'boring-headers)
1775 (when (eq 1 (point-min))
1776 (set-window-start (get-buffer-window (current-buffer)) 1)))
1777 (unless gnus-inhibit-hiding
1778 (let ((inhibit-read-only t)
1779 (case-fold-search t)
1780 (max (1+ (length gnus-sorted-header-list)))
1781 (inhibit-point-motion-hooks t)
1782 (cur (current-buffer))
1783 ignored visible beg)
1785 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1786 ;; group parameters, so we should go to the summary buffer.
1789 (progn (set-buffer gnus-summary-buffer) t)
1791 (setq ignored (when (not gnus-visible-headers)
1792 (cond ((stringp gnus-ignored-headers)
1793 gnus-ignored-headers)
1794 ((listp gnus-ignored-headers)
1795 (mapconcat 'identity
1796 gnus-ignored-headers
1798 visible (cond ((stringp gnus-visible-headers)
1799 gnus-visible-headers)
1800 ((and gnus-visible-headers
1801 (listp gnus-visible-headers))
1802 (mapconcat 'identity
1803 gnus-visible-headers
1807 ;; First we narrow to just the headers.
1808 (article-narrow-to-head)
1809 ;; Hide any "From " lines at the beginning of (mail) articles.
1810 (while (looking-at "From ")
1814 (delete-region (point-min) (point))
1815 (gnus-article-hide-text (point-min) (point)
1816 (nconc (list 'article-type 'headers)
1817 gnus-hidden-properties))))
1818 ;; Then treat the rest of the header lines.
1819 ;; Then we use the two regular expressions
1820 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1821 ;; select which header lines is to remain visible in the
1823 (while (re-search-forward "^[^ \t:]*:" nil t)
1825 ;; Mark the rank of the header.
1827 (point) (1+ (point)) 'message-rank
1828 (if (or (and visible (looking-at visible))
1830 (not (looking-at ignored))))
1831 (gnus-article-header-rank)
1834 (message-sort-headers-1)
1835 (when (setq beg (text-property-any
1836 (point-min) (point-max) 'message-rank (+ 2 max)))
1837 ;; We delete or make invisible the unwanted headers.
1838 (gnus-add-wash-type 'headers)
1841 (add-text-properties
1842 (point-min) (+ 5 (point-min))
1843 '(article-type headers dummy-invisible t))
1844 (delete-region beg (point-max)))
1845 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1847 (defun article-hide-boring-headers (&optional arg)
1848 "Toggle hiding of headers that aren't very interesting.
1849 If given a negative prefix, always show; if given a positive prefix,
1851 (interactive (gnus-article-hidden-arg))
1852 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1853 (not gnus-show-all-headers))
1856 (let ((inhibit-read-only t)
1857 (inhibit-point-motion-hooks t))
1858 (article-narrow-to-head)
1859 (dolist (elem gnus-boring-article-headers)
1860 (goto-char (point-min))
1862 ;; Hide empty headers.
1864 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1866 (gnus-article-hide-text-type
1870 (if (re-search-forward "^[^ \t]" nil t)
1874 ;; Hide boring Newsgroups header.
1875 ((eq elem 'newsgroups)
1876 (when (gnus-string-equal
1877 (gnus-fetch-field "newsgroups")
1878 (gnus-group-real-name
1879 (if (boundp 'gnus-newsgroup-name)
1882 (gnus-article-hide-header "newsgroups")))
1883 ((eq elem 'to-address)
1884 (let ((to (message-fetch-field "to"))
1886 (gnus-parameter-to-address
1887 (if (boundp 'gnus-newsgroup-name)
1888 gnus-newsgroup-name ""))))
1889 (when (and to to-address
1892 ;; only one address in To
1893 (nth 1 (mail-extract-address-components to))
1895 (gnus-article-hide-header "to"))))
1897 (let ((to (message-fetch-field "to"))
1899 (gnus-parameter-to-list
1900 (if (boundp 'gnus-newsgroup-name)
1901 gnus-newsgroup-name ""))))
1902 (when (and to to-list
1905 ;; only one address in To
1906 (nth 1 (mail-extract-address-components to))
1908 (gnus-article-hide-header "to"))))
1910 (let ((cc (message-fetch-field "cc"))
1912 (gnus-parameter-to-list
1913 (if (boundp 'gnus-newsgroup-name)
1914 gnus-newsgroup-name ""))))
1915 (when (and cc to-list
1918 ;; only one address in CC
1919 (nth 1 (mail-extract-address-components cc))
1921 (gnus-article-hide-header "cc"))))
1922 ((eq elem 'followup-to)
1923 (when (gnus-string-equal
1924 (message-fetch-field "followup-to")
1925 (message-fetch-field "newsgroups"))
1926 (gnus-article-hide-header "followup-to")))
1927 ((eq elem 'reply-to)
1928 (if (gnus-group-find-parameter
1929 gnus-newsgroup-name 'broken-reply-to)
1930 (gnus-article-hide-header "reply-to")
1931 (let ((from (message-fetch-field "from"))
1932 (reply-to (message-fetch-field "reply-to")))
1939 (lambda (x) (downcase (cadr x)))
1940 (mail-extract-address-components from t))
1943 (lambda (x) (downcase (cadr x)))
1944 (mail-extract-address-components reply-to t))
1946 (gnus-article-hide-header "reply-to")))))
1948 (let ((date (message-fetch-field "date")))
1950 (< (days-between (current-time-string) date)
1952 (gnus-article-hide-header "date"))))
1954 (let ((to (message-fetch-field "to"))
1955 (cc (message-fetch-field "cc")))
1956 (when (> (length to) 1024)
1957 (gnus-article-hide-header "to"))
1958 (when (> (length cc) 1024)
1959 (gnus-article-hide-header "cc"))))
1963 (goto-char (point-min))
1964 (while (re-search-forward "^to:" nil t)
1965 (setq to-count (1+ to-count)))
1966 (when (> to-count 1)
1967 (while (> to-count 0)
1968 (goto-char (point-min))
1970 (re-search-forward "^to:" nil nil to-count)
1972 (narrow-to-region (point) (point-max))
1973 (gnus-article-hide-header "to"))
1974 (setq to-count (1- to-count))))
1975 (goto-char (point-min))
1976 (while (re-search-forward "^cc:" nil t)
1977 (setq cc-count (1+ cc-count)))
1978 (when (> cc-count 1)
1979 (while (> cc-count 0)
1980 (goto-char (point-min))
1982 (re-search-forward "^cc:" nil nil cc-count)
1984 (narrow-to-region (point) (point-max))
1985 (gnus-article-hide-header "cc"))
1986 (setq cc-count (1- cc-count)))))))))))))
1988 (defun gnus-article-hide-header (header)
1990 (goto-char (point-min))
1991 (when (re-search-forward (concat "^" header ":") nil t)
1992 (gnus-article-hide-text-type
1996 (if (re-search-forward "^[^ \t]" nil t)
2001 (defvar gnus-article-normalized-header-length 40
2002 "Length of normalized headers.")
2004 (defun article-normalize-headers ()
2005 "Make all header lines 40 characters long."
2007 (let ((inhibit-read-only t)
2011 (article-narrow-to-head)
2014 ((< (setq column (- (point-at-eol) (point)))
2015 gnus-article-normalized-header-length)
2017 (insert (make-string
2018 (- gnus-article-normalized-header-length column)
2020 ((> column gnus-article-normalized-header-length)
2021 (gnus-put-text-property
2023 (forward-char gnus-article-normalized-header-length)
2030 (forward-line 1))))))
2032 (defun article-treat-dumbquotes ()
2033 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2034 Note that this function guesses whether a character is a sm*rtq**t* or
2035 not, so it should only be used interactively.
2037 Sm*rtq**t*s are M****s***'s unilateral extension to the
2038 iso-8859-1 character map in an attempt to provide more quoting
2039 characters. If you see something like \\222 or \\264 where
2040 you're expecting some kind of apostrophe or quotation mark, then
2043 (article-translate-strings gnus-article-dumbquotes-map))
2045 (defun article-translate-characters (from to)
2046 "Translate all characters in the body of the article according to FROM and TO.
2047 FROM is a string of characters to translate from; to is a string of
2048 characters to translate to."
2050 (when (article-goto-body)
2051 (let ((inhibit-read-only t)
2052 (x (make-string 225 ?x))
2054 (while (< (incf i) (length x))
2057 (while (< i (length from))
2058 (aset x (aref from i) (aref to i))
2060 (translate-region (point) (point-max) x)))))
2062 (defun article-translate-strings (map)
2063 "Translate all string in the body of the article according to MAP.
2064 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2066 (when (article-goto-body)
2067 (let ((inhibit-read-only t))
2070 (while (search-forward (car elem) nil t)
2071 (replace-match (cadr elem)))))))))
2073 (defun article-treat-overstrike ()
2074 "Translate overstrikes into bold text."
2077 (when (article-goto-body)
2078 (let ((inhibit-read-only t))
2079 (while (search-forward "\b" nil t)
2080 (let ((next (char-after))
2084 previous (char-after))
2088 ;; We do the boldification/underlining by hiding the
2089 ;; overstrikes and putting the proper text property
2093 (gnus-article-hide-text-type start (point) 'overstrike)
2094 (put-text-property (point) end 'face 'bold))
2096 (gnus-article-hide-text-type
2097 (1- (point)) (1+ (point)) 'overstrike)
2099 start (1- (point)) 'face 'underline))
2101 (gnus-article-hide-text-type start (point) 'overstrike)
2103 (point) end 'face 'underline)))))))))
2105 (defun article-treat-ansi-sequences ()
2106 "Translate ANSI SGR control sequences into overlays or extents."
2109 (when (article-goto-body)
2110 (let ((inhibit-read-only t))
2111 (ansi-color-apply-on-region (point) (point-max))))))
2113 (defun gnus-article-treat-unfold-headers ()
2114 "Unfold folded message headers.
2115 Only the headers that fit into the current window width will be
2118 (gnus-with-article-headers
2122 (mail-header-narrow-to-field)
2123 (let ((header (buffer-string)))
2126 (goto-char (point-min))
2127 (while (re-search-forward "\n[\t ]" nil t)
2128 (replace-match " " t t)))
2129 (setq length (- (point-max) (point-min) 1)))
2130 (when (< length (window-width))
2131 (while (re-search-forward "\n[\t ]" nil t)
2132 (replace-match " " t t)))
2133 (goto-char (point-max)))))))
2135 (defun gnus-article-treat-fold-headers ()
2136 "Fold message headers."
2138 (gnus-with-article-headers
2141 (mail-header-narrow-to-field)
2142 (mail-header-fold-field)
2143 (goto-char (point-max))))))
2145 (defun gnus-treat-smiley ()
2146 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2148 (unless (featurep 'xemacs)
2149 (when (and (not gnus-article-should-use-smiley-mule)
2150 gnus-article-smiley-mule-loaded-p)
2151 (load "smiley" nil t)
2152 (setq gnus-article-smiley-mule-loaded-p nil))
2153 (when (and gnus-article-should-use-smiley-mule
2154 (not gnus-article-smiley-mule-loaded-p))
2155 (load "smiley-mule" nil t)
2156 (setq gnus-article-smiley-mule-loaded-p t)))
2157 (gnus-with-article-buffer
2158 (if (memq 'smiley gnus-article-wash-types)
2159 (gnus-delete-images 'smiley)
2161 (let ((images (smiley-region (point) (point-max))))
2163 (gnus-add-wash-type 'smiley)
2164 (dolist (image images)
2165 (gnus-add-image 'smiley image)))))))
2167 (defun gnus-article-remove-images ()
2168 "Remove all images from the article buffer."
2170 (gnus-with-article-buffer
2171 (dolist (elem gnus-article-image-alist)
2172 (gnus-delete-images (car elem)))))
2174 (defun gnus-article-treat-fold-newsgroups ()
2175 "Unfold folded message headers.
2176 Only the headers that fit into the current window width will be
2179 (gnus-with-article-headers
2180 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2182 (mail-header-narrow-to-field)
2183 (while (re-search-forward ", *" nil t)
2184 (replace-match ", " t t))
2185 (mail-header-fold-field)
2186 (goto-char (point-max))))))
2188 (defun gnus-article-treat-body-boundary ()
2189 "Place a boundary line at the end of the headers."
2191 (when (and gnus-body-boundary-delimiter
2192 (> (length gnus-body-boundary-delimiter) 0))
2193 (gnus-with-article-headers
2194 (goto-char (point-max))
2195 (let ((start (point)))
2196 (insert "X-Boundary: ")
2197 (gnus-add-text-properties start (point) '(invisible t intangible t))
2199 (while (>= (1- (window-width)) (length str))
2200 (setq str (concat str gnus-body-boundary-delimiter)))
2201 (substring str 0 (1- (window-width))))
2203 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2205 (defun article-fill-long-lines ()
2206 "Fill lines that are wider than the window width."
2209 (let ((inhibit-read-only t)
2210 (width (window-width (get-buffer-window (current-buffer)))))
2213 (let ((adaptive-fill-mode nil)) ;Why? -sm
2216 (when (>= (current-column) (min fill-column width))
2217 (narrow-to-region (min (1+ (point)) (point-max))
2219 (let ((goback (point-marker)))
2220 (fill-paragraph nil)
2221 (goto-char (marker-position goback)))
2223 (forward-line 1)))))))
2225 (defun article-capitalize-sentences ()
2226 "Capitalize the first word in each sentence."
2229 (let ((inhibit-read-only t)
2230 (paragraph-start "^[\n\^L]"))
2234 (forward-sentence)))))
2236 (defun article-remove-cr ()
2237 "Remove trailing CRs and then translate remaining CRs into LFs."
2240 (let ((inhibit-read-only t))
2241 (goto-char (point-min))
2242 (while (re-search-forward "\r+$" nil t)
2243 (replace-match "" t t))
2244 (goto-char (point-min))
2245 (while (search-forward "\r" nil t)
2246 (replace-match "\n" t t)))))
2248 (defun article-remove-trailing-blank-lines ()
2249 "Remove all trailing blank lines from the article."
2252 (let ((inhibit-read-only t))
2253 (goto-char (point-max))
2257 (while (and (not (bobp))
2258 (looking-at "^[ \t]*$")
2259 (not (gnus-annotation-in-region-p
2260 (point) (point-at-eol))))
2266 (defvar gnus-face-properties-alist))
2268 (defun article-display-face ()
2269 "Display any Face headers in the header."
2271 (let ((wash-face-p buffer-read-only))
2272 (gnus-with-article-headers
2273 ;; When displaying parts, this function can be called several times on
2274 ;; the same article, without any intended toggle semantic (as typing `W
2275 ;; D d' would have). So face deletion must occur only when we come from
2276 ;; an interactive command, that is when the *Article* buffer is
2278 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2279 (gnus-delete-images 'face)
2282 (when (and wash-face-p
2284 (goto-char (point-min))
2285 (not (re-search-forward "^Face:[\t ]*" nil t)))
2286 (gnus-buffer-live-p gnus-original-article-buffer))
2287 (set-buffer gnus-original-article-buffer))
2289 (mail-narrow-to-head)
2290 (while (gnus-article-goto-header "Face")
2291 (setq faces (nconc faces (list (mail-header-field-value)))))))
2292 (dolist (face faces)
2293 (let ((png (gnus-convert-face-to-png face))
2297 (apply 'gnus-create-image png 'png t
2298 (cdr (assq 'png gnus-face-properties-alist))))
2299 (gnus-article-goto-header "from")
2301 (insert "From: [no `from' set]\n")
2303 (gnus-add-wash-type 'face)
2304 (gnus-add-image 'face image)
2305 (gnus-put-image image nil 'face))))))
2308 (defun article-display-x-face (&optional force)
2309 "Look for an X-Face header and display it if present."
2310 (interactive (list 'force))
2311 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2312 (gnus-with-article-headers
2313 ;; Delete the old process, if any.
2314 (when (process-status "article-x-face")
2315 (delete-process "article-x-face"))
2316 ;; See the comment in `article-display-face'.
2317 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2318 ;; We have already displayed X-Faces, so we remove them
2320 (gnus-delete-images 'xface)
2322 (let (x-faces from face)
2324 (when (and wash-face-p
2326 (goto-char (point-min))
2327 (not (re-search-forward
2328 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2329 (gnus-buffer-live-p gnus-original-article-buffer))
2330 ;; If type `W f', use gnus-original-article-buffer,
2331 ;; otherwise use the current buffer because displaying
2332 ;; RFC822 parts calls this function too.
2333 (set-buffer gnus-original-article-buffer))
2335 (mail-narrow-to-head)
2336 (while (gnus-article-goto-header "X-Face")
2337 (push (mail-header-field-value) x-faces))
2338 (setq from (message-fetch-field "from"))))
2339 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2340 ;; single external face.
2341 (when (stringp gnus-article-x-face-command)
2342 (setq x-faces (list (car x-faces))))
2343 (while (and (setq face (pop x-faces))
2344 gnus-article-x-face-command
2346 ;; Check whether this face is censored.
2347 (not gnus-article-x-face-too-ugly)
2348 (and gnus-article-x-face-too-ugly from
2349 (not (string-match gnus-article-x-face-too-ugly
2351 ;; We display the face.
2352 (cond ((stringp gnus-article-x-face-command)
2353 ;; The command is a string, so we interpret the command
2354 ;; as a, well, command, and fork it off.
2355 (let ((process-connection-type nil))
2356 (process-kill-without-query
2358 "article-x-face" nil shell-file-name
2359 shell-command-switch gnus-article-x-face-command))
2362 (process-send-region "article-x-face"
2363 (point-min) (point-max)))
2364 (process-send-eof "article-x-face")))
2365 ((functionp gnus-article-x-face-command)
2366 ;; The command is a lisp function, so we call it.
2367 (funcall gnus-article-x-face-command face))
2369 (error "%s is not a function"
2370 gnus-article-x-face-command)))))))))
2372 (defun article-decode-mime-words ()
2373 "Decode all MIME-encoded words in the article."
2375 (gnus-with-article-buffer
2376 (let ((inhibit-point-motion-hooks t)
2377 (mail-parse-charset gnus-newsgroup-charset)
2378 (mail-parse-ignored-charsets
2379 (with-current-buffer gnus-summary-buffer
2380 gnus-newsgroup-ignored-charsets)))
2381 (mail-decode-encoded-word-region (point-min) (point-max)))))
2383 (defun article-decode-charset (&optional prompt)
2384 "Decode charset-encoded text in the article.
2385 If PROMPT (the prefix), prompt for a coding system to use."
2387 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2388 (inhibit-read-only t)
2389 (mail-parse-charset gnus-newsgroup-charset)
2390 (mail-parse-ignored-charsets
2391 (save-excursion (condition-case nil
2392 (set-buffer gnus-summary-buffer)
2394 gnus-newsgroup-ignored-charsets))
2395 ct cte ctl charset format)
2398 (article-narrow-to-head)
2399 (setq ct (message-fetch-field "Content-Type" t)
2400 cte (message-fetch-field "Content-Transfer-Encoding" t)
2401 ctl (and ct (ignore-errors
2402 (mail-header-parse-content-type ct)))
2405 (mm-read-coding-system "Charset to decode: "))
2407 (mail-content-type-get ctl 'charset)))
2408 format (and ctl (mail-content-type-get ctl 'format)))
2410 (setq cte (mail-header-strip cte)))
2411 (if (and ctl (not (string-match "/" (car ctl))))
2413 (goto-char (point-max)))
2416 (narrow-to-region (point) (point-max))
2417 (when (and (eq mail-parse-charset 'gnus-decoded)
2418 (eq (mm-body-7-or-8) '8bit))
2419 ;; The text code could have been decoded.
2420 (setq charset mail-parse-charset))
2421 (when (and (or (not ctl)
2422 (equal (car ctl) "text/plain"))
2423 (not format)) ;; article with format will decode later.
2425 charset (and cte (intern (downcase
2426 (gnus-strip-whitespace cte))))
2429 (defun article-decode-encoded-words ()
2430 "Remove encoded-word encoding from headers."
2431 (let ((charset (save-excursion
2432 (set-buffer gnus-summary-buffer)
2433 default-mime-charset))
2434 (inhibit-read-only t))
2435 (mime-decode-header-in-buffer charset)))
2437 (defun article-decode-group-name ()
2438 "Decode group names in `Newsgroups:'."
2439 (let ((inhibit-point-motion-hooks t)
2440 (inhibit-read-only t)
2441 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2442 (when (and (or gnus-group-name-charset-method-alist
2443 gnus-group-name-charset-group-alist)
2444 (gnus-buffer-live-p gnus-original-article-buffer))
2446 (article-narrow-to-head)
2447 (with-current-buffer gnus-original-article-buffer
2448 (goto-char (point-min)))
2449 (while (re-search-forward
2450 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2451 (replace-match (save-match-data
2452 (gnus-decode-newsgroups
2453 ;; XXX how to use data in article buffer?
2454 (with-current-buffer gnus-original-article-buffer
2456 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2459 gnus-newsgroup-name method))
2461 (goto-char (point-min))
2462 (with-current-buffer gnus-original-article-buffer
2463 (goto-char (point-min)))
2464 (while (re-search-forward
2465 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2466 (replace-match (save-match-data
2467 (gnus-decode-newsgroups
2468 ;; XXX how to use data in article buffer?
2469 (with-current-buffer gnus-original-article-buffer
2471 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2474 gnus-newsgroup-name method))
2477 (autoload 'idna-to-unicode "idna")
2479 (defun article-decode-idna-rhs ()
2480 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2483 (let ((inhibit-point-motion-hooks t)
2484 (inhibit-read-only t))
2485 (article-narrow-to-head)
2486 (goto-char (point-min))
2487 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2489 (when (save-match-data
2490 (and (setq ace (match-string 1))
2492 (and (re-search-backward "^[^ \t]" nil t)
2493 (looking-at "From\\|To\\|Cc")))
2494 (setq unicode (idna-to-unicode ace))))
2495 (unless (string= ace unicode)
2496 (replace-match unicode nil nil nil 1)))))))))
2498 (defun article-de-quoted-unreadable (&optional force read-charset)
2499 "Translate a quoted-printable-encoded article.
2500 If FORCE, decode the article whether it is marked as quoted-printable
2502 If READ-CHARSET, ask for a coding system."
2503 (interactive (list 'force current-prefix-arg))
2505 (let ((inhibit-read-only t) type charset)
2506 (if (gnus-buffer-live-p gnus-original-article-buffer)
2507 (with-current-buffer gnus-original-article-buffer
2509 (gnus-fetch-field "content-transfer-encoding"))
2510 (let* ((ct (gnus-fetch-field "content-type"))
2513 (mail-header-parse-content-type ct)))))
2514 (setq charset (and ctl
2515 (mail-content-type-get ctl 'charset)))
2516 (if (stringp charset)
2517 (setq charset (intern (downcase charset)))))))
2519 (setq charset (mm-read-coding-system "Charset: " charset)))
2521 (setq charset gnus-newsgroup-charset))
2523 (and type (let ((case-fold-search t))
2524 (string-match "quoted-printable" type))))
2526 (quoted-printable-decode-region
2527 (point) (point-max) (mm-charset-to-coding-system charset))))))
2529 (defun article-de-base64-unreadable (&optional force read-charset)
2530 "Translate a base64 article.
2531 If FORCE, decode the article whether it is marked as base64 not.
2532 If READ-CHARSET, ask for a coding system."
2533 (interactive (list 'force current-prefix-arg))
2535 (let ((inhibit-read-only t) type charset)
2536 (if (gnus-buffer-live-p gnus-original-article-buffer)
2537 (with-current-buffer gnus-original-article-buffer
2539 (gnus-fetch-field "content-transfer-encoding"))
2540 (let* ((ct (gnus-fetch-field "content-type"))
2543 (mail-header-parse-content-type ct)))))
2544 (setq charset (and ctl
2545 (mail-content-type-get ctl 'charset)))
2546 (if (stringp charset)
2547 (setq charset (intern (downcase charset)))))))
2549 (setq charset (mm-read-coding-system "Charset: " charset)))
2551 (setq charset gnus-newsgroup-charset))
2553 (and type (let ((case-fold-search t))
2554 (string-match "base64" type))))
2557 (narrow-to-region (point) (point-max))
2558 (base64-decode-region (point-min) (point-max))
2559 (mm-decode-coding-region
2560 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2565 (defun article-decode-HZ ()
2566 "Translate a HZ-encoded article."
2570 (let ((inhibit-read-only t))
2571 (rfc1843-decode-region (point-min) (point-max)))))
2573 (defun article-unsplit-urls ()
2574 "Remove the newlines that some other mailers insert into URLs."
2577 (let ((inhibit-read-only t))
2578 (goto-char (point-min))
2579 (while (re-search-forward
2580 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2581 (replace-match "\\1\\3" t)))
2582 (when (interactive-p)
2583 (gnus-treat-article nil))))
2586 (defun article-wash-html (&optional read-charset)
2587 "Format an HTML article.
2588 If READ-CHARSET, ask for a coding system."
2591 (let ((inhibit-read-only t)
2593 (when (gnus-buffer-live-p gnus-original-article-buffer)
2594 (with-current-buffer gnus-original-article-buffer
2595 (let* ((ct (gnus-fetch-field "content-type"))
2598 (mail-header-parse-content-type ct)))))
2599 (setq charset (and ctl
2600 (mail-content-type-get ctl 'charset)))
2601 (when (stringp charset)
2602 (setq charset (intern (downcase charset)))))))
2604 (setq charset (mm-read-coding-system "Charset: " charset)))
2606 (setq charset gnus-newsgroup-charset))
2608 (save-window-excursion
2610 (narrow-to-region (point) (point-max))
2611 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2612 (entry (assq func mm-text-html-washer-alist)))
2614 (setq func (cdr entry)))
2619 (apply (car func) (cdr func))))))))))
2621 (defun gnus-article-wash-html-with-w3 ()
2622 "Wash the current buffer with w3."
2624 (let ((w3-strict-width (window-width))
2625 (url-standalone-mode t)
2626 (url-gateway-unplugged t)
2627 (w3-honor-stylesheets nil))
2629 (w3-region (point-min) (point-max))
2632 (defun gnus-article-wash-html-with-w3m ()
2633 "Wash the current buffer with emacs-w3m."
2636 (narrow-to-region (point) (point-max))
2637 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2638 w3m-force-redisplay)
2639 (w3m-region (point-min) (point-max)))
2640 (when (and mm-inline-text-html-with-w3m-keymap
2641 (boundp 'w3m-minor-mode-map)
2643 (add-text-properties
2644 (point-min) (point-max)
2645 (list 'keymap w3m-minor-mode-map
2646 ;; Put the mark meaning this part was rendered by emacs-w3m.
2647 'mm-inline-text-html-with-w3m t)))))
2649 (defun article-hide-list-identifiers ()
2650 "Remove list identifies from the Subject header.
2651 The `gnus-list-identifiers' variable specifies what to do."
2653 (let ((inhibit-point-motion-hooks t)
2654 (regexp (if (consp gnus-list-identifiers)
2655 (mapconcat 'identity gnus-list-identifiers " *\\|")
2656 gnus-list-identifiers))
2657 (inhibit-read-only t))
2661 (article-narrow-to-head)
2662 (goto-char (point-min))
2663 (while (re-search-forward
2664 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2666 (delete-region (match-beginning 2) (match-end 0))
2667 (beginning-of-line))
2668 (when (re-search-forward
2669 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2670 (delete-region (match-beginning 1) (match-end 1))))))))
2672 (defun article-hide-pem (&optional arg)
2673 "Toggle hiding of any PEM headers and signatures in the current article.
2674 If given a negative prefix, always show; if given a positive prefix,
2676 (interactive (gnus-article-hidden-arg))
2677 (unless (gnus-article-check-hidden-text 'pem arg)
2679 (let ((inhibit-read-only t) end)
2680 (goto-char (point-min))
2681 ;; Hide the horrendously ugly "header".
2682 (when (and (search-forward
2683 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2685 (setq end (1+ (match-beginning 0))))
2686 (gnus-add-wash-type 'pem)
2687 (gnus-article-hide-text-type
2689 (if (search-forward "\n\n" nil t)
2693 ;; Hide the trailer as well
2694 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2696 (gnus-article-hide-text-type
2697 (match-beginning 0) (match-end 0) 'pem)))))))
2699 (defun article-strip-banner ()
2700 "Strip the banners specified by the `banner' group parameter and by
2701 `gnus-article-address-banner-alist'."
2705 (let ((inhibit-point-motion-hooks t))
2706 (when (gnus-parameter-banner gnus-newsgroup-name)
2707 (article-really-strip-banner
2708 (gnus-parameter-banner gnus-newsgroup-name)))
2709 (when gnus-article-address-banner-alist
2710 ;; It is necessary to encode from fields before checking,
2711 ;; because `mail-header-parse-addresses' does not work
2712 ;; (reliably) on decoded headers. And more, it is
2713 ;; impossible to use `gnus-fetch-original-field' here,
2714 ;; because `article-strip-banner' may be called in draft
2715 ;; buffers to preview them.
2716 (let ((from (save-restriction
2718 (article-narrow-to-head)
2719 (mail-fetch-field "from"))))
2722 (caar (mail-header-parse-addresses
2723 (mail-encode-encoded-word-string from)))))
2725 (dolist (pair gnus-article-address-banner-alist)
2726 (when (string-match (car pair) from)
2728 (article-really-strip-banner (cdr pair)))))))))))))
2730 (defun article-really-strip-banner (banner)
2731 "Strip the banner specified by the argument."
2734 (let ((inhibit-point-motion-hooks t)
2735 (gnus-signature-limit nil)
2736 (inhibit-read-only t))
2739 ((eq banner 'signature)
2740 (when (gnus-article-narrow-to-signature)
2743 (delete-region (point) (point-max))))
2745 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2746 (while (re-search-forward banner nil t)
2747 (delete-region (match-beginning 0) (match-end 0)))))
2749 (while (re-search-forward banner nil t)
2750 (delete-region (match-beginning 0) (match-end 0)))))))))
2752 (defun article-babel ()
2753 "Translate article using an online translation service."
2756 (gnus-with-article-buffer
2757 (when (article-goto-body)
2758 (let* ((start (point))
2760 (orig (buffer-substring start end))
2761 (trans (babel-as-string orig)))
2763 (narrow-to-region start end)
2764 (delete-region start end)
2767 (defun article-hide-signature (&optional arg)
2768 "Hide the signature in the current article.
2769 If given a negative prefix, always show; if given a positive prefix,
2771 (interactive (gnus-article-hidden-arg))
2777 (article-goto-body))
2778 (goto-char (point-min)))
2779 (unless (gnus-article-check-hidden-text 'signature arg)
2780 (let ((inhibit-read-only t)
2782 (while (setq button (text-property-any button (point-max)
2784 'gnus-signature-toggle))
2785 (setq button (text-property-not-all button (point-max)
2787 'gnus-signature-toggle))
2788 (when (and button (not (eobp)))
2789 (gnus-article-hide-text-type
2791 (next-single-property-change (1+ button) 'mime-view-entity
2794 (gnus-set-mode-line 'article))
2796 (defun article-strip-headers-in-body ()
2797 "Strip offensive headers from bodies."
2801 (let ((case-fold-search t))
2802 (when (looking-at "x-no-archive:")
2803 (gnus-delete-line)))))
2805 (defun article-strip-leading-blank-lines ()
2806 "Remove all blank lines from the beginning of the article."
2809 (let ((inhibit-point-motion-hooks t)
2810 (inhibit-read-only t))
2811 (when (article-goto-body)
2812 (while (and (not (eobp))
2813 (looking-at "[ \t]*$"))
2814 (gnus-delete-line))))))
2816 (defun article-narrow-to-head ()
2817 "Narrow the buffer to the head of the message.
2818 Point is left at the beginning of the narrowed-to region."
2820 (goto-char (point-min))
2821 (if (search-forward "\n\n" nil 1)
2824 (goto-char (point-min)))
2826 (defun article-goto-body ()
2827 "Place point at the start of the body."
2828 (goto-char (point-min))
2830 ;; This variable is only bound when dealing with separate
2832 (article-goto-body-goes-to-point-min-p
2834 ((search-forward "\n\n" nil t)
2837 (goto-char (point-max))
2840 (defun article-strip-multiple-blank-lines ()
2841 "Replace consecutive blank lines with one empty line."
2844 (let ((inhibit-point-motion-hooks t)
2845 (inhibit-read-only t))
2846 ;; First make all blank lines empty.
2848 (while (re-search-forward "^[ \t]+$" nil t)
2849 (unless (gnus-annotation-in-region-p
2850 (match-beginning 0) (match-end 0))
2851 (replace-match "" nil t)))
2852 ;; Then replace multiple empty lines with a single empty line.
2854 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2855 (unless (gnus-annotation-in-region-p
2856 (match-beginning 0) (match-end 0))
2857 (delete-region (match-beginning 1) (match-end 1)))))))
2859 (defun article-strip-leading-space ()
2860 "Remove all white space from the beginning of the lines in the article."
2863 (let ((inhibit-point-motion-hooks t)
2864 (inhibit-read-only t))
2866 (while (re-search-forward "^[ \t]+" nil t)
2867 (replace-match "" t t)))))
2869 (defun article-strip-trailing-space ()
2870 "Remove all white space from the end of the lines in the article."
2873 (let ((inhibit-point-motion-hooks t)
2874 (inhibit-read-only t))
2876 (while (re-search-forward "[ \t]+$" nil t)
2877 (replace-match "" t t)))))
2879 (defun article-strip-blank-lines ()
2880 "Strip leading, trailing and multiple blank lines."
2882 (article-strip-leading-blank-lines)
2883 (article-remove-trailing-blank-lines)
2884 (article-strip-multiple-blank-lines))
2886 (defun article-strip-all-blank-lines ()
2887 "Strip all blank lines."
2890 (let ((inhibit-point-motion-hooks t)
2891 (inhibit-read-only t))
2893 (while (re-search-forward "^[ \t]*\n" nil t)
2894 (replace-match "" t t)))))
2896 (defun gnus-article-narrow-to-signature ()
2897 "Narrow to the signature; return t if a signature is found, else nil."
2898 (let ((inhibit-point-motion-hooks t))
2899 (when (gnus-article-search-signature)
2901 ;; Check whether we have some limits to what we consider
2902 ;; to be a signature.
2903 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2904 (list gnus-signature-limit)))
2906 (while (setq limit (pop limits))
2907 (if (or (and (integerp limit)
2908 (< (- (point-max) (point)) limit))
2910 (< (count-lines (point) (point-max)) limit))
2911 (and (functionp limit)
2913 (and (stringp limit)
2914 (not (re-search-forward limit nil t))))
2915 () ; This limit did not succeed.
2919 (narrow-to-region (point) (point-max))
2922 (defun gnus-article-search-signature ()
2923 "Search the current buffer for the signature separator.
2924 Put point at the beginning of the signature separator."
2925 (let ((cur (point)))
2926 (goto-char (point-max))
2927 (if (if (stringp gnus-signature-separator)
2928 (re-search-backward gnus-signature-separator nil t)
2929 (let ((seps gnus-signature-separator))
2931 (not (re-search-backward (car seps) nil t)))
2938 (defun gnus-article-hidden-arg ()
2939 "Return the current prefix arg as a number, or 0 if no prefix."
2940 (list (if current-prefix-arg
2941 (prefix-numeric-value current-prefix-arg)
2944 (defun gnus-article-check-hidden-text (type arg)
2945 "Return nil if hiding is necessary.
2946 Arg can be nil or a number. nil and positive means hide, negative
2947 means show, 0 means toggle."
2950 (let ((hide (gnus-article-hidden-text-p type)))
2956 (gnus-article-show-hidden-text type)
2959 (if (eq hide 'hidden)
2961 (gnus-article-show-hidden-text type)
2965 (defun gnus-article-hidden-text-p (type)
2966 "Say whether the current buffer contains hidden text of type TYPE."
2967 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2969 (not (get-text-property pos 'invisible))
2970 (not (get-text-property pos 'dummy-invisible)))
2972 (text-property-any (1+ pos) (point-max) 'article-type type)))
2977 (defun gnus-article-show-hidden-text (type &optional dummy)
2978 "Show all hidden text of type TYPE.
2979 Originally it is hide instead of DUMMY."
2980 (let ((inhibit-read-only t)
2981 (inhibit-point-motion-hooks t))
2982 (gnus-remove-text-properties-when
2984 (point-min) (point-max)
2985 (cons 'article-type (cons type
2986 gnus-hidden-properties)))
2987 (gnus-delete-wash-type type)))
2989 (defconst article-time-units
2990 `((year . ,(* 365.25 24 60 60))
2991 (week . ,(* 7 24 60 60))
2992 (day . ,(* 24 60 60))
2996 "Mapping from time units to seconds.")
2998 (defun gnus-article-forward-header ()
2999 "Move point to the start of the next header.
3000 If the current header is a continuation header, this can be several
3005 (if (looking-at "[ \t]+[^ \t]")
3009 (defun article-date-ut (&optional type highlight header)
3010 "Convert DATE date to universal time in the current article.
3011 If TYPE is `local', convert to local time; if it is `lapsed', output
3012 how much time has lapsed since DATE. For `lapsed', the value of
3013 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3014 should replace the \"Date:\" one, or should be added below it."
3015 (interactive (list 'ut t))
3016 (let* ((header (or header
3017 (and (eq 1 (point-min))
3018 (mail-header-date (save-excursion
3019 (set-buffer gnus-summary-buffer)
3020 gnus-current-headers)))
3021 (message-fetch-field "date")
3023 (date (if (vectorp header) (mail-header-date header)
3025 (inhibit-point-motion-hooks t)
3026 bface eface date-pos)
3027 (when (and date (not (string= date "")))
3030 (article-narrow-to-head)
3031 (when (or (and (eq type 'lapsed)
3032 gnus-article-date-lapsed-new-header
3033 ;; Attempt to get the face of X-Sent first.
3034 (re-search-forward "^X-Sent:[ \t]" nil t))
3035 (re-search-forward "^Date:[ \t]" nil t)
3036 ;; If Date is missing, try again for X-Sent.
3037 (re-search-forward "^X-Sent:[ \t]" nil t))
3038 (setq bface (get-text-property (point-at-bol) 'face)
3039 date (or (get-text-property (point-at-bol)
3042 eface (get-text-property (1- (point-at-eol))
3044 (let ((inhibit-read-only t))
3045 ;; Delete any old X-Sent headers.
3046 (when (setq date-pos
3047 (text-property-any (point-min) (point-max)
3048 'article-date-lapsed t))
3049 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
3050 (delete-region (match-beginning 0)
3051 (progn (forward-line 1) (point))))
3052 (goto-char (point-min))
3053 ;; Delete any old Date headers.
3054 (while (re-search-forward "^Date:[ \t]" nil t)
3056 (setq date-pos (match-beginning 0)))
3057 (unless (and (eq type 'lapsed)
3058 gnus-article-date-lapsed-new-header)
3059 (delete-region (match-beginning 0)
3060 (progn (message-next-header) (point)))))
3063 (goto-char date-pos)
3065 ;; Possibly, Date has been deleted.
3067 (when (and (eq type 'lapsed)
3068 gnus-article-date-lapsed-new-header
3069 (looking-at "Date:"))
3071 (goto-char (point-min)))
3072 (insert (article-make-date-line date type))
3073 (when (eq type 'lapsed)
3074 (put-text-property (point-at-bol) (point)
3075 'article-date-lapsed t))
3079 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3080 (add-text-properties (match-beginning 1) (1+ (match-end 1))
3081 (list 'original-date date 'face bface))
3082 (put-text-property (match-beginning 2) (match-end 2)
3085 (defun article-make-date-line (date type)
3086 "Return a DATE line of TYPE."
3087 (unless (memq type '(local ut original user iso8601 lapsed english))
3088 (error "Unknown conversion type: %s" type))
3090 (let ((time (date-to-time date)))
3092 ;; Convert to the local timezone.
3094 (concat "Date: " (message-make-date time)))
3095 ;; Convert to Universal Time.
3100 (let* ((e (parse-time-string date))
3101 (tm (apply 'encode-time e))
3103 (ls (- (cadr tm) (car (current-time-zone time)))))
3104 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3105 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3109 ;; Get the original date from the article.
3110 ((eq type 'original)
3111 (concat "Date: " (if (string-match "\n+$" date)
3112 (substring date 0 (match-beginning 0))
3114 ;; Let the user define the format.
3116 (let ((format (or (condition-case nil
3117 (with-current-buffer gnus-summary-buffer
3118 gnus-article-time-format)
3120 gnus-article-time-format)))
3121 (if (functionp format)
3122 (funcall format time)
3123 (concat "Date: " (format-time-string format time)))))
3126 (let ((tz (car (current-time-zone time))))
3129 (format-time-string "%Y%m%dT%H%M%S" time)
3130 (format "%s%02d%02d"
3131 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3132 (/ (% (abs tz) 3600) 60)))))
3133 ;; Do an X-Sent lapsed format.
3135 ;; If the date is seriously mangled, the timezone functions are
3136 ;; liable to bug out, so we ignore all errors.
3137 (let* ((now (current-time))
3138 (real-time (subtract-time now time))
3139 (real-sec (and real-time
3140 (+ (* (float (car real-time)) 65536)
3142 (sec (and real-time (abs real-sec)))
3152 ;; This is a bit convoluted, but basically we go
3153 ;; through the time units for years, weeks, etc,
3154 ;; and divide things to see whether that results
3155 ;; in positive answers.
3158 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3159 ;; The (remaining) seconds are too few to
3160 ;; be divided into this time unit.
3162 ;; It's big enough, so we output it.
3163 (setq sec (- sec (* num (cdr unit))))
3165 (concat (if prev ", " "") (int-to-string
3167 " " (symbol-name (car unit))
3168 (if (> num 1) "s" ""))
3170 article-time-units "")
3171 ;; If dates are odd, then it might appear like the
3172 ;; article was sent in the future.
3175 " in the future"))))))
3176 ;; Display the date in proper English
3178 (let ((dtime (decode-time time)))
3181 (number-to-string (nth 3 dtime))
3182 (let ((digit (% (nth 3 dtime) 10)))
3184 ((memq (nth 3 dtime) '(11 12 13)) "th")
3190 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3192 (number-to-string (nth 5 dtime))
3194 (format "%02d" (nth 2 dtime))
3196 (format "%02d" (nth 1 dtime)))))))
3198 (format "Date: %s (from T-gnus)" date))))
3200 (defun article-date-local (&optional highlight)
3201 "Convert the current article date to the local timezone."
3202 (interactive (list t))
3203 (article-date-ut 'local highlight))
3205 (defun article-date-english (&optional highlight)
3206 "Convert the current article date to something that is proper English."
3207 (interactive (list t))
3208 (article-date-ut 'english highlight))
3210 (defun article-date-original (&optional highlight)
3211 "Convert the current article date to what it was originally.
3212 This is only useful if you have used some other date conversion
3213 function and want to see what the date was before converting."
3214 (interactive (list t))
3215 (article-date-ut 'original highlight))
3217 (defun article-date-lapsed (&optional highlight)
3218 "Convert the current article date to time lapsed since it was sent."
3219 (interactive (list t))
3220 (article-date-ut 'lapsed highlight))
3222 (defun article-update-date-lapsed ()
3223 "Function to be run from a timer to update the lapsed time line."
3224 (let (deactivate-mark)
3229 (set-buffer (window-buffer w))
3230 (when (eq major-mode 'gnus-article-mode)
3231 (let ((mark (point-marker)))
3232 (goto-char (point-min))
3233 (when (re-search-forward "^X-Sent:" nil t)
3234 (article-date-lapsed t))
3235 (goto-char (marker-position mark))
3236 (move-marker mark nil))))
3239 (defun gnus-start-date-timer (&optional n)
3240 "Start a timer to update the X-Sent header in the article buffers.
3241 The numerical prefix says how frequently (in seconds) the function
3246 (gnus-stop-date-timer)
3247 (setq article-lapsed-timer
3248 (run-at-time 1 n 'article-update-date-lapsed)))
3250 (defun gnus-stop-date-timer ()
3251 "Stop the X-Sent timer."
3253 (when article-lapsed-timer
3254 (nnheader-cancel-timer article-lapsed-timer)
3255 (setq article-lapsed-timer nil)))
3257 (defun article-date-user (&optional highlight)
3258 "Convert the current article date to the user-defined format.
3259 This format is defined by the `gnus-article-time-format' variable."
3260 (interactive (list t))
3261 (article-date-ut 'user highlight))
3263 (defun article-date-iso8601 (&optional highlight)
3264 "Convert the current article date to ISO8601."
3265 (interactive (list t))
3266 (article-date-ut 'iso8601 highlight))
3268 ;; (defun article-show-all ()
3269 ;; "Show all hidden text in the article buffer."
3273 ;; (let ((inhibit-read-only t))
3274 ;; (gnus-article-unhide-text (point-min) (point-max))
3275 ;; (gnus-remove-text-with-property 'gnus-prev)
3276 ;; (gnus-remove-text-with-property 'gnus-next))))
3278 (defun article-show-all-headers ()
3279 "Show all hidden headers in the article buffer."
3284 (article-narrow-to-head)
3285 (let ((inhibit-read-only t))
3286 (gnus-article-unhide-text (point-min) (point-max))))))
3288 (defun article-remove-leading-whitespace ()
3289 "Remove excessive whitespace from all headers."
3293 (let ((inhibit-read-only t))
3294 (article-narrow-to-head)
3295 (goto-char (point-min))
3296 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3297 (delete-region (match-beginning 1) (match-end 1)))))))
3299 (defun article-emphasize (&optional arg)
3300 "Emphasize text according to `gnus-emphasis-alist'."
3301 (interactive (gnus-article-hidden-arg))
3302 (unless (gnus-article-check-hidden-text 'emphasis arg)
3306 (with-current-buffer gnus-summary-buffer
3307 gnus-article-emphasis-alist)
3309 gnus-emphasis-alist))
3310 (inhibit-read-only t)
3311 (props (append '(article-type emphasis)
3312 gnus-hidden-properties))
3313 regexp elem beg invisible visible face)
3316 (while (setq elem (pop alist))
3318 (setq regexp (car elem)
3319 invisible (nth 1 elem)
3320 visible (nth 2 elem)
3322 (while (re-search-forward regexp nil t)
3323 (when (and (match-beginning visible) (match-beginning invisible))
3324 (gnus-article-hide-text
3325 (match-beginning invisible) (match-end invisible) props)
3326 (gnus-article-unhide-text-type
3327 (match-beginning visible) (match-end visible) 'emphasis)
3328 (gnus-put-overlay-excluding-newlines
3329 (match-beginning visible) (match-end visible) 'face face)
3330 (gnus-add-wash-type 'emphasis)
3331 (goto-char (match-end invisible)))))))))
3333 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3334 "Setup newsgroup emphasis alist."
3335 (unless gnus-article-emphasis-alist
3336 (let ((name (and gnus-newsgroup-name
3337 (gnus-group-real-name gnus-newsgroup-name))))
3338 (make-local-variable 'gnus-article-emphasis-alist)
3339 (setq gnus-article-emphasis-alist
3341 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3342 (while (setq elem (pop alist))
3343 (when (and name (string-match (car elem) name))
3345 highlight (copy-sequence (cdr elem)))))
3347 (copy-sequence highlight-words)
3348 (if gnus-newsgroup-name
3349 (copy-sequence (gnus-group-find-parameter
3350 gnus-newsgroup-name 'highlight-words t)))
3351 gnus-emphasis-alist)))))
3354 (defvar gnus-summary-article-menu)
3355 (defvar gnus-summary-post-menu))
3357 ;;; Saving functions.
3359 (defun gnus-article-save (save-buffer file &optional num)
3360 "Save the currently selected article."
3361 (unless gnus-save-all-headers
3362 ;; Remove headers according to `gnus-saved-headers'.
3363 (let ((gnus-visible-headers
3364 (or gnus-saved-headers gnus-visible-headers))
3365 (gnus-article-buffer save-buffer))
3367 (set-buffer save-buffer)
3368 (article-hide-headers 1 t))))
3369 (save-window-excursion
3370 (if (not gnus-default-article-saver)
3371 (error "No default saver is defined")
3372 ;; !!! Magic! The saving functions all save
3373 ;; `gnus-save-article-buffer' (or so they think), but we
3374 ;; bind that variable to our save-buffer.
3375 (set-buffer gnus-article-buffer)
3376 (let* ((gnus-save-article-buffer save-buffer)
3379 ((not gnus-prompt-before-saving) 'default)
3380 ((eq gnus-prompt-before-saving 'always) nil)
3382 (gnus-number-of-articles-to-be-saved
3383 (when (eq gnus-prompt-before-saving t)
3385 (set-buffer gnus-article-current-summary)
3386 (funcall gnus-default-article-saver filename)))))
3388 (defun gnus-read-save-file-name (prompt &optional filename
3389 function group headers variable)
3391 (funcall function group headers (symbol-value variable)))
3396 ((eq filename 'default)
3402 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3405 (if (and gnus-number-of-articles-to-be-saved
3406 (> gnus-number-of-articles-to-be-saved 1))
3407 (format "these %d articles"
3408 gnus-number-of-articles-to-be-saved)
3411 ;; Let the split methods have their say.
3413 ;; No split name was found.
3416 (concat prompt " (default "
3417 (file-name-nondirectory default-name) ") ")
3418 (file-name-directory default-name)
3420 ;; A single group name is returned.
3421 ((stringp split-name)
3423 (funcall function split-name headers
3424 (symbol-value variable)))
3426 (concat prompt " (default "
3427 (file-name-nondirectory default-name) ") ")
3428 (file-name-directory default-name)
3430 ;; A single split name was found
3431 ((= 1 (length split-name))
3432 (let* ((name (expand-file-name
3434 gnus-article-save-directory))
3435 (dir (cond ((file-directory-p name)
3436 (file-name-as-directory name))
3437 ((file-exists-p name) name)
3438 (t gnus-article-save-directory))))
3440 (concat prompt " (default " name ") ")
3442 ;; A list of splits was found.
3444 (setq split-name (nreverse split-name))
3446 (let ((file-name-history
3447 (nconc split-name file-name-history)))
3451 (concat prompt " (`M-p' for defaults) ")
3452 gnus-article-save-directory
3454 gnus-article-save-directory)))
3455 (car (push result file-name-history)))))))
3456 ;; Create the directory.
3457 (gnus-make-directory (file-name-directory file))
3458 ;; If we have read a directory, we append the default file name.
3459 (when (file-directory-p file)
3460 (setq file (expand-file-name (file-name-nondirectory
3462 (file-name-as-directory file))))
3463 ;; Possibly translate some characters.
3464 (nnheader-translate-file-chars file))))))
3465 (gnus-make-directory (file-name-directory result))
3466 (set variable result)))
3468 (defun gnus-article-archive-name (group)
3469 "Return the first instance of an \"Archive-name\" in the current buffer."
3470 (let ((case-fold-search t))
3471 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3472 (nnheader-concat gnus-article-save-directory
3473 (match-string 1)))))
3475 (defun gnus-article-nndoc-name (group)
3476 "If GROUP is an nndoc group, return the name of the parent group."
3477 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3478 (gnus-group-get-parameter group 'save-article-group)))
3480 (defun gnus-summary-save-in-rmail (&optional filename)
3481 "Append this article to Rmail file.
3482 Optional argument FILENAME specifies file name.
3483 Directory to save to is default to `gnus-article-save-directory'."
3484 (setq filename (gnus-read-save-file-name
3485 "Save %s in rmail file:" filename
3486 gnus-rmail-save-name gnus-newsgroup-name
3487 gnus-current-headers 'gnus-newsgroup-last-rmail))
3488 (gnus-eval-in-buffer-window gnus-save-article-buffer
3492 (gnus-output-to-rmail filename))))
3495 (defun gnus-summary-save-in-mail (&optional filename)
3496 "Append this article to Unix mail file.
3497 Optional argument FILENAME specifies file name.
3498 Directory to save to is default to `gnus-article-save-directory'."
3499 (setq filename (gnus-read-save-file-name
3500 "Save %s in Unix mail file:" filename
3501 gnus-mail-save-name gnus-newsgroup-name
3502 gnus-current-headers 'gnus-newsgroup-last-mail))
3503 (gnus-eval-in-buffer-window gnus-save-article-buffer
3507 (if (and (file-readable-p filename)
3508 (file-regular-p filename)
3509 (mail-file-babyl-p filename))
3510 (rmail-output-to-rmail-file filename t)
3511 (gnus-output-to-mail filename)))))
3514 (defun gnus-summary-save-in-file (&optional filename overwrite)
3515 "Append this article to file.
3516 Optional argument FILENAME specifies file name.
3517 Directory to save to is default to `gnus-article-save-directory'."
3518 (setq filename (gnus-read-save-file-name
3519 "Save %s in file:" filename
3520 gnus-file-save-name gnus-newsgroup-name
3521 gnus-current-headers 'gnus-newsgroup-last-file))
3522 (gnus-eval-in-buffer-window gnus-save-article-buffer
3526 (when (and overwrite
3527 (file-exists-p filename))
3528 (delete-file filename))
3529 (gnus-output-to-file filename))))
3532 (defun gnus-summary-write-to-file (&optional filename)
3533 "Write this article to a file, overwriting it if the file exists.
3534 Optional argument FILENAME specifies file name.
3535 The directory to save in defaults to `gnus-article-save-directory'."
3536 (gnus-summary-save-in-file nil t))
3538 (defun gnus-summary-save-body-in-file (&optional filename)
3539 "Append this article body to a file.
3540 Optional argument FILENAME specifies file name.
3541 The directory to save in defaults to `gnus-article-save-directory'."
3542 (setq filename (gnus-read-save-file-name
3543 "Save %s body in file:" filename
3544 gnus-file-save-name gnus-newsgroup-name
3545 gnus-current-headers 'gnus-newsgroup-last-file))
3546 (gnus-eval-in-buffer-window gnus-save-article-buffer
3550 (when (article-goto-body)
3551 (narrow-to-region (point) (point-max)))
3552 (gnus-output-to-file filename))))
3555 (defun gnus-summary-save-in-pipe (&optional command)
3556 "Pipe this article to subprocess."
3558 (cond ((and (eq command 'default)
3559 gnus-last-shell-command)
3560 gnus-last-shell-command)
3565 "Shell command on %s: "
3566 (if (and gnus-number-of-articles-to-be-saved
3567 (> gnus-number-of-articles-to-be-saved 1))
3568 (format "these %d articles"
3569 gnus-number-of-articles-to-be-saved)
3571 gnus-last-shell-command))))
3572 (when (string-equal command "")
3573 (if gnus-last-shell-command
3574 (setq command gnus-last-shell-command)
3575 (error "A command is required")))
3576 (gnus-eval-in-buffer-window gnus-article-buffer
3579 (shell-command-on-region (point-min) (point-max) command nil)))
3580 (setq gnus-last-shell-command command))
3582 (defun gnus-summary-pipe-to-muttprint (&optional command)
3583 "Pipe this article to muttprint."
3584 (setq command (read-string
3585 "Print using command: " gnus-summary-muttprint-program
3586 nil gnus-summary-muttprint-program))
3587 (gnus-summary-save-in-pipe command))
3589 ;;; Article file names when saving.
3591 (defun gnus-capitalize-newsgroup (newsgroup)
3592 "Capitalize NEWSGROUP name."
3593 (when (not (zerop (length newsgroup)))
3594 (concat (char-to-string (upcase (aref newsgroup 0)))
3595 (substring newsgroup 1))))
3597 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3598 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3599 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3600 Otherwise, it is like ~/News/news/group/num."
3603 (concat (if (gnus-use-long-file-name 'not-save)
3604 (gnus-capitalize-newsgroup newsgroup)
3605 (gnus-newsgroup-directory-form newsgroup))
3606 "/" (int-to-string (mail-header-number headers)))
3607 gnus-article-save-directory)))
3609 (string-equal (file-name-directory default)
3610 (file-name-directory last-file))
3611 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3613 (or last-file default))))
3615 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3616 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3617 If variable `gnus-use-long-file-name' is non-nil, it is
3618 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3621 (concat (if (gnus-use-long-file-name 'not-save)
3623 (gnus-newsgroup-directory-form newsgroup))
3624 "/" (int-to-string (mail-header-number headers)))
3625 gnus-article-save-directory)))
3627 (string-equal (file-name-directory default)
3628 (file-name-directory last-file))
3629 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3631 (or last-file default))))
3633 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3634 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3635 If variable `gnus-use-long-file-name' is non-nil, it is
3636 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3639 (if (gnus-use-long-file-name 'not-save)
3642 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3644 gnus-article-save-directory)))
3646 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3647 "Generate file name from sender."
3648 (let ((from (mail-header-from headers)))
3650 (if (and from (string-match "\\([^ <]+\\)@" from))
3651 (match-string 1 from)
3653 gnus-article-save-directory)))
3655 (defun article-verify-x-pgp-sig ()
3658 (if (gnus-buffer-live-p gnus-original-article-buffer)
3659 (let ((sig (with-current-buffer gnus-original-article-buffer
3660 (gnus-fetch-field "X-PGP-Sig")))
3664 (mml2015-clear-verify-function))
3666 (insert-buffer-substring gnus-original-article-buffer)
3667 (setq items (split-string sig))
3668 (message-narrow-to-head)
3669 (let ((inhibit-point-motion-hooks t)
3670 (case-fold-search t))
3671 ;; Don't verify multiple headers.
3672 (setq headers (mapconcat (lambda (header)
3674 (mail-fetch-field header)
3676 (split-string (nth 1 items) ",") "")))
3677 (delete-region (point-min) (point-max))
3678 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3679 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3684 (if (looking-at "^-")
3687 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3688 (insert "Version: " (car items) "\n\n")
3689 (insert (mapconcat 'identity (cddr items) "\n"))
3690 (insert "\n-----END PGP SIGNATURE-----\n")
3691 (let ((mm-security-handle (list (format "multipart/signed"))))
3692 (mml2015-clean-buffer)
3693 (let ((coding-system-for-write (or gnus-newsgroup-charset
3695 (funcall (mml2015-clear-verify-function)))
3697 (or (mm-handle-multipart-ctl-parameter
3698 mm-security-handle 'gnus-details)
3699 (mm-handle-multipart-ctl-parameter
3700 mm-security-handle 'gnus-info)))))
3702 (let ((inhibit-read-only t) bface eface)
3704 (message-narrow-to-head)
3705 (goto-char (point-max))
3707 (setq bface (get-text-property (point-at-bol) 'face)
3708 eface (get-text-property (1- (point-at-eol)) 'face))
3709 (message-remove-header "X-Gnus-PGP-Verify")
3710 (if (re-search-forward "^X-PGP-Sig:" nil t)
3712 (goto-char (point-max)))
3713 (narrow-to-region (point) (point))
3714 (insert "X-Gnus-PGP-Verify: " info "\n")
3715 (goto-char (point-min))
3718 (if (not (looking-at "^[ \t]"))
3722 (goto-char (point-min))
3723 (when (looking-at "\\([^:]+\\): *")
3724 (put-text-property (match-beginning 1) (1+ (match-end 1))
3726 (put-text-property (match-end 0) (point-max)
3727 'face eface)))))))))
3729 (defun article-verify-cancel-lock ()
3730 "Verify Cancel-Lock header."
3732 (if (gnus-buffer-live-p gnus-original-article-buffer)
3733 (canlock-verify gnus-original-article-buffer)))
3735 (defun article-monafy ()
3736 "Display body part with mona font."
3738 (unless (if (featurep 'xemacs)
3739 (find-face 'gnus-mona-face)
3740 (facep 'gnus-mona-face))
3741 (require 'navi2ch-mona)
3742 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3744 (let ((inhibit-read-only t))
3747 (gnus-make-overlay (point) (point-max))
3748 'face 'gnus-mona-face))))
3755 (setq afunc (car func)
3758 gfunc (intern (format "gnus-%s" func))))
3760 (when (fboundp afunc)
3761 `(lambda (&optional interactive &rest args)
3762 ,(documentation afunc t)
3763 (interactive (list t))
3765 (set-buffer gnus-article-buffer)
3767 (call-interactively ',afunc)
3768 (apply ',afunc args))))))))
3769 '(article-hide-headers
3770 article-verify-x-pgp-sig
3771 article-verify-cancel-lock
3773 article-hide-boring-headers
3774 article-treat-overstrike
3775 article-treat-ansi-sequences
3776 article-fill-long-lines
3777 article-capitalize-sentences
3779 article-remove-leading-whitespace
3780 article-display-x-face
3781 article-display-face
3782 article-de-quoted-unreadable
3783 article-de-base64-unreadable
3786 article-unsplit-urls
3787 article-hide-list-identifiers
3788 article-strip-banner
3791 article-hide-signature
3792 article-strip-headers-in-body
3793 article-remove-trailing-blank-lines
3794 article-strip-leading-blank-lines
3795 article-strip-multiple-blank-lines
3796 article-strip-leading-space
3797 article-strip-trailing-space
3798 article-strip-blank-lines
3799 article-strip-all-blank-lines
3801 article-date-english
3802 article-date-iso8601
3803 article-date-original
3805 article-decode-mime-words
3806 article-decode-charset
3807 article-decode-encoded-words
3811 article-treat-dumbquotes
3812 article-normalize-headers
3813 (article-show-all-headers . gnus-article-show-all-headers)
3814 ;; (article-show-all . gnus-article-show-all)
3818 ;;; Gnus article mode
3821 (put 'gnus-article-mode 'mode-class 'special)
3823 (gnus-define-keys gnus-article-mode-map
3824 " " gnus-article-goto-next-page
3825 "\177" gnus-article-goto-prev-page
3826 [delete] gnus-article-goto-prev-page
3827 [backspace] gnus-article-goto-prev-page
3828 "\C-c^" gnus-article-refer-article
3829 "h" gnus-article-show-summary
3830 "s" gnus-article-show-summary
3831 "\C-c\C-m" gnus-article-mail
3832 "?" gnus-article-describe-briefly
3833 "e" gnus-summary-edit-article
3834 "<" beginning-of-buffer
3836 "\C-c\C-i" gnus-info-find-node
3838 "R" gnus-article-reply-with-original
3839 "F" gnus-article-followup-with-original
3840 "\C-hk" gnus-article-describe-key
3841 "\C-hc" gnus-article-describe-key-briefly
3843 "\C-d" gnus-article-read-summary-keys
3844 "\M-*" gnus-article-read-summary-keys
3845 "\M-#" gnus-article-read-summary-keys
3846 "\M-^" gnus-article-read-summary-keys
3847 "\M-g" gnus-article-read-summary-keys)
3849 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3853 (push (char-to-string key) keys)
3855 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3856 (setq key (car elem))
3857 (when (and (> (length key) 0)
3858 (not (eq 'menu-bar (aref key 0)))
3859 (symbolp (lookup-key gnus-summary-mode-map key)))
3862 (unless (lookup-key gnus-article-mode-map key)
3863 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3865 (defun gnus-article-make-menu-bar ()
3866 (unless (boundp 'gnus-article-commands-menu)
3867 (gnus-summary-make-menu-bar))
3868 (gnus-turn-off-edit-menu 'article)
3869 (unless (boundp 'gnus-article-article-menu)
3871 gnus-article-article-menu gnus-article-mode-map ""
3873 ["Scroll forwards" gnus-article-goto-next-page t]
3874 ["Scroll backwards" gnus-article-goto-prev-page t]
3875 ["Show summary" gnus-article-show-summary t]
3876 ["Fetch Message-ID at point" gnus-article-refer-article t]
3877 ["Mail to address at point" gnus-article-mail t]
3878 ["Send a bug report" gnus-bug t]))
3881 gnus-article-treatment-menu gnus-article-mode-map ""
3882 ;; Fixme: this should use :active (and maybe :visible).
3884 ["Hide headers" gnus-article-hide-headers t]
3885 ["Hide signature" gnus-article-hide-signature t]
3886 ["Hide citation" gnus-article-hide-citation t]
3887 ["Treat overstrike" gnus-article-treat-overstrike t]
3888 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3889 ["Remove carriage return" gnus-article-remove-cr t]
3890 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3891 ["Treat html" gnus-article-wash-html t]
3892 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3893 ["Decode HZ" gnus-article-decode-HZ t]))
3895 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3897 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3899 (gnus-run-hooks 'gnus-article-menu-hook)))
3901 (defun gnus-article-mode ()
3902 "Major mode for displaying an article.
3904 All normal editing commands are switched off.
3906 The following commands are available in addition to all summary mode
3908 \\<gnus-article-mode-map>
3909 \\[gnus-article-next-page]\t Scroll the article one page forwards
3910 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3911 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3912 \\[gnus-article-show-summary]\t Display the summary buffer
3913 \\[gnus-article-mail]\t Send a reply to the address near point
3914 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3915 \\[gnus-info-find-node]\t Go to the Gnus info node"
3917 (gnus-simplify-mode-line)
3918 (setq mode-name "Article")
3919 (setq major-mode 'gnus-article-mode)
3920 (make-local-variable 'minor-mode-alist)
3921 (unless (assq 'gnus-show-mime minor-mode-alist)
3922 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3923 (use-local-map gnus-article-mode-map)
3924 (when (gnus-visual-p 'article-menu 'menu)
3925 (gnus-article-make-menu-bar)
3926 (when gnus-summary-tool-bar-map
3927 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3928 (gnus-update-format-specifications nil 'article-mode)
3929 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3930 (set (make-local-variable 'gnus-page-broken) nil)
3931 (make-local-variable 'gnus-button-marker-list)
3932 (make-local-variable 'gnus-article-current-summary)
3933 (make-local-variable 'gnus-article-mime-handles)
3934 (make-local-variable 'gnus-article-decoded-p)
3935 (make-local-variable 'gnus-article-mime-handle-alist)
3936 (make-local-variable 'gnus-article-wash-types)
3937 (make-local-variable 'gnus-article-image-alist)
3938 (make-local-variable 'gnus-article-charset)
3939 (make-local-variable 'gnus-article-ignored-charsets)
3940 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3941 (set (make-local-variable 'show-nonbreak-escape) nil)
3942 (gnus-set-default-directory)
3943 (buffer-disable-undo)
3944 (setq buffer-read-only t
3945 show-trailing-whitespace nil)
3946 (set-syntax-table gnus-article-mode-syntax-table)
3947 (gnus-run-hooks 'gnus-article-mode-hook))
3949 (defun gnus-article-setup-buffer ()
3950 "Initialize the article buffer."
3951 (let* ((name (if gnus-single-article-buffer "*Article*"
3952 (concat "*Article " gnus-newsgroup-name "*")))
3954 (progn (string-match "\\*Article" name)
3955 (concat " *Original Article"
3956 (substring name (match-end 0))))))
3957 (setq gnus-article-buffer name)
3958 (setq gnus-original-article-buffer original)
3959 (setq gnus-article-mime-handle-alist nil)
3960 ;; This might be a variable local to the summary buffer.
3961 (unless gnus-single-article-buffer
3963 (set-buffer gnus-summary-buffer)
3964 (setq gnus-article-buffer name)
3965 (setq gnus-original-article-buffer original)
3966 (gnus-set-global-variables)))
3967 (gnus-article-setup-highlight-words)
3968 ;; Init original article buffer.
3970 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3971 (set-buffer-multibyte t)
3972 (setq major-mode 'gnus-original-article-mode)
3973 (make-local-variable 'gnus-original-article))
3974 (if (and (get-buffer name)
3975 (with-current-buffer name
3976 (if gnus-article-edit-mode
3977 (if (y-or-n-p "Article mode edit in progress; discard? ")
3979 (set-buffer-modified-p nil)
3980 (gnus-kill-buffer name)
3983 (error "Action aborted"))
3987 (set (make-local-variable 'gnus-article-edit-mode) nil)
3988 (buffer-disable-undo)
3989 (setq buffer-read-only t)
3990 ;; This list just keeps growing if we don't reset it.
3991 (setq gnus-button-marker-list nil)
3992 (unless (eq major-mode 'gnus-article-mode)
3993 (gnus-article-mode))
3996 (set-buffer (gnus-get-buffer-create name))
3998 (make-local-variable 'gnus-summary-buffer)
3999 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4000 (current-buffer)))))
4002 ;; Set article window start at LINE, where LINE is the number of lines
4003 ;; from the head of the article.
4004 (defun gnus-article-set-window-start (&optional line)
4006 (gnus-get-buffer-window gnus-article-buffer t)
4008 (set-buffer gnus-article-buffer)
4009 (goto-char (point-min))
4012 (gnus-message 6 "Moved to bookmark")
4013 (search-forward "\n\n" nil t)
4017 ;;; @@ article filters
4020 (defun gnus-article-display-mime-message ()
4021 "Article display method for MIME message."
4022 ;; called from `gnus-original-article-buffer'.
4023 (let (charset all-headers)
4024 (with-current-buffer gnus-summary-buffer
4025 (setq charset default-mime-charset
4026 all-headers gnus-have-all-headers))
4027 (make-local-variable 'default-mime-charset)
4028 (setq default-mime-charset charset)
4029 (with-current-buffer (get-buffer-create gnus-article-buffer)
4030 (make-local-variable 'default-mime-charset)
4031 (setq default-mime-charset charset))
4032 (mime-display-message mime-message-structure
4033 gnus-article-buffer nil gnus-article-mode-map)
4035 (gnus-article-hide-headers nil -1)))
4036 (run-hooks 'gnus-mime-article-prepare-hook))
4038 (defun gnus-article-display-traditional-message ()
4039 "Article display method for traditional message."
4040 (set-buffer gnus-article-buffer)
4041 (let ((inhibit-read-only t))
4043 (insert-buffer-substring gnus-original-article-buffer)))
4045 (defun gnus-article-make-full-mail-header (&optional number charset)
4046 "Create a new mail header structure in a raw article buffer."
4047 (unless (and number charset)
4048 (save-current-buffer
4049 (set-buffer gnus-summary-buffer)
4051 (setq number (or (cdr gnus-article-current) 0)))
4053 (setq charset (or default-mime-charset 'x-ctext)))))
4054 (goto-char (point-min))
4055 (let ((header-end (if (search-forward "\n\n" nil t)
4057 (goto-char (point-max))))
4058 (chars (- (point-max) (point)))
4059 (lines (count-lines (point) (point-max)))
4060 (default-mime-charset charset)
4062 (narrow-to-region (point-min) header-end)
4063 (setq xref (std11-fetch-field "xref"))
4065 (make-full-mail-header
4067 (std11-fetch-field "subject")
4068 (std11-fetch-field "from")
4069 (std11-fetch-field "date")
4070 (std11-fetch-field "message-id")
4071 (std11-fetch-field "references")
4074 (when xref (concat "Xref: " xref)))
4077 (defun gnus-article-prepare (article &optional all-headers header)
4078 "Prepare ARTICLE in article mode buffer.
4079 ARTICLE should either be an article number or a Message-ID.
4080 If ARTICLE is an id, HEADER should be the article headers.
4081 If ALL-HEADERS is non-nil, no headers are hidden."
4083 ;; Make sure we start in a summary buffer.
4084 (unless (eq major-mode 'gnus-summary-mode)
4085 (set-buffer gnus-summary-buffer))
4086 (setq gnus-summary-buffer (current-buffer))
4087 (let* ((gnus-article (if header (mail-header-number header) article))
4088 (summary-buffer (current-buffer))
4089 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4090 (group gnus-newsgroup-name)
4093 (gnus-article-setup-buffer)
4094 (set-buffer gnus-article-buffer)
4095 ;; Deactivate active regions.
4096 (when (and (boundp 'transient-mark-mode)
4097 transient-mark-mode)
4098 (setq mark-active nil))
4099 (if (not (setq result (let ((inhibit-read-only t))
4100 (gnus-request-article-this-buffer
4102 ;; There is no such article.
4104 (when (and (numberp article)
4105 (not (memq article gnus-newsgroup-sparse)))
4106 (setq gnus-article-current
4107 (cons gnus-newsgroup-name article))
4108 (set-buffer gnus-summary-buffer)
4109 (setq gnus-current-article article)
4110 (if (and (memq article gnus-newsgroup-undownloaded)
4111 (not (gnus-online (gnus-find-method-for-group
4112 gnus-newsgroup-name))))
4114 (gnus-summary-set-agent-mark article)
4115 (message "Message marked for downloading"))
4116 (gnus-summary-mark-article article gnus-canceled-mark)
4117 (unless (memq article gnus-newsgroup-sparse)
4118 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4119 (if (or (eq result 'pseudo)
4120 (eq result 'nneething))
4123 (set-buffer summary-buffer)
4124 (push article gnus-newsgroup-history)
4125 (setq gnus-last-article gnus-current-article
4126 gnus-current-article 0
4127 gnus-current-headers nil
4128 gnus-article-current nil)
4129 (if (eq result 'nneething)
4130 (gnus-configure-windows 'summary)
4131 (gnus-configure-windows 'article))
4132 (gnus-set-global-variables))
4133 (let ((gnus-article-mime-handle-alist-1
4134 gnus-article-mime-handle-alist))
4135 (gnus-set-mode-line 'article)))
4136 ;; The result from the `request' was an actual article -
4137 ;; or at least some text that is now displayed in the
4139 (when (and (numberp article)
4140 (not (eq article gnus-current-article)))
4141 ;; Seems like a new article has been selected.
4142 ;; `gnus-current-article' must be an article number.
4144 (set-buffer summary-buffer)
4145 (push article gnus-newsgroup-history)
4146 (setq gnus-last-article gnus-current-article
4147 gnus-current-article article
4148 gnus-current-headers
4149 (gnus-summary-article-header gnus-current-article)
4150 gnus-article-current
4151 (cons gnus-newsgroup-name gnus-current-article))
4152 (unless (vectorp gnus-current-headers)
4153 (setq gnus-current-headers nil))
4154 (gnus-summary-goto-subject gnus-current-article)
4155 (when (gnus-summary-show-thread)
4156 ;; If the summary buffer really was folded, the
4157 ;; previous goto may not actually have gone to
4158 ;; the right article, but the thread root instead.
4160 (gnus-summary-goto-subject gnus-current-article))
4161 (gnus-run-hooks 'gnus-mark-article-hook)
4162 (gnus-set-mode-line 'summary)
4163 (when (gnus-visual-p 'article-highlight 'highlight)
4164 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4165 ;; Set the global newsgroup variables here.
4166 (gnus-set-global-variables)
4167 (setq gnus-have-all-headers
4168 (or all-headers gnus-show-all-headers))))
4170 (gnus-configure-windows 'article))
4171 (when (or (numberp article)
4173 (gnus-article-prepare-display)
4175 (goto-char (point-min))
4176 (when gnus-break-pages
4177 (gnus-narrow-to-page)))
4178 (let ((gnus-article-mime-handle-alist-1
4179 gnus-article-mime-handle-alist))
4180 (gnus-set-mode-line 'article))
4184 (set-window-point (get-buffer-window (current-buffer)) (point))
4185 (gnus-configure-windows 'article)
4188 (defun gnus-article-prepare-mime-display (&optional number)
4189 (goto-char (point-min))
4190 (when (re-search-forward "^[^\t ]+:" nil t)
4191 (goto-char (match-beginning 0)))
4192 (let ((entity (if (eq 1 (point-min))
4193 (get-text-property 1 'mime-view-entity)
4194 (get-text-property (point) 'mime-view-entity)))
4195 last-entity child-entity next type)
4196 (setq child-entity (mime-entity-children entity))
4198 (setq last-entity (nth (1- (length child-entity))
4200 (setq last-entity entity))
4202 (narrow-to-region (point)
4203 (if (search-forward "\n\n" nil t)
4206 (gnus-treat-article 'head)
4207 (put-text-property (point-min) (point-max) 'article-treated-header t)
4208 (goto-char (point-max)))
4209 (while (and (not (eobp)) entity)
4210 (setq next (set-marker
4212 (next-single-property-change (point) 'mime-view-entity
4214 (let ((types (mime-entity-content-type entity)))
4215 (while (eq 'multipart (mime-content-type-primary-type types))
4216 (setq entity (car (mime-entity-children entity))
4217 types (mime-entity-content-type entity)))
4219 (setq type (format "%s/%s"
4220 (mime-content-type-primary-type types)
4221 (mime-content-type-subtype types)))))
4222 (if (string-equal type "message/rfc822")
4225 (let ((children (mime-entity-children entity))
4228 (setq last-children (nth (1- (length children)) children))
4231 (not (eq last-children
4232 (get-text-property next 'mime-view-entity)))
4234 (next-single-property-change next
4236 nil (point-max)))))))
4237 (setq next (next-single-property-change next 'mime-view-entity
4240 (narrow-to-region (point) next)
4241 (gnus-article-prepare-mime-display)
4242 (goto-char (point-max)))
4243 (setq entity (get-text-property (point) 'mime-view-entity)))
4245 (narrow-to-region (point) next)
4246 ;; Kludge. We have to count true number, but for now,
4247 ;; part number is here only to achieve `last'.
4248 (gnus-treat-article nil 1
4249 (if (eq entity last-entity)
4252 (goto-char (point-max)))
4253 (setq entity (get-text-property next 'mime-view-entity))))))
4256 (defun gnus-article-prepare-display ()
4257 "Make the current buffer look like a nice article."
4258 (let ((gnus-article-buffer (current-buffer))
4260 (inhibit-read-only t))
4261 (unless (eq major-mode 'gnus-article-mode)
4262 (gnus-article-mode))
4263 (setq buffer-read-only nil
4264 gnus-button-marker-list nil
4265 gnus-article-wash-types nil
4266 gnus-article-image-alist nil)
4269 (static-if (featurep 'xemacs)
4270 (map-extents (lambda (extent maparg) (delete-extent extent)))
4271 (let ((lists (overlay-lists)))
4272 (dolist (overlay (nconc (car lists) (cdr lists)))
4273 (delete-overlay overlay)))))
4274 (gnus-run-hooks 'gnus-tmp-internal-hook))
4275 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4278 (inhibit-read-only t))
4279 (set-buffer gnus-original-article-buffer)
4281 (setq mime-message-structure gnus-current-headers)
4282 (mime-buffer-entity-set-buffer-internal mime-message-structure
4283 gnus-original-article-buffer)
4284 (mime-entity-set-representation-type-internal mime-message-structure
4285 'mime-buffer-entity)
4286 (luna-send mime-message-structure 'initialize-instance
4287 mime-message-structure)
4289 (let (mime-display-header-hook mime-display-text/plain-hook)
4290 (funcall gnus-article-display-method-for-mime))
4291 (funcall gnus-article-display-method-for-traditional))
4292 ;; Call the treatment functions.
4296 (gnus-article-prepare-mime-display)
4297 (narrow-to-region (goto-char (point-min))
4298 (if (search-forward "\n\n" nil t)
4301 (gnus-treat-article 'head)
4302 (put-text-property (point-min) (point-max) 'article-treated-header t)
4303 (goto-char (point-max))
4305 (narrow-to-region (point) (point-max))
4306 (gnus-treat-article nil))
4307 (put-text-property (point-min) (point-max) 'read-only nil)))
4308 (gnus-run-hooks 'gnus-article-prepare-hook))
4310 (defun gnus-article-decode-article-as-default-mime-charset ()
4311 "Decode an article as `default-mime-charset'. It won't work if the
4312 value of the variable `gnus-show-mime' is non-nil."
4313 (unless (or gnus-show-mime
4314 (member gnus-newsgroup-name '("nndraft:delayed"
4316 (set (make-local-variable 'default-mime-charset)
4317 (with-current-buffer gnus-summary-buffer
4318 default-mime-charset))
4319 (decode-mime-charset-region (point-min) (point-max)
4320 default-mime-charset)))
4323 ;;; Gnus MIME viewing functions
4326 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4327 "Format of the MIME buttons.
4329 Valid specifiers include:
4331 %T MIME type, along with additional info
4332 %n The `name' parameter
4333 %d The description, if any
4334 %l The length of the encoded part
4335 %p The part identifier number
4336 %e Dots if the part isn't displayed
4338 General format specifiers can also be used. See Info node
4339 `(gnus)Formatting Variables'.")
4341 (defvar gnus-mime-button-line-format-alist
4342 '((?t gnus-tmp-type ?s)
4343 (?T gnus-tmp-type-long ?s)
4344 (?n gnus-tmp-name ?s)
4345 (?d gnus-tmp-description ?s)
4347 (?l gnus-tmp-length ?d)
4348 (?e gnus-tmp-dots ?s)))
4350 (defvar gnus-mime-button-commands
4351 '((gnus-article-press-button "\r" "Toggle Display")
4352 (gnus-mime-view-part "v" "View Interactively...")
4353 (gnus-mime-view-part-as-type "t" "View As Type...")
4354 (gnus-mime-view-part-as-charset "C" "View As charset...")
4355 (gnus-mime-save-part "o" "Save...")
4356 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4357 (gnus-mime-delete-part "d" "Delete part")
4358 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4359 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4360 (gnus-mime-view-part-internally "E" "View Internally")
4361 (gnus-mime-view-part-externally "e" "View Externally")
4362 (gnus-mime-print-part "p" "Print")
4363 (gnus-mime-pipe-part "|" "Pipe To Command...")
4364 (gnus-mime-action-on-part "." "Take action on the part...")))
4366 (defun gnus-article-mime-part-status ()
4367 (with-current-buffer gnus-article-buffer
4368 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4371 (setq children (mime-entity-children entity))
4372 (setq children (length children)))
4375 (format " (%d parts)" children))
4378 (defvar gnus-mime-button-map
4379 (let ((map (make-sparse-keymap)))
4380 (define-key map gnus-mouse-2 'gnus-article-push-button)
4381 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4382 (dolist (c gnus-mime-button-commands)
4383 (define-key map (cadr c) (car c)))
4387 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4389 ,@(mapcar (lambda (c)
4390 (vector (caddr c) (car c) :enable t))
4391 gnus-mime-button-commands)))
4393 (defun gnus-mime-button-menu (event prefix)
4394 "Construct a context-sensitive menu of MIME commands."
4395 (interactive "e\nP")
4396 (save-window-excursion
4397 (let ((pos (event-start event)))
4398 (select-window (posn-window pos))
4399 (goto-char (posn-point pos))
4400 (gnus-article-check-buffer)
4401 (popup-menu gnus-mime-button-menu nil prefix))))
4403 (defun gnus-mime-view-all-parts (&optional handles)
4404 "View all the MIME parts."
4406 (with-current-buffer gnus-article-buffer
4407 (let ((handles (or handles gnus-article-mime-handles))
4408 (mail-parse-charset gnus-newsgroup-charset)
4409 (mail-parse-ignored-charsets
4410 (with-current-buffer gnus-summary-buffer
4411 gnus-newsgroup-ignored-charsets)))
4413 (mm-remove-parts handles)
4414 (goto-char (point-min))
4415 (or (search-forward "\n\n") (goto-char (point-max)))
4416 (let ((inhibit-read-only t))
4417 (delete-region (point) (point-max))
4418 (mm-display-parts handles))))))
4421 (defsubst gnus-article-edit-part (handles)
4422 "Edit an article in order to delete a mime part.
4423 This function is exclusively used by `gnus-mime-save-part-and-strip'
4424 and `gnus-mime-delete-part', and not provided at run-time normally."
4425 (gnus-article-edit-article
4428 (let ((mail-parse-charset (or gnus-article-charset
4429 ',gnus-newsgroup-charset))
4430 (mail-parse-ignored-charsets
4431 (or gnus-article-ignored-charsets
4432 ',gnus-newsgroup-ignored-charsets))
4433 (mbl mml-buffer-list))
4434 (setq mml-buffer-list nil)
4435 (insert-buffer gnus-original-article-buffer)
4436 (mime-to-mml ',handles)
4437 (setq gnus-article-mime-handles nil)
4438 (let ((mbl1 mml-buffer-list))
4439 (setq mml-buffer-list mbl)
4440 (set (make-local-variable 'mml-buffer-list) mbl1))
4441 (gnus-make-local-hook 'kill-buffer-hook)
4442 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4443 `(lambda (no-highlight)
4444 (let ((mail-parse-charset (or gnus-article-charset
4445 ',gnus-newsgroup-charset))
4446 (message-options message-options)
4447 (message-options-set-recipient)
4448 (mail-parse-ignored-charsets
4449 (or gnus-article-ignored-charsets
4450 ',gnus-newsgroup-ignored-charsets)))
4452 (mml-destroy-buffers)
4453 (remove-hook 'kill-buffer-hook
4454 'mml-destroy-buffers t)
4455 (kill-local-variable 'mml-buffer-list))
4456 (gnus-summary-edit-article-done
4457 ,(or (mail-header-references gnus-current-headers) "")
4458 ,(gnus-group-read-only-p)
4459 ,gnus-summary-buffer no-highlight)))
4460 (gnus-article-edit-done)
4461 (gnus-summary-expand-window)
4462 (gnus-summary-show-article)))
4464 (defun gnus-mime-save-part-and-strip ()
4465 "Save the MIME part under point then replace it with an external body."
4467 (gnus-article-check-buffer)
4468 (when (gnus-group-read-only-p)
4469 (error "The current group does not support deleting of parts"))
4470 (when (mm-complicated-handles gnus-article-mime-handles)
4472 The current article has a complicated MIME structure, giving up..."))
4473 (when (gnus-yes-or-no-p "\
4474 Deleting parts may malfunction or destroy the article; continue? ")
4475 (let* ((data (get-text-property (point) 'gnus-data))
4477 (handles gnus-article-mime-handles))
4478 (setq file (and data (mm-save-part data)))
4480 (with-current-buffer (mm-handle-buffer data)
4482 (insert "Content-Type: " (mm-handle-media-type data))
4483 (mml-insert-parameter-string (cdr (mm-handle-type data))
4486 (insert "Content-ID: " (message-make-message-id) "\n")
4487 (insert "Content-Transfer-Encoding: binary\n")
4490 (cdr (mm-make-handle nil
4491 `("message/external-body"
4492 (access-type . "LOCAL-FILE")
4494 (set-buffer gnus-summary-buffer)
4495 (gnus-article-edit-part handles)))))
4497 (defun gnus-mime-delete-part ()
4498 "Delete the MIME part under point.
4499 Replace it with some information about the removed part."
4501 (gnus-article-check-buffer)
4502 (when (gnus-group-read-only-p)
4503 (error "The current group does not support deleting of parts"))
4504 (when (mm-complicated-handles gnus-article-mime-handles)
4506 The current article has a complicated MIME structure, giving up..."))
4507 (when (gnus-yes-or-no-p "\
4508 Deleting parts may malfunction or destroy the article; continue? ")
4509 (let* ((data (get-text-property (point) 'gnus-data))
4510 (handles gnus-article-mime-handles)
4514 (mail-decode-encoded-word-string (or (mm-handle-description data)
4517 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4519 (type (mm-handle-media-type data)))
4521 (error "No MIME part under point"))
4522 (with-current-buffer (mm-handle-buffer data)
4523 (let ((bsize (format "%s" (buffer-size))))
4528 "| The following attachment has been deleted:\n"
4530 "| Type: " type "\n"
4531 "| Filename: " filename "\n"
4532 "| Size (encoded): " bsize " Byte\n"
4533 "| Description: " description "\n"
4536 (cdr (mm-make-handle
4537 nil `("text/plain") nil nil
4539 (format "Deleted attachment (%s bytes)" bsize))))))
4540 (set-buffer gnus-summary-buffer)
4541 (gnus-article-edit-part handles))))
4543 (defun gnus-mime-save-part ()
4544 "Save the MIME part under point."
4546 (gnus-article-check-buffer)
4547 (let ((data (get-text-property (point) 'gnus-data)))
4549 (mm-save-part data))))
4551 (defun gnus-mime-pipe-part ()
4552 "Pipe the MIME part under point to a process."
4554 (gnus-article-check-buffer)
4555 (let ((data (get-text-property (point) 'gnus-data)))
4557 (mm-pipe-part data))))
4559 (defun gnus-mime-view-part ()
4560 "Interactively choose a viewing method for the MIME part under point."
4562 (gnus-article-check-buffer)
4563 (let ((data (get-text-property (point) 'gnus-data)))
4565 (setq gnus-article-mime-handles
4567 gnus-article-mime-handles (setq data (copy-sequence data))))
4568 (mm-interactively-view-part data))))
4570 (defun gnus-mime-view-part-as-type-internal ()
4571 (gnus-article-check-buffer)
4572 (let* ((name (mail-content-type-get
4573 (mm-handle-type (get-text-property (point) 'gnus-data))
4575 (def-type (and name (mm-default-file-encoding name))))
4576 (and def-type (cons def-type 0))))
4578 (defun gnus-mime-view-part-as-type (&optional mime-type)
4579 "Choose a MIME media type, and view the part as such."
4582 (setq mime-type (completing-read
4583 "View as MIME type: "
4584 (mapcar #'list (mailcap-mime-types))
4586 (gnus-mime-view-part-as-type-internal))))
4587 (gnus-article-check-buffer)
4588 (let ((handle (get-text-property (point) 'gnus-data)))
4591 (mm-make-handle (mm-handle-buffer handle)
4592 (cons mime-type (cdr (mm-handle-type handle)))
4593 (mm-handle-encoding handle)
4594 (mm-handle-undisplayer handle)
4595 (mm-handle-disposition handle)
4596 (mm-handle-description handle)
4598 (mm-handle-id handle)))
4599 (setq gnus-article-mime-handles
4600 (mm-merge-handles gnus-article-mime-handles handle))
4601 (gnus-mm-display-part handle))))
4603 (defun gnus-mime-copy-part (&optional handle arg)
4604 "Put the MIME part under point into a new buffer.
4605 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4607 (interactive (list nil current-prefix-arg))
4608 (gnus-article-check-buffer)
4610 (setq handle (get-text-property (point) 'gnus-data)))
4612 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4614 (mail-content-type-get (mm-handle-disposition handle)
4616 contents dont-decode charset coding-system)
4617 (mm-with-unibyte-buffer
4618 (mm-insert-part handle)
4619 (setq contents (or (condition-case nil
4620 (mm-decompress-buffer filename nil 'sig)
4622 (setq dont-decode t)
4625 (setq filename (cond (filename (file-name-nondirectory filename))
4626 (dont-decode "*raw data*")
4631 (unless (setq charset (mail-content-type-get
4632 (mm-handle-type handle) 'charset))
4633 (unless (setq coding-system (mm-with-unibyte-buffer
4635 (mm-find-buffer-file-coding-system)))
4636 (setq charset gnus-newsgroup-charset))))
4638 (setq charset (or (cdr (assq arg
4639 gnus-summary-show-article-charset-alist))
4640 (mm-read-coding-system "Charset: ")))))
4641 (switch-to-buffer (generate-new-buffer filename))
4642 (if (or coding-system
4644 (setq coding-system (mm-charset-to-coding-system charset))
4645 (not (eq charset 'ascii))))
4647 (mm-enable-multibyte)
4648 (insert (mm-decode-coding-string contents coding-system))
4649 (setq buffer-file-coding-system
4650 (if (boundp 'last-coding-system-used)
4651 (symbol-value 'last-coding-system-used)
4653 (mm-disable-multibyte)
4655 (setq buffer-file-coding-system mm-binary-coding-system))
4656 ;; We do it this way to make `normal-mode' set the appropriate mode.
4659 (setq buffer-file-name (expand-file-name filename))
4661 (setq buffer-file-name nil))
4662 (goto-char (point-min)))))
4664 (defun gnus-mime-print-part (&optional handle filename)
4665 "Print the MIME part under point."
4666 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4667 (gnus-article-check-buffer)
4668 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4669 (contents (and handle (mm-get-part handle)))
4670 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4671 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4676 (mm-save-part-to-file handle file)
4677 (call-process shell-file-name nil
4678 (generate-new-buffer " *mm*")
4680 shell-command-switch
4682 printer file (mm-handle-type handle))))
4686 (gnus-print-buffer))
4687 (ps-despool filename)))))
4689 (defun gnus-mime-inline-part (&optional handle arg)
4690 "Insert the MIME part under point into the current buffer.
4691 Compressed files like .gz and .bz2 are decompressed."
4692 (interactive (list nil current-prefix-arg))
4693 (gnus-article-check-buffer)
4695 (setq handle (get-text-property (point) 'gnus-data)))
4698 (inhibit-read-only t)
4699 contents charset coding-system)
4700 (if (and (not arg) (mm-handle-undisplayer handle))
4701 (mm-remove-part handle)
4702 (mm-with-unibyte-buffer
4703 (mm-insert-part handle)
4705 (or (mm-decompress-buffer
4706 (or (mail-content-type-get (mm-handle-disposition handle)
4708 (mail-content-type-get (mm-handle-disposition handle)
4714 (unless (setq charset (mail-content-type-get
4715 (mm-handle-type handle) 'charset))
4716 (unless (setq coding-system
4717 (mm-with-unibyte-buffer
4719 (mm-find-buffer-file-coding-system)))
4720 (setq charset gnus-newsgroup-charset))))
4722 (if (mm-handle-undisplayer handle)
4723 (mm-remove-part handle))
4726 gnus-summary-show-article-charset-alist))
4727 (mm-read-coding-system "Charset: "))))
4729 (if (mm-handle-undisplayer handle)
4730 (mm-remove-part handle))))
4734 (if (or coding-system
4737 (mm-charset-to-coding-system charset))
4738 (not (eq charset 'ascii))))
4739 (mm-decode-coding-string contents coding-system)
4740 (mm-string-to-multibyte contents)))
4743 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4744 "Insert the MIME part under point into the current buffer using the
4746 (interactive (list nil current-prefix-arg))
4747 (gnus-article-check-buffer)
4748 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4751 (inhibit-read-only t))
4753 (if (mm-handle-undisplayer handle)
4754 (mm-remove-part handle))
4755 (let ((gnus-newsgroup-charset
4757 gnus-summary-show-article-charset-alist))
4758 (mm-read-coding-system "Charset: ")))
4759 (gnus-newsgroup-ignored-charsets 'gnus-all))
4760 (gnus-article-press-button)))))
4762 (defun gnus-mime-view-part-externally (&optional handle)
4763 "View the MIME part under point with an external viewer."
4765 (gnus-article-check-buffer)
4766 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4767 (mm-user-display-methods nil)
4768 (mm-inlined-types nil)
4769 (mail-parse-charset gnus-newsgroup-charset)
4770 (mail-parse-ignored-charsets
4771 (with-current-buffer gnus-summary-buffer
4772 gnus-newsgroup-ignored-charsets)))
4774 (if (mm-handle-undisplayer handle)
4775 (mm-remove-part handle)
4776 (mm-display-part handle)))))
4778 (defun gnus-mime-view-part-internally (&optional handle)
4779 "View the MIME part under point with an internal viewer.
4780 If no internal viewer is available, use an external viewer."
4782 (gnus-article-check-buffer)
4783 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4784 (mm-inlined-types '(".*"))
4785 (mm-inline-large-images t)
4786 (mail-parse-charset gnus-newsgroup-charset)
4787 (mail-parse-ignored-charsets
4788 (with-current-buffer gnus-summary-buffer
4789 gnus-newsgroup-ignored-charsets))
4790 (inhibit-read-only t))
4792 (if (mm-handle-undisplayer handle)
4793 (mm-remove-part handle)
4794 (mm-display-part handle)))))
4796 (defun gnus-mime-action-on-part (&optional action)
4797 "Do something with the MIME attachment at \(point\)."
4799 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4800 (gnus-article-check-buffer)
4801 (let ((action-pair (assoc action gnus-mime-action-alist)))
4803 (funcall (cdr action-pair)))))
4805 (defun gnus-article-part-wrapper (n function)
4806 (with-current-buffer gnus-article-buffer
4807 (when (> n (length gnus-article-mime-handle-alist))
4808 (error "No such part"))
4809 (gnus-article-goto-part n)
4810 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4811 (funcall function handle))))
4813 (defun gnus-article-pipe-part (n)
4814 "Pipe MIME part N, which is the numerical prefix."
4816 (gnus-article-part-wrapper n 'mm-pipe-part))
4818 (defun gnus-article-save-part (n)
4819 "Save MIME part N, which is the numerical prefix."
4821 (gnus-article-part-wrapper n 'mm-save-part))
4823 (defun gnus-article-interactively-view-part (n)
4824 "View MIME part N interactively, which is the numerical prefix."
4826 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4828 (defun gnus-article-copy-part (n)
4829 "Copy MIME part N, which is the numerical prefix."
4831 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4833 (defun gnus-article-view-part-as-charset (n)
4834 "View MIME part N using a specified charset.
4835 N is the numerical prefix."
4837 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4839 (defun gnus-article-view-part-externally (n)
4840 "View MIME part N externally, which is the numerical prefix."
4842 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4844 (defun gnus-article-inline-part (n)
4845 "Inline MIME part N, which is the numerical prefix."
4847 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4849 (defun gnus-article-mime-match-handle-first (condition)
4852 (dolist (ihandle gnus-article-mime-handle-alist)
4854 ((functionp condition)
4855 (funcall condition (cdr ihandle)))
4856 ((eq condition 'undisplayed)
4857 (not (or (mm-handle-undisplayer (cdr ihandle))
4858 (equal (mm-handle-media-type (cdr ihandle))
4859 "multipart/alternative"))))
4860 ((eq condition 'undisplayed-alternative)
4861 (not (mm-handle-undisplayer (cdr ihandle))))
4863 (gnus-article-goto-part (car ihandle))
4864 (or (not n) (< (car ihandle) n)))
4865 (setq n (car ihandle))))
4869 (defun gnus-article-view-part (&optional n)
4870 "View MIME part N, which is the numerical prefix."
4872 (with-current-buffer gnus-article-buffer
4873 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4874 gnus-article-mime-match-handle-function)))
4875 (when (> n (length gnus-article-mime-handle-alist))
4876 (error "No such part"))
4877 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4878 (when (gnus-article-goto-part n)
4879 (if (equal (car handle) "multipart/alternative")
4880 (gnus-article-press-button)
4881 (when (eq (gnus-mm-display-part handle) 'internal)
4882 (gnus-set-window-start)))))))
4884 (defsubst gnus-article-mime-total-parts ()
4885 (if (bufferp (car gnus-article-mime-handles))
4887 (1- (length gnus-article-mime-handles))))
4889 (defun gnus-mm-display-part (handle)
4890 "Display HANDLE and fix MIME button."
4891 (let ((id (get-text-property (point) 'gnus-part))
4893 (inhibit-read-only t))
4896 (let ((window (selected-window))
4897 (mail-parse-charset gnus-newsgroup-charset)
4898 (mail-parse-ignored-charsets
4899 (if (gnus-buffer-live-p gnus-summary-buffer)
4900 (with-current-buffer gnus-summary-buffer
4901 gnus-newsgroup-ignored-charsets)
4905 (let ((win (gnus-get-buffer-window (current-buffer) t))
4908 (select-window win))
4911 (if (mm-handle-displayed-p handle)
4912 ;; This will remove the part.
4913 (mm-display-part handle)
4915 (narrow-to-region (point)
4916 (if (eobp) (point) (1+ (point))))
4917 (mm-display-part handle)
4918 ;; We narrow to the part itself and
4919 ;; then call the treatment functions.
4920 (goto-char (point-min))
4922 (narrow-to-region (point) (point-max))
4925 (gnus-article-mime-total-parts)
4926 (mm-handle-media-type handle)))))
4927 (if (window-live-p window)
4928 (select-window window)))))
4931 (gnus-insert-mime-button
4932 handle id (list (mm-handle-displayed-p handle)))
4933 (goto-char point))))
4935 (defun gnus-article-goto-part (n)
4936 "Go to MIME part N."
4937 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4939 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4940 (let ((gnus-tmp-name
4941 (or (mail-content-type-get (mm-handle-type handle) 'name)
4942 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4943 (mail-content-type-get (mm-handle-type handle) 'url)
4945 (gnus-tmp-type (mm-handle-media-type handle))
4946 (gnus-tmp-description
4947 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4950 (if (if displayed (car displayed)
4951 (mm-handle-displayed-p handle))
4953 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4955 gnus-tmp-type-long b e)
4956 (when (string-match ".*/" gnus-tmp-name)
4957 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4958 (setq gnus-tmp-type-long (concat gnus-tmp-type
4959 (and (not (equal gnus-tmp-name ""))
4960 (concat "; " gnus-tmp-name))))
4961 (unless (equal gnus-tmp-description "")
4962 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4967 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4968 `(keymap ,gnus-mime-button-map
4969 gnus-callback gnus-mm-display-part
4970 gnus-part ,gnus-tmp-id
4971 article-type annotation
4974 ;; Exclude a newline.
4977 (widget-convert-button
4980 :action 'gnus-widget-press-button
4981 :button-keymap gnus-mime-button-map
4983 (lambda (widget/window &optional overlay pos)
4984 ;; Needed to properly clear the message due to a bug in
4985 ;; wid-edit (XEmacs only).
4986 (if (boundp 'help-echo-owns-message)
4987 (setq help-echo-owns-message t))
4989 "%S: %s the MIME part; %S: more options"
4990 (aref gnus-mouse-2 0)
4991 ;; XEmacs will get a single widget arg; Emacs 21 will get
4992 ;; window, overlay, position.
4993 (if (mm-handle-displayed-p
4995 (with-current-buffer (gnus-overlay-buffer overlay)
4996 (widget-get (widget-at (gnus-overlay-start overlay))
4998 (widget-get widget/window :mime-handle)))
5000 (aref gnus-down-mouse-3 0))))))
5002 (defun gnus-widget-press-button (elems el)
5003 (goto-char (widget-get elems :from))
5004 (gnus-article-press-button))
5006 (defvar gnus-displaying-mime nil)
5008 (defun gnus-display-mime (&optional ihandles)
5009 "Display the MIME parts."
5011 (save-selected-window
5012 (let ((window (get-buffer-window gnus-article-buffer))
5015 (select-window window)
5016 ;; We have to do this since selecting the window
5017 ;; may change the point. So we set the window point.
5018 (set-window-point window point)))
5019 (let ((handles ihandles)
5020 (inhibit-read-only t)
5021 handle name type b e display)
5023 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5024 (when gnus-article-emulate-mime
5025 (mm-uu-dissect-text-parts handles)))
5026 (gnus-article-emulate-mime
5027 (setq handles (mm-uu-dissect))))
5028 (when (and (not ihandles)
5029 (not gnus-displaying-mime))
5030 ;; Top-level call; we clean up.
5031 (when gnus-article-mime-handles
5032 (mm-destroy-parts gnus-article-mime-handles)
5033 (setq gnus-article-mime-handle-alist nil));; A trick.
5034 (setq gnus-article-mime-handles handles)
5035 ;; We allow users to glean info from the handles.
5036 (when gnus-article-mime-part-function
5037 (gnus-mime-part-function handles)))
5039 (or (not (stringp (car handles)))
5042 (when (and (not ihandles)
5043 (not gnus-displaying-mime))
5044 ;; Clean up for mime parts.
5046 (delete-region (point) (point-max)))
5047 (let ((gnus-displaying-mime t))
5048 (gnus-mime-display-part handles)))
5051 (narrow-to-region (point) (point-max))
5052 (gnus-treat-article nil 1 1)
5055 ;; Highlight the headers.
5059 (narrow-to-region (point-min) (point))
5060 (gnus-treat-article 'head))))))))
5062 (defcustom gnus-mime-display-multipart-as-mixed nil
5063 "Display \"multipart\" parts as \"multipart/mixed\".
5065 If t, it overrides nil values of
5066 `gnus-mime-display-multipart-alternative-as-mixed' and
5067 `gnus-mime-display-multipart-related-as-mixed'."
5068 :group 'gnus-article-mime
5071 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5072 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5074 :group 'gnus-article-mime
5077 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5078 "Display \"multipart/related\" parts as \"multipart/mixed\".
5080 If displaying \"text/html\" is discouraged \(see
5081 `mm-discouraged-alternatives'\) images or other material inside a
5082 \"multipart/related\" part might be overlooked when this variable is nil."
5084 :group 'gnus-article-mime
5087 (defun gnus-mime-display-part (handle)
5090 ((not (stringp (car handle)))
5091 (gnus-mime-display-single handle))
5092 ;; User-defined multipart
5093 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5094 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5096 ;; multipart/alternative
5097 ((and (equal (car handle) "multipart/alternative")
5098 (not (or gnus-mime-display-multipart-as-mixed
5099 gnus-mime-display-multipart-alternative-as-mixed)))
5100 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5101 (push (cons id handle) gnus-article-mime-handle-alist)
5102 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5103 ;; multipart/related
5104 ((and (equal (car handle) "multipart/related")
5105 (not (or gnus-mime-display-multipart-as-mixed
5106 gnus-mime-display-multipart-related-as-mixed)))
5107 ;;;!!!We should find the start part, but we just default
5108 ;;;!!!to the first part.
5109 ;;(gnus-mime-display-part (cadr handle))
5110 ;;;!!! Most multipart/related is an HTML message plus images.
5111 ;;;!!! Unfortunately we are unable to let W3 display those
5112 ;;;!!! included images, so we just display it as a mixed multipart.
5113 ;;(gnus-mime-display-mixed (cdr handle))
5114 ;;;!!! No, w3 can display everything just fine.
5115 (gnus-mime-display-part (cadr handle)))
5116 ((equal (car handle) "multipart/signed")
5117 (gnus-add-wash-type 'signed)
5118 (gnus-mime-display-security handle))
5119 ((equal (car handle) "multipart/encrypted")
5120 (gnus-add-wash-type 'encrypted)
5121 (gnus-mime-display-security handle))
5122 ;; Other multiparts are handled like multipart/mixed.
5124 (gnus-mime-display-mixed (cdr handle)))))
5126 (defun gnus-mime-part-function (handles)
5127 (if (stringp (car handles))
5128 (mapcar 'gnus-mime-part-function (cdr handles))
5129 (funcall gnus-article-mime-part-function handles)))
5131 (defun gnus-mime-display-mixed (handles)
5132 (mapcar 'gnus-mime-display-part handles))
5134 (defun gnus-mime-display-single (handle)
5135 (let ((type (mm-handle-media-type handle))
5136 (ignored gnus-ignored-mime-types)
5143 (when (string-match (pop ignored) type)
5144 (throw 'ignored nil)))
5145 (if (and (setq not-attachment
5146 (and (not (mm-inline-override-p handle))
5147 (or (not (mm-handle-disposition handle))
5148 (equal (car (mm-handle-disposition handle))
5150 (mm-attachment-override-p handle))))
5151 (mm-automatic-display-p handle)
5153 (mm-inlinable-p handle)
5154 (mm-inlined-p handle))
5155 (mm-automatic-external-display-p type)))
5157 (when (equal (mm-handle-media-supertype handle) "text")
5159 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5161 (push (cons id handle) gnus-article-mime-handle-alist)
5162 (when (or (not display)
5163 (not (gnus-unbuttonized-mime-type-p type)))
5164 (gnus-insert-mime-button
5165 handle id (list (or display (and not-attachment text))))
5166 (gnus-article-insert-newline)
5167 ;; Remember modify the number of forward lines.
5175 (let ((mail-parse-charset gnus-newsgroup-charset)
5176 (mail-parse-ignored-charsets
5177 (save-excursion (condition-case ()
5178 (set-buffer gnus-summary-buffer)
5180 gnus-newsgroup-ignored-charsets)))
5181 (mm-display-part handle t))
5182 (goto-char (point-max)))
5183 ((and text not-attachment)
5187 (gnus-article-insert-newline)
5188 (mm-display-inline handle)
5189 (goto-char (point-max))))
5193 (narrow-to-region beg (point))
5196 (gnus-article-mime-total-parts)
5197 (mm-handle-media-type handle)))))))))
5199 (defun gnus-unbuttonized-mime-type-p (type)
5200 "Say whether TYPE is to be unbuttonized."
5201 (unless gnus-inhibit-mime-unbuttonizing
5203 (let ((types gnus-unbuttonized-mime-types))
5205 (when (string-match (pop types) type)
5206 (throw 'found t)))))
5208 (let ((types gnus-buttonized-mime-types))
5210 (when (string-match (pop types) type)
5211 (throw 'found t)))))))))
5213 (defun gnus-article-insert-newline ()
5214 "Insert a newline, but mark it as undeletable."
5215 (gnus-put-text-property
5216 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5218 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5219 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5222 handle (inhibit-read-only t) from props begend not-pref)
5223 (save-window-excursion
5226 (narrow-to-region (car ibegend)
5229 (goto-char (car ibegend))
5232 (delete-region (point-min) (point-max))
5233 (mm-remove-parts handles))
5234 (setq begend (list (point-marker)))
5236 (unless (setq not-pref (cadr (member preferred ihandles)))
5237 (setq not-pref (car ihandles)))
5240 (not (gnus-unbuttonized-mime-type-p
5241 "multipart/alternative")))
5242 (gnus-add-text-properties
5245 (insert (format "%d. " id))
5249 (unless ,(not ibegend)
5250 (setq gnus-article-mime-handle-alist
5251 ',gnus-article-mime-handle-alist))
5252 (gnus-mime-display-alternative
5253 ',ihandles ',not-pref ',begend ,id))
5254 keymap ,gnus-mime-button-map
5255 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5256 face ,gnus-article-button-face
5259 (widget-convert-button 'link from (point)
5260 :action 'gnus-widget-press-button
5261 :button-keymap gnus-widget-button-keymap)
5263 (while (setq handle (pop handles))
5264 (gnus-add-text-properties
5267 (insert (format "(%c) %-18s"
5268 (if (equal handle preferred) ?* ? )
5269 (mm-handle-media-type handle)))
5273 (unless ,(not ibegend)
5274 (setq gnus-article-mime-handle-alist
5275 ',gnus-article-mime-handle-alist))
5276 (gnus-mime-display-alternative
5277 ',ihandles ',handle ',begend ,id))
5278 keymap ,gnus-mime-button-map
5279 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5280 face ,gnus-article-button-face
5283 (widget-convert-button 'link from (point)
5284 :action 'gnus-widget-press-button
5285 :button-keymap gnus-widget-button-keymap)
5289 (if (stringp (car preferred))
5290 (gnus-display-mime preferred)
5291 (let ((mail-parse-charset gnus-newsgroup-charset)
5292 (mail-parse-ignored-charsets
5293 (with-current-buffer gnus-summary-buffer
5294 gnus-newsgroup-ignored-charsets)))
5295 (mm-display-part preferred)
5299 (narrow-to-region (car begend) (point-max))
5301 nil (length gnus-article-mime-handle-alist)
5302 (gnus-article-mime-total-parts)
5303 (mm-handle-media-type handle))))))
5304 (goto-char (point-max))
5305 (setcdr begend (point-marker)))))
5307 (goto-char point))))
5309 (defconst gnus-article-wash-status-strings
5310 (let ((alist '((cite "c" "Possible hidden citation text"
5311 " " "All citation text visible")
5312 (headers "h" "Hidden headers"
5313 " " "All headers visible.")
5314 (pgp "p" "Encrypted or signed message status hidden"
5315 " " "No hidden encryption nor digital signature status")
5316 (signature "s" "Signature has been hidden"
5317 " " "Signature is visible")
5318 (overstrike "o" "Overstrike (^H) characters applied"
5319 " " "No overstrike characters applied")
5320 (gnus-show-mime "m" "Mime processing is activated"
5321 " " "Mime processing is not activated")
5322 (emphasis "e" "/*_Emphasis_*/ characters applied"
5323 " " "No /*_emphasis_*/ characters applied")))
5325 (dolist (entry alist result)
5326 (let ((key (nth 0 entry))
5327 (on (copy-sequence (nth 1 entry)))
5328 (on-help (nth 2 entry))
5329 (off (copy-sequence (nth 3 entry)))
5330 (off-help (nth 4 entry)))
5331 (put-text-property 0 1 'help-echo on-help on)
5332 (put-text-property 0 1 'help-echo off-help off)
5333 (push (list key on off) result))))
5334 "Alist of strings describing wash status in the mode line.
5335 Each entry has the form (KEY ON OF), where the KEY is a symbol
5336 representing the particular washing function, ON is the string to use
5337 in the article mode line when the washing function is active, and OFF
5338 is the string to use when it is inactive.")
5340 (defun gnus-article-wash-status-entry (key value)
5341 (let ((entry (assoc key gnus-article-wash-status-strings)))
5342 (if value (nth 1 entry) (nth 2 entry))))
5344 (defun gnus-article-wash-status ()
5345 "Return a string which display status of article washing."
5346 (with-current-buffer gnus-article-buffer
5347 (let ((cite (memq 'cite gnus-article-wash-types))
5348 (headers (memq 'headers gnus-article-wash-types))
5349 (boring (memq 'boring-headers gnus-article-wash-types))
5350 (pgp (memq 'pgp gnus-article-wash-types))
5351 (pem (memq 'pem gnus-article-wash-types))
5352 (signed (memq 'signed gnus-article-wash-types))
5353 (encrypted (memq 'encrypted gnus-article-wash-types))
5354 (signature (memq 'signature gnus-article-wash-types))
5355 (overstrike (memq 'overstrike gnus-article-wash-types))
5356 (emphasis (memq 'emphasis gnus-article-wash-types)))
5358 (gnus-article-wash-status-entry 'cite cite)
5359 (gnus-article-wash-status-entry 'headers (or headers boring))
5360 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5361 (gnus-article-wash-status-entry 'signature signature)
5362 (gnus-article-wash-status-entry 'overstrike overstrike)
5363 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5364 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5366 (defun gnus-add-wash-type (type)
5367 "Add a washing of TYPE to the current status."
5368 (add-to-list 'gnus-article-wash-types type))
5370 (defun gnus-delete-wash-type (type)
5371 "Add a washing of TYPE to the current status."
5372 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5374 (defun gnus-add-image (category image)
5375 "Add IMAGE of CATEGORY to the list of displayed images."
5376 (let ((entry (assq category gnus-article-image-alist)))
5378 (setq entry (list category))
5379 (push entry gnus-article-image-alist))
5380 (nconc entry (list image))))
5382 (defun gnus-delete-images (category)
5383 "Delete all images in CATEGORY."
5384 (let ((entry (assq category gnus-article-image-alist)))
5385 (dolist (image (cdr entry))
5386 (gnus-remove-image image category))
5387 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5388 (gnus-delete-wash-type category)))
5390 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5392 (defun gnus-article-maybe-hide-headers ()
5393 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5394 Provided for backwards compatibility."
5395 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5396 (not (with-current-buffer gnus-summary-buffer
5397 gnus-have-all-headers)))
5398 (not gnus-inhibit-hiding))
5399 (gnus-article-hide-headers)))
5403 (defun gnus-output-to-file (file-name)
5404 "Append the current article to a file named FILE-NAME."
5405 (let ((artbuf (current-buffer)))
5407 (insert-buffer-substring artbuf)
5408 ;; Append newline at end of the buffer as separator, and then
5410 (goto-char (point-max))
5412 (let ((file-name-coding-system nnmail-pathname-coding-system))
5413 (write-region-as-binary (point-min) (point-max) file-name 'append))
5416 (defun gnus-narrow-to-page (&optional arg)
5417 "Narrow the article buffer to a page.
5418 If given a numerical ARG, move forward ARG pages."
5420 (setq arg (if arg (prefix-numeric-value arg) 0))
5422 (set-buffer gnus-article-buffer)
5423 (goto-char (point-min))
5425 ;; Remove any old next/prev buttons.
5426 (when (gnus-visual-p 'page-marker)
5427 (let ((inhibit-read-only t))
5428 (gnus-remove-text-with-property 'gnus-prev)
5429 (gnus-remove-text-with-property 'gnus-next)))
5432 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5434 (re-search-forward page-delimiter nil 'move arg)))
5435 (goto-char (match-end 0))
5437 (goto-char (point-min))
5438 (setq gnus-page-broken
5439 (and (re-search-forward page-delimiter nil t) t))))
5440 (when gnus-page-broken
5443 (if (re-search-forward page-delimiter nil 'move)
5446 (when (and (gnus-visual-p 'page-marker)
5447 (> (point-min) (save-restriction (widen) (point-min))))
5449 (goto-char (point-min))
5450 (gnus-insert-prev-page-button)))
5451 (when (and (gnus-visual-p 'page-marker)
5452 (< (point-max) (save-restriction (widen) (point-max))))
5454 (goto-char (point-max))
5455 (gnus-insert-next-page-button))))))
5457 ;; Article mode commands
5459 (defun gnus-article-goto-next-page ()
5460 "Show the next page of the article."
5462 (when (gnus-article-next-page)
5463 (goto-char (point-min))
5464 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5467 (defun gnus-article-goto-prev-page ()
5468 "Show the previous page of the article."
5471 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5472 (gnus-article-prev-page nil)))
5474 ;; This is cleaner but currently breaks `gnus-pick-mode':
5476 ;; (defun gnus-article-goto-next-page ()
5477 ;; "Show the next page of the article."
5479 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5480 ;; (gnus-summary-next-page)))
5482 ;; (defun gnus-article-goto-prev-page ()
5483 ;; "Show the next page of the article."
5485 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5486 ;; (gnus-summary-prev-page)))
5488 (defun gnus-article-next-page (&optional lines)
5489 "Show the next page of the current article.
5490 If end of article, return non-nil. Otherwise return nil.
5491 Argument LINES specifies lines to be scrolled up."
5493 (move-to-window-line -1)
5496 (and (pos-visible-in-window-p) ;Not continuation line.
5497 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5498 ;; Nothing in this page.
5499 (if (or (not gnus-page-broken)
5504 (eobp)))) ;Real end-of-buffer?
5506 (when gnus-article-over-scroll
5507 (gnus-article-next-page-1 lines))
5509 (gnus-narrow-to-page 1) ;Go to next page.
5511 ;; More in this page.
5512 (gnus-article-next-page-1 lines)
5515 (defun gnus-article-next-page-1 (lines)
5516 (let ((scroll-in-place nil))
5520 ;; Long lines may cause an end-of-buffer error.
5521 (goto-char (point-max)))))
5522 (move-to-window-line 0))
5524 (defun gnus-article-prev-page (&optional lines)
5525 "Show previous page of current article.
5526 Argument LINES specifies lines to be scrolled down."
5528 (move-to-window-line 0)
5529 (if (and gnus-page-broken
5531 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5533 (gnus-narrow-to-page -1) ;Go to previous page.
5534 (goto-char (point-max))
5536 (let ((scroll-in-place nil))
5540 (beginning-of-buffer
5541 (goto-char (point-min))))
5542 (move-to-window-line 0)))))
5544 (defun gnus-article-only-boring-p ()
5545 "Decide whether there is only boring text remaining in the article.
5546 Something \"interesting\" is a word of at least two letters that does
5547 not have a face in `gnus-article-boring-faces'."
5548 (when (and gnus-article-skip-boring
5549 (boundp 'gnus-article-boring-faces)
5550 (symbol-value 'gnus-article-boring-faces))
5553 (while (re-search-forward "\\b\\w\\w" nil t)
5555 (when (not (gnus-intersection
5556 (gnus-faces-at (point))
5557 (symbol-value 'gnus-article-boring-faces)))
5558 (throw 'only-boring nil)))
5559 (throw 'only-boring t)))))
5561 (defun gnus-article-refer-article ()
5562 "Read article specified by message-id around point."
5565 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5566 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5567 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5568 (let ((msg-id (concat "<" (match-string 0) ">")))
5569 (set-buffer gnus-summary-buffer)
5570 (gnus-summary-refer-article msg-id))
5571 (error "No references around point"))))
5573 (defun gnus-article-show-summary ()
5574 "Reconfigure windows to show summary buffer."
5576 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5577 (error "There is no summary buffer for this article buffer")
5578 (gnus-article-set-globals)
5579 (gnus-configure-windows 'article)
5580 (gnus-summary-goto-subject gnus-current-article)
5581 (gnus-summary-position-point)))
5583 (defun gnus-article-describe-briefly ()
5584 "Describe article mode commands briefly."
5586 (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")))
5588 (defun gnus-article-summary-command ()
5589 "Execute the last keystroke in the summary buffer."
5591 (let ((obuf (current-buffer))
5592 (owin (current-window-configuration))
5594 (switch-to-buffer gnus-article-current-summary 'norecord)
5595 (setq func (lookup-key (current-local-map) (this-command-keys)))
5596 (call-interactively func)
5598 (set-window-configuration owin)
5599 (set-window-point (get-buffer-window (current-buffer)) (point))))
5601 (defun gnus-article-summary-command-nosave ()
5602 "Execute the last keystroke in the summary buffer."
5605 (pop-to-buffer gnus-article-current-summary 'norecord)
5606 (setq func (lookup-key (current-local-map) (this-command-keys)))
5607 (call-interactively func)))
5609 (defun gnus-article-check-buffer ()
5610 "Beep if not in an article buffer."
5611 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5612 (error "Command invoked outside of a Gnus article buffer")))
5614 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5615 "Read a summary buffer key sequence and execute it from the article buffer."
5617 (gnus-article-check-buffer)
5619 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5620 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5621 "=" "^" "\M-^" "|"))
5627 '("n" "Gn" "p" "Gp"))
5630 (set-buffer gnus-article-current-summary)
5631 (let (gnus-pick-mode)
5632 (push (or key last-command-event) unread-command-events)
5633 (setq keys (static-if (featurep 'xemacs)
5634 (events-to-keys (read-key-sequence nil))
5635 (read-key-sequence nil)))))
5638 (if (or (member keys nosaves)
5639 (member keys nosave-but-article)
5640 (member keys nosave-in-article))
5642 (save-window-excursion
5643 (pop-to-buffer gnus-article-current-summary 'norecord)
5644 ;; We disable the pick minor mode commands.
5645 (let (gnus-pick-mode)
5646 (setq func (lookup-key (current-local-map) keys))))
5650 (unless (member keys nosave-in-article)
5651 (set-buffer gnus-article-current-summary))
5652 (call-interactively func)
5653 (setq new-sum-point (point)))
5654 (when (member keys nosave-but-article)
5655 (pop-to-buffer gnus-article-buffer 'norecord)))
5656 ;; These commands should restore window configuration.
5657 (let ((obuf (current-buffer))
5658 (owin (current-window-configuration))
5660 win func in-buffer selected new-sum-start new-sum-hscroll)
5661 (cond (not-restore-window
5662 (pop-to-buffer gnus-article-current-summary 'norecord))
5663 ((setq win (get-buffer-window gnus-article-current-summary))
5664 (select-window win))
5666 (switch-to-buffer gnus-article-current-summary 'norecord)))
5667 (setq in-buffer (current-buffer))
5668 ;; We disable the pick minor mode commands.
5669 (if (and (setq func (let (gnus-pick-mode)
5670 (lookup-key (current-local-map) keys)))
5673 (call-interactively func)
5674 (when (eq win (selected-window))
5675 (setq new-sum-point (point)
5676 new-sum-start (window-start win)
5677 new-sum-hscroll (window-hscroll win))
5678 (when (eq in-buffer (current-buffer))
5679 (setq selected (gnus-summary-select-article))
5681 (unless not-restore-window
5682 (set-window-configuration owin))
5683 (when (eq selected 'old)
5685 (set-window-start (get-buffer-window (current-buffer))
5687 (set-window-point (get-buffer-window (current-buffer))
5689 (when (and (not not-restore-window)
5691 (set-window-point win new-sum-point)
5692 (set-window-start win new-sum-start)
5693 (set-window-hscroll win new-sum-hscroll)))))
5694 (set-window-configuration owin)
5697 (defun gnus-article-describe-key (key)
5698 "Display documentation of the function invoked by KEY. KEY is a string."
5699 (interactive "kDescribe key: ")
5700 (gnus-article-check-buffer)
5701 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5703 (set-buffer gnus-article-current-summary)
5704 (let (gnus-pick-mode)
5705 (if (featurep 'xemacs)
5707 (push (elt key 0) unread-command-events)
5708 (setq key (events-to-keys
5709 (read-key-sequence "Describe key: "))))
5710 (setq unread-command-events
5712 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5714 (setq key (read-key-sequence "Describe key: "))))
5716 (describe-key key)))
5718 (defun gnus-article-describe-key-briefly (key &optional insert)
5719 "Display documentation of the function invoked by KEY. KEY is a string."
5720 (interactive "kDescribe key: \nP")
5721 (gnus-article-check-buffer)
5722 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5724 (set-buffer gnus-article-current-summary)
5725 (let (gnus-pick-mode)
5726 (if (featurep 'xemacs)
5728 (push (elt key 0) unread-command-events)
5729 (setq key (events-to-keys
5730 (read-key-sequence "Describe key: "))))
5731 (setq unread-command-events
5733 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5735 (setq key (read-key-sequence "Describe key: "))))
5736 (describe-key-briefly key insert))
5737 (describe-key-briefly key insert)))
5739 (defun gnus-article-reply-with-original (&optional wide)
5740 "Start composing a reply mail to the current message.
5741 The text in the region will be yanked. If the region isn't active,
5742 the entire article will be yanked."
5744 (let ((article (cdr gnus-article-current))
5746 (if (not (gnus-region-active-p))
5747 (with-current-buffer gnus-summary-buffer
5748 (gnus-summary-reply (list (list article)) wide))
5749 (setq contents (buffer-substring (point) (mark t)))
5750 ;; Deactivate active regions.
5751 (when (and (boundp 'transient-mark-mode)
5752 transient-mark-mode)
5753 (setq mark-active nil))
5754 (with-current-buffer gnus-summary-buffer
5756 (list (list article contents)) wide)))))
5758 (defun gnus-article-followup-with-original ()
5759 "Compose a followup to the current article.
5760 The text in the region will be yanked. If the region isn't active,
5761 the entire article will be yanked."
5763 (let ((article (cdr gnus-article-current))
5765 (if (not (gnus-region-active-p))
5766 (with-current-buffer gnus-summary-buffer
5767 (gnus-summary-followup (list (list article))))
5768 (setq contents (buffer-substring (point) (mark t)))
5769 ;; Deactivate active regions.
5770 (when (and (boundp 'transient-mark-mode)
5771 transient-mark-mode)
5772 (setq mark-active nil))
5773 (with-current-buffer gnus-summary-buffer
5774 (gnus-summary-followup
5775 (list (list article contents)))))))
5777 (defun gnus-article-hide (&optional arg force)
5778 "Hide all the gruft in the current article.
5779 This means that signatures, cited text and (some) headers will be
5781 If given a prefix, show the hidden text instead."
5782 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5783 (gnus-article-hide-headers arg)
5784 (gnus-article-hide-list-identifiers arg)
5785 (gnus-article-hide-citation-maybe arg force)
5786 (gnus-article-hide-signature arg))
5788 (defun gnus-article-maybe-highlight ()
5789 "Do some article highlighting if article highlighting is requested."
5790 (when (gnus-visual-p 'article-highlight 'highlight)
5791 (gnus-article-highlight-some)))
5793 (defun gnus-check-group-server ()
5794 ;; Make sure the connection to the server is alive.
5795 (unless (gnus-server-opened
5796 (gnus-find-method-for-group gnus-newsgroup-name))
5797 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5798 (gnus-request-group gnus-newsgroup-name t)))
5801 (autoload 'nneething-get-file-name "nneething"))
5803 (defun gnus-request-article-this-buffer (article group)
5804 "Get an article and insert it into this buffer."
5805 (let (do-update-line sparse-header)
5809 (gnus-kill-all-overlays)
5810 (setq group (or group gnus-newsgroup-name))
5812 ;; Using `gnus-request-article' directly will insert the article into
5813 ;; `nntp-server-buffer' - so we'll save some time by not having to
5814 ;; copy it from the server buffer into the article buffer.
5816 ;; We only request an article by message-id when we do not have the
5817 ;; headers for it, so we'll have to get those.
5818 (when (stringp article)
5819 (gnus-read-header article))
5821 ;; If the article number is negative, that means that this article
5822 ;; doesn't belong in this newsgroup (possibly), so we find its
5823 ;; message-id and request it by id instead of number.
5824 (when (and (numberp article)
5826 (get-buffer gnus-summary-buffer)
5827 (gnus-buffer-exists-p gnus-summary-buffer))
5829 (set-buffer gnus-summary-buffer)
5830 (let ((header (gnus-summary-article-header article)))
5833 ((memq article gnus-newsgroup-sparse)
5834 ;; This is a sparse gap article.
5835 (setq do-update-line article)
5836 (setq article (mail-header-id header))
5837 (setq sparse-header (gnus-read-header article))
5838 (setq gnus-newsgroup-sparse
5839 (delq article gnus-newsgroup-sparse)))
5841 ;; It's a real article.
5842 (setq article (mail-header-id header)))
5844 ;; It is an extracted pseudo-article.
5845 (setq article 'pseudo)
5846 (gnus-request-pseudo-article header))))
5848 (let ((method (gnus-find-method-for-group
5849 gnus-newsgroup-name)))
5850 (when (and (eq (car method) 'nneething)
5852 (let ((dir (nneething-get-file-name
5853 (mail-header-id header))))
5854 (when (and (stringp dir)
5855 (file-directory-p dir))
5856 (setq article 'nneething)
5857 (gnus-group-enter-directory dir))))))))
5860 ;; Refuse to select canceled articles.
5861 ((and (numberp article)
5863 (get-buffer gnus-summary-buffer)
5864 (gnus-buffer-exists-p gnus-summary-buffer)
5865 (eq (cdr (with-current-buffer gnus-summary-buffer
5866 (assq article gnus-newsgroup-reads)))
5867 gnus-canceled-mark))
5869 ;; We first check `gnus-original-article-buffer'.
5870 ((and (get-buffer gnus-original-article-buffer)
5872 (with-current-buffer gnus-original-article-buffer
5873 (and (equal (car gnus-original-article) group)
5874 (eq (cdr gnus-original-article) article))))
5875 (insert-buffer-substring gnus-original-article-buffer)
5877 ;; Check the backlog.
5878 ((and gnus-keep-backlog
5879 (gnus-backlog-request-article group article (current-buffer)))
5881 ;; Check asynchronous pre-fetch.
5882 ((gnus-async-request-fetched-article group article (current-buffer))
5883 (gnus-async-prefetch-next group article gnus-summary-buffer)
5884 (when (and (numberp article) gnus-keep-backlog)
5885 (gnus-backlog-enter-article group article (current-buffer)))
5888 ((and gnus-use-cache
5890 (gnus-cache-request-article article group))
5892 ;; Check the agent cache.
5893 ((gnus-agent-request-article article group)
5895 ;; Get the article and put into the article buffer.
5896 ((or (stringp article)
5898 (let ((gnus-override-method gnus-override-method)
5899 (methods (and (stringp article)
5900 gnus-refer-article-method))
5901 (backend (car (gnus-find-method-for-group
5902 gnus-newsgroup-name)))
5904 (inhibit-read-only t))
5905 (if (or (not (listp methods))
5906 (and (symbolp (car methods))
5907 (assq (car methods) nnoo-definition-alist)))
5908 (setq methods (list methods)))
5909 (when (and (null gnus-override-method)
5911 (setq gnus-override-method (pop methods)))
5913 (when (eq gnus-override-method 'current)
5914 (setq gnus-override-method
5915 (with-current-buffer gnus-summary-buffer
5916 gnus-current-select-method)))
5918 (gnus-kill-all-overlays)
5919 (let ((gnus-newsgroup-name group))
5920 (gnus-check-group-server))
5922 ((gnus-request-article article group (current-buffer))
5923 (when (numberp article)
5924 (gnus-async-prefetch-next group article
5925 gnus-summary-buffer)
5926 (when gnus-keep-backlog
5927 (gnus-backlog-enter-article
5928 group article (current-buffer))))
5929 (setq result 'article))
5931 (setq gnus-override-method (pop methods)))
5932 ((not (string-match "^400 "
5933 (nnheader-get-report backend)))
5934 ;; If we get 400 server disconnect, reconnect and
5935 ;; retry; otherwise, assume the article has expired.
5936 (setq result 'done))))
5937 (and (eq result 'article) 'article)))
5941 ;; Associate this article with the current summary buffer.
5942 (setq gnus-article-current-summary gnus-summary-buffer)
5944 ;; Take the article from the original article buffer
5945 ;; and place it in the buffer it's supposed to be in.
5946 (when (and (get-buffer gnus-article-buffer)
5947 (equal (buffer-name (current-buffer))
5948 (buffer-name (get-buffer gnus-article-buffer))))
5950 (if (get-buffer gnus-original-article-buffer)
5951 (set-buffer gnus-original-article-buffer)
5952 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5953 (buffer-disable-undo)
5954 (setq major-mode 'gnus-original-article-mode)
5955 (setq buffer-read-only t))
5956 (let ((inhibit-read-only t))
5958 (insert-buffer-substring gnus-article-buffer))
5959 (setq gnus-original-article (cons group article)))
5962 (run-hooks 'gnus-article-decode-hook)
5963 ;; Mark article as decoded or not.
5964 (setq gnus-article-decoded-p gnus-article-decode-hook))
5966 ;; Update sparse articles.
5967 (when (and do-update-line
5968 (or (numberp article)
5970 (let ((buf (current-buffer)))
5971 (set-buffer gnus-summary-buffer)
5972 (gnus-summary-update-article do-update-line sparse-header)
5973 (gnus-summary-goto-subject do-update-line nil t)
5974 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5976 (set-buffer buf))))))
5982 (defcustom gnus-article-edit-mode-hook nil
5983 "Hook run in article edit mode buffers."
5984 :group 'gnus-article-various
5987 (defcustom gnus-article-edit-article-setup-function
5988 'gnus-article-mime-edit-article-setup
5989 "Function called to setup an editing article buffer."
5990 :group 'gnus-article-various
5993 (defvar gnus-article-edit-done-function nil)
5995 (defvar gnus-article-edit-mode-map nil)
5997 ;; Should we be using derived.el for this?
5998 (unless gnus-article-edit-mode-map
5999 (setq gnus-article-edit-mode-map (make-keymap))
6000 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6002 (gnus-define-keys gnus-article-edit-mode-map
6003 "\C-c?" describe-mode
6004 "\C-c\C-c" gnus-article-edit-done
6005 "\C-c\C-k" gnus-article-edit-exit
6006 "\C-c\C-f\C-t" message-goto-to
6007 "\C-c\C-f\C-o" message-goto-from
6008 "\C-c\C-f\C-b" message-goto-bcc
6009 ;;"\C-c\C-f\C-w" message-goto-fcc
6010 "\C-c\C-f\C-c" message-goto-cc
6011 "\C-c\C-f\C-s" message-goto-subject
6012 "\C-c\C-f\C-r" message-goto-reply-to
6013 "\C-c\C-f\C-n" message-goto-newsgroups
6014 "\C-c\C-f\C-d" message-goto-distribution
6015 "\C-c\C-f\C-f" message-goto-followup-to
6016 "\C-c\C-f\C-m" message-goto-mail-followup-to
6017 "\C-c\C-f\C-k" message-goto-keywords
6018 "\C-c\C-f\C-u" message-goto-summary
6019 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6020 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6021 "\C-c\C-b" message-goto-body
6022 "\C-c\C-i" message-goto-signature
6024 "\C-c\C-t" message-insert-to
6025 "\C-c\C-n" message-insert-newsgroups
6026 "\C-c\C-o" message-sort-headers
6027 "\C-c\C-e" message-elide-region
6028 "\C-c\C-v" message-delete-not-region
6029 "\C-c\C-z" message-kill-to-signature
6030 "\M-\r" message-newline-and-reformat
6031 "\C-c\C-a" mml-attach-file
6032 "\C-a" message-beginning-of-line
6034 "\M-;" comment-region)
6036 (gnus-define-keys (gnus-article-edit-wash-map
6037 "\C-c\C-w" gnus-article-edit-mode-map)
6038 "f" gnus-article-edit-full-stops))
6041 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6043 ["Fetch To" message-insert-to t]
6044 ["Fetch Newsgroups" message-insert-newsgroups t]
6046 ["To" message-goto-to t]
6047 ["From" message-goto-from t]
6048 ["Subject" message-goto-subject t]
6049 ["Cc" message-goto-cc t]
6050 ["Reply-To" message-goto-reply-to t]
6051 ["Summary" message-goto-summary t]
6052 ["Keywords" message-goto-keywords t]
6053 ["Newsgroups" message-goto-newsgroups t]
6054 ["Followup-To" message-goto-followup-to t]
6055 ["Mail-Followup-To" message-goto-mail-followup-to t]
6056 ["Distribution" message-goto-distribution t]
6057 ["Body" message-goto-body t]
6058 ["Signature" message-goto-signature t]))
6060 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6061 "Major mode for editing articles.
6062 This is an extended text-mode.
6064 \\{gnus-article-edit-mode-map}"
6065 (make-local-variable 'gnus-article-edit-done-function)
6066 (make-local-variable 'gnus-prev-winconf)
6067 (set (make-local-variable 'font-lock-defaults)
6068 '(message-font-lock-keywords t))
6069 (set (make-local-variable 'mail-header-separator) "")
6070 (set (make-local-variable 'gnus-article-edit-mode) t)
6071 (easy-menu-add message-mode-field-menu message-mode-map)
6072 (setq buffer-read-only nil)
6073 (buffer-enable-undo)
6076 (defun gnus-article-edit (&optional force)
6077 "Edit the current article.
6078 This will have permanent effect only in mail groups.
6079 If FORCE is non-nil, allow editing of articles even in read-only
6082 (when (and (not force)
6083 (gnus-group-read-only-p))
6084 (error "The current newsgroup does not support article editing"))
6085 (gnus-article-date-original)
6086 (gnus-article-edit-article
6088 `(lambda (no-highlight)
6090 (gnus-summary-edit-article-done
6091 ,(or (mail-header-references gnus-current-headers) "")
6092 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6094 (defun gnus-article-edit-article (start-func exit-func)
6095 "Start editing the contents of the current article buffer."
6096 (let ((winconf (current-window-configuration)))
6097 (set-buffer gnus-article-buffer)
6098 (let ((message-auto-save-directory
6099 ;; Don't associate the article buffer with a draft file.
6101 (gnus-article-edit-mode))
6102 (funcall start-func)
6103 (set-buffer-modified-p nil)
6104 (gnus-configure-windows 'edit-article)
6105 (setq gnus-article-edit-done-function exit-func)
6106 (setq gnus-prev-winconf winconf)
6107 (when gnus-article-edit-article-setup-function
6108 (funcall gnus-article-edit-article-setup-function))
6109 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
6111 (defun gnus-article-edit-done (&optional arg)
6112 "Update the article edits and exit."
6114 (let ((func gnus-article-edit-done-function)
6115 (buf (current-buffer))
6116 (start (window-start))
6118 (winconf gnus-prev-winconf))
6119 (remove-hook 'gnus-article-mode-hook
6120 'gnus-article-mime-edit-article-unwind)
6121 (widen) ;; Widen it in case that users narrowed the buffer.
6124 ;; The cache and backlog have to be flushed somewhat.
6125 (when gnus-keep-backlog
6126 (gnus-backlog-remove-article
6127 (car gnus-article-current) (cdr gnus-article-current)))
6128 ;; Flush original article as well.
6130 (when (get-buffer gnus-original-article-buffer)
6131 (set-buffer gnus-original-article-buffer)
6132 (setq gnus-original-article nil)))
6133 (when gnus-use-cache
6134 (gnus-cache-update-article
6135 (car gnus-article-current) (cdr gnus-article-current)))
6136 ;; We remove all text props from the article buffer.
6137 (kill-all-local-variables)
6138 (set-text-properties (point-min) (point-max) nil)
6140 (set-window-configuration winconf)
6142 (set-window-start (get-buffer-window buf) start)
6143 (set-window-point (get-buffer-window buf) (point)))
6144 (gnus-summary-show-article))
6146 (defun gnus-article-edit-exit ()
6147 "Exit the article editing without updating."
6149 (when (or (not (buffer-modified-p))
6150 (yes-or-no-p "Article modified; kill anyway? "))
6151 (let ((curbuf (current-buffer))
6153 (window-start (window-start)))
6155 (if (gnus-buffer-live-p gnus-original-article-buffer)
6156 (insert-buffer-substring gnus-original-article-buffer))
6157 (let ((winconf gnus-prev-winconf))
6158 (kill-all-local-variables)
6160 (set-window-configuration winconf)
6161 ;; Tippy-toe some to make sure that point remains where it was.
6162 (save-current-buffer
6164 (set-window-start (get-buffer-window (current-buffer)) window-start)
6166 (gnus-summary-show-article)))
6168 (defun gnus-article-edit-full-stops ()
6169 "Interactively repair spacing at end of sentences."
6172 (goto-char (point-min))
6173 (search-forward-regexp "^$" nil t)
6174 (let ((case-fold-search nil))
6175 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6178 ;;; Article editing with MIME-Edit
6181 (defcustom gnus-article-mime-edit-article-setup-hook nil
6182 "Hook run after setting up a MIME editing article buffer."
6183 :group 'gnus-article-various
6186 (defun gnus-article-mime-edit-article-unwind ()
6187 "Unwind `gnus-article-buffer' if article editing was given up."
6188 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6189 (when (featurep 'font-lock)
6190 (setq font-lock-defaults nil)
6191 (font-lock-mode -1))
6192 (when mime-edit-mode-flag
6193 (mime-edit-exit 'nomime 'no-error)
6196 (defun gnus-article-mime-edit-article-setup ()
6197 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6198 after replacing with the original article."
6199 (setq gnus-show-mime t)
6200 (setq gnus-article-edit-done-function
6201 `(lambda (&rest args)
6202 (when mime-edit-mode-flag
6203 (let (mime-edit-insert-user-agent-field)
6206 (goto-char (point-min))
6207 (let (case-fold-search)
6208 (when (re-search-forward
6209 (format "^%s$" (regexp-quote mail-header-separator))
6211 (replace-match "")))
6212 (apply ,gnus-article-edit-done-function args)
6215 (buffer-substring-no-properties (point-min) (point-max))
6216 (set-buffer (get-buffer-create gnus-original-article-buffer))
6218 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6219 (set-buffer gnus-article-buffer)
6220 (gnus-article-prepare-display)))
6221 (substitute-key-definition 'gnus-article-edit-done
6222 'gnus-article-mime-edit-done
6223 gnus-article-edit-mode-map)
6224 (substitute-key-definition 'gnus-article-edit-exit
6225 'gnus-article-mime-edit-exit
6226 gnus-article-edit-mode-map)
6228 (insert-buffer-substring gnus-original-article-buffer)
6229 (unless (member (with-current-buffer gnus-summary-buffer
6230 gnus-newsgroup-name)
6231 '("nndraft:delayed" "nndraft:drafts"))
6232 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6233 (fset 'mime-edit-decode-single-part-in-buffer
6234 (lambda (&rest args)
6235 (if (let ((content-type (car args)))
6236 (and (eq 'message (mime-content-type-primary-type
6238 (eq 'rfc822 (mime-content-type-subtype
6240 (setcar (cdr args) 'not-decode-text))
6244 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6245 (when (featurep 'font-lock)
6246 (set (make-local-variable 'font-lock-defaults)
6247 '(message-font-lock-keywords t))
6248 (font-lock-set-defaults)
6249 (turn-on-font-lock))
6250 (set-buffer-modified-p nil)
6251 (delete-other-windows)
6252 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6253 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6255 (defun gnus-article-mime-edit-done (&optional arg)
6256 "Update the article MIME edits and exit."
6258 (when (featurep 'font-lock)
6259 (setq font-lock-defaults nil)
6260 (font-lock-mode -1))
6261 (let ((inhibit-read-only t))
6262 (gnus-article-edit-done arg)))
6264 (defun gnus-article-mime-edit-exit ()
6265 "Exit the article MIME editing without updating."
6267 (when (or (not (buffer-modified-p))
6268 (yes-or-no-p "Article modified; kill anyway? "))
6269 (when (featurep 'font-lock)
6270 (setq font-lock-defaults nil)
6271 (font-lock-mode -1))
6272 (when mime-edit-mode-flag
6273 (let (mime-edit-insert-user-agent-field)
6276 (goto-char (point-min))
6277 (let (case-fold-search)
6278 (when (re-search-forward
6279 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6280 (replace-match "")))
6281 (let ((winconf gnus-prev-winconf))
6283 (buffer-substring-no-properties (point-min) (point-max))
6284 (set-buffer (get-buffer-create gnus-original-article-buffer))
6286 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6287 (set-buffer gnus-article-buffer)
6288 (gnus-article-prepare-display)
6289 (set-window-configuration winconf))))
6292 ;;; Article highlights
6295 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6297 ;;; Internal Variables:
6299 (defcustom gnus-button-url-regexp
6300 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6301 "\\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:]]\\)"
6302 "\\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\\)\\)")
6303 "Regular expression that matches URLs."
6304 :group 'gnus-article-buttons
6307 (defcustom gnus-button-valid-fqdn-regexp
6308 message-valid-fqdn-regexp
6309 "Regular expression that matches a valid FQDN."
6311 :group 'gnus-article-buttons
6314 (defcustom gnus-button-man-handler 'manual-entry
6315 "Function to use for displaying man pages.
6316 The function must take at least one argument with a string naming the
6319 :type '(choice (function-item :tag "Man" manual-entry)
6320 (function-item :tag "Woman" woman)
6321 (function :tag "Other"))
6322 :group 'gnus-article-buttons)
6324 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6325 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6326 If the default site is too slow, try to find a CTAN mirror, see
6327 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6328 the variable `gnus-button-handle-ctan'."
6330 :group 'gnus-article-buttons
6331 :link '(custom-manual "(gnus)Group Parameters")
6332 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6333 (const "http://tug.ctan.org/tex-archive/")
6334 (const "http://www.dante.de/CTAN/")
6335 (string :tag "Other")))
6337 (defcustom gnus-button-ctan-handler 'browse-url
6338 "Function to use for displaying CTAN links.
6339 The function must take one argument, the string naming the URL."
6341 :type '(choice (function-item :tag "Browse Url" browse-url)
6342 (function :tag "Other"))
6343 :group 'gnus-article-buttons)
6345 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6346 "Bogus strings removed from CTAN URLs."
6348 :group 'gnus-article-buttons
6349 :type '(choice (const "^/?tex-archive/\\|/")
6350 (regexp :tag "Other")))
6352 (defcustom gnus-button-ctan-directory-regexp
6355 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6356 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6357 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6359 "Regular expression for ctan directories.
6360 It should match all directories in the top level of `gnus-ctan-url'."
6362 :group 'gnus-article-buttons
6365 (defcustom gnus-button-mid-or-mail-regexp
6366 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
6367 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6368 gnus-button-valid-fqdn-regexp
6370 "Regular expression that matches a message ID or a mail address."
6372 :group 'gnus-article-buttons
6375 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6376 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6377 Strings like this can be either a message ID or a mail address. If it is one
6378 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6379 message ID or a mail address, respectively. If this variable is set to the
6380 symbol `ask', always query the user what do do. If it is a function, this
6381 function will be called with the string as it's only argument. The function
6382 must return `mid', `mail', `invalid' or `ask'."
6384 :group 'gnus-article-buttons
6385 :type '(choice (function-item :tag "Heuristic function"
6386 gnus-button-mid-or-mail-heuristic)
6391 (defcustom gnus-button-mid-or-mail-heuristic-alist
6392 '((-10.0 . ".+\\$.+@")
6395 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6396 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6397 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6398 (-1.0 . "^[^a-z]+@")
6400 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6401 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6402 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6403 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6406 (-1.0 . "^[0-9][0-9]")
6408 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6409 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6410 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6411 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6413 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6414 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6417 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6419 ;; compensation for TDMA dated mail addresses:
6420 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6422 (-20.0 . "\\.fsf@") ;; Gnus
6425 (-20.0 . "_-_") ;; Subject change in thread
6427 (-20.0 . "\\.ln@") ;; leafnode
6428 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6429 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6431 ;; (5.0 . "") ;; $local_part_len <= 7
6432 (10.0 . "^[^0-9]+@")
6433 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6434 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6437 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6439 (0.5 . "^[A-Z][a-z]")
6440 (0.5 . "^[A-Z][a-z][a-z]")
6441 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6442 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6443 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6445 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6446 address. The REGEXP is processed with `case-fold-search' set to nil."
6448 :group 'gnus-article-buttons
6449 :type '(repeat (cons (number :tag "Rate")
6450 (regexp :tag "Regexp"))))
6452 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6453 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6454 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6455 address, `ask' if unsure and `invalid' if the string is invalid."
6456 (let ((case-fold-search nil)
6457 (list gnus-button-mid-or-mail-heuristic-alist)
6458 (result 0) rate regexp lpartlen elem)
6460 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6461 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6462 ;; Certain special cases...
6465 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6466 "^[0-9]+\\.[0-9]+@compuserve\\|"
6467 "@public\\.gmane\\.org")
6469 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6470 (setq result 'mail))
6471 (when (string-match "@.*@\\| " mid-or-mail)
6472 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6473 (setq result 'invalid))
6474 ;; Nothing more to do, if result is not a number here...
6475 (when (numberp result)
6477 (setq elem (car list)
6481 (when (string-match regexp mid-or-mail)
6482 (setq result (+ result rate))
6484 9 "`%s' matched `%s', rate `%s', result `%s'."
6485 mid-or-mail regexp rate result)))
6486 (when (<= lpartlen 7)
6487 (setq result (+ result 5.0))
6488 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6489 mid-or-mail result))
6490 (when (>= lpartlen 12)
6491 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6493 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6494 ;; Long local part should contain realname if e-mail address,
6495 ;; too many digits: message-id.
6496 ;; $score -= 5.0 + 0.1 * $local_part_len;
6497 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6498 (setq result (+ result rate))
6500 9 "Many digits in `%s', rate `%s', result `%s'."
6501 mid-or-mail rate result))
6502 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6504 ;; Too few vowels [^aeiouy]{4,}.*\@
6505 (setq result (+ result -5.0))
6507 9 "Few vowels in `%s', rate `%s', result `%s'."
6508 mid-or-mail -5.0 result))
6510 (setq result (+ result 5.0))
6512 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6513 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6514 ;; Maybe we should make this a customizable alist: (condition . 'result)
6516 ((symbolp result) result)
6517 ;; Now convert number into proper results:
6518 ((< result -10.0) 'mid)
6519 ((> result 10.0) 'mail)
6522 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6523 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6524 (url-mid (concat "news" ":" mid-or-mail))
6525 (url-mailto (concat "mailto" ":" mid-or-mail)))
6526 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6527 (when (fboundp pref)
6529 ;; get rid of surrounding angles...
6531 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6532 (if (or (eq 'mid guessed) (eq 'mail guessed))
6536 (save-window-excursion
6537 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6540 (cond ((eq pref 'mid)
6541 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6542 (gnus-button-handle-news url-mid))
6544 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6545 (gnus-url-mailto url-mailto))
6546 (t (gnus-message 3 "Invalid string.")))))
6548 (defun gnus-button-handle-custom (url)
6549 "Follow a Custom URL."
6550 (customize-apropos (gnus-url-unhex-string url)))
6552 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6554 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6557 (defun gnus-button-handle-describe-function (url)
6558 "Call `describe-function' when pushing the corresponding URL button."
6561 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6563 (defun gnus-button-handle-describe-variable (url)
6564 "Call `describe-variable' when pushing the corresponding URL button."
6567 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6569 (defun gnus-button-handle-symbol (url)
6570 "Display help on variable or function.
6571 Calls `describe-variable' or `describe-function'."
6572 (let ((sym (intern url)))
6574 ((fboundp sym) (describe-function sym))
6575 ((boundp sym) (describe-variable sym))
6576 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6578 (defun gnus-button-handle-describe-key (url)
6579 "Call `describe-key' when pushing the corresponding URL button."
6581 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6582 (keys (ignore-errors (eval `(kbd ,key-string)))))
6585 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6587 (defun gnus-button-handle-apropos (url)
6588 "Call `apropos' when pushing the corresponding URL button."
6589 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6591 (defun gnus-button-handle-apropos-command (url)
6592 "Call `apropos' when pushing the corresponding URL button."
6594 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6596 (defun gnus-button-handle-apropos-variable (url)
6597 "Call `apropos' when pushing the corresponding URL button."
6599 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6600 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6602 (defun gnus-button-handle-apropos-documentation (url)
6603 "Call `apropos' when pushing the corresponding URL button."
6605 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6606 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6608 (defun gnus-button-handle-library (url)
6609 "Call `locate-library' when pushing the corresponding URL button."
6610 (gnus-message 9 "url=`%s'" url)
6611 (let* ((lib (locate-library url))
6612 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6614 (gnus-message 1 "Cannot locale library `%s'." url)
6615 (find-file-read-only file))))
6617 (defun gnus-button-handle-ctan (url)
6618 "Call `browse-url' when pushing a CTAN URL button."
6620 gnus-button-ctan-handler
6623 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6625 (defcustom gnus-button-tex-level 5
6626 "*Integer that says how many TeX-related buttons Gnus will show.
6627 The higher the number, the more buttons will appear and the more false
6628 positives are possible. Note that you can set this variable local to
6629 specific groups. Setting it higher in TeX groups is probably a good idea.
6630 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6631 how to set variables in specific groups."
6633 :group 'gnus-article-buttons
6634 :link '(custom-manual "(gnus)Group Parameters")
6637 (defcustom gnus-button-man-level 5
6638 "*Integer that says how many man-related buttons Gnus will show.
6639 The higher the number, the more buttons will appear and the more false
6640 positives are possible. Note that you can set this variable local to
6641 specific groups. Setting it higher in Unix groups is probably a good idea.
6642 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6643 how to set variables in specific groups."
6645 :group 'gnus-article-buttons
6646 :link '(custom-manual "(gnus)Group Parameters")
6649 (defcustom gnus-button-emacs-level 5
6650 "*Integer that says how many emacs-related buttons Gnus will show.
6651 The higher the number, the more buttons will appear and the more false
6652 positives are possible. Note that you can set this variable local to
6653 specific groups. Setting it higher in Emacs or Gnus related groups is
6654 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6655 `gnus-parameters' on how to set variables in specific groups."
6657 :group 'gnus-article-buttons
6658 :link '(custom-manual "(gnus)Group Parameters")
6661 (defcustom gnus-button-message-level 5
6662 "*Integer that says how many buttons for news or mail messages will appear.
6663 The higher the number, the more buttons will appear and the more false
6664 positives are possible."
6665 ;; mail addresses, MIDs, URLs for news, ...
6667 :group 'gnus-article-buttons
6670 (defcustom gnus-button-browse-level 5
6671 "*Integer that says how many buttons for browsing will appear.
6672 The higher the number, the more buttons will appear and the more false
6673 positives are possible."
6674 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6676 :group 'gnus-article-buttons
6679 (defcustom gnus-button-alist
6680 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6681 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6682 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6683 gnus-button-handle-news 2)
6684 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6685 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6686 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6687 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6688 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6689 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6690 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6691 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6692 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6693 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6694 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6695 ;; RFC 2368 (The mailto URL scheme)
6696 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6697 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6698 ("\\bmailto:\\([^ \n\t]+\\)"
6699 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6701 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6702 gnus-button-ctan-directory-regexp
6703 "[^][>)!;:,'\n\t ]+\\)")
6704 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6705 ((concat "\\btex-archive/\\("
6706 gnus-button-ctan-directory-regexp
6707 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6708 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6711 gnus-button-ctan-directory-regexp
6712 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6713 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6714 ;; This is info (home-grown style) <info://foo/bar+baz>
6715 ("\\binfo://\\([^'\">\n\t ]+\\)"
6716 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6717 ;; Info GNOME style <info:foo#bar_baz>
6718 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6719 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6720 ;; Info KDE style <info:(foo)bar baz>
6721 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6722 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6723 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6724 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6725 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6726 ;; Info links like `C-h i d m CC Mode RET'
6727 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6729 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6730 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6731 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6732 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6733 ;; Emacs help commands
6734 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6735 ;; regexp doesn't match arguments containing ` '.
6736 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6737 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6738 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6739 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6740 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6741 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6742 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6743 ;; The following entries may lead to many false positives so don't enable
6744 ;; them by default (use a high button level).
6745 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6746 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6747 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6748 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6749 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6750 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6751 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6752 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6753 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6754 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6755 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6756 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6757 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6758 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6759 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6760 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6761 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6762 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6763 ;; Unlike the other regexps we really have to require quoting
6764 ;; here to determine where it ends.
6765 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6766 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6767 ("<URL: *\\([^<>]*\\)>"
6768 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6769 ;; RFC 2396 (2.4.3., delims) ...
6770 ("\"URL: *\\([^\"]*\\)\""
6771 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6772 ;; RFC 2396 (2.4.3., delims) ...
6773 ("\"URL: *\\([^\"]*\\)\""
6774 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6776 (gnus-button-url-regexp
6777 0 (>= gnus-button-browse-level 0) browse-url 0)
6779 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6780 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6781 gnus-button-handle-man 1)
6782 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6783 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6784 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6785 gnus-button-handle-man 1)
6786 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6787 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6788 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6789 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6790 ;; MID or mail: To avoid too many false positives we don't try to catch
6791 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6792 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6793 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6794 ;; so that non-ambiguous entries (see above) match first.
6795 (gnus-button-mid-or-mail-regexp
6796 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6797 "*Alist of regexps matching buttons in article bodies.
6799 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6800 REGEXP: is the string (case insensitive) matching text around the button (can
6801 also be Lisp expression evaluating to a string),
6802 BUTTON: is the number of the regexp grouping actually matching the button,
6803 FORM: is a Lisp expression which must eval to true for the button to
6805 CALLBACK: is the function to call when the user push this button, and each
6806 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6808 CALLBACK can also be a variable, in that case the value of that
6809 variable it the real callback function."
6810 :group 'gnus-article-buttons
6811 :type '(repeat (list (choice regexp variable sexp)
6812 (integer :tag "Button")
6814 (function :tag "Callback")
6817 (integer :tag "Regexp group")))))
6819 (defcustom gnus-header-button-alist
6820 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6821 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6822 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6823 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6824 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6825 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6826 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6827 0 (>= gnus-button-browse-level 0) browse-url 0)
6828 ("^Subject:" gnus-button-url-regexp
6829 0 (>= gnus-button-browse-level 0) browse-url 0)
6830 ("^[^:]+:" gnus-button-url-regexp
6831 0 (>= gnus-button-browse-level 0) browse-url 0)
6832 ("^OpenPGP:.*url=" gnus-button-url-regexp
6833 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6834 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6835 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6836 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6837 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6838 "*Alist of headers and regexps to match buttons in article heads.
6840 This alist is very similar to `gnus-button-alist', except that each
6841 alist has an additional HEADER element first in each entry:
6843 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6845 HEADER is a regexp to match a header. For a fuller explanation, see
6846 `gnus-button-alist'."
6847 :group 'gnus-article-buttons
6848 :group 'gnus-article-headers
6849 :type '(repeat (list (regexp :tag "Header")
6850 (choice regexp variable)
6851 (integer :tag "Button")
6853 (function :tag "Callback")
6856 (integer :tag "Regexp group")))))
6860 (defun gnus-article-push-button (event)
6861 "Check text under the mouse pointer for a callback function.
6862 If the text under the mouse pointer has a `gnus-callback' property,
6863 call it with the value of the `gnus-data' text property."
6865 (set-buffer (window-buffer (posn-window (event-start event))))
6866 (let* ((pos (posn-point (event-start event)))
6867 (data (get-text-property pos 'gnus-data))
6868 (fun (get-text-property pos 'gnus-callback)))
6871 (funcall fun data))))
6873 (defun gnus-article-press-button ()
6874 "Check text at point for a callback function.
6875 If the text at point has a `gnus-callback' property,
6876 call it with the value of the `gnus-data' text property."
6878 (let ((data (get-text-property (point) 'gnus-data))
6879 (fun (get-text-property (point) 'gnus-callback)))
6881 (funcall fun data))))
6883 (defun gnus-article-prev-button (n)
6884 "Move point to N buttons backward.
6885 If N is negative, move forward instead."
6887 (gnus-article-next-button (- n)))
6889 (defun gnus-article-next-button (n)
6890 "Move point to N buttons forward.
6891 If N is negative, move backward instead."
6893 (let ((function (if (< n 0) 'previous-single-property-change
6894 'next-single-property-change))
6895 (inhibit-point-motion-hooks t)
6897 (limit (if (< n 0) (point-min) (point-max))))
6899 (while (and (not (= limit (point)))
6901 ;; Skip past the current button.
6902 (when (get-text-property (point) 'gnus-callback)
6903 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6904 ;; Go to the next (or previous) button.
6905 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6906 ;; Put point at the start of the button.
6907 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6908 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6909 ;; Skip past intangible buttons.
6910 (when (get-text-property (point) 'intangible)
6914 (gnus-message 5 "No more buttons"))
6917 (defun gnus-article-highlight (&optional force)
6918 "Highlight current article.
6919 This function calls `gnus-article-highlight-headers',
6920 `gnus-article-highlight-citation',
6921 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6922 do the highlighting. See the documentation for those functions."
6923 (interactive (list 'force))
6924 (gnus-article-highlight-headers)
6925 (gnus-article-highlight-citation force)
6926 (gnus-article-highlight-signature)
6927 (gnus-article-add-buttons force)
6928 (gnus-article-add-buttons-to-head))
6930 (defun gnus-article-highlight-some (&optional force)
6931 "Highlight current article.
6932 This function calls `gnus-article-highlight-headers',
6933 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6934 do the highlighting. See the documentation for those functions."
6935 (interactive (list 'force))
6936 (gnus-article-highlight-headers)
6937 (gnus-article-highlight-signature)
6938 (gnus-article-add-buttons))
6940 (defun gnus-article-highlight-headers ()
6941 "Highlight article headers as specified by `gnus-header-face-alist'."
6943 (gnus-with-article-headers
6944 (let (regexp header-face field-face from hpoints fpoints)
6945 (dolist (entry gnus-header-face-alist)
6946 (goto-char (point-min))
6947 (setq regexp (concat "^\\("
6948 (if (string-equal "" (nth 0 entry))
6952 header-face (nth 1 entry)
6953 field-face (nth 2 entry))
6954 (while (and (re-search-forward regexp nil t)
6958 (unless (search-forward ":" nil t)
6960 (when (and header-face
6961 (not (memq (point) hpoints)))
6962 (push (point) hpoints)
6963 (gnus-put-text-property from (point) 'face header-face))
6964 (when (and field-face
6965 (not (memq (setq from (point)) fpoints)))
6967 (if (re-search-forward "^[^ \t]" nil t)
6969 (goto-char (point-max)))
6970 (gnus-put-text-property from (point) 'face field-face)))))))
6972 (defun gnus-article-highlight-signature ()
6973 "Highlight the signature in an article.
6974 It does this by highlighting everything after
6975 `gnus-signature-separator' using `gnus-signature-face'."
6977 (when gnus-signature-face
6978 (gnus-with-article-buffer
6979 (let ((inhibit-point-motion-hooks t))
6981 (when (gnus-article-narrow-to-signature)
6982 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6983 'face gnus-signature-face)))))))
6985 (defun gnus-article-buttonize-signature ()
6986 "Add button to the signature."
6989 (set-buffer gnus-article-buffer)
6990 (let ((inhibit-read-only t)
6991 (inhibit-point-motion-hooks t))
6992 (when (gnus-article-search-signature)
6993 (gnus-article-add-button (match-beginning 0) (match-end 0)
6994 'gnus-signature-toggle
6995 (set-marker (make-marker)
6996 (1+ (match-end 0))))))))
6998 (defun gnus-button-in-region-p (b e prop)
6999 "Say whether PROP exists in the region."
7000 (text-property-not-all b e prop nil))
7002 (defun gnus-article-add-buttons (&optional force)
7003 "Find external references in the article and make buttons of them.
7004 \"External references\" are things like Message-IDs and URLs, as
7005 specified by `gnus-button-alist'."
7006 (interactive (list 'force))
7007 (gnus-with-article-buffer
7008 (let ((inhibit-point-motion-hooks t)
7009 (case-fold-search t)
7010 (alist gnus-button-alist)
7012 ;; Remove all old markers.
7013 (let (marker entry new-list)
7014 (while (setq marker (pop gnus-button-marker-list))
7015 (if (or (< marker (point-min)) (>= marker (point-max)))
7016 (push marker new-list)
7018 (when (setq entry (gnus-button-entry))
7019 (put-text-property (match-beginning (nth 1 entry))
7020 (match-end (nth 1 entry))
7021 'gnus-callback nil))
7022 (set-marker marker nil)))
7023 (setq gnus-button-marker-list new-list))
7024 ;; We skip the headers.
7027 (while (setq entry (pop alist))
7028 (setq regexp (eval (car entry)))
7030 (while (re-search-forward regexp nil t)
7031 (let* ((start (and entry (match-beginning (nth 1 entry))))
7032 (end (and entry (match-end (nth 1 entry))))
7033 (from (match-beginning 0)))
7034 (when (and (or (eq t (nth 2 entry))
7035 (eval (nth 2 entry)))
7036 (not (gnus-button-in-region-p
7037 start end 'gnus-callback)))
7038 ;; That optional form returned non-nil, so we add the
7040 (gnus-article-add-button
7041 start end 'gnus-button-push
7042 (car (push (set-marker (make-marker) from)
7043 gnus-button-marker-list))))))))))
7045 ;; Add buttons to the head of an article.
7046 (defun gnus-article-add-buttons-to-head ()
7047 "Add buttons to the head of the article."
7049 (gnus-with-article-headers
7051 (dolist (entry gnus-header-button-alist)
7052 ;; Each alist entry.
7053 (goto-char (point-min))
7054 (while (re-search-forward (car entry) nil t)
7055 ;; Each header matching the entry.
7056 (setq beg (match-beginning 0))
7057 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7058 (match-beginning 0))
7061 (while (re-search-forward (eval (nth 1 entry)) end t)
7062 ;; Each match within a header.
7063 (let* ((entry (cdr entry))
7064 (start (match-beginning (nth 1 entry)))
7065 (end (match-end (nth 1 entry)))
7066 (form (nth 2 entry)))
7067 (goto-char (match-end 0))
7069 (gnus-article-add-button
7070 start end (nth 3 entry)
7071 (buffer-substring (match-beginning (nth 4 entry))
7072 (match-end (nth 4 entry)))))))
7073 (goto-char end))))))
7075 ;;; External functions:
7077 (defun gnus-article-add-button (from to fun &optional data)
7078 "Create a button between FROM and TO with callback FUN and data DATA."
7079 (when gnus-article-button-face
7080 (gnus-overlay-put (gnus-make-overlay from to)
7081 'face gnus-article-button-face))
7082 (gnus-add-text-properties
7084 (nconc (and gnus-article-mouse-face
7085 (list gnus-mouse-face-prop gnus-article-mouse-face))
7086 (list 'gnus-callback fun)
7087 (and data (list 'gnus-data data))))
7088 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7089 :button-keymap gnus-widget-button-keymap))
7091 ;;; Internal functions:
7093 (defun gnus-article-set-globals ()
7094 (with-current-buffer gnus-summary-buffer
7095 (gnus-set-global-variables)))
7097 (defun gnus-signature-toggle (end)
7098 (gnus-with-article-buffer
7099 (let ((inhibit-point-motion-hooks t)
7100 (limit (next-single-property-change end 'mime-view-entity
7102 (if (text-property-any end limit 'article-type 'signature)
7104 (gnus-delete-wash-type 'signature)
7105 (gnus-remove-text-properties-when
7106 'article-type 'signature end limit
7107 (cons 'article-type (cons 'signature
7108 gnus-hidden-properties))))
7109 (gnus-add-wash-type 'signature)
7110 (gnus-add-text-properties-when
7111 'article-type nil end limit
7112 (cons 'article-type (cons 'signature
7113 gnus-hidden-properties)))))
7114 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7115 (gnus-set-mode-line 'article))))
7117 (defun gnus-button-entry ()
7118 ;; Return the first entry in `gnus-button-alist' matching this place.
7119 (let ((alist gnus-button-alist)
7122 (setq entry (pop alist))
7123 (if (looking-at (eval (car entry)))
7128 (defun gnus-button-push (marker)
7129 ;; Push button starting at MARKER.
7132 (let* ((entry (gnus-button-entry))
7133 (inhibit-point-motion-hooks t)
7135 (args (mapcar (lambda (group)
7136 (let ((string (match-string group)))
7137 (set-text-properties
7138 0 (length string) nil string)
7145 (fboundp (symbol-value fun)))
7146 (apply (symbol-value fun) args))
7148 (gnus-message 1 "You must define `%S' to use this button"
7149 (cons fun args)))))))
7151 (defun gnus-parse-news-url (url)
7152 (let (scheme server group message-id articles)
7155 (goto-char (point-min))
7156 (when (looking-at "\\([A-Za-z]+\\):")
7157 (setq scheme (match-string 1))
7158 (goto-char (match-end 0)))
7159 (when (looking-at "//\\([^/]+\\)/")
7160 (setq server (match-string 1))
7161 (goto-char (match-end 0)))
7164 ((looking-at "\\(.*@.*\\)")
7165 (setq message-id (match-string 1)))
7166 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7167 (setq group (match-string 1)
7168 articles (split-string (match-string 2) "-")))
7169 ((looking-at "\\([^/]+\\)/?")
7170 (setq group (match-string 1)))
7172 (error "Unknown news URL syntax"))))
7173 (list scheme server group message-id articles)))
7175 (defun gnus-button-handle-news (url)
7177 (destructuring-bind (scheme server group message-id articles)
7178 (gnus-parse-news-url url)
7182 (set-buffer gnus-summary-buffer)
7184 (let ((gnus-refer-article-method (list (list 'nntp server))))
7185 (gnus-summary-refer-article message-id))
7186 (gnus-summary-refer-article message-id))))
7188 (gnus-button-fetch-group url)))))
7190 (defun gnus-button-handle-man (url)
7192 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7193 (when (eq gnus-button-man-handler 'woman)
7194 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7195 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7196 (funcall gnus-button-man-handler url))
7198 (defun gnus-button-handle-info-url (url)
7199 "Fetch an info URL."
7200 (setq url (mm-subst-char-in-string ?+ ?\ url))
7202 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7203 (gnus-info-find-node
7204 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7206 ")" (gnus-url-unhex-string (match-string 2 url)))))
7207 ((string-match "([^)\"]+)[^\"]+" url)
7209 (gnus-replace-in-string
7210 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7211 (gnus-info-find-node url))
7212 (t (error "Can't parse %s" url))))
7214 (defun gnus-button-handle-info-url-gnome (url)
7215 "Fetch GNOME style info URL."
7216 (setq url (mm-subst-char-in-string ?_ ?\ url))
7217 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7218 (gnus-info-find-node
7220 (gnus-url-unhex-string
7221 (match-string 1 url))
7223 (or (gnus-url-unhex-string
7224 (match-string 2 url))
7226 (error "Can't parse %s" url)))
7228 (defun gnus-button-handle-info-url-kde (url)
7229 "Fetch KDE style info URL."
7230 (gnus-info-find-node (gnus-url-unhex-string url)))
7232 (defun gnus-button-handle-info-keystrokes (url)
7233 "Call `info' when pushing the corresponding URL button."
7234 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7239 (defun gnus-button-openpgp (url)
7240 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7242 (mm-url-insert-file-contents-external url)
7243 (pgg-snarf-keys-region (point-min) (point-max))
7244 (pgg-display-output-buffer nil nil nil)))
7246 (defun gnus-button-message-id (message-id)
7248 (with-current-buffer gnus-summary-buffer
7249 (gnus-summary-refer-article message-id)))
7251 (defun gnus-button-fetch-group (address)
7252 "Fetch GROUP specified by ADDRESS."
7253 (if (not (string-match "[:/]" address))
7254 ;; This is just a simple group url.
7255 (gnus-group-read-ephemeral-group address gnus-select-method)
7258 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7260 (error "Can't parse %s" address)
7261 (gnus-group-read-ephemeral-group
7262 (match-string 4 address)
7263 `(nntp ,(match-string 1 address)
7264 (nntp-address ,(match-string 1 address))
7265 (nntp-port-number ,(if (match-end 3)
7266 (match-string 3 address)
7269 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7271 (defun gnus-url-parse-query-string (query &optional downcase)
7272 (let (retval pairs cur key val)
7273 (setq pairs (split-string query "&"))
7275 (setq cur (car pairs)
7277 (if (not (string-match "=" cur))
7279 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7280 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7282 (setq key (downcase key)))
7283 (setq cur (assoc key retval))
7285 (setcdr cur (cons val (cdr cur)))
7286 (setq retval (cons (list key val) retval)))))
7289 (defun gnus-url-mailto (url)
7290 ;; Send mail to someone
7291 (when (string-match "mailto:/*\\(.*\\)" url)
7292 (setq url (substring url (match-beginning 1) nil)))
7293 (let (to args subject func)
7294 (setq args (gnus-url-parse-query-string
7295 (if (string-match "^\\?" url)
7297 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7298 (concat "to=" (match-string 1 url) "&"
7299 (match-string 2 url))
7300 (concat "to=" url)))
7302 subject (cdr-safe (assoc "subject" args)))
7305 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7308 (message-position-on-field (caar args)))
7309 (insert (gnus-replace-in-string
7310 (mapconcat 'identity (reverse (cdar args)) ", ")
7312 (setq args (cdr args)))
7315 (message-goto-subject))))
7317 (defun gnus-button-embedded-url (address)
7318 "Activate ADDRESS with `browse-url'."
7319 (browse-url (gnus-strip-whitespace address)))
7321 ;;; Next/prev buttons in the article buffer.
7323 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7324 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7326 (defvar gnus-prev-page-map
7327 (let ((map (make-sparse-keymap)))
7328 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7329 (define-key map "\r" 'gnus-button-prev-page)
7332 (defvar gnus-next-page-map
7333 (let ((map (make-sparse-keymap)))
7334 (unless (>= emacs-major-version 21)
7335 ;; XEmacs doesn't care.
7336 (set-keymap-parent map gnus-article-mode-map))
7337 (define-key map gnus-mouse-2 'gnus-button-next-page)
7338 (define-key map "\r" 'gnus-button-next-page)
7341 (defun gnus-insert-prev-page-button ()
7343 (inhibit-read-only t)
7344 (situation (get-text-property (point-min) 'mime-view-situation)))
7346 gnus-prev-page-line-format nil
7347 `(keymap ,gnus-prev-page-map
7349 gnus-callback gnus-article-button-prev-page
7350 article-type annotation
7351 mime-view-situation ,situation))
7352 (widget-convert-button
7354 ;; Exclude a newline.
7357 :action 'gnus-button-prev-page
7358 :button-keymap gnus-prev-page-map)))
7360 (defun gnus-button-next-page (&optional args more-args)
7361 "Go to the next page."
7363 (let ((win (selected-window)))
7364 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7365 (gnus-article-next-page)
7366 (select-window win)))
7368 (defun gnus-button-prev-page (&optional args more-args)
7369 "Go to the prev page."
7371 (let ((win (selected-window)))
7372 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7373 (gnus-article-prev-page)
7374 (select-window win)))
7376 (defun gnus-insert-next-page-button ()
7378 (inhibit-read-only t)
7379 (situation (get-text-property (point-min) 'mime-view-situation)))
7380 (gnus-eval-format gnus-next-page-line-format nil
7381 `(keymap ,gnus-next-page-map
7383 gnus-callback gnus-article-button-next-page
7384 article-type annotation
7385 mime-view-situation ,situation))
7386 (widget-convert-button
7388 ;; Exclude a newline.
7391 :action 'gnus-button-next-page
7392 :button-keymap gnus-next-page-map)))
7394 (defun gnus-article-button-next-page (arg)
7395 "Go to the next page."
7397 (let ((win (selected-window)))
7398 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7399 (gnus-article-next-page)
7400 (select-window win)))
7402 (defun gnus-article-button-prev-page (arg)
7403 "Go to the prev page."
7405 (let ((win (selected-window)))
7406 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7407 (gnus-article-prev-page)
7408 (select-window win)))
7410 (defvar gnus-decode-header-methods
7411 '(mail-decode-encoded-word-region)
7412 "List of methods used to decode headers.
7414 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7415 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7416 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7417 whose names match REGEXP.
7420 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7421 mail-decode-encoded-word-region
7422 (\"chinese\" . rfc1843-decode-region))
7425 (defvar gnus-decode-header-methods-cache nil)
7427 (defun gnus-multi-decode-header (start end)
7428 "Apply the functions from `gnus-encoded-word-methods' that match."
7429 (unless (and gnus-decode-header-methods-cache
7430 (eq gnus-newsgroup-name
7431 (car gnus-decode-header-methods-cache)))
7432 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7435 (nconc gnus-decode-header-methods-cache (list x))
7436 (if (and gnus-newsgroup-name
7437 (string-match (car x) gnus-newsgroup-name))
7438 (nconc gnus-decode-header-methods-cache
7440 gnus-decode-header-methods))
7441 (let ((xlist gnus-decode-header-methods-cache))
7444 (narrow-to-region start end)
7446 (funcall (pop xlist) (point-min) (point-max))))))
7449 ;;; Treatment top-level handling.
7452 (defun gnus-treat-article (condition &optional part-number total-parts type)
7453 (let ((length (- (point-max) (point-min)))
7454 (alist gnus-treatment-function-alist)
7455 (article-goto-body-goes-to-point-min-p t)
7459 (let ((list gnus-article-treat-types))
7461 (when (string-match (pop list) type)
7462 (throw 'found t)))))))
7463 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7464 (entity (static-unless (featurep 'xemacs)
7465 (when (eq 'head condition)
7466 (get-text-property (point-min) 'mime-view-entity))))
7467 val elem buttonized)
7468 (gnus-run-hooks 'gnus-part-display-hook)
7469 (unless gnus-inhibit-treatment
7470 (dolist (elem alist)
7473 (when (gnus-buffer-live-p gnus-summary-buffer)
7474 (set-buffer gnus-summary-buffer))
7475 (symbol-value (car elem))))
7476 (when (and (or (consp val)
7478 (gnus-treat-predicate val)
7479 (or (not (get (car elem) 'highlight))
7481 (when (and (not buttonized)
7483 '(gnus-treat-hide-signature
7484 gnus-treat-highlight-signature)))
7485 (gnus-article-buttonize-signature)
7486 (setq buttonized t))
7488 (funcall (cadr elem)))))
7489 ;; FSF Emacsen does not inherit the existing text properties
7490 ;; in the new text, so we should do it for `mime-view-entity'.
7491 (static-unless (featurep 'xemacs)
7493 (put-text-property (point-min) (point-max)
7494 'mime-view-entity entity))))))
7496 ;; Dynamic variables.
7498 (defvar part-number)
7499 (defvar total-parts)
7504 (defun gnus-treat-predicate (val)
7509 (stringp (car val)))
7510 (apply 'gnus-or (mapcar `(lambda (s)
7511 (string-match s ,(or gnus-newsgroup-name "")))
7514 (let ((pred (pop val)))
7517 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7519 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7521 (not (gnus-treat-predicate (car val))))
7523 (equal (car val) type))
7525 (error "%S is not a valid predicate" pred)))))
7535 (eq part-number total-parts))
7539 (error "%S is not a valid value" val))))
7541 (defun gnus-article-encrypt-body (protocol &optional n)
7542 "Encrypt the article body."
7545 (or gnus-article-encrypt-protocol
7546 (completing-read "Encrypt protocol: "
7547 gnus-article-encrypt-protocol-alist
7549 current-prefix-arg))
7550 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7552 (error (format "Can't find the encrypt protocol %s" protocol)))
7553 (if (member gnus-newsgroup-name '("nndraft:delayed"
7556 (error "Can't encrypt the article in group %s"
7557 gnus-newsgroup-name))
7558 (gnus-summary-iterate n
7560 (set-buffer gnus-summary-buffer)
7561 (let ((mail-parse-charset gnus-newsgroup-charset)
7562 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7563 (summary-buffer gnus-summary-buffer)
7565 (gnus-set-global-variables)
7566 (when (gnus-group-read-only-p)
7567 (error "The current newsgroup does not support article encrypt"))
7568 (gnus-summary-show-article t)
7570 (or (mail-header-references gnus-current-headers) ""))
7571 (set-buffer gnus-article-buffer)
7572 (let* ((inhibit-read-only t)
7574 (mapcar (lambda (field)
7575 (and (save-restriction
7576 (message-narrow-to-head)
7577 (goto-char (point-min))
7578 (search-forward field nil t))
7580 (message-narrow-to-field)
7582 (delete-region (point-min) (point-max))
7584 '("Content-Type:" "Content-Transfer-Encoding:"
7585 "Content-Disposition:"))))
7586 (message-narrow-to-head)
7587 (message-remove-header "MIME-Version")
7588 (goto-char (point-max))
7589 (setq point (point))
7590 (insert (apply 'concat headers))
7592 (narrow-to-region point (point-max))
7593 (let ((message-options message-options))
7594 (message-options-set 'message-sender user-mail-address)
7595 (message-options-set 'message-recipients user-mail-address)
7596 (message-options-set 'message-sign-encrypt 'not)
7598 (goto-char (point-min))
7599 (insert "MIME-Version: 1.0\n")
7601 (gnus-summary-edit-article-done
7602 references nil summary-buffer t))
7603 (when gnus-keep-backlog
7604 (gnus-backlog-remove-article
7605 (car gnus-article-current) (cdr gnus-article-current)))
7607 (when (get-buffer gnus-original-article-buffer)
7608 (set-buffer gnus-original-article-buffer)
7609 (setq gnus-original-article nil)))
7610 (when gnus-use-cache
7611 (gnus-cache-update-article
7612 (car gnus-article-current) (cdr gnus-article-current))))))))
7614 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7615 "The following specs can be used:
7616 %t The security MIME type
7619 %D Details if button is pressed")
7621 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7622 "The following specs can be used:
7623 %t The security MIME type
7626 %D Details if button is pressed")
7628 (defvar gnus-mime-security-button-line-format-alist
7629 '((?t gnus-tmp-type ?s)
7630 (?i gnus-tmp-info ?s)
7631 (?d gnus-tmp-details ?s)
7632 (?D gnus-tmp-pressed-details ?s)))
7634 (defvar gnus-mime-security-button-map
7635 (let ((map (make-sparse-keymap)))
7636 (define-key map gnus-mouse-2 'gnus-article-push-button)
7637 (define-key map "\r" 'gnus-article-press-button)
7640 (defvar gnus-mime-security-details-buffer nil)
7642 (defvar gnus-mime-security-button-pressed nil)
7644 (defvar gnus-mime-security-show-details-inline t
7645 "If non-nil, show details in the article buffer.")
7647 (defun gnus-mime-security-verify-or-decrypt (handle)
7648 (mm-remove-parts (cdr handle))
7649 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7650 point (inhibit-read-only t))
7652 (goto-char (car region)))
7654 (narrow-to-region (point) (point))
7655 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7656 (let* ((mm-verify-option 'known)
7657 (mm-decrypt-option 'known)
7658 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7659 (unless (eq nparts (cdr handle))
7660 (mm-destroy-parts (cdr handle))
7661 (setcdr handle nparts))))
7662 (setq point (point))
7663 (gnus-mime-display-security handle)
7664 (goto-char (point-max)))
7666 (delete-region (point) (cdr region))
7667 (set-marker (car region) nil)
7668 (set-marker (cdr region) nil))
7671 (defun gnus-mime-security-show-details (handle)
7672 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7674 (gnus-message 5 "No details.")
7675 (if gnus-mime-security-show-details-inline
7676 (let ((gnus-mime-security-button-pressed
7677 (not (get-text-property (point) 'gnus-mime-details)))
7678 (gnus-mime-security-button-line-format
7679 (get-text-property (point) 'gnus-line-format))
7680 (inhibit-read-only t))
7682 (while (eq (get-text-property (point) 'gnus-line-format)
7683 gnus-mime-security-button-line-format)
7687 (narrow-to-region (point) (point))
7688 (gnus-insert-mime-security-button handle))
7689 (delete-region (point)
7690 (or (text-property-not-all
7693 gnus-mime-security-button-line-format)
7696 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7697 (with-current-buffer gnus-mime-security-details-buffer
7700 (setq gnus-mime-security-details-buffer
7701 (gnus-get-buffer-create "*MIME Security Details*")))
7702 (with-current-buffer gnus-mime-security-details-buffer
7704 (goto-char (point-min)))
7705 (pop-to-buffer gnus-mime-security-details-buffer)))))
7707 (defun gnus-mime-security-press-button (handle)
7709 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7710 (gnus-mime-security-show-details handle)
7711 (gnus-mime-security-verify-or-decrypt handle))))
7713 (defun gnus-insert-mime-security-button (handle &optional displayed)
7714 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7717 (or (nth 2 (assoc protocol mm-verify-function-alist))
7718 (nth 2 (assoc protocol mm-decrypt-function-alist))
7720 (if (equal (car handle) "multipart/signed")
7721 " Signed" " Encrypted")
7724 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7727 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7728 gnus-tmp-pressed-details
7730 (setq gnus-tmp-details
7731 (if gnus-tmp-details
7732 (concat "\n" gnus-tmp-details)
7734 (setq gnus-tmp-pressed-details
7735 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7740 gnus-mime-security-button-line-format
7741 gnus-mime-security-button-line-format-alist
7742 `(keymap ,gnus-mime-security-button-map
7743 gnus-callback gnus-mime-security-press-button
7744 gnus-line-format ,gnus-mime-security-button-line-format
7745 gnus-mime-details ,gnus-mime-security-button-pressed
7746 article-type annotation
7749 ;; Exclude a newline.
7752 (widget-convert-button
7755 :action 'gnus-widget-press-button
7756 :button-keymap gnus-mime-security-button-map
7758 (lambda (widget/window &optional overlay pos)
7759 ;; Needed to properly clear the message due to a bug in
7760 ;; wid-edit (XEmacs only).
7761 (when (boundp 'help-echo-owns-message)
7762 (setq help-echo-owns-message t))
7765 (aref gnus-mouse-2 0))))))
7767 (defun gnus-mime-display-security (handle)
7769 (narrow-to-region (point) (point))
7770 (unless (gnus-unbuttonized-mime-type-p (car handle))
7771 (gnus-insert-mime-security-button handle))
7772 (gnus-mime-display-mixed (cdr handle))
7775 (unless (gnus-unbuttonized-mime-type-p (car handle))
7776 (let ((gnus-mime-security-button-line-format
7777 gnus-mime-security-button-end-line-format))
7778 (gnus-insert-mime-security-button handle)))
7779 (mm-set-handle-multipart-parameter
7781 (cons (set-marker (make-marker) (point-min))
7782 (set-marker (make-marker) (point-max))))))
7788 (defun gnus-article-header-presentation-method (entity situation)
7789 (mime-insert-header entity)
7790 (article-decode-group-name))
7792 (set-alist 'mime-header-presentation-method-alist
7793 'gnus-original-article-mode
7794 #'gnus-article-header-presentation-method)
7796 (defun gnus-mime-preview-quitting-method ()
7797 (mime-preview-kill-buffer)
7798 (delete-other-windows)
7799 (gnus-article-show-summary)
7800 (gnus-summary-select-article gnus-show-all-headers t))
7802 (set-alist 'mime-preview-quitting-method-alist
7803 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7805 (set-alist 'mime-preview-following-method-alist
7806 'gnus-original-article-mode #'gnus-following-method)
7808 (set-alist 'mime-preview-over-to-previous-method-alist
7809 'gnus-original-article-mode
7811 (if (> (point-min) 1)
7812 (gnus-article-prev-page)
7813 (gnus-article-read-summary-keys
7814 nil (gnus-character-to-event ?P)))))
7816 (set-alist 'mime-preview-over-to-next-method-alist
7817 'gnus-original-article-mode'
7819 (if (< (point-max) (buffer-size))
7820 (gnus-article-next-page)
7821 (gnus-article-read-summary-keys
7822 nil (gnus-character-to-event ?N)))))
7832 (run-hooks 'gnus-art-load-hook)
7834 ;;; gnus-art.el ends here