1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
46 (autoload 'gnus-msg-mail "gnus-msg" nil t)
47 (autoload 'gnus-button-mailto "gnus-msg")
48 (autoload 'gnus-button-reply "gnus-msg" nil t)
49 (autoload 'ansi-color-apply-on-region "ansi-color")
51 (defgroup gnus-article nil
53 :link '(custom-manual "(gnus)Article Buffer")
56 (defgroup gnus-article-treat nil
57 "Treating article parts."
58 :link '(custom-manual "(gnus)Article Hiding")
61 (defgroup gnus-article-hiding nil
62 "Hiding article parts."
63 :link '(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-highlight nil
67 "Article highlighting."
68 :link '(custom-manual "(gnus)Article Highlighting")
72 (defgroup gnus-article-signature nil
74 :link '(custom-manual "(gnus)Article Signature")
77 (defgroup gnus-article-headers nil
79 :link '(custom-manual "(gnus)Hiding Headers")
82 (defgroup gnus-article-washing nil
83 "Special commands on articles."
84 :link '(custom-manual "(gnus)Article Washing")
87 (defgroup gnus-article-emphasis nil
88 "Fontisizing articles."
89 :link '(custom-manual "(gnus)Article Fontisizing")
92 (defgroup gnus-article-saving nil
94 :link '(custom-manual "(gnus)Saving Articles")
97 (defgroup gnus-article-mime nil
98 "Worshiping the MIME wonder."
99 :link '(custom-manual "(gnus)Using MIME")
100 :group 'gnus-article)
102 (defgroup gnus-article-buttons nil
103 "Pushable buttons in the article buffer."
104 :link '(custom-manual "(gnus)Article Buttons")
105 :group 'gnus-article)
107 (defgroup gnus-article-various nil
108 "Other article options."
109 :link '(custom-manual "(gnus)Misc Article")
110 :group 'gnus-article)
112 (defcustom gnus-ignored-headers
115 (concat "^" header ":"))
116 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
117 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
118 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
119 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
120 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
121 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
122 "X-Attribution" "X-Originating-IP" "Delivered-To"
123 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
124 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
125 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
126 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
127 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
128 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
129 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
130 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
131 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
132 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
133 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
134 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
135 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
136 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
137 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
138 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
139 "List-[A-Za-z]+" "X-Listprocessor-Version"
140 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
141 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
142 "X-Received" "Content-length" "X-precedence"
143 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
144 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
145 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
146 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
147 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
148 "X-Content-length" "X-Posting-Agent" "Original-Received"
149 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
150 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
151 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
152 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
153 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
154 "*All headers that start with this regexp will be hidden.
155 This variable can also be a list of regexps of headers to be ignored.
156 If `gnus-visible-headers' is non-nil, this variable will be ignored."
157 :type '(choice :custom-show nil
160 :group 'gnus-article-hiding)
162 (defcustom gnus-visible-headers
163 "^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:"
164 "*All headers that do not match this regexp will be hidden.
165 This variable can also be a list of regexp of headers to remain visible.
166 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
167 :type '(repeat :value-to-internal (lambda (widget value)
168 (custom-split-regexp-maybe value))
169 :match (lambda (widget value)
171 (widget-editable-list-match widget value)))
173 :group 'gnus-article-hiding)
175 (defcustom gnus-sorted-header-list
176 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
177 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
178 "*This variable is a list of regular expressions.
179 If it is non-nil, headers that match the regular expressions will
180 be placed first in the article buffer in the sequence specified by
182 :type '(repeat regexp)
183 :group 'gnus-article-hiding)
185 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
186 "Headers that are only to be displayed if they have interesting data.
187 Possible values in this list are:
189 'empty Headers with no content.
190 'newsgroups Newsgroup identical to Gnus group.
191 'to-address To identical to To-address.
192 'to-list To identical to To-list.
193 'cc-list CC identical to To-list.
194 'followup-to Followup-to identical to Newsgroups.
195 'reply-to Reply-to identical to From.
196 'date Date less than four days old.
197 'long-to To and/or Cc longer than 1024 characters.
198 'many-to Multiple To and/or Cc."
199 :type '(set (const :tag "Headers with no content." empty)
200 (const :tag "Newsgroups identical to Gnus group." newsgroups)
201 (const :tag "To identical to To-address." to-address)
202 (const :tag "To identical to To-list." to-list)
203 (const :tag "CC identical to To-list." cc-list)
204 (const :tag "Followup-to identical to Newsgroups." followup-to)
205 (const :tag "Reply-to identical to From." reply-to)
206 (const :tag "Date less than four days old." date)
207 (const :tag "To and/or Cc longer than 1024 characters." long-to)
208 (const :tag "Multiple To and/or Cc headers." many-to))
209 :group 'gnus-article-hiding)
211 (defcustom gnus-article-skip-boring nil
212 "Skip over text that is not worth reading.
213 By default, if you set this t, then Gnus will display citations and
214 signatures, but will never scroll down to show you a page consisting
215 only of boring text. Boring text is controlled by
216 `gnus-article-boring-faces'."
219 :group 'gnus-article-hiding)
221 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
222 "Regexp matching signature separator.
223 This can also be a list of regexps. In that case, it will be checked
224 from head to tail looking for a separator. Searches will be done from
225 the end of the buffer."
226 :type '(repeat string)
227 :group 'gnus-article-signature)
229 (defcustom gnus-signature-limit nil
230 "Provide a limit to what is considered a signature.
231 If it is a number, no signature may not be longer (in characters) than
232 that number. If it is a floating point number, no signature may be
233 longer (in lines) than that number. If it is a function, the function
234 will be called without any parameters, and if it returns nil, there is
235 no signature in the buffer. If it is a string, it will be used as a
236 regexp. If it matches, the text in question is not a signature.
238 This can also be a list of the above values."
239 :type '(choice (integer :value 200)
241 (function :value fun)
242 (regexp :value ".*"))
243 :group 'gnus-article-signature)
245 (defcustom gnus-hidden-properties '(invisible t intangible t)
246 "Property list to use for hiding text."
248 :group 'gnus-article-hiding)
250 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
251 ;; frames in a session.
252 (defcustom gnus-article-x-face-command
253 (if (featurep 'xemacs)
254 (if (or (gnus-image-type-available-p 'xface)
255 (gnus-image-type-available-p 'pbm))
256 'gnus-display-x-face-in-from
257 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
258 (if (gnus-image-type-available-p 'pbm)
259 'gnus-display-x-face-in-from
260 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
262 "*String or function to be executed to display an X-Face header.
263 If it is a string, the command will be executed in a sub-shell
264 asynchronously. The compressed face will be piped to this command."
265 :type `(choice string
266 (function-item gnus-display-x-face-in-from)
270 :group 'gnus-article-washing)
272 (defcustom gnus-article-x-face-too-ugly nil
273 "Regexp matching posters whose face shouldn't be shown automatically."
274 :type '(choice regexp (const nil))
275 :group 'gnus-article-washing)
277 (defcustom gnus-article-banner-alist nil
278 "Banner alist for stripping.
280 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
282 :type '(repeat (cons symbol regexp))
283 :group 'gnus-article-washing)
285 (gnus-define-group-parameter
288 "Alist of regexps (to match group names) and banner."
289 :variable-group gnus-article-washing
291 '(choice :tag "Banner"
293 (const :tag "Remove signature" signature)
294 (symbol :tag "Item in `gnus-article-banner-alist'" none)
296 (const :tag "None" nil))
298 "If non-nil, specify how to remove `banners' from articles.
300 Symbol `signature' means to remove signatures delimited by
301 `gnus-signature-separator'. Any other symbol is used to look up a
302 regular expression to match the banner in `gnus-article-banner-alist'.
303 A string is used as a regular expression to match the banner
306 (defcustom gnus-article-address-banner-alist nil
307 "Alist of mail addresses and banners.
308 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
309 to match a mail address in the From: header, BANNER is one of a symbol
310 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
311 If ADDRESS matches author's mail address, it will remove things like
312 advertisements. For example:
314 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
318 (regexp :tag "Address")
319 (choice :tag "Banner" :value nil
320 (const :tag "Remove signature" signature)
321 (symbol :tag "Item in `gnus-article-banner-alist'" none)
323 (const :tag "None" nil))))
325 :group 'gnus-article-washing)
327 (defmacro gnus-emphasis-custom-with-format (&rest body)
329 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
330 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
333 (defun gnus-emphasis-custom-value-to-external (value)
334 (gnus-emphasis-custom-with-format
335 (if (consp (car value))
336 (list (format format (car (car value)) (cdr (car value)))
338 (if (nth 1 value) 2 3)
342 (defun gnus-emphasis-custom-value-to-internal (value)
343 (gnus-emphasis-custom-with-format
344 (let ((regexp (concat "\\`"
345 (format (regexp-quote format)
346 "\\([^()]+\\)" "\\([^()]+\\)")
349 (if (string-match regexp (setq pattern (car value)))
350 (list (cons (match-string 1 pattern) (match-string 2 pattern))
355 (defcustom gnus-emphasis-alist
357 '(("\\*" "\\*" bold nil 2)
360 ("_/" "/_" underline-italic)
361 ("_\\*" "\\*_" underline-bold)
362 ("\\*/" "/\\*" bold-italic)
363 ("_\\*/" "/\\*_" underline-bold-italic))))
365 (gnus-emphasis-custom-with-format
366 (mapcar (lambda (spec)
367 (list (format format (car spec) (cadr spec))
370 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
372 '(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
373 2 3 gnus-emphasis-underline))))
374 "*Alist that says how to fontify certain phrases.
375 Each item looks like this:
377 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
379 The first element is a regular expression to be matched. The second
380 is a number that says what regular expression grouping used to find
381 the entire emphasized word. The third is a number that says what
382 regexp grouping should be displayed and highlighted. The fourth
383 is the face used for highlighting."
387 :format "%[Customizing Style%]\n%v"
389 (group :tag "Default"
390 :value ("" 0 0 default)
393 (let ((value (widget-get
394 (cadr (widget-get (widget-get widget :parent)
397 (if (not (eq (nth 2 value) 'default))
401 (gnus-emphasis-custom-value-to-external value))))
402 (widget-group-value-create widget))
404 (integer :format "Match group: %v")
405 (integer :format "Emphasize group: %v")
408 :value (("_" . "_") nil default)
410 (regexp :format "Start regexp: %v")
411 (regexp :format "End regexp: %v"))
412 (boolean :format "Show start and end patterns: %[%v%]\n"
413 :on " On " :off " Off ")
415 :get (lambda (symbol)
416 (mapcar 'gnus-emphasis-custom-value-to-internal
417 (default-value symbol)))
418 :set (lambda (symbol value)
419 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
421 :group 'gnus-article-emphasis)
423 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
424 "A regexp to describe whitespace which should not be emphasized.
425 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
426 The former avoids underlining of leading and trailing whitespace,
427 and the latter avoids underlining any whitespace at all."
429 :group 'gnus-article-emphasis
432 (defface gnus-emphasis-bold '((t (:bold t)))
433 "Face used for displaying strong emphasized text (*word*)."
434 :group 'gnus-article-emphasis)
436 (defface gnus-emphasis-italic '((t (:italic t)))
437 "Face used for displaying italic emphasized text (/word/)."
438 :group 'gnus-article-emphasis)
440 (defface gnus-emphasis-underline '((t (:underline t)))
441 "Face used for displaying underlined emphasized text (_word_)."
442 :group 'gnus-article-emphasis)
444 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
445 "Face used for displaying underlined bold emphasized text (_*word*_)."
446 :group 'gnus-article-emphasis)
448 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
449 "Face used for displaying underlined italic emphasized text (_/word/_)."
450 :group 'gnus-article-emphasis)
452 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
453 "Face used for displaying bold italic emphasized text (/*word*/)."
454 :group 'gnus-article-emphasis)
456 (defface gnus-emphasis-underline-bold-italic
457 '((t (:bold t :italic t :underline t)))
458 "Face used for displaying underlined bold italic emphasized text.
459 Example: (_/*word*/_)."
460 :group 'gnus-article-emphasis)
462 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
463 '((t (:strikethru t)))
464 '((t (:strike-through t))))
465 "Face used for displaying strike-through text (-word-)."
466 :group 'gnus-article-emphasis)
468 (defface gnus-emphasis-highlight-words
469 '((t (:background "black" :foreground "yellow")))
470 "Face used for displaying highlighted words."
471 :group 'gnus-article-emphasis)
473 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
474 "Format for display of Date headers in article bodies.
475 See `format-time-string' for the possible values.
477 The variable can also be function, which should return a complete Date
478 header. The function is called with one argument, the time, which can
479 be fed to `format-time-string'."
480 :type '(choice string function)
481 :link '(custom-manual "(gnus)Article Date")
482 :group 'gnus-article-washing)
485 (autoload 'mail-extract-address-components "mail-extr"))
487 (defcustom gnus-save-all-headers t
488 "*If non-nil, don't remove any headers before saving."
489 :group 'gnus-article-saving
492 (defcustom gnus-prompt-before-saving 'always
493 "*This variable says how much prompting is to be done when saving articles.
494 If it is nil, no prompting will be done, and the articles will be
495 saved to the default files. If this variable is `always', each and
496 every article that is saved will be preceded by a prompt, even when
497 saving large batches of articles. If this variable is neither nil not
498 `always', there the user will be prompted once for a file name for
499 each invocation of the saving commands."
500 :group 'gnus-article-saving
501 :type '(choice (item always)
502 (item :tag "never" nil)
503 (sexp :tag "once" :format "%t\n" :value t)))
505 (defcustom gnus-saved-headers gnus-visible-headers
506 "Headers to keep if `gnus-save-all-headers' is nil.
507 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
508 If that variable is nil, however, all headers that match this regexp
509 will be kept while the rest will be deleted before saving."
510 :group 'gnus-article-saving
513 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
514 "A function to save articles in your favourite format.
515 The function must be interactively callable (in other words, it must
516 be an Emacs command).
518 Gnus provides the following functions:
520 * gnus-summary-save-in-rmail (Rmail format)
521 * gnus-summary-save-in-mail (Unix mail format)
522 * gnus-summary-save-in-folder (MH folder)
523 * gnus-summary-save-in-file (article format)
524 * gnus-summary-save-body-in-file (article body)
525 * gnus-summary-save-in-vm (use VM's folder format)
526 * gnus-summary-write-to-file (article format -- overwrite)."
527 :group 'gnus-article-saving
528 :type '(radio (function-item gnus-summary-save-in-rmail)
529 (function-item gnus-summary-save-in-mail)
530 (function-item gnus-summary-save-in-folder)
531 (function-item gnus-summary-save-in-file)
532 (function-item gnus-summary-save-body-in-file)
533 (function-item gnus-summary-save-in-vm)
534 (function-item gnus-summary-write-to-file)))
536 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
537 "A function generating a file name to save articles in Rmail format.
538 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
539 :group 'gnus-article-saving
542 (defcustom gnus-mail-save-name 'gnus-plain-save-name
543 "A function generating a file name to save articles in Unix mail format.
544 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
545 :group 'gnus-article-saving
548 (defcustom gnus-folder-save-name 'gnus-folder-save-name
549 "A function generating a file name to save articles in MH folder.
550 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
551 :group 'gnus-article-saving
554 (defcustom gnus-file-save-name 'gnus-numeric-save-name
555 "A function generating a file name to save articles in article format.
556 The function is called with NEWSGROUP, HEADERS, and optional
558 :group 'gnus-article-saving
561 (defcustom gnus-split-methods
562 '((gnus-article-archive-name)
563 (gnus-article-nndoc-name))
564 "*Variable used to suggest where articles are to be saved.
565 For instance, if you would like to save articles related to Gnus in
566 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
567 you could set this variable to something like:
569 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
570 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
572 This variable is an alist where the key is the match and the
573 value is a list of possible files to save in if the match is
576 If the match is a string, it is used as a regexp match on the
577 article. If the match is a symbol, that symbol will be funcalled
578 from the buffer of the article to be saved with the newsgroup as
579 the parameter. If it is a list, it will be evaled in the same
582 If this form or function returns a string, this string will be
583 used as a possible file name; and if it returns a non-nil list,
584 that list will be used as possible file names."
585 :group 'gnus-article-saving
586 :type '(repeat (choice (list :value (fun) function)
587 (cons :value ("" "") regexp (repeat string))
590 (defcustom gnus-page-delimiter "^\^L"
591 "*Regexp describing what to use as article page delimiters.
592 The default value is \"^\^L\", which is a form linefeed at the
593 beginning of a line."
595 :group 'gnus-article-various)
597 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
598 "*The format specification for the article mode line.
599 See `gnus-summary-mode-line-format' for a closer description.
601 The following additional specs are available:
603 %w The article washing status.
604 %m The number of MIME parts in the article."
606 :group 'gnus-article-various)
608 (defcustom gnus-article-mode-hook nil
609 "*A hook for Gnus article mode."
611 :group 'gnus-article-various)
613 (when (featurep 'xemacs)
614 ;; Extracted from gnus-xmas-define in order to preserve user settings
615 (when (fboundp 'turn-off-scroll-in-place)
616 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
617 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
618 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
620 (defcustom gnus-article-menu-hook nil
621 "*Hook run after the creation of the article mode menu."
623 :group 'gnus-article-various)
625 (defcustom gnus-article-prepare-hook nil
626 "*A hook called after an article has been prepared in the article buffer."
628 :group 'gnus-article-various)
630 (defcustom gnus-copy-article-ignored-headers nil
631 "List of headers to be removed when copying an article.
632 Each element is a regular expression."
633 :version "22.0" ;; No Gnus
634 :type '(repeat regexp)
635 :group 'gnus-article-various)
637 (make-obsolete-variable 'gnus-article-hide-pgp-hook
638 "This variable is obsolete in Gnus 5.10.")
640 (defcustom gnus-article-button-face 'bold
641 "Face used for highlighting buttons in the article buffer.
643 An article button is a piece of text that you can activate by pressing
644 `RET' or `mouse-2' above it."
646 :group 'gnus-article-buttons)
648 (defcustom gnus-article-mouse-face 'highlight
649 "Face used for mouse highlighting in the article buffer.
651 Article buttons will be displayed in this face when the cursor is
654 :group 'gnus-article-buttons)
656 (defcustom gnus-signature-face 'gnus-signature-face
657 "Face used for highlighting a signature in the article buffer.
658 Obsolete; use the face `gnus-signature-face' for customizations instead."
660 :group 'gnus-article-highlight
661 :group 'gnus-article-signature)
663 (defface gnus-signature-face
666 "Face used for highlighting a signature in the article buffer."
667 :group 'gnus-article-highlight
668 :group 'gnus-article-signature)
670 (defface gnus-header-from-face
673 (:foreground "spring green"))
676 (:foreground "red3"))
679 "Face used for displaying from headers."
680 :group 'gnus-article-headers
681 :group 'gnus-article-highlight)
683 (defface gnus-header-subject-face
686 (:foreground "SeaGreen3"))
689 (:foreground "red4"))
691 (:bold t :italic t)))
692 "Face used for displaying subject headers."
693 :group 'gnus-article-headers
694 :group 'gnus-article-highlight)
696 (defface gnus-header-newsgroups-face
699 (:foreground "yellow" :italic t))
702 (:foreground "MidnightBlue" :italic t))
705 "Face used for displaying newsgroups headers.
706 In the default setup this face is only used for crossposted
708 :group 'gnus-article-headers
709 :group 'gnus-article-highlight)
711 (defface gnus-header-name-face
714 (:foreground "SeaGreen"))
717 (:foreground "maroon"))
720 "Face used for displaying header names."
721 :group 'gnus-article-headers
722 :group 'gnus-article-highlight)
724 (defface gnus-header-content-face
727 (:foreground "forest green" :italic t))
730 (:foreground "indianred4" :italic t))
732 (:italic t))) "Face used for displaying header content."
733 :group 'gnus-article-headers
734 :group 'gnus-article-highlight)
736 (defcustom gnus-header-face-alist
737 '(("From" nil gnus-header-from-face)
738 ("Subject" nil gnus-header-subject-face)
739 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
740 ("" gnus-header-name-face gnus-header-content-face))
741 "*Controls highlighting of article headers.
743 An alist of the form (HEADER NAME CONTENT).
745 HEADER is a regular expression which should match the name of a
746 header and NAME and CONTENT are either face names or nil.
748 The name of each header field will be displayed using the face
749 specified by the first element in the list where HEADER matches
750 the header name and NAME is non-nil. Similarly, the content will
751 be displayed by the first non-nil matching CONTENT face."
752 :group 'gnus-article-headers
753 :group 'gnus-article-highlight
754 :type '(repeat (list (regexp :tag "Header")
756 (item :tag "skip" nil)
757 (face :value default))
758 (choice :tag "Content"
759 (item :tag "skip" nil)
760 (face :value default)))))
762 (defcustom gnus-article-decode-hook
763 '(article-decode-charset article-decode-encoded-words
764 article-decode-group-name article-decode-idna-rhs)
765 "*Hook run to decode charsets in articles."
766 :group 'gnus-article-headers
769 (defcustom gnus-display-mime-function 'gnus-display-mime
770 "Function to display MIME articles."
771 :group 'gnus-article-mime
774 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
775 "Function used to decode headers.")
777 (defvar gnus-article-dumbquotes-map
797 "Table for MS-to-Latin1 translation.")
799 (defcustom gnus-ignored-mime-types nil
800 "List of MIME types that should be ignored by Gnus."
802 :group 'gnus-article-mime
803 :type '(repeat regexp))
805 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
806 "List of MIME types that should not be given buttons when rendered inline.
807 See also `gnus-buttonized-mime-types' which may override this variable.
808 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
810 :group 'gnus-article-mime
811 :type '(repeat regexp))
813 (defcustom gnus-buttonized-mime-types nil
814 "List of MIME types that should be given buttons when rendered inline.
815 If set, this variable overrides `gnus-unbuttonized-mime-types'.
816 To see e.g. security buttons you could set this to
817 `(\"multipart/signed\")'.
818 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
820 :group 'gnus-article-mime
821 :type '(repeat regexp))
823 (defcustom gnus-inhibit-mime-unbuttonizing nil
824 "If non-nil, all MIME parts get buttons.
825 When nil (the default value), then some MIME parts do not get buttons,
826 as described by the variables `gnus-buttonized-mime-types' and
827 `gnus-unbuttonized-mime-types'."
829 :group 'gnus-article-mime
832 (defcustom gnus-body-boundary-delimiter "_"
833 "String used to delimit header and body.
834 This variable is used by `gnus-article-treat-body-boundary' which can
835 be controlled by `gnus-treat-body-boundary'."
837 :group 'gnus-article-various
838 :type '(choice (item :tag "None" :value nil)
841 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
843 "Defines the location of the faces database.
844 For information on obtaining this database of pretty pictures, please
845 see http://www.cs.indiana.edu/picons/ftp/index.html"
847 :type '(repeat directory)
848 :link '(url-link :tag "download"
849 "http://www.cs.indiana.edu/picons/ftp/index.html")
850 :link '(custom-manual "(gnus)Picons")
853 (defun gnus-picons-installed-p ()
854 "Say whether picons are installed on your machine."
855 (let ((installed nil))
856 (dolist (database gnus-picon-databases)
857 (when (file-exists-p database)
861 (defcustom gnus-article-mime-part-function nil
862 "Function called with a MIME handle as the argument.
863 This is meant for people who want to do something automatic based
864 on parts -- for instance, adding Vcard info to a database."
865 :group 'gnus-article-mime
868 (defcustom gnus-mime-multipart-functions nil
869 "An alist of MIME types to functions to display them."
871 :group 'gnus-article-mime
872 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
874 (defcustom gnus-article-date-lapsed-new-header nil
875 "Whether the X-Sent and Date headers can coexist.
876 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
877 either replace the old \"Date:\" header (if this variable is nil), or
878 be added below it (otherwise)."
880 :group 'gnus-article-headers
883 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
884 "Function called with a MIME handle as the argument.
885 This is meant for people who want to view first matched part.
886 For `undisplayed-alternative' (default), the first undisplayed
887 part or alternative part is used. For `undisplayed', the first
888 undisplayed part is used. For a function, the first part which
889 the function return t is used. For nil, the first part is
892 :group 'gnus-article-mime
894 (item :tag "first" :value nil)
895 (item :tag "undisplayed" :value undisplayed)
896 (item :tag "undisplayed or alternative"
897 :value undisplayed-alternative)
900 (defcustom gnus-mime-action-alist
901 '(("save to file" . gnus-mime-save-part)
902 ("save and strip" . gnus-mime-save-part-and-strip)
903 ("delete part" . gnus-mime-delete-part)
904 ("display as text" . gnus-mime-inline-part)
905 ("view the part" . gnus-mime-view-part)
906 ("pipe to command" . gnus-mime-pipe-part)
907 ("toggle display" . gnus-article-press-button)
908 ("toggle display" . gnus-article-view-part-as-charset)
909 ("view as type" . gnus-mime-view-part-as-type)
910 ("view internally" . gnus-mime-view-part-internally)
911 ("view externally" . gnus-mime-view-part-externally))
912 "An alist of actions that run on the MIME attachment."
913 :group 'gnus-article-mime
914 :type '(repeat (cons (string :tag "name")
918 ;;; The treatment variables
921 (defvar gnus-part-display-hook nil
922 "Hook called on parts that are to receive treatment.")
924 (defvar gnus-article-treat-custom
925 '(choice (const :tag "Off" nil)
927 (const :tag "Header" head)
928 (const :tag "Last" last)
929 (integer :tag "Less")
930 (repeat :tag "Groups" regexp)
931 (sexp :tag "Predicate")))
933 (defvar gnus-article-treat-head-custom
934 '(choice (const :tag "Off" nil)
935 (const :tag "Header" head)))
937 (defvar gnus-article-treat-types '("text/plain")
940 (defvar gnus-inhibit-treatment nil
941 "Whether to inhibit treatment.")
943 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
944 "Highlight the signature.
945 Valid values are nil, t, `head', `last', an integer or a predicate.
946 See Info node `(gnus)Customizing Articles'."
947 :group 'gnus-article-treat
948 :link '(custom-manual "(gnus)Customizing Articles")
949 :type gnus-article-treat-custom)
950 (put 'gnus-treat-highlight-signature 'highlight t)
952 (defcustom gnus-treat-buttonize 100000
954 Valid values are nil, t, `head', `last', an integer or a predicate.
955 See Info node `(gnus)Customizing Articles'."
956 :group 'gnus-article-treat
957 :link '(custom-manual "(gnus)Customizing Articles")
958 :type gnus-article-treat-custom)
959 (put 'gnus-treat-buttonize 'highlight t)
961 (defcustom gnus-treat-buttonize-head 'head
962 "Add buttons to the head.
963 Valid values are nil, t, `head', `last', an integer or a predicate.
964 See Info node `(gnus)Customizing Articles' for details."
965 :group 'gnus-article-treat
966 :link '(custom-manual "(gnus)Customizing Articles")
967 :type gnus-article-treat-head-custom)
968 (put 'gnus-treat-buttonize-head 'highlight t)
970 (defcustom gnus-treat-emphasize
971 (and (or window-system
975 Valid values are nil, t, `head', `last', an integer or a predicate.
976 See Info node `(gnus)Customizing Articles' for details."
977 :group 'gnus-article-treat
978 :link '(custom-manual "(gnus)Customizing Articles")
979 :type gnus-article-treat-custom)
980 (put 'gnus-treat-emphasize 'highlight t)
982 (defcustom gnus-treat-strip-cr nil
983 "Remove carriage returns.
984 Valid values are nil, t, `head', `last', an integer or a predicate.
985 See Info node `(gnus)Customizing Articles' for details."
987 :group 'gnus-article-treat
988 :link '(custom-manual "(gnus)Customizing Articles")
989 :type gnus-article-treat-custom)
991 (defcustom gnus-treat-unsplit-urls nil
992 "Remove newlines from within URLs.
993 Valid values are nil, t, `head', `last', an integer or a predicate.
994 See Info node `(gnus)Customizing Articles' for details."
996 :group 'gnus-article-treat
997 :link '(custom-manual "(gnus)Customizing Articles")
998 :type gnus-article-treat-custom)
1000 (defcustom gnus-treat-leading-whitespace nil
1001 "Remove leading whitespace in headers.
1002 Valid values are nil, t, `head', `last', an integer or a predicate.
1003 See Info node `(gnus)Customizing Articles' for details."
1005 :group 'gnus-article-treat
1006 :link '(custom-manual "(gnus)Customizing Articles")
1007 :type gnus-article-treat-custom)
1009 (defcustom gnus-treat-hide-headers 'head
1011 Valid values are nil, t, `head', `last', an integer or a predicate.
1012 See Info node `(gnus)Customizing Articles' for details."
1013 :group 'gnus-article-treat
1014 :link '(custom-manual "(gnus)Customizing Articles")
1015 :type gnus-article-treat-head-custom)
1017 (defcustom gnus-treat-hide-boring-headers nil
1018 "Hide boring headers.
1019 Valid values are nil, t, `head', `last', an integer or a predicate.
1020 See Info node `(gnus)Customizing Articles' for details."
1021 :group 'gnus-article-treat
1022 :link '(custom-manual "(gnus)Customizing Articles")
1023 :type gnus-article-treat-head-custom)
1025 (defcustom gnus-treat-hide-signature nil
1026 "Hide the signature.
1027 Valid values are nil, t, `head', `last', an integer or a predicate.
1028 See Info node `(gnus)Customizing Articles' for details."
1029 :group 'gnus-article-treat
1030 :link '(custom-manual "(gnus)Customizing Articles")
1031 :type gnus-article-treat-custom)
1033 (defcustom gnus-treat-fill-article nil
1035 Valid values are nil, t, `head', `last', an integer or a predicate.
1036 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-hide-citation nil
1043 Valid values are nil, t, `head', `last', an integer or a predicate.
1044 See Info node `(gnus)Customizing Articles' for details."
1045 :group 'gnus-article-treat
1046 :link '(custom-manual "(gnus)Customizing Articles")
1047 :type gnus-article-treat-custom)
1049 (defcustom gnus-treat-hide-citation-maybe nil
1051 Valid values are nil, t, `head', `last', an integer or a predicate.
1052 See Info node `(gnus)Customizing Articles' for details."
1053 :group 'gnus-article-treat
1054 :link '(custom-manual "(gnus)Customizing Articles")
1055 :type gnus-article-treat-custom)
1057 (defcustom gnus-treat-strip-list-identifiers 'head
1058 "Strip list identifiers from `gnus-list-identifiers`.
1059 Valid values are nil, t, `head', `last', an integer or a predicate.
1060 See Info node `(gnus)Customizing Articles' for details."
1062 :group 'gnus-article-treat
1063 :link '(custom-manual "(gnus)Customizing Articles")
1064 :type gnus-article-treat-custom)
1066 (make-obsolete-variable 'gnus-treat-strip-pgp
1067 "This option is obsolete in Gnus 5.10.")
1069 (defcustom gnus-treat-strip-pem nil
1070 "Strip PEM signatures.
1071 Valid values are nil, t, `head', `last', an integer or a predicate.
1072 See Info node `(gnus)Customizing Articles' for details."
1073 :group 'gnus-article-treat
1074 :link '(custom-manual "(gnus)Customizing Articles")
1075 :type gnus-article-treat-custom)
1077 (defcustom gnus-treat-strip-banner t
1078 "Strip banners from articles.
1079 The banner to be stripped is specified in the `banner' group parameter.
1080 Valid values are nil, t, `head', `last', an integer or a predicate.
1081 See Info node `(gnus)Customizing Articles' for details."
1082 :group 'gnus-article-treat
1083 :link '(custom-manual "(gnus)Customizing Articles")
1084 :type gnus-article-treat-custom)
1086 (defcustom gnus-treat-highlight-headers 'head
1087 "Highlight the headers.
1088 Valid values are nil, t, `head', `last', an integer or a predicate.
1089 See Info node `(gnus)Customizing Articles' for details."
1090 :group 'gnus-article-treat
1091 :link '(custom-manual "(gnus)Customizing Articles")
1092 :type gnus-article-treat-head-custom)
1093 (put 'gnus-treat-highlight-headers 'highlight t)
1095 (defcustom gnus-treat-highlight-citation t
1096 "Highlight cited text.
1097 Valid values are nil, t, `head', `last', an integer or a predicate.
1098 See Info node `(gnus)Customizing Articles' for details."
1099 :group 'gnus-article-treat
1100 :link '(custom-manual "(gnus)Customizing Articles")
1101 :type gnus-article-treat-custom)
1102 (put 'gnus-treat-highlight-citation 'highlight t)
1104 (defcustom gnus-treat-date-ut nil
1105 "Display the Date in UT (GMT).
1106 Valid values are nil, t, `head', `last', an integer or a predicate.
1107 See Info node `(gnus)Customizing Articles' for details."
1108 :group 'gnus-article-treat
1109 :link '(custom-manual "(gnus)Customizing Articles")
1110 :type gnus-article-treat-head-custom)
1112 (defcustom gnus-treat-date-local nil
1113 "Display the Date in the local timezone.
1114 Valid values are nil, t, `head', `last', an integer or a predicate.
1115 See Info node `(gnus)Customizing Articles' for details."
1116 :group 'gnus-article-treat
1117 :link '(custom-manual "(gnus)Customizing Articles")
1118 :type gnus-article-treat-head-custom)
1120 (defcustom gnus-treat-date-english nil
1121 "Display the Date in a format that can be read aloud in English.
1122 Valid values are nil, t, `head', `last', an integer or a predicate.
1123 See Info node `(gnus)Customizing Articles' for details."
1125 :group 'gnus-article-treat
1126 :link '(custom-manual "(gnus)Customizing Articles")
1127 :type gnus-article-treat-head-custom)
1129 (defcustom gnus-treat-date-lapsed nil
1130 "Display the Date header in a way that says how much time has elapsed.
1131 Valid values are nil, t, `head', `last', an integer or a predicate.
1132 See Info node `(gnus)Customizing Articles' for details."
1133 :group 'gnus-article-treat
1134 :link '(custom-manual "(gnus)Customizing Articles")
1135 :type gnus-article-treat-head-custom)
1137 (defcustom gnus-treat-date-original nil
1138 "Display the date in the original timezone.
1139 Valid values are nil, t, `head', `last', an integer or a predicate.
1140 See Info node `(gnus)Customizing Articles' for details."
1141 :group 'gnus-article-treat
1142 :link '(custom-manual "(gnus)Customizing Articles")
1143 :type gnus-article-treat-head-custom)
1145 (defcustom gnus-treat-date-iso8601 nil
1146 "Display the date in the ISO8601 format.
1147 Valid values are nil, t, `head', `last', an integer or a predicate.
1148 See Info node `(gnus)Customizing Articles' for details."
1150 :group 'gnus-article-treat
1151 :link '(custom-manual "(gnus)Customizing Articles")
1152 :type gnus-article-treat-head-custom)
1154 (defcustom gnus-treat-date-user-defined nil
1155 "Display the date in a user-defined format.
1156 The format is defined by the `gnus-article-time-format' variable.
1157 Valid values are nil, t, `head', `last', an integer or a predicate.
1158 See Info node `(gnus)Customizing Articles' for details."
1159 :group 'gnus-article-treat
1160 :link '(custom-manual "(gnus)Customizing Articles")
1161 :type gnus-article-treat-head-custom)
1163 (defcustom gnus-treat-strip-headers-in-body t
1164 "Strip the X-No-Archive header line from the beginning of the body.
1165 Valid values are nil, t, `head', `last', an integer or a predicate.
1166 See Info node `(gnus)Customizing Articles' for details."
1168 :group 'gnus-article-treat
1169 :link '(custom-manual "(gnus)Customizing Articles")
1170 :type gnus-article-treat-custom)
1172 (defcustom gnus-treat-strip-trailing-blank-lines nil
1173 "Strip trailing blank lines.
1174 Valid values are nil, t, `head', `last', an integer or a predicate.
1175 See Info node `(gnus)Customizing Articles' for details."
1176 :group 'gnus-article-treat
1177 :link '(custom-manual "(gnus)Customizing Articles")
1178 :type gnus-article-treat-custom)
1180 (defcustom gnus-treat-strip-leading-blank-lines nil
1181 "Strip leading blank lines.
1182 Valid values are nil, t, `head', `last', an integer or a predicate.
1183 See Info node `(gnus)Customizing Articles' for details."
1184 :group 'gnus-article-treat
1185 :link '(custom-manual "(gnus)Customizing Articles")
1186 :type gnus-article-treat-custom)
1188 (defcustom gnus-treat-strip-multiple-blank-lines nil
1189 "Strip multiple blank lines.
1190 Valid values are nil, t, `head', `last', an integer or a predicate.
1191 See Info node `(gnus)Customizing Articles' for details."
1192 :group 'gnus-article-treat
1193 :link '(custom-manual "(gnus)Customizing Articles")
1194 :type gnus-article-treat-custom)
1196 (defcustom gnus-treat-unfold-headers 'head
1197 "Unfold folded header lines.
1198 Valid values are nil, t, `head', `last', an integer or a predicate.
1199 See Info node `(gnus)Customizing Articles' for details."
1201 :group 'gnus-article-treat
1202 :link '(custom-manual "(gnus)Customizing Articles")
1203 :type gnus-article-treat-custom)
1205 (defcustom gnus-treat-fold-headers nil
1207 Valid values are nil, t, `head', `last', an integer or a predicate.
1208 See Info node `(gnus)Customizing Articles' for details."
1210 :group 'gnus-article-treat
1211 :link '(custom-manual "(gnus)Customizing Articles")
1212 :type gnus-article-treat-custom)
1214 (defcustom gnus-treat-fold-newsgroups 'head
1215 "Fold the Newsgroups and Followup-To headers.
1216 Valid values are nil, t, `head', `last', an integer or a predicate.
1217 See Info node `(gnus)Customizing Articles' for details."
1219 :group 'gnus-article-treat
1220 :link '(custom-manual "(gnus)Customizing Articles")
1221 :type gnus-article-treat-custom)
1223 (defcustom gnus-treat-overstrike t
1224 "Treat overstrike highlighting.
1225 Valid values are nil, t, `head', `last', an integer or a predicate.
1226 See Info node `(gnus)Customizing Articles' for details."
1227 :group 'gnus-article-treat
1228 :link '(custom-manual "(gnus)Customizing Articles")
1229 :type gnus-article-treat-custom)
1230 (put 'gnus-treat-overstrike 'highlight t)
1232 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1233 "Treat ANSI SGR control sequences.
1234 Valid values are nil, t, `head', `last', an integer or a predicate.
1235 See Info node `(gnus)Customizing Articles' for details."
1236 :group 'gnus-article-treat
1237 :link '(custom-manual "(gnus)Customizing Articles")
1238 :type gnus-article-treat-custom)
1240 (make-obsolete-variable 'gnus-treat-display-xface
1241 'gnus-treat-display-x-face)
1243 (defcustom gnus-treat-display-x-face
1244 (and (not noninteractive)
1245 (or (and (fboundp 'image-type-available-p)
1246 (image-type-available-p 'xbm)
1247 (string-match "^0x" (shell-command-to-string "uncompface"))
1248 (executable-find "icontopbm"))
1249 (and (featurep 'xemacs)
1252 "Display X-Face headers.
1253 Valid values are nil, t, `head', `last', an integer or a predicate.
1254 See Info node `(gnus)Customizing Articles' and Info node
1255 `(gnus)X-Face' for details."
1256 :group 'gnus-article-treat
1258 :link '(custom-manual "(gnus)Customizing Articles")
1259 :link '(custom-manual "(gnus)X-Face")
1260 :type gnus-article-treat-head-custom
1261 :set (lambda (symbol value)
1264 (cond ((or (boundp symbol) (get symbol 'saved-value))
1266 ((boundp 'gnus-treat-display-xface)
1268 ** gnus-treat-display-xface is an obsolete variable;\
1269 use gnus-treat-display-x-face instead")
1270 (default-value 'gnus-treat-display-xface))
1271 ((get 'gnus-treat-display-xface 'saved-value)
1273 ** gnus-treat-display-xface is an obsolete variable;\
1274 use gnus-treat-display-x-face instead")
1275 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1278 (put 'gnus-treat-display-x-face 'highlight t)
1280 (defcustom gnus-treat-display-face
1281 (and (not noninteractive)
1282 (or (and (fboundp 'image-type-available-p)
1283 (image-type-available-p 'png))
1284 (and (featurep 'xemacs)
1287 "Display Face headers.
1288 Valid values are nil, t, `head', `last', an integer or a predicate.
1289 See Info node `(gnus)Customizing Articles' and Info node
1290 `(gnus)X-Face' for details."
1291 :group 'gnus-article-treat
1293 :link '(custom-manual "(gnus)Customizing Articles")
1294 :link '(custom-manual "(gnus)X-Face")
1295 :type gnus-article-treat-head-custom)
1296 (put 'gnus-treat-display-face 'highlight t)
1298 (defcustom gnus-treat-display-smileys
1299 (if (or (and (featurep 'xemacs)
1301 (and (fboundp 'image-type-available-p)
1302 (image-type-available-p 'pbm)))
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)Smileys' for details."
1308 :group 'gnus-article-treat
1310 :link '(custom-manual "(gnus)Customizing Articles")
1311 :link '(custom-manual "(gnus)Smileys")
1312 :type gnus-article-treat-custom)
1313 (put 'gnus-treat-display-smileys 'highlight t)
1315 (defcustom gnus-treat-from-picon
1316 (if (and (gnus-image-type-available-p 'xpm)
1317 (gnus-picons-installed-p))
1319 "Display picons in the From header.
1320 Valid values are nil, t, `head', `last', an integer or a predicate.
1321 See Info node `(gnus)Customizing Articles' and Info node
1322 `(gnus)Picons' for details."
1324 :group 'gnus-article-treat
1326 :link '(custom-manual "(gnus)Customizing Articles")
1327 :link '(custom-manual "(gnus)Picons")
1328 :type gnus-article-treat-head-custom)
1329 (put 'gnus-treat-from-picon 'highlight t)
1331 (defcustom gnus-treat-mail-picon
1332 (if (and (gnus-image-type-available-p 'xpm)
1333 (gnus-picons-installed-p))
1335 "Display picons in To and Cc headers.
1336 Valid values are nil, t, `head', `last', an integer or a predicate.
1337 See Info node `(gnus)Customizing Articles' and Info node
1338 `(gnus)Picons' for details."
1340 :group 'gnus-article-treat
1342 :link '(custom-manual "(gnus)Customizing Articles")
1343 :link '(custom-manual "(gnus)Picons")
1344 :type gnus-article-treat-head-custom)
1345 (put 'gnus-treat-mail-picon 'highlight t)
1347 (defcustom gnus-treat-newsgroups-picon
1348 (if (and (gnus-image-type-available-p 'xpm)
1349 (gnus-picons-installed-p))
1351 "Display picons in the Newsgroups and Followup-To headers.
1352 Valid values are nil, t, `head', `last', an integer or a predicate.
1353 See Info node `(gnus)Customizing Articles' and Info node
1354 `(gnus)Picons' for details."
1356 :group 'gnus-article-treat
1358 :link '(custom-manual "(gnus)Customizing Articles")
1359 :link '(custom-manual "(gnus)Picons")
1360 :type gnus-article-treat-head-custom)
1361 (put 'gnus-treat-newsgroups-picon 'highlight t)
1363 (defcustom gnus-treat-body-boundary
1364 (if (and (eq window-system 'x)
1365 (or gnus-treat-newsgroups-picon
1366 gnus-treat-mail-picon
1367 gnus-treat-from-picon))
1369 "Draw a boundary at the end of the headers.
1370 Valid values are nil and `head'.
1371 See Info node `(gnus)Customizing Articles' for details."
1373 :group 'gnus-article-treat
1374 :link '(custom-manual "(gnus)Customizing Articles")
1375 :type gnus-article-treat-head-custom)
1377 (defcustom gnus-treat-capitalize-sentences nil
1378 "Capitalize sentence-starting words.
1379 Valid values are nil, t, `head', `last', an integer or a predicate.
1380 See Info node `(gnus)Customizing Articles' for details."
1382 :group 'gnus-article-treat
1383 :link '(custom-manual "(gnus)Customizing Articles")
1384 :type gnus-article-treat-custom)
1386 (defcustom gnus-treat-wash-html nil
1388 Valid values are nil, t, `head', `last', an integer or a predicate.
1389 See Info node `(gnus)Customizing Articles' for details."
1391 :group 'gnus-article-treat
1392 :link '(custom-manual "(gnus)Customizing Articles")
1393 :type gnus-article-treat-custom)
1395 (defcustom gnus-treat-fill-long-lines nil
1397 Valid values are nil, t, `head', `last', an integer or a predicate.
1398 See Info node `(gnus)Customizing Articles' for details."
1399 :group 'gnus-article-treat
1400 :link '(custom-manual "(gnus)Customizing Articles")
1401 :type gnus-article-treat-custom)
1403 (defcustom gnus-treat-play-sounds nil
1405 Valid values are nil, t, `head', `last', an integer or a predicate.
1406 See Info node `(gnus)Customizing Articles' for details."
1408 :group 'gnus-article-treat
1409 :link '(custom-manual "(gnus)Customizing Articles")
1410 :type gnus-article-treat-custom)
1412 (defcustom gnus-treat-translate nil
1413 "Translate articles from one language to another.
1414 Valid values are nil, t, `head', `last', an integer or a predicate.
1415 See Info node `(gnus)Customizing Articles' for details."
1417 :group 'gnus-article-treat
1418 :link '(custom-manual "(gnus)Customizing Articles")
1419 :type gnus-article-treat-custom)
1421 (defcustom gnus-treat-x-pgp-sig nil
1423 To automatically treat X-PGP-Sig, set it to head.
1424 Valid values are nil, t, `head', `last', an integer or a predicate.
1425 See Info node `(gnus)Customizing Articles' for details."
1427 :group 'gnus-article-treat
1428 :group 'mime-security
1429 :link '(custom-manual "(gnus)Customizing Articles")
1430 :type gnus-article-treat-custom)
1432 (defvar gnus-article-encrypt-protocol-alist
1433 '(("PGP" . mml2015-self-encrypt)))
1435 ;; Set to nil if more than one protocol added to
1436 ;; gnus-article-encrypt-protocol-alist.
1437 (defcustom gnus-article-encrypt-protocol "PGP"
1438 "The protocol used for encrypt articles.
1439 It is a string, such as \"PGP\". If nil, ask user."
1442 :group 'mime-security)
1444 (defvar gnus-article-wash-function nil
1445 "Function used for converting HTML into text.")
1447 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1448 (mm-coding-system-p 'utf-8)
1449 (executable-find idna-program))
1450 "Whether IDNA decoding of headers is used when viewing messages.
1451 This requires GNU Libidn, and by default only enabled if it is found."
1453 :group 'gnus-article-headers
1456 (defcustom gnus-article-over-scroll nil
1457 "If non-nil, allow scrolling the article buffer even when there no more text."
1459 :group 'gnus-article
1462 ;;; Internal variables
1464 (defvar gnus-english-month-names
1465 '("January" "February" "March" "April" "May" "June" "July" "August"
1466 "September" "October" "November" "December"))
1468 (defvar gnus-button-regexp nil)
1469 (defvar gnus-button-marker-list nil)
1470 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1472 (defvar gnus-button-last nil)
1473 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1475 (defvar article-goto-body-goes-to-point-min-p nil)
1476 (defvar gnus-article-wash-types nil)
1477 (defvar gnus-article-emphasis-alist nil)
1478 (defvar gnus-article-image-alist nil)
1480 (defvar gnus-article-mime-handle-alist-1 nil)
1481 (defvar gnus-treatment-function-alist
1482 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1483 (gnus-treat-strip-banner gnus-article-strip-banner)
1484 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1485 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1486 (gnus-treat-buttonize gnus-article-add-buttons)
1487 (gnus-treat-fill-article gnus-article-fill-cited-article)
1488 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1489 (gnus-treat-strip-cr gnus-article-remove-cr)
1490 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1491 (gnus-treat-date-ut gnus-article-date-ut)
1492 (gnus-treat-date-local gnus-article-date-local)
1493 (gnus-treat-date-english gnus-article-date-english)
1494 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1495 (gnus-treat-date-original gnus-article-date-original)
1496 (gnus-treat-date-user-defined gnus-article-date-user)
1497 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1498 (gnus-treat-display-x-face gnus-article-display-x-face)
1499 (gnus-treat-display-face gnus-article-display-face)
1500 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1501 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1502 (gnus-treat-hide-signature gnus-article-hide-signature)
1503 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1504 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1505 (gnus-treat-strip-pem gnus-article-hide-pem)
1506 (gnus-treat-from-picon gnus-treat-from-picon)
1507 (gnus-treat-mail-picon gnus-treat-mail-picon)
1508 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1509 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1510 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1511 (gnus-treat-strip-trailing-blank-lines
1512 gnus-article-remove-trailing-blank-lines)
1513 (gnus-treat-strip-leading-blank-lines
1514 gnus-article-strip-leading-blank-lines)
1515 (gnus-treat-strip-multiple-blank-lines
1516 gnus-article-strip-multiple-blank-lines)
1517 (gnus-treat-overstrike gnus-article-treat-overstrike)
1518 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1519 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1520 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1521 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1522 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1523 (gnus-treat-display-smileys gnus-treat-smiley)
1524 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1525 (gnus-treat-wash-html gnus-article-wash-html)
1526 (gnus-treat-emphasize gnus-article-emphasize)
1527 (gnus-treat-hide-citation gnus-article-hide-citation)
1528 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1529 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1530 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1531 (gnus-treat-play-sounds gnus-earcon-display)))
1533 (defvar gnus-article-mime-handle-alist nil)
1534 (defvar article-lapsed-timer nil)
1535 (defvar gnus-article-current-summary nil)
1537 (defvar gnus-article-mode-syntax-table
1538 (let ((table (copy-syntax-table text-mode-syntax-table)))
1539 ;; This causes the citation match run O(2^n).
1540 ;; (modify-syntax-entry ?- "w" table)
1541 (modify-syntax-entry ?> ")<" table)
1542 (modify-syntax-entry ?< "(>" table)
1543 ;; make M-. in article buffers work for `foo' strings
1544 (modify-syntax-entry ?' " " table)
1545 (modify-syntax-entry ?` " " table)
1547 "Syntax table used in article mode buffers.
1548 Initialized from `text-mode-syntax-table.")
1550 (defvar gnus-save-article-buffer nil)
1552 (defvar gnus-article-mode-line-format-alist
1553 (nconc '((?w (gnus-article-wash-status) ?s)
1554 (?m (gnus-article-mime-part-status) ?s))
1555 gnus-summary-mode-line-format-alist))
1557 (defvar gnus-number-of-articles-to-be-saved nil)
1559 (defvar gnus-inhibit-hiding nil)
1561 (defvar gnus-article-edit-mode nil)
1563 ;;; Macros for dealing with the article buffer.
1565 (defmacro gnus-with-article-headers (&rest forms)
1567 (set-buffer gnus-article-buffer)
1569 (let ((inhibit-read-only t)
1570 (inhibit-point-motion-hooks t)
1571 (case-fold-search t))
1572 (article-narrow-to-head)
1575 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1576 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1578 (defmacro gnus-with-article-buffer (&rest forms)
1580 (set-buffer gnus-article-buffer)
1581 (let ((inhibit-read-only t))
1584 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1585 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1587 (defun gnus-article-goto-header (header)
1588 "Go to HEADER, which is a regular expression."
1589 (re-search-forward (concat "^\\(" header "\\):") nil t))
1591 (defsubst gnus-article-hide-text (b e props)
1592 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1593 (gnus-add-text-properties-when 'article-type nil b e props)
1594 (when (memq 'intangible props)
1596 (max (1- b) (point-min))
1597 b 'intangible (cddr (memq 'intangible props)))))
1599 (defsubst gnus-article-unhide-text (b e)
1600 "Remove hidden text properties from region between B and E."
1601 (remove-text-properties b e gnus-hidden-properties)
1602 (when (memq 'intangible gnus-hidden-properties)
1603 (put-text-property (max (1- b) (point-min))
1604 b 'intangible nil)))
1606 (defun gnus-article-hide-text-type (b e type)
1607 "Hide text of TYPE between B and E."
1608 (gnus-add-wash-type type)
1609 (gnus-article-hide-text
1610 b e (cons 'article-type (cons type gnus-hidden-properties))))
1612 (defun gnus-article-unhide-text-type (b e type)
1613 "Unhide text of TYPE between B and E."
1614 (gnus-delete-wash-type type)
1615 (remove-text-properties
1616 b e (cons 'article-type (cons type gnus-hidden-properties)))
1617 (when (memq 'intangible gnus-hidden-properties)
1618 (put-text-property (max (1- b) (point-min))
1619 b 'intangible nil)))
1621 (defun gnus-article-hide-text-of-type (type)
1622 "Hide text of TYPE in the current buffer."
1624 (let ((b (point-min))
1626 (while (setq b (text-property-any b e 'article-type type))
1627 (add-text-properties b (incf b) gnus-hidden-properties)))))
1629 (defun gnus-article-delete-text-of-type (type)
1630 "Delete text of TYPE in the current buffer."
1632 (let ((b (point-min)))
1633 (while (setq b (text-property-any b (point-max) 'article-type type))
1635 b (or (text-property-not-all b (point-max) 'article-type type)
1638 (defun gnus-article-delete-invisible-text ()
1639 "Delete all invisible text in the current buffer."
1641 (let ((b (point-min)))
1642 (while (setq b (text-property-any b (point-max) 'invisible t))
1644 b (or (text-property-not-all b (point-max) 'invisible t)
1647 (defun gnus-article-text-type-exists-p (type)
1648 "Say whether any text of type TYPE exists in the buffer."
1649 (text-property-any (point-min) (point-max) 'article-type type))
1651 (defsubst gnus-article-header-rank ()
1652 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1653 (let ((list gnus-sorted-header-list)
1656 (if (looking-at (car list))
1658 (setq list (cdr list))
1662 (defun article-hide-headers (&optional arg delete)
1663 "Hide unwanted headers and possibly sort them as well."
1665 ;; This function might be inhibited.
1666 (unless gnus-inhibit-hiding
1667 (let ((inhibit-read-only nil)
1668 (case-fold-search t)
1669 (max (1+ (length gnus-sorted-header-list)))
1670 (inhibit-point-motion-hooks t)
1671 (cur (current-buffer))
1672 ignored visible beg)
1674 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1675 ;; group parameters, so we should go to the summary buffer.
1678 (progn (set-buffer gnus-summary-buffer) t)
1680 (setq ignored (when (not gnus-visible-headers)
1681 (cond ((stringp gnus-ignored-headers)
1682 gnus-ignored-headers)
1683 ((listp gnus-ignored-headers)
1684 (mapconcat 'identity
1685 gnus-ignored-headers
1687 visible (cond ((stringp gnus-visible-headers)
1688 gnus-visible-headers)
1689 ((and gnus-visible-headers
1690 (listp gnus-visible-headers))
1691 (mapconcat 'identity
1692 gnus-visible-headers
1696 ;; First we narrow to just the headers.
1697 (article-narrow-to-head)
1698 ;; Hide any "From " lines at the beginning of (mail) articles.
1699 (while (looking-at "From ")
1702 (delete-region (point-min) (point)))
1703 ;; Then treat the rest of the header lines.
1704 ;; Then we use the two regular expressions
1705 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1706 ;; select which header lines is to remain visible in the
1708 (while (re-search-forward "^[^ \t:]*:" nil t)
1710 ;; Mark the rank of the header.
1712 (point) (1+ (point)) 'message-rank
1713 (if (or (and visible (looking-at visible))
1715 (not (looking-at ignored))))
1716 (gnus-article-header-rank)
1719 (message-sort-headers-1)
1720 (when (setq beg (text-property-any
1721 (point-min) (point-max) 'message-rank (+ 2 max)))
1722 ;; We delete the unwanted headers.
1723 (gnus-add-wash-type 'headers)
1724 (add-text-properties (point-min) (+ 5 (point-min))
1725 '(article-type headers dummy-invisible t))
1726 (delete-region beg (point-max))))))))
1728 (defun article-hide-boring-headers (&optional arg)
1729 "Toggle hiding of headers that aren't very interesting.
1730 If given a negative prefix, always show; if given a positive prefix,
1732 (interactive (gnus-article-hidden-arg))
1733 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1734 (not gnus-show-all-headers))
1737 (let ((inhibit-read-only t)
1738 (inhibit-point-motion-hooks t))
1739 (article-narrow-to-head)
1740 (dolist (elem gnus-boring-article-headers)
1741 (goto-char (point-min))
1743 ;; Hide empty headers.
1745 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1747 (gnus-article-hide-text-type
1751 (if (re-search-forward "^[^ \t]" nil t)
1755 ;; Hide boring Newsgroups header.
1756 ((eq elem 'newsgroups)
1757 (when (gnus-string-equal
1758 (gnus-fetch-field "newsgroups")
1759 (gnus-group-real-name
1760 (if (boundp 'gnus-newsgroup-name)
1763 (gnus-article-hide-header "newsgroups")))
1764 ((eq elem 'to-address)
1765 (let ((to (message-fetch-field "to"))
1767 (gnus-parameter-to-address
1768 (if (boundp 'gnus-newsgroup-name)
1769 gnus-newsgroup-name ""))))
1770 (when (and to to-address
1773 ;; only one address in To
1774 (nth 1 (mail-extract-address-components to))
1776 (gnus-article-hide-header "to"))))
1778 (let ((to (message-fetch-field "to"))
1780 (gnus-parameter-to-list
1781 (if (boundp 'gnus-newsgroup-name)
1782 gnus-newsgroup-name ""))))
1783 (when (and to to-list
1786 ;; only one address in To
1787 (nth 1 (mail-extract-address-components to))
1789 (gnus-article-hide-header "to"))))
1791 (let ((cc (message-fetch-field "cc"))
1793 (gnus-parameter-to-list
1794 (if (boundp 'gnus-newsgroup-name)
1795 gnus-newsgroup-name ""))))
1796 (when (and cc to-list
1799 ;; only one address in CC
1800 (nth 1 (mail-extract-address-components cc))
1802 (gnus-article-hide-header "cc"))))
1803 ((eq elem 'followup-to)
1804 (when (gnus-string-equal
1805 (message-fetch-field "followup-to")
1806 (message-fetch-field "newsgroups"))
1807 (gnus-article-hide-header "followup-to")))
1808 ((eq elem 'reply-to)
1809 (if (gnus-group-find-parameter
1810 gnus-newsgroup-name 'broken-reply-to)
1811 (gnus-article-hide-header "reply-to")
1812 (let ((from (message-fetch-field "from"))
1813 (reply-to (message-fetch-field "reply-to")))
1820 (lambda (x) (downcase (cadr x)))
1821 (mail-extract-address-components from t))
1824 (lambda (x) (downcase (cadr x)))
1825 (mail-extract-address-components reply-to t))
1827 (gnus-article-hide-header "reply-to")))))
1829 (let ((date (message-fetch-field "date")))
1831 (< (days-between (current-time-string) date)
1833 (gnus-article-hide-header "date"))))
1835 (let ((to (message-fetch-field "to"))
1836 (cc (message-fetch-field "cc")))
1837 (when (> (length to) 1024)
1838 (gnus-article-hide-header "to"))
1839 (when (> (length cc) 1024)
1840 (gnus-article-hide-header "cc"))))
1844 (goto-char (point-min))
1845 (while (re-search-forward "^to:" nil t)
1846 (setq to-count (1+ to-count)))
1847 (when (> to-count 1)
1848 (while (> to-count 0)
1849 (goto-char (point-min))
1851 (re-search-forward "^to:" nil nil to-count)
1853 (narrow-to-region (point) (point-max))
1854 (gnus-article-hide-header "to"))
1855 (setq to-count (1- to-count))))
1856 (goto-char (point-min))
1857 (while (re-search-forward "^cc:" nil t)
1858 (setq cc-count (1+ cc-count)))
1859 (when (> cc-count 1)
1860 (while (> cc-count 0)
1861 (goto-char (point-min))
1863 (re-search-forward "^cc:" nil nil cc-count)
1865 (narrow-to-region (point) (point-max))
1866 (gnus-article-hide-header "cc"))
1867 (setq cc-count (1- cc-count)))))))))))))
1869 (defun gnus-article-hide-header (header)
1871 (goto-char (point-min))
1872 (when (re-search-forward (concat "^" header ":") nil t)
1873 (gnus-article-hide-text-type
1877 (if (re-search-forward "^[^ \t]" nil t)
1882 (defvar gnus-article-normalized-header-length 40
1883 "Length of normalized headers.")
1885 (defun article-normalize-headers ()
1886 "Make all header lines 40 characters long."
1888 (let ((inhibit-read-only t)
1892 (article-narrow-to-head)
1895 ((< (setq column (- (point-at-eol) (point)))
1896 gnus-article-normalized-header-length)
1898 (insert (make-string
1899 (- gnus-article-normalized-header-length column)
1901 ((> column gnus-article-normalized-header-length)
1902 (gnus-put-text-property
1904 (forward-char gnus-article-normalized-header-length)
1911 (forward-line 1))))))
1913 (defun article-treat-dumbquotes ()
1914 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1915 Note that this function guesses whether a character is a sm*rtq**t* or
1916 not, so it should only be used interactively.
1918 Sm*rtq**t*s are M****s***'s unilateral extension to the
1919 iso-8859-1 character map in an attempt to provide more quoting
1920 characters. If you see something like \\222 or \\264 where
1921 you're expecting some kind of apostrophe or quotation mark, then
1924 (article-translate-strings gnus-article-dumbquotes-map))
1926 (defun article-translate-characters (from to)
1927 "Translate all characters in the body of the article according to FROM and TO.
1928 FROM is a string of characters to translate from; to is a string of
1929 characters to translate to."
1931 (when (article-goto-body)
1932 (let ((inhibit-read-only t)
1933 (x (make-string 225 ?x))
1935 (while (< (incf i) (length x))
1938 (while (< i (length from))
1939 (aset x (aref from i) (aref to i))
1941 (translate-region (point) (point-max) x)))))
1943 (defun article-translate-strings (map)
1944 "Translate all string in the body of the article according to MAP.
1945 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1947 (when (article-goto-body)
1948 (let ((inhibit-read-only t))
1951 (while (search-forward (car elem) nil t)
1952 (replace-match (cadr elem)))))))))
1954 (defun article-treat-overstrike ()
1955 "Translate overstrikes into bold text."
1958 (when (article-goto-body)
1959 (let ((inhibit-read-only t))
1960 (while (search-forward "\b" nil t)
1961 (let ((next (char-after))
1962 (previous (char-after (- (point) 2))))
1963 ;; We do the boldification/underlining by hiding the
1964 ;; overstrikes and putting the proper text property
1968 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1969 (put-text-property (point) (1+ (point)) 'face 'bold))
1971 (gnus-article-hide-text-type
1972 (1- (point)) (1+ (point)) 'overstrike)
1974 (- (point) 2) (1- (point)) 'face 'underline))
1976 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1978 (point) (1+ (point)) 'face 'underline)))))))))
1980 (defun article-treat-ansi-sequences ()
1981 "Translate ANSI SGR control sequences into overlays or extents."
1984 (when (article-goto-body)
1985 (let ((inhibit-read-only t))
1986 (ansi-color-apply-on-region (point) (point-max))))))
1988 (defun gnus-article-treat-unfold-headers ()
1989 "Unfold folded message headers.
1990 Only the headers that fit into the current window width will be
1993 (gnus-with-article-headers
1997 (mail-header-narrow-to-field)
1998 (let ((header (buffer-string)))
2001 (goto-char (point-min))
2002 (while (re-search-forward "\n[\t ]" nil t)
2003 (replace-match " " t t)))
2004 (setq length (- (point-max) (point-min) 1)))
2005 (when (< length (window-width))
2006 (while (re-search-forward "\n[\t ]" nil t)
2007 (replace-match " " t t)))
2008 (goto-char (point-max)))))))
2010 (defun gnus-article-treat-fold-headers ()
2011 "Fold message headers."
2013 (gnus-with-article-headers
2016 (mail-header-narrow-to-field)
2017 (mail-header-fold-field)
2018 (goto-char (point-max))))))
2020 (defun gnus-treat-smiley ()
2021 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2023 (gnus-with-article-buffer
2024 (if (memq 'smiley gnus-article-wash-types)
2025 (gnus-delete-images 'smiley)
2027 (let ((images (smiley-region (point) (point-max))))
2029 (gnus-add-wash-type 'smiley)
2030 (dolist (image images)
2031 (gnus-add-image 'smiley image)))))))
2033 (defun gnus-article-remove-images ()
2034 "Remove all images from the article buffer."
2036 (gnus-with-article-buffer
2037 (dolist (elem gnus-article-image-alist)
2038 (gnus-delete-images (car elem)))))
2040 (defun gnus-article-treat-fold-newsgroups ()
2041 "Unfold folded message headers.
2042 Only the headers that fit into the current window width will be
2045 (gnus-with-article-headers
2046 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2048 (mail-header-narrow-to-field)
2049 (while (re-search-forward ", *" nil t)
2050 (replace-match ", " t t))
2051 (mail-header-fold-field)
2052 (goto-char (point-max))))))
2054 (defun gnus-article-treat-body-boundary ()
2055 "Place a boundary line at the end of the headers."
2057 (when (and gnus-body-boundary-delimiter
2058 (> (length gnus-body-boundary-delimiter) 0))
2059 (gnus-with-article-headers
2060 (goto-char (point-max))
2061 (let ((start (point)))
2062 (insert "X-Boundary: ")
2063 (gnus-add-text-properties start (point) '(invisible t intangible t))
2065 (while (>= (1- (window-width)) (length str))
2066 (setq str (concat str gnus-body-boundary-delimiter)))
2067 (substring str 0 (1- (window-width))))
2069 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2071 (defun article-fill-long-lines ()
2072 "Fill lines that are wider than the window width."
2075 (let ((inhibit-read-only t)
2076 (width (window-width (get-buffer-window (current-buffer)))))
2079 (let ((adaptive-fill-mode nil)) ;Why? -sm
2082 (when (>= (current-column) (min fill-column width))
2083 (narrow-to-region (min (1+ (point)) (point-max))
2085 (let ((goback (point-marker)))
2086 (fill-paragraph nil)
2087 (goto-char (marker-position goback)))
2089 (forward-line 1)))))))
2091 (defun article-capitalize-sentences ()
2092 "Capitalize the first word in each sentence."
2095 (let ((inhibit-read-only t)
2096 (paragraph-start "^[\n\^L]"))
2100 (forward-sentence)))))
2102 (defun article-remove-cr ()
2103 "Remove trailing CRs and then translate remaining CRs into LFs."
2106 (let ((inhibit-read-only t))
2107 (goto-char (point-min))
2108 (while (re-search-forward "\r+$" nil t)
2109 (replace-match "" t t))
2110 (goto-char (point-min))
2111 (while (search-forward "\r" nil t)
2112 (replace-match "\n" t t)))))
2114 (defun article-remove-trailing-blank-lines ()
2115 "Remove all trailing blank lines from the article."
2118 (let ((inhibit-read-only t))
2119 (goto-char (point-max))
2123 (while (and (not (bobp))
2124 (looking-at "^[ \t]*$")
2125 (not (gnus-annotation-in-region-p
2126 (point) (point-at-eol))))
2132 (defvar gnus-face-properties-alist))
2134 (defun article-display-face ()
2135 "Display any Face headers in the header."
2137 (let ((wash-face-p buffer-read-only))
2138 (gnus-with-article-headers
2139 ;; When displaying parts, this function can be called several times on
2140 ;; the same article, without any intended toggle semantic (as typing `W
2141 ;; D d' would have). So face deletion must occur only when we come from
2142 ;; an interactive command, that is when the *Article* buffer is
2144 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2145 (gnus-delete-images 'face)
2148 (when (and wash-face-p
2150 (goto-char (point-min))
2151 (not (re-search-forward "^Face:[\t ]*" nil t)))
2152 (gnus-buffer-live-p gnus-original-article-buffer))
2153 (set-buffer gnus-original-article-buffer))
2155 (mail-narrow-to-head)
2156 (while (gnus-article-goto-header "Face")
2157 (setq faces (nconc faces (list (mail-header-field-value)))))))
2158 (dolist (face faces)
2159 (let ((png (gnus-convert-face-to-png face))
2163 (apply 'gnus-create-image png 'png t
2164 (cdr (assq 'png gnus-face-properties-alist))))
2165 (gnus-article-goto-header "from")
2167 (insert "From: [no `from' set]\n")
2169 (gnus-add-wash-type 'face)
2170 (gnus-add-image 'face image)
2171 (gnus-put-image image nil 'face))))))
2174 (defun article-display-x-face (&optional force)
2175 "Look for an X-Face header and display it if present."
2176 (interactive (list 'force))
2177 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2178 (gnus-with-article-headers
2179 ;; Delete the old process, if any.
2180 (when (process-status "article-x-face")
2181 (delete-process "article-x-face"))
2182 ;; See the comment in `article-display-face'.
2183 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2184 ;; We have already displayed X-Faces, so we remove them
2186 (gnus-delete-images 'xface)
2188 (let (x-faces from face)
2190 (when (and wash-face-p
2192 (goto-char (point-min))
2193 (not (re-search-forward
2194 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2195 (gnus-buffer-live-p gnus-original-article-buffer))
2196 ;; If type `W f', use gnus-original-article-buffer,
2197 ;; otherwise use the current buffer because displaying
2198 ;; RFC822 parts calls this function too.
2199 (set-buffer gnus-original-article-buffer))
2201 (mail-narrow-to-head)
2202 (while (gnus-article-goto-header "X-Face")
2203 (push (mail-header-field-value) x-faces))
2204 (setq from (message-fetch-field "from"))))
2205 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2206 ;; single external face.
2207 (when (stringp gnus-article-x-face-command)
2208 (setq x-faces (list (car x-faces))))
2209 (while (and (setq face (pop x-faces))
2210 gnus-article-x-face-command
2212 ;; Check whether this face is censored.
2213 (not gnus-article-x-face-too-ugly)
2214 (and gnus-article-x-face-too-ugly from
2215 (not (string-match gnus-article-x-face-too-ugly
2217 ;; We display the face.
2218 (cond ((stringp gnus-article-x-face-command)
2219 ;; The command is a string, so we interpret the command
2220 ;; as a, well, command, and fork it off.
2221 (let ((process-connection-type nil))
2222 (process-kill-without-query
2224 "article-x-face" nil shell-file-name
2225 shell-command-switch gnus-article-x-face-command))
2228 (process-send-region "article-x-face"
2229 (point-min) (point-max)))
2230 (process-send-eof "article-x-face")))
2231 ((functionp gnus-article-x-face-command)
2232 ;; The command is a lisp function, so we call it.
2233 (funcall gnus-article-x-face-command face))
2235 (error "%s is not a function"
2236 gnus-article-x-face-command)))))))))
2238 (defun article-decode-mime-words ()
2239 "Decode all MIME-encoded words in the article."
2241 (gnus-with-article-buffer
2242 (let ((inhibit-point-motion-hooks t)
2243 (mail-parse-charset gnus-newsgroup-charset)
2244 (mail-parse-ignored-charsets
2245 (with-current-buffer gnus-summary-buffer
2246 gnus-newsgroup-ignored-charsets)))
2247 (mail-decode-encoded-word-region (point-min) (point-max)))))
2249 (defun article-decode-charset (&optional prompt)
2250 "Decode charset-encoded text in the article.
2251 If PROMPT (the prefix), prompt for a coding system to use."
2253 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2254 (inhibit-read-only t)
2255 (mail-parse-charset gnus-newsgroup-charset)
2256 (mail-parse-ignored-charsets
2257 (save-excursion (condition-case nil
2258 (set-buffer gnus-summary-buffer)
2260 gnus-newsgroup-ignored-charsets))
2261 ct cte ctl charset format)
2264 (article-narrow-to-head)
2265 (setq ct (message-fetch-field "Content-Type" t)
2266 cte (message-fetch-field "Content-Transfer-Encoding" t)
2267 ctl (and ct (ignore-errors
2268 (mail-header-parse-content-type ct)))
2271 (mm-read-coding-system "Charset to decode: "))
2273 (mail-content-type-get ctl 'charset)))
2274 format (and ctl (mail-content-type-get ctl 'format)))
2276 (setq cte (mail-header-strip cte)))
2277 (if (and ctl (not (string-match "/" (car ctl))))
2279 (goto-char (point-max)))
2282 (narrow-to-region (point) (point-max))
2283 (when (and (eq mail-parse-charset 'gnus-decoded)
2284 (eq (mm-body-7-or-8) '8bit))
2285 ;; The text code could have been decoded.
2286 (setq charset mail-parse-charset))
2287 (when (and (or (not ctl)
2288 (equal (car ctl) "text/plain"))
2289 (not format)) ;; article with format will decode later.
2291 charset (and cte (intern (downcase
2292 (gnus-strip-whitespace cte))))
2295 (defun article-decode-encoded-words ()
2296 "Remove encoded-word encoding from headers."
2297 (let ((inhibit-point-motion-hooks t)
2298 (mail-parse-charset gnus-newsgroup-charset)
2299 (mail-parse-ignored-charsets
2300 (save-excursion (condition-case nil
2301 (set-buffer gnus-summary-buffer)
2303 gnus-newsgroup-ignored-charsets))
2304 (inhibit-read-only t))
2306 (article-narrow-to-head)
2307 (funcall gnus-decode-header-function (point-min) (point-max)))))
2309 (defun article-decode-group-name ()
2310 "Decode group names in `Newsgroups:'."
2311 (let ((inhibit-point-motion-hooks t)
2312 (inhibit-read-only t)
2313 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2314 (when (and (or gnus-group-name-charset-method-alist
2315 gnus-group-name-charset-group-alist)
2316 (gnus-buffer-live-p gnus-original-article-buffer))
2318 (article-narrow-to-head)
2319 (with-current-buffer gnus-original-article-buffer
2320 (goto-char (point-min)))
2321 (while (re-search-forward
2322 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2323 (replace-match (save-match-data
2324 (gnus-decode-newsgroups
2325 ;; XXX how to use data in article buffer?
2326 (with-current-buffer gnus-original-article-buffer
2328 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2331 gnus-newsgroup-name method))
2333 (goto-char (point-min))
2334 (with-current-buffer gnus-original-article-buffer
2335 (goto-char (point-min)))
2336 (while (re-search-forward
2337 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2338 (replace-match (save-match-data
2339 (gnus-decode-newsgroups
2340 ;; XXX how to use data in article buffer?
2341 (with-current-buffer gnus-original-article-buffer
2343 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2346 gnus-newsgroup-name method))
2349 (autoload 'idna-to-unicode "idna")
2351 (defun article-decode-idna-rhs ()
2352 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2355 (let ((inhibit-point-motion-hooks t)
2356 (inhibit-read-only t))
2357 (article-narrow-to-head)
2358 (goto-char (point-min))
2359 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2361 (when (save-match-data
2362 (and (setq ace (match-string 1))
2364 (and (re-search-backward "^[^ \t]" nil t)
2365 (looking-at "From\\|To\\|Cc")))
2366 (setq unicode (idna-to-unicode ace))))
2367 (unless (string= ace unicode)
2368 (replace-match unicode nil nil nil 1)))))))))
2370 (defun article-de-quoted-unreadable (&optional force read-charset)
2371 "Translate a quoted-printable-encoded article.
2372 If FORCE, decode the article whether it is marked as quoted-printable
2374 If READ-CHARSET, ask for a coding system."
2375 (interactive (list 'force current-prefix-arg))
2377 (let ((inhibit-read-only t) type charset)
2378 (if (gnus-buffer-live-p gnus-original-article-buffer)
2379 (with-current-buffer gnus-original-article-buffer
2381 (gnus-fetch-field "content-transfer-encoding"))
2382 (let* ((ct (gnus-fetch-field "content-type"))
2385 (mail-header-parse-content-type ct)))))
2386 (setq charset (and ctl
2387 (mail-content-type-get ctl 'charset)))
2388 (if (stringp charset)
2389 (setq charset (intern (downcase charset)))))))
2391 (setq charset (mm-read-coding-system "Charset: " charset)))
2393 (setq charset gnus-newsgroup-charset))
2395 (and type (let ((case-fold-search t))
2396 (string-match "quoted-printable" type))))
2398 (quoted-printable-decode-region
2399 (point) (point-max) (mm-charset-to-coding-system charset))))))
2401 (defun article-de-base64-unreadable (&optional force read-charset)
2402 "Translate a base64 article.
2403 If FORCE, decode the article whether it is marked as base64 not.
2404 If READ-CHARSET, ask for a coding system."
2405 (interactive (list 'force current-prefix-arg))
2407 (let ((inhibit-read-only t) type charset)
2408 (if (gnus-buffer-live-p gnus-original-article-buffer)
2409 (with-current-buffer gnus-original-article-buffer
2411 (gnus-fetch-field "content-transfer-encoding"))
2412 (let* ((ct (gnus-fetch-field "content-type"))
2415 (mail-header-parse-content-type ct)))))
2416 (setq charset (and ctl
2417 (mail-content-type-get ctl 'charset)))
2418 (if (stringp charset)
2419 (setq charset (intern (downcase charset)))))))
2421 (setq charset (mm-read-coding-system "Charset: " charset)))
2423 (setq charset gnus-newsgroup-charset))
2425 (and type (let ((case-fold-search t))
2426 (string-match "base64" type))))
2429 (narrow-to-region (point) (point-max))
2430 (base64-decode-region (point-min) (point-max))
2431 (mm-decode-coding-region
2432 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2437 (defun article-decode-HZ ()
2438 "Translate a HZ-encoded article."
2442 (let ((inhibit-read-only t))
2443 (rfc1843-decode-region (point-min) (point-max)))))
2445 (defun article-unsplit-urls ()
2446 "Remove the newlines that some other mailers insert into URLs."
2449 (let ((inhibit-read-only t))
2450 (goto-char (point-min))
2451 (while (re-search-forward
2452 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2453 (replace-match "\\1\\3" t)))
2454 (when (interactive-p)
2455 (gnus-treat-article nil))))
2458 (defun article-wash-html (&optional read-charset)
2459 "Format an HTML article.
2460 If READ-CHARSET, ask for a coding system."
2463 (let ((inhibit-read-only t)
2465 (when (gnus-buffer-live-p gnus-original-article-buffer)
2466 (with-current-buffer gnus-original-article-buffer
2467 (let* ((ct (gnus-fetch-field "content-type"))
2470 (mail-header-parse-content-type ct)))))
2471 (setq charset (and ctl
2472 (mail-content-type-get ctl 'charset)))
2473 (when (stringp charset)
2474 (setq charset (intern (downcase charset)))))))
2476 (setq charset (mm-read-coding-system "Charset: " charset)))
2478 (setq charset gnus-newsgroup-charset))
2480 (save-window-excursion
2482 (narrow-to-region (point) (point-max))
2483 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2484 (entry (assq func mm-text-html-washer-alist)))
2486 (setq func (cdr entry)))
2491 (apply (car func) (cdr func))))))))))
2493 (defun gnus-article-wash-html-with-w3 ()
2494 "Wash the current buffer with w3."
2496 (let ((w3-strict-width (window-width))
2497 (url-standalone-mode t)
2498 (url-gateway-unplugged t)
2499 (w3-honor-stylesheets nil))
2501 (w3-region (point-min) (point-max))
2504 (defun gnus-article-wash-html-with-w3m ()
2505 "Wash the current buffer with emacs-w3m."
2508 (narrow-to-region (point) (point-max))
2509 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2510 w3m-force-redisplay)
2511 (w3m-region (point-min) (point-max)))
2512 (when (and mm-inline-text-html-with-w3m-keymap
2513 (boundp 'w3m-minor-mode-map)
2515 (add-text-properties
2516 (point-min) (point-max)
2517 (list 'keymap w3m-minor-mode-map
2518 ;; Put the mark meaning this part was rendered by emacs-w3m.
2519 'mm-inline-text-html-with-w3m t)))))
2521 (defun article-hide-list-identifiers ()
2522 "Remove list identifies from the Subject header.
2523 The `gnus-list-identifiers' variable specifies what to do."
2525 (let ((inhibit-point-motion-hooks t)
2526 (regexp (if (consp gnus-list-identifiers)
2527 (mapconcat 'identity gnus-list-identifiers " *\\|")
2528 gnus-list-identifiers))
2529 (inhibit-read-only t))
2533 (article-narrow-to-head)
2534 (goto-char (point-min))
2535 (while (re-search-forward
2536 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2538 (delete-region (match-beginning 2) (match-end 0))
2539 (beginning-of-line))
2540 (when (re-search-forward
2541 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2542 (delete-region (match-beginning 1) (match-end 1))))))))
2544 (defun article-hide-pem (&optional arg)
2545 "Toggle hiding of any PEM headers and signatures in the current article.
2546 If given a negative prefix, always show; if given a positive prefix,
2548 (interactive (gnus-article-hidden-arg))
2549 (unless (gnus-article-check-hidden-text 'pem arg)
2551 (let ((inhibit-read-only t) end)
2552 (goto-char (point-min))
2553 ;; Hide the horrendously ugly "header".
2554 (when (and (search-forward
2555 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2557 (setq end (1+ (match-beginning 0))))
2558 (gnus-add-wash-type 'pem)
2559 (gnus-article-hide-text-type
2561 (if (search-forward "\n\n" nil t)
2565 ;; Hide the trailer as well
2566 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2568 (gnus-article-hide-text-type
2569 (match-beginning 0) (match-end 0) 'pem)))))))
2571 (defun article-strip-banner ()
2572 "Strip the banners specified by the `banner' group parameter and by
2573 `gnus-article-address-banner-alist'."
2577 (let ((inhibit-point-motion-hooks t))
2578 (when (gnus-parameter-banner gnus-newsgroup-name)
2579 (article-really-strip-banner
2580 (gnus-parameter-banner gnus-newsgroup-name)))
2581 (when gnus-article-address-banner-alist
2582 ;; It is necessary to encode from fields before checking,
2583 ;; because `mail-header-parse-addresses' does not work
2584 ;; (reliably) on decoded headers. And more, it is
2585 ;; impossible to use `gnus-fetch-original-field' here,
2586 ;; because `article-strip-banner' may be called in draft
2587 ;; buffers to preview them.
2588 (let ((from (save-restriction
2590 (article-narrow-to-head)
2591 (mail-fetch-field "from"))))
2594 (caar (mail-header-parse-addresses
2595 (mail-encode-encoded-word-string from)))))
2597 (dolist (pair gnus-article-address-banner-alist)
2598 (when (string-match (car pair) from)
2600 (article-really-strip-banner (cdr pair)))))))))))))
2602 (defun article-really-strip-banner (banner)
2603 "Strip the banner specified by the argument."
2606 (let ((inhibit-point-motion-hooks t)
2607 (gnus-signature-limit nil)
2608 (inhibit-read-only t))
2611 ((eq banner 'signature)
2612 (when (gnus-article-narrow-to-signature)
2615 (delete-region (point) (point-max))))
2617 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2618 (while (re-search-forward banner nil t)
2619 (delete-region (match-beginning 0) (match-end 0)))))
2621 (while (re-search-forward banner nil t)
2622 (delete-region (match-beginning 0) (match-end 0)))))))))
2624 (defun article-babel ()
2625 "Translate article using an online translation service."
2628 (gnus-with-article-buffer
2629 (when (article-goto-body)
2630 (let* ((start (point))
2632 (orig (buffer-substring start end))
2633 (trans (babel-as-string orig)))
2635 (narrow-to-region start end)
2636 (delete-region start end)
2639 (defun article-hide-signature (&optional arg)
2640 "Hide the signature in the current article.
2641 If given a negative prefix, always show; if given a positive prefix,
2643 (interactive (gnus-article-hidden-arg))
2644 (unless (gnus-article-check-hidden-text 'signature arg)
2647 (let ((inhibit-read-only t))
2648 (when (gnus-article-narrow-to-signature)
2649 (gnus-article-hide-text-type
2650 (point-min) (point-max) 'signature))))))
2651 (gnus-set-mode-line 'article))
2653 (defun article-strip-headers-in-body ()
2654 "Strip offensive headers from bodies."
2658 (let ((case-fold-search t))
2659 (when (looking-at "x-no-archive:")
2660 (gnus-delete-line)))))
2662 (defun article-strip-leading-blank-lines ()
2663 "Remove all blank lines from the beginning of the article."
2666 (let ((inhibit-point-motion-hooks t)
2667 (inhibit-read-only t))
2668 (when (article-goto-body)
2669 (while (and (not (eobp))
2670 (looking-at "[ \t]*$"))
2671 (gnus-delete-line))))))
2673 (defun article-narrow-to-head ()
2674 "Narrow the buffer to the head of the message.
2675 Point is left at the beginning of the narrowed-to region."
2677 (goto-char (point-min))
2678 (if (search-forward "\n\n" nil 1)
2681 (goto-char (point-min)))
2683 (defun article-goto-body ()
2684 "Place point at the start of the body."
2685 (goto-char (point-min))
2687 ;; This variable is only bound when dealing with separate
2689 (article-goto-body-goes-to-point-min-p
2691 ((search-forward "\n\n" nil t)
2694 (goto-char (point-max))
2697 (defun article-strip-multiple-blank-lines ()
2698 "Replace consecutive blank lines with one empty line."
2701 (let ((inhibit-point-motion-hooks t)
2702 (inhibit-read-only t))
2703 ;; First make all blank lines empty.
2705 (while (re-search-forward "^[ \t]+$" nil t)
2706 (unless (gnus-annotation-in-region-p
2707 (match-beginning 0) (match-end 0))
2708 (replace-match "" nil t)))
2709 ;; Then replace multiple empty lines with a single empty line.
2711 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2712 (unless (gnus-annotation-in-region-p
2713 (match-beginning 0) (match-end 0))
2714 (delete-region (match-beginning 1) (match-end 1)))))))
2716 (defun article-strip-leading-space ()
2717 "Remove all white space from the beginning of the lines in the article."
2720 (let ((inhibit-point-motion-hooks t)
2721 (inhibit-read-only t))
2723 (while (re-search-forward "^[ \t]+" nil t)
2724 (replace-match "" t t)))))
2726 (defun article-strip-trailing-space ()
2727 "Remove all white space from the end of the lines in the article."
2730 (let ((inhibit-point-motion-hooks t)
2731 (inhibit-read-only t))
2733 (while (re-search-forward "[ \t]+$" nil t)
2734 (replace-match "" t t)))))
2736 (defun article-strip-blank-lines ()
2737 "Strip leading, trailing and multiple blank lines."
2739 (article-strip-leading-blank-lines)
2740 (article-remove-trailing-blank-lines)
2741 (article-strip-multiple-blank-lines))
2743 (defun article-strip-all-blank-lines ()
2744 "Strip all blank lines."
2747 (let ((inhibit-point-motion-hooks t)
2748 (inhibit-read-only t))
2750 (while (re-search-forward "^[ \t]*\n" nil t)
2751 (replace-match "" t t)))))
2753 (defun gnus-article-narrow-to-signature ()
2754 "Narrow to the signature; return t if a signature is found, else nil."
2755 (let ((inhibit-point-motion-hooks t))
2756 (when (gnus-article-search-signature)
2758 ;; Check whether we have some limits to what we consider
2759 ;; to be a signature.
2760 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2761 (list gnus-signature-limit)))
2763 (while (setq limit (pop limits))
2764 (if (or (and (integerp limit)
2765 (< (- (point-max) (point)) limit))
2767 (< (count-lines (point) (point-max)) limit))
2768 (and (functionp limit)
2770 (and (stringp limit)
2771 (not (re-search-forward limit nil t))))
2772 () ; This limit did not succeed.
2776 (narrow-to-region (point) (point-max))
2779 (defun gnus-article-search-signature ()
2780 "Search the current buffer for the signature separator.
2781 Put point at the beginning of the signature separator."
2782 (let ((cur (point)))
2783 (goto-char (point-max))
2784 (if (if (stringp gnus-signature-separator)
2785 (re-search-backward gnus-signature-separator nil t)
2786 (let ((seps gnus-signature-separator))
2788 (not (re-search-backward (car seps) nil t)))
2795 (defun gnus-article-hidden-arg ()
2796 "Return the current prefix arg as a number, or 0 if no prefix."
2797 (list (if current-prefix-arg
2798 (prefix-numeric-value current-prefix-arg)
2801 (defun gnus-article-check-hidden-text (type arg)
2802 "Return nil if hiding is necessary.
2803 Arg can be nil or a number. nil and positive means hide, negative
2804 means show, 0 means toggle."
2807 (let ((hide (gnus-article-hidden-text-p type)))
2813 (gnus-article-show-hidden-text type)
2816 (if (eq hide 'hidden)
2818 (gnus-article-show-hidden-text type)
2822 (defun gnus-article-hidden-text-p (type)
2823 "Say whether the current buffer contains hidden text of type TYPE."
2824 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2826 (not (get-text-property pos 'invisible))
2827 (not (get-text-property pos 'dummy-invisible)))
2829 (text-property-any (1+ pos) (point-max) 'article-type type)))
2834 (defun gnus-article-show-hidden-text (type &optional dummy)
2835 "Show all hidden text of type TYPE.
2836 Originally it is hide instead of DUMMY."
2837 (let ((inhibit-read-only t)
2838 (inhibit-point-motion-hooks t))
2839 (gnus-remove-text-properties-when
2841 (point-min) (point-max)
2842 (cons 'article-type (cons type
2843 gnus-hidden-properties)))
2844 (gnus-delete-wash-type type)))
2846 (defconst article-time-units
2847 `((year . ,(* 365.25 24 60 60))
2848 (week . ,(* 7 24 60 60))
2849 (day . ,(* 24 60 60))
2853 "Mapping from time units to seconds.")
2855 (defun gnus-article-forward-header ()
2856 "Move point to the start of the next header.
2857 If the current header is a continuation header, this can be several
2862 (if (looking-at "[ \t]+[^ \t]")
2866 (defun article-date-ut (&optional type highlight header)
2867 "Convert DATE date to universal time in the current article.
2868 If TYPE is `local', convert to local time; if it is `lapsed', output
2869 how much time has lapsed since DATE. For `lapsed', the value of
2870 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2871 should replace the \"Date:\" one, or should be added below it."
2872 (interactive (list 'ut t))
2873 (let* ((header (or header
2874 (message-fetch-field "date")
2876 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2879 ((not gnus-article-date-lapsed-new-header)
2885 (date (if (vectorp header) (mail-header-date header)
2887 (inhibit-point-motion-hooks t)
2892 (article-narrow-to-head)
2893 (when (re-search-forward tdate-regexp nil t)
2894 (setq bface (get-text-property (point-at-bol) 'face)
2895 date (or (get-text-property (point-at-bol)
2898 eface (get-text-property (1- (point-at-eol)) 'face))
2900 (when (and date (not (string= date "")))
2901 (goto-char (point-min))
2902 (let ((inhibit-read-only t))
2903 ;; Delete any old Date headers.
2904 (while (re-search-forward date-regexp nil t)
2906 (delete-region (point-at-bol)
2907 (progn (gnus-article-forward-header)
2909 (delete-region (point-at-bol)
2910 (progn (gnus-article-forward-header)
2913 (setq pos (point))))
2914 (when (and (not pos)
2915 (re-search-forward tdate-regexp nil t))
2917 (gnus-goto-char pos)
2918 (insert (article-make-date-line date (or type 'ut)))
2924 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2925 (add-text-properties (match-beginning 1) (1+ (match-end 1))
2926 (list 'original-date date 'face bface))
2927 (put-text-property (match-beginning 2) (match-end 2)
2930 (defun article-make-date-line (date type)
2931 "Return a DATE line of TYPE."
2932 (unless (memq type '(local ut original user iso8601 lapsed english))
2933 (error "Unknown conversion type: %s" type))
2935 (let ((time (date-to-time date)))
2937 ;; Convert to the local timezone.
2939 (concat "Date: " (message-make-date time)))
2940 ;; Convert to Universal Time.
2945 (let* ((e (parse-time-string date))
2946 (tm (apply 'encode-time e))
2948 (ls (- (cadr tm) (car (current-time-zone time)))))
2949 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2950 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2954 ;; Get the original date from the article.
2955 ((eq type 'original)
2956 (concat "Date: " (if (string-match "\n+$" date)
2957 (substring date 0 (match-beginning 0))
2959 ;; Let the user define the format.
2961 (let ((format (or (condition-case nil
2962 (with-current-buffer gnus-summary-buffer
2963 gnus-article-time-format)
2965 gnus-article-time-format)))
2966 (if (functionp format)
2967 (funcall format time)
2968 (concat "Date: " (format-time-string format time)))))
2971 (let ((tz (car (current-time-zone time))))
2974 (format-time-string "%Y%m%dT%H%M%S" time)
2975 (format "%s%02d%02d"
2976 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2977 (/ (% (abs tz) 3600) 60)))))
2978 ;; Do an X-Sent lapsed format.
2980 ;; If the date is seriously mangled, the timezone functions are
2981 ;; liable to bug out, so we ignore all errors.
2982 (let* ((now (current-time))
2983 (real-time (subtract-time now time))
2984 (real-sec (and real-time
2985 (+ (* (float (car real-time)) 65536)
2987 (sec (and real-time (abs real-sec)))
2997 ;; This is a bit convoluted, but basically we go
2998 ;; through the time units for years, weeks, etc,
2999 ;; and divide things to see whether that results
3000 ;; in positive answers.
3003 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3004 ;; The (remaining) seconds are too few to
3005 ;; be divided into this time unit.
3007 ;; It's big enough, so we output it.
3008 (setq sec (- sec (* num (cdr unit))))
3010 (concat (if prev ", " "") (int-to-string
3012 " " (symbol-name (car unit))
3013 (if (> num 1) "s" ""))
3015 article-time-units "")
3016 ;; If dates are odd, then it might appear like the
3017 ;; article was sent in the future.
3020 " in the future"))))))
3021 ;; Display the date in proper English
3023 (let ((dtime (decode-time time)))
3026 (number-to-string (nth 3 dtime))
3027 (let ((digit (% (nth 3 dtime) 10)))
3029 ((memq (nth 3 dtime) '(11 12 13)) "th")
3035 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3037 (number-to-string (nth 5 dtime))
3039 (format "%02d" (nth 2 dtime))
3041 (format "%02d" (nth 1 dtime)))))))
3043 (format "Date: %s (from Gnus)" date))))
3045 (defun article-date-local (&optional highlight)
3046 "Convert the current article date to the local timezone."
3047 (interactive (list t))
3048 (article-date-ut 'local highlight))
3050 (defun article-date-english (&optional highlight)
3051 "Convert the current article date to something that is proper English."
3052 (interactive (list t))
3053 (article-date-ut 'english highlight))
3055 (defun article-date-original (&optional highlight)
3056 "Convert the current article date to what it was originally.
3057 This is only useful if you have used some other date conversion
3058 function and want to see what the date was before converting."
3059 (interactive (list t))
3060 (article-date-ut 'original highlight))
3062 (defun article-date-lapsed (&optional highlight)
3063 "Convert the current article date to time lapsed since it was sent."
3064 (interactive (list t))
3065 (article-date-ut 'lapsed highlight))
3067 (defun article-update-date-lapsed ()
3068 "Function to be run from a timer to update the lapsed time line."
3069 (let (deactivate-mark)
3074 (set-buffer (window-buffer w))
3075 (when (eq major-mode 'gnus-article-mode)
3076 (let ((mark (point-marker)))
3077 (goto-char (point-min))
3078 (when (re-search-forward "^X-Sent:" nil t)
3079 (article-date-lapsed t))
3080 (goto-char (marker-position mark))
3081 (move-marker mark nil))))
3084 (defun gnus-start-date-timer (&optional n)
3085 "Start a timer to update the X-Sent header in the article buffers.
3086 The numerical prefix says how frequently (in seconds) the function
3091 (gnus-stop-date-timer)
3092 (setq article-lapsed-timer
3093 (run-at-time 1 n 'article-update-date-lapsed)))
3095 (defun gnus-stop-date-timer ()
3096 "Stop the X-Sent timer."
3098 (when article-lapsed-timer
3099 (nnheader-cancel-timer article-lapsed-timer)
3100 (setq article-lapsed-timer nil)))
3102 (defun article-date-user (&optional highlight)
3103 "Convert the current article date to the user-defined format.
3104 This format is defined by the `gnus-article-time-format' variable."
3105 (interactive (list t))
3106 (article-date-ut 'user highlight))
3108 (defun article-date-iso8601 (&optional highlight)
3109 "Convert the current article date to ISO8601."
3110 (interactive (list t))
3111 (article-date-ut 'iso8601 highlight))
3113 ;; (defun article-show-all ()
3114 ;; "Show all hidden text in the article buffer."
3117 ;; (let ((inhibit-read-only t))
3118 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3120 (defun article-remove-leading-whitespace ()
3121 "Remove excessive whitespace from all headers."
3125 (let ((inhibit-read-only t))
3126 (article-narrow-to-head)
3127 (goto-char (point-min))
3128 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3129 (delete-region (match-beginning 1) (match-end 1)))))))
3131 (defun article-emphasize (&optional arg)
3132 "Emphasize text according to `gnus-emphasis-alist'."
3133 (interactive (gnus-article-hidden-arg))
3134 (unless (gnus-article-check-hidden-text 'emphasis arg)
3138 (with-current-buffer gnus-summary-buffer
3139 gnus-article-emphasis-alist)
3141 gnus-emphasis-alist))
3142 (inhibit-read-only t)
3143 (props (append '(article-type emphasis)
3144 gnus-hidden-properties))
3145 regexp elem beg invisible visible face)
3148 (while (setq elem (pop alist))
3150 (setq regexp (car elem)
3151 invisible (nth 1 elem)
3152 visible (nth 2 elem)
3154 (while (re-search-forward regexp nil t)
3155 (when (and (match-beginning visible) (match-beginning invisible))
3156 (gnus-article-hide-text
3157 (match-beginning invisible) (match-end invisible) props)
3158 (gnus-article-unhide-text-type
3159 (match-beginning visible) (match-end visible) 'emphasis)
3160 (gnus-put-overlay-excluding-newlines
3161 (match-beginning visible) (match-end visible) 'face face)
3162 (gnus-add-wash-type 'emphasis)
3163 (goto-char (match-end invisible)))))))))
3165 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3166 "Setup newsgroup emphasis alist."
3167 (unless gnus-article-emphasis-alist
3168 (let ((name (and gnus-newsgroup-name
3169 (gnus-group-real-name gnus-newsgroup-name))))
3170 (make-local-variable 'gnus-article-emphasis-alist)
3171 (setq gnus-article-emphasis-alist
3173 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3174 (while (setq elem (pop alist))
3175 (when (and name (string-match (car elem) name))
3177 highlight (copy-sequence (cdr elem)))))
3179 (copy-sequence highlight-words)
3180 (if gnus-newsgroup-name
3181 (copy-sequence (gnus-group-find-parameter
3182 gnus-newsgroup-name 'highlight-words t)))
3183 gnus-emphasis-alist)))))
3186 (defvar gnus-summary-article-menu)
3187 (defvar gnus-summary-post-menu))
3189 ;;; Saving functions.
3191 (defun gnus-article-save (save-buffer file &optional num)
3192 "Save the currently selected article."
3193 (unless gnus-save-all-headers
3194 ;; Remove headers according to `gnus-saved-headers'.
3195 (let ((gnus-visible-headers
3196 (or gnus-saved-headers gnus-visible-headers))
3197 (gnus-article-buffer save-buffer))
3199 (set-buffer save-buffer)
3200 (article-hide-headers 1 t))))
3201 (save-window-excursion
3202 (if (not gnus-default-article-saver)
3203 (error "No default saver is defined")
3204 ;; !!! Magic! The saving functions all save
3205 ;; `gnus-save-article-buffer' (or so they think), but we
3206 ;; bind that variable to our save-buffer.
3207 (set-buffer gnus-article-buffer)
3208 (let* ((gnus-save-article-buffer save-buffer)
3211 ((not gnus-prompt-before-saving) 'default)
3212 ((eq gnus-prompt-before-saving 'always) nil)
3214 (gnus-number-of-articles-to-be-saved
3215 (when (eq gnus-prompt-before-saving t)
3217 (set-buffer gnus-article-current-summary)
3218 (funcall gnus-default-article-saver filename)))))
3220 (defun gnus-read-save-file-name (prompt &optional filename
3221 function group headers variable)
3223 (funcall function group headers (symbol-value variable)))
3228 ((eq filename 'default)
3234 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3237 (if (and gnus-number-of-articles-to-be-saved
3238 (> gnus-number-of-articles-to-be-saved 1))
3239 (format "these %d articles"
3240 gnus-number-of-articles-to-be-saved)
3243 ;; Let the split methods have their say.
3245 ;; No split name was found.
3248 (concat prompt " (default "
3249 (file-name-nondirectory default-name) ") ")
3250 (file-name-directory default-name)
3252 ;; A single group name is returned.
3253 ((stringp split-name)
3255 (funcall function split-name headers
3256 (symbol-value variable)))
3258 (concat prompt " (default "
3259 (file-name-nondirectory default-name) ") ")
3260 (file-name-directory default-name)
3262 ;; A single split name was found
3263 ((= 1 (length split-name))
3264 (let* ((name (expand-file-name
3266 gnus-article-save-directory))
3267 (dir (cond ((file-directory-p name)
3268 (file-name-as-directory name))
3269 ((file-exists-p name) name)
3270 (t gnus-article-save-directory))))
3272 (concat prompt " (default " name ") ")
3274 ;; A list of splits was found.
3276 (setq split-name (nreverse split-name))
3278 (let ((file-name-history
3279 (nconc split-name file-name-history)))
3283 (concat prompt " (`M-p' for defaults) ")
3284 gnus-article-save-directory
3286 gnus-article-save-directory)))
3287 (car (push result file-name-history)))))))
3288 ;; Create the directory.
3289 (gnus-make-directory (file-name-directory file))
3290 ;; If we have read a directory, we append the default file name.
3291 (when (file-directory-p file)
3292 (setq file (expand-file-name (file-name-nondirectory
3294 (file-name-as-directory file))))
3295 ;; Possibly translate some characters.
3296 (nnheader-translate-file-chars file))))))
3297 (gnus-make-directory (file-name-directory result))
3298 (set variable result)))
3300 (defun gnus-article-archive-name (group)
3301 "Return the first instance of an \"Archive-name\" in the current buffer."
3302 (let ((case-fold-search t))
3303 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3304 (nnheader-concat gnus-article-save-directory
3305 (match-string 1)))))
3307 (defun gnus-article-nndoc-name (group)
3308 "If GROUP is an nndoc group, return the name of the parent group."
3309 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3310 (gnus-group-get-parameter group 'save-article-group)))
3312 (defun gnus-summary-save-in-rmail (&optional filename)
3313 "Append this article to Rmail file.
3314 Optional argument FILENAME specifies file name.
3315 Directory to save to is default to `gnus-article-save-directory'."
3316 (setq filename (gnus-read-save-file-name
3317 "Save %s in rmail file:" filename
3318 gnus-rmail-save-name gnus-newsgroup-name
3319 gnus-current-headers 'gnus-newsgroup-last-rmail))
3320 (gnus-eval-in-buffer-window gnus-save-article-buffer
3324 (gnus-output-to-rmail filename))))
3327 (defun gnus-summary-save-in-mail (&optional filename)
3328 "Append this article to Unix mail file.
3329 Optional argument FILENAME specifies file name.
3330 Directory to save to is default to `gnus-article-save-directory'."
3331 (setq filename (gnus-read-save-file-name
3332 "Save %s in Unix mail file:" filename
3333 gnus-mail-save-name gnus-newsgroup-name
3334 gnus-current-headers 'gnus-newsgroup-last-mail))
3335 (gnus-eval-in-buffer-window gnus-save-article-buffer
3339 (if (and (file-readable-p filename)
3340 (file-regular-p filename)
3341 (mail-file-babyl-p filename))
3342 (rmail-output-to-rmail-file filename t)
3343 (gnus-output-to-mail filename)))))
3346 (defun gnus-summary-save-in-file (&optional filename overwrite)
3347 "Append this article to file.
3348 Optional argument FILENAME specifies file name.
3349 Directory to save to is default to `gnus-article-save-directory'."
3350 (setq filename (gnus-read-save-file-name
3351 "Save %s in file:" filename
3352 gnus-file-save-name gnus-newsgroup-name
3353 gnus-current-headers 'gnus-newsgroup-last-file))
3354 (gnus-eval-in-buffer-window gnus-save-article-buffer
3358 (when (and overwrite
3359 (file-exists-p filename))
3360 (delete-file filename))
3361 (gnus-output-to-file filename))))
3364 (defun gnus-summary-write-to-file (&optional filename)
3365 "Write this article to a file, overwriting it if the file exists.
3366 Optional argument FILENAME specifies file name.
3367 The directory to save in defaults to `gnus-article-save-directory'."
3368 (gnus-summary-save-in-file nil t))
3370 (defun gnus-summary-save-body-in-file (&optional filename)
3371 "Append this article body to a file.
3372 Optional argument FILENAME specifies file name.
3373 The directory to save in defaults to `gnus-article-save-directory'."
3374 (setq filename (gnus-read-save-file-name
3375 "Save %s body in file:" filename
3376 gnus-file-save-name gnus-newsgroup-name
3377 gnus-current-headers 'gnus-newsgroup-last-file))
3378 (gnus-eval-in-buffer-window gnus-save-article-buffer
3382 (when (article-goto-body)
3383 (narrow-to-region (point) (point-max)))
3384 (gnus-output-to-file filename))))
3387 (defun gnus-summary-save-in-pipe (&optional command)
3388 "Pipe this article to subprocess."
3390 (cond ((and (eq command 'default)
3391 gnus-last-shell-command)
3392 gnus-last-shell-command)
3397 "Shell command on %s: "
3398 (if (and gnus-number-of-articles-to-be-saved
3399 (> gnus-number-of-articles-to-be-saved 1))
3400 (format "these %d articles"
3401 gnus-number-of-articles-to-be-saved)
3403 gnus-last-shell-command))))
3404 (when (string-equal command "")
3405 (if gnus-last-shell-command
3406 (setq command gnus-last-shell-command)
3407 (error "A command is required")))
3408 (gnus-eval-in-buffer-window gnus-article-buffer
3411 (shell-command-on-region (point-min) (point-max) command nil)))
3412 (setq gnus-last-shell-command command))
3414 (defun gnus-summary-pipe-to-muttprint (&optional command)
3415 "Pipe this article to muttprint."
3416 (setq command (read-string
3417 "Print using command: " gnus-summary-muttprint-program
3418 nil gnus-summary-muttprint-program))
3419 (gnus-summary-save-in-pipe command))
3421 ;;; Article file names when saving.
3423 (defun gnus-capitalize-newsgroup (newsgroup)
3424 "Capitalize NEWSGROUP name."
3425 (when (not (zerop (length newsgroup)))
3426 (concat (char-to-string (upcase (aref newsgroup 0)))
3427 (substring newsgroup 1))))
3429 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3430 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3431 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3432 Otherwise, it is like ~/News/news/group/num."
3435 (concat (if (gnus-use-long-file-name 'not-save)
3436 (gnus-capitalize-newsgroup newsgroup)
3437 (gnus-newsgroup-directory-form newsgroup))
3438 "/" (int-to-string (mail-header-number headers)))
3439 gnus-article-save-directory)))
3441 (string-equal (file-name-directory default)
3442 (file-name-directory last-file))
3443 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3445 (or last-file default))))
3447 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3448 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3449 If variable `gnus-use-long-file-name' is non-nil, it is
3450 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3453 (concat (if (gnus-use-long-file-name 'not-save)
3455 (gnus-newsgroup-directory-form newsgroup))
3456 "/" (int-to-string (mail-header-number headers)))
3457 gnus-article-save-directory)))
3459 (string-equal (file-name-directory default)
3460 (file-name-directory last-file))
3461 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3463 (or last-file default))))
3465 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3466 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3467 If variable `gnus-use-long-file-name' is non-nil, it is
3468 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3471 (if (gnus-use-long-file-name 'not-save)
3474 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3476 gnus-article-save-directory)))
3478 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3479 "Generate file name from sender."
3480 (let ((from (mail-header-from headers)))
3482 (if (and from (string-match "\\([^ <]+\\)@" from))
3483 (match-string 1 from)
3485 gnus-article-save-directory)))
3487 (defun article-verify-x-pgp-sig ()
3490 (if (gnus-buffer-live-p gnus-original-article-buffer)
3491 (let ((sig (with-current-buffer gnus-original-article-buffer
3492 (gnus-fetch-field "X-PGP-Sig")))
3496 (mml2015-clear-verify-function))
3498 (insert-buffer-substring gnus-original-article-buffer)
3499 (setq items (split-string sig))
3500 (message-narrow-to-head)
3501 (let ((inhibit-point-motion-hooks t)
3502 (case-fold-search t))
3503 ;; Don't verify multiple headers.
3504 (setq headers (mapconcat (lambda (header)
3506 (mail-fetch-field header)
3508 (split-string (nth 1 items) ",") "")))
3509 (delete-region (point-min) (point-max))
3510 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3511 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3516 (if (looking-at "^-")
3519 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3520 (insert "Version: " (car items) "\n\n")
3521 (insert (mapconcat 'identity (cddr items) "\n"))
3522 (insert "\n-----END PGP SIGNATURE-----\n")
3523 (let ((mm-security-handle (list (format "multipart/signed"))))
3524 (mml2015-clean-buffer)
3525 (let ((coding-system-for-write (or gnus-newsgroup-charset
3527 (funcall (mml2015-clear-verify-function)))
3529 (or (mm-handle-multipart-ctl-parameter
3530 mm-security-handle 'gnus-details)
3531 (mm-handle-multipart-ctl-parameter
3532 mm-security-handle 'gnus-info)))))
3534 (let ((inhibit-read-only t) bface eface)
3536 (message-narrow-to-head)
3537 (goto-char (point-max))
3539 (setq bface (get-text-property (point-at-bol) 'face)
3540 eface (get-text-property (1- (point-at-eol)) 'face))
3541 (message-remove-header "X-Gnus-PGP-Verify")
3542 (if (re-search-forward "^X-PGP-Sig:" nil t)
3544 (goto-char (point-max)))
3545 (narrow-to-region (point) (point))
3546 (insert "X-Gnus-PGP-Verify: " info "\n")
3547 (goto-char (point-min))
3550 (if (not (looking-at "^[ \t]"))
3554 (goto-char (point-min))
3555 (when (looking-at "\\([^:]+\\): *")
3556 (put-text-property (match-beginning 1) (1+ (match-end 1))
3558 (put-text-property (match-end 0) (point-max)
3559 'face eface)))))))))
3561 (defun article-verify-cancel-lock ()
3562 "Verify Cancel-Lock header."
3564 (if (gnus-buffer-live-p gnus-original-article-buffer)
3565 (canlock-verify gnus-original-article-buffer)))
3572 (setq afunc (car func)
3575 gfunc (intern (format "gnus-%s" func))))
3577 (when (fboundp afunc)
3578 `(lambda (&optional interactive &rest args)
3579 ,(documentation afunc t)
3580 (interactive (list t))
3582 (set-buffer gnus-article-buffer)
3584 (call-interactively ',afunc)
3585 (apply ',afunc args))))))))
3586 '(article-hide-headers
3587 article-verify-x-pgp-sig
3588 article-verify-cancel-lock
3589 article-hide-boring-headers
3590 article-treat-overstrike
3591 article-treat-ansi-sequences
3592 article-fill-long-lines
3593 article-capitalize-sentences
3595 article-remove-leading-whitespace
3596 article-display-x-face
3597 article-display-face
3598 article-de-quoted-unreadable
3599 article-de-base64-unreadable
3602 article-unsplit-urls
3603 article-hide-list-identifiers
3604 article-strip-banner
3607 article-hide-signature
3608 article-strip-headers-in-body
3609 article-remove-trailing-blank-lines
3610 article-strip-leading-blank-lines
3611 article-strip-multiple-blank-lines
3612 article-strip-leading-space
3613 article-strip-trailing-space
3614 article-strip-blank-lines
3615 article-strip-all-blank-lines
3617 article-date-english
3618 article-date-iso8601
3619 article-date-original
3621 article-decode-mime-words
3622 article-decode-charset
3623 article-decode-encoded-words
3627 article-treat-dumbquotes
3628 article-normalize-headers
3629 ;; (article-show-all . gnus-article-show-all-headers)
3633 ;;; Gnus article mode
3636 (put 'gnus-article-mode 'mode-class 'special)
3638 (set-keymap-parent gnus-article-mode-map widget-keymap)
3640 (gnus-define-keys gnus-article-mode-map
3641 " " gnus-article-goto-next-page
3642 "\177" gnus-article-goto-prev-page
3643 [delete] gnus-article-goto-prev-page
3644 [backspace] gnus-article-goto-prev-page
3645 "\C-c^" gnus-article-refer-article
3646 "h" gnus-article-show-summary
3647 "s" gnus-article-show-summary
3648 "\C-c\C-m" gnus-article-mail
3649 "?" gnus-article-describe-briefly
3650 "e" gnus-summary-edit-article
3651 "<" beginning-of-buffer
3653 "\C-c\C-i" gnus-info-find-node
3655 "R" gnus-article-reply-with-original
3656 "F" gnus-article-followup-with-original
3657 "\C-hk" gnus-article-describe-key
3658 "\C-hc" gnus-article-describe-key-briefly
3660 "\C-d" gnus-article-read-summary-keys
3661 "\M-*" gnus-article-read-summary-keys
3662 "\M-#" gnus-article-read-summary-keys
3663 "\M-^" gnus-article-read-summary-keys
3664 "\M-g" gnus-article-read-summary-keys)
3666 (substitute-key-definition
3667 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3669 (defun gnus-article-make-menu-bar ()
3670 (unless (boundp 'gnus-article-commands-menu)
3671 (gnus-summary-make-menu-bar))
3672 (gnus-turn-off-edit-menu 'article)
3673 (unless (boundp 'gnus-article-article-menu)
3675 gnus-article-article-menu gnus-article-mode-map ""
3677 ["Scroll forwards" gnus-article-goto-next-page t]
3678 ["Scroll backwards" gnus-article-goto-prev-page t]
3679 ["Show summary" gnus-article-show-summary t]
3680 ["Fetch Message-ID at point" gnus-article-refer-article t]
3681 ["Mail to address at point" gnus-article-mail t]
3682 ["Send a bug report" gnus-bug t]))
3685 gnus-article-treatment-menu gnus-article-mode-map ""
3686 ;; Fixme: this should use :active (and maybe :visible).
3688 ["Hide headers" gnus-article-hide-headers t]
3689 ["Hide signature" gnus-article-hide-signature t]
3690 ["Hide citation" gnus-article-hide-citation t]
3691 ["Treat overstrike" gnus-article-treat-overstrike t]
3692 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3693 ["Remove carriage return" gnus-article-remove-cr t]
3694 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3695 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3696 ["Remove base64" gnus-article-de-base64-unreadable t]
3697 ["Treat html" gnus-article-wash-html t]
3698 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3699 ["Decode HZ" gnus-article-decode-HZ t]))
3701 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3703 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3705 (gnus-run-hooks 'gnus-article-menu-hook)))
3707 (defun gnus-article-mode ()
3708 "Major mode for displaying an article.
3710 All normal editing commands are switched off.
3712 The following commands are available in addition to all summary mode
3714 \\<gnus-article-mode-map>
3715 \\[gnus-article-next-page]\t Scroll the article one page forwards
3716 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3717 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3718 \\[gnus-article-show-summary]\t Display the summary buffer
3719 \\[gnus-article-mail]\t Send a reply to the address near point
3720 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3721 \\[gnus-info-find-node]\t Go to the Gnus info node"
3723 (gnus-simplify-mode-line)
3724 (setq mode-name "Article")
3725 (setq major-mode 'gnus-article-mode)
3726 (make-local-variable 'minor-mode-alist)
3727 (use-local-map gnus-article-mode-map)
3728 (when (gnus-visual-p 'article-menu 'menu)
3729 (gnus-article-make-menu-bar)
3730 (when gnus-summary-tool-bar-map
3731 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3732 (gnus-update-format-specifications nil 'article-mode)
3733 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3734 (set (make-local-variable 'gnus-page-broken) nil)
3735 (make-local-variable 'gnus-button-marker-list)
3736 (make-local-variable 'gnus-article-current-summary)
3737 (make-local-variable 'gnus-article-mime-handles)
3738 (make-local-variable 'gnus-article-decoded-p)
3739 (make-local-variable 'gnus-article-mime-handle-alist)
3740 (make-local-variable 'gnus-article-wash-types)
3741 (make-local-variable 'gnus-article-image-alist)
3742 (make-local-variable 'gnus-article-charset)
3743 (make-local-variable 'gnus-article-ignored-charsets)
3744 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3745 (set (make-local-variable 'show-nonbreak-escape) nil)
3746 (gnus-set-default-directory)
3747 (buffer-disable-undo)
3748 (setq buffer-read-only t
3749 show-trailing-whitespace nil)
3750 (set-syntax-table gnus-article-mode-syntax-table)
3751 (mm-enable-multibyte)
3752 (gnus-run-hooks 'gnus-article-mode-hook))
3754 (defun gnus-article-setup-buffer ()
3755 "Initialize the article buffer."
3756 (let* ((name (if gnus-single-article-buffer "*Article*"
3757 (concat "*Article " gnus-newsgroup-name "*")))
3759 (progn (string-match "\\*Article" name)
3760 (concat " *Original Article"
3761 (substring name (match-end 0))))))
3762 (setq gnus-article-buffer name)
3763 (setq gnus-original-article-buffer original)
3764 (setq gnus-article-mime-handle-alist nil)
3765 ;; This might be a variable local to the summary buffer.
3766 (unless gnus-single-article-buffer
3768 (set-buffer gnus-summary-buffer)
3769 (setq gnus-article-buffer name)
3770 (setq gnus-original-article-buffer original)
3771 (gnus-set-global-variables)))
3772 (gnus-article-setup-highlight-words)
3773 ;; Init original article buffer.
3775 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3776 (mm-enable-multibyte)
3777 (setq major-mode 'gnus-original-article-mode)
3778 (make-local-variable 'gnus-original-article))
3779 (if (and (get-buffer name)
3780 (with-current-buffer name
3781 (if gnus-article-edit-mode
3782 (if (y-or-n-p "Article mode edit in progress; discard? ")
3784 (set-buffer-modified-p nil)
3785 (gnus-kill-buffer name)
3788 (error "Action aborted"))
3792 (set (make-local-variable 'gnus-article-edit-mode) nil)
3793 (when gnus-article-mime-handles
3794 (mm-destroy-parts gnus-article-mime-handles)
3795 (setq gnus-article-mime-handles nil))
3796 ;; Set it to nil in article-buffer!
3797 (setq gnus-article-mime-handle-alist nil)
3798 (buffer-disable-undo)
3799 (setq buffer-read-only t)
3800 ;; This list just keeps growing if we don't reset it.
3801 (setq gnus-button-marker-list nil)
3802 (unless (eq major-mode 'gnus-article-mode)
3803 (gnus-article-mode))
3806 (set-buffer (gnus-get-buffer-create name))
3808 (make-local-variable 'gnus-summary-buffer)
3809 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3810 (current-buffer)))))
3812 ;; Set article window start at LINE, where LINE is the number of lines
3813 ;; from the head of the article.
3814 (defun gnus-article-set-window-start (&optional line)
3816 (gnus-get-buffer-window gnus-article-buffer t)
3818 (set-buffer gnus-article-buffer)
3819 (goto-char (point-min))
3822 (gnus-message 6 "Moved to bookmark")
3823 (search-forward "\n\n" nil t)
3827 (defun gnus-article-prepare (article &optional all-headers header)
3828 "Prepare ARTICLE in article mode buffer.
3829 ARTICLE should either be an article number or a Message-ID.
3830 If ARTICLE is an id, HEADER should be the article headers.
3831 If ALL-HEADERS is non-nil, no headers are hidden."
3833 ;; Make sure we start in a summary buffer.
3834 (unless (eq major-mode 'gnus-summary-mode)
3835 (set-buffer gnus-summary-buffer))
3836 (setq gnus-summary-buffer (current-buffer))
3837 (let* ((gnus-article (if header (mail-header-number header) article))
3838 (summary-buffer (current-buffer))
3839 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3840 (group gnus-newsgroup-name)
3843 (gnus-article-setup-buffer)
3844 (set-buffer gnus-article-buffer)
3845 ;; Deactivate active regions.
3846 (when (and (boundp 'transient-mark-mode)
3847 transient-mark-mode)
3848 (setq mark-active nil))
3849 (if (not (setq result (let ((inhibit-read-only t))
3850 (gnus-request-article-this-buffer
3852 ;; There is no such article.
3854 (when (and (numberp article)
3855 (not (memq article gnus-newsgroup-sparse)))
3856 (setq gnus-article-current
3857 (cons gnus-newsgroup-name article))
3858 (set-buffer gnus-summary-buffer)
3859 (setq gnus-current-article article)
3860 (if (and (memq article gnus-newsgroup-undownloaded)
3861 (not (gnus-online (gnus-find-method-for-group
3862 gnus-newsgroup-name))))
3864 (gnus-summary-set-agent-mark article)
3865 (message "Message marked for downloading"))
3866 (gnus-summary-mark-article article gnus-canceled-mark)
3867 (unless (memq article gnus-newsgroup-sparse)
3868 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3869 (if (or (eq result 'pseudo)
3870 (eq result 'nneething))
3873 (set-buffer summary-buffer)
3874 (push article gnus-newsgroup-history)
3875 (setq gnus-last-article gnus-current-article
3876 gnus-current-article 0
3877 gnus-current-headers nil
3878 gnus-article-current nil)
3879 (if (eq result 'nneething)
3880 (gnus-configure-windows 'summary)
3881 (gnus-configure-windows 'article))
3882 (gnus-set-global-variables))
3883 (let ((gnus-article-mime-handle-alist-1
3884 gnus-article-mime-handle-alist))
3885 (gnus-set-mode-line 'article)))
3886 ;; The result from the `request' was an actual article -
3887 ;; or at least some text that is now displayed in the
3889 (when (and (numberp article)
3890 (not (eq article gnus-current-article)))
3891 ;; Seems like a new article has been selected.
3892 ;; `gnus-current-article' must be an article number.
3894 (set-buffer summary-buffer)
3895 (push article gnus-newsgroup-history)
3896 (setq gnus-last-article gnus-current-article
3897 gnus-current-article article
3898 gnus-current-headers
3899 (gnus-summary-article-header gnus-current-article)
3900 gnus-article-current
3901 (cons gnus-newsgroup-name gnus-current-article))
3902 (unless (vectorp gnus-current-headers)
3903 (setq gnus-current-headers nil))
3904 (gnus-summary-goto-subject gnus-current-article)
3905 (when (gnus-summary-show-thread)
3906 ;; If the summary buffer really was folded, the
3907 ;; previous goto may not actually have gone to
3908 ;; the right article, but the thread root instead.
3910 (gnus-summary-goto-subject gnus-current-article))
3911 (gnus-run-hooks 'gnus-mark-article-hook)
3912 (gnus-set-mode-line 'summary)
3913 (when (gnus-visual-p 'article-highlight 'highlight)
3914 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3915 ;; Set the global newsgroup variables here.
3916 (gnus-set-global-variables)
3917 (setq gnus-have-all-headers
3918 (or all-headers gnus-show-all-headers))))
3920 (gnus-configure-windows 'article))
3921 (when (or (numberp article)
3923 (gnus-article-prepare-display)
3925 (goto-char (point-min))
3926 (when gnus-break-pages
3927 (gnus-narrow-to-page)))
3928 (let ((gnus-article-mime-handle-alist-1
3929 gnus-article-mime-handle-alist))
3930 (gnus-set-mode-line 'article))
3934 (set-window-point (get-buffer-window (current-buffer)) (point))
3935 (gnus-configure-windows 'article)
3939 (defun gnus-article-prepare-display ()
3940 "Make the current buffer look like a nice article."
3941 ;; Hooks for getting information from the article.
3942 ;; This hook must be called before being narrowed.
3943 (let ((gnus-article-buffer (current-buffer))
3945 (inhibit-read-only t))
3946 (unless (eq major-mode 'gnus-article-mode)
3947 (gnus-article-mode))
3948 (setq buffer-read-only nil
3949 gnus-article-wash-types nil
3950 gnus-article-image-alist nil)
3951 (gnus-run-hooks 'gnus-tmp-internal-hook)
3952 (when gnus-display-mime-function
3953 (funcall gnus-display-mime-function))
3954 (gnus-run-hooks 'gnus-article-prepare-hook)))
3957 ;;; Gnus MIME viewing functions
3960 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3961 "Format of the MIME buttons.
3963 Valid specifiers include:
3965 %T MIME type, along with additional info
3966 %n The `name' parameter
3967 %d The description, if any
3968 %l The length of the encoded part
3969 %p The part identifier number
3970 %e Dots if the part isn't displayed
3972 General format specifiers can also be used. See Info node
3973 `(gnus)Formatting Variables'.")
3975 (defvar gnus-mime-button-line-format-alist
3976 '((?t gnus-tmp-type ?s)
3977 (?T gnus-tmp-type-long ?s)
3978 (?n gnus-tmp-name ?s)
3979 (?d gnus-tmp-description ?s)
3981 (?l gnus-tmp-length ?d)
3982 (?e gnus-tmp-dots ?s)))
3984 (defvar gnus-mime-button-commands
3985 '((gnus-article-press-button "\r" "Toggle Display")
3986 (gnus-mime-view-part "v" "View Interactively...")
3987 (gnus-mime-view-part-as-type "t" "View As Type...")
3988 (gnus-mime-view-part-as-charset "C" "View As charset...")
3989 (gnus-mime-save-part "o" "Save...")
3990 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3991 (gnus-mime-delete-part "d" "Delete part")
3992 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3993 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3994 (gnus-mime-view-part-internally "E" "View Internally")
3995 (gnus-mime-view-part-externally "e" "View Externally")
3996 (gnus-mime-print-part "p" "Print")
3997 (gnus-mime-pipe-part "|" "Pipe To Command...")
3998 (gnus-mime-action-on-part "." "Take action on the part...")))
4000 (defun gnus-article-mime-part-status ()
4001 (if gnus-article-mime-handle-alist-1
4002 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4004 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4007 (defvar gnus-mime-button-map
4008 (let ((map (make-sparse-keymap)))
4009 (define-key map gnus-mouse-2 'gnus-article-push-button)
4010 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4011 (dolist (c gnus-mime-button-commands)
4012 (define-key map (cadr c) (car c)))
4016 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4018 ,@(mapcar (lambda (c)
4019 (vector (caddr c) (car c) :enable t))
4020 gnus-mime-button-commands)))
4022 (defun gnus-mime-button-menu (event prefix)
4023 "Construct a context-sensitive menu of MIME commands."
4024 (interactive "e\nP")
4025 (save-window-excursion
4026 (let ((pos (event-start event)))
4027 (select-window (posn-window pos))
4028 (goto-char (posn-point pos))
4029 (gnus-article-check-buffer)
4030 (popup-menu gnus-mime-button-menu nil prefix))))
4032 (defun gnus-mime-view-all-parts (&optional handles)
4033 "View all the MIME parts."
4035 (with-current-buffer gnus-article-buffer
4036 (let ((handles (or handles gnus-article-mime-handles))
4037 (mail-parse-charset gnus-newsgroup-charset)
4038 (mail-parse-ignored-charsets
4039 (with-current-buffer gnus-summary-buffer
4040 gnus-newsgroup-ignored-charsets)))
4042 (mm-remove-parts handles)
4043 (goto-char (point-min))
4044 (or (search-forward "\n\n") (goto-char (point-max)))
4045 (let ((inhibit-read-only t))
4046 (delete-region (point) (point-max))
4047 (mm-display-parts handles))))))
4050 (defsubst gnus-article-edit-part (handles)
4051 "Edit an article in order to delete a mime part.
4052 This function is exclusively used by `gnus-mime-save-part-and-strip'
4053 and `gnus-mime-delete-part', and not provided at run-time normally."
4054 (gnus-article-edit-article
4057 (let ((mail-parse-charset (or gnus-article-charset
4058 ',gnus-newsgroup-charset))
4059 (mail-parse-ignored-charsets
4060 (or gnus-article-ignored-charsets
4061 ',gnus-newsgroup-ignored-charsets))
4062 (mbl mml-buffer-list))
4063 (setq mml-buffer-list nil)
4064 (insert-buffer gnus-original-article-buffer)
4065 (mime-to-mml ',handles)
4066 (setq gnus-article-mime-handles nil)
4067 (let ((mbl1 mml-buffer-list))
4068 (setq mml-buffer-list mbl)
4069 (set (make-local-variable 'mml-buffer-list) mbl1))
4070 (gnus-make-local-hook 'kill-buffer-hook)
4071 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4072 `(lambda (no-highlight)
4073 (let ((mail-parse-charset (or gnus-article-charset
4074 ',gnus-newsgroup-charset))
4075 (message-options message-options)
4076 (message-options-set-recipient)
4077 (mail-parse-ignored-charsets
4078 (or gnus-article-ignored-charsets
4079 ',gnus-newsgroup-ignored-charsets)))
4081 (mml-destroy-buffers)
4082 (remove-hook 'kill-buffer-hook
4083 'mml-destroy-buffers t)
4084 (kill-local-variable 'mml-buffer-list))
4085 (gnus-summary-edit-article-done
4086 ,(or (mail-header-references gnus-current-headers) "")
4087 ,(gnus-group-read-only-p)
4088 ,gnus-summary-buffer no-highlight)))
4089 (gnus-article-edit-done)
4090 (gnus-summary-expand-window)
4091 (gnus-summary-show-article)))
4093 (defun gnus-mime-save-part-and-strip ()
4094 "Save the MIME part under point then replace it with an external body."
4096 (gnus-article-check-buffer)
4097 (when (gnus-group-read-only-p)
4098 (error "The current group does not support deleting of parts"))
4099 (when (mm-complicated-handles gnus-article-mime-handles)
4101 The current article has a complicated MIME structure, giving up..."))
4102 (when (gnus-yes-or-no-p "\
4103 Deleting parts may malfunction or destroy the article; continue? ")
4104 (let* ((data (get-text-property (point) 'gnus-data))
4106 (handles gnus-article-mime-handles))
4107 (setq file (and data (mm-save-part data)))
4109 (with-current-buffer (mm-handle-buffer data)
4111 (insert "Content-Type: " (mm-handle-media-type data))
4112 (mml-insert-parameter-string (cdr (mm-handle-type data))
4115 (insert "Content-ID: " (message-make-message-id) "\n")
4116 (insert "Content-Transfer-Encoding: binary\n")
4119 (cdr (mm-make-handle nil
4120 `("message/external-body"
4121 (access-type . "LOCAL-FILE")
4123 (set-buffer gnus-summary-buffer)
4124 (gnus-article-edit-part handles)))))
4126 (defun gnus-mime-delete-part ()
4127 "Delete the MIME part under point.
4128 Replace it with some information about the removed part."
4130 (gnus-article-check-buffer)
4131 (when (gnus-group-read-only-p)
4132 (error "The current group does not support deleting of parts"))
4133 (when (mm-complicated-handles gnus-article-mime-handles)
4135 The current article has a complicated MIME structure, giving up..."))
4136 (when (gnus-yes-or-no-p "\
4137 Deleting parts may malfunction or destroy the article; continue? ")
4138 (let* ((data (get-text-property (point) 'gnus-data))
4139 (handles gnus-article-mime-handles)
4143 (mail-decode-encoded-word-string (or (mm-handle-description data)
4146 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4148 (type (mm-handle-media-type data)))
4150 (error "No MIME part under point"))
4151 (with-current-buffer (mm-handle-buffer data)
4152 (let ((bsize (format "%s" (buffer-size))))
4157 "| The following attachment has been deleted:\n"
4159 "| Type: " type "\n"
4160 "| Filename: " filename "\n"
4161 "| Size (encoded): " bsize " Byte\n"
4162 "| Description: " description "\n"
4165 (cdr (mm-make-handle
4166 nil `("text/plain") nil nil
4168 (format "Deleted attachment (%s bytes)" bsize))))))
4169 (set-buffer gnus-summary-buffer)
4170 (gnus-article-edit-part handles))))
4172 (defun gnus-mime-save-part ()
4173 "Save the MIME part under point."
4175 (gnus-article-check-buffer)
4176 (let ((data (get-text-property (point) 'gnus-data)))
4178 (mm-save-part data))))
4180 (defun gnus-mime-pipe-part ()
4181 "Pipe the MIME part under point to a process."
4183 (gnus-article-check-buffer)
4184 (let ((data (get-text-property (point) 'gnus-data)))
4186 (mm-pipe-part data))))
4188 (defun gnus-mime-view-part ()
4189 "Interactively choose a viewing method for the MIME part under point."
4191 (gnus-article-check-buffer)
4192 (let ((data (get-text-property (point) 'gnus-data)))
4194 (setq gnus-article-mime-handles
4196 gnus-article-mime-handles (setq data (copy-sequence data))))
4197 (mm-interactively-view-part data))))
4199 (defun gnus-mime-view-part-as-type-internal ()
4200 (gnus-article-check-buffer)
4201 (let* ((name (mail-content-type-get
4202 (mm-handle-type (get-text-property (point) 'gnus-data))
4204 (def-type (and name (mm-default-file-encoding name))))
4205 (and def-type (cons def-type 0))))
4207 (defun gnus-mime-view-part-as-type (&optional mime-type)
4208 "Choose a MIME media type, and view the part as such."
4211 (setq mime-type (completing-read
4212 "View as MIME type: "
4213 (mapcar #'list (mailcap-mime-types))
4215 (gnus-mime-view-part-as-type-internal))))
4216 (gnus-article-check-buffer)
4217 (let ((handle (get-text-property (point) 'gnus-data)))
4220 (mm-make-handle (mm-handle-buffer handle)
4221 (cons mime-type (cdr (mm-handle-type handle)))
4222 (mm-handle-encoding handle)
4223 (mm-handle-undisplayer handle)
4224 (mm-handle-disposition handle)
4225 (mm-handle-description handle)
4227 (mm-handle-id handle)))
4228 (setq gnus-article-mime-handles
4229 (mm-merge-handles gnus-article-mime-handles handle))
4230 (gnus-mm-display-part handle))))
4232 (defun gnus-mime-copy-part (&optional handle arg)
4233 "Put the MIME part under point into a new buffer.
4234 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4236 (interactive (list nil current-prefix-arg))
4237 (gnus-article-check-buffer)
4239 (setq handle (get-text-property (point) 'gnus-data)))
4241 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4243 (mail-content-type-get (mm-handle-disposition handle)
4245 contents dont-decode charset coding-system)
4246 (mm-with-unibyte-buffer
4247 (mm-insert-part handle)
4248 (setq contents (or (condition-case nil
4249 (mm-decompress-buffer filename nil 'sig)
4251 (setq dont-decode t)
4254 (setq filename (cond (filename (file-name-nondirectory filename))
4255 (dont-decode "*raw data*")
4260 (unless (setq charset (mail-content-type-get
4261 (mm-handle-type handle) 'charset))
4262 (unless (setq coding-system (mm-with-unibyte-buffer
4264 (mm-find-buffer-file-coding-system)))
4265 (setq charset gnus-newsgroup-charset))))
4267 (setq charset (or (cdr (assq arg
4268 gnus-summary-show-article-charset-alist))
4269 (mm-read-coding-system "Charset: ")))))
4270 (switch-to-buffer (generate-new-buffer filename))
4271 (if (or coding-system
4273 (setq coding-system (mm-charset-to-coding-system charset))
4274 (not (eq charset 'ascii))))
4276 (mm-enable-multibyte)
4277 (insert (mm-decode-coding-string contents coding-system))
4278 (setq buffer-file-coding-system
4279 (if (boundp 'last-coding-system-used)
4280 (symbol-value 'last-coding-system-used)
4282 (mm-disable-multibyte)
4284 (setq buffer-file-coding-system mm-binary-coding-system))
4285 ;; We do it this way to make `normal-mode' set the appropriate mode.
4288 (setq buffer-file-name (expand-file-name filename))
4290 (setq buffer-file-name nil))
4291 (goto-char (point-min)))))
4293 (defun gnus-mime-print-part (&optional handle filename)
4294 "Print the MIME part under point."
4295 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4296 (gnus-article-check-buffer)
4297 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4298 (contents (and handle (mm-get-part handle)))
4299 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4300 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4305 (mm-save-part-to-file handle file)
4306 (call-process shell-file-name nil
4307 (generate-new-buffer " *mm*")
4309 shell-command-switch
4311 printer file (mm-handle-type handle))))
4315 (gnus-print-buffer))
4316 (ps-despool filename)))))
4318 (defun gnus-mime-inline-part (&optional handle arg)
4319 "Insert the MIME part under point into the current buffer.
4320 Compressed files like .gz and .bz2 are decompressed."
4321 (interactive (list nil current-prefix-arg))
4322 (gnus-article-check-buffer)
4324 (setq handle (get-text-property (point) 'gnus-data)))
4327 (inhibit-read-only t)
4328 contents charset coding-system)
4329 (if (and (not arg) (mm-handle-undisplayer handle))
4330 (mm-remove-part handle)
4331 (mm-with-unibyte-buffer
4332 (mm-insert-part handle)
4334 (or (mm-decompress-buffer
4335 (or (mail-content-type-get (mm-handle-disposition handle)
4337 (mail-content-type-get (mm-handle-disposition handle)
4343 (unless (setq charset (mail-content-type-get
4344 (mm-handle-type handle) 'charset))
4345 (unless (setq coding-system
4346 (mm-with-unibyte-buffer
4348 (mm-find-buffer-file-coding-system)))
4349 (setq charset gnus-newsgroup-charset))))
4351 (if (mm-handle-undisplayer handle)
4352 (mm-remove-part handle))
4355 gnus-summary-show-article-charset-alist))
4356 (mm-read-coding-system "Charset: "))))
4358 (if (mm-handle-undisplayer handle)
4359 (mm-remove-part handle))))
4363 (if (or coding-system
4366 (mm-charset-to-coding-system charset))
4367 (not (eq charset 'ascii))))
4368 (mm-decode-coding-string contents coding-system)
4369 (mm-string-to-multibyte contents)))
4372 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4373 "Insert the MIME part under point into the current buffer using the
4375 (interactive (list nil current-prefix-arg))
4376 (gnus-article-check-buffer)
4377 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4380 (inhibit-read-only t))
4382 (if (mm-handle-undisplayer handle)
4383 (mm-remove-part handle))
4384 (let ((gnus-newsgroup-charset
4386 gnus-summary-show-article-charset-alist))
4387 (mm-read-coding-system "Charset: ")))
4388 (gnus-newsgroup-ignored-charsets 'gnus-all))
4389 (gnus-article-press-button)))))
4391 (defun gnus-mime-view-part-externally (&optional handle)
4392 "View the MIME part under point with an external viewer."
4394 (gnus-article-check-buffer)
4395 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4396 (mm-user-display-methods nil)
4397 (mm-inlined-types nil)
4398 (mail-parse-charset gnus-newsgroup-charset)
4399 (mail-parse-ignored-charsets
4400 (with-current-buffer gnus-summary-buffer
4401 gnus-newsgroup-ignored-charsets)))
4403 (if (mm-handle-undisplayer handle)
4404 (mm-remove-part handle)
4405 (mm-display-part handle)))))
4407 (defun gnus-mime-view-part-internally (&optional handle)
4408 "View the MIME part under point with an internal viewer.
4409 If no internal viewer is available, use an external viewer."
4411 (gnus-article-check-buffer)
4412 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4413 (mm-inlined-types '(".*"))
4414 (mm-inline-large-images t)
4415 (mail-parse-charset gnus-newsgroup-charset)
4416 (mail-parse-ignored-charsets
4417 (with-current-buffer gnus-summary-buffer
4418 gnus-newsgroup-ignored-charsets))
4419 (inhibit-read-only t))
4421 (if (mm-handle-undisplayer handle)
4422 (mm-remove-part handle)
4423 (mm-display-part handle)))))
4425 (defun gnus-mime-action-on-part (&optional action)
4426 "Do something with the MIME attachment at \(point\)."
4428 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4429 (gnus-article-check-buffer)
4430 (let ((action-pair (assoc action gnus-mime-action-alist)))
4432 (funcall (cdr action-pair)))))
4434 (defun gnus-article-part-wrapper (n function)
4435 (with-current-buffer gnus-article-buffer
4436 (when (> n (length gnus-article-mime-handle-alist))
4437 (error "No such part"))
4438 (gnus-article-goto-part n)
4439 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4440 (funcall function handle))))
4442 (defun gnus-article-pipe-part (n)
4443 "Pipe MIME part N, which is the numerical prefix."
4445 (gnus-article-part-wrapper n 'mm-pipe-part))
4447 (defun gnus-article-save-part (n)
4448 "Save MIME part N, which is the numerical prefix."
4450 (gnus-article-part-wrapper n 'mm-save-part))
4452 (defun gnus-article-interactively-view-part (n)
4453 "View MIME part N interactively, which is the numerical prefix."
4455 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4457 (defun gnus-article-copy-part (n)
4458 "Copy MIME part N, which is the numerical prefix."
4460 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4462 (defun gnus-article-view-part-as-charset (n)
4463 "View MIME part N using a specified charset.
4464 N is the numerical prefix."
4466 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4468 (defun gnus-article-view-part-externally (n)
4469 "View MIME part N externally, which is the numerical prefix."
4471 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4473 (defun gnus-article-inline-part (n)
4474 "Inline MIME part N, which is the numerical prefix."
4476 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4478 (defun gnus-article-mime-match-handle-first (condition)
4481 (dolist (ihandle gnus-article-mime-handle-alist)
4483 ((functionp condition)
4484 (funcall condition (cdr ihandle)))
4485 ((eq condition 'undisplayed)
4486 (not (or (mm-handle-undisplayer (cdr ihandle))
4487 (equal (mm-handle-media-type (cdr ihandle))
4488 "multipart/alternative"))))
4489 ((eq condition 'undisplayed-alternative)
4490 (not (mm-handle-undisplayer (cdr ihandle))))
4492 (gnus-article-goto-part (car ihandle))
4493 (or (not n) (< (car ihandle) n)))
4494 (setq n (car ihandle))))
4498 (defun gnus-article-view-part (&optional n)
4499 "View MIME part N, which is the numerical prefix."
4501 (with-current-buffer gnus-article-buffer
4502 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4503 gnus-article-mime-match-handle-function)))
4504 (when (> n (length gnus-article-mime-handle-alist))
4505 (error "No such part"))
4506 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4507 (when (gnus-article-goto-part n)
4508 (if (equal (car handle) "multipart/alternative")
4509 (gnus-article-press-button)
4510 (when (eq (gnus-mm-display-part handle) 'internal)
4511 (gnus-set-window-start)))))))
4513 (defsubst gnus-article-mime-total-parts ()
4514 (if (bufferp (car gnus-article-mime-handles))
4516 (1- (length gnus-article-mime-handles))))
4518 (defun gnus-mm-display-part (handle)
4519 "Display HANDLE and fix MIME button."
4520 (let ((id (get-text-property (point) 'gnus-part))
4522 (inhibit-read-only t))
4525 (let ((window (selected-window))
4526 (mail-parse-charset gnus-newsgroup-charset)
4527 (mail-parse-ignored-charsets
4528 (if (gnus-buffer-live-p gnus-summary-buffer)
4529 (with-current-buffer gnus-summary-buffer
4530 gnus-newsgroup-ignored-charsets)
4534 (let ((win (gnus-get-buffer-window (current-buffer) t))
4537 (select-window win))
4540 (if (mm-handle-displayed-p handle)
4541 ;; This will remove the part.
4542 (mm-display-part handle)
4544 (narrow-to-region (point)
4545 (if (eobp) (point) (1+ (point))))
4546 (mm-display-part handle)
4547 ;; We narrow to the part itself and
4548 ;; then call the treatment functions.
4549 (goto-char (point-min))
4551 (narrow-to-region (point) (point-max))
4554 (gnus-article-mime-total-parts)
4555 (mm-handle-media-type handle)))))
4556 (if (window-live-p window)
4557 (select-window window)))))
4560 (gnus-insert-mime-button
4561 handle id (list (mm-handle-displayed-p handle)))
4562 (goto-char point))))
4564 (defun gnus-article-goto-part (n)
4565 "Go to MIME part N."
4566 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4568 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4569 (let ((gnus-tmp-name
4570 (or (mail-content-type-get (mm-handle-type handle) 'name)
4571 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4572 (mail-content-type-get (mm-handle-type handle) 'url)
4574 (gnus-tmp-type (mm-handle-media-type handle))
4575 (gnus-tmp-description
4576 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4579 (if (if displayed (car displayed)
4580 (mm-handle-displayed-p handle))
4582 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4584 gnus-tmp-type-long b e)
4585 (when (string-match ".*/" gnus-tmp-name)
4586 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4587 (setq gnus-tmp-type-long (concat gnus-tmp-type
4588 (and (not (equal gnus-tmp-name ""))
4589 (concat "; " gnus-tmp-name))))
4590 (unless (equal gnus-tmp-description "")
4591 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4596 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4597 `(keymap ,gnus-mime-button-map
4598 gnus-callback gnus-mm-display-part
4599 gnus-part ,gnus-tmp-id
4600 article-type annotation
4603 ;; Exclude a newline.
4606 (widget-convert-button
4609 :action 'gnus-widget-press-button
4610 :button-keymap gnus-mime-button-map
4612 (lambda (widget/window &optional overlay pos)
4613 ;; Needed to properly clear the message due to a bug in
4614 ;; wid-edit (XEmacs only).
4615 (if (boundp 'help-echo-owns-message)
4616 (setq help-echo-owns-message t))
4618 "%S: %s the MIME part; %S: more options"
4619 (aref gnus-mouse-2 0)
4620 ;; XEmacs will get a single widget arg; Emacs 21 will get
4621 ;; window, overlay, position.
4622 (if (mm-handle-displayed-p
4624 (with-current-buffer (gnus-overlay-buffer overlay)
4625 (widget-get (widget-at (gnus-overlay-start overlay))
4627 (widget-get widget/window :mime-handle)))
4629 (aref gnus-down-mouse-3 0))))))
4631 (defun gnus-widget-press-button (elems el)
4632 (goto-char (widget-get elems :from))
4633 (gnus-article-press-button))
4635 (defvar gnus-displaying-mime nil)
4637 (defun gnus-display-mime (&optional ihandles)
4638 "Display the MIME parts."
4640 (save-selected-window
4641 (let ((window (get-buffer-window gnus-article-buffer))
4644 (select-window window)
4645 ;; We have to do this since selecting the window
4646 ;; may change the point. So we set the window point.
4647 (set-window-point window point)))
4648 (let ((handles ihandles)
4649 (inhibit-read-only t)
4650 handle name type b e display)
4652 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
4653 (when gnus-article-emulate-mime
4654 (mm-uu-dissect-text-parts handles)))
4655 (gnus-article-emulate-mime
4656 (setq handles (mm-uu-dissect))))
4657 (when (and (not ihandles)
4658 (not gnus-displaying-mime))
4659 ;; Top-level call; we clean up.
4660 (when gnus-article-mime-handles
4661 (mm-destroy-parts gnus-article-mime-handles)
4662 (setq gnus-article-mime-handle-alist nil));; A trick.
4663 (setq gnus-article-mime-handles handles)
4664 ;; We allow users to glean info from the handles.
4665 (when gnus-article-mime-part-function
4666 (gnus-mime-part-function handles)))
4668 (or (not (stringp (car handles)))
4671 (when (and (not ihandles)
4672 (not gnus-displaying-mime))
4673 ;; Clean up for mime parts.
4675 (delete-region (point) (point-max)))
4676 (let ((gnus-displaying-mime t))
4677 (gnus-mime-display-part handles)))
4680 (narrow-to-region (point) (point-max))
4681 (gnus-treat-article nil 1 1)
4684 ;; Highlight the headers.
4688 (narrow-to-region (point-min) (point))
4689 (gnus-treat-article 'head))))))))
4691 (defcustom gnus-mime-display-multipart-as-mixed nil
4692 "Display \"multipart\" parts as \"multipart/mixed\".
4694 If t, it overrides nil values of
4695 `gnus-mime-display-multipart-alternative-as-mixed' and
4696 `gnus-mime-display-multipart-related-as-mixed'."
4697 :group 'gnus-article-mime
4700 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4701 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4703 :group 'gnus-article-mime
4706 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4707 "Display \"multipart/related\" parts as \"multipart/mixed\".
4709 If displaying \"text/html\" is discouraged \(see
4710 `mm-discouraged-alternatives'\) images or other material inside a
4711 \"multipart/related\" part might be overlooked when this variable is nil."
4713 :group 'gnus-article-mime
4716 (defun gnus-mime-display-part (handle)
4719 ((not (stringp (car handle)))
4720 (gnus-mime-display-single handle))
4721 ;; User-defined multipart
4722 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4723 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4725 ;; multipart/alternative
4726 ((and (equal (car handle) "multipart/alternative")
4727 (not (or gnus-mime-display-multipart-as-mixed
4728 gnus-mime-display-multipart-alternative-as-mixed)))
4729 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4730 (push (cons id handle) gnus-article-mime-handle-alist)
4731 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4732 ;; multipart/related
4733 ((and (equal (car handle) "multipart/related")
4734 (not (or gnus-mime-display-multipart-as-mixed
4735 gnus-mime-display-multipart-related-as-mixed)))
4736 ;;;!!!We should find the start part, but we just default
4737 ;;;!!!to the first part.
4738 ;;(gnus-mime-display-part (cadr handle))
4739 ;;;!!! Most multipart/related is an HTML message plus images.
4740 ;;;!!! Unfortunately we are unable to let W3 display those
4741 ;;;!!! included images, so we just display it as a mixed multipart.
4742 ;;(gnus-mime-display-mixed (cdr handle))
4743 ;;;!!! No, w3 can display everything just fine.
4744 (gnus-mime-display-part (cadr handle)))
4745 ((equal (car handle) "multipart/signed")
4746 (gnus-add-wash-type 'signed)
4747 (gnus-mime-display-security handle))
4748 ((equal (car handle) "multipart/encrypted")
4749 (gnus-add-wash-type 'encrypted)
4750 (gnus-mime-display-security handle))
4751 ;; Other multiparts are handled like multipart/mixed.
4753 (gnus-mime-display-mixed (cdr handle)))))
4755 (defun gnus-mime-part-function (handles)
4756 (if (stringp (car handles))
4757 (mapcar 'gnus-mime-part-function (cdr handles))
4758 (funcall gnus-article-mime-part-function handles)))
4760 (defun gnus-mime-display-mixed (handles)
4761 (mapcar 'gnus-mime-display-part handles))
4763 (defun gnus-mime-display-single (handle)
4764 (let ((type (mm-handle-media-type handle))
4765 (ignored gnus-ignored-mime-types)
4772 (when (string-match (pop ignored) type)
4773 (throw 'ignored nil)))
4774 (if (and (setq not-attachment
4775 (and (not (mm-inline-override-p handle))
4776 (or (not (mm-handle-disposition handle))
4777 (equal (car (mm-handle-disposition handle))
4779 (mm-attachment-override-p handle))))
4780 (mm-automatic-display-p handle)
4782 (mm-inlinable-p handle)
4783 (mm-inlined-p handle))
4784 (mm-automatic-external-display-p type)))
4786 (when (equal (mm-handle-media-supertype handle) "text")
4788 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4790 (push (cons id handle) gnus-article-mime-handle-alist)
4791 (when (or (not display)
4792 (not (gnus-unbuttonized-mime-type-p type)))
4793 (gnus-insert-mime-button
4794 handle id (list (or display (and not-attachment text))))
4795 (gnus-article-insert-newline)
4796 ;; Remember modify the number of forward lines.
4804 (let ((mail-parse-charset gnus-newsgroup-charset)
4805 (mail-parse-ignored-charsets
4806 (save-excursion (condition-case ()
4807 (set-buffer gnus-summary-buffer)
4809 gnus-newsgroup-ignored-charsets)))
4810 (mm-display-part handle t))
4811 (goto-char (point-max)))
4812 ((and text not-attachment)
4816 (gnus-article-insert-newline)
4817 (mm-display-inline handle)
4818 (goto-char (point-max))))
4822 (narrow-to-region beg (point))
4825 (gnus-article-mime-total-parts)
4826 (mm-handle-media-type handle)))))))))
4828 (defun gnus-unbuttonized-mime-type-p (type)
4829 "Say whether TYPE is to be unbuttonized."
4830 (unless gnus-inhibit-mime-unbuttonizing
4832 (let ((types gnus-unbuttonized-mime-types))
4834 (when (string-match (pop types) type)
4835 (throw 'found t)))))
4837 (let ((types gnus-buttonized-mime-types))
4839 (when (string-match (pop types) type)
4840 (throw 'found t)))))))))
4842 (defun gnus-article-insert-newline ()
4843 "Insert a newline, but mark it as undeletable."
4844 (gnus-put-text-property
4845 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4847 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4848 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4851 handle (inhibit-read-only t) from props begend not-pref)
4852 (save-window-excursion
4855 (narrow-to-region (car ibegend)
4858 (goto-char (car ibegend))
4861 (delete-region (point-min) (point-max))
4862 (mm-remove-parts handles))
4863 (setq begend (list (point-marker)))
4865 (unless (setq not-pref (cadr (member preferred ihandles)))
4866 (setq not-pref (car ihandles)))
4869 (not (gnus-unbuttonized-mime-type-p
4870 "multipart/alternative")))
4871 (gnus-add-text-properties
4874 (insert (format "%d. " id))
4878 (unless ,(not ibegend)
4879 (setq gnus-article-mime-handle-alist
4880 ',gnus-article-mime-handle-alist))
4881 (gnus-mime-display-alternative
4882 ',ihandles ',not-pref ',begend ,id))
4883 keymap ,gnus-mime-button-map
4884 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4885 face ,gnus-article-button-face
4888 (widget-convert-button 'link from (point)
4889 :action 'gnus-widget-press-button
4890 :button-keymap gnus-widget-button-keymap)
4892 (while (setq handle (pop handles))
4893 (gnus-add-text-properties
4896 (insert (format "(%c) %-18s"
4897 (if (equal handle preferred) ?* ? )
4898 (mm-handle-media-type handle)))
4902 (unless ,(not ibegend)
4903 (setq gnus-article-mime-handle-alist
4904 ',gnus-article-mime-handle-alist))
4905 (gnus-mime-display-alternative
4906 ',ihandles ',handle ',begend ,id))
4907 keymap ,gnus-mime-button-map
4908 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4909 face ,gnus-article-button-face
4912 (widget-convert-button 'link from (point)
4913 :action 'gnus-widget-press-button
4914 :button-keymap gnus-widget-button-keymap)
4918 (if (stringp (car preferred))
4919 (gnus-display-mime preferred)
4920 (let ((mail-parse-charset gnus-newsgroup-charset)
4921 (mail-parse-ignored-charsets
4922 (with-current-buffer gnus-summary-buffer
4923 gnus-newsgroup-ignored-charsets)))
4924 (mm-display-part preferred)
4928 (narrow-to-region (car begend) (point-max))
4930 nil (length gnus-article-mime-handle-alist)
4931 (gnus-article-mime-total-parts)
4932 (mm-handle-media-type handle))))))
4933 (goto-char (point-max))
4934 (setcdr begend (point-marker)))))
4936 (goto-char point))))
4938 (defconst gnus-article-wash-status-strings
4939 (let ((alist '((cite "c" "Possible hidden citation text"
4940 " " "All citation text visible")
4941 (headers "h" "Hidden headers"
4942 " " "All headers visible.")
4943 (pgp "p" "Encrypted or signed message status hidden"
4944 " " "No hidden encryption nor digital signature status")
4945 (signature "s" "Signature has been hidden"
4946 " " "Signature is visible")
4947 (overstrike "o" "Overstrike (^H) characters applied"
4948 " " "No overstrike characters applied")
4949 (emphasis "e" "/*_Emphasis_*/ characters applied"
4950 " " "No /*_emphasis_*/ characters applied")))
4952 (dolist (entry alist result)
4953 (let ((key (nth 0 entry))
4954 (on (copy-sequence (nth 1 entry)))
4955 (on-help (nth 2 entry))
4956 (off (copy-sequence (nth 3 entry)))
4957 (off-help (nth 4 entry)))
4958 (put-text-property 0 1 'help-echo on-help on)
4959 (put-text-property 0 1 'help-echo off-help off)
4960 (push (list key on off) result))))
4961 "Alist of strings describing wash status in the mode line.
4962 Each entry has the form (KEY ON OF), where the KEY is a symbol
4963 representing the particular washing function, ON is the string to use
4964 in the article mode line when the washing function is active, and OFF
4965 is the string to use when it is inactive.")
4967 (defun gnus-article-wash-status-entry (key value)
4968 (let ((entry (assoc key gnus-article-wash-status-strings)))
4969 (if value (nth 1 entry) (nth 2 entry))))
4971 (defun gnus-article-wash-status ()
4972 "Return a string which display status of article washing."
4973 (with-current-buffer gnus-article-buffer
4974 (let ((cite (memq 'cite gnus-article-wash-types))
4975 (headers (memq 'headers gnus-article-wash-types))
4976 (boring (memq 'boring-headers gnus-article-wash-types))
4977 (pgp (memq 'pgp gnus-article-wash-types))
4978 (pem (memq 'pem gnus-article-wash-types))
4979 (signed (memq 'signed gnus-article-wash-types))
4980 (encrypted (memq 'encrypted gnus-article-wash-types))
4981 (signature (memq 'signature gnus-article-wash-types))
4982 (overstrike (memq 'overstrike gnus-article-wash-types))
4983 (emphasis (memq 'emphasis gnus-article-wash-types)))
4985 (gnus-article-wash-status-entry 'cite cite)
4986 (gnus-article-wash-status-entry 'headers (or headers boring))
4987 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4988 (gnus-article-wash-status-entry 'signature signature)
4989 (gnus-article-wash-status-entry 'overstrike overstrike)
4990 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4992 (defun gnus-add-wash-type (type)
4993 "Add a washing of TYPE to the current status."
4994 (add-to-list 'gnus-article-wash-types type))
4996 (defun gnus-delete-wash-type (type)
4997 "Add a washing of TYPE to the current status."
4998 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5000 (defun gnus-add-image (category image)
5001 "Add IMAGE of CATEGORY to the list of displayed images."
5002 (let ((entry (assq category gnus-article-image-alist)))
5004 (setq entry (list category))
5005 (push entry gnus-article-image-alist))
5006 (nconc entry (list image))))
5008 (defun gnus-delete-images (category)
5009 "Delete all images in CATEGORY."
5010 (let ((entry (assq category gnus-article-image-alist)))
5011 (dolist (image (cdr entry))
5012 (gnus-remove-image image category))
5013 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5014 (gnus-delete-wash-type category)))
5016 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5018 (defun gnus-article-maybe-hide-headers ()
5019 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5020 Provided for backwards compatibility."
5021 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5022 (not (with-current-buffer gnus-summary-buffer
5023 gnus-have-all-headers)))
5024 (not gnus-inhibit-hiding))
5025 (gnus-article-hide-headers)))
5029 (defun gnus-output-to-file (file-name)
5030 "Append the current article to a file named FILE-NAME."
5031 (let ((artbuf (current-buffer)))
5033 (insert-buffer-substring artbuf)
5034 ;; Append newline at end of the buffer as separator, and then
5036 (goto-char (point-max))
5038 (let ((file-name-coding-system nnmail-pathname-coding-system))
5039 (mm-append-to-file (point-min) (point-max) file-name))
5042 (defun gnus-narrow-to-page (&optional arg)
5043 "Narrow the article buffer to a page.
5044 If given a numerical ARG, move forward ARG pages."
5046 (setq arg (if arg (prefix-numeric-value arg) 0))
5048 (set-buffer gnus-article-buffer)
5049 (goto-char (point-min))
5051 ;; Remove any old next/prev buttons.
5052 (when (gnus-visual-p 'page-marker)
5053 (let ((inhibit-read-only t))
5054 (gnus-remove-text-with-property 'gnus-prev)
5055 (gnus-remove-text-with-property 'gnus-next)))
5058 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5060 (re-search-forward page-delimiter nil 'move arg)))
5061 (goto-char (match-end 0))
5063 (goto-char (point-min))
5064 (setq gnus-page-broken
5065 (and (re-search-forward page-delimiter nil t) t))))
5066 (when gnus-page-broken
5069 (if (re-search-forward page-delimiter nil 'move)
5072 (when (and (gnus-visual-p 'page-marker)
5073 (> (point-min) (save-restriction (widen) (point-min))))
5075 (goto-char (point-min))
5076 (gnus-insert-prev-page-button)))
5077 (when (and (gnus-visual-p 'page-marker)
5078 (< (point-max) (save-restriction (widen) (point-max))))
5080 (goto-char (point-max))
5081 (gnus-insert-next-page-button))))))
5083 ;; Article mode commands
5085 (defun gnus-article-goto-next-page ()
5086 "Show the next page of the article."
5088 (when (gnus-article-next-page)
5089 (goto-char (point-min))
5090 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5093 (defun gnus-article-goto-prev-page ()
5094 "Show the previous page of the article."
5097 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5098 (gnus-article-prev-page nil)))
5100 ;; This is cleaner but currently breaks `gnus-pick-mode':
5102 ;; (defun gnus-article-goto-next-page ()
5103 ;; "Show the next page of the article."
5105 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5106 ;; (gnus-summary-next-page)))
5108 ;; (defun gnus-article-goto-prev-page ()
5109 ;; "Show the next page of the article."
5111 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5112 ;; (gnus-summary-prev-page)))
5114 (defun gnus-article-next-page (&optional lines)
5115 "Show the next page of the current article.
5116 If end of article, return non-nil. Otherwise return nil.
5117 Argument LINES specifies lines to be scrolled up."
5119 (move-to-window-line -1)
5122 (and (pos-visible-in-window-p) ;Not continuation line.
5123 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5124 ;; Nothing in this page.
5125 (if (or (not gnus-page-broken)
5130 (eobp)))) ;Real end-of-buffer?
5132 (when gnus-article-over-scroll
5133 (gnus-article-next-page-1 lines))
5135 (gnus-narrow-to-page 1) ;Go to next page.
5137 ;; More in this page.
5138 (gnus-article-next-page-1 lines)
5141 (defun gnus-article-next-page-1 (lines)
5142 (let ((scroll-in-place nil))
5146 ;; Long lines may cause an end-of-buffer error.
5147 (goto-char (point-max)))))
5148 (move-to-window-line 0))
5150 (defun gnus-article-prev-page (&optional lines)
5151 "Show previous page of current article.
5152 Argument LINES specifies lines to be scrolled down."
5154 (move-to-window-line 0)
5155 (if (and gnus-page-broken
5157 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5159 (gnus-narrow-to-page -1) ;Go to previous page.
5160 (goto-char (point-max))
5162 (let ((scroll-in-place nil))
5166 (beginning-of-buffer
5167 (goto-char (point-min))))
5168 (move-to-window-line 0)))))
5170 (defun gnus-article-only-boring-p ()
5171 "Decide whether there is only boring text remaining in the article.
5172 Something \"interesting\" is a word of at least two letters that does
5173 not have a face in `gnus-article-boring-faces'."
5174 (when (and gnus-article-skip-boring
5175 (boundp 'gnus-article-boring-faces)
5176 (symbol-value 'gnus-article-boring-faces))
5179 (while (re-search-forward "\\b\\w\\w" nil t)
5181 (when (not (gnus-intersection
5182 (gnus-faces-at (point))
5183 (symbol-value 'gnus-article-boring-faces)))
5184 (throw 'only-boring nil)))
5185 (throw 'only-boring t)))))
5187 (defun gnus-article-refer-article ()
5188 "Read article specified by message-id around point."
5191 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5192 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5193 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5194 (let ((msg-id (concat "<" (match-string 0) ">")))
5195 (set-buffer gnus-summary-buffer)
5196 (gnus-summary-refer-article msg-id))
5197 (error "No references around point"))))
5199 (defun gnus-article-show-summary ()
5200 "Reconfigure windows to show summary buffer."
5202 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5203 (error "There is no summary buffer for this article buffer")
5204 (gnus-article-set-globals)
5205 (gnus-configure-windows 'article)
5206 (gnus-summary-goto-subject gnus-current-article)
5207 (gnus-summary-position-point)))
5209 (defun gnus-article-describe-briefly ()
5210 "Describe article mode commands briefly."
5212 (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")))
5214 (defun gnus-article-summary-command ()
5215 "Execute the last keystroke in the summary buffer."
5217 (let ((obuf (current-buffer))
5218 (owin (current-window-configuration))
5220 (switch-to-buffer gnus-article-current-summary 'norecord)
5221 (setq func (lookup-key (current-local-map) (this-command-keys)))
5222 (call-interactively func)
5224 (set-window-configuration owin)
5225 (set-window-point (get-buffer-window (current-buffer)) (point))))
5227 (defun gnus-article-summary-command-nosave ()
5228 "Execute the last keystroke in the summary buffer."
5231 (pop-to-buffer gnus-article-current-summary 'norecord)
5232 (setq func (lookup-key (current-local-map) (this-command-keys)))
5233 (call-interactively func)))
5235 (defun gnus-article-check-buffer ()
5236 "Beep if not in an article buffer."
5237 (unless (equal major-mode 'gnus-article-mode)
5238 (error "Command invoked outside of a Gnus article buffer")))
5240 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5241 "Read a summary buffer key sequence and execute it from the article buffer."
5243 (gnus-article-check-buffer)
5245 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5246 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5247 "=" "^" "\M-^" "|"))
5253 '("n" "Gn" "p" "Gp"))
5256 (set-buffer gnus-article-current-summary)
5257 (let (gnus-pick-mode)
5258 (push (or key last-command-event) unread-command-events)
5259 (setq keys (if (featurep 'xemacs)
5260 (events-to-keys (read-key-sequence nil))
5261 (read-key-sequence nil)))))
5265 (if (or (member keys nosaves)
5266 (member keys nosave-but-article)
5267 (member keys nosave-in-article))
5269 (save-window-excursion
5270 (pop-to-buffer gnus-article-current-summary 'norecord)
5271 ;; We disable the pick minor mode commands.
5272 (let (gnus-pick-mode)
5273 (setq func (lookup-key (current-local-map) keys))))
5277 (unless (member keys nosave-in-article)
5278 (set-buffer gnus-article-current-summary))
5279 (call-interactively func)
5280 (setq new-sum-point (point)))
5281 (when (member keys nosave-but-article)
5282 (pop-to-buffer gnus-article-buffer 'norecord)))
5283 ;; These commands should restore window configuration.
5284 (let ((obuf (current-buffer))
5285 (owin (current-window-configuration))
5287 win func in-buffer selected new-sum-start new-sum-hscroll)
5288 (cond (not-restore-window
5289 (pop-to-buffer gnus-article-current-summary 'norecord))
5290 ((setq win (get-buffer-window gnus-article-current-summary))
5291 (select-window win))
5293 (switch-to-buffer gnus-article-current-summary 'norecord)))
5294 (setq in-buffer (current-buffer))
5295 ;; We disable the pick minor mode commands.
5296 (if (and (setq func (let (gnus-pick-mode)
5297 (lookup-key (current-local-map) keys)))
5300 (call-interactively func)
5301 (when (eq win (selected-window))
5302 (setq new-sum-point (point)
5303 new-sum-start (window-start win)
5304 new-sum-hscroll (window-hscroll win))
5305 (when (eq in-buffer (current-buffer))
5306 (setq selected (gnus-summary-select-article))
5308 (unless not-restore-window
5309 (set-window-configuration owin))
5310 (when (eq selected 'old)
5312 (set-window-start (get-buffer-window (current-buffer))
5314 (set-window-point (get-buffer-window (current-buffer))
5316 (when (and (not not-restore-window)
5318 (set-window-point win new-sum-point)
5319 (set-window-start win new-sum-start)
5320 (set-window-hscroll win new-sum-hscroll)))))
5321 (set-window-configuration owin)
5324 (defun gnus-article-describe-key (key)
5325 "Display documentation of the function invoked by KEY. KEY is a string."
5326 (interactive "kDescribe key: ")
5327 (gnus-article-check-buffer)
5328 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5330 (set-buffer gnus-article-current-summary)
5331 (let (gnus-pick-mode)
5332 (if (featurep 'xemacs)
5334 (push (elt key 0) unread-command-events)
5335 (setq key (events-to-keys
5336 (read-key-sequence "Describe key: "))))
5337 (setq unread-command-events
5339 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5340 (string-to-list key)))
5341 (setq key (read-key-sequence "Describe key: "))))
5343 (describe-key key)))
5345 (defun gnus-article-describe-key-briefly (key &optional insert)
5346 "Display documentation of the function invoked by KEY. KEY is a string."
5347 (interactive "kDescribe key: \nP")
5348 (gnus-article-check-buffer)
5349 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5351 (set-buffer gnus-article-current-summary)
5352 (let (gnus-pick-mode)
5353 (if (featurep 'xemacs)
5355 (push (elt key 0) unread-command-events)
5356 (setq key (events-to-keys
5357 (read-key-sequence "Describe key: "))))
5358 (setq unread-command-events
5360 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5361 (string-to-list key)))
5362 (setq key (read-key-sequence "Describe key: "))))
5363 (describe-key-briefly key insert))
5364 (describe-key-briefly key insert)))
5366 (defun gnus-article-reply-with-original (&optional wide)
5367 "Start composing a reply mail to the current message.
5368 The text in the region will be yanked. If the region isn't active,
5369 the entire article will be yanked."
5371 (let ((article (cdr gnus-article-current))
5373 (if (not (gnus-region-active-p))
5374 (with-current-buffer gnus-summary-buffer
5375 (gnus-summary-reply (list (list article)) wide))
5376 (setq contents (buffer-substring (point) (mark t)))
5377 ;; Deactivate active regions.
5378 (when (and (boundp 'transient-mark-mode)
5379 transient-mark-mode)
5380 (setq mark-active nil))
5381 (with-current-buffer gnus-summary-buffer
5383 (list (list article contents)) wide)))))
5385 (defun gnus-article-followup-with-original ()
5386 "Compose a followup to the current article.
5387 The text in the region will be yanked. If the region isn't active,
5388 the entire article will be yanked."
5390 (let ((article (cdr gnus-article-current))
5392 (if (not (gnus-region-active-p))
5393 (with-current-buffer gnus-summary-buffer
5394 (gnus-summary-followup (list (list article))))
5395 (setq contents (buffer-substring (point) (mark t)))
5396 ;; Deactivate active regions.
5397 (when (and (boundp 'transient-mark-mode)
5398 transient-mark-mode)
5399 (setq mark-active nil))
5400 (with-current-buffer gnus-summary-buffer
5401 (gnus-summary-followup
5402 (list (list article contents)))))))
5404 (defun gnus-article-hide (&optional arg force)
5405 "Hide all the gruft in the current article.
5406 This means that signatures, cited text and (some) headers will be
5408 If given a prefix, show the hidden text instead."
5409 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5410 (gnus-article-hide-headers arg)
5411 (gnus-article-hide-list-identifiers arg)
5412 (gnus-article-hide-citation-maybe arg force)
5413 (gnus-article-hide-signature arg))
5415 (defun gnus-article-maybe-highlight ()
5416 "Do some article highlighting if article highlighting is requested."
5417 (when (gnus-visual-p 'article-highlight 'highlight)
5418 (gnus-article-highlight-some)))
5420 (defun gnus-check-group-server ()
5421 ;; Make sure the connection to the server is alive.
5422 (unless (gnus-server-opened
5423 (gnus-find-method-for-group gnus-newsgroup-name))
5424 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5425 (gnus-request-group gnus-newsgroup-name t)))
5428 (autoload 'nneething-get-file-name "nneething"))
5430 (defun gnus-request-article-this-buffer (article group)
5431 "Get an article and insert it into this buffer."
5432 (let (do-update-line sparse-header)
5436 (gnus-kill-all-overlays)
5437 (setq group (or group gnus-newsgroup-name))
5439 ;; Using `gnus-request-article' directly will insert the article into
5440 ;; `nntp-server-buffer' - so we'll save some time by not having to
5441 ;; copy it from the server buffer into the article buffer.
5443 ;; We only request an article by message-id when we do not have the
5444 ;; headers for it, so we'll have to get those.
5445 (when (stringp article)
5446 (gnus-read-header article))
5448 ;; If the article number is negative, that means that this article
5449 ;; doesn't belong in this newsgroup (possibly), so we find its
5450 ;; message-id and request it by id instead of number.
5451 (when (and (numberp article)
5453 (get-buffer gnus-summary-buffer)
5454 (gnus-buffer-exists-p gnus-summary-buffer))
5456 (set-buffer gnus-summary-buffer)
5457 (let ((header (gnus-summary-article-header article)))
5460 ((memq article gnus-newsgroup-sparse)
5461 ;; This is a sparse gap article.
5462 (setq do-update-line article)
5463 (setq article (mail-header-id header))
5464 (setq sparse-header (gnus-read-header article))
5465 (setq gnus-newsgroup-sparse
5466 (delq article gnus-newsgroup-sparse)))
5468 ;; It's a real article.
5469 (setq article (mail-header-id header)))
5471 ;; It is an extracted pseudo-article.
5472 (setq article 'pseudo)
5473 (gnus-request-pseudo-article header))))
5475 (let ((method (gnus-find-method-for-group
5476 gnus-newsgroup-name)))
5477 (when (and (eq (car method) 'nneething)
5479 (let ((dir (nneething-get-file-name
5480 (mail-header-id header))))
5481 (when (and (stringp dir)
5482 (file-directory-p dir))
5483 (setq article 'nneething)
5484 (gnus-group-enter-directory dir))))))))
5487 ;; Refuse to select canceled articles.
5488 ((and (numberp article)
5490 (get-buffer gnus-summary-buffer)
5491 (gnus-buffer-exists-p gnus-summary-buffer)
5492 (eq (cdr (with-current-buffer gnus-summary-buffer
5493 (assq article gnus-newsgroup-reads)))
5494 gnus-canceled-mark))
5496 ;; We first check `gnus-original-article-buffer'.
5497 ((and (get-buffer gnus-original-article-buffer)
5499 (with-current-buffer gnus-original-article-buffer
5500 (and (equal (car gnus-original-article) group)
5501 (eq (cdr gnus-original-article) article))))
5502 (insert-buffer-substring gnus-original-article-buffer)
5504 ;; Check the backlog.
5505 ((and gnus-keep-backlog
5506 (gnus-backlog-request-article group article (current-buffer)))
5508 ;; Check asynchronous pre-fetch.
5509 ((gnus-async-request-fetched-article group article (current-buffer))
5510 (gnus-async-prefetch-next group article gnus-summary-buffer)
5511 (when (and (numberp article) gnus-keep-backlog)
5512 (gnus-backlog-enter-article group article (current-buffer)))
5515 ((and gnus-use-cache
5517 (gnus-cache-request-article article group))
5519 ;; Check the agent cache.
5520 ((gnus-agent-request-article article group)
5522 ;; Get the article and put into the article buffer.
5523 ((or (stringp article)
5525 (let ((gnus-override-method gnus-override-method)
5526 (methods (and (stringp article)
5527 gnus-refer-article-method))
5528 (backend (car (gnus-find-method-for-group
5529 gnus-newsgroup-name)))
5531 (inhibit-read-only t))
5532 (if (or (not (listp methods))
5533 (and (symbolp (car methods))
5534 (assq (car methods) nnoo-definition-alist)))
5535 (setq methods (list methods)))
5536 (when (and (null gnus-override-method)
5538 (setq gnus-override-method (pop methods)))
5540 (when (eq gnus-override-method 'current)
5541 (setq gnus-override-method
5542 (with-current-buffer gnus-summary-buffer
5543 gnus-current-select-method)))
5545 (gnus-kill-all-overlays)
5546 (let ((gnus-newsgroup-name group))
5547 (gnus-check-group-server))
5549 ((gnus-request-article article group (current-buffer))
5550 (when (numberp article)
5551 (gnus-async-prefetch-next group article
5552 gnus-summary-buffer)
5553 (when gnus-keep-backlog
5554 (gnus-backlog-enter-article
5555 group article (current-buffer))))
5556 (setq result 'article))
5558 (setq gnus-override-method (pop methods)))
5559 ((not (string-match "^400 "
5560 (nnheader-get-report backend)))
5561 ;; If we get 400 server disconnect, reconnect and
5562 ;; retry; otherwise, assume the article has expired.
5563 (setq result 'done))))
5564 (and (eq result 'article) 'article)))
5568 ;; Associate this article with the current summary buffer.
5569 (setq gnus-article-current-summary gnus-summary-buffer)
5571 ;; Take the article from the original article buffer
5572 ;; and place it in the buffer it's supposed to be in.
5573 (when (and (get-buffer gnus-article-buffer)
5574 (equal (buffer-name (current-buffer))
5575 (buffer-name (get-buffer gnus-article-buffer))))
5577 (if (get-buffer gnus-original-article-buffer)
5578 (set-buffer gnus-original-article-buffer)
5579 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5580 (buffer-disable-undo)
5581 (setq major-mode 'gnus-original-article-mode)
5582 (setq buffer-read-only t))
5583 (let ((inhibit-read-only t))
5585 (insert-buffer-substring gnus-article-buffer))
5586 (setq gnus-original-article (cons group article)))
5589 (run-hooks 'gnus-article-decode-hook)
5590 ;; Mark article as decoded or not.
5591 (setq gnus-article-decoded-p gnus-article-decode-hook))
5593 ;; Update sparse articles.
5594 (when (and do-update-line
5595 (or (numberp article)
5597 (let ((buf (current-buffer)))
5598 (set-buffer gnus-summary-buffer)
5599 (gnus-summary-update-article do-update-line sparse-header)
5600 (gnus-summary-goto-subject do-update-line nil t)
5601 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5603 (set-buffer buf))))))
5609 (defcustom gnus-article-edit-mode-hook nil
5610 "Hook run in article edit mode buffers."
5611 :group 'gnus-article-various
5614 (defvar gnus-article-edit-done-function nil)
5616 (defvar gnus-article-edit-mode-map nil)
5618 ;; Should we be using derived.el for this?
5619 (unless gnus-article-edit-mode-map
5620 (setq gnus-article-edit-mode-map (make-keymap))
5621 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5623 (gnus-define-keys gnus-article-edit-mode-map
5624 "\C-c?" describe-mode
5625 "\C-c\C-c" gnus-article-edit-done
5626 "\C-c\C-k" gnus-article-edit-exit
5627 "\C-c\C-f\C-t" message-goto-to
5628 "\C-c\C-f\C-o" message-goto-from
5629 "\C-c\C-f\C-b" message-goto-bcc
5630 ;;"\C-c\C-f\C-w" message-goto-fcc
5631 "\C-c\C-f\C-c" message-goto-cc
5632 "\C-c\C-f\C-s" message-goto-subject
5633 "\C-c\C-f\C-r" message-goto-reply-to
5634 "\C-c\C-f\C-n" message-goto-newsgroups
5635 "\C-c\C-f\C-d" message-goto-distribution
5636 "\C-c\C-f\C-f" message-goto-followup-to
5637 "\C-c\C-f\C-m" message-goto-mail-followup-to
5638 "\C-c\C-f\C-k" message-goto-keywords
5639 "\C-c\C-f\C-u" message-goto-summary
5640 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5641 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5642 "\C-c\C-b" message-goto-body
5643 "\C-c\C-i" message-goto-signature
5645 "\C-c\C-t" message-insert-to
5646 "\C-c\C-n" message-insert-newsgroups
5647 "\C-c\C-o" message-sort-headers
5648 "\C-c\C-e" message-elide-region
5649 "\C-c\C-v" message-delete-not-region
5650 "\C-c\C-z" message-kill-to-signature
5651 "\M-\r" message-newline-and-reformat
5652 "\C-c\C-a" mml-attach-file
5653 "\C-a" message-beginning-of-line
5655 "\M-;" comment-region)
5657 (gnus-define-keys (gnus-article-edit-wash-map
5658 "\C-c\C-w" gnus-article-edit-mode-map)
5659 "f" gnus-article-edit-full-stops))
5662 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5664 ["Fetch To" message-insert-to t]
5665 ["Fetch Newsgroups" message-insert-newsgroups t]
5667 ["To" message-goto-to t]
5668 ["From" message-goto-from t]
5669 ["Subject" message-goto-subject t]
5670 ["Cc" message-goto-cc t]
5671 ["Reply-To" message-goto-reply-to t]
5672 ["Summary" message-goto-summary t]
5673 ["Keywords" message-goto-keywords t]
5674 ["Newsgroups" message-goto-newsgroups t]
5675 ["Followup-To" message-goto-followup-to t]
5676 ["Mail-Followup-To" message-goto-mail-followup-to t]
5677 ["Distribution" message-goto-distribution t]
5678 ["Body" message-goto-body t]
5679 ["Signature" message-goto-signature t]))
5681 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5682 "Major mode for editing articles.
5683 This is an extended text-mode.
5685 \\{gnus-article-edit-mode-map}"
5686 (make-local-variable 'gnus-article-edit-done-function)
5687 (make-local-variable 'gnus-prev-winconf)
5688 (set (make-local-variable 'font-lock-defaults)
5689 '(message-font-lock-keywords t))
5690 (set (make-local-variable 'mail-header-separator) "")
5691 (set (make-local-variable 'gnus-article-edit-mode) t)
5692 (easy-menu-add message-mode-field-menu message-mode-map)
5694 (setq buffer-read-only nil)
5695 (buffer-enable-undo)
5698 (defun gnus-article-edit (&optional force)
5699 "Edit the current article.
5700 This will have permanent effect only in mail groups.
5701 If FORCE is non-nil, allow editing of articles even in read-only
5704 (when (and (not force)
5705 (gnus-group-read-only-p))
5706 (error "The current newsgroup does not support article editing"))
5707 (gnus-article-date-original)
5708 (gnus-article-edit-article
5710 `(lambda (no-highlight)
5712 (gnus-summary-edit-article-done
5713 ,(or (mail-header-references gnus-current-headers) "")
5714 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5716 (defun gnus-article-edit-article (start-func exit-func)
5717 "Start editing the contents of the current article buffer."
5718 (let ((winconf (current-window-configuration)))
5719 (set-buffer gnus-article-buffer)
5720 (let ((message-auto-save-directory
5721 ;; Don't associate the article buffer with a draft file.
5723 (gnus-article-edit-mode))
5724 (funcall start-func)
5725 (set-buffer-modified-p nil)
5726 (gnus-configure-windows 'edit-article)
5727 (setq gnus-article-edit-done-function exit-func)
5728 (setq gnus-prev-winconf winconf)
5729 (gnus-message 6 "C-c C-c to end edits")))
5731 (defun gnus-article-edit-done (&optional arg)
5732 "Update the article edits and exit."
5734 (let ((func gnus-article-edit-done-function)
5735 (buf (current-buffer))
5736 (start (window-start))
5738 (winconf gnus-prev-winconf))
5739 (widen) ;; Widen it in case that users narrowed the buffer.
5742 ;; The cache and backlog have to be flushed somewhat.
5743 (when gnus-keep-backlog
5744 (gnus-backlog-remove-article
5745 (car gnus-article-current) (cdr gnus-article-current)))
5746 ;; Flush original article as well.
5748 (when (get-buffer gnus-original-article-buffer)
5749 (set-buffer gnus-original-article-buffer)
5750 (setq gnus-original-article nil)))
5751 (when gnus-use-cache
5752 (gnus-cache-update-article
5753 (car gnus-article-current) (cdr gnus-article-current)))
5754 ;; We remove all text props from the article buffer.
5755 (kill-all-local-variables)
5756 (set-text-properties (point-min) (point-max) nil)
5758 (set-window-configuration winconf)
5760 (set-window-start (get-buffer-window buf) start)
5761 (set-window-point (get-buffer-window buf) (point)))
5762 (gnus-summary-show-article))
5764 (defun gnus-article-edit-exit ()
5765 "Exit the article editing without updating."
5767 (when (or (not (buffer-modified-p))
5768 (yes-or-no-p "Article modified; kill anyway? "))
5769 (let ((curbuf (current-buffer))
5771 (window-start (window-start)))
5773 (if (gnus-buffer-live-p gnus-original-article-buffer)
5774 (insert-buffer gnus-original-article-buffer))
5775 (let ((winconf gnus-prev-winconf))
5776 (kill-all-local-variables)
5778 (set-window-configuration winconf)
5779 ;; Tippy-toe some to make sure that point remains where it was.
5780 (save-current-buffer
5782 (set-window-start (get-buffer-window (current-buffer)) window-start)
5784 (gnus-summary-show-article)))
5786 (defun gnus-article-edit-full-stops ()
5787 "Interactively repair spacing at end of sentences."
5790 (goto-char (point-min))
5791 (search-forward-regexp "^$" nil t)
5792 (let ((case-fold-search nil))
5793 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5796 ;;; Article highlights
5799 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5801 ;;; Internal Variables:
5803 (defcustom gnus-button-url-regexp
5804 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5805 "\\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:]]\\)"
5806 "\\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\\)\\)")
5807 "Regular expression that matches URLs."
5808 :group 'gnus-article-buttons
5811 (defcustom gnus-button-valid-fqdn-regexp
5812 message-valid-fqdn-regexp
5813 "Regular expression that matches a valid FQDN."
5815 :group 'gnus-article-buttons
5818 (defcustom gnus-button-man-handler 'manual-entry
5819 "Function to use for displaying man pages.
5820 The function must take at least one argument with a string naming the
5823 :type '(choice (function-item :tag "Man" manual-entry)
5824 (function-item :tag "Woman" woman)
5825 (function :tag "Other"))
5826 :group 'gnus-article-buttons)
5828 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5829 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5830 If the default site is too slow, try to find a CTAN mirror, see
5831 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5832 the variable `gnus-button-handle-ctan'."
5834 :group 'gnus-article-buttons
5835 :link '(custom-manual "(gnus)Group Parameters")
5836 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5837 (const "http://tug.ctan.org/tex-archive/")
5838 (const "http://www.dante.de/CTAN/")
5839 (string :tag "Other")))
5841 (defcustom gnus-button-ctan-handler 'browse-url
5842 "Function to use for displaying CTAN links.
5843 The function must take one argument, the string naming the URL."
5845 :type '(choice (function-item :tag "Browse Url" browse-url)
5846 (function :tag "Other"))
5847 :group 'gnus-article-buttons)
5849 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5850 "Bogus strings removed from CTAN URLs."
5852 :group 'gnus-article-buttons
5853 :type '(choice (const "^/?tex-archive/\\|/")
5854 (regexp :tag "Other")))
5856 (defcustom gnus-button-ctan-directory-regexp
5859 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5860 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5861 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5863 "Regular expression for ctan directories.
5864 It should match all directories in the top level of `gnus-ctan-url'."
5866 :group 'gnus-article-buttons
5869 (defcustom gnus-button-mid-or-mail-regexp
5870 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
5871 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5872 gnus-button-valid-fqdn-regexp
5874 "Regular expression that matches a message ID or a mail address."
5876 :group 'gnus-article-buttons
5879 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5880 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5881 Strings like this can be either a message ID or a mail address. If it is one
5882 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5883 message ID or a mail address, respectively. If this variable is set to the
5884 symbol `ask', always query the user what do do. If it is a function, this
5885 function will be called with the string as it's only argument. The function
5886 must return `mid', `mail', `invalid' or `ask'."
5888 :group 'gnus-article-buttons
5889 :type '(choice (function-item :tag "Heuristic function"
5890 gnus-button-mid-or-mail-heuristic)
5895 (defcustom gnus-button-mid-or-mail-heuristic-alist
5896 '((-10.0 . ".+\\$.+@")
5899 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5900 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5901 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5902 (-1.0 . "^[^a-z]+@")
5904 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5905 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5906 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5907 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5910 (-1.0 . "^[0-9][0-9]")
5912 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5913 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5914 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5915 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5917 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5918 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5921 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5923 ;; compensation for TDMA dated mail addresses:
5924 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5926 (-20.0 . "\\.fsf@") ;; Gnus
5929 (-20.0 . "_-_") ;; Subject change in thread
5931 (-20.0 . "\\.ln@") ;; leafnode
5932 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5933 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5935 ;; (5.0 . "") ;; $local_part_len <= 7
5936 (10.0 . "^[^0-9]+@")
5937 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5938 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5941 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5943 (0.5 . "^[A-Z][a-z]")
5944 (0.5 . "^[A-Z][a-z][a-z]")
5945 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5946 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5947 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5949 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5950 address. The REGEXP is processed with `case-fold-search' set to nil."
5952 :group 'gnus-article-buttons
5953 :type '(repeat (cons (number :tag "Rate")
5954 (regexp :tag "Regexp"))))
5956 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5957 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5958 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5959 address, `ask' if unsure and `invalid' if the string is invalid."
5960 (let ((case-fold-search nil)
5961 (list gnus-button-mid-or-mail-heuristic-alist)
5962 (result 0) rate regexp lpartlen elem)
5964 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5965 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5966 ;; Certain special cases...
5969 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
5970 "^[0-9]+\\.[0-9]+@compuserve\\|"
5971 "@public\\.gmane\\.org")
5973 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
5974 (setq result 'mail))
5975 (when (string-match "@.*@\\| " mid-or-mail)
5976 (gnus-message 8 "`%s' is invalid." mid-or-mail)
5977 (setq result 'invalid))
5978 ;; Nothing more to do, if result is not a number here...
5979 (when (numberp result)
5981 (setq elem (car list)
5985 (when (string-match regexp mid-or-mail)
5986 (setq result (+ result rate))
5988 9 "`%s' matched `%s', rate `%s', result `%s'."
5989 mid-or-mail regexp rate result)))
5990 (when (<= lpartlen 7)
5991 (setq result (+ result 5.0))
5992 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
5993 mid-or-mail result))
5994 (when (>= lpartlen 12)
5995 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
5997 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
5998 ;; Long local part should contain realname if e-mail address,
5999 ;; too many digits: message-id.
6000 ;; $score -= 5.0 + 0.1 * $local_part_len;
6001 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6002 (setq result (+ result rate))
6004 9 "Many digits in `%s', rate `%s', result `%s'."
6005 mid-or-mail rate result))
6006 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6008 ;; Too few vowels [^aeiouy]{4,}.*\@
6009 (setq result (+ result -5.0))
6011 9 "Few vowels in `%s', rate `%s', result `%s'."
6012 mid-or-mail -5.0 result))
6014 (setq result (+ result 5.0))
6016 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6017 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6018 ;; Maybe we should make this a customizable alist: (condition . 'result)
6020 ((symbolp result) result)
6021 ;; Now convert number into proper results:
6022 ((< result -10.0) 'mid)
6023 ((> result 10.0) 'mail)
6026 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6027 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6028 (url-mid (concat "news" ":" mid-or-mail))
6029 (url-mailto (concat "mailto" ":" mid-or-mail)))
6030 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6031 (when (fboundp pref)
6033 ;; get rid of surrounding angles...
6035 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6036 (if (or (eq 'mid guessed) (eq 'mail guessed))
6040 (save-window-excursion
6041 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6044 (cond ((eq pref 'mid)
6045 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6046 (gnus-button-handle-news url-mid))
6048 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6049 (gnus-url-mailto url-mailto))
6050 (t (gnus-message 3 "Invalid string.")))))
6052 (defun gnus-button-handle-custom (url)
6053 "Follow a Custom URL."
6054 (customize-apropos (gnus-url-unhex-string url)))
6056 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6058 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6061 (defun gnus-button-handle-describe-function (url)
6062 "Call `describe-function' when pushing the corresponding URL button."
6065 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6067 (defun gnus-button-handle-describe-variable (url)
6068 "Call `describe-variable' when pushing the corresponding URL button."
6071 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6073 (defun gnus-button-handle-symbol (url)
6074 "Display help on variable or function.
6075 Calls `describe-variable' or `describe-function'."
6076 (let ((sym (intern url)))
6078 ((fboundp sym) (describe-function sym))
6079 ((boundp sym) (describe-variable sym))
6080 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6082 (defun gnus-button-handle-describe-key (url)
6083 "Call `describe-key' when pushing the corresponding URL button."
6085 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6086 (keys (ignore-errors (eval `(kbd ,key-string)))))
6089 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6091 (defun gnus-button-handle-apropos (url)
6092 "Call `apropos' when pushing the corresponding URL button."
6093 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6095 (defun gnus-button-handle-apropos-command (url)
6096 "Call `apropos' when pushing the corresponding URL button."
6098 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6100 (defun gnus-button-handle-apropos-variable (url)
6101 "Call `apropos' when pushing the corresponding URL button."
6103 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6104 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6106 (defun gnus-button-handle-apropos-documentation (url)
6107 "Call `apropos' when pushing the corresponding URL button."
6109 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6110 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6112 (defun gnus-button-handle-library (url)
6113 "Call `locate-library' when pushing the corresponding URL button."
6114 (gnus-message 9 "url=`%s'" url)
6115 (let* ((lib (locate-library url))
6116 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6118 (gnus-message 1 "Cannot locale library `%s'." url)
6119 (find-file-read-only file))))
6121 (defun gnus-button-handle-ctan (url)
6122 "Call `browse-url' when pushing a CTAN URL button."
6124 gnus-button-ctan-handler
6127 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6129 (defcustom gnus-button-tex-level 5
6130 "*Integer that says how many TeX-related buttons Gnus will show.
6131 The higher the number, the more buttons will appear and the more false
6132 positives are possible. Note that you can set this variable local to
6133 specific groups. Setting it higher in TeX groups is probably a good idea.
6134 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6135 how to set variables in specific groups."
6137 :group 'gnus-article-buttons
6138 :link '(custom-manual "(gnus)Group Parameters")
6141 (defcustom gnus-button-man-level 5
6142 "*Integer that says how many man-related buttons Gnus will show.
6143 The higher the number, the more buttons will appear and the more false
6144 positives are possible. Note that you can set this variable local to
6145 specific groups. Setting it higher in Unix groups is probably a good idea.
6146 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6147 how to set variables in specific groups."
6149 :group 'gnus-article-buttons
6150 :link '(custom-manual "(gnus)Group Parameters")
6153 (defcustom gnus-button-emacs-level 5
6154 "*Integer that says how many emacs-related buttons Gnus will show.
6155 The higher the number, the more buttons will appear and the more false
6156 positives are possible. Note that you can set this variable local to
6157 specific groups. Setting it higher in Emacs or Gnus related groups is
6158 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6159 `gnus-parameters' on how to set variables in specific groups."
6161 :group 'gnus-article-buttons
6162 :link '(custom-manual "(gnus)Group Parameters")
6165 (defcustom gnus-button-message-level 5
6166 "*Integer that says how many buttons for news or mail messages will appear.
6167 The higher the number, the more buttons will appear and the more false
6168 positives are possible."
6169 ;; mail addresses, MIDs, URLs for news, ...
6171 :group 'gnus-article-buttons
6174 (defcustom gnus-button-browse-level 5
6175 "*Integer that says how many buttons for browsing will appear.
6176 The higher the number, the more buttons will appear and the more false
6177 positives are possible."
6178 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6180 :group 'gnus-article-buttons
6183 (defcustom gnus-button-alist
6184 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6185 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6186 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6187 gnus-button-handle-news 2)
6188 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6189 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6190 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6191 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6192 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6193 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6194 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6195 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6196 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6197 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6198 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6199 ;; RFC 2368 (The mailto URL scheme)
6200 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6201 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6202 ("\\bmailto:\\([^ \n\t]+\\)"
6203 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6205 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6206 gnus-button-ctan-directory-regexp
6207 "[^][>)!;:,'\n\t ]+\\)")
6208 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6209 ((concat "\\btex-archive/\\("
6210 gnus-button-ctan-directory-regexp
6211 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6212 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6215 gnus-button-ctan-directory-regexp
6216 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6217 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6218 ;; This is info (home-grown style) <info://foo/bar+baz>
6219 ("\\binfo://\\([^'\">\n\t ]+\\)"
6220 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6221 ;; Info GNOME style <info:foo#bar_baz>
6222 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6223 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6224 ;; Info KDE style <info:(foo)bar baz>
6225 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6226 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6227 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6228 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6229 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6230 ;; Info links like `C-h i d m CC Mode RET'
6231 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6233 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6234 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6235 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6236 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6237 ;; Emacs help commands
6238 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6239 ;; regexp doesn't match arguments containing ` '.
6240 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6241 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6242 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6243 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6244 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6245 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6246 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6247 ;; The following entries may lead to many false positives so don't enable
6248 ;; them by default (use a high button level).
6249 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6250 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6251 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6252 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6253 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6254 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6255 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6256 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6257 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6258 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6259 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6260 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6261 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6262 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6263 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6264 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6265 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6266 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6267 ;; Unlike the other regexps we really have to require quoting
6268 ;; here to determine where it ends.
6269 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6270 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6271 ("<URL: *\\([^<>]*\\)>"
6272 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6273 ;; RFC 2396 (2.4.3., delims) ...
6274 ("\"URL: *\\([^\"]*\\)\""
6275 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6276 ;; RFC 2396 (2.4.3., delims) ...
6277 ("\"URL: *\\([^\"]*\\)\""
6278 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6280 (gnus-button-url-regexp
6281 0 (>= gnus-button-browse-level 0) browse-url 0)
6283 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6284 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6285 gnus-button-handle-man 1)
6286 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6287 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6288 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6289 gnus-button-handle-man 1)
6290 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6291 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6292 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6293 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6294 ;; MID or mail: To avoid too many false positives we don't try to catch
6295 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6296 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6297 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6298 ;; so that non-ambiguous entries (see above) match first.
6299 (gnus-button-mid-or-mail-regexp
6300 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6301 "*Alist of regexps matching buttons in article bodies.
6303 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6304 REGEXP: is the string (case insensitive) matching text around the button (can
6305 also be Lisp expression evaluating to a string),
6306 BUTTON: is the number of the regexp grouping actually matching the button,
6307 FORM: is a Lisp expression which must eval to true for the button to
6309 CALLBACK: is the function to call when the user push this button, and each
6310 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6312 CALLBACK can also be a variable, in that case the value of that
6313 variable it the real callback function."
6314 :group 'gnus-article-buttons
6315 :type '(repeat (list (choice regexp variable sexp)
6316 (integer :tag "Button")
6318 (function :tag "Callback")
6321 (integer :tag "Regexp group")))))
6323 (defcustom gnus-header-button-alist
6324 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6325 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6326 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6327 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6328 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6329 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6330 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6331 0 (>= gnus-button-browse-level 0) browse-url 0)
6332 ("^Subject:" gnus-button-url-regexp
6333 0 (>= gnus-button-browse-level 0) browse-url 0)
6334 ("^[^:]+:" gnus-button-url-regexp
6335 0 (>= gnus-button-browse-level 0) browse-url 0)
6336 ("^OpenPGP:.*url=" gnus-button-url-regexp
6337 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6338 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6339 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6340 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6341 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6342 "*Alist of headers and regexps to match buttons in article heads.
6344 This alist is very similar to `gnus-button-alist', except that each
6345 alist has an additional HEADER element first in each entry:
6347 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6349 HEADER is a regexp to match a header. For a fuller explanation, see
6350 `gnus-button-alist'."
6351 :group 'gnus-article-buttons
6352 :group 'gnus-article-headers
6353 :type '(repeat (list (regexp :tag "Header")
6354 (choice regexp variable)
6355 (integer :tag "Button")
6357 (function :tag "Callback")
6360 (integer :tag "Regexp group")))))
6364 (defun gnus-article-push-button (event)
6365 "Check text under the mouse pointer for a callback function.
6366 If the text under the mouse pointer has a `gnus-callback' property,
6367 call it with the value of the `gnus-data' text property."
6369 (set-buffer (window-buffer (posn-window (event-start event))))
6370 (let* ((pos (posn-point (event-start event)))
6371 (data (get-text-property pos 'gnus-data))
6372 (fun (get-text-property pos 'gnus-callback)))
6375 (funcall fun data))))
6377 (defun gnus-article-press-button ()
6378 "Check text at point for a callback function.
6379 If the text at point has a `gnus-callback' property,
6380 call it with the value of the `gnus-data' text property."
6382 (let ((data (get-text-property (point) 'gnus-data))
6383 (fun (get-text-property (point) 'gnus-callback)))
6385 (funcall fun data))))
6387 (defun gnus-article-highlight (&optional force)
6388 "Highlight current article.
6389 This function calls `gnus-article-highlight-headers',
6390 `gnus-article-highlight-citation',
6391 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6392 do the highlighting. See the documentation for those functions."
6393 (interactive (list 'force))
6394 (gnus-article-highlight-headers)
6395 (gnus-article-highlight-citation force)
6396 (gnus-article-highlight-signature)
6397 (gnus-article-add-buttons force)
6398 (gnus-article-add-buttons-to-head))
6400 (defun gnus-article-highlight-some (&optional force)
6401 "Highlight current article.
6402 This function calls `gnus-article-highlight-headers',
6403 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6404 do the highlighting. See the documentation for those functions."
6405 (interactive (list 'force))
6406 (gnus-article-highlight-headers)
6407 (gnus-article-highlight-signature)
6408 (gnus-article-add-buttons))
6410 (defun gnus-article-highlight-headers ()
6411 "Highlight article headers as specified by `gnus-header-face-alist'."
6413 (gnus-with-article-headers
6414 (let (regexp header-face field-face from hpoints fpoints)
6415 (dolist (entry gnus-header-face-alist)
6416 (goto-char (point-min))
6417 (setq regexp (concat "^\\("
6418 (if (string-equal "" (nth 0 entry))
6422 header-face (nth 1 entry)
6423 field-face (nth 2 entry))
6424 (while (and (re-search-forward regexp nil t)
6428 (unless (search-forward ":" nil t)
6430 (when (and header-face
6431 (not (memq (point) hpoints)))
6432 (push (point) hpoints)
6433 (gnus-put-text-property from (point) 'face header-face))
6434 (when (and field-face
6435 (not (memq (setq from (point)) fpoints)))
6437 (if (re-search-forward "^[^ \t]" nil t)
6439 (goto-char (point-max)))
6440 (gnus-put-text-property from (point) 'face field-face)))))))
6442 (defun gnus-article-highlight-signature ()
6443 "Highlight the signature in an article.
6444 It does this by highlighting everything after
6445 `gnus-signature-separator' using `gnus-signature-face'."
6447 (gnus-with-article-buffer
6448 (let ((inhibit-point-motion-hooks t))
6450 (when (and gnus-signature-face
6451 (gnus-article-narrow-to-signature))
6452 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6453 'face gnus-signature-face)
6455 (gnus-article-search-signature)
6456 (let ((start (match-beginning 0))
6457 (end (set-marker (make-marker) (1+ (match-end 0)))))
6458 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6461 (defun gnus-button-in-region-p (b e prop)
6462 "Say whether PROP exists in the region."
6463 (text-property-not-all b e prop nil))
6465 (defun gnus-article-add-buttons (&optional force)
6466 "Find external references in the article and make buttons of them.
6467 \"External references\" are things like Message-IDs and URLs, as
6468 specified by `gnus-button-alist'."
6469 (interactive (list 'force))
6470 (gnus-with-article-buffer
6471 (let ((inhibit-point-motion-hooks t)
6472 (case-fold-search t)
6473 (alist gnus-button-alist)
6475 ;; Remove all old markers.
6476 (let (marker entry new-list)
6477 (while (setq marker (pop gnus-button-marker-list))
6478 (if (or (< marker (point-min)) (>= marker (point-max)))
6479 (push marker new-list)
6481 (when (setq entry (gnus-button-entry))
6482 (put-text-property (match-beginning (nth 1 entry))
6483 (match-end (nth 1 entry))
6484 'gnus-callback nil))
6485 (set-marker marker nil)))
6486 (setq gnus-button-marker-list new-list))
6487 ;; We skip the headers.
6490 (while (setq entry (pop alist))
6491 (setq regexp (eval (car entry)))
6493 (while (re-search-forward regexp nil t)
6494 (let* ((start (and entry (match-beginning (nth 1 entry))))
6495 (end (and entry (match-end (nth 1 entry))))
6496 (from (match-beginning 0)))
6497 (when (and (or (eq t (nth 2 entry))
6498 (eval (nth 2 entry)))
6499 (not (gnus-button-in-region-p
6500 start end 'gnus-callback)))
6501 ;; That optional form returned non-nil, so we add the
6503 (gnus-article-add-button
6504 start end 'gnus-button-push
6505 (car (push (set-marker (make-marker) from)
6506 gnus-button-marker-list))))))))))
6508 ;; Add buttons to the head of an article.
6509 (defun gnus-article-add-buttons-to-head ()
6510 "Add buttons to the head of the article."
6512 (gnus-with-article-headers
6514 (dolist (entry gnus-header-button-alist)
6515 ;; Each alist entry.
6516 (goto-char (point-min))
6517 (while (re-search-forward (car entry) nil t)
6518 ;; Each header matching the entry.
6519 (setq beg (match-beginning 0))
6520 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6521 (match-beginning 0))
6524 (while (re-search-forward (eval (nth 1 entry)) end t)
6525 ;; Each match within a header.
6526 (let* ((entry (cdr entry))
6527 (start (match-beginning (nth 1 entry)))
6528 (end (match-end (nth 1 entry)))
6529 (form (nth 2 entry)))
6530 (goto-char (match-end 0))
6532 (gnus-article-add-button
6533 start end (nth 3 entry)
6534 (buffer-substring (match-beginning (nth 4 entry))
6535 (match-end (nth 4 entry)))))))
6536 (goto-char end))))))
6538 ;;; External functions:
6540 (defun gnus-article-add-button (from to fun &optional data)
6541 "Create a button between FROM and TO with callback FUN and data DATA."
6542 (when gnus-article-button-face
6543 (gnus-overlay-put (gnus-make-overlay from to)
6544 'face gnus-article-button-face))
6545 (gnus-add-text-properties
6547 (nconc (and gnus-article-mouse-face
6548 (list gnus-mouse-face-prop gnus-article-mouse-face))
6549 (list 'gnus-callback fun)
6550 (and data (list 'gnus-data data))))
6551 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6552 :button-keymap gnus-widget-button-keymap))
6554 ;;; Internal functions:
6556 (defun gnus-article-set-globals ()
6557 (with-current-buffer gnus-summary-buffer
6558 (gnus-set-global-variables)))
6560 (defun gnus-signature-toggle (end)
6561 (gnus-with-article-buffer
6562 (let ((inhibit-point-motion-hooks t))
6563 (if (text-property-any end (point-max) 'article-type 'signature)
6565 (gnus-delete-wash-type 'signature)
6566 (gnus-remove-text-properties-when
6567 'article-type 'signature end (point-max)
6568 (cons 'article-type (cons 'signature
6569 gnus-hidden-properties))))
6570 (gnus-add-wash-type 'signature)
6571 (gnus-add-text-properties-when
6572 'article-type nil end (point-max)
6573 (cons 'article-type (cons 'signature
6574 gnus-hidden-properties)))))
6575 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6576 (gnus-set-mode-line 'article))))
6578 (defun gnus-button-entry ()
6579 ;; Return the first entry in `gnus-button-alist' matching this place.
6580 (let ((alist gnus-button-alist)
6583 (setq entry (pop alist))
6584 (if (looking-at (eval (car entry)))
6589 (defun gnus-button-push (marker)
6590 ;; Push button starting at MARKER.
6593 (let* ((entry (gnus-button-entry))
6594 (inhibit-point-motion-hooks t)
6596 (args (mapcar (lambda (group)
6597 (let ((string (match-string group)))
6598 (set-text-properties
6599 0 (length string) nil string)
6606 (fboundp (symbol-value fun)))
6607 (apply (symbol-value fun) args))
6609 (gnus-message 1 "You must define `%S' to use this button"
6610 (cons fun args)))))))
6612 (defun gnus-parse-news-url (url)
6613 (let (scheme server group message-id articles)
6616 (goto-char (point-min))
6617 (when (looking-at "\\([A-Za-z]+\\):")
6618 (setq scheme (match-string 1))
6619 (goto-char (match-end 0)))
6620 (when (looking-at "//\\([^/]+\\)/")
6621 (setq server (match-string 1))
6622 (goto-char (match-end 0)))
6625 ((looking-at "\\(.*@.*\\)")
6626 (setq message-id (match-string 1)))
6627 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6628 (setq group (match-string 1)
6629 articles (split-string (match-string 2) "-")))
6630 ((looking-at "\\([^/]+\\)/?")
6631 (setq group (match-string 1)))
6633 (error "Unknown news URL syntax"))))
6634 (list scheme server group message-id articles)))
6636 (defun gnus-button-handle-news (url)
6638 (destructuring-bind (scheme server group message-id articles)
6639 (gnus-parse-news-url url)
6643 (set-buffer gnus-summary-buffer)
6645 (let ((gnus-refer-article-method (list (list 'nntp server))))
6646 (gnus-summary-refer-article message-id))
6647 (gnus-summary-refer-article message-id))))
6649 (gnus-button-fetch-group url)))))
6651 (defun gnus-button-handle-man (url)
6653 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6654 (when (eq gnus-button-man-handler 'woman)
6655 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
6656 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6657 (funcall gnus-button-man-handler url))
6659 (defun gnus-button-handle-info-url (url)
6660 "Fetch an info URL."
6661 (setq url (mm-subst-char-in-string ?+ ?\ url))
6663 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6664 (gnus-info-find-node
6665 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6667 ")" (gnus-url-unhex-string (match-string 2 url)))))
6668 ((string-match "([^)\"]+)[^\"]+" url)
6670 (gnus-replace-in-string
6671 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6672 (gnus-info-find-node url))
6673 (t (error "Can't parse %s" url))))
6675 (defun gnus-button-handle-info-url-gnome (url)
6676 "Fetch GNOME style info URL."
6677 (setq url (mm-subst-char-in-string ?_ ?\ url))
6678 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6679 (gnus-info-find-node
6681 (gnus-url-unhex-string
6682 (match-string 1 url))
6684 (or (gnus-url-unhex-string
6685 (match-string 2 url))
6687 (error "Can't parse %s" url)))
6689 (defun gnus-button-handle-info-url-kde (url)
6690 "Fetch KDE style info URL."
6691 (gnus-info-find-node (gnus-url-unhex-string url)))
6693 (defun gnus-button-handle-info-keystrokes (url)
6694 "Call `info' when pushing the corresponding URL button."
6695 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6700 (defun gnus-button-openpgp (url)
6701 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
6703 (mm-url-insert-file-contents-external url)
6704 (pgg-snarf-keys-region (point-min) (point-max))
6705 (pgg-display-output-buffer nil nil nil)))
6707 (defun gnus-button-message-id (message-id)
6709 (with-current-buffer gnus-summary-buffer
6710 (gnus-summary-refer-article message-id)))
6712 (defun gnus-button-fetch-group (address)
6713 "Fetch GROUP specified by ADDRESS."
6714 (if (not (string-match "[:/]" address))
6715 ;; This is just a simple group url.
6716 (gnus-group-read-ephemeral-group address gnus-select-method)
6719 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6721 (error "Can't parse %s" address)
6722 (gnus-group-read-ephemeral-group
6723 (match-string 4 address)
6724 `(nntp ,(match-string 1 address)
6725 (nntp-address ,(match-string 1 address))
6726 (nntp-port-number ,(if (match-end 3)
6727 (match-string 3 address)
6730 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6732 (defun gnus-url-parse-query-string (query &optional downcase)
6733 (let (retval pairs cur key val)
6734 (setq pairs (split-string query "&"))
6736 (setq cur (car pairs)
6738 (if (not (string-match "=" cur))
6740 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6741 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6743 (setq key (downcase key)))
6744 (setq cur (assoc key retval))
6746 (setcdr cur (cons val (cdr cur)))
6747 (setq retval (cons (list key val) retval)))))
6750 (defun gnus-url-mailto (url)
6751 ;; Send mail to someone
6752 (when (string-match "mailto:/*\\(.*\\)" url)
6753 (setq url (substring url (match-beginning 1) nil)))
6754 (let (to args subject func)
6755 (setq args (gnus-url-parse-query-string
6756 (if (string-match "^\\?" url)
6758 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6759 (concat "to=" (match-string 1 url) "&"
6760 (match-string 2 url))
6761 (concat "to=" url)))
6763 subject (cdr-safe (assoc "subject" args)))
6766 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6769 (message-position-on-field (caar args)))
6770 (insert (gnus-replace-in-string
6771 (mapconcat 'identity (reverse (cdar args)) ", ")
6773 (setq args (cdr args)))
6776 (message-goto-subject))))
6778 (defun gnus-button-embedded-url (address)
6779 "Activate ADDRESS with `browse-url'."
6780 (browse-url (gnus-strip-whitespace address)))
6782 ;;; Next/prev buttons in the article buffer.
6784 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6785 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6787 (defvar gnus-prev-page-map
6788 (let ((map (make-sparse-keymap)))
6789 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6790 (define-key map "\r" 'gnus-button-prev-page)
6793 (defvar gnus-next-page-map
6794 (let ((map (make-sparse-keymap)))
6795 (unless (>= emacs-major-version 21)
6796 ;; XEmacs doesn't care.
6797 (set-keymap-parent map gnus-article-mode-map))
6798 (define-key map gnus-mouse-2 'gnus-button-next-page)
6799 (define-key map "\r" 'gnus-button-next-page)
6802 (defun gnus-insert-prev-page-button ()
6804 (inhibit-read-only t))
6806 gnus-prev-page-line-format nil
6807 `(keymap ,gnus-prev-page-map
6809 gnus-callback gnus-article-button-prev-page
6810 article-type annotation))
6811 (widget-convert-button
6813 ;; Exclude a newline.
6816 :action 'gnus-button-prev-page
6817 :button-keymap gnus-prev-page-map)))
6819 (defun gnus-button-next-page (&optional args more-args)
6820 "Go to the next page."
6822 (let ((win (selected-window)))
6823 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6824 (gnus-article-next-page)
6825 (select-window win)))
6827 (defun gnus-button-prev-page (&optional args more-args)
6828 "Go to the prev page."
6830 (let ((win (selected-window)))
6831 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6832 (gnus-article-prev-page)
6833 (select-window win)))
6835 (defun gnus-insert-next-page-button ()
6837 (inhibit-read-only t))
6838 (gnus-eval-format gnus-next-page-line-format nil
6839 `(keymap ,gnus-next-page-map
6841 gnus-callback gnus-article-button-next-page
6842 article-type annotation))
6843 (widget-convert-button
6845 ;; Exclude a newline.
6848 :action 'gnus-button-next-page
6849 :button-keymap gnus-next-page-map)))
6851 (defun gnus-article-button-next-page (arg)
6852 "Go to the next page."
6854 (let ((win (selected-window)))
6855 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6856 (gnus-article-next-page)
6857 (select-window win)))
6859 (defun gnus-article-button-prev-page (arg)
6860 "Go to the prev page."
6862 (let ((win (selected-window)))
6863 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6864 (gnus-article-prev-page)
6865 (select-window win)))
6867 (defvar gnus-decode-header-methods
6868 '(mail-decode-encoded-word-region)
6869 "List of methods used to decode headers.
6871 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6872 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
6873 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6874 whose names match REGEXP.
6877 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6878 mail-decode-encoded-word-region
6879 (\"chinese\" . rfc1843-decode-region))
6882 (defvar gnus-decode-header-methods-cache nil)
6884 (defun gnus-multi-decode-header (start end)
6885 "Apply the functions from `gnus-encoded-word-methods' that match."
6886 (unless (and gnus-decode-header-methods-cache
6887 (eq gnus-newsgroup-name
6888 (car gnus-decode-header-methods-cache)))
6889 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6892 (nconc gnus-decode-header-methods-cache (list x))
6893 (if (and gnus-newsgroup-name
6894 (string-match (car x) gnus-newsgroup-name))
6895 (nconc gnus-decode-header-methods-cache
6897 gnus-decode-header-methods))
6898 (let ((xlist gnus-decode-header-methods-cache))
6901 (narrow-to-region start end)
6903 (funcall (pop xlist) (point-min) (point-max))))))
6906 ;;; Treatment top-level handling.
6909 (defun gnus-treat-article (condition &optional part-number total-parts type)
6910 (let ((length (- (point-max) (point-min)))
6911 (alist gnus-treatment-function-alist)
6912 (article-goto-body-goes-to-point-min-p t)
6916 (let ((list gnus-article-treat-types))
6918 (when (string-match (pop list) type)
6919 (throw 'found t)))))))
6920 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6922 (gnus-run-hooks 'gnus-part-display-hook)
6923 (dolist (elem alist)
6926 (when (gnus-buffer-live-p gnus-summary-buffer)
6927 (set-buffer gnus-summary-buffer))
6928 (symbol-value (car elem))))
6929 (when (and (or (consp val)
6931 (gnus-treat-predicate val)
6932 (or (not (get (car elem) 'highlight))
6935 (funcall (cadr elem)))))))
6937 ;; Dynamic variables.
6939 (defvar part-number)
6940 (defvar total-parts)
6945 (defun gnus-treat-predicate (val)
6952 (stringp (car val)))
6953 (apply 'gnus-or (mapcar `(lambda (s)
6954 (string-match s ,(or gnus-newsgroup-name "")))
6957 (let ((pred (pop val)))
6960 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6962 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6964 (not (gnus-treat-predicate (car val))))
6966 (equal (car val) type))
6968 (error "%S is not a valid predicate" pred)))))
6974 (eq part-number total-parts))
6978 (error "%S is not a valid value" val))))
6980 (defun gnus-article-encrypt-body (protocol &optional n)
6981 "Encrypt the article body."
6984 (or gnus-article-encrypt-protocol
6985 (completing-read "Encrypt protocol: "
6986 gnus-article-encrypt-protocol-alist
6988 current-prefix-arg))
6989 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6991 (error (format "Can't find the encrypt protocol %s" protocol)))
6992 (if (member gnus-newsgroup-name '("nndraft:delayed"
6995 (error "Can't encrypt the article in group %s"
6996 gnus-newsgroup-name))
6997 (gnus-summary-iterate n
6999 (set-buffer gnus-summary-buffer)
7000 (let ((mail-parse-charset gnus-newsgroup-charset)
7001 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7002 (summary-buffer gnus-summary-buffer)
7004 (gnus-set-global-variables)
7005 (when (gnus-group-read-only-p)
7006 (error "The current newsgroup does not support article encrypt"))
7007 (gnus-summary-show-article t)
7009 (or (mail-header-references gnus-current-headers) ""))
7010 (set-buffer gnus-article-buffer)
7011 (let* ((inhibit-read-only t)
7013 (mapcar (lambda (field)
7014 (and (save-restriction
7015 (message-narrow-to-head)
7016 (goto-char (point-min))
7017 (search-forward field nil t))
7019 (message-narrow-to-field)
7021 (delete-region (point-min) (point-max))
7023 '("Content-Type:" "Content-Transfer-Encoding:"
7024 "Content-Disposition:"))))
7025 (message-narrow-to-head)
7026 (message-remove-header "MIME-Version")
7027 (goto-char (point-max))
7028 (setq point (point))
7029 (insert (apply 'concat headers))
7031 (narrow-to-region point (point-max))
7032 (let ((message-options message-options))
7033 (message-options-set 'message-sender user-mail-address)
7034 (message-options-set 'message-recipients user-mail-address)
7035 (message-options-set 'message-sign-encrypt 'not)
7037 (goto-char (point-min))
7038 (insert "MIME-Version: 1.0\n")
7040 (gnus-summary-edit-article-done
7041 references nil summary-buffer t))
7042 (when gnus-keep-backlog
7043 (gnus-backlog-remove-article
7044 (car gnus-article-current) (cdr gnus-article-current)))
7046 (when (get-buffer gnus-original-article-buffer)
7047 (set-buffer gnus-original-article-buffer)
7048 (setq gnus-original-article nil)))
7049 (when gnus-use-cache
7050 (gnus-cache-update-article
7051 (car gnus-article-current) (cdr gnus-article-current))))))))
7053 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7054 "The following specs can be used:
7055 %t The security MIME type
7058 %D Details if button is pressed")
7060 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7061 "The following specs can be used:
7062 %t The security MIME type
7065 %D Details if button is pressed")
7067 (defvar gnus-mime-security-button-line-format-alist
7068 '((?t gnus-tmp-type ?s)
7069 (?i gnus-tmp-info ?s)
7070 (?d gnus-tmp-details ?s)
7071 (?D gnus-tmp-pressed-details ?s)))
7073 (defvar gnus-mime-security-button-map
7074 (let ((map (make-sparse-keymap)))
7075 (define-key map gnus-mouse-2 'gnus-article-push-button)
7076 (define-key map "\r" 'gnus-article-press-button)
7079 (defvar gnus-mime-security-details-buffer nil)
7081 (defvar gnus-mime-security-button-pressed nil)
7083 (defvar gnus-mime-security-show-details-inline t
7084 "If non-nil, show details in the article buffer.")
7086 (defun gnus-mime-security-verify-or-decrypt (handle)
7087 (mm-remove-parts (cdr handle))
7088 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7089 point (inhibit-read-only t))
7091 (goto-char (car region)))
7093 (narrow-to-region (point) (point))
7094 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7095 (let* ((mm-verify-option 'known)
7096 (mm-decrypt-option 'known)
7097 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7098 (unless (eq nparts (cdr handle))
7099 (mm-destroy-parts (cdr handle))
7100 (setcdr handle nparts))))
7101 (setq point (point))
7102 (gnus-mime-display-security handle)
7103 (goto-char (point-max)))
7105 (delete-region (point) (cdr region))
7106 (set-marker (car region) nil)
7107 (set-marker (cdr region) nil))
7110 (defun gnus-mime-security-show-details (handle)
7111 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7113 (gnus-message 5 "No details.")
7114 (if gnus-mime-security-show-details-inline
7115 (let ((gnus-mime-security-button-pressed
7116 (not (get-text-property (point) 'gnus-mime-details)))
7117 (gnus-mime-security-button-line-format
7118 (get-text-property (point) 'gnus-line-format))
7119 (inhibit-read-only t))
7121 (while (eq (get-text-property (point) 'gnus-line-format)
7122 gnus-mime-security-button-line-format)
7126 (narrow-to-region (point) (point))
7127 (gnus-insert-mime-security-button handle))
7128 (delete-region (point)
7129 (or (text-property-not-all
7132 gnus-mime-security-button-line-format)
7135 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7136 (with-current-buffer gnus-mime-security-details-buffer
7139 (setq gnus-mime-security-details-buffer
7140 (gnus-get-buffer-create "*MIME Security Details*")))
7141 (with-current-buffer gnus-mime-security-details-buffer
7143 (goto-char (point-min)))
7144 (pop-to-buffer gnus-mime-security-details-buffer)))))
7146 (defun gnus-mime-security-press-button (handle)
7148 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7149 (gnus-mime-security-show-details handle)
7150 (gnus-mime-security-verify-or-decrypt handle))))
7152 (defun gnus-insert-mime-security-button (handle &optional displayed)
7153 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7156 (or (nth 2 (assoc protocol mm-verify-function-alist))
7157 (nth 2 (assoc protocol mm-decrypt-function-alist))
7159 (if (equal (car handle) "multipart/signed")
7160 " Signed" " Encrypted")
7163 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7166 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7167 gnus-tmp-pressed-details
7169 (setq gnus-tmp-details
7170 (if gnus-tmp-details
7171 (concat "\n" gnus-tmp-details)
7173 (setq gnus-tmp-pressed-details
7174 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7179 gnus-mime-security-button-line-format
7180 gnus-mime-security-button-line-format-alist
7181 `(keymap ,gnus-mime-security-button-map
7182 gnus-callback gnus-mime-security-press-button
7183 gnus-line-format ,gnus-mime-security-button-line-format
7184 gnus-mime-details ,gnus-mime-security-button-pressed
7185 article-type annotation
7188 ;; Exclude a newline.
7191 (widget-convert-button
7194 :action 'gnus-widget-press-button
7195 :button-keymap gnus-mime-security-button-map
7197 (lambda (widget/window &optional overlay pos)
7198 ;; Needed to properly clear the message due to a bug in
7199 ;; wid-edit (XEmacs only).
7200 (when (boundp 'help-echo-owns-message)
7201 (setq help-echo-owns-message t))
7204 (aref gnus-mouse-2 0))))))
7206 (defun gnus-mime-display-security (handle)
7208 (narrow-to-region (point) (point))
7209 (unless (gnus-unbuttonized-mime-type-p (car handle))
7210 (gnus-insert-mime-security-button handle))
7211 (gnus-mime-display-mixed (cdr handle))
7214 (unless (gnus-unbuttonized-mime-type-p (car handle))
7215 (let ((gnus-mime-security-button-line-format
7216 gnus-mime-security-button-end-line-format))
7217 (gnus-insert-mime-security-button handle)))
7218 (mm-set-handle-multipart-parameter
7220 (cons (set-marker (make-marker) (point-min))
7221 (set-marker (make-marker) (point-max))))))
7227 (run-hooks 'gnus-art-load-hook)
7229 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7230 ;;; gnus-art.el ends here