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 'parse-time-string "parse-time" nil nil)
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."
237 :type '(choice (integer :value 200)
239 (function :value fun)
240 (regexp :value ".*"))
241 :group 'gnus-article-signature)
243 (defcustom gnus-hidden-properties '(invisible t intangible t)
244 "Property list to use for hiding text."
246 :group 'gnus-article-hiding)
248 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
249 ;; frames in a session.
250 (defcustom gnus-article-x-face-command
251 (if (featurep 'xemacs)
252 (if (or (gnus-image-type-available-p 'xface)
253 (gnus-image-type-available-p 'pbm))
254 'gnus-display-x-face-in-from
255 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
256 (if (gnus-image-type-available-p 'pbm)
257 'gnus-display-x-face-in-from
258 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
260 "*String or function to be executed to display an X-Face header.
261 If it is a string, the command will be executed in a sub-shell
262 asynchronously. The compressed face will be piped to this command."
263 :type `(choice string
264 (function-item gnus-display-x-face-in-from)
268 :group 'gnus-article-washing)
270 (defcustom gnus-article-x-face-too-ugly nil
271 "Regexp matching posters whose face shouldn't be shown automatically."
272 :type '(choice regexp (const nil))
273 :group 'gnus-article-washing)
275 (defcustom gnus-article-banner-alist nil
276 "Banner alist for stripping.
278 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
280 :type '(repeat (cons symbol regexp))
281 :group 'gnus-article-washing)
283 (gnus-define-group-parameter
286 "Alist of regexps (to match group names) and banner."
287 :variable-group gnus-article-washing
289 '(choice :tag "Banner"
291 (const :tag "Remove signature" signature)
292 (symbol :tag "Item in `gnus-article-banner-alist'" none)
294 (const :tag "None" nil))
296 "If non-nil, specify how to remove `banners' from articles.
298 Symbol `signature' means to remove signatures delimited by
299 `gnus-signature-separator'. Any other symbol is used to look up a
300 regular expression to match the banner in `gnus-article-banner-alist'.
301 A string is used as a regular expression to match the banner
304 (defcustom gnus-article-address-banner-alist nil
305 "Alist of mail addresses and banners.
306 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
307 to match a mail address in the From: header, BANNER is one of a symbol
308 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
309 If ADDRESS matches author's mail address, it will remove things like
310 advertisements. For example:
312 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
316 (regexp :tag "Address")
317 (choice :tag "Banner" :value nil
318 (const :tag "Remove signature" signature)
319 (symbol :tag "Item in `gnus-article-banner-alist'" none)
321 (const :tag "None" nil))))
323 :group 'gnus-article-washing)
325 (defmacro gnus-emphasis-custom-with-format (&rest body)
327 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
328 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
331 (defun gnus-emphasis-custom-value-to-external (value)
332 (gnus-emphasis-custom-with-format
333 (if (consp (car value))
334 (list (format format (car (car value)) (cdr (car value)))
336 (if (nth 1 value) 2 3)
340 (defun gnus-emphasis-custom-value-to-internal (value)
341 (gnus-emphasis-custom-with-format
342 (let ((regexp (concat "\\`"
343 (format (regexp-quote format)
344 "\\([^()]+\\)" "\\([^()]+\\)")
347 (if (string-match regexp (setq pattern (car value)))
348 (list (cons (match-string 1 pattern) (match-string 2 pattern))
353 (defcustom gnus-emphasis-alist
355 '(("\\*" "\\*" bold nil 2)
358 ("_/" "/_" underline-italic)
359 ("_\\*" "\\*_" underline-bold)
360 ("\\*/" "/\\*" bold-italic)
361 ("_\\*/" "/\\*_" underline-bold-italic))))
363 (gnus-emphasis-custom-with-format
364 (mapcar (lambda (spec)
365 (list (format format (car spec) (cadr spec))
368 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
370 '(("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
371 2 3 gnus-emphasis-strikethru)
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, %b %d %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 symbol)
481 :link '(custom-manual "(gnus)Article Date")
482 :group 'gnus-article-washing)
484 (defcustom gnus-save-all-headers t
485 "*If non-nil, don't remove any headers before saving."
486 :group 'gnus-article-saving
489 (defcustom gnus-prompt-before-saving 'always
490 "*This variable says how much prompting is to be done when saving articles.
491 If it is nil, no prompting will be done, and the articles will be
492 saved to the default files. If this variable is `always', each and
493 every article that is saved will be preceded by a prompt, even when
494 saving large batches of articles. If this variable is neither nil not
495 `always', there the user will be prompted once for a file name for
496 each invocation of the saving commands."
497 :group 'gnus-article-saving
498 :type '(choice (item always)
499 (item :tag "never" nil)
500 (sexp :tag "once" :format "%t\n" :value t)))
502 (defcustom gnus-saved-headers gnus-visible-headers
503 "Headers to keep if `gnus-save-all-headers' is nil.
504 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
505 If that variable is nil, however, all headers that match this regexp
506 will be kept while the rest will be deleted before saving."
507 :group 'gnus-article-saving
510 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
511 "A function to save articles in your favourite format.
512 The function must be interactively callable (in other words, it must
513 be an Emacs command).
515 Gnus provides the following functions:
517 * gnus-summary-save-in-rmail (Rmail format)
518 * gnus-summary-save-in-mail (Unix mail format)
519 * gnus-summary-save-in-folder (MH folder)
520 * gnus-summary-save-in-file (article format)
521 * gnus-summary-save-body-in-file (article body)
522 * gnus-summary-save-in-vm (use VM's folder format)
523 * gnus-summary-write-to-file (article format -- overwrite)."
524 :group 'gnus-article-saving
525 :type '(radio (function-item gnus-summary-save-in-rmail)
526 (function-item gnus-summary-save-in-mail)
527 (function-item gnus-summary-save-in-folder)
528 (function-item gnus-summary-save-in-file)
529 (function-item gnus-summary-save-body-in-file)
530 (function-item gnus-summary-save-in-vm)
531 (function-item gnus-summary-write-to-file)))
533 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
534 "A function generating a file name to save articles in Rmail format.
535 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
536 :group 'gnus-article-saving
539 (defcustom gnus-mail-save-name 'gnus-plain-save-name
540 "A function generating a file name to save articles in Unix mail format.
541 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
542 :group 'gnus-article-saving
545 (defcustom gnus-folder-save-name 'gnus-folder-save-name
546 "A function generating a file name to save articles in MH folder.
547 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
548 :group 'gnus-article-saving
551 (defcustom gnus-file-save-name 'gnus-numeric-save-name
552 "A function generating a file name to save articles in article format.
553 The function is called with NEWSGROUP, HEADERS, and optional
555 :group 'gnus-article-saving
558 (defcustom gnus-split-methods
559 '((gnus-article-archive-name)
560 (gnus-article-nndoc-name))
561 "*Variable used to suggest where articles are to be saved.
562 For instance, if you would like to save articles related to Gnus in
563 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
564 you could set this variable to something like:
566 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
567 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
569 This variable is an alist where the where the key is the match and the
570 value is a list of possible files to save in if the match is non-nil.
572 If the match is a string, it is used as a regexp match on the
573 article. If the match is a symbol, that symbol will be funcalled
574 from the buffer of the article to be saved with the newsgroup as the
575 parameter. If it is a list, it will be evaled in the same buffer.
577 If this form or function returns a string, this string will be used as
578 a possible file name; and if it returns a non-nil list, that list will
579 be used as possible file names."
580 :group 'gnus-article-saving
581 :type '(repeat (choice (list :value (fun) function)
582 (cons :value ("" "") regexp (repeat string))
585 (defcustom gnus-page-delimiter "^\^L"
586 "*Regexp describing what to use as article page delimiters.
587 The default value is \"^\^L\", which is a form linefeed at the
588 beginning of a line."
590 :group 'gnus-article-various)
592 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
593 "*The format specification for the article mode line.
594 See `gnus-summary-mode-line-format' for a closer description.
596 The following additional specs are available:
598 %w The article washing status.
599 %m The number of MIME parts in the article."
601 :group 'gnus-article-various)
603 (defcustom gnus-article-mode-hook nil
604 "*A hook for Gnus article mode."
606 :group 'gnus-article-various)
608 (when (featurep 'xemacs)
609 ;; Extracted from gnus-xmas-define in order to preserve user settings
610 (when (fboundp 'turn-off-scroll-in-place)
611 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
612 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
613 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
615 (defcustom gnus-article-menu-hook nil
616 "*Hook run after the creation of the article mode menu."
618 :group 'gnus-article-various)
620 (defcustom gnus-article-prepare-hook nil
621 "*A hook called after an article has been prepared in the article buffer."
623 :group 'gnus-article-various)
625 (make-obsolete-variable 'gnus-article-hide-pgp-hook
626 "This variable is obsolete in Gnus 5.10.")
628 (defcustom gnus-article-button-face 'bold
629 "Face used for highlighting buttons in the article buffer.
631 An article button is a piece of text that you can activate by pressing
632 `RET' or `mouse-2' above it."
634 :group 'gnus-article-buttons)
636 (defcustom gnus-article-mouse-face 'highlight
637 "Face used for mouse highlighting in the article buffer.
639 Article buttons will be displayed in this face when the cursor is
642 :group 'gnus-article-buttons)
644 (defcustom gnus-signature-face 'gnus-signature-face
645 "Face used for highlighting a signature in the article buffer.
646 Obsolete; use the face `gnus-signature-face' for customizations instead."
648 :group 'gnus-article-highlight
649 :group 'gnus-article-signature)
651 (defface gnus-signature-face
654 "Face used for highlighting a signature in the article buffer."
655 :group 'gnus-article-highlight
656 :group 'gnus-article-signature)
658 (defface gnus-header-from-face
661 (:foreground "spring green"))
664 (:foreground "red3"))
667 "Face used for displaying from headers."
668 :group 'gnus-article-headers
669 :group 'gnus-article-highlight)
671 (defface gnus-header-subject-face
674 (:foreground "SeaGreen3"))
677 (:foreground "red4"))
679 (:bold t :italic t)))
680 "Face used for displaying subject headers."
681 :group 'gnus-article-headers
682 :group 'gnus-article-highlight)
684 (defface gnus-header-newsgroups-face
687 (:foreground "yellow" :italic t))
690 (:foreground "MidnightBlue" :italic t))
693 "Face used for displaying newsgroups headers.
694 In the default setup this face is only used for crossposted
696 :group 'gnus-article-headers
697 :group 'gnus-article-highlight)
699 (defface gnus-header-name-face
702 (:foreground "SeaGreen"))
705 (:foreground "maroon"))
708 "Face used for displaying header names."
709 :group 'gnus-article-headers
710 :group 'gnus-article-highlight)
712 (defface gnus-header-content-face
715 (:foreground "forest green" :italic t))
718 (:foreground "indianred4" :italic t))
720 (:italic t))) "Face used for displaying header content."
721 :group 'gnus-article-headers
722 :group 'gnus-article-highlight)
724 (defcustom gnus-header-face-alist
725 '(("From" nil gnus-header-from-face)
726 ("Subject" nil gnus-header-subject-face)
727 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
728 ("" gnus-header-name-face gnus-header-content-face))
729 "*Controls highlighting of article headers.
731 An alist of the form (HEADER NAME CONTENT).
733 HEADER is a regular expression which should match the name of a
734 header and NAME and CONTENT are either face names or nil.
736 The name of each header field will be displayed using the face
737 specified by the first element in the list where HEADER matches
738 the header name and NAME is non-nil. Similarly, the content will
739 be displayed by the first non-nil matching CONTENT face."
740 :group 'gnus-article-headers
741 :group 'gnus-article-highlight
742 :type '(repeat (list (regexp :tag "Header")
744 (item :tag "skip" nil)
745 (face :value default))
746 (choice :tag "Content"
747 (item :tag "skip" nil)
748 (face :value default)))))
750 (defcustom gnus-article-decode-hook
751 '(article-decode-charset article-decode-encoded-words
752 article-decode-group-name article-decode-idna-rhs)
753 "*Hook run to decode charsets in articles."
754 :group 'gnus-article-headers
757 (defcustom gnus-display-mime-function 'gnus-display-mime
758 "Function to display MIME articles."
759 :group 'gnus-article-mime
762 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
763 "Function used to decode headers.")
765 (defvar gnus-article-dumbquotes-map
785 "Table for MS-to-Latin1 translation.")
787 (defcustom gnus-ignored-mime-types nil
788 "List of MIME types that should be ignored by Gnus."
790 :group 'gnus-article-mime
791 :type '(repeat regexp))
793 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
794 "List of MIME types that should not be given buttons when rendered inline.
795 See also `gnus-buttonized-mime-types' which may override this variable.
796 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
798 :group 'gnus-article-mime
799 :type '(repeat regexp))
801 (defcustom gnus-buttonized-mime-types nil
802 "List of MIME types that should be given buttons when rendered inline.
803 If set, this variable overrides `gnus-unbuttonized-mime-types'.
804 To see e.g. security buttons you could set this to
805 `(\"multipart/signed\")'.
806 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
808 :group 'gnus-article-mime
809 :type '(repeat regexp))
811 (defcustom gnus-inhibit-mime-unbuttonizing nil
812 "If non-nil, all MIME parts get buttons.
813 When nil (the default value), then some MIME parts do not get buttons,
814 as described by the variables `gnus-buttonized-mime-types' and
815 `gnus-unbuttonized-mime-types'."
819 (defcustom gnus-body-boundary-delimiter "_"
820 "String used to delimit header and body.
821 This variable is used by `gnus-article-treat-body-boundary' which can
822 be controlled by `gnus-treat-body-boundary'."
824 :group 'gnus-article-various
825 :type '(choice (item :tag "None" :value nil)
828 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
829 "Defines the location of the faces database.
830 For information on obtaining this database of pretty pictures, please
831 see http://www.cs.indiana.edu/picons/ftp/index.html"
833 :type '(repeat directory)
834 :link '(url-link :tag "download"
835 "http://www.cs.indiana.edu/picons/ftp/index.html")
836 :link '(custom-manual "(gnus)Picons")
839 (defun gnus-picons-installed-p ()
840 "Say whether picons are installed on your machine."
841 (let ((installed nil))
842 (dolist (database gnus-picon-databases)
843 (when (file-exists-p database)
847 (defcustom gnus-article-mime-part-function nil
848 "Function called with a MIME handle as the argument.
849 This is meant for people who want to do something automatic based
850 on parts -- for instance, adding Vcard info to a database."
851 :group 'gnus-article-mime
854 (defcustom gnus-mime-multipart-functions nil
855 "An alist of MIME types to functions to display them."
857 :group 'gnus-article-mime
860 (defcustom gnus-article-date-lapsed-new-header nil
861 "Whether the X-Sent and Date headers can coexist.
862 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
863 either replace the old \"Date:\" header (if this variable is nil), or
864 be added below it (otherwise)."
866 :group 'gnus-article-headers
869 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
870 "Function called with a MIME handle as the argument.
871 This is meant for people who want to view first matched part.
872 For `undisplayed-alternative' (default), the first undisplayed
873 part or alternative part is used. For `undisplayed', the first
874 undisplayed part is used. For a function, the first part which
875 the function return t is used. For nil, the first part is
878 :group 'gnus-article-mime
880 (item :tag "first" :value nil)
881 (item :tag "undisplayed" :value undisplayed)
882 (item :tag "undisplayed or alternative"
883 :value undisplayed-alternative)
886 (defcustom gnus-mime-action-alist
887 '(("save to file" . gnus-mime-save-part)
888 ("save and strip" . gnus-mime-save-part-and-strip)
889 ("delete part" . gnus-mime-delete-part)
890 ("display as text" . gnus-mime-inline-part)
891 ("view the part" . gnus-mime-view-part)
892 ("pipe to command" . gnus-mime-pipe-part)
893 ("toggle display" . gnus-article-press-button)
894 ("toggle display" . gnus-article-view-part-as-charset)
895 ("view as type" . gnus-mime-view-part-as-type)
896 ("view internally" . gnus-mime-view-part-internally)
897 ("view externally" . gnus-mime-view-part-externally))
898 "An alist of actions that run on the MIME attachment."
899 :group 'gnus-article-mime
900 :type '(repeat (cons (string :tag "name")
904 ;;; The treatment variables
907 (defvar gnus-part-display-hook nil
908 "Hook called on parts that are to receive treatment.")
910 (defvar gnus-article-treat-custom
911 '(choice (const :tag "Off" nil)
913 (const :tag "Header" head)
914 (const :tag "Last" last)
915 (integer :tag "Less")
916 (repeat :tag "Groups" regexp)
917 (sexp :tag "Predicate")))
919 (defvar gnus-article-treat-head-custom
920 '(choice (const :tag "Off" nil)
921 (const :tag "Header" head)))
923 (defvar gnus-article-treat-types '("text/plain")
926 (defvar gnus-inhibit-treatment nil
927 "Whether to inhibit treatment.")
929 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
930 "Highlight the signature.
931 Valid values are nil, t, `head', `last', an integer or a predicate.
932 See Info node `(gnus)Customizing Articles'."
933 :group 'gnus-article-treat
934 :link '(custom-manual "(gnus)Customizing Articles")
935 :type gnus-article-treat-custom)
936 (put 'gnus-treat-highlight-signature 'highlight t)
938 (defcustom gnus-treat-buttonize 100000
940 Valid values are nil, t, `head', `last', an integer or a predicate.
941 See Info node `(gnus)Customizing Articles'."
942 :group 'gnus-article-treat
943 :link '(custom-manual "(gnus)Customizing Articles")
944 :type gnus-article-treat-custom)
945 (put 'gnus-treat-buttonize 'highlight t)
947 (defcustom gnus-treat-buttonize-head 'head
948 "Add buttons to the head.
949 Valid values are nil, t, `head', `last', an integer or a predicate.
950 See Info node `(gnus)Customizing Articles' for details."
951 :group 'gnus-article-treat
952 :link '(custom-manual "(gnus)Customizing Articles")
953 :type gnus-article-treat-head-custom)
954 (put 'gnus-treat-buttonize-head 'highlight t)
956 (defcustom gnus-treat-emphasize
957 (and (or window-system
959 (>= (string-to-number emacs-version) 21))
962 Valid values are nil, t, `head', `last', an integer or a predicate.
963 See Info node `(gnus)Customizing Articles' for details."
964 :group 'gnus-article-treat
965 :link '(custom-manual "(gnus)Customizing Articles")
966 :type gnus-article-treat-custom)
967 (put 'gnus-treat-emphasize 'highlight t)
969 (defcustom gnus-treat-strip-cr nil
970 "Remove carriage returns.
971 Valid values are nil, t, `head', `last', an integer or a predicate.
972 See Info node `(gnus)Customizing Articles' for details."
974 :group 'gnus-article-treat
975 :link '(custom-manual "(gnus)Customizing Articles")
976 :type gnus-article-treat-custom)
978 (defcustom gnus-treat-unsplit-urls nil
979 "Remove newlines from within URLs.
980 Valid values are nil, t, `head', `last', an integer or a predicate.
981 See Info node `(gnus)Customizing Articles' for details."
983 :group 'gnus-article-treat
984 :link '(custom-manual "(gnus)Customizing Articles")
985 :type gnus-article-treat-custom)
987 (defcustom gnus-treat-leading-whitespace nil
988 "Remove leading whitespace in headers.
989 Valid values are nil, t, `head', `last', an integer or a predicate.
990 See Info node `(gnus)Customizing Articles' for details."
992 :group 'gnus-article-treat
993 :link '(custom-manual "(gnus)Customizing Articles")
994 :type gnus-article-treat-custom)
996 (defcustom gnus-treat-hide-headers 'head
998 Valid values are nil, t, `head', `last', an integer or a predicate.
999 See Info node `(gnus)Customizing Articles' for details."
1000 :group 'gnus-article-treat
1001 :link '(custom-manual "(gnus)Customizing Articles")
1002 :type gnus-article-treat-head-custom)
1004 (defcustom gnus-treat-hide-boring-headers nil
1005 "Hide boring headers.
1006 Valid values are nil, t, `head', `last', an integer or a predicate.
1007 See Info node `(gnus)Customizing Articles' for details."
1008 :group 'gnus-article-treat
1009 :link '(custom-manual "(gnus)Customizing Articles")
1010 :type gnus-article-treat-head-custom)
1012 (defcustom gnus-treat-hide-signature nil
1013 "Hide the signature.
1014 Valid values are nil, t, `head', `last', an integer or a predicate.
1015 See Info node `(gnus)Customizing Articles' for details."
1016 :group 'gnus-article-treat
1017 :link '(custom-manual "(gnus)Customizing Articles")
1018 :type gnus-article-treat-custom)
1020 (defcustom gnus-treat-fill-article nil
1022 Valid values are nil, t, `head', `last', an integer or a predicate.
1023 See Info node `(gnus)Customizing Articles' for details."
1024 :group 'gnus-article-treat
1025 :link '(custom-manual "(gnus)Customizing Articles")
1026 :type gnus-article-treat-custom)
1028 (defcustom gnus-treat-hide-citation nil
1030 Valid values are nil, t, `head', `last', an integer or a predicate.
1031 See Info node `(gnus)Customizing Articles' for details."
1032 :group 'gnus-article-treat
1033 :link '(custom-manual "(gnus)Customizing Articles")
1034 :type gnus-article-treat-custom)
1036 (defcustom gnus-treat-hide-citation-maybe nil
1038 Valid values are nil, t, `head', `last', an integer or a predicate.
1039 See Info node `(gnus)Customizing Articles' for details."
1040 :group 'gnus-article-treat
1041 :link '(custom-manual "(gnus)Customizing Articles")
1042 :type gnus-article-treat-custom)
1044 (defcustom gnus-treat-strip-list-identifiers 'head
1045 "Strip list identifiers from `gnus-list-identifiers`.
1046 Valid values are nil, t, `head', `last', an integer or a predicate.
1047 See Info node `(gnus)Customizing Articles' for details."
1049 :group 'gnus-article-treat
1050 :link '(custom-manual "(gnus)Customizing Articles")
1051 :type gnus-article-treat-custom)
1053 (make-obsolete-variable 'gnus-treat-strip-pgp
1054 "This option is obsolete in Gnus 5.10.")
1056 (defcustom gnus-treat-strip-pem nil
1057 "Strip PEM signatures.
1058 Valid values are nil, t, `head', `last', an integer or a predicate.
1059 See Info node `(gnus)Customizing Articles' for details."
1060 :group 'gnus-article-treat
1061 :link '(custom-manual "(gnus)Customizing Articles")
1062 :type gnus-article-treat-custom)
1064 (defcustom gnus-treat-strip-banner t
1065 "Strip banners from articles.
1066 The banner to be stripped is specified in the `banner' group parameter.
1067 Valid values are nil, t, `head', `last', an integer or a predicate.
1068 See Info node `(gnus)Customizing Articles' for details."
1069 :group 'gnus-article-treat
1070 :link '(custom-manual "(gnus)Customizing Articles")
1071 :type gnus-article-treat-custom)
1073 (defcustom gnus-treat-highlight-headers 'head
1074 "Highlight the headers.
1075 Valid values are nil, t, `head', `last', an integer or a predicate.
1076 See Info node `(gnus)Customizing Articles' for details."
1077 :group 'gnus-article-treat
1078 :link '(custom-manual "(gnus)Customizing Articles")
1079 :type gnus-article-treat-head-custom)
1080 (put 'gnus-treat-highlight-headers 'highlight t)
1082 (defcustom gnus-treat-highlight-citation t
1083 "Highlight cited text.
1084 Valid values are nil, t, `head', `last', an integer or a predicate.
1085 See Info node `(gnus)Customizing Articles' for details."
1086 :group 'gnus-article-treat
1087 :link '(custom-manual "(gnus)Customizing Articles")
1088 :type gnus-article-treat-custom)
1089 (put 'gnus-treat-highlight-citation 'highlight t)
1091 (defcustom gnus-treat-date-ut nil
1092 "Display the Date in UT (GMT).
1093 Valid values are nil, t, `head', `last', an integer or a predicate.
1094 See Info node `(gnus)Customizing Articles' for details."
1095 :group 'gnus-article-treat
1096 :link '(custom-manual "(gnus)Customizing Articles")
1097 :type gnus-article-treat-head-custom)
1099 (defcustom gnus-treat-date-local nil
1100 "Display the Date in the local timezone.
1101 Valid values are nil, t, `head', `last', an integer or a predicate.
1102 See Info node `(gnus)Customizing Articles' for details."
1103 :group 'gnus-article-treat
1104 :link '(custom-manual "(gnus)Customizing Articles")
1105 :type gnus-article-treat-head-custom)
1107 (defcustom gnus-treat-date-english nil
1108 "Display the Date in a format that can be read aloud in English.
1109 Valid values are nil, t, `head', `last', an integer or a predicate.
1110 See Info node `(gnus)Customizing Articles' for details."
1112 :group 'gnus-article-treat
1113 :link '(custom-manual "(gnus)Customizing Articles")
1114 :type gnus-article-treat-head-custom)
1116 (defcustom gnus-treat-date-lapsed nil
1117 "Display the Date header in a way that says how much time has elapsed.
1118 Valid values are nil, t, `head', `last', an integer or a predicate.
1119 See Info node `(gnus)Customizing Articles' for details."
1120 :group 'gnus-article-treat
1121 :link '(custom-manual "(gnus)Customizing Articles")
1122 :type gnus-article-treat-head-custom)
1124 (defcustom gnus-treat-date-original nil
1125 "Display the date in the original timezone.
1126 Valid values are nil, t, `head', `last', an integer or a predicate.
1127 See Info node `(gnus)Customizing Articles' for details."
1128 :group 'gnus-article-treat
1129 :link '(custom-manual "(gnus)Customizing Articles")
1130 :type gnus-article-treat-head-custom)
1132 (defcustom gnus-treat-date-iso8601 nil
1133 "Display the date in the ISO8601 format.
1134 Valid values are nil, t, `head', `last', an integer or a predicate.
1135 See Info node `(gnus)Customizing Articles' for details."
1137 :group 'gnus-article-treat
1138 :link '(custom-manual "(gnus)Customizing Articles")
1139 :type gnus-article-treat-head-custom)
1141 (defcustom gnus-treat-date-user-defined nil
1142 "Display the date in a user-defined format.
1143 The format is defined by the `gnus-article-time-format' variable.
1144 Valid values are nil, t, `head', `last', an integer or a predicate.
1145 See Info node `(gnus)Customizing Articles' for details."
1146 :group 'gnus-article-treat
1147 :link '(custom-manual "(gnus)Customizing Articles")
1148 :type gnus-article-treat-head-custom)
1150 (defcustom gnus-treat-strip-headers-in-body t
1151 "Strip the X-No-Archive header line from the beginning of the body.
1152 Valid values are nil, t, `head', `last', an integer or a predicate.
1153 See Info node `(gnus)Customizing Articles' for details."
1155 :group 'gnus-article-treat
1156 :link '(custom-manual "(gnus)Customizing Articles")
1157 :type gnus-article-treat-custom)
1159 (defcustom gnus-treat-strip-trailing-blank-lines nil
1160 "Strip trailing blank lines.
1161 Valid values are nil, t, `head', `last', an integer or a predicate.
1162 See Info node `(gnus)Customizing Articles' for details."
1163 :group 'gnus-article-treat
1164 :link '(custom-manual "(gnus)Customizing Articles")
1165 :type gnus-article-treat-custom)
1167 (defcustom gnus-treat-strip-leading-blank-lines nil
1168 "Strip leading blank lines.
1169 Valid values are nil, t, `head', `last', an integer or a predicate.
1170 See Info node `(gnus)Customizing Articles' for details."
1171 :group 'gnus-article-treat
1172 :link '(custom-manual "(gnus)Customizing Articles")
1173 :type gnus-article-treat-custom)
1175 (defcustom gnus-treat-strip-multiple-blank-lines nil
1176 "Strip multiple blank lines.
1177 Valid values are nil, t, `head', `last', an integer or a predicate.
1178 See Info node `(gnus)Customizing Articles' for details."
1179 :group 'gnus-article-treat
1180 :link '(custom-manual "(gnus)Customizing Articles")
1181 :type gnus-article-treat-custom)
1183 (defcustom gnus-treat-unfold-headers 'head
1184 "Unfold folded header lines.
1185 Valid values are nil, t, `head', `last', an integer or a predicate.
1186 See Info node `(gnus)Customizing Articles' for details."
1188 :group 'gnus-article-treat
1189 :link '(custom-manual "(gnus)Customizing Articles")
1190 :type gnus-article-treat-custom)
1192 (defcustom gnus-treat-fold-headers nil
1194 Valid values are nil, t, `head', `last', an integer or a predicate.
1195 See Info node `(gnus)Customizing Articles' for details."
1197 :group 'gnus-article-treat
1198 :link '(custom-manual "(gnus)Customizing Articles")
1199 :type gnus-article-treat-custom)
1201 (defcustom gnus-treat-fold-newsgroups 'head
1202 "Fold the Newsgroups and Followup-To headers.
1203 Valid values are nil, t, `head', `last', an integer or a predicate.
1204 See Info node `(gnus)Customizing Articles' for details."
1206 :group 'gnus-article-treat
1207 :link '(custom-manual "(gnus)Customizing Articles")
1208 :type gnus-article-treat-custom)
1210 (defcustom gnus-treat-overstrike t
1211 "Treat overstrike highlighting.
1212 Valid values are nil, t, `head', `last', an integer or a predicate.
1213 See Info node `(gnus)Customizing Articles' for details."
1214 :group 'gnus-article-treat
1215 :link '(custom-manual "(gnus)Customizing Articles")
1216 :type gnus-article-treat-custom)
1217 (put 'gnus-treat-overstrike 'highlight t)
1219 (make-obsolete-variable 'gnus-treat-display-xface
1220 'gnus-treat-display-x-face)
1222 (defcustom gnus-treat-display-x-face
1223 (and (not noninteractive)
1224 (or (and (fboundp 'image-type-available-p)
1225 (image-type-available-p 'xbm)
1226 (string-match "^0x" (shell-command-to-string "uncompface"))
1227 (executable-find "icontopbm"))
1228 (and (featurep 'xemacs)
1231 "Display X-Face headers.
1232 Valid values are nil, t, `head', `last', an integer or a predicate.
1233 See Info node `(gnus)Customizing Articles' and Info node
1234 `(gnus)X-Face' for details."
1235 :group 'gnus-article-treat
1237 :link '(custom-manual "(gnus)Customizing Articles")
1238 :link '(custom-manual "(gnus)X-Face")
1239 :type gnus-article-treat-head-custom
1240 :set (lambda (symbol value)
1243 (cond ((or (boundp symbol) (get symbol 'saved-value))
1245 ((boundp 'gnus-treat-display-xface)
1247 ** gnus-treat-display-xface is an obsolete variable;\
1248 use gnus-treat-display-x-face instead")
1249 (default-value 'gnus-treat-display-xface))
1250 ((get 'gnus-treat-display-xface 'saved-value)
1252 ** gnus-treat-display-xface is an obsolete variable;\
1253 use gnus-treat-display-x-face instead")
1254 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1257 (put 'gnus-treat-display-x-face 'highlight t)
1259 (defcustom gnus-treat-display-face
1260 (and (not noninteractive)
1261 (or (and (fboundp 'image-type-available-p)
1262 (image-type-available-p 'png))
1263 (and (featurep 'xemacs)
1266 "Display Face headers.
1267 Valid values are nil, t, `head', `last', an integer or a predicate.
1268 See Info node `(gnus)Customizing Articles' and Info node
1269 `(gnus)X-Face' for details."
1270 :group 'gnus-article-treat
1272 :link '(custom-manual "(gnus)Customizing Articles")
1273 :link '(custom-manual "(gnus)X-Face")
1274 :type gnus-article-treat-head-custom)
1275 (put 'gnus-treat-display-face 'highlight t)
1277 (defcustom gnus-treat-display-smileys
1278 (if (or (and (featurep 'xemacs)
1280 (and (fboundp 'image-type-available-p)
1281 (image-type-available-p 'pbm)))
1284 Valid values are nil, t, `head', `last', an integer or a predicate.
1285 See Info node `(gnus)Customizing Articles' and Info node
1286 `(gnus)Smileys' for details."
1287 :group 'gnus-article-treat
1289 :link '(custom-manual "(gnus)Customizing Articles")
1290 :link '(custom-manual "(gnus)Smileys")
1291 :type gnus-article-treat-custom)
1292 (put 'gnus-treat-display-smileys 'highlight t)
1294 (defcustom gnus-treat-from-picon
1295 (if (and (gnus-image-type-available-p 'xpm)
1296 (gnus-picons-installed-p))
1298 "Display picons in the From header.
1299 Valid values are nil, t, `head', `last', an integer or a predicate.
1300 See Info node `(gnus)Customizing Articles' and Info node
1301 `(gnus)Picons' for details."
1303 :group 'gnus-article-treat
1305 :link '(custom-manual "(gnus)Customizing Articles")
1306 :link '(custom-manual "(gnus)Picons")
1307 :type gnus-article-treat-head-custom)
1308 (put 'gnus-treat-from-picon 'highlight t)
1310 (defcustom gnus-treat-mail-picon
1311 (if (and (gnus-image-type-available-p 'xpm)
1312 (gnus-picons-installed-p))
1314 "Display picons in To and Cc headers.
1315 Valid values are nil, t, `head', `last', an integer or a predicate.
1316 See Info node `(gnus)Customizing Articles' and Info node
1317 `(gnus)Picons' for details."
1319 :group 'gnus-article-treat
1321 :link '(custom-manual "(gnus)Customizing Articles")
1322 :link '(custom-manual "(gnus)Picons")
1323 :type gnus-article-treat-head-custom)
1324 (put 'gnus-treat-mail-picon 'highlight t)
1326 (defcustom gnus-treat-newsgroups-picon
1327 (if (and (gnus-image-type-available-p 'xpm)
1328 (gnus-picons-installed-p))
1330 "Display picons in the Newsgroups and Followup-To headers.
1331 Valid values are nil, t, `head', `last', an integer or a predicate.
1332 See Info node `(gnus)Customizing Articles' and Info node
1333 `(gnus)Picons' for details."
1335 :group 'gnus-article-treat
1337 :link '(custom-manual "(gnus)Customizing Articles")
1338 :link '(custom-manual "(gnus)Picons")
1339 :type gnus-article-treat-head-custom)
1340 (put 'gnus-treat-newsgroups-picon 'highlight t)
1342 (defcustom gnus-treat-body-boundary
1343 (if (or gnus-treat-newsgroups-picon
1344 gnus-treat-mail-picon
1345 gnus-treat-from-picon)
1347 "Draw a boundary at the end of the headers.
1348 Valid values are nil and `head'.
1349 See Info node `(gnus)Customizing Articles' for details."
1351 :group 'gnus-article-treat
1352 :link '(custom-manual "(gnus)Customizing Articles")
1353 :type gnus-article-treat-head-custom)
1355 (defcustom gnus-treat-capitalize-sentences nil
1356 "Capitalize sentence-starting words.
1357 Valid values are nil, t, `head', `last', an integer or a predicate.
1358 See Info node `(gnus)Customizing Articles' for details."
1360 :group 'gnus-article-treat
1361 :link '(custom-manual "(gnus)Customizing Articles")
1362 :type gnus-article-treat-custom)
1364 (defcustom gnus-treat-wash-html nil
1366 Valid values are nil, t, `head', `last', an integer or a predicate.
1367 See Info node `(gnus)Customizing Articles' for details."
1369 :group 'gnus-article-treat
1370 :link '(custom-manual "(gnus)Customizing Articles")
1371 :type gnus-article-treat-custom)
1373 (defcustom gnus-treat-fill-long-lines nil
1375 Valid values are nil, t, `head', `last', an integer or a predicate.
1376 See Info node `(gnus)Customizing Articles' for details."
1377 :group 'gnus-article-treat
1378 :link '(custom-manual "(gnus)Customizing Articles")
1379 :type gnus-article-treat-custom)
1381 (defcustom gnus-treat-play-sounds nil
1383 Valid values are nil, t, `head', `last', an integer or a predicate.
1384 See Info node `(gnus)Customizing Articles' for details."
1386 :group 'gnus-article-treat
1387 :link '(custom-manual "(gnus)Customizing Articles")
1388 :type gnus-article-treat-custom)
1390 (defcustom gnus-treat-translate nil
1391 "Translate articles from one language to another.
1392 Valid values are nil, t, `head', `last', an integer or a predicate.
1393 See Info node `(gnus)Customizing Articles' for details."
1395 :group 'gnus-article-treat
1396 :link '(custom-manual "(gnus)Customizing Articles")
1397 :type gnus-article-treat-custom)
1399 (defcustom gnus-treat-x-pgp-sig nil
1401 To automatically treat X-PGP-Sig, set it to head.
1402 Valid values are nil, t, `head', `last', an integer or a predicate.
1403 See Info node `(gnus)Customizing Articles' for details."
1405 :group 'gnus-article-treat
1406 :group 'mime-security
1407 :link '(custom-manual "(gnus)Customizing Articles")
1408 :type gnus-article-treat-custom)
1410 (defvar gnus-article-encrypt-protocol-alist
1411 '(("PGP" . mml2015-self-encrypt)))
1413 ;; Set to nil if more than one protocol added to
1414 ;; gnus-article-encrypt-protocol-alist.
1415 (defcustom gnus-article-encrypt-protocol "PGP"
1416 "The protocol used for encrypt articles.
1417 It is a string, such as \"PGP\". If nil, ask user."
1420 :group 'mime-security)
1422 (defvar gnus-article-wash-function nil
1423 "Function used for converting HTML into text.")
1425 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1426 (mm-coding-system-p 'utf-8)
1427 (executable-find idna-program))
1428 "Whether IDNA decoding of headers is used when viewing messages.
1429 This requires GNU Libidn, and by default only enabled if it is found."
1431 :group 'gnus-article-headers
1434 (defcustom gnus-article-over-scroll nil
1435 "If non-nil, allow scrolling the article buffer even when there no more text."
1437 :group 'gnus-article
1440 ;;; Internal variables
1442 (defvar gnus-english-month-names
1443 '("January" "February" "March" "April" "May" "June" "July" "August"
1444 "September" "October" "November" "December"))
1446 (defvar article-goto-body-goes-to-point-min-p nil)
1447 (defvar gnus-article-wash-types nil)
1448 (defvar gnus-article-emphasis-alist nil)
1449 (defvar gnus-article-image-alist nil)
1451 (defvar gnus-article-mime-handle-alist-1 nil)
1452 (defvar gnus-treatment-function-alist
1453 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1454 (gnus-treat-strip-banner gnus-article-strip-banner)
1455 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1456 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1457 (gnus-treat-buttonize gnus-article-add-buttons)
1458 (gnus-treat-fill-article gnus-article-fill-cited-article)
1459 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1460 (gnus-treat-strip-cr gnus-article-remove-cr)
1461 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1462 (gnus-treat-date-ut gnus-article-date-ut)
1463 (gnus-treat-date-local gnus-article-date-local)
1464 (gnus-treat-date-english gnus-article-date-english)
1465 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1466 (gnus-treat-date-original gnus-article-date-original)
1467 (gnus-treat-date-user-defined gnus-article-date-user)
1468 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1469 (gnus-treat-display-x-face gnus-article-display-x-face)
1470 (gnus-treat-display-face gnus-article-display-face)
1471 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1472 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1473 (gnus-treat-hide-signature gnus-article-hide-signature)
1474 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1475 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1476 (gnus-treat-strip-pem gnus-article-hide-pem)
1477 (gnus-treat-from-picon gnus-treat-from-picon)
1478 (gnus-treat-mail-picon gnus-treat-mail-picon)
1479 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1480 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1481 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1482 (gnus-treat-strip-trailing-blank-lines
1483 gnus-article-remove-trailing-blank-lines)
1484 (gnus-treat-strip-leading-blank-lines
1485 gnus-article-strip-leading-blank-lines)
1486 (gnus-treat-strip-multiple-blank-lines
1487 gnus-article-strip-multiple-blank-lines)
1488 (gnus-treat-overstrike gnus-article-treat-overstrike)
1489 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1490 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1491 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1492 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1493 (gnus-treat-display-smileys gnus-treat-smiley)
1494 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1495 (gnus-treat-wash-html gnus-article-wash-html)
1496 (gnus-treat-emphasize gnus-article-emphasize)
1497 (gnus-treat-hide-citation gnus-article-hide-citation)
1498 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1499 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1500 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1501 (gnus-treat-play-sounds gnus-earcon-display)))
1503 (defvar gnus-article-mime-handle-alist nil)
1504 (defvar article-lapsed-timer nil)
1505 (defvar gnus-article-current-summary nil)
1507 (defvar gnus-article-mode-syntax-table
1508 (let ((table (copy-syntax-table text-mode-syntax-table)))
1509 ;; This causes the citation match run O(2^n).
1510 ;; (modify-syntax-entry ?- "w" table)
1511 (modify-syntax-entry ?> ")<" table)
1512 (modify-syntax-entry ?< "(>" table)
1513 ;; make M-. in article buffers work for `foo' strings
1514 (modify-syntax-entry ?' " " table)
1515 (modify-syntax-entry ?` " " table)
1517 "Syntax table used in article mode buffers.
1518 Initialized from `text-mode-syntax-table.")
1520 (defvar gnus-save-article-buffer nil)
1522 (defvar gnus-article-mode-line-format-alist
1523 (nconc '((?w (gnus-article-wash-status) ?s)
1524 (?m (gnus-article-mime-part-status) ?s))
1525 gnus-summary-mode-line-format-alist))
1527 (defvar gnus-number-of-articles-to-be-saved nil)
1529 (defvar gnus-inhibit-hiding nil)
1531 (defvar gnus-article-edit-mode nil)
1533 ;;; Macros for dealing with the article buffer.
1535 (defmacro gnus-with-article-headers (&rest forms)
1537 (set-buffer gnus-article-buffer)
1539 (let ((inhibit-read-only t)
1540 (inhibit-point-motion-hooks t)
1541 (case-fold-search t))
1542 (article-narrow-to-head)
1545 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1546 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1548 (defmacro gnus-with-article-buffer (&rest forms)
1550 (set-buffer gnus-article-buffer)
1551 (let ((inhibit-read-only t))
1554 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1555 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1557 (defun gnus-article-goto-header (header)
1558 "Go to HEADER, which is a regular expression."
1559 (re-search-forward (concat "^\\(" header "\\):") nil t))
1561 (defsubst gnus-article-hide-text (b e props)
1562 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1563 (gnus-add-text-properties-when 'article-type nil b e props)
1564 (when (memq 'intangible props)
1566 (max (1- b) (point-min))
1567 b 'intangible (cddr (memq 'intangible props)))))
1569 (defsubst gnus-article-unhide-text (b e)
1570 "Remove hidden text properties from region between B and E."
1571 (remove-text-properties b e gnus-hidden-properties)
1572 (when (memq 'intangible gnus-hidden-properties)
1573 (put-text-property (max (1- b) (point-min))
1574 b 'intangible nil)))
1576 (defun gnus-article-hide-text-type (b e type)
1577 "Hide text of TYPE between B and E."
1578 (gnus-add-wash-type type)
1579 (gnus-article-hide-text
1580 b e (cons 'article-type (cons type gnus-hidden-properties))))
1582 (defun gnus-article-unhide-text-type (b e type)
1583 "Unhide text of TYPE between B and E."
1584 (gnus-delete-wash-type type)
1585 (remove-text-properties
1586 b e (cons 'article-type (cons type gnus-hidden-properties)))
1587 (when (memq 'intangible gnus-hidden-properties)
1588 (put-text-property (max (1- b) (point-min))
1589 b 'intangible nil)))
1591 (defun gnus-article-hide-text-of-type (type)
1592 "Hide text of TYPE in the current buffer."
1594 (let ((b (point-min))
1596 (while (setq b (text-property-any b e 'article-type type))
1597 (add-text-properties b (incf b) gnus-hidden-properties)))))
1599 (defun gnus-article-delete-text-of-type (type)
1600 "Delete text of TYPE in the current buffer."
1602 (let ((b (point-min)))
1603 (while (setq b (text-property-any b (point-max) 'article-type type))
1605 b (or (text-property-not-all b (point-max) 'article-type type)
1608 (defun gnus-article-delete-invisible-text ()
1609 "Delete all invisible text in the current buffer."
1611 (let ((b (point-min)))
1612 (while (setq b (text-property-any b (point-max) 'invisible t))
1614 b (or (text-property-not-all b (point-max) 'invisible t)
1617 (defun gnus-article-text-type-exists-p (type)
1618 "Say whether any text of type TYPE exists in the buffer."
1619 (text-property-any (point-min) (point-max) 'article-type type))
1621 (defsubst gnus-article-header-rank ()
1622 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1623 (let ((list gnus-sorted-header-list)
1626 (if (looking-at (car list))
1628 (setq list (cdr list))
1632 (defun article-hide-headers (&optional arg delete)
1633 "Hide unwanted headers and possibly sort them as well."
1635 ;; This function might be inhibited.
1636 (unless gnus-inhibit-hiding
1637 (let ((inhibit-read-only nil)
1638 (case-fold-search t)
1639 (max (1+ (length gnus-sorted-header-list)))
1640 (inhibit-point-motion-hooks t)
1641 (cur (current-buffer))
1642 ignored visible beg)
1644 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1645 ;; group parameters, so we should go to the summary buffer.
1648 (progn (set-buffer gnus-summary-buffer) t)
1650 (setq ignored (when (not gnus-visible-headers)
1651 (cond ((stringp gnus-ignored-headers)
1652 gnus-ignored-headers)
1653 ((listp gnus-ignored-headers)
1654 (mapconcat 'identity
1655 gnus-ignored-headers
1657 visible (cond ((stringp gnus-visible-headers)
1658 gnus-visible-headers)
1659 ((and gnus-visible-headers
1660 (listp gnus-visible-headers))
1661 (mapconcat 'identity
1662 gnus-visible-headers
1666 ;; First we narrow to just the headers.
1667 (article-narrow-to-head)
1668 ;; Hide any "From " lines at the beginning of (mail) articles.
1669 (while (looking-at "From ")
1672 (delete-region (point-min) (point)))
1673 ;; Then treat the rest of the header lines.
1674 ;; Then we use the two regular expressions
1675 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1676 ;; select which header lines is to remain visible in the
1678 (while (re-search-forward "^[^ \t:]*:" nil t)
1680 ;; Mark the rank of the header.
1682 (point) (1+ (point)) 'message-rank
1683 (if (or (and visible (looking-at visible))
1685 (not (looking-at ignored))))
1686 (gnus-article-header-rank)
1689 (message-sort-headers-1)
1690 (when (setq beg (text-property-any
1691 (point-min) (point-max) 'message-rank (+ 2 max)))
1692 ;; We delete the unwanted headers.
1693 (gnus-add-wash-type 'headers)
1694 (add-text-properties (point-min) (+ 5 (point-min))
1695 '(article-type headers dummy-invisible t))
1696 (delete-region beg (point-max))))))))
1698 (defun article-hide-boring-headers (&optional arg)
1699 "Toggle hiding of headers that aren't very interesting.
1700 If given a negative prefix, always show; if given a positive prefix,
1702 (interactive (gnus-article-hidden-arg))
1703 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1704 (not gnus-show-all-headers))
1707 (let ((inhibit-read-only t)
1708 (list gnus-boring-article-headers)
1709 (inhibit-point-motion-hooks t)
1711 (article-narrow-to-head)
1713 (setq elem (pop list))
1714 (goto-char (point-min))
1716 ;; Hide empty headers.
1718 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1720 (gnus-article-hide-text-type
1724 (if (re-search-forward "^[^ \t]" nil t)
1728 ;; Hide boring Newsgroups header.
1729 ((eq elem 'newsgroups)
1730 (when (gnus-string-equal
1731 (gnus-fetch-field "newsgroups")
1732 (gnus-group-real-name
1733 (if (boundp 'gnus-newsgroup-name)
1736 (gnus-article-hide-header "newsgroups")))
1737 ((eq elem 'to-address)
1738 (let ((to (message-fetch-field "to"))
1740 (gnus-parameter-to-address
1741 (if (boundp 'gnus-newsgroup-name)
1742 gnus-newsgroup-name ""))))
1743 (when (and to to-address
1746 ;; only one address in To
1747 (nth 1 (mail-extract-address-components to))
1749 (gnus-article-hide-header "to"))))
1751 (let ((to (message-fetch-field "to"))
1753 (gnus-parameter-to-list
1754 (if (boundp 'gnus-newsgroup-name)
1755 gnus-newsgroup-name ""))))
1756 (when (and to to-list
1759 ;; only one address in To
1760 (nth 1 (mail-extract-address-components to))
1762 (gnus-article-hide-header "to"))))
1764 (let ((cc (message-fetch-field "cc"))
1766 (gnus-parameter-to-list
1767 (if (boundp 'gnus-newsgroup-name)
1768 gnus-newsgroup-name ""))))
1769 (when (and cc to-list
1772 ;; only one address in CC
1773 (nth 1 (mail-extract-address-components cc))
1775 (gnus-article-hide-header "cc"))))
1776 ((eq elem 'followup-to)
1777 (when (gnus-string-equal
1778 (message-fetch-field "followup-to")
1779 (message-fetch-field "newsgroups"))
1780 (gnus-article-hide-header "followup-to")))
1781 ((eq elem 'reply-to)
1782 (if (gnus-group-find-parameter
1783 gnus-newsgroup-name 'broken-reply-to)
1784 (gnus-article-hide-header "reply-to")
1785 (let ((from (message-fetch-field "from"))
1786 (reply-to (message-fetch-field "reply-to")))
1793 (lambda (x) (downcase (cadr x)))
1794 (mail-extract-address-components from t))
1797 (lambda (x) (downcase (cadr x)))
1798 (mail-extract-address-components reply-to t))
1800 (gnus-article-hide-header "reply-to")))))
1802 (let ((date (message-fetch-field "date")))
1804 (< (days-between (current-time-string) date)
1806 (gnus-article-hide-header "date"))))
1808 (let ((to (message-fetch-field "to"))
1809 (cc (message-fetch-field "cc")))
1810 (when (> (length to) 1024)
1811 (gnus-article-hide-header "to"))
1812 (when (> (length cc) 1024)
1813 (gnus-article-hide-header "cc"))))
1817 (goto-char (point-min))
1818 (while (re-search-forward "^to:" nil t)
1819 (setq to-count (1+ to-count)))
1820 (when (> to-count 1)
1821 (while (> to-count 0)
1822 (goto-char (point-min))
1824 (re-search-forward "^to:" nil nil to-count)
1826 (narrow-to-region (point) (point-max))
1827 (gnus-article-hide-header "to"))
1828 (setq to-count (1- to-count))))
1829 (goto-char (point-min))
1830 (while (re-search-forward "^cc:" nil t)
1831 (setq cc-count (1+ cc-count)))
1832 (when (> cc-count 1)
1833 (while (> cc-count 0)
1834 (goto-char (point-min))
1836 (re-search-forward "^cc:" nil nil cc-count)
1838 (narrow-to-region (point) (point-max))
1839 (gnus-article-hide-header "cc"))
1840 (setq cc-count (1- cc-count)))))))))))))
1842 (defun gnus-article-hide-header (header)
1844 (goto-char (point-min))
1845 (when (re-search-forward (concat "^" header ":") nil t)
1846 (gnus-article-hide-text-type
1850 (if (re-search-forward "^[^ \t]" nil t)
1855 (defvar gnus-article-normalized-header-length 40
1856 "Length of normalized headers.")
1858 (defun article-normalize-headers ()
1859 "Make all header lines 40 characters long."
1861 (let ((inhibit-read-only t)
1865 (article-narrow-to-head)
1868 ((< (setq column (- (gnus-point-at-eol) (point)))
1869 gnus-article-normalized-header-length)
1871 (insert (make-string
1872 (- gnus-article-normalized-header-length column)
1874 ((> column gnus-article-normalized-header-length)
1875 (gnus-put-text-property
1877 (forward-char gnus-article-normalized-header-length)
1884 (forward-line 1))))))
1886 (defun article-treat-dumbquotes ()
1887 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1888 Note that this function guesses whether a character is a sm*rtq**t* or
1889 not, so it should only be used interactively.
1891 Sm*rtq**t*s are M****s***'s unilateral extension to the
1892 iso-8859-1 character map in an attempt to provide more quoting
1893 characters. If you see something like \\222 or \\264 where
1894 you're expecting some kind of apostrophe or quotation mark, then
1897 (article-translate-strings gnus-article-dumbquotes-map))
1899 (defun article-translate-characters (from to)
1900 "Translate all characters in the body of the article according to FROM and TO.
1901 FROM is a string of characters to translate from; to is a string of
1902 characters to translate to."
1904 (when (article-goto-body)
1905 (let ((inhibit-read-only t)
1906 (x (make-string 225 ?x))
1908 (while (< (incf i) (length x))
1911 (while (< i (length from))
1912 (aset x (aref from i) (aref to i))
1914 (translate-region (point) (point-max) x)))))
1916 (defun article-translate-strings (map)
1917 "Translate all string in the body of the article according to MAP.
1918 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1920 (when (article-goto-body)
1921 (let ((inhibit-read-only t)
1923 (while (setq elem (pop map))
1925 (while (search-forward (car elem) nil t)
1926 (replace-match (cadr elem)))))))))
1928 (defun article-treat-overstrike ()
1929 "Translate overstrikes into bold text."
1932 (when (article-goto-body)
1933 (let ((inhibit-read-only t))
1934 (while (search-forward "\b" nil t)
1935 (let ((next (char-after))
1936 (previous (char-after (- (point) 2))))
1937 ;; We do the boldification/underlining by hiding the
1938 ;; overstrikes and putting the proper text property
1942 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1943 (put-text-property (point) (1+ (point)) 'face 'bold))
1945 (gnus-article-hide-text-type
1946 (1- (point)) (1+ (point)) 'overstrike)
1948 (- (point) 2) (1- (point)) 'face 'underline))
1950 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1952 (point) (1+ (point)) 'face 'underline)))))))))
1954 (defun gnus-article-treat-unfold-headers ()
1955 "Unfold folded message headers.
1956 Only the headers that fit into the current window width will be
1959 (gnus-with-article-headers
1963 (mail-header-narrow-to-field)
1964 (let ((header (buffer-string)))
1967 (goto-char (point-min))
1968 (while (re-search-forward "\n[\t ]" nil t)
1969 (replace-match " " t t)))
1970 (setq length (- (point-max) (point-min) 1)))
1971 (when (< length (window-width))
1972 (while (re-search-forward "\n[\t ]" nil t)
1973 (replace-match " " t t)))
1974 (goto-char (point-max)))))))
1976 (defun gnus-article-treat-fold-headers ()
1977 "Fold message headers."
1979 (gnus-with-article-headers
1982 (mail-header-narrow-to-field)
1983 (mail-header-fold-field)
1984 (goto-char (point-max))))))
1986 (defun gnus-treat-smiley ()
1987 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1989 (gnus-with-article-buffer
1990 (if (memq 'smiley gnus-article-wash-types)
1991 (gnus-delete-images 'smiley)
1993 (let ((images (smiley-region (point) (point-max))))
1995 (gnus-add-wash-type 'smiley)
1996 (dolist (image images)
1997 (gnus-add-image 'smiley image)))))))
1999 (defun gnus-article-remove-images ()
2000 "Remove all images from the article buffer."
2002 (gnus-with-article-buffer
2003 (dolist (elem gnus-article-image-alist)
2004 (gnus-delete-images (car elem)))))
2006 (defun gnus-article-treat-fold-newsgroups ()
2007 "Unfold folded message headers.
2008 Only the headers that fit into the current window width will be
2011 (gnus-with-article-headers
2012 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2014 (mail-header-narrow-to-field)
2015 (while (re-search-forward ", *" nil t)
2016 (replace-match ", " t t))
2017 (mail-header-fold-field)
2018 (goto-char (point-max))))))
2020 (defun gnus-article-treat-body-boundary ()
2021 "Place a boundary line at the end of the headers."
2023 (when (and gnus-body-boundary-delimiter
2024 (> (length gnus-body-boundary-delimiter) 0))
2025 (gnus-with-article-headers
2026 (goto-char (point-max))
2027 (let ((start (point)))
2028 (insert "X-Boundary: ")
2029 (gnus-add-text-properties start (point) '(invisible t intangible t))
2031 (while (>= (1- (window-width)) (length str))
2032 (setq str (concat str gnus-body-boundary-delimiter)))
2033 (substring str 0 (1- (window-width))))
2035 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2037 (defun article-fill-long-lines ()
2038 "Fill lines that are wider than the window width."
2041 (let ((inhibit-read-only t)
2042 (width (window-width (get-buffer-window (current-buffer)))))
2045 (let ((adaptive-fill-mode nil)) ;Why? -sm
2048 (when (>= (current-column) (min fill-column width))
2049 (narrow-to-region (min (1+ (point)) (point-max))
2050 (gnus-point-at-bol))
2051 (let ((goback (point-marker)))
2052 (fill-paragraph nil)
2053 (goto-char (marker-position goback)))
2055 (forward-line 1)))))))
2057 (defun article-capitalize-sentences ()
2058 "Capitalize the first word in each sentence."
2061 (let ((inhibit-read-only t)
2062 (paragraph-start "^[\n\^L]"))
2066 (forward-sentence)))))
2068 (defun article-remove-cr ()
2069 "Remove trailing CRs and then translate remaining CRs into LFs."
2072 (let ((inhibit-read-only t))
2073 (goto-char (point-min))
2074 (while (re-search-forward "\r+$" nil t)
2075 (replace-match "" t t))
2076 (goto-char (point-min))
2077 (while (search-forward "\r" nil t)
2078 (replace-match "\n" t t)))))
2080 (defun article-remove-trailing-blank-lines ()
2081 "Remove all trailing blank lines from the article."
2084 (let ((inhibit-read-only t))
2085 (goto-char (point-max))
2089 (while (and (not (bobp))
2090 (looking-at "^[ \t]*$")
2091 (not (gnus-annotation-in-region-p
2092 (point) (gnus-point-at-eol))))
2097 (defun article-display-face ()
2098 "Display any Face headers in the header."
2100 (let ((wash-face-p buffer-read-only))
2101 (gnus-with-article-headers
2102 ;; When displaying parts, this function can be called several times on
2103 ;; the same article, without any intended toggle semantic (as typing `W
2104 ;; D d' would have). So face deletion must occur only when we come from
2105 ;; an interactive command, that is when the *Article* buffer is
2107 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2108 (gnus-delete-images 'face)
2111 (when (and wash-face-p
2113 (goto-char (point-min))
2114 (not (re-search-forward "^Face:[\t ]*" nil t)))
2115 (gnus-buffer-live-p gnus-original-article-buffer))
2116 (set-buffer gnus-original-article-buffer))
2118 (mail-narrow-to-head)
2119 (while (gnus-article-goto-header "Face")
2120 (push (mail-header-field-value) faces))))
2121 (while (setq face (pop faces))
2122 (let ((png (gnus-convert-face-to-png face))
2125 (setq image (gnus-create-image png 'png t))
2126 (gnus-article-goto-header "from")
2128 (insert "From: [no `from' set]\n")
2130 (gnus-add-wash-type 'face)
2131 (gnus-add-image 'face image)
2132 (gnus-put-image image nil 'face))))))
2135 (defun article-display-x-face (&optional force)
2136 "Look for an X-Face header and display it if present."
2137 (interactive (list 'force))
2138 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2139 (gnus-with-article-headers
2140 ;; Delete the old process, if any.
2141 (when (process-status "article-x-face")
2142 (delete-process "article-x-face"))
2143 ;; See the comment in `article-display-face'.
2144 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2145 ;; We have already displayed X-Faces, so we remove them
2147 (gnus-delete-images 'xface)
2149 (let (x-faces from face)
2151 (when (and wash-face-p
2153 (goto-char (point-min))
2154 (not (re-search-forward
2155 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2156 (gnus-buffer-live-p gnus-original-article-buffer))
2157 ;; If type `W f', use gnus-original-article-buffer,
2158 ;; otherwise use the current buffer because displaying
2159 ;; RFC822 parts calls this function too.
2160 (set-buffer gnus-original-article-buffer))
2162 (mail-narrow-to-head)
2163 (while (gnus-article-goto-header "X-Face")
2164 (push (mail-header-field-value) x-faces))
2165 (setq from (message-fetch-field "from"))))
2166 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2167 ;; single external face.
2168 (when (stringp gnus-article-x-face-command)
2169 (setq x-faces (list (car x-faces))))
2170 (while (and (setq face (pop x-faces))
2171 gnus-article-x-face-command
2173 ;; Check whether this face is censored.
2174 (not gnus-article-x-face-too-ugly)
2175 (and gnus-article-x-face-too-ugly from
2176 (not (string-match gnus-article-x-face-too-ugly
2178 ;; We display the face.
2179 (cond ((stringp gnus-article-x-face-command)
2180 ;; The command is a string, so we interpret the command
2181 ;; as a, well, command, and fork it off.
2182 (let ((process-connection-type nil))
2183 (process-kill-without-query
2185 "article-x-face" nil shell-file-name
2186 shell-command-switch gnus-article-x-face-command))
2189 (process-send-region "article-x-face"
2190 (point-min) (point-max)))
2191 (process-send-eof "article-x-face")))
2192 ((functionp gnus-article-x-face-command)
2193 ;; The command is a lisp function, so we call it.
2194 (funcall gnus-article-x-face-command face))
2196 (error "%s is not a function"
2197 gnus-article-x-face-command)))))))))
2199 (defun article-decode-mime-words ()
2200 "Decode all MIME-encoded words in the article."
2203 (set-buffer gnus-article-buffer)
2204 (let ((inhibit-point-motion-hooks t)
2205 (inhibit-read-only t)
2206 (mail-parse-charset gnus-newsgroup-charset)
2207 (mail-parse-ignored-charsets
2208 (save-excursion (set-buffer gnus-summary-buffer)
2209 gnus-newsgroup-ignored-charsets)))
2210 (mail-decode-encoded-word-region (point-min) (point-max)))))
2212 (defun article-decode-charset (&optional prompt)
2213 "Decode charset-encoded text in the article.
2214 If PROMPT (the prefix), prompt for a coding system to use."
2216 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2217 (inhibit-read-only t)
2218 (mail-parse-charset gnus-newsgroup-charset)
2219 (mail-parse-ignored-charsets
2220 (save-excursion (condition-case nil
2221 (set-buffer gnus-summary-buffer)
2223 gnus-newsgroup-ignored-charsets))
2224 ct cte ctl charset format)
2227 (article-narrow-to-head)
2228 (setq ct (message-fetch-field "Content-Type" t)
2229 cte (message-fetch-field "Content-Transfer-Encoding" t)
2230 ctl (and ct (ignore-errors
2231 (mail-header-parse-content-type ct)))
2234 (mm-read-coding-system "Charset to decode: "))
2236 (mail-content-type-get ctl 'charset)))
2237 format (and ctl (mail-content-type-get ctl 'format)))
2239 (setq cte (mail-header-strip cte)))
2240 (if (and ctl (not (string-match "/" (car ctl))))
2242 (goto-char (point-max)))
2245 (narrow-to-region (point) (point-max))
2246 (when (and (eq mail-parse-charset 'gnus-decoded)
2247 (eq (mm-body-7-or-8) '8bit))
2248 ;; The text code could have been decoded.
2249 (setq charset mail-parse-charset))
2250 (when (and (or (not ctl)
2251 (equal (car ctl) "text/plain"))
2252 (not format)) ;; article with format will decode later.
2254 charset (and cte (intern (downcase
2255 (gnus-strip-whitespace cte))))
2258 (defun article-decode-encoded-words ()
2259 "Remove encoded-word encoding from headers."
2260 (let ((inhibit-point-motion-hooks t)
2261 (mail-parse-charset gnus-newsgroup-charset)
2262 (mail-parse-ignored-charsets
2263 (save-excursion (condition-case nil
2264 (set-buffer gnus-summary-buffer)
2266 gnus-newsgroup-ignored-charsets))
2267 (inhibit-read-only t))
2269 (article-narrow-to-head)
2270 (funcall gnus-decode-header-function (point-min) (point-max)))))
2272 (defun article-decode-group-name ()
2273 "Decode group names in `Newsgroups:'."
2274 (let ((inhibit-point-motion-hooks t)
2275 (inhibit-read-only t)
2276 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2277 (when (and (or gnus-group-name-charset-method-alist
2278 gnus-group-name-charset-group-alist)
2279 (gnus-buffer-live-p gnus-original-article-buffer))
2281 (article-narrow-to-head)
2282 (with-current-buffer gnus-original-article-buffer
2283 (goto-char (point-min)))
2284 (while (re-search-forward
2285 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2286 (replace-match (save-match-data
2287 (gnus-decode-newsgroups
2288 ;; XXX how to use data in article buffer?
2289 (with-current-buffer gnus-original-article-buffer
2291 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2294 gnus-newsgroup-name method))
2296 (goto-char (point-min))
2297 (with-current-buffer gnus-original-article-buffer
2298 (goto-char (point-min)))
2299 (while (re-search-forward
2300 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2301 (replace-match (save-match-data
2302 (gnus-decode-newsgroups
2303 ;; XXX how to use data in article buffer?
2304 (with-current-buffer gnus-original-article-buffer
2306 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2309 gnus-newsgroup-name method))
2312 (autoload 'idna-to-unicode "idna")
2314 (defun article-decode-idna-rhs ()
2315 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2318 (let ((inhibit-point-motion-hooks t)
2319 (inhibit-read-only t))
2320 (article-narrow-to-head)
2321 (goto-char (point-min))
2322 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2324 (when (save-match-data
2325 (and (setq ace (match-string 1))
2327 (and (re-search-backward "^[^ \t]" nil t)
2328 (looking-at "From\\|To\\|Cc")))
2329 (setq unicode (idna-to-unicode ace))))
2330 (unless (string= ace unicode)
2331 (replace-match unicode nil nil nil 1)))))))))
2333 (defun article-de-quoted-unreadable (&optional force read-charset)
2334 "Translate a quoted-printable-encoded article.
2335 If FORCE, decode the article whether it is marked as quoted-printable
2337 If READ-CHARSET, ask for a coding system."
2338 (interactive (list 'force current-prefix-arg))
2340 (let ((inhibit-read-only t) type charset)
2341 (if (gnus-buffer-live-p gnus-original-article-buffer)
2342 (with-current-buffer gnus-original-article-buffer
2344 (gnus-fetch-field "content-transfer-encoding"))
2345 (let* ((ct (gnus-fetch-field "content-type"))
2348 (mail-header-parse-content-type ct)))))
2349 (setq charset (and ctl
2350 (mail-content-type-get ctl 'charset)))
2351 (if (stringp charset)
2352 (setq charset (intern (downcase charset)))))))
2354 (setq charset (mm-read-coding-system "Charset: " charset)))
2356 (setq charset gnus-newsgroup-charset))
2358 (and type (let ((case-fold-search t))
2359 (string-match "quoted-printable" type))))
2361 (quoted-printable-decode-region
2362 (point) (point-max) (mm-charset-to-coding-system charset))))))
2364 (defun article-de-base64-unreadable (&optional force read-charset)
2365 "Translate a base64 article.
2366 If FORCE, decode the article whether it is marked as base64 not.
2367 If READ-CHARSET, ask for a coding system."
2368 (interactive (list 'force current-prefix-arg))
2370 (let ((inhibit-read-only t) type charset)
2371 (if (gnus-buffer-live-p gnus-original-article-buffer)
2372 (with-current-buffer gnus-original-article-buffer
2374 (gnus-fetch-field "content-transfer-encoding"))
2375 (let* ((ct (gnus-fetch-field "content-type"))
2378 (mail-header-parse-content-type ct)))))
2379 (setq charset (and ctl
2380 (mail-content-type-get ctl 'charset)))
2381 (if (stringp charset)
2382 (setq charset (intern (downcase charset)))))))
2384 (setq charset (mm-read-coding-system "Charset: " charset)))
2386 (setq charset gnus-newsgroup-charset))
2388 (and type (let ((case-fold-search t))
2389 (string-match "base64" type))))
2392 (narrow-to-region (point) (point-max))
2393 (base64-decode-region (point-min) (point-max))
2394 (mm-decode-coding-region
2395 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2400 (defun article-decode-HZ ()
2401 "Translate a HZ-encoded article."
2405 (let ((inhibit-read-only t))
2406 (rfc1843-decode-region (point-min) (point-max)))))
2408 (defun article-unsplit-urls ()
2409 "Remove the newlines that some other mailers insert into URLs."
2412 (let ((inhibit-read-only t))
2413 (goto-char (point-min))
2414 (while (re-search-forward
2415 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2416 (replace-match "\\1\\3" t)))
2417 (when (interactive-p)
2418 (gnus-treat-article nil))))
2421 (defun article-wash-html (&optional read-charset)
2422 "Format an HTML article.
2423 If READ-CHARSET, ask for a coding system."
2426 (let ((inhibit-read-only t)
2428 (when (gnus-buffer-live-p gnus-original-article-buffer)
2429 (with-current-buffer gnus-original-article-buffer
2430 (let* ((ct (gnus-fetch-field "content-type"))
2433 (mail-header-parse-content-type ct)))))
2434 (setq charset (and ctl
2435 (mail-content-type-get ctl 'charset)))
2436 (when (stringp charset)
2437 (setq charset (intern (downcase charset)))))))
2439 (setq charset (mm-read-coding-system "Charset: " charset)))
2441 (setq charset gnus-newsgroup-charset))
2443 (save-window-excursion
2445 (narrow-to-region (point) (point-max))
2446 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2447 (entry (assq func mm-text-html-washer-alist)))
2449 (setq func (cdr entry)))
2454 (apply (car func) (cdr func))))))))))
2456 (defun gnus-article-wash-html-with-w3 ()
2457 "Wash the current buffer with w3."
2459 (let ((w3-strict-width (window-width))
2460 (url-standalone-mode t)
2461 (url-gateway-unplugged t)
2462 (w3-honor-stylesheets nil))
2464 (w3-region (point-min) (point-max))
2467 (defun gnus-article-wash-html-with-w3m ()
2468 "Wash the current buffer with emacs-w3m."
2471 (narrow-to-region (point) (point-max))
2472 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2473 w3m-force-redisplay)
2474 (w3m-region (point-min) (point-max)))
2475 (when (and mm-inline-text-html-with-w3m-keymap
2476 (boundp 'w3m-minor-mode-map)
2478 (add-text-properties
2479 (point-min) (point-max)
2480 (list 'keymap w3m-minor-mode-map
2481 ;; Put the mark meaning this part was rendered by emacs-w3m.
2482 'mm-inline-text-html-with-w3m t)))))
2484 (defun article-hide-list-identifiers ()
2485 "Remove list identifies from the Subject header.
2486 The `gnus-list-identifiers' variable specifies what to do."
2488 (let ((inhibit-point-motion-hooks t)
2489 (regexp (if (consp gnus-list-identifiers)
2490 (mapconcat 'identity gnus-list-identifiers " *\\|")
2491 gnus-list-identifiers))
2492 (inhibit-read-only t))
2496 (article-narrow-to-head)
2497 (goto-char (point-min))
2498 (while (re-search-forward
2499 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2501 (delete-region (match-beginning 2) (match-end 0))
2502 (beginning-of-line))
2503 (when (re-search-forward
2504 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2505 (delete-region (match-beginning 1) (match-end 1))))))))
2507 (defun article-hide-pem (&optional arg)
2508 "Toggle hiding of any PEM headers and signatures in the current article.
2509 If given a negative prefix, always show; if given a positive prefix,
2511 (interactive (gnus-article-hidden-arg))
2512 (unless (gnus-article-check-hidden-text 'pem arg)
2514 (let ((inhibit-read-only t) end)
2515 (goto-char (point-min))
2516 ;; Hide the horrendously ugly "header".
2517 (when (and (search-forward
2518 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2520 (setq end (1+ (match-beginning 0))))
2521 (gnus-add-wash-type 'pem)
2522 (gnus-article-hide-text-type
2524 (if (search-forward "\n\n" nil t)
2528 ;; Hide the trailer as well
2529 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2531 (gnus-article-hide-text-type
2532 (match-beginning 0) (match-end 0) 'pem)))))))
2534 (defun article-strip-banner ()
2535 "Strip the banners specified by the `banner' group parameter and by
2536 `gnus-article-address-banner-alist'."
2540 (let ((inhibit-point-motion-hooks t))
2541 (when (gnus-parameter-banner gnus-newsgroup-name)
2542 (article-really-strip-banner
2543 (gnus-parameter-banner gnus-newsgroup-name)))
2544 (when gnus-article-address-banner-alist
2545 (article-really-strip-banner
2546 (let ((from (save-restriction
2548 (article-narrow-to-head)
2549 (mail-fetch-field "from"))))
2552 (caar (mail-header-parse-addresses from))))
2554 (dolist (pair gnus-article-address-banner-alist)
2555 (when (string-match (car pair) from)
2556 (throw 'found (cdr pair)))))))))))))
2558 (defun article-really-strip-banner (banner)
2559 "Strip the banner specified by the argument."
2562 (let ((inhibit-point-motion-hooks t)
2563 (gnus-signature-limit nil)
2564 (inhibit-read-only t))
2567 ((eq banner 'signature)
2568 (when (gnus-article-narrow-to-signature)
2571 (delete-region (point) (point-max))))
2573 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2574 (while (re-search-forward banner nil t)
2575 (delete-region (match-beginning 0) (match-end 0)))))
2577 (while (re-search-forward banner nil t)
2578 (delete-region (match-beginning 0) (match-end 0)))))))))
2580 (defun article-babel ()
2581 "Translate article using an online translation service."
2585 (set-buffer gnus-article-buffer)
2586 (when (article-goto-body)
2587 (let* ((inhibit-read-only t)
2590 (orig (buffer-substring start end))
2591 (trans (babel-as-string orig)))
2593 (narrow-to-region start end)
2594 (delete-region start end)
2597 (defun article-hide-signature (&optional arg)
2598 "Hide the signature in the current article.
2599 If given a negative prefix, always show; if given a positive prefix,
2601 (interactive (gnus-article-hidden-arg))
2602 (unless (gnus-article-check-hidden-text 'signature arg)
2605 (let ((inhibit-read-only t))
2606 (when (gnus-article-narrow-to-signature)
2607 (gnus-article-hide-text-type
2608 (point-min) (point-max) 'signature))))))
2609 (gnus-set-mode-line 'article))
2611 (defun article-strip-headers-in-body ()
2612 "Strip offensive headers from bodies."
2616 (let ((case-fold-search t))
2617 (when (looking-at "x-no-archive:")
2618 (gnus-delete-line)))))
2620 (defun article-strip-leading-blank-lines ()
2621 "Remove all blank lines from the beginning of the article."
2624 (let ((inhibit-point-motion-hooks t)
2625 (inhibit-read-only t))
2626 (when (article-goto-body)
2627 (while (and (not (eobp))
2628 (looking-at "[ \t]*$"))
2629 (gnus-delete-line))))))
2631 (defun article-narrow-to-head ()
2632 "Narrow the buffer to the head of the message.
2633 Point is left at the beginning of the narrowed-to region."
2635 (goto-char (point-min))
2636 (if (search-forward "\n\n" nil 1)
2639 (goto-char (point-min)))
2641 (defun article-goto-body ()
2642 "Place point at the start of the body."
2643 (goto-char (point-min))
2645 ;; This variable is only bound when dealing with separate
2647 (article-goto-body-goes-to-point-min-p
2649 ((search-forward "\n\n" nil t)
2652 (goto-char (point-max))
2655 (defun article-strip-multiple-blank-lines ()
2656 "Replace consecutive blank lines with one empty line."
2659 (let ((inhibit-point-motion-hooks t)
2660 (inhibit-read-only t))
2661 ;; First make all blank lines empty.
2663 (while (re-search-forward "^[ \t]+$" nil t)
2664 (unless (gnus-annotation-in-region-p
2665 (match-beginning 0) (match-end 0))
2666 (replace-match "" nil t)))
2667 ;; Then replace multiple empty lines with a single empty line.
2669 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2670 (unless (gnus-annotation-in-region-p
2671 (match-beginning 0) (match-end 0))
2672 (delete-region (match-beginning 1) (match-end 1)))))))
2674 (defun article-strip-leading-space ()
2675 "Remove all white space from the beginning of the lines in the article."
2678 (let ((inhibit-point-motion-hooks t)
2679 (inhibit-read-only t))
2681 (while (re-search-forward "^[ \t]+" nil t)
2682 (replace-match "" t t)))))
2684 (defun article-strip-trailing-space ()
2685 "Remove all white space from the end of the lines in the article."
2688 (let ((inhibit-point-motion-hooks t)
2689 (inhibit-read-only t))
2691 (while (re-search-forward "[ \t]+$" nil t)
2692 (replace-match "" t t)))))
2694 (defun article-strip-blank-lines ()
2695 "Strip leading, trailing and multiple blank lines."
2697 (article-strip-leading-blank-lines)
2698 (article-remove-trailing-blank-lines)
2699 (article-strip-multiple-blank-lines))
2701 (defun article-strip-all-blank-lines ()
2702 "Strip all blank lines."
2705 (let ((inhibit-point-motion-hooks t)
2706 (inhibit-read-only t))
2708 (while (re-search-forward "^[ \t]*\n" nil t)
2709 (replace-match "" t t)))))
2711 (defun gnus-article-narrow-to-signature ()
2712 "Narrow to the signature; return t if a signature is found, else nil."
2713 (let ((inhibit-point-motion-hooks t))
2714 (when (gnus-article-search-signature)
2716 ;; Check whether we have some limits to what we consider
2717 ;; to be a signature.
2718 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2719 (list gnus-signature-limit)))
2721 (while (setq limit (pop limits))
2722 (if (or (and (integerp limit)
2723 (< (- (point-max) (point)) limit))
2725 (< (count-lines (point) (point-max)) limit))
2726 (and (functionp limit)
2728 (and (stringp limit)
2729 (not (re-search-forward limit nil t))))
2730 () ; This limit did not succeed.
2734 (narrow-to-region (point) (point-max))
2737 (defun gnus-article-search-signature ()
2738 "Search the current buffer for the signature separator.
2739 Put point at the beginning of the signature separator."
2740 (let ((cur (point)))
2741 (goto-char (point-max))
2742 (if (if (stringp gnus-signature-separator)
2743 (re-search-backward gnus-signature-separator nil t)
2744 (let ((seps gnus-signature-separator))
2746 (not (re-search-backward (car seps) nil t)))
2753 (defun gnus-article-hidden-arg ()
2754 "Return the current prefix arg as a number, or 0 if no prefix."
2755 (list (if current-prefix-arg
2756 (prefix-numeric-value current-prefix-arg)
2759 (defun gnus-article-check-hidden-text (type arg)
2760 "Return nil if hiding is necessary.
2761 Arg can be nil or a number. nil and positive means hide, negative
2762 means show, 0 means toggle."
2765 (let ((hide (gnus-article-hidden-text-p type)))
2771 (gnus-article-show-hidden-text type)
2774 (if (eq hide 'hidden)
2776 (gnus-article-show-hidden-text type)
2780 (defun gnus-article-hidden-text-p (type)
2781 "Say whether the current buffer contains hidden text of type TYPE."
2782 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2784 (not (get-text-property pos 'invisible))
2785 (not (get-text-property pos 'dummy-invisible)))
2787 (text-property-any (1+ pos) (point-max) 'article-type type)))
2792 (defun gnus-article-show-hidden-text (type &optional dummy)
2793 "Show all hidden text of type TYPE.
2794 Originally it is hide instead of DUMMY."
2795 (let ((inhibit-read-only t)
2796 (inhibit-point-motion-hooks t))
2797 (gnus-remove-text-properties-when
2799 (point-min) (point-max)
2800 (cons 'article-type (cons type
2801 gnus-hidden-properties)))
2802 (gnus-delete-wash-type type)))
2804 (defconst article-time-units
2805 `((year . ,(* 365.25 24 60 60))
2806 (week . ,(* 7 24 60 60))
2807 (day . ,(* 24 60 60))
2811 "Mapping from time units to seconds.")
2813 (defun gnus-article-forward-header ()
2814 "Move point to the start of the next header.
2815 If the current header is a continuation header, this can be several
2820 (if (looking-at "[ \t]+[^ \t]")
2824 (defun article-date-ut (&optional type highlight)
2825 "Convert DATE date to universal time in the current article.
2826 If TYPE is `local', convert to local time; if it is `lapsed', output
2827 how much time has lapsed since DATE. For `lapsed', the value of
2828 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2829 should replace the \"Date:\" one, or should be added below it."
2830 (interactive (list 'ut t))
2831 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2832 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
2836 (article-lapsed-timer
2840 (case-fold-search t)
2841 (inhibit-read-only t)
2842 (inhibit-point-motion-hooks t)
2843 pos date bface eface)
2847 (goto-char (point-min))
2848 (while (or (setq date (get-text-property (setq pos (point))
2850 (when (setq pos (next-single-property-change
2851 (point) 'original-date))
2852 (setq date (get-text-property pos 'original-date))
2854 (narrow-to-region pos (or (text-property-any pos (point-max)
2857 (goto-char (point-min))
2858 (when (re-search-forward tdate-regexp nil t)
2859 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2860 eface (get-text-property (1- (gnus-point-at-eol)) 'face)))
2861 (goto-char (point-min))
2863 ;; Delete any old Date headers.
2864 (while (re-search-forward date-regexp nil t)
2866 (delete-region (gnus-point-at-bol)
2868 (gnus-article-forward-header)
2870 (delete-region (gnus-point-at-bol)
2872 (gnus-article-forward-header)
2875 (setq pos (point))))
2876 (when (and (not pos)
2877 (re-search-forward tdate-regexp nil t))
2879 (gnus-goto-char pos)
2880 (insert (article-make-date-line date (or type 'ut)))
2886 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2887 (put-text-property (match-beginning 1) (1+ (match-end 1))
2889 (put-text-property (match-beginning 2) (match-end 2)
2891 (put-text-property (point-min) (1- (point-max)) 'original-date date)
2892 (goto-char (point-max))
2895 (defun article-make-date-line (date type)
2896 "Return a DATE line of TYPE."
2897 (unless (memq type '(local ut original user iso8601 lapsed english))
2898 (error "Unknown conversion type: %s" type))
2900 (let ((time (date-to-time date)))
2902 ;; Convert to the local timezone.
2904 (let ((tz (car (current-time-zone time))))
2905 (format "Date: %s %s%02d%02d" (current-time-string time)
2906 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2907 (/ (% (abs tz) 3600) 60))))
2908 ;; Convert to Universal Time.
2911 (current-time-string
2912 (let* ((e (parse-time-string date))
2913 (tm (apply 'encode-time e))
2915 (ls (- (cadr tm) (car (current-time-zone time)))))
2916 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2917 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2920 ;; Get the original date from the article.
2921 ((eq type 'original)
2922 (concat "Date: " (if (string-match "\n+$" date)
2923 (substring date 0 (match-beginning 0))
2925 ;; Let the user define the format.
2927 (let ((format (or (condition-case nil
2928 (with-current-buffer gnus-summary-buffer
2929 gnus-article-time-format)
2931 gnus-article-time-format)))
2932 (if (functionp format)
2933 (funcall format time)
2934 (concat "Date: " (format-time-string format time)))))
2937 (let ((tz (car (current-time-zone time))))
2940 (format-time-string "%Y%m%dT%H%M%S" time)
2941 (format "%s%02d%02d"
2942 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2943 (/ (% (abs tz) 3600) 60)))))
2944 ;; Do an X-Sent lapsed format.
2946 ;; If the date is seriously mangled, the timezone functions are
2947 ;; liable to bug out, so we ignore all errors.
2948 (let* ((now (current-time))
2949 (real-time (subtract-time now time))
2950 (real-sec (and real-time
2951 (+ (* (float (car real-time)) 65536)
2953 (sec (and real-time (abs real-sec)))
2963 ;; This is a bit convoluted, but basically we go
2964 ;; through the time units for years, weeks, etc,
2965 ;; and divide things to see whether that results
2966 ;; in positive answers.
2969 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2970 ;; The (remaining) seconds are too few to
2971 ;; be divided into this time unit.
2973 ;; It's big enough, so we output it.
2974 (setq sec (- sec (* num (cdr unit))))
2976 (concat (if prev ", " "") (int-to-string
2978 " " (symbol-name (car unit))
2979 (if (> num 1) "s" ""))
2981 article-time-units "")
2982 ;; If dates are odd, then it might appear like the
2983 ;; article was sent in the future.
2986 " in the future"))))))
2987 ;; Display the date in proper English
2989 (let ((dtime (decode-time time)))
2992 (number-to-string (nth 3 dtime))
2993 (let ((digit (% (nth 3 dtime) 10)))
2995 ((memq (nth 3 dtime) '(11 12 13)) "th")
3001 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3003 (number-to-string (nth 5 dtime))
3005 (format "%02d" (nth 2 dtime))
3007 (format "%02d" (nth 1 dtime)))))))
3009 (format "Date: %s (from Gnus)" date))))
3011 (defun article-date-local (&optional highlight)
3012 "Convert the current article date to the local timezone."
3013 (interactive (list t))
3014 (article-date-ut 'local highlight))
3016 (defun article-date-english (&optional highlight)
3017 "Convert the current article date to something that is proper English."
3018 (interactive (list t))
3019 (article-date-ut 'english highlight))
3021 (defun article-date-original (&optional highlight)
3022 "Convert the current article date to what it was originally.
3023 This is only useful if you have used some other date conversion
3024 function and want to see what the date was before converting."
3025 (interactive (list t))
3026 (article-date-ut 'original highlight))
3028 (defun article-date-lapsed (&optional highlight)
3029 "Convert the current article date to time lapsed since it was sent."
3030 (interactive (list t))
3031 (article-date-ut 'lapsed highlight))
3033 (defun article-update-date-lapsed ()
3034 "Function to be run from a timer to update the lapsed time line."
3035 (let (deactivate-mark)
3040 (set-buffer (window-buffer w))
3041 (when (eq major-mode 'gnus-article-mode)
3042 (let ((mark (point-marker)))
3043 (goto-char (point-min))
3044 (when (re-search-forward "^X-Sent:" nil t)
3045 (article-date-lapsed t))
3046 (goto-char (marker-position mark))
3047 (move-marker mark nil))))
3050 (defun gnus-start-date-timer (&optional n)
3051 "Start a timer to update the X-Sent header in the article buffers.
3052 The numerical prefix says how frequently (in seconds) the function
3057 (gnus-stop-date-timer)
3058 (setq article-lapsed-timer
3059 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
3061 (defun gnus-stop-date-timer ()
3062 "Stop the X-Sent timer."
3064 (when article-lapsed-timer
3065 (nnheader-cancel-timer article-lapsed-timer)
3066 (setq article-lapsed-timer nil)))
3068 (defun article-date-user (&optional highlight)
3069 "Convert the current article date to the user-defined format.
3070 This format is defined by the `gnus-article-time-format' variable."
3071 (interactive (list t))
3072 (article-date-ut 'user highlight))
3074 (defun article-date-iso8601 (&optional highlight)
3075 "Convert the current article date to ISO8601."
3076 (interactive (list t))
3077 (article-date-ut 'iso8601 highlight))
3079 (defmacro gnus-article-save-original-date (&rest forms)
3080 "Save the original date as a text property and evaluate FORMS."
3081 `(let* ((case-fold-search t)
3083 (goto-char (point-min))
3084 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3087 (date (when (and start
3088 (re-search-forward "[\t ]*\n\\([^\t ]\\|\\'\\)"
3090 (buffer-substring-no-properties start
3091 (match-beginning 0)))))
3092 (goto-char (point-max))
3093 (skip-chars-backward "\n")
3094 (put-text-property (point-min) (point) 'original-date date)
3096 (goto-char (point-max))
3097 (skip-chars-backward "\n")
3098 (put-text-property (point-min) (point) 'original-date date)))
3100 ;; (defun article-show-all ()
3101 ;; "Show all hidden text in the article buffer."
3104 ;; (let ((inhibit-read-only t))
3105 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3107 (defun article-remove-leading-whitespace ()
3108 "Remove excessive whitespace from all headers."
3112 (let ((inhibit-read-only t))
3113 (article-narrow-to-head)
3114 (goto-char (point-min))
3115 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3116 (delete-region (match-beginning 1) (match-end 1)))))))
3118 (defun article-emphasize (&optional arg)
3119 "Emphasize text according to `gnus-emphasis-alist'."
3120 (interactive (gnus-article-hidden-arg))
3121 (unless (gnus-article-check-hidden-text 'emphasis arg)
3125 (with-current-buffer gnus-summary-buffer
3126 gnus-article-emphasis-alist)
3128 gnus-emphasis-alist))
3129 (inhibit-read-only t)
3130 (props (append '(article-type emphasis)
3131 gnus-hidden-properties))
3132 regexp elem beg invisible visible face)
3135 (while (setq elem (pop alist))
3137 (setq regexp (car elem)
3138 invisible (nth 1 elem)
3139 visible (nth 2 elem)
3141 (while (re-search-forward regexp nil t)
3142 (when (and (match-beginning visible) (match-beginning invisible))
3143 (gnus-article-hide-text
3144 (match-beginning invisible) (match-end invisible) props)
3145 (gnus-article-unhide-text-type
3146 (match-beginning visible) (match-end visible) 'emphasis)
3147 (gnus-put-overlay-excluding-newlines
3148 (match-beginning visible) (match-end visible) 'face face)
3149 (gnus-add-wash-type 'emphasis)
3150 (goto-char (match-end invisible)))))))))
3152 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3153 "Setup newsgroup emphasis alist."
3154 (unless gnus-article-emphasis-alist
3155 (let ((name (and gnus-newsgroup-name
3156 (gnus-group-real-name gnus-newsgroup-name))))
3157 (make-local-variable 'gnus-article-emphasis-alist)
3158 (setq gnus-article-emphasis-alist
3160 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3161 (while (setq elem (pop alist))
3162 (when (and name (string-match (car elem) name))
3164 highlight (copy-sequence (cdr elem)))))
3166 (copy-sequence highlight-words)
3167 (if gnus-newsgroup-name
3168 (copy-sequence (gnus-group-find-parameter
3169 gnus-newsgroup-name 'highlight-words t)))
3170 gnus-emphasis-alist)))))
3173 (defvar gnus-summary-article-menu)
3174 (defvar gnus-summary-post-menu))
3176 ;;; Saving functions.
3178 (defun gnus-article-save (save-buffer file &optional num)
3179 "Save the currently selected article."
3180 (unless gnus-save-all-headers
3181 ;; Remove headers according to `gnus-saved-headers'.
3182 (let ((gnus-visible-headers
3183 (or gnus-saved-headers gnus-visible-headers))
3184 (gnus-article-buffer save-buffer))
3186 (set-buffer save-buffer)
3187 (article-hide-headers 1 t))))
3188 (save-window-excursion
3189 (if (not gnus-default-article-saver)
3190 (error "No default saver is defined")
3191 ;; !!! Magic! The saving functions all save
3192 ;; `gnus-save-article-buffer' (or so they think), but we
3193 ;; bind that variable to our save-buffer.
3194 (set-buffer gnus-article-buffer)
3195 (let* ((gnus-save-article-buffer save-buffer)
3198 ((not gnus-prompt-before-saving) 'default)
3199 ((eq gnus-prompt-before-saving 'always) nil)
3201 (gnus-number-of-articles-to-be-saved
3202 (when (eq gnus-prompt-before-saving t)
3204 (set-buffer gnus-article-current-summary)
3205 (funcall gnus-default-article-saver filename)))))
3207 (defun gnus-read-save-file-name (prompt &optional filename
3208 function group headers variable)
3210 (funcall function group headers (symbol-value variable)))
3215 ((eq filename 'default)
3221 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3224 (if (and gnus-number-of-articles-to-be-saved
3225 (> gnus-number-of-articles-to-be-saved 1))
3226 (format "these %d articles"
3227 gnus-number-of-articles-to-be-saved)
3230 ;; Let the split methods have their say.
3232 ;; No split name was found.
3235 (concat prompt " (default "
3236 (file-name-nondirectory default-name) ") ")
3237 (file-name-directory default-name)
3239 ;; A single group name is returned.
3240 ((stringp split-name)
3242 (funcall function split-name headers
3243 (symbol-value variable)))
3245 (concat prompt " (default "
3246 (file-name-nondirectory default-name) ") ")
3247 (file-name-directory default-name)
3249 ;; A single split name was found
3250 ((= 1 (length split-name))
3251 (let* ((name (expand-file-name
3253 gnus-article-save-directory))
3254 (dir (cond ((file-directory-p name)
3255 (file-name-as-directory name))
3256 ((file-exists-p name) name)
3257 (t gnus-article-save-directory))))
3259 (concat prompt " (default " name ") ")
3261 ;; A list of splits was found.
3263 (setq split-name (nreverse split-name))
3265 (let ((file-name-history
3266 (nconc split-name file-name-history)))
3270 (concat prompt " (`M-p' for defaults) ")
3271 gnus-article-save-directory
3273 gnus-article-save-directory)))
3274 (car (push result file-name-history)))))))
3275 ;; Create the directory.
3276 (gnus-make-directory (file-name-directory file))
3277 ;; If we have read a directory, we append the default file name.
3278 (when (file-directory-p file)
3279 (setq file (expand-file-name (file-name-nondirectory
3281 (file-name-as-directory file))))
3282 ;; Possibly translate some characters.
3283 (nnheader-translate-file-chars file))))))
3284 (gnus-make-directory (file-name-directory result))
3285 (set variable result)))
3287 (defun gnus-article-archive-name (group)
3288 "Return the first instance of an \"Archive-name\" in the current buffer."
3289 (let ((case-fold-search t))
3290 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3291 (nnheader-concat gnus-article-save-directory
3292 (match-string 1)))))
3294 (defun gnus-article-nndoc-name (group)
3295 "If GROUP is an nndoc group, return the name of the parent group."
3296 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3297 (gnus-group-get-parameter group 'save-article-group)))
3299 (defun gnus-summary-save-in-rmail (&optional filename)
3300 "Append this article to Rmail file.
3301 Optional argument FILENAME specifies file name.
3302 Directory to save to is default to `gnus-article-save-directory'."
3303 (setq filename (gnus-read-save-file-name
3304 "Save %s in rmail file:" filename
3305 gnus-rmail-save-name gnus-newsgroup-name
3306 gnus-current-headers 'gnus-newsgroup-last-rmail))
3307 (gnus-eval-in-buffer-window gnus-save-article-buffer
3311 (gnus-output-to-rmail filename))))
3314 (defun gnus-summary-save-in-mail (&optional filename)
3315 "Append this article to Unix mail file.
3316 Optional argument FILENAME specifies file name.
3317 Directory to save to is default to `gnus-article-save-directory'."
3318 (setq filename (gnus-read-save-file-name
3319 "Save %s in Unix mail file:" filename
3320 gnus-mail-save-name gnus-newsgroup-name
3321 gnus-current-headers 'gnus-newsgroup-last-mail))
3322 (gnus-eval-in-buffer-window gnus-save-article-buffer
3326 (if (and (file-readable-p filename)
3327 (file-regular-p filename)
3328 (mail-file-babyl-p filename))
3329 (rmail-output-to-rmail-file filename t)
3330 (gnus-output-to-mail filename)))))
3333 (defun gnus-summary-save-in-file (&optional filename overwrite)
3334 "Append this article to file.
3335 Optional argument FILENAME specifies file name.
3336 Directory to save to is default to `gnus-article-save-directory'."
3337 (setq filename (gnus-read-save-file-name
3338 "Save %s in file:" filename
3339 gnus-file-save-name gnus-newsgroup-name
3340 gnus-current-headers 'gnus-newsgroup-last-file))
3341 (gnus-eval-in-buffer-window gnus-save-article-buffer
3345 (when (and overwrite
3346 (file-exists-p filename))
3347 (delete-file filename))
3348 (gnus-output-to-file filename))))
3351 (defun gnus-summary-write-to-file (&optional filename)
3352 "Write this article to a file, overwriting it if the file exists.
3353 Optional argument FILENAME specifies file name.
3354 The directory to save in defaults to `gnus-article-save-directory'."
3355 (gnus-summary-save-in-file nil t))
3357 (defun gnus-summary-save-body-in-file (&optional filename)
3358 "Append this article body to a file.
3359 Optional argument FILENAME specifies file name.
3360 The directory to save in defaults to `gnus-article-save-directory'."
3361 (setq filename (gnus-read-save-file-name
3362 "Save %s body in file:" filename
3363 gnus-file-save-name gnus-newsgroup-name
3364 gnus-current-headers 'gnus-newsgroup-last-file))
3365 (gnus-eval-in-buffer-window gnus-save-article-buffer
3369 (when (article-goto-body)
3370 (narrow-to-region (point) (point-max)))
3371 (gnus-output-to-file filename))))
3374 (defun gnus-summary-save-in-pipe (&optional command)
3375 "Pipe this article to subprocess."
3377 (cond ((and (eq command 'default)
3378 gnus-last-shell-command)
3379 gnus-last-shell-command)
3384 "Shell command on %s: "
3385 (if (and gnus-number-of-articles-to-be-saved
3386 (> gnus-number-of-articles-to-be-saved 1))
3387 (format "these %d articles"
3388 gnus-number-of-articles-to-be-saved)
3390 gnus-last-shell-command))))
3391 (when (string-equal command "")
3392 (if gnus-last-shell-command
3393 (setq command gnus-last-shell-command)
3394 (error "A command is required")))
3395 (gnus-eval-in-buffer-window gnus-article-buffer
3398 (shell-command-on-region (point-min) (point-max) command nil)))
3399 (setq gnus-last-shell-command command))
3401 (defmacro gnus-read-string (prompt &optional initial-contents history
3403 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3404 (if (and (featurep 'xemacs)
3405 (< emacs-minor-version 2))
3406 `(read-string ,prompt ,initial-contents ,history)
3407 `(read-string ,prompt ,initial-contents ,history ,default-value)))
3409 (defun gnus-summary-pipe-to-muttprint (&optional command)
3410 "Pipe this article to muttprint."
3411 (setq command (gnus-read-string
3412 "Print using command: " gnus-summary-muttprint-program
3413 nil gnus-summary-muttprint-program))
3414 (gnus-summary-save-in-pipe command))
3416 ;;; Article file names when saving.
3418 (defun gnus-capitalize-newsgroup (newsgroup)
3419 "Capitalize NEWSGROUP name."
3420 (when (not (zerop (length newsgroup)))
3421 (concat (char-to-string (upcase (aref newsgroup 0)))
3422 (substring newsgroup 1))))
3424 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3425 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3426 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3427 Otherwise, it is like ~/News/news/group/num."
3430 (concat (if (gnus-use-long-file-name 'not-save)
3431 (gnus-capitalize-newsgroup newsgroup)
3432 (gnus-newsgroup-directory-form newsgroup))
3433 "/" (int-to-string (mail-header-number headers)))
3434 gnus-article-save-directory)))
3436 (string-equal (file-name-directory default)
3437 (file-name-directory last-file))
3438 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3440 (or last-file default))))
3442 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3443 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3444 If variable `gnus-use-long-file-name' is non-nil, it is
3445 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3448 (concat (if (gnus-use-long-file-name 'not-save)
3450 (gnus-newsgroup-directory-form newsgroup))
3451 "/" (int-to-string (mail-header-number headers)))
3452 gnus-article-save-directory)))
3454 (string-equal (file-name-directory default)
3455 (file-name-directory last-file))
3456 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3458 (or last-file default))))
3460 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3461 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3462 If variable `gnus-use-long-file-name' is non-nil, it is
3463 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3466 (if (gnus-use-long-file-name 'not-save)
3469 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3471 gnus-article-save-directory)))
3473 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3474 "Generate file name from sender."
3475 (let ((from (mail-header-from headers)))
3477 (if (and from (string-match "\\([^ <]+\\)@" from))
3478 (match-string 1 from)
3480 gnus-article-save-directory)))
3482 (defun article-verify-x-pgp-sig ()
3485 (if (gnus-buffer-live-p gnus-original-article-buffer)
3486 (let ((sig (with-current-buffer gnus-original-article-buffer
3487 (gnus-fetch-field "X-PGP-Sig")))
3491 (mml2015-clear-verify-function))
3493 (insert-buffer-substring gnus-original-article-buffer)
3494 (setq items (split-string sig))
3495 (message-narrow-to-head)
3496 (let ((inhibit-point-motion-hooks t)
3497 (case-fold-search t))
3498 ;; Don't verify multiple headers.
3499 (setq headers (mapconcat (lambda (header)
3501 (mail-fetch-field header)
3503 (split-string (nth 1 items) ",") "")))
3504 (delete-region (point-min) (point-max))
3505 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3506 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3511 (if (looking-at "^-")
3514 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3515 (insert "Version: " (car items) "\n\n")
3516 (insert (mapconcat 'identity (cddr items) "\n"))
3517 (insert "\n-----END PGP SIGNATURE-----\n")
3518 (let ((mm-security-handle (list (format "multipart/signed"))))
3519 (mml2015-clean-buffer)
3520 (let ((coding-system-for-write (or gnus-newsgroup-charset
3522 (funcall (mml2015-clear-verify-function)))
3524 (or (mm-handle-multipart-ctl-parameter
3525 mm-security-handle 'gnus-details)
3526 (mm-handle-multipart-ctl-parameter
3527 mm-security-handle 'gnus-info)))))
3529 (let ((inhibit-read-only t) bface eface)
3531 (message-narrow-to-head)
3532 (goto-char (point-max))
3534 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3535 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3536 (message-remove-header "X-Gnus-PGP-Verify")
3537 (if (re-search-forward "^X-PGP-Sig:" nil t)
3539 (goto-char (point-max)))
3540 (narrow-to-region (point) (point))
3541 (insert "X-Gnus-PGP-Verify: " info "\n")
3542 (goto-char (point-min))
3545 (if (not (looking-at "^[ \t]"))
3549 (goto-char (point-min))
3550 (when (looking-at "\\([^:]+\\): *")
3551 (put-text-property (match-beginning 1) (1+ (match-end 1))
3553 (put-text-property (match-end 0) (point-max)
3554 'face eface)))))))))
3556 (defun article-verify-cancel-lock ()
3557 "Verify Cancel-Lock header."
3559 (if (gnus-buffer-live-p gnus-original-article-buffer)
3560 (canlock-verify gnus-original-article-buffer)))
3567 (setq afunc (car func)
3570 gfunc (intern (format "gnus-%s" func))))
3572 (when (fboundp afunc)
3573 `(lambda (&optional interactive &rest args)
3574 ,(documentation afunc t)
3575 (interactive (list t))
3577 (set-buffer gnus-article-buffer)
3579 (call-interactively ',afunc)
3580 (apply ',afunc args))))))))
3581 '(article-hide-headers
3582 article-verify-x-pgp-sig
3583 article-verify-cancel-lock
3584 article-hide-boring-headers
3585 article-treat-overstrike
3586 article-fill-long-lines
3587 article-capitalize-sentences
3589 article-remove-leading-whitespace
3590 article-display-x-face
3591 article-display-face
3592 article-de-quoted-unreadable
3593 article-de-base64-unreadable
3596 article-unsplit-urls
3597 article-hide-list-identifiers
3598 article-strip-banner
3601 article-hide-signature
3602 article-strip-headers-in-body
3603 article-remove-trailing-blank-lines
3604 article-strip-leading-blank-lines
3605 article-strip-multiple-blank-lines
3606 article-strip-leading-space
3607 article-strip-trailing-space
3608 article-strip-blank-lines
3609 article-strip-all-blank-lines
3611 article-date-english
3612 article-date-iso8601
3613 article-date-original
3615 article-decode-mime-words
3616 article-decode-charset
3617 article-decode-encoded-words
3621 article-treat-dumbquotes
3622 article-normalize-headers
3623 ;; (article-show-all . gnus-article-show-all-headers)
3627 ;;; Gnus article mode
3630 (put 'gnus-article-mode 'mode-class 'special)
3632 (set-keymap-parent gnus-article-mode-map widget-keymap)
3634 (gnus-define-keys gnus-article-mode-map
3635 " " gnus-article-goto-next-page
3636 "\177" gnus-article-goto-prev-page
3637 [delete] gnus-article-goto-prev-page
3638 [backspace] gnus-article-goto-prev-page
3639 "\C-c^" gnus-article-refer-article
3640 "h" gnus-article-show-summary
3641 "s" gnus-article-show-summary
3642 "\C-c\C-m" gnus-article-mail
3643 "?" gnus-article-describe-briefly
3644 "e" gnus-summary-edit-article
3645 "<" beginning-of-buffer
3647 "\C-c\C-i" gnus-info-find-node
3649 "R" gnus-article-reply-with-original
3650 "F" gnus-article-followup-with-original
3651 "\C-hk" gnus-article-describe-key
3652 "\C-hc" gnus-article-describe-key-briefly
3654 "\C-d" gnus-article-read-summary-keys
3655 "\M-*" gnus-article-read-summary-keys
3656 "\M-#" gnus-article-read-summary-keys
3657 "\M-^" gnus-article-read-summary-keys
3658 "\M-g" gnus-article-read-summary-keys)
3660 (substitute-key-definition
3661 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3663 (defun gnus-article-make-menu-bar ()
3664 (unless (boundp 'gnus-article-commands-menu)
3665 (gnus-summary-make-menu-bar))
3666 (gnus-turn-off-edit-menu 'article)
3667 (unless (boundp 'gnus-article-article-menu)
3669 gnus-article-article-menu gnus-article-mode-map ""
3671 ["Scroll forwards" gnus-article-goto-next-page t]
3672 ["Scroll backwards" gnus-article-goto-prev-page t]
3673 ["Show summary" gnus-article-show-summary t]
3674 ["Fetch Message-ID at point" gnus-article-refer-article t]
3675 ["Mail to address at point" gnus-article-mail t]
3676 ["Send a bug report" gnus-bug t]))
3679 gnus-article-treatment-menu gnus-article-mode-map ""
3680 ;; Fixme: this should use :active (and maybe :visible).
3682 ["Hide headers" gnus-article-hide-headers t]
3683 ["Hide signature" gnus-article-hide-signature t]
3684 ["Hide citation" gnus-article-hide-citation t]
3685 ["Treat overstrike" gnus-article-treat-overstrike t]
3686 ["Remove carriage return" gnus-article-remove-cr t]
3687 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3688 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3689 ["Remove base64" gnus-article-de-base64-unreadable t]
3690 ["Treat html" gnus-article-wash-html t]
3691 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3692 ["Decode HZ" gnus-article-decode-HZ t]))
3694 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3696 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3698 (gnus-run-hooks 'gnus-article-menu-hook)))
3700 (defun gnus-article-mode ()
3701 "Major mode for displaying an article.
3703 All normal editing commands are switched off.
3705 The following commands are available in addition to all summary mode
3707 \\<gnus-article-mode-map>
3708 \\[gnus-article-next-page]\t Scroll the article one page forwards
3709 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3710 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3711 \\[gnus-article-show-summary]\t Display the summary buffer
3712 \\[gnus-article-mail]\t Send a reply to the address near point
3713 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3714 \\[gnus-info-find-node]\t Go to the Gnus info node"
3716 (gnus-simplify-mode-line)
3717 (setq mode-name "Article")
3718 (setq major-mode 'gnus-article-mode)
3719 (make-local-variable 'minor-mode-alist)
3720 (use-local-map gnus-article-mode-map)
3721 (when (gnus-visual-p 'article-menu 'menu)
3722 (gnus-article-make-menu-bar)
3723 (when gnus-summary-tool-bar-map
3724 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3725 (gnus-update-format-specifications nil 'article-mode)
3726 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3727 (set (make-local-variable 'gnus-page-broken) nil)
3728 (make-local-variable 'gnus-button-marker-list)
3729 (make-local-variable 'gnus-article-current-summary)
3730 (make-local-variable 'gnus-article-mime-handles)
3731 (make-local-variable 'gnus-article-decoded-p)
3732 (make-local-variable 'gnus-article-mime-handle-alist)
3733 (make-local-variable 'gnus-article-wash-types)
3734 (make-local-variable 'gnus-article-image-alist)
3735 (make-local-variable 'gnus-article-charset)
3736 (make-local-variable 'gnus-article-ignored-charsets)
3737 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3738 (set (make-local-variable 'show-nonbreak-escape) nil)
3739 (gnus-set-default-directory)
3740 (buffer-disable-undo)
3741 (setq buffer-read-only t)
3742 (set-syntax-table gnus-article-mode-syntax-table)
3743 (mm-enable-multibyte)
3744 (gnus-run-hooks 'gnus-article-mode-hook))
3746 (defun gnus-article-setup-buffer ()
3747 "Initialize the article buffer."
3748 (let* ((name (if gnus-single-article-buffer "*Article*"
3749 (concat "*Article " gnus-newsgroup-name "*")))
3751 (progn (string-match "\\*Article" name)
3752 (concat " *Original Article"
3753 (substring name (match-end 0))))))
3754 (setq gnus-article-buffer name)
3755 (setq gnus-original-article-buffer original)
3756 (setq gnus-article-mime-handle-alist nil)
3757 ;; This might be a variable local to the summary buffer.
3758 (unless gnus-single-article-buffer
3760 (set-buffer gnus-summary-buffer)
3761 (setq gnus-article-buffer name)
3762 (setq gnus-original-article-buffer original)
3763 (gnus-set-global-variables)))
3764 (gnus-article-setup-highlight-words)
3765 ;; Init original article buffer.
3767 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3768 (mm-enable-multibyte)
3769 (setq major-mode 'gnus-original-article-mode)
3770 (make-local-variable 'gnus-original-article))
3771 (if (and (get-buffer name)
3772 (with-current-buffer name
3773 (if gnus-article-edit-mode
3774 (if (y-or-n-p "Article mode edit in progress; discard? ")
3776 (set-buffer-modified-p nil)
3777 (gnus-kill-buffer name)
3780 (error "Action aborted"))
3784 (set (make-local-variable 'gnus-article-edit-mode) nil)
3785 (when gnus-article-mime-handles
3786 (mm-destroy-parts gnus-article-mime-handles)
3787 (setq gnus-article-mime-handles nil))
3788 ;; Set it to nil in article-buffer!
3789 (setq gnus-article-mime-handle-alist nil)
3790 (buffer-disable-undo)
3791 (setq buffer-read-only t)
3792 ;; This list just keeps growing if we don't reset it.
3793 (setq gnus-button-marker-list nil)
3794 (unless (eq major-mode 'gnus-article-mode)
3795 (gnus-article-mode))
3798 (set-buffer (gnus-get-buffer-create name))
3800 (make-local-variable 'gnus-summary-buffer)
3801 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3802 (current-buffer)))))
3804 ;; Set article window start at LINE, where LINE is the number of lines
3805 ;; from the head of the article.
3806 (defun gnus-article-set-window-start (&optional line)
3808 (gnus-get-buffer-window gnus-article-buffer t)
3810 (set-buffer gnus-article-buffer)
3811 (goto-char (point-min))
3814 (gnus-message 6 "Moved to bookmark")
3815 (search-forward "\n\n" nil t)
3819 (defun gnus-article-prepare (article &optional all-headers header)
3820 "Prepare ARTICLE in article mode buffer.
3821 ARTICLE should either be an article number or a Message-ID.
3822 If ARTICLE is an id, HEADER should be the article headers.
3823 If ALL-HEADERS is non-nil, no headers are hidden."
3825 ;; Make sure we start in a summary buffer.
3826 (unless (eq major-mode 'gnus-summary-mode)
3827 (set-buffer gnus-summary-buffer))
3828 (setq gnus-summary-buffer (current-buffer))
3829 (let* ((gnus-article (if header (mail-header-number header) article))
3830 (summary-buffer (current-buffer))
3831 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3832 (group gnus-newsgroup-name)
3835 (gnus-article-setup-buffer)
3836 (set-buffer gnus-article-buffer)
3837 ;; Deactivate active regions.
3838 (when (and (boundp 'transient-mark-mode)
3839 transient-mark-mode)
3840 (setq mark-active nil))
3841 (if (not (setq result (let ((inhibit-read-only t))
3842 (gnus-request-article-this-buffer
3844 ;; There is no such article.
3846 (when (and (numberp article)
3847 (not (memq article gnus-newsgroup-sparse)))
3848 (setq gnus-article-current
3849 (cons gnus-newsgroup-name article))
3850 (set-buffer gnus-summary-buffer)
3851 (setq gnus-current-article article)
3852 (if (and (memq article gnus-newsgroup-undownloaded)
3853 (not (gnus-online (gnus-find-method-for-group
3854 gnus-newsgroup-name))))
3856 (gnus-summary-set-agent-mark article)
3857 (message "Message marked for downloading"))
3858 (gnus-summary-mark-article article gnus-canceled-mark)
3859 (unless (memq article gnus-newsgroup-sparse)
3860 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3861 (if (or (eq result 'pseudo)
3862 (eq result 'nneething))
3865 (set-buffer summary-buffer)
3866 (push article gnus-newsgroup-history)
3867 (setq gnus-last-article gnus-current-article
3868 gnus-current-article 0
3869 gnus-current-headers nil
3870 gnus-article-current nil)
3871 (if (eq result 'nneething)
3872 (gnus-configure-windows 'summary)
3873 (gnus-configure-windows 'article))
3874 (gnus-set-global-variables))
3875 (let ((gnus-article-mime-handle-alist-1
3876 gnus-article-mime-handle-alist))
3877 (gnus-set-mode-line 'article)))
3878 ;; The result from the `request' was an actual article -
3879 ;; or at least some text that is now displayed in the
3881 (when (and (numberp article)
3882 (not (eq article gnus-current-article)))
3883 ;; Seems like a new article has been selected.
3884 ;; `gnus-current-article' must be an article number.
3886 (set-buffer summary-buffer)
3887 (push article gnus-newsgroup-history)
3888 (setq gnus-last-article gnus-current-article
3889 gnus-current-article article
3890 gnus-current-headers
3891 (gnus-summary-article-header gnus-current-article)
3892 gnus-article-current
3893 (cons gnus-newsgroup-name gnus-current-article))
3894 (unless (vectorp gnus-current-headers)
3895 (setq gnus-current-headers nil))
3896 (gnus-summary-goto-subject gnus-current-article)
3897 (when (gnus-summary-show-thread)
3898 ;; If the summary buffer really was folded, the
3899 ;; previous goto may not actually have gone to
3900 ;; the right article, but the thread root instead.
3902 (gnus-summary-goto-subject gnus-current-article))
3903 (gnus-run-hooks 'gnus-mark-article-hook)
3904 (gnus-set-mode-line 'summary)
3905 (when (gnus-visual-p 'article-highlight 'highlight)
3906 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3907 ;; Set the global newsgroup variables here.
3908 (gnus-set-global-variables)
3909 (setq gnus-have-all-headers
3910 (or all-headers gnus-show-all-headers))))
3912 (gnus-configure-windows 'article))
3913 (when (or (numberp article)
3915 (gnus-article-prepare-display)
3917 (goto-char (point-min))
3918 (when gnus-break-pages
3919 (gnus-narrow-to-page)))
3920 (let ((gnus-article-mime-handle-alist-1
3921 gnus-article-mime-handle-alist))
3922 (gnus-set-mode-line 'article))
3926 (set-window-point (get-buffer-window (current-buffer)) (point))
3927 (gnus-configure-windows 'article)
3931 (defun gnus-article-prepare-display ()
3932 "Make the current buffer look like a nice article."
3933 ;; Hooks for getting information from the article.
3934 ;; This hook must be called before being narrowed.
3935 (let ((gnus-article-buffer (current-buffer))
3937 (inhibit-read-only t))
3938 (unless (eq major-mode 'gnus-article-mode)
3939 (gnus-article-mode))
3940 (setq buffer-read-only nil
3941 gnus-article-wash-types nil
3942 gnus-article-image-alist nil)
3943 (gnus-run-hooks 'gnus-tmp-internal-hook)
3944 (when gnus-display-mime-function
3945 (funcall gnus-display-mime-function))
3946 (gnus-run-hooks 'gnus-article-prepare-hook)))
3949 ;;; Gnus MIME viewing functions
3952 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3953 "Format of the MIME buttons.
3955 Valid specifiers include:
3957 %T MIME type, along with additional info
3958 %n The `name' parameter
3959 %d The description, if any
3960 %l The length of the encoded part
3961 %p The part identifier number
3962 %e Dots if the part isn't displayed
3964 General format specifiers can also be used. See Info node
3965 `(gnus)Formatting Variables'.")
3967 (defvar gnus-mime-button-line-format-alist
3968 '((?t gnus-tmp-type ?s)
3969 (?T gnus-tmp-type-long ?s)
3970 (?n gnus-tmp-name ?s)
3971 (?d gnus-tmp-description ?s)
3973 (?l gnus-tmp-length ?d)
3974 (?e gnus-tmp-dots ?s)))
3976 (defvar gnus-mime-button-commands
3977 '((gnus-article-press-button "\r" "Toggle Display")
3978 (gnus-mime-view-part "v" "View Interactively...")
3979 (gnus-mime-view-part-as-type "t" "View As Type...")
3980 (gnus-mime-view-part-as-charset "C" "View As charset...")
3981 (gnus-mime-save-part "o" "Save...")
3982 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3983 (gnus-mime-delete-part "d" "Delete part")
3984 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3985 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3986 (gnus-mime-view-part-internally "E" "View Internally")
3987 (gnus-mime-view-part-externally "e" "View Externally")
3988 (gnus-mime-print-part "p" "Print")
3989 (gnus-mime-pipe-part "|" "Pipe To Command...")
3990 (gnus-mime-action-on-part "." "Take action on the part...")))
3992 (defun gnus-article-mime-part-status ()
3993 (if gnus-article-mime-handle-alist-1
3994 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3996 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3999 (defvar gnus-mime-button-map
4000 (let ((map (make-sparse-keymap)))
4001 (unless (>= (string-to-number emacs-version) 21)
4002 ;; XEmacs doesn't care.
4003 (set-keymap-parent map gnus-article-mode-map))
4004 (define-key map gnus-mouse-2 'gnus-article-push-button)
4005 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4006 (dolist (c gnus-mime-button-commands)
4007 (define-key map (cadr c) (car c)))
4011 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4013 ,@(mapcar (lambda (c)
4014 (vector (caddr c) (car c) :enable t))
4015 gnus-mime-button-commands)))
4018 (define-compiler-macro popup-menu (&whole form
4019 menu &optional position prefix)
4020 (if (and (fboundp 'popup-menu)
4021 (not (memq 'popup-menu (assoc "lmenu" load-history))))
4023 ;; Gnus is probably running under Emacs 20.
4024 `(let* ((menu (cdr ,menu))
4025 (response (x-popup-menu
4027 (cons "" (mapcar (lambda (c)
4028 (cons (caddr c) (car c)))
4031 (call-interactively (nth 3 (assq response menu))))))))
4033 (defun gnus-mime-button-menu (event prefix)
4034 "Construct a context-sensitive menu of MIME commands."
4035 (interactive "e\nP")
4036 (save-window-excursion
4037 (let ((pos (event-start event)))
4038 (select-window (posn-window pos))
4039 (goto-char (posn-point pos))
4040 (gnus-article-check-buffer)
4041 (popup-menu gnus-mime-button-menu nil prefix))))
4043 (defun gnus-mime-view-all-parts (&optional handles)
4044 "View all the MIME parts."
4046 (save-current-buffer
4047 (set-buffer gnus-article-buffer)
4048 (let ((handles (or handles gnus-article-mime-handles))
4049 (mail-parse-charset gnus-newsgroup-charset)
4050 (mail-parse-ignored-charsets
4051 (with-current-buffer gnus-summary-buffer
4052 gnus-newsgroup-ignored-charsets)))
4054 (mm-remove-parts handles)
4055 (goto-char (point-min))
4056 (or (search-forward "\n\n") (goto-char (point-max)))
4057 (let ((inhibit-read-only t))
4058 (delete-region (point) (point-max))
4059 (mm-display-parts handles))))))
4061 (defun gnus-mime-save-part-and-strip ()
4062 "Save the MIME part under point then replace it with an external body."
4064 (gnus-article-check-buffer)
4065 (when (gnus-group-read-only-p)
4066 (error "The current group does not support deleting of parts"))
4067 (when (mm-complicated-handles gnus-article-mime-handles)
4069 The current article has a complicated MIME structure, giving up..."))
4070 (when (gnus-yes-or-no-p "\
4071 Deleting parts may malfunction or destroy the article; continue? ")
4072 (let* ((data (get-text-property (point) 'gnus-data))
4074 (handles gnus-article-mime-handles))
4075 (setq file (and data (mm-save-part data)))
4077 (with-current-buffer (mm-handle-buffer data)
4079 (insert "Content-Type: " (mm-handle-media-type data))
4080 (mml-insert-parameter-string (cdr (mm-handle-type data))
4083 (insert "Content-ID: " (message-make-message-id) "\n")
4084 (insert "Content-Transfer-Encoding: binary\n")
4087 (cdr (mm-make-handle nil
4088 `("message/external-body"
4089 (access-type . "LOCAL-FILE")
4091 (set-buffer gnus-summary-buffer)
4092 (gnus-article-edit-article
4095 (let ((mail-parse-charset (or gnus-article-charset
4096 ',gnus-newsgroup-charset))
4097 (mail-parse-ignored-charsets
4098 (or gnus-article-ignored-charsets
4099 ',gnus-newsgroup-ignored-charsets))
4100 (mbl mml-buffer-list))
4101 (setq mml-buffer-list nil)
4102 (insert-buffer gnus-original-article-buffer)
4103 (mime-to-mml ',handles)
4104 (setq gnus-article-mime-handles nil)
4105 (let ((mbl1 mml-buffer-list))
4106 (setq mml-buffer-list mbl)
4107 (set (make-local-variable 'mml-buffer-list) mbl1))
4108 (gnus-make-local-hook 'kill-buffer-hook)
4109 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4110 `(lambda (no-highlight)
4111 (let ((mail-parse-charset (or gnus-article-charset
4112 ',gnus-newsgroup-charset))
4113 (message-options message-options)
4114 (message-options-set-recipient)
4115 (mail-parse-ignored-charsets
4116 (or gnus-article-ignored-charsets
4117 ',gnus-newsgroup-ignored-charsets)))
4119 (mml-destroy-buffers)
4120 (remove-hook 'kill-buffer-hook
4121 'mml-destroy-buffers t)
4122 (kill-local-variable 'mml-buffer-list))
4123 (gnus-summary-edit-article-done
4124 ,(or (mail-header-references gnus-current-headers) "")
4125 ,(gnus-group-read-only-p)
4126 ,gnus-summary-buffer no-highlight)))))))
4128 (defun gnus-mime-delete-part ()
4129 "Delete the MIME part under point.
4130 Replace it with some information about the removed part."
4132 (gnus-article-check-buffer)
4133 (when (gnus-group-read-only-p)
4134 (error "The current group does not support deleting of parts"))
4135 (when (mm-complicated-handles gnus-article-mime-handles)
4137 The current article has a complicated MIME structure, giving up..."))
4138 (when (gnus-yes-or-no-p "\
4139 Deleting parts may malfunction or destroy the article; continue? ")
4140 (let* ((data (get-text-property (point) 'gnus-data))
4141 (handles gnus-article-mime-handles)
4145 (mail-decode-encoded-word-string (or (mm-handle-description data)
4148 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4150 (type (mm-handle-media-type data)))
4152 (error "No MIME part under point"))
4153 (with-current-buffer (mm-handle-buffer data)
4154 (let ((bsize (format "%s" (buffer-size))))
4159 "| The following attachment has been deleted:\n"
4161 "| Type: " type "\n"
4162 "| Filename: " filename "\n"
4163 "| Size (encoded): " bsize " Byte\n"
4164 "| Description: " description "\n"
4167 (cdr (mm-make-handle
4168 nil `("text/plain") nil nil
4170 (format "Deleted attachment (%s bytes)" bsize))))))
4171 (set-buffer gnus-summary-buffer)
4172 ;; FIXME: maybe some of the following code (borrowed from
4173 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4174 (gnus-article-edit-article
4177 (let ((mail-parse-charset (or gnus-article-charset
4178 ',gnus-newsgroup-charset))
4179 (mail-parse-ignored-charsets
4180 (or gnus-article-ignored-charsets
4181 ',gnus-newsgroup-ignored-charsets))
4182 (mbl mml-buffer-list))
4183 (setq mml-buffer-list nil)
4184 (insert-buffer gnus-original-article-buffer)
4185 (mime-to-mml ',handles)
4186 (setq gnus-article-mime-handles nil)
4187 (let ((mbl1 mml-buffer-list))
4188 (setq mml-buffer-list mbl)
4189 (set (make-local-variable 'mml-buffer-list) mbl1))
4190 (gnus-make-local-hook 'kill-buffer-hook)
4191 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4192 `(lambda (no-highlight)
4193 (let ((mail-parse-charset (or gnus-article-charset
4194 ',gnus-newsgroup-charset))
4195 (message-options message-options)
4196 (message-options-set-recipient)
4197 (mail-parse-ignored-charsets
4198 (or gnus-article-ignored-charsets
4199 ',gnus-newsgroup-ignored-charsets)))
4201 (mml-destroy-buffers)
4202 (remove-hook 'kill-buffer-hook
4203 'mml-destroy-buffers t)
4204 (kill-local-variable 'mml-buffer-list))
4205 (gnus-summary-edit-article-done
4206 ,(or (mail-header-references gnus-current-headers) "")
4207 ,(gnus-group-read-only-p)
4208 ,gnus-summary-buffer no-highlight)))))
4209 ;; Not in `gnus-mime-save-part-and-strip':
4210 (gnus-article-edit-done)
4211 (gnus-summary-expand-window)
4212 (gnus-summary-show-article))
4214 (defun gnus-mime-save-part ()
4215 "Save the MIME part under point."
4217 (gnus-article-check-buffer)
4218 (let ((data (get-text-property (point) 'gnus-data)))
4220 (mm-save-part data))))
4222 (defun gnus-mime-pipe-part ()
4223 "Pipe the MIME part under point to a process."
4225 (gnus-article-check-buffer)
4226 (let ((data (get-text-property (point) 'gnus-data)))
4228 (mm-pipe-part data))))
4230 (defun gnus-mime-view-part ()
4231 "Interactively choose a viewing method for the MIME part under point."
4233 (gnus-article-check-buffer)
4234 (let ((data (get-text-property (point) 'gnus-data)))
4236 (setq gnus-article-mime-handles
4238 gnus-article-mime-handles (setq data (copy-sequence data))))
4239 (mm-interactively-view-part data))))
4241 (defun gnus-mime-view-part-as-type-internal ()
4242 (gnus-article-check-buffer)
4243 (let* ((name (mail-content-type-get
4244 (mm-handle-type (get-text-property (point) 'gnus-data))
4246 (def-type (and name (mm-default-file-encoding name))))
4247 (and def-type (cons def-type 0))))
4249 (defun gnus-mime-view-part-as-type (&optional mime-type)
4250 "Choose a MIME media type, and view the part as such."
4253 (setq mime-type (completing-read
4254 "View as MIME type: "
4255 (mapcar #'list (mailcap-mime-types))
4257 (gnus-mime-view-part-as-type-internal))))
4258 (gnus-article-check-buffer)
4259 (let ((handle (get-text-property (point) 'gnus-data)))
4262 (mm-make-handle (mm-handle-buffer handle)
4263 (cons mime-type (cdr (mm-handle-type handle)))
4264 (mm-handle-encoding handle)
4265 (mm-handle-undisplayer handle)
4266 (mm-handle-disposition handle)
4267 (mm-handle-description handle)
4269 (mm-handle-id handle)))
4270 (setq gnus-article-mime-handles
4271 (mm-merge-handles gnus-article-mime-handles handle))
4272 (gnus-mm-display-part handle))))
4275 (require 'jka-compr))
4277 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4278 ;; emacs can do that itself.
4280 (defun gnus-mime-jka-compr-maybe-uncompress ()
4281 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4282 The uncompress method used is derived from `buffer-file-name'."
4283 (when (and (fboundp 'jka-compr-installed-p)
4284 (jka-compr-installed-p))
4285 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4287 (let ((basename (file-name-nondirectory buffer-file-name))
4288 (args (jka-compr-info-uncompress-args info))
4289 (prog (jka-compr-info-uncompress-program info))
4290 (message (jka-compr-info-uncompress-message info))
4291 (err-file (jka-compr-make-temp-name)))
4293 (message "%s %s..." message basename))
4295 (unless (memq (apply 'call-process-region
4296 (point-min) (point-max)
4298 t (list t err-file) nil
4300 jka-compr-acceptable-retval-list)
4301 (jka-compr-error prog args basename message err-file))
4302 (jka-compr-delete-temp-file err-file)))))))
4304 (defun gnus-mime-copy-part (&optional handle)
4305 "Put the MIME part under point into a new buffer.
4306 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4309 (gnus-article-check-buffer)
4310 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4311 (contents (and handle (mm-get-part handle)))
4313 (file-name-nondirectory
4315 (mail-content-type-get (mm-handle-type handle) 'name)
4316 (mail-content-type-get (mm-handle-disposition handle)
4319 (buffer (and base (generate-new-buffer base))))
4321 (switch-to-buffer buffer)
4323 ;; We do it this way to make `normal-mode' set the appropriate mode.
4326 (setq buffer-file-name (expand-file-name base))
4327 (gnus-mime-jka-compr-maybe-uncompress)
4329 (setq buffer-file-name nil))
4330 (goto-char (point-min)))))
4332 (defun gnus-mime-print-part (&optional handle filename)
4333 "Print the MIME part under point."
4334 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4335 (gnus-article-check-buffer)
4336 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4337 (contents (and handle (mm-get-part handle)))
4338 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4339 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4344 (mm-save-part-to-file handle file)
4345 (call-process shell-file-name nil
4346 (generate-new-buffer " *mm*")
4348 shell-command-switch
4350 printer file (mm-handle-type handle))))
4354 (gnus-print-buffer))
4355 (ps-despool filename)))))
4357 (defun gnus-mime-inline-part (&optional handle arg)
4358 "Insert the MIME part under point into the current buffer."
4359 (interactive (list nil current-prefix-arg))
4360 (gnus-article-check-buffer)
4361 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4364 (inhibit-read-only t))
4366 (if (and (not arg) (mm-handle-undisplayer handle))
4367 (mm-remove-part handle)
4368 (setq contents (mm-get-part handle))
4371 (setq charset (or (mail-content-type-get
4372 (mm-handle-type handle) 'charset)
4373 gnus-newsgroup-charset)))
4375 (if (mm-handle-undisplayer handle)
4376 (mm-remove-part handle))
4379 gnus-summary-show-article-charset-alist))
4380 (mm-read-coding-system "Charset: "))))
4382 (if (mm-handle-undisplayer handle)
4383 (mm-remove-part handle))))
4388 (setq charset (mm-charset-to-coding-system
4390 (not (eq charset 'ascii)))
4391 (mm-decode-coding-string contents charset)
4392 (mm-string-to-multibyte contents)))
4395 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4396 "Insert the MIME part under point into the current buffer using the
4398 (interactive (list nil current-prefix-arg))
4399 (gnus-article-check-buffer)
4400 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4403 (inhibit-read-only t))
4405 (if (mm-handle-undisplayer handle)
4406 (mm-remove-part handle))
4407 (let ((gnus-newsgroup-charset
4409 gnus-summary-show-article-charset-alist))
4410 (mm-read-coding-system "Charset: ")))
4411 (gnus-newsgroup-ignored-charsets 'gnus-all))
4412 (gnus-article-press-button)))))
4414 (defun gnus-mime-view-part-externally (&optional handle)
4415 "View the MIME part under point with an external viewer."
4417 (gnus-article-check-buffer)
4418 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4419 (mm-user-display-methods nil)
4420 (mm-inlined-types nil)
4421 (mail-parse-charset gnus-newsgroup-charset)
4422 (mail-parse-ignored-charsets
4423 (save-excursion (set-buffer gnus-summary-buffer)
4424 gnus-newsgroup-ignored-charsets)))
4426 (if (mm-handle-undisplayer handle)
4427 (mm-remove-part handle)
4428 (mm-display-part handle)))))
4430 (defun gnus-mime-view-part-internally (&optional handle)
4431 "View the MIME part under point with an internal viewer.
4432 If no internal viewer is available, use an external viewer."
4434 (gnus-article-check-buffer)
4435 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4436 (mm-inlined-types '(".*"))
4437 (mm-inline-large-images t)
4438 (mail-parse-charset gnus-newsgroup-charset)
4439 (mail-parse-ignored-charsets
4440 (save-excursion (set-buffer gnus-summary-buffer)
4441 gnus-newsgroup-ignored-charsets))
4442 (inhibit-read-only t))
4444 (if (mm-handle-undisplayer handle)
4445 (mm-remove-part handle)
4446 (mm-display-part handle)))))
4448 (defun gnus-mime-action-on-part (&optional action)
4449 "Do something with the MIME attachment at \(point\)."
4451 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4452 (gnus-article-check-buffer)
4453 (let ((action-pair (assoc action gnus-mime-action-alist)))
4455 (funcall (cdr action-pair)))))
4457 (defun gnus-article-part-wrapper (n function)
4458 (save-current-buffer
4459 (set-buffer gnus-article-buffer)
4460 (when (> n (length gnus-article-mime-handle-alist))
4461 (error "No such part"))
4462 (gnus-article-goto-part n)
4463 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4464 (funcall function handle))))
4466 (defun gnus-article-pipe-part (n)
4467 "Pipe MIME part N, which is the numerical prefix."
4469 (gnus-article-part-wrapper n 'mm-pipe-part))
4471 (defun gnus-article-save-part (n)
4472 "Save MIME part N, which is the numerical prefix."
4474 (gnus-article-part-wrapper n 'mm-save-part))
4476 (defun gnus-article-interactively-view-part (n)
4477 "View MIME part N interactively, which is the numerical prefix."
4479 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4481 (defun gnus-article-copy-part (n)
4482 "Copy MIME part N, which is the numerical prefix."
4484 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4486 (defun gnus-article-view-part-as-charset (n)
4487 "View MIME part N using a specified charset.
4488 N is the numerical prefix."
4490 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4492 (defun gnus-article-view-part-externally (n)
4493 "View MIME part N externally, which is the numerical prefix."
4495 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4497 (defun gnus-article-inline-part (n)
4498 "Inline MIME part N, which is the numerical prefix."
4500 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4502 (defun gnus-article-mime-match-handle-first (condition)
4504 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4505 (while (setq ihandle (pop alist))
4507 ((functionp condition)
4508 (funcall condition (cdr ihandle)))
4509 ((eq condition 'undisplayed)
4510 (not (or (mm-handle-undisplayer (cdr ihandle))
4511 (equal (mm-handle-media-type (cdr ihandle))
4512 "multipart/alternative"))))
4513 ((eq condition 'undisplayed-alternative)
4514 (not (mm-handle-undisplayer (cdr ihandle))))
4516 (gnus-article-goto-part (car ihandle))
4517 (or (not n) (< (car ihandle) n)))
4518 (setq n (car ihandle))))
4522 (defun gnus-article-view-part (&optional n)
4523 "View MIME part N, which is the numerical prefix."
4525 (save-current-buffer
4526 (set-buffer gnus-article-buffer)
4527 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4528 gnus-article-mime-match-handle-function)))
4529 (when (> n (length gnus-article-mime-handle-alist))
4530 (error "No such part"))
4531 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4532 (when (gnus-article-goto-part n)
4533 (if (equal (car handle) "multipart/alternative")
4534 (gnus-article-press-button)
4535 (when (eq (gnus-mm-display-part handle) 'internal)
4536 (gnus-set-window-start)))))))
4538 (defsubst gnus-article-mime-total-parts ()
4539 (if (bufferp (car gnus-article-mime-handles))
4541 (1- (length gnus-article-mime-handles))))
4543 (defun gnus-mm-display-part (handle)
4544 "Display HANDLE and fix MIME button."
4545 (let ((id (get-text-property (point) 'gnus-part))
4547 (inhibit-read-only t))
4550 (let ((window (selected-window))
4551 (mail-parse-charset gnus-newsgroup-charset)
4552 (mail-parse-ignored-charsets
4553 (if (gnus-buffer-live-p gnus-summary-buffer)
4555 (set-buffer gnus-summary-buffer)
4556 gnus-newsgroup-ignored-charsets)
4560 (let ((win (gnus-get-buffer-window (current-buffer) t))
4563 (select-window win))
4566 (if (mm-handle-displayed-p handle)
4567 ;; This will remove the part.
4568 (mm-display-part handle)
4570 (narrow-to-region (point)
4571 (if (eobp) (point) (1+ (point))))
4572 (mm-display-part handle)
4573 ;; We narrow to the part itself and
4574 ;; then call the treatment functions.
4575 (goto-char (point-min))
4577 (narrow-to-region (point) (point-max))
4580 (gnus-article-mime-total-parts)
4581 (mm-handle-media-type handle)))))
4582 (if (window-live-p window)
4583 (select-window window)))))
4586 (gnus-insert-mime-button
4587 handle id (list (mm-handle-displayed-p handle)))
4588 (goto-char point))))
4590 (defun gnus-article-goto-part (n)
4591 "Go to MIME part N."
4592 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4594 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4595 (let ((gnus-tmp-name
4596 (or (mail-content-type-get (mm-handle-type handle) 'name)
4597 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4598 (mail-content-type-get (mm-handle-type handle) 'url)
4600 (gnus-tmp-type (mm-handle-media-type handle))
4601 (gnus-tmp-description
4602 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4605 (if (if displayed (car displayed)
4606 (mm-handle-displayed-p handle))
4608 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4610 gnus-tmp-type-long b e)
4611 (when (string-match ".*/" gnus-tmp-name)
4612 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4613 (setq gnus-tmp-type-long (concat gnus-tmp-type
4614 (and (not (equal gnus-tmp-name ""))
4615 (concat "; " gnus-tmp-name))))
4616 (unless (equal gnus-tmp-description "")
4617 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4622 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4623 `(,@(gnus-local-map-property gnus-mime-button-map)
4624 gnus-callback gnus-mm-display-part
4625 gnus-part ,gnus-tmp-id
4626 article-type annotation
4629 ;; Exclude a newline.
4632 (widget-convert-button
4635 :action 'gnus-widget-press-button
4636 :button-keymap gnus-mime-button-map
4638 (lambda (widget/window &optional overlay pos)
4639 ;; Needed to properly clear the message due to a bug in
4640 ;; wid-edit (XEmacs only).
4641 (if (boundp 'help-echo-owns-message)
4642 (setq help-echo-owns-message t))
4644 "%S: %s the MIME part; %S: more options"
4645 (aref gnus-mouse-2 0)
4646 ;; XEmacs will get a single widget arg; Emacs 21 will get
4647 ;; window, overlay, position.
4648 (if (mm-handle-displayed-p
4650 (with-current-buffer (gnus-overlay-buffer overlay)
4651 (widget-get (widget-at (gnus-overlay-start overlay))
4653 (widget-get widget/window :mime-handle)))
4655 (aref gnus-down-mouse-3 0))))))
4657 (defun gnus-widget-press-button (elems el)
4658 (goto-char (widget-get elems :from))
4659 (gnus-article-press-button))
4661 (defvar gnus-displaying-mime nil)
4663 (defun gnus-display-mime (&optional ihandles)
4664 "Display the MIME parts."
4666 (save-selected-window
4667 (let ((window (get-buffer-window gnus-article-buffer))
4670 (select-window window)
4671 ;; We have to do this since selecting the window
4672 ;; may change the point. So we set the window point.
4673 (set-window-point window point)))
4674 (let* ((handles (or ihandles
4675 (mm-dissect-buffer nil gnus-article-loose-mime)
4676 (and gnus-article-emulate-mime
4678 (inhibit-read-only t) handle name type b e display)
4679 (when (and (not ihandles)
4680 (not gnus-displaying-mime))
4681 ;; Top-level call; we clean up.
4682 (when gnus-article-mime-handles
4683 (mm-destroy-parts gnus-article-mime-handles)
4684 (setq gnus-article-mime-handle-alist nil));; A trick.
4685 (setq gnus-article-mime-handles handles)
4686 ;; We allow users to glean info from the handles.
4687 (when gnus-article-mime-part-function
4688 (gnus-mime-part-function handles)))
4690 (or (not (stringp (car handles)))
4693 (when (and (not ihandles)
4694 (not gnus-displaying-mime))
4695 ;; Clean up for mime parts.
4697 (delete-region (point) (point-max)))
4698 (let ((gnus-displaying-mime t))
4699 (gnus-mime-display-part handles)))
4702 (narrow-to-region (point) (point-max))
4703 (gnus-treat-article nil 1 1)
4706 ;; Highlight the headers.
4710 (narrow-to-region (point-min) (point))
4711 (gnus-article-save-original-date
4712 (gnus-treat-article 'head)))))))))
4714 (defcustom gnus-mime-display-multipart-as-mixed nil
4715 "Display \"multipart\" parts as \"multipart/mixed\".
4717 If t, it overrides nil values of
4718 `gnus-mime-display-multipart-alternative-as-mixed' and
4719 `gnus-mime-display-multipart-related-as-mixed'."
4720 :group 'gnus-article-mime
4723 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4724 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4726 :group 'gnus-article-mime
4729 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4730 "Display \"multipart/related\" parts as \"multipart/mixed\".
4732 If displaying \"text/html\" is discouraged \(see
4733 `mm-discouraged-alternatives'\) images or other material inside a
4734 \"multipart/related\" part might be overlooked when this variable is nil."
4736 :group 'gnus-article-mime
4739 (defun gnus-mime-display-part (handle)
4742 ((not (stringp (car handle)))
4743 (gnus-mime-display-single handle))
4744 ;; User-defined multipart
4745 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4746 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4748 ;; multipart/alternative
4749 ((and (equal (car handle) "multipart/alternative")
4750 (not (or gnus-mime-display-multipart-as-mixed
4751 gnus-mime-display-multipart-alternative-as-mixed)))
4752 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4753 (push (cons id handle) gnus-article-mime-handle-alist)
4754 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4755 ;; multipart/related
4756 ((and (equal (car handle) "multipart/related")
4757 (not (or gnus-mime-display-multipart-as-mixed
4758 gnus-mime-display-multipart-related-as-mixed)))
4759 ;;;!!!We should find the start part, but we just default
4760 ;;;!!!to the first part.
4761 ;;(gnus-mime-display-part (cadr handle))
4762 ;;;!!! Most multipart/related is an HTML message plus images.
4763 ;;;!!! Unfortunately we are unable to let W3 display those
4764 ;;;!!! included images, so we just display it as a mixed multipart.
4765 ;;(gnus-mime-display-mixed (cdr handle))
4766 ;;;!!! No, w3 can display everything just fine.
4767 (gnus-mime-display-part (cadr handle)))
4768 ((equal (car handle) "multipart/signed")
4769 (gnus-add-wash-type 'signed)
4770 (gnus-mime-display-security handle))
4771 ((equal (car handle) "multipart/encrypted")
4772 (gnus-add-wash-type 'encrypted)
4773 (gnus-mime-display-security handle))
4774 ;; Other multiparts are handled like multipart/mixed.
4776 (gnus-mime-display-mixed (cdr handle)))))
4778 (defun gnus-mime-part-function (handles)
4779 (if (stringp (car handles))
4780 (mapcar 'gnus-mime-part-function (cdr handles))
4781 (funcall gnus-article-mime-part-function handles)))
4783 (defun gnus-mime-display-mixed (handles)
4784 (mapcar 'gnus-mime-display-part handles))
4786 (defun gnus-mime-display-single (handle)
4787 (let ((type (mm-handle-media-type handle))
4788 (ignored gnus-ignored-mime-types)
4795 (when (string-match (pop ignored) type)
4796 (throw 'ignored nil)))
4797 (if (and (setq not-attachment
4798 (and (not (mm-inline-override-p handle))
4799 (or (not (mm-handle-disposition handle))
4800 (equal (car (mm-handle-disposition handle))
4802 (mm-attachment-override-p handle))))
4803 (mm-automatic-display-p handle)
4805 (mm-inlinable-p handle)
4806 (mm-inlined-p handle))
4807 (mm-automatic-external-display-p type)))
4809 (when (equal (mm-handle-media-supertype handle) "text")
4811 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4813 (push (cons id handle) gnus-article-mime-handle-alist)
4814 (when (or (not display)
4815 (not (gnus-unbuttonized-mime-type-p type)))
4816 ;(gnus-article-insert-newline)
4817 (gnus-insert-mime-button
4818 handle id (list (or display (and not-attachment text))))
4819 (gnus-article-insert-newline)
4820 ;(gnus-article-insert-newline)
4821 ;; Remember modify the number of forward lines.
4829 (let ((mail-parse-charset gnus-newsgroup-charset)
4830 (mail-parse-ignored-charsets
4831 (save-excursion (condition-case ()
4832 (set-buffer gnus-summary-buffer)
4834 gnus-newsgroup-ignored-charsets)))
4835 (mm-display-part handle t))
4836 (goto-char (point-max)))
4837 ((and text not-attachment)
4841 (gnus-article-insert-newline)
4842 (mm-insert-inline handle (mm-get-part handle))
4843 (goto-char (point-max))))
4847 (narrow-to-region beg (point))
4850 (gnus-article-mime-total-parts)
4851 (mm-handle-media-type handle)))))))))
4853 (defun gnus-unbuttonized-mime-type-p (type)
4854 "Say whether TYPE is to be unbuttonized."
4855 (unless gnus-inhibit-mime-unbuttonizing
4857 (let ((types gnus-unbuttonized-mime-types))
4859 (when (string-match (pop types) type)
4860 (throw 'found t)))))
4862 (let ((types gnus-buttonized-mime-types))
4864 (when (string-match (pop types) type)
4865 (throw 'found t)))))))))
4867 (defun gnus-article-insert-newline ()
4868 "Insert a newline, but mark it as undeletable."
4869 (gnus-put-text-property
4870 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4872 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4873 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4876 handle (inhibit-read-only t) from props begend not-pref)
4877 (save-window-excursion
4880 (narrow-to-region (car ibegend)
4883 (goto-char (car ibegend))
4886 (delete-region (point-min) (point-max))
4887 (mm-remove-parts handles))
4888 (setq begend (list (point-marker)))
4890 (unless (setq not-pref (cadr (member preferred ihandles)))
4891 (setq not-pref (car ihandles)))
4894 (not (gnus-unbuttonized-mime-type-p
4895 "multipart/alternative")))
4896 (gnus-add-text-properties
4899 (insert (format "%d. " id))
4903 (unless ,(not ibegend)
4904 (setq gnus-article-mime-handle-alist
4905 ',gnus-article-mime-handle-alist))
4906 (gnus-mime-display-alternative
4907 ',ihandles ',not-pref ',begend ,id))
4908 ,@(gnus-local-map-property gnus-mime-button-map)
4909 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4910 face ,gnus-article-button-face
4913 (widget-convert-button 'link from (point)
4914 :action 'gnus-widget-press-button
4915 :button-keymap gnus-widget-button-keymap)
4917 (while (setq handle (pop handles))
4918 (gnus-add-text-properties
4921 (insert (format "(%c) %-18s"
4922 (if (equal handle preferred) ?* ? )
4923 (mm-handle-media-type handle)))
4927 (unless ,(not ibegend)
4928 (setq gnus-article-mime-handle-alist
4929 ',gnus-article-mime-handle-alist))
4930 (gnus-mime-display-alternative
4931 ',ihandles ',handle ',begend ,id))
4932 ,@(gnus-local-map-property gnus-mime-button-map)
4933 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4934 face ,gnus-article-button-face
4937 (widget-convert-button 'link from (point)
4938 :action 'gnus-widget-press-button
4939 :button-keymap gnus-widget-button-keymap)
4943 (if (stringp (car preferred))
4944 (gnus-display-mime preferred)
4945 (let ((mail-parse-charset gnus-newsgroup-charset)
4946 (mail-parse-ignored-charsets
4947 (save-excursion (set-buffer gnus-summary-buffer)
4948 gnus-newsgroup-ignored-charsets)))
4949 (mm-display-part preferred)
4953 (narrow-to-region (car begend) (point-max))
4955 nil (length gnus-article-mime-handle-alist)
4956 (gnus-article-mime-total-parts)
4957 (mm-handle-media-type handle))))))
4958 (goto-char (point-max))
4959 (setcdr begend (point-marker)))))
4961 (goto-char point))))
4963 (defconst gnus-article-wash-status-strings
4964 (let ((alist '((cite "c" "Possible hidden citation text"
4965 " " "All citation text visible")
4966 (headers "h" "Hidden headers"
4967 " " "All headers visible.")
4968 (pgp "p" "Encrypted or signed message status hidden"
4969 " " "No hidden encryption nor digital signature status")
4970 (signature "s" "Signature has been hidden"
4971 " " "Signature is visible")
4972 (overstrike "o" "Overstrike (^H) characters applied"
4973 " " "No overstrike characters applied")
4974 (emphasis "e" "/*_Emphasis_*/ characters applied"
4975 " " "No /*_emphasis_*/ characters applied")))
4977 (dolist (entry alist result)
4978 (let ((key (nth 0 entry))
4979 (on (copy-sequence (nth 1 entry)))
4980 (on-help (nth 2 entry))
4981 (off (copy-sequence (nth 3 entry)))
4982 (off-help (nth 4 entry)))
4983 (put-text-property 0 1 'help-echo on-help on)
4984 (put-text-property 0 1 'help-echo off-help off)
4985 (push (list key on off) result))))
4986 "Alist of strings describing wash status in the mode line.
4987 Each entry has the form (KEY ON OF), where the KEY is a symbol
4988 representing the particular washing function, ON is the string to use
4989 in the article mode line when the washing function is active, and OFF
4990 is the string to use when it is inactive.")
4992 (defun gnus-article-wash-status-entry (key value)
4993 (let ((entry (assoc key gnus-article-wash-status-strings)))
4994 (if value (nth 1 entry) (nth 2 entry))))
4996 (defun gnus-article-wash-status ()
4997 "Return a string which display status of article washing."
4999 (set-buffer gnus-article-buffer)
5000 (let ((cite (memq 'cite gnus-article-wash-types))
5001 (headers (memq 'headers gnus-article-wash-types))
5002 (boring (memq 'boring-headers gnus-article-wash-types))
5003 (pgp (memq 'pgp gnus-article-wash-types))
5004 (pem (memq 'pem gnus-article-wash-types))
5005 (signed (memq 'signed gnus-article-wash-types))
5006 (encrypted (memq 'encrypted gnus-article-wash-types))
5007 (signature (memq 'signature gnus-article-wash-types))
5008 (overstrike (memq 'overstrike gnus-article-wash-types))
5009 (emphasis (memq 'emphasis gnus-article-wash-types)))
5011 (gnus-article-wash-status-entry 'cite cite)
5012 (gnus-article-wash-status-entry 'headers (or headers boring))
5013 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5014 (gnus-article-wash-status-entry 'signature signature)
5015 (gnus-article-wash-status-entry 'overstrike overstrike)
5016 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5018 (defun gnus-add-wash-type (type)
5019 "Add a washing of TYPE to the current status."
5020 (add-to-list 'gnus-article-wash-types type))
5022 (defun gnus-delete-wash-type (type)
5023 "Add a washing of TYPE to the current status."
5024 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5026 (defun gnus-add-image (category image)
5027 "Add IMAGE of CATEGORY to the list of displayed images."
5028 (let ((entry (assq category gnus-article-image-alist)))
5030 (setq entry (list category))
5031 (push entry gnus-article-image-alist))
5032 (nconc entry (list image))))
5034 (defun gnus-delete-images (category)
5035 "Delete all images in CATEGORY."
5036 (let ((entry (assq category gnus-article-image-alist)))
5037 (dolist (image (cdr entry))
5038 (gnus-remove-image image category))
5039 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5040 (gnus-delete-wash-type category)))
5042 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5044 (defun gnus-article-maybe-hide-headers ()
5045 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5046 Provided for backwards compatibility."
5047 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5048 (not (save-excursion (set-buffer gnus-summary-buffer)
5049 gnus-have-all-headers)))
5050 (not gnus-inhibit-hiding))
5051 (gnus-article-hide-headers)))
5055 (defun gnus-output-to-file (file-name)
5056 "Append the current article to a file named FILE-NAME."
5057 (let ((artbuf (current-buffer)))
5059 (insert-buffer-substring artbuf)
5060 ;; Append newline at end of the buffer as separator, and then
5062 (goto-char (point-max))
5064 (let ((file-name-coding-system nnmail-pathname-coding-system))
5065 (mm-append-to-file (point-min) (point-max) file-name))
5068 (defun gnus-narrow-to-page (&optional arg)
5069 "Narrow the article buffer to a page.
5070 If given a numerical ARG, move forward ARG pages."
5072 (setq arg (if arg (prefix-numeric-value arg) 0))
5074 (set-buffer gnus-article-buffer)
5075 (goto-char (point-min))
5077 ;; Remove any old next/prev buttons.
5078 (when (gnus-visual-p 'page-marker)
5079 (let ((inhibit-read-only t))
5080 (gnus-remove-text-with-property 'gnus-prev)
5081 (gnus-remove-text-with-property 'gnus-next)))
5084 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5086 (re-search-forward page-delimiter nil 'move arg)))
5087 (goto-char (match-end 0))
5089 (goto-char (point-min))
5090 (setq gnus-page-broken
5091 (and (re-search-forward page-delimiter nil t) t))))
5092 (when gnus-page-broken
5095 (if (re-search-forward page-delimiter nil 'move)
5098 (when (and (gnus-visual-p 'page-marker)
5099 (> (point-min) (save-restriction (widen) (point-min))))
5101 (goto-char (point-min))
5102 (gnus-insert-prev-page-button)))
5103 (when (and (gnus-visual-p 'page-marker)
5104 (< (point-max) (save-restriction (widen) (point-max))))
5106 (goto-char (point-max))
5107 (gnus-insert-next-page-button))))))
5109 ;; Article mode commands
5111 (defun gnus-article-goto-next-page ()
5112 "Show the next page of the article."
5114 (when (gnus-article-next-page)
5115 (goto-char (point-min))
5116 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5119 (defun gnus-article-goto-prev-page ()
5120 "Show the previous page of the article."
5123 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5124 (gnus-article-prev-page nil)))
5126 ;; This is cleaner but currently breaks `gnus-pick-mode':
5128 ;; (defun gnus-article-goto-next-page ()
5129 ;; "Show the next page of the article."
5131 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5132 ;; (gnus-summary-next-page)))
5134 ;; (defun gnus-article-goto-prev-page ()
5135 ;; "Show the next page of the article."
5137 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5138 ;; (gnus-summary-prev-page)))
5140 (defun gnus-article-next-page (&optional lines)
5141 "Show the next page of the current article.
5142 If end of article, return non-nil. Otherwise return nil.
5143 Argument LINES specifies lines to be scrolled up."
5145 (move-to-window-line -1)
5148 (and (pos-visible-in-window-p) ;Not continuation line.
5149 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5150 ;; Nothing in this page.
5151 (if (or (not gnus-page-broken)
5156 (eobp)))) ;Real end-of-buffer?
5158 (when gnus-article-over-scroll
5159 (gnus-article-next-page-1 lines))
5161 (gnus-narrow-to-page 1) ;Go to next page.
5163 ;; More in this page.
5164 (gnus-article-next-page-1 lines)
5167 (defun gnus-article-next-page-1 (lines)
5168 (let ((scroll-in-place nil))
5172 ;; Long lines may cause an end-of-buffer error.
5173 (goto-char (point-max)))))
5174 (move-to-window-line 0))
5176 (defun gnus-article-prev-page (&optional lines)
5177 "Show previous page of current article.
5178 Argument LINES specifies lines to be scrolled down."
5180 (move-to-window-line 0)
5181 (if (and gnus-page-broken
5183 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5185 (gnus-narrow-to-page -1) ;Go to previous page.
5186 (goto-char (point-max))
5188 (let ((scroll-in-place nil))
5192 (beginning-of-buffer
5193 (goto-char (point-min))))
5194 (move-to-window-line 0)))))
5196 (defun gnus-article-only-boring-p ()
5197 "Decide whether there is only boring text remaining in the article.
5198 Something \"interesting\" is a word of at least two letters that does
5199 not have a face in `gnus-article-boring-faces'."
5200 (when (and gnus-article-skip-boring
5201 (boundp 'gnus-article-boring-faces)
5202 (symbol-value 'gnus-article-boring-faces))
5205 (while (re-search-forward "\\b\\w\\w" nil t)
5207 (when (not (gnus-intersection
5208 (gnus-faces-at (point))
5209 (symbol-value 'gnus-article-boring-faces)))
5210 (throw 'only-boring nil)))
5211 (throw 'only-boring t)))))
5213 (defun gnus-article-refer-article ()
5214 "Read article specified by message-id around point."
5217 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5218 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5219 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5220 (let ((msg-id (concat "<" (match-string 0) ">")))
5221 (set-buffer gnus-summary-buffer)
5222 (gnus-summary-refer-article msg-id))
5223 (error "No references around point"))))
5225 (defun gnus-article-show-summary ()
5226 "Reconfigure windows to show summary buffer."
5228 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5229 (error "There is no summary buffer for this article buffer")
5230 (gnus-article-set-globals)
5231 (gnus-configure-windows 'article)
5232 (gnus-summary-goto-subject gnus-current-article)
5233 (gnus-summary-position-point)))
5235 (defun gnus-article-describe-briefly ()
5236 "Describe article mode commands briefly."
5238 (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")))
5240 (defun gnus-article-summary-command ()
5241 "Execute the last keystroke in the summary buffer."
5243 (let ((obuf (current-buffer))
5244 (owin (current-window-configuration))
5246 (switch-to-buffer gnus-article-current-summary 'norecord)
5247 (setq func (lookup-key (current-local-map) (this-command-keys)))
5248 (call-interactively func)
5250 (set-window-configuration owin)
5251 (set-window-point (get-buffer-window (current-buffer)) (point))))
5253 (defun gnus-article-summary-command-nosave ()
5254 "Execute the last keystroke in the summary buffer."
5257 (pop-to-buffer gnus-article-current-summary 'norecord)
5258 (setq func (lookup-key (current-local-map) (this-command-keys)))
5259 (call-interactively func)))
5261 (defun gnus-article-check-buffer ()
5262 "Beep if not in an article buffer."
5263 (unless (equal major-mode 'gnus-article-mode)
5264 (error "Command invoked outside of a Gnus article buffer")))
5266 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5267 "Read a summary buffer key sequence and execute it from the article buffer."
5269 (gnus-article-check-buffer)
5271 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5272 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5273 "=" "^" "\M-^" "|"))
5279 '("n" "Gn" "p" "Gp"))
5282 (set-buffer gnus-article-current-summary)
5283 (let (gnus-pick-mode)
5284 (push (or key last-command-event) unread-command-events)
5285 (setq keys (if (featurep 'xemacs)
5286 (events-to-keys (read-key-sequence nil))
5287 (read-key-sequence nil)))))
5291 (if (or (member keys nosaves)
5292 (member keys nosave-but-article)
5293 (member keys nosave-in-article))
5295 (save-window-excursion
5296 (pop-to-buffer gnus-article-current-summary 'norecord)
5297 ;; We disable the pick minor mode commands.
5298 (let (gnus-pick-mode)
5299 (setq func (lookup-key (current-local-map) keys))))
5303 (unless (member keys nosave-in-article)
5304 (set-buffer gnus-article-current-summary))
5305 (call-interactively func)
5306 (setq new-sum-point (point)))
5307 (when (member keys nosave-but-article)
5308 (pop-to-buffer gnus-article-buffer 'norecord)))
5309 ;; These commands should restore window configuration.
5310 (let ((obuf (current-buffer))
5311 (owin (current-window-configuration))
5313 win func in-buffer selected new-sum-start new-sum-hscroll)
5314 (cond (not-restore-window
5315 (pop-to-buffer gnus-article-current-summary 'norecord))
5316 ((setq win (get-buffer-window gnus-article-current-summary))
5317 (select-window win))
5319 (switch-to-buffer gnus-article-current-summary 'norecord)))
5320 (setq in-buffer (current-buffer))
5321 ;; We disable the pick minor mode commands.
5322 (if (and (setq func (let (gnus-pick-mode)
5323 (lookup-key (current-local-map) keys)))
5326 (call-interactively func)
5327 (when (eq win (selected-window))
5328 (setq new-sum-point (point)
5329 new-sum-start (window-start win)
5330 new-sum-hscroll (window-hscroll win)))
5331 (when (eq in-buffer (current-buffer))
5332 (setq selected (gnus-summary-select-article))
5334 (unless not-restore-window
5335 (set-window-configuration owin))
5336 (when (eq selected 'old)
5338 (set-window-start (get-buffer-window (current-buffer))
5340 (set-window-point (get-buffer-window (current-buffer))
5342 (when (and (not not-restore-window)
5344 (set-window-point win new-sum-point)
5345 (set-window-start win new-sum-start)
5346 (set-window-hscroll win new-sum-hscroll))))
5347 (set-window-configuration owin)
5350 (defun gnus-article-describe-key (key)
5351 "Display documentation of the function invoked by KEY. KEY is a string."
5352 (interactive "kDescribe key: ")
5353 (gnus-article-check-buffer)
5354 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5356 (set-buffer gnus-article-current-summary)
5357 (let (gnus-pick-mode)
5358 (if (featurep 'xemacs)
5360 (push (elt key 0) unread-command-events)
5361 (setq key (events-to-keys
5362 (read-key-sequence "Describe key: "))))
5363 (setq unread-command-events
5365 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5366 (string-to-list key)))
5367 (setq key (read-key-sequence "Describe key: "))))
5369 (describe-key key)))
5371 (defun gnus-article-describe-key-briefly (key &optional insert)
5372 "Display documentation of the function invoked by KEY. KEY is a string."
5373 (interactive "kDescribe key: \nP")
5374 (gnus-article-check-buffer)
5375 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5377 (set-buffer gnus-article-current-summary)
5378 (let (gnus-pick-mode)
5379 (if (featurep 'xemacs)
5381 (push (elt key 0) unread-command-events)
5382 (setq key (events-to-keys
5383 (read-key-sequence "Describe key: "))))
5384 (setq unread-command-events
5386 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5387 (string-to-list key)))
5388 (setq key (read-key-sequence "Describe key: "))))
5389 (describe-key-briefly key insert))
5390 (describe-key-briefly key insert)))
5392 (defun gnus-article-reply-with-original (&optional wide)
5393 "Start composing a reply mail to the current message.
5394 The text in the region will be yanked. If the region isn't active,
5395 the entire article will be yanked."
5397 (let ((article (cdr gnus-article-current))
5399 (if (not (gnus-mark-active-p))
5400 (with-current-buffer gnus-summary-buffer
5401 (gnus-summary-reply (list (list article)) wide))
5402 (setq contents (buffer-substring (point) (mark t)))
5403 ;; Deactivate active regions.
5404 (when (and (boundp 'transient-mark-mode)
5405 transient-mark-mode)
5406 (setq mark-active nil))
5407 (with-current-buffer gnus-summary-buffer
5409 (list (list article contents)) wide)))))
5411 (defun gnus-article-followup-with-original ()
5412 "Compose a followup to the current article.
5413 The text in the region will be yanked. If the region isn't active,
5414 the entire article will be yanked."
5416 (let ((article (cdr gnus-article-current))
5418 (if (not (gnus-mark-active-p))
5419 (with-current-buffer gnus-summary-buffer
5420 (gnus-summary-followup (list (list article))))
5421 (setq contents (buffer-substring (point) (mark t)))
5422 ;; Deactivate active regions.
5423 (when (and (boundp 'transient-mark-mode)
5424 transient-mark-mode)
5425 (setq mark-active nil))
5426 (with-current-buffer gnus-summary-buffer
5427 (gnus-summary-followup
5428 (list (list article contents)))))))
5430 (defun gnus-article-hide (&optional arg force)
5431 "Hide all the gruft in the current article.
5432 This means that signatures, cited text and (some) headers will be
5434 If given a prefix, show the hidden text instead."
5435 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5436 (gnus-article-hide-headers arg)
5437 (gnus-article-hide-list-identifiers arg)
5438 (gnus-article-hide-citation-maybe arg force)
5439 (gnus-article-hide-signature arg))
5441 (defun gnus-article-maybe-highlight ()
5442 "Do some article highlighting if article highlighting is requested."
5443 (when (gnus-visual-p 'article-highlight 'highlight)
5444 (gnus-article-highlight-some)))
5446 (defun gnus-check-group-server ()
5447 ;; Make sure the connection to the server is alive.
5448 (unless (gnus-server-opened
5449 (gnus-find-method-for-group gnus-newsgroup-name))
5450 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5451 (gnus-request-group gnus-newsgroup-name t)))
5454 (autoload 'nneething-get-file-name "nneething"))
5456 (defun gnus-request-article-this-buffer (article group)
5457 "Get an article and insert it into this buffer."
5458 (let (do-update-line sparse-header)
5462 (gnus-kill-all-overlays)
5463 (setq group (or group gnus-newsgroup-name))
5465 ;; Using `gnus-request-article' directly will insert the article into
5466 ;; `nntp-server-buffer' - so we'll save some time by not having to
5467 ;; copy it from the server buffer into the article buffer.
5469 ;; We only request an article by message-id when we do not have the
5470 ;; headers for it, so we'll have to get those.
5471 (when (stringp article)
5472 (gnus-read-header article))
5474 ;; If the article number is negative, that means that this article
5475 ;; doesn't belong in this newsgroup (possibly), so we find its
5476 ;; message-id and request it by id instead of number.
5477 (when (and (numberp article)
5479 (get-buffer gnus-summary-buffer)
5480 (gnus-buffer-exists-p gnus-summary-buffer))
5482 (set-buffer gnus-summary-buffer)
5483 (let ((header (gnus-summary-article-header article)))
5486 ((memq article gnus-newsgroup-sparse)
5487 ;; This is a sparse gap article.
5488 (setq do-update-line article)
5489 (setq article (mail-header-id header))
5490 (setq sparse-header (gnus-read-header article))
5491 (setq gnus-newsgroup-sparse
5492 (delq article gnus-newsgroup-sparse)))
5494 ;; It's a real article.
5495 (setq article (mail-header-id header)))
5497 ;; It is an extracted pseudo-article.
5498 (setq article 'pseudo)
5499 (gnus-request-pseudo-article header))))
5501 (let ((method (gnus-find-method-for-group
5502 gnus-newsgroup-name)))
5503 (when (and (eq (car method) 'nneething)
5505 (let ((dir (nneething-get-file-name
5506 (mail-header-id header))))
5507 (when (and (stringp dir)
5508 (file-directory-p dir))
5509 (setq article 'nneething)
5510 (gnus-group-enter-directory dir))))))))
5513 ;; Refuse to select canceled articles.
5514 ((and (numberp article)
5516 (get-buffer gnus-summary-buffer)
5517 (gnus-buffer-exists-p gnus-summary-buffer)
5518 (eq (cdr (save-excursion
5519 (set-buffer gnus-summary-buffer)
5520 (assq article gnus-newsgroup-reads)))
5521 gnus-canceled-mark))
5523 ;; We first check `gnus-original-article-buffer'.
5524 ((and (get-buffer gnus-original-article-buffer)
5527 (set-buffer gnus-original-article-buffer)
5528 (and (equal (car gnus-original-article) group)
5529 (eq (cdr gnus-original-article) article))))
5530 (insert-buffer-substring gnus-original-article-buffer)
5532 ;; Check the backlog.
5533 ((and gnus-keep-backlog
5534 (gnus-backlog-request-article group article (current-buffer)))
5536 ;; Check asynchronous pre-fetch.
5537 ((gnus-async-request-fetched-article group article (current-buffer))
5538 (gnus-async-prefetch-next group article gnus-summary-buffer)
5539 (when (and (numberp article) gnus-keep-backlog)
5540 (gnus-backlog-enter-article group article (current-buffer)))
5543 ((and gnus-use-cache
5545 (gnus-cache-request-article article group))
5547 ;; Check the agent cache.
5548 ((gnus-agent-request-article article group)
5550 ;; Get the article and put into the article buffer.
5551 ((or (stringp article)
5553 (let ((gnus-override-method gnus-override-method)
5554 (methods (and (stringp article)
5555 gnus-refer-article-method))
5556 (backend (car (gnus-find-method-for-group
5557 gnus-newsgroup-name)))
5559 (inhibit-read-only t))
5560 (if (or (not (listp methods))
5561 (and (symbolp (car methods))
5562 (assq (car methods) nnoo-definition-alist)))
5563 (setq methods (list methods)))
5564 (when (and (null gnus-override-method)
5566 (setq gnus-override-method (pop methods)))
5568 (when (eq gnus-override-method 'current)
5569 (setq gnus-override-method
5570 (with-current-buffer gnus-summary-buffer
5571 gnus-current-select-method)))
5573 (gnus-kill-all-overlays)
5574 (let ((gnus-newsgroup-name group))
5575 (gnus-check-group-server))
5577 ((gnus-request-article article group (current-buffer))
5578 (when (numberp article)
5579 (gnus-async-prefetch-next group article
5580 gnus-summary-buffer)
5581 (when gnus-keep-backlog
5582 (gnus-backlog-enter-article
5583 group article (current-buffer))))
5584 (setq result 'article))
5586 (setq gnus-override-method (pop methods)))
5587 ((not (string-match "^400 "
5588 (nnheader-get-report backend)))
5589 ;; If we get 400 server disconnect, reconnect and
5590 ;; retry; otherwise, assume the article has expired.
5591 (setq result 'done))))
5592 (and (eq result 'article) 'article)))
5596 ;; Associate this article with the current summary buffer.
5597 (setq gnus-article-current-summary gnus-summary-buffer)
5599 ;; Take the article from the original article buffer
5600 ;; and place it in the buffer it's supposed to be in.
5601 (when (and (get-buffer gnus-article-buffer)
5602 (equal (buffer-name (current-buffer))
5603 (buffer-name (get-buffer gnus-article-buffer))))
5605 (if (get-buffer gnus-original-article-buffer)
5606 (set-buffer gnus-original-article-buffer)
5607 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5608 (buffer-disable-undo)
5609 (setq major-mode 'gnus-original-article-mode)
5610 (setq buffer-read-only t))
5611 (let ((inhibit-read-only t))
5613 (insert-buffer-substring gnus-article-buffer))
5614 (setq gnus-original-article (cons group article)))
5617 (run-hooks 'gnus-article-decode-hook)
5618 ;; Mark article as decoded or not.
5619 (setq gnus-article-decoded-p gnus-article-decode-hook))
5621 ;; Update sparse articles.
5622 (when (and do-update-line
5623 (or (numberp article)
5625 (let ((buf (current-buffer)))
5626 (set-buffer gnus-summary-buffer)
5627 (gnus-summary-update-article do-update-line sparse-header)
5628 (gnus-summary-goto-subject do-update-line nil t)
5629 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5631 (set-buffer buf))))))
5637 (defcustom gnus-article-edit-mode-hook nil
5638 "Hook run in article edit mode buffers."
5639 :group 'gnus-article-various
5642 (defvar gnus-article-edit-done-function nil)
5644 (defvar gnus-article-edit-mode-map nil)
5645 (defvar gnus-article-edit-mode nil)
5647 ;; Should we be using derived.el for this?
5648 (unless gnus-article-edit-mode-map
5649 (setq gnus-article-edit-mode-map (make-keymap))
5650 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5652 (gnus-define-keys gnus-article-edit-mode-map
5653 "\C-c?" describe-mode
5654 "\C-c\C-c" gnus-article-edit-done
5655 "\C-c\C-k" gnus-article-edit-exit
5656 "\C-c\C-f\C-t" message-goto-to
5657 "\C-c\C-f\C-o" message-goto-from
5658 "\C-c\C-f\C-b" message-goto-bcc
5659 ;;"\C-c\C-f\C-w" message-goto-fcc
5660 "\C-c\C-f\C-c" message-goto-cc
5661 "\C-c\C-f\C-s" message-goto-subject
5662 "\C-c\C-f\C-r" message-goto-reply-to
5663 "\C-c\C-f\C-n" message-goto-newsgroups
5664 "\C-c\C-f\C-d" message-goto-distribution
5665 "\C-c\C-f\C-f" message-goto-followup-to
5666 "\C-c\C-f\C-m" message-goto-mail-followup-to
5667 "\C-c\C-f\C-k" message-goto-keywords
5668 "\C-c\C-f\C-u" message-goto-summary
5669 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5670 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5671 "\C-c\C-b" message-goto-body
5672 "\C-c\C-i" message-goto-signature
5674 "\C-c\C-t" message-insert-to
5675 "\C-c\C-n" message-insert-newsgroups
5676 "\C-c\C-o" message-sort-headers
5677 "\C-c\C-e" message-elide-region
5678 "\C-c\C-v" message-delete-not-region
5679 "\C-c\C-z" message-kill-to-signature
5680 "\M-\r" message-newline-and-reformat
5681 "\C-c\C-a" mml-attach-file
5682 "\C-a" message-beginning-of-line
5684 "\M-;" comment-region)
5686 (gnus-define-keys (gnus-article-edit-wash-map
5687 "\C-c\C-w" gnus-article-edit-mode-map)
5688 "f" gnus-article-edit-full-stops))
5691 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5693 ["Fetch To" message-insert-to t]
5694 ["Fetch Newsgroups" message-insert-newsgroups t]
5696 ["To" message-goto-to t]
5697 ["From" message-goto-from t]
5698 ["Subject" message-goto-subject t]
5699 ["Cc" message-goto-cc t]
5700 ["Reply-To" message-goto-reply-to t]
5701 ["Summary" message-goto-summary t]
5702 ["Keywords" message-goto-keywords t]
5703 ["Newsgroups" message-goto-newsgroups t]
5704 ["Followup-To" message-goto-followup-to t]
5705 ["Mail-Followup-To" message-goto-mail-followup-to t]
5706 ["Distribution" message-goto-distribution t]
5707 ["Body" message-goto-body t]
5708 ["Signature" message-goto-signature t]))
5710 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5711 "Major mode for editing articles.
5712 This is an extended text-mode.
5714 \\{gnus-article-edit-mode-map}"
5715 (make-local-variable 'gnus-article-edit-done-function)
5716 (make-local-variable 'gnus-prev-winconf)
5717 (set (make-local-variable 'font-lock-defaults)
5718 '(message-font-lock-keywords t))
5719 (set (make-local-variable 'mail-header-separator) "")
5720 (set (make-local-variable 'gnus-article-edit-mode) t)
5721 (easy-menu-add message-mode-field-menu message-mode-map)
5723 (setq buffer-read-only nil)
5724 (buffer-enable-undo)
5727 (defun gnus-article-edit (&optional force)
5728 "Edit the current article.
5729 This will have permanent effect only in mail groups.
5730 If FORCE is non-nil, allow editing of articles even in read-only
5733 (when (and (not force)
5734 (gnus-group-read-only-p))
5735 (error "The current newsgroup does not support article editing"))
5736 (gnus-article-date-original)
5737 (gnus-article-edit-article
5739 `(lambda (no-highlight)
5741 (gnus-summary-edit-article-done
5742 ,(or (mail-header-references gnus-current-headers) "")
5743 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5745 (defun gnus-article-edit-article (start-func exit-func)
5746 "Start editing the contents of the current article buffer."
5747 (let ((winconf (current-window-configuration)))
5748 (set-buffer gnus-article-buffer)
5749 (let ((message-auto-save-directory
5750 ;; Don't associate the article buffer with a draft file.
5752 (gnus-article-edit-mode))
5753 (funcall start-func)
5754 (set-buffer-modified-p nil)
5755 (gnus-configure-windows 'edit-article)
5756 (setq gnus-article-edit-done-function exit-func)
5757 (setq gnus-prev-winconf winconf)
5758 (gnus-message 6 "C-c C-c to end edits")))
5760 (defun gnus-article-edit-done (&optional arg)
5761 "Update the article edits and exit."
5763 (let ((func gnus-article-edit-done-function)
5764 (buf (current-buffer))
5765 (start (window-start))
5767 (winconf gnus-prev-winconf))
5768 (widen) ;; Widen it in case that users narrowed the buffer.
5771 ;; The cache and backlog have to be flushed somewhat.
5772 (when gnus-keep-backlog
5773 (gnus-backlog-remove-article
5774 (car gnus-article-current) (cdr gnus-article-current)))
5775 ;; Flush original article as well.
5777 (when (get-buffer gnus-original-article-buffer)
5778 (set-buffer gnus-original-article-buffer)
5779 (setq gnus-original-article nil)))
5780 (when gnus-use-cache
5781 (gnus-cache-update-article
5782 (car gnus-article-current) (cdr gnus-article-current)))
5783 ;; We remove all text props from the article buffer.
5784 (kill-all-local-variables)
5785 (gnus-set-text-properties (point-min) (point-max) nil)
5787 (set-window-configuration winconf)
5789 (set-window-start (get-buffer-window buf) start)
5790 (set-window-point (get-buffer-window buf) (point)))
5791 (gnus-summary-show-article))
5793 (defun gnus-article-edit-exit ()
5794 "Exit the article editing without updating."
5796 (when (or (not (buffer-modified-p))
5797 (yes-or-no-p "Article modified; kill anyway? "))
5798 (let ((curbuf (current-buffer))
5800 (window-start (window-start)))
5802 (if (gnus-buffer-live-p gnus-original-article-buffer)
5803 (insert-buffer gnus-original-article-buffer))
5804 (let ((winconf gnus-prev-winconf))
5805 (kill-all-local-variables)
5807 (set-window-configuration winconf)
5808 ;; Tippy-toe some to make sure that point remains where it was.
5809 (save-current-buffer
5811 (set-window-start (get-buffer-window (current-buffer)) window-start)
5813 (gnus-summary-show-article)))
5815 (defun gnus-article-edit-full-stops ()
5816 "Interactively repair spacing at end of sentences."
5819 (goto-char (point-min))
5820 (search-forward-regexp "^$" nil t)
5821 (let ((case-fold-search nil))
5822 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5825 ;;; Article highlights
5828 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5830 ;;; Internal Variables:
5832 (defcustom gnus-button-url-regexp
5833 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5834 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~%&*+\\/[:word:]]\\)"
5835 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)\\)")
5836 "Regular expression that matches URLs."
5837 :group 'gnus-article-buttons
5840 (defcustom gnus-button-valid-fqdn-regexp
5841 message-valid-fqdn-regexp
5842 "Regular expression that matches a valid FQDN."
5844 :group 'gnus-article-buttons
5847 (defcustom gnus-button-man-handler 'manual-entry
5848 "Function to use for displaying man pages.
5849 The function must take at least one argument with a string naming the
5852 :type '(choice (function-item :tag "Man" manual-entry)
5853 (function-item :tag "Woman" woman)
5854 (function :tag "Other"))
5855 :group 'gnus-article-buttons)
5857 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5858 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5859 If the default site is too slow, try to find a CTAN mirror, see
5860 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5861 the variable `gnus-button-handle-ctan'."
5863 :group 'gnus-article-buttons
5864 :link '(custom-manual "(gnus)Group Parameters")
5865 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5866 (const "http://tug.ctan.org/tex-archive/")
5867 (const "http://www.dante.de/CTAN/")
5868 (string :tag "Other")))
5870 (defcustom gnus-button-ctan-handler 'browse-url
5871 "Function to use for displaying CTAN links.
5872 The function must take one argument, the string naming the URL."
5874 :type '(choice (function-item :tag "Browse Url" browse-url)
5875 (function :tag "Other"))
5876 :group 'gnus-article-buttons)
5878 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5879 "Bogus strings removed from CTAN URLs."
5881 :group 'gnus-article-buttons
5882 :type '(choice (const "^/?tex-archive/\\|/")
5883 (regexp :tag "Other")))
5885 (defcustom gnus-button-ctan-directory-regexp
5887 "\\("; Cannot use `\(?: ... \)' (compatibility with Emacs 20).
5888 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5889 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5890 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5892 "Regular expression for ctan directories.
5893 It should match all directories in the top level of `gnus-ctan-url'."
5895 :group 'gnus-article-buttons
5898 (defcustom gnus-button-mid-or-mail-regexp
5899 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
5900 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5901 gnus-button-valid-fqdn-regexp
5903 "Regular expression that matches a message ID or a mail address."
5905 :group 'gnus-article-buttons
5908 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5909 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5910 Strings like this can be either a message ID or a mail address. If it is one
5911 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5912 message ID or a mail address, respectively. If this variable is set to the
5913 symbol `ask', always query the user what do do. If it is a function, this
5914 function will be called with the string as it's only argument. The function
5915 must return `mid', `mail', `invalid' or `ask'."
5917 :group 'gnus-article-buttons
5918 :type '(choice (function-item :tag "Heuristic function"
5919 gnus-button-mid-or-mail-heuristic)
5924 (defcustom gnus-button-mid-or-mail-heuristic-alist
5925 '((-10.0 . ".+\\$.+@")
5928 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5929 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5930 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5931 (-1.0 . "^[^a-z]+@")
5933 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5934 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5935 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5936 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5939 (-1.0 . "^[0-9][0-9]")
5941 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5942 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5943 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5944 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5946 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5947 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5950 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5952 ;; compensation for TDMA dated mail addresses:
5953 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5955 (-20.0 . "\\.fsf@") ;; Gnus
5958 (-20.0 . "_-_") ;; Subject change in thread
5960 (-20.0 . "\\.ln@") ;; leafnode
5961 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5962 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5964 ;; (5.0 . "") ;; $local_part_len <= 7
5965 (10.0 . "^[^0-9]+@")
5966 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5967 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5970 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5972 (0.5 . "^[A-Z][a-z]")
5973 (0.5 . "^[A-Z][a-z][a-z]")
5974 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5975 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5976 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5978 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5979 address. The REGEXP is processed with `case-fold-search' set to nil."
5981 :group 'gnus-article-buttons
5982 :type '(repeat (cons (number :tag "Rate")
5983 (regexp :tag "Regexp"))))
5985 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5986 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5987 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5988 address, `ask' if unsure and `invalid' if the string is invalid."
5989 (let ((case-fold-search nil)
5990 (list gnus-button-mid-or-mail-heuristic-alist)
5991 (result 0) rate regexp lpartlen elem)
5993 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5994 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5995 ;; Certain special cases...
5998 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
5999 "^[0-9]+\\.[0-9]+@compuserve\\|"
6000 "@public\\.gmane\\.org")
6002 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6003 (setq result 'mail))
6004 (when (string-match "@.*@\\| " mid-or-mail)
6005 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6006 (setq result 'invalid))
6007 ;; Nothing more to do, if result is not a number here...
6008 (when (numberp result)
6010 (setq elem (car list)
6014 (when (string-match regexp mid-or-mail)
6015 (setq result (+ result rate))
6017 9 "`%s' matched `%s', rate `%s', result `%s'."
6018 mid-or-mail regexp rate result)))
6019 (when (<= lpartlen 7)
6020 (setq result (+ result 5.0))
6021 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6022 mid-or-mail result))
6023 (when (>= lpartlen 12)
6024 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6026 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6027 ;; Long local part should contain realname if e-mail address,
6028 ;; too many digits: message-id.
6029 ;; $score -= 5.0 + 0.1 * $local_part_len;
6030 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6031 (setq result (+ result rate))
6033 9 "Many digits in `%s', rate `%s', result `%s'."
6034 mid-or-mail rate result))
6035 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6037 ;; Too few vowels [^aeiouy]{4,}.*\@
6038 (setq result (+ result -5.0))
6040 9 "Few vowels in `%s', rate `%s', result `%s'."
6041 mid-or-mail -5.0 result))
6043 (setq result (+ result 5.0))
6045 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6046 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6047 ;; Maybe we should make this a customizable alist: (condition . 'result)
6049 ((symbolp result) result)
6050 ;; Now convert number into proper results:
6051 ((< result -10.0) 'mid)
6052 ((> result 10.0) 'mail)
6055 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6056 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6057 (url-mid (concat "news" ":" mid-or-mail))
6058 (url-mailto (concat "mailto" ":" mid-or-mail)))
6059 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6060 (when (fboundp pref)
6062 ;; get rid of surrounding angles...
6064 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6065 (if (or (eq 'mid guessed) (eq 'mail guessed))
6069 (save-window-excursion
6070 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6073 (cond ((eq pref 'mid)
6074 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6075 (gnus-button-handle-news url-mid))
6077 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6078 (gnus-url-mailto url-mailto))
6079 (t (gnus-message 3 "Invalid string.")))))
6081 (defun gnus-button-handle-custom (url)
6082 "Follow a Custom URL."
6083 (customize-apropos (gnus-url-unhex-string url)))
6085 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6087 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6090 (defun gnus-button-handle-describe-function (url)
6091 "Call `describe-function' when pushing the corresponding URL button."
6094 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6096 (defun gnus-button-handle-describe-variable (url)
6097 "Call `describe-variable' when pushing the corresponding URL button."
6100 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6102 (defun gnus-button-handle-symbol (url)
6103 "Display help on variable or function.
6104 Calls `describe-variable' or `describe-function'."
6105 (let ((sym (intern url)))
6107 ((fboundp sym) (describe-function sym))
6108 ((boundp sym) (describe-variable sym))
6109 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6111 (defun gnus-button-handle-describe-key (url)
6112 "Call `describe-key' when pushing the corresponding URL button."
6114 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6115 (keys (ignore-errors (eval `(kbd ,key-string)))))
6118 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6120 (defun gnus-button-handle-apropos (url)
6121 "Call `apropos' when pushing the corresponding URL button."
6122 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6124 (defun gnus-button-handle-apropos-command (url)
6125 "Call `apropos' when pushing the corresponding URL button."
6127 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6129 (defun gnus-button-handle-apropos-variable (url)
6130 "Call `apropos' when pushing the corresponding URL button."
6132 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6133 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6135 (defun gnus-button-handle-apropos-documentation (url)
6136 "Call `apropos' when pushing the corresponding URL button."
6138 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6139 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6141 (defun gnus-button-handle-library (url)
6142 "Call `locate-library' when pushing the corresponding URL button."
6143 (gnus-message 9 "url=`%s'" url)
6144 (let* ((lib (locate-library url))
6145 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6147 (gnus-message 1 "Cannot locale library `%s'." url)
6148 (find-file-read-only file))))
6150 (defun gnus-button-handle-ctan (url)
6151 "Call `browse-url' when pushing a CTAN URL button."
6153 gnus-button-ctan-handler
6156 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6158 (defcustom gnus-button-tex-level 5
6159 "*Integer that says how many TeX-related buttons Gnus will show.
6160 The higher the number, the more buttons will appear and the more false
6161 positives are possible. Note that you can set this variable local to
6162 specific groups. Setting it higher in TeX groups is probably a good idea.
6163 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6164 how to set variables in specific groups."
6166 :group 'gnus-article-buttons
6167 :link '(custom-manual "(gnus)Group Parameters")
6170 (defcustom gnus-button-man-level 5
6171 "*Integer that says how many man-related buttons Gnus will show.
6172 The higher the number, the more buttons will appear and the more false
6173 positives are possible. Note that you can set this variable local to
6174 specific groups. Setting it higher in Unix groups is probably a good idea.
6175 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6176 how to set variables in specific groups."
6178 :group 'gnus-article-buttons
6179 :link '(custom-manual "(gnus)Group Parameters")
6182 (defcustom gnus-button-emacs-level 5
6183 "*Integer that says how many emacs-related buttons Gnus will show.
6184 The higher the number, the more buttons will appear and the more false
6185 positives are possible. Note that you can set this variable local to
6186 specific groups. Setting it higher in Emacs or Gnus related groups is
6187 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6188 `gnus-parameters' on how to set variables in specific groups."
6190 :group 'gnus-article-buttons
6191 :link '(custom-manual "(gnus)Group Parameters")
6194 (defcustom gnus-button-message-level 5
6195 "*Integer that says how many buttons for news or mail messages will appear.
6196 The higher the number, the more buttons will appear and the more false
6197 positives are possible."
6198 ;; mail addresses, MIDs, URLs for news, ...
6200 :group 'gnus-article-buttons
6203 (defcustom gnus-button-browse-level 5
6204 "*Integer that says how many buttons for browsing will appear.
6205 The higher the number, the more buttons will appear and the more false
6206 positives are possible."
6207 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6209 :group 'gnus-article-buttons
6212 (defcustom gnus-button-alist
6213 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6214 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6215 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6216 gnus-button-handle-news 2)
6217 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6218 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6219 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6220 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6221 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6222 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6223 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6224 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6225 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6226 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6227 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6228 ;; RFC 2368 (The mailto URL scheme)
6229 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6230 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6231 ("\\bmailto:\\([^ \n\t]+\\)"
6232 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6234 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6235 gnus-button-ctan-directory-regexp
6236 "[^][>)!;:,'\n\t ]+\\)")
6237 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6238 ((concat "\\btex-archive/\\("
6239 gnus-button-ctan-directory-regexp
6240 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6241 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6244 gnus-button-ctan-directory-regexp
6245 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6246 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6247 ;; This is info (home-grown style) <info://foo/bar+baz>
6248 ("\\binfo://\\([^'\">\n\t ]+\\)"
6249 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6250 ;; Info GNOME style <info:foo#bar_baz>
6251 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6252 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6253 ;; Info KDE style <info:(foo)bar baz>
6254 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6255 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6256 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6257 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6258 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6259 ;; Info links like `C-h i d m CC Mode RET'
6260 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6262 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6263 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6264 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6265 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6266 ;; Emacs help commands
6267 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6268 ;; regexp doesn't match arguments containing ` '.
6269 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6270 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6271 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6272 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6273 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6274 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6275 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6276 ;; The following entries may lead to many false positives so don't enable
6277 ;; them by default (use a high button level).
6278 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6279 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6280 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6281 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6282 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6283 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6284 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6285 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6286 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6287 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6288 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6289 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6290 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6291 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6292 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6293 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6294 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6295 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6296 ;; Unlike the other regexps we really have to require quoting
6297 ;; here to determine where it ends.
6298 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6299 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6300 ("<URL: *\\([^<>]*\\)>"
6301 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6302 ;; RFC 2396 (2.4.3., delims) ...
6303 ("\"URL: *\\([^\"]*\\)\""
6304 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6305 ;; RFC 2396 (2.4.3., delims) ...
6306 ("\"URL: *\\([^\"]*\\)\""
6307 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6309 (gnus-button-url-regexp
6310 0 (>= gnus-button-browse-level 0) browse-url 0)
6312 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6313 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6314 gnus-button-handle-man 1)
6315 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6316 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6317 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6318 gnus-button-handle-man 1)
6319 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6320 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6321 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6322 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6323 ;; MID or mail: To avoid too many false positives we don't try to catch
6324 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6325 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6326 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6327 ;; so that non-ambiguous entries (see above) match first.
6328 (gnus-button-mid-or-mail-regexp
6329 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6330 "*Alist of regexps matching buttons in article bodies.
6332 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6333 REGEXP: is the string (case insensitive) matching text around the button (can
6334 also be Lisp expression evaluating to a string),
6335 BUTTON: is the number of the regexp grouping actually matching the button,
6336 FORM: is a Lisp expression which must eval to true for the button to
6338 CALLBACK: is the function to call when the user push this button, and each
6339 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6341 CALLBACK can also be a variable, in that case the value of that
6342 variable it the real callback function."
6343 :group 'gnus-article-buttons
6344 :type '(repeat (list (choice regexp variable sexp)
6345 (integer :tag "Button")
6347 (function :tag "Callback")
6350 (integer :tag "Regexp group")))))
6352 (defcustom gnus-header-button-alist
6353 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6354 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6355 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6356 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6357 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6358 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6359 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6360 0 (>= gnus-button-browse-level 0) browse-url 0)
6361 ("^Subject:" gnus-button-url-regexp
6362 0 (>= gnus-button-browse-level 0) browse-url 0)
6363 ("^[^:]+:" gnus-button-url-regexp
6364 0 (>= gnus-button-browse-level 0) browse-url 0)
6365 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6366 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6367 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6368 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6369 "*Alist of headers and regexps to match buttons in article heads.
6371 This alist is very similar to `gnus-button-alist', except that each
6372 alist has an additional HEADER element first in each entry:
6374 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6376 HEADER is a regexp to match a header. For a fuller explanation, see
6377 `gnus-button-alist'."
6378 :group 'gnus-article-buttons
6379 :group 'gnus-article-headers
6380 :type '(repeat (list (regexp :tag "Header")
6381 (choice regexp variable)
6382 (integer :tag "Button")
6384 (function :tag "Callback")
6387 (integer :tag "Regexp group")))))
6389 (defvar gnus-button-regexp nil)
6390 (defvar gnus-button-marker-list nil)
6391 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6393 (defvar gnus-button-last nil)
6394 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6398 (defun gnus-article-push-button (event)
6399 "Check text under the mouse pointer for a callback function.
6400 If the text under the mouse pointer has a `gnus-callback' property,
6401 call it with the value of the `gnus-data' text property."
6403 (set-buffer (window-buffer (posn-window (event-start event))))
6404 (let* ((pos (posn-point (event-start event)))
6405 (data (get-text-property pos 'gnus-data))
6406 (fun (get-text-property pos 'gnus-callback)))
6409 (funcall fun data))))
6411 (defun gnus-article-press-button ()
6412 "Check text at point for a callback function.
6413 If the text at point has a `gnus-callback' property,
6414 call it with the value of the `gnus-data' text property."
6416 (let ((data (get-text-property (point) 'gnus-data))
6417 (fun (get-text-property (point) 'gnus-callback)))
6419 (funcall fun data))))
6421 (defun gnus-article-highlight (&optional force)
6422 "Highlight current article.
6423 This function calls `gnus-article-highlight-headers',
6424 `gnus-article-highlight-citation',
6425 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6426 do the highlighting. See the documentation for those functions."
6427 (interactive (list 'force))
6428 (gnus-article-highlight-headers)
6429 (gnus-article-highlight-citation force)
6430 (gnus-article-highlight-signature)
6431 (gnus-article-add-buttons force)
6432 (gnus-article-add-buttons-to-head))
6434 (defun gnus-article-highlight-some (&optional force)
6435 "Highlight current article.
6436 This function calls `gnus-article-highlight-headers',
6437 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6438 do the highlighting. See the documentation for those functions."
6439 (interactive (list 'force))
6440 (gnus-article-highlight-headers)
6441 (gnus-article-highlight-signature)
6442 (gnus-article-add-buttons))
6444 (defun gnus-article-highlight-headers ()
6445 "Highlight article headers as specified by `gnus-header-face-alist'."
6448 (set-buffer gnus-article-buffer)
6450 (let ((alist gnus-header-face-alist)
6451 (inhibit-read-only t)
6452 (case-fold-search t)
6453 (inhibit-point-motion-hooks t)
6454 entry regexp header-face field-face from hpoints fpoints)
6455 (article-narrow-to-head)
6456 (while (setq entry (pop alist))
6457 (goto-char (point-min))
6458 (setq regexp (concat "^\\("
6459 (if (string-equal "" (nth 0 entry))
6463 header-face (nth 1 entry)
6464 field-face (nth 2 entry))
6465 (while (and (re-search-forward regexp nil t)
6469 (unless (search-forward ":" nil t)
6471 (when (and header-face
6472 (not (memq (point) hpoints)))
6473 (push (point) hpoints)
6474 (gnus-put-text-property from (point) 'face header-face))
6475 (when (and field-face
6476 (not (memq (setq from (point)) fpoints)))
6478 (if (re-search-forward "^[^ \t]" nil t)
6480 (goto-char (point-max)))
6481 (gnus-put-text-property from (point) 'face field-face))))))))
6483 (defun gnus-article-highlight-signature ()
6484 "Highlight the signature in an article.
6485 It does this by highlighting everything after
6486 `gnus-signature-separator' using `gnus-signature-face'."
6489 (set-buffer gnus-article-buffer)
6490 (let ((inhibit-read-only t)
6491 (inhibit-point-motion-hooks t))
6493 (when (and gnus-signature-face
6494 (gnus-article-narrow-to-signature))
6495 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6496 'face gnus-signature-face)
6498 (gnus-article-search-signature)
6499 (let ((start (match-beginning 0))
6500 (end (set-marker (make-marker) (1+ (match-end 0)))))
6501 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6504 (defun gnus-button-in-region-p (b e prop)
6505 "Say whether PROP exists in the region."
6506 (text-property-not-all b e prop nil))
6508 (defun gnus-article-add-buttons (&optional force)
6509 "Find external references in the article and make buttons of them.
6510 \"External references\" are things like Message-IDs and URLs, as
6511 specified by `gnus-button-alist'."
6512 (interactive (list 'force))
6514 (set-buffer gnus-article-buffer)
6515 (let ((inhibit-read-only t)
6516 (inhibit-point-motion-hooks t)
6517 (case-fold-search t)
6518 (alist gnus-button-alist)
6520 ;; Remove all old markers.
6521 (let (marker entry new-list)
6522 (while (setq marker (pop gnus-button-marker-list))
6523 (if (or (< marker (point-min)) (>= marker (point-max)))
6524 (push marker new-list)
6526 (when (setq entry (gnus-button-entry))
6527 (put-text-property (match-beginning (nth 1 entry))
6528 (match-end (nth 1 entry))
6529 'gnus-callback nil))
6530 (set-marker marker nil)))
6531 (setq gnus-button-marker-list new-list))
6532 ;; We skip the headers.
6535 (while (setq entry (pop alist))
6536 (setq regexp (eval (car entry)))
6538 (while (re-search-forward regexp nil t)
6539 (let* ((start (and entry (match-beginning (nth 1 entry))))
6540 (end (and entry (match-end (nth 1 entry))))
6541 (from (match-beginning 0)))
6542 (when (and (or (eq t (nth 2 entry))
6543 (eval (nth 2 entry)))
6544 (not (gnus-button-in-region-p
6545 start end 'gnus-callback)))
6546 ;; That optional form returned non-nil, so we add the
6548 (gnus-article-add-button
6549 start end 'gnus-button-push
6550 (car (push (set-marker (make-marker) from)
6551 gnus-button-marker-list))))))))))
6553 ;; Add buttons to the head of an article.
6554 (defun gnus-article-add-buttons-to-head ()
6555 "Add buttons to the head of the article."
6558 (set-buffer gnus-article-buffer)
6560 (let ((inhibit-read-only t)
6561 (inhibit-point-motion-hooks t)
6562 (case-fold-search t)
6563 (alist gnus-header-button-alist)
6565 (article-narrow-to-head)
6567 ;; Each alist entry.
6568 (setq entry (car alist)
6570 (goto-char (point-min))
6571 (while (re-search-forward (car entry) nil t)
6572 ;; Each header matching the entry.
6573 (setq beg (match-beginning 0))
6574 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6575 (match-beginning 0))
6578 (while (re-search-forward (eval (nth 1 entry)) end t)
6579 ;; Each match within a header.
6580 (let* ((entry (cdr entry))
6581 (start (match-beginning (nth 1 entry)))
6582 (end (match-end (nth 1 entry)))
6583 (form (nth 2 entry)))
6584 (goto-char (match-end 0))
6586 (gnus-article-add-button
6587 start end (nth 3 entry)
6588 (buffer-substring (match-beginning (nth 4 entry))
6589 (match-end (nth 4 entry)))))))
6590 (goto-char end)))))))
6592 ;;; External functions:
6594 (defun gnus-article-add-button (from to fun &optional data)
6595 "Create a button between FROM and TO with callback FUN and data DATA."
6596 (when gnus-article-button-face
6597 (gnus-overlay-put (gnus-make-overlay from to)
6598 'face gnus-article-button-face))
6599 (gnus-add-text-properties
6601 (nconc (and gnus-article-mouse-face
6602 (list gnus-mouse-face-prop gnus-article-mouse-face))
6603 (list 'gnus-callback fun)
6604 (and data (list 'gnus-data data))))
6605 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6606 :button-keymap gnus-widget-button-keymap))
6608 ;;; Internal functions:
6610 (defun gnus-article-set-globals ()
6612 (set-buffer gnus-summary-buffer)
6613 (gnus-set-global-variables)))
6615 (defun gnus-signature-toggle (end)
6617 (set-buffer gnus-article-buffer)
6618 (let ((inhibit-read-only t)
6619 (inhibit-point-motion-hooks t))
6620 (if (text-property-any end (point-max) 'article-type 'signature)
6622 (gnus-delete-wash-type 'signature)
6623 (gnus-remove-text-properties-when
6624 'article-type 'signature end (point-max)
6625 (cons 'article-type (cons 'signature
6626 gnus-hidden-properties))))
6627 (gnus-add-wash-type 'signature)
6628 (gnus-add-text-properties-when
6629 'article-type nil end (point-max)
6630 (cons 'article-type (cons 'signature
6631 gnus-hidden-properties)))))
6632 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6633 (gnus-set-mode-line 'article))))
6635 (defun gnus-button-entry ()
6636 ;; Return the first entry in `gnus-button-alist' matching this place.
6637 (let ((alist gnus-button-alist)
6640 (setq entry (pop alist))
6641 (if (looking-at (eval (car entry)))
6646 (defun gnus-button-push (marker)
6647 ;; Push button starting at MARKER.
6650 (let* ((entry (gnus-button-entry))
6651 (inhibit-point-motion-hooks t)
6653 (args (mapcar (lambda (group)
6654 (let ((string (match-string group)))
6655 (gnus-set-text-properties
6656 0 (length string) nil string)
6663 (fboundp (symbol-value fun)))
6664 (apply (symbol-value fun) args))
6666 (gnus-message 1 "You must define `%S' to use this button"
6667 (cons fun args)))))))
6669 (defun gnus-parse-news-url (url)
6670 (let (scheme server port group message-id articles)
6673 (goto-char (point-min))
6674 (when (looking-at "\\([A-Za-z]+\\):")
6675 (setq scheme (match-string 1))
6676 (goto-char (match-end 0)))
6677 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
6678 (setq server (match-string 1))
6679 (setq port (if (stringp (match-string 3))
6680 (string-to-number (match-string 3))
6682 (goto-char (match-end 0)))
6685 ((looking-at "\\(.*@.*\\)")
6686 (setq message-id (match-string 1)))
6687 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6688 (setq group (match-string 1)
6689 articles (split-string (match-string 2) "-")))
6690 ((looking-at "\\([^/]+\\)/?")
6691 (setq group (match-string 1)))
6693 (error "Unknown news URL syntax"))))
6694 (list scheme server port group message-id articles)))
6696 (defun gnus-button-handle-news (url)
6698 (destructuring-bind (scheme server port group message-id articles)
6699 (gnus-parse-news-url url)
6703 (set-buffer gnus-summary-buffer)
6705 (let ((gnus-refer-article-method
6706 (nconc (list (list 'nntp server))
6707 gnus-refer-article-method))
6708 (nntp-port-number (or port "nntp")))
6709 (gnus-message 7 "Fetching %s with %s"
6710 message-id gnus-refer-article-method)
6711 (gnus-summary-refer-article message-id))
6712 (gnus-summary-refer-article message-id))))
6714 (gnus-button-fetch-group url)))))
6716 (defun gnus-button-handle-man (url)
6718 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6719 (when (eq gnus-button-man-handler 'woman)
6720 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
6721 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6722 (funcall gnus-button-man-handler url))
6724 (defun gnus-button-handle-info-url (url)
6725 "Fetch an info URL."
6726 (setq url (mm-subst-char-in-string ?+ ?\ url))
6728 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6729 (gnus-info-find-node
6730 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6732 ")" (gnus-url-unhex-string (match-string 2 url)))))
6733 ((string-match "([^)\"]+)[^\"]+" url)
6735 (gnus-replace-in-string
6736 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6737 (gnus-info-find-node url))
6738 (t (error "Can't parse %s" url))))
6740 (defun gnus-button-handle-info-url-gnome (url)
6741 "Fetch GNOME style info URL."
6742 (setq url (mm-subst-char-in-string ?_ ?\ url))
6743 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6744 (gnus-info-find-node
6746 (gnus-url-unhex-string
6747 (match-string 1 url))
6749 (or (gnus-url-unhex-string
6750 (match-string 2 url))
6752 (error "Can't parse %s" url)))
6754 (defun gnus-button-handle-info-url-kde (url)
6755 "Fetch KDE style info URL."
6756 (gnus-info-find-node (gnus-url-unhex-string url)))
6758 (defun gnus-button-handle-info-keystrokes (url)
6759 "Call `info' when pushing the corresponding URL button."
6760 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6765 (defun gnus-button-message-id (message-id)
6768 (set-buffer gnus-summary-buffer)
6769 (gnus-summary-refer-article message-id)))
6771 (defun gnus-button-fetch-group (address)
6772 "Fetch GROUP specified by ADDRESS."
6773 (if (not (string-match "[:/]" address))
6774 ;; This is just a simple group url.
6775 (gnus-group-read-ephemeral-group address gnus-select-method)
6778 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6780 (error "Can't parse %s" address)
6781 (gnus-group-read-ephemeral-group
6782 (match-string 4 address)
6783 `(nntp ,(match-string 1 address)
6784 (nntp-address ,(match-string 1 address))
6785 (nntp-port-number ,(if (match-end 3)
6786 (match-string 3 address)
6789 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6791 (defun gnus-url-parse-query-string (query &optional downcase)
6792 (let (retval pairs cur key val)
6793 (setq pairs (split-string query "&"))
6795 (setq cur (car pairs)
6797 (if (not (string-match "=" cur))
6799 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6800 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6802 (setq key (downcase key)))
6803 (setq cur (assoc key retval))
6805 (setcdr cur (cons val (cdr cur)))
6806 (setq retval (cons (list key val) retval)))))
6809 (defun gnus-url-mailto (url)
6810 ;; Send mail to someone
6811 (when (string-match "mailto:/*\\(.*\\)" url)
6812 (setq url (substring url (match-beginning 1) nil)))
6813 (let (to args subject func)
6814 (setq args (gnus-url-parse-query-string
6815 (if (string-match "^\\?" url)
6817 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6818 (concat "to=" (match-string 1 url) "&"
6819 (match-string 2 url))
6820 (concat "to=" url)))
6822 subject (cdr-safe (assoc "subject" args)))
6825 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6828 (message-position-on-field (caar args)))
6829 (insert (gnus-replace-in-string
6830 (mapconcat 'identity (reverse (cdar args)) ", ")
6832 (setq args (cdr args)))
6835 (message-goto-subject))))
6837 (defun gnus-button-embedded-url (address)
6838 "Activate ADDRESS with `browse-url'."
6839 (browse-url (gnus-strip-whitespace address)))
6841 ;;; Next/prev buttons in the article buffer.
6843 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6844 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6846 (defvar gnus-prev-page-map
6847 (let ((map (make-sparse-keymap)))
6848 (unless (>= emacs-major-version 21)
6849 ;; XEmacs doesn't care.
6850 (set-keymap-parent map gnus-article-mode-map))
6851 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6852 (define-key map "\r" 'gnus-button-prev-page)
6855 (defvar gnus-next-page-map
6856 (let ((map (make-sparse-keymap)))
6857 (unless (>= emacs-major-version 21)
6858 ;; XEmacs doesn't care.
6859 (set-keymap-parent map gnus-article-mode-map))
6860 (define-key map gnus-mouse-2 'gnus-button-next-page)
6861 (define-key map "\r" 'gnus-button-next-page)
6864 (defun gnus-insert-prev-page-button ()
6866 (inhibit-read-only t))
6868 gnus-prev-page-line-format nil
6869 `(,@(gnus-local-map-property gnus-prev-page-map)
6871 gnus-callback gnus-article-button-prev-page
6872 article-type annotation))
6873 (widget-convert-button
6875 ;; Exclude a newline.
6878 :action 'gnus-button-prev-page
6879 :button-keymap gnus-prev-page-map)))
6881 (defun gnus-button-next-page (&optional args more-args)
6882 "Go to the next page."
6884 (let ((win (selected-window)))
6885 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6886 (gnus-article-next-page)
6887 (select-window win)))
6889 (defun gnus-button-prev-page (&optional args more-args)
6890 "Go to the prev page."
6892 (let ((win (selected-window)))
6893 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6894 (gnus-article-prev-page)
6895 (select-window win)))
6897 (defun gnus-insert-next-page-button ()
6899 (inhibit-read-only t))
6900 (gnus-eval-format gnus-next-page-line-format nil
6901 `(,@(gnus-local-map-property gnus-next-page-map)
6903 gnus-callback gnus-article-button-next-page
6904 article-type annotation))
6905 (widget-convert-button
6907 ;; Exclude a newline.
6910 :action 'gnus-button-next-page
6911 :button-keymap gnus-next-page-map)))
6913 (defun gnus-article-button-next-page (arg)
6914 "Go to the next page."
6916 (let ((win (selected-window)))
6917 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6918 (gnus-article-next-page)
6919 (select-window win)))
6921 (defun gnus-article-button-prev-page (arg)
6922 "Go to the prev page."
6924 (let ((win (selected-window)))
6925 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6926 (gnus-article-prev-page)
6927 (select-window win)))
6929 (defvar gnus-decode-header-methods
6930 '(mail-decode-encoded-word-region)
6931 "List of methods used to decode headers.
6933 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6934 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
6935 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6936 whose names match REGEXP.
6939 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6940 mail-decode-encoded-word-region
6941 (\"chinese\" . rfc1843-decode-region))
6944 (defvar gnus-decode-header-methods-cache nil)
6946 (defun gnus-multi-decode-header (start end)
6947 "Apply the functions from `gnus-encoded-word-methods' that match."
6948 (unless (and gnus-decode-header-methods-cache
6949 (eq gnus-newsgroup-name
6950 (car gnus-decode-header-methods-cache)))
6951 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6954 (nconc gnus-decode-header-methods-cache (list x))
6955 (if (and gnus-newsgroup-name
6956 (string-match (car x) gnus-newsgroup-name))
6957 (nconc gnus-decode-header-methods-cache
6959 gnus-decode-header-methods))
6960 (let ((xlist gnus-decode-header-methods-cache))
6963 (narrow-to-region start end)
6965 (funcall (pop xlist) (point-min) (point-max))))))
6968 ;;; Treatment top-level handling.
6971 (defun gnus-treat-article (condition &optional part-number total-parts type)
6972 (let ((length (- (point-max) (point-min)))
6973 (alist gnus-treatment-function-alist)
6974 (article-goto-body-goes-to-point-min-p t)
6978 (let ((list gnus-article-treat-types))
6980 (when (string-match (pop list) type)
6981 (throw 'found t)))))))
6982 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6984 (gnus-run-hooks 'gnus-part-display-hook)
6985 (dolist (elem alist)
6988 (when (gnus-buffer-live-p gnus-summary-buffer)
6989 (set-buffer gnus-summary-buffer))
6990 (symbol-value (car elem))))
6991 (when (and (or (consp val)
6993 (gnus-treat-predicate val)
6994 (or (not (get (car elem) 'highlight))
6997 (funcall (cadr elem)))))))
6999 ;; Dynamic variables.
7001 (defvar part-number)
7002 (defvar total-parts)
7007 (defun gnus-treat-predicate (val)
7014 (stringp (car val)))
7015 (apply 'gnus-or (mapcar `(lambda (s)
7016 (string-match s ,(or gnus-newsgroup-name "")))
7019 (let ((pred (pop val)))
7022 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7024 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7026 (not (gnus-treat-predicate (car val))))
7028 (equal (car val) type))
7030 (error "%S is not a valid predicate" pred)))))
7036 (eq part-number total-parts))
7040 (error "%S is not a valid value" val))))
7042 (defun gnus-article-encrypt-body (protocol &optional n)
7043 "Encrypt the article body."
7046 (or gnus-article-encrypt-protocol
7047 (completing-read "Encrypt protocol: "
7048 gnus-article-encrypt-protocol-alist
7050 current-prefix-arg))
7051 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7053 (error (format "Can't find the encrypt protocol %s" protocol)))
7054 (if (member gnus-newsgroup-name '("nndraft:delayed"
7057 (error "Can't encrypt the article in group %s"
7058 gnus-newsgroup-name))
7059 (gnus-summary-iterate n
7061 (set-buffer gnus-summary-buffer)
7062 (let ((mail-parse-charset gnus-newsgroup-charset)
7063 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7064 (summary-buffer gnus-summary-buffer)
7066 (gnus-set-global-variables)
7067 (when (gnus-group-read-only-p)
7068 (error "The current newsgroup does not support article encrypt"))
7069 (gnus-summary-show-article t)
7071 (or (mail-header-references gnus-current-headers) ""))
7072 (set-buffer gnus-article-buffer)
7073 (let* ((inhibit-read-only t)
7075 (mapcar (lambda (field)
7076 (and (save-restriction
7077 (message-narrow-to-head)
7078 (goto-char (point-min))
7079 (search-forward field nil t))
7081 (message-narrow-to-field)
7083 (delete-region (point-min) (point-max))
7085 '("Content-Type:" "Content-Transfer-Encoding:"
7086 "Content-Disposition:"))))
7087 (message-narrow-to-head)
7088 (message-remove-header "MIME-Version")
7089 (goto-char (point-max))
7090 (setq point (point))
7091 (insert (apply 'concat headers))
7093 (narrow-to-region point (point-max))
7094 (let ((message-options message-options))
7095 (message-options-set 'message-sender user-mail-address)
7096 (message-options-set 'message-recipients user-mail-address)
7097 (message-options-set 'message-sign-encrypt 'not)
7099 (goto-char (point-min))
7100 (insert "MIME-Version: 1.0\n")
7102 (gnus-summary-edit-article-done
7103 references nil summary-buffer t))
7104 (when gnus-keep-backlog
7105 (gnus-backlog-remove-article
7106 (car gnus-article-current) (cdr gnus-article-current)))
7108 (when (get-buffer gnus-original-article-buffer)
7109 (set-buffer gnus-original-article-buffer)
7110 (setq gnus-original-article nil)))
7111 (when gnus-use-cache
7112 (gnus-cache-update-article
7113 (car gnus-article-current) (cdr gnus-article-current))))))))
7115 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7116 "The following specs can be used:
7117 %t The security MIME type
7120 %D Details if button is pressed")
7122 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7123 "The following specs can be used:
7124 %t The security MIME type
7127 %D Details if button is pressed")
7129 (defvar gnus-mime-security-button-line-format-alist
7130 '((?t gnus-tmp-type ?s)
7131 (?i gnus-tmp-info ?s)
7132 (?d gnus-tmp-details ?s)
7133 (?D gnus-tmp-pressed-details ?s)))
7135 (defvar gnus-mime-security-button-map
7136 (let ((map (make-sparse-keymap)))
7137 (unless (>= (string-to-number emacs-version) 21)
7138 (set-keymap-parent map gnus-article-mode-map))
7139 (define-key map gnus-mouse-2 'gnus-article-push-button)
7140 (define-key map "\r" 'gnus-article-press-button)
7143 (defvar gnus-mime-security-details-buffer nil)
7145 (defvar gnus-mime-security-button-pressed nil)
7147 (defvar gnus-mime-security-show-details-inline t
7148 "If non-nil, show details in the article buffer.")
7150 (defun gnus-mime-security-verify-or-decrypt (handle)
7151 (mm-remove-parts (cdr handle))
7152 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7153 point (inhibit-read-only t))
7155 (goto-char (car region)))
7157 (narrow-to-region (point) (point))
7158 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7159 (let* ((mm-verify-option 'known)
7160 (mm-decrypt-option 'known)
7161 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7162 (unless (eq nparts (cdr handle))
7163 (mm-destroy-parts (cdr handle))
7164 (setcdr handle nparts))))
7165 (setq point (point))
7166 (gnus-mime-display-security handle)
7167 (goto-char (point-max)))
7169 (delete-region (point) (cdr region))
7170 (set-marker (car region) nil)
7171 (set-marker (cdr region) nil))
7174 (defun gnus-mime-security-show-details (handle)
7175 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7177 (gnus-message 5 "No details.")
7178 (if gnus-mime-security-show-details-inline
7179 (let ((gnus-mime-security-button-pressed
7180 (not (get-text-property (point) 'gnus-mime-details)))
7181 (gnus-mime-security-button-line-format
7182 (get-text-property (point) 'gnus-line-format))
7183 (inhibit-read-only t))
7185 (while (eq (get-text-property (point) 'gnus-line-format)
7186 gnus-mime-security-button-line-format)
7190 (narrow-to-region (point) (point))
7191 (gnus-insert-mime-security-button handle))
7192 (delete-region (point)
7193 (or (text-property-not-all
7196 gnus-mime-security-button-line-format)
7199 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7200 (with-current-buffer gnus-mime-security-details-buffer
7203 (setq gnus-mime-security-details-buffer
7204 (gnus-get-buffer-create "*MIME Security Details*")))
7205 (with-current-buffer gnus-mime-security-details-buffer
7207 (goto-char (point-min)))
7208 (pop-to-buffer gnus-mime-security-details-buffer)))))
7210 (defun gnus-mime-security-press-button (handle)
7212 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7213 (gnus-mime-security-show-details handle)
7214 (gnus-mime-security-verify-or-decrypt handle))))
7216 (defun gnus-insert-mime-security-button (handle &optional displayed)
7217 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7220 (or (nth 2 (assoc protocol mm-verify-function-alist))
7221 (nth 2 (assoc protocol mm-decrypt-function-alist))
7223 (if (equal (car handle) "multipart/signed")
7224 " Signed" " Encrypted")
7227 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7230 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7231 gnus-tmp-pressed-details
7233 (setq gnus-tmp-details
7234 (if gnus-tmp-details
7235 (concat "\n" gnus-tmp-details)
7237 (setq gnus-tmp-pressed-details
7238 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7243 gnus-mime-security-button-line-format
7244 gnus-mime-security-button-line-format-alist
7245 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7246 gnus-callback gnus-mime-security-press-button
7247 gnus-line-format ,gnus-mime-security-button-line-format
7248 gnus-mime-details ,gnus-mime-security-button-pressed
7249 article-type annotation
7252 ;; Exclude a newline.
7255 (widget-convert-button
7258 :action 'gnus-widget-press-button
7259 :button-keymap gnus-mime-security-button-map
7261 (lambda (widget/window &optional overlay pos)
7262 ;; Needed to properly clear the message due to a bug in
7263 ;; wid-edit (XEmacs only).
7264 (when (boundp 'help-echo-owns-message)
7265 (setq help-echo-owns-message t))
7268 (aref gnus-mouse-2 0))))))
7270 (defun gnus-mime-display-security (handle)
7272 (narrow-to-region (point) (point))
7273 (unless (gnus-unbuttonized-mime-type-p (car handle))
7274 (gnus-insert-mime-security-button handle))
7275 (gnus-mime-display-mixed (cdr handle))
7278 (unless (gnus-unbuttonized-mime-type-p (car handle))
7279 (let ((gnus-mime-security-button-line-format
7280 gnus-mime-security-button-end-line-format))
7281 (gnus-insert-mime-security-button handle)))
7282 (mm-set-handle-multipart-parameter
7284 (cons (set-marker (make-marker) (point-min))
7285 (set-marker (make-marker) (point-max))))))
7291 (run-hooks 'gnus-art-load-hook)
7293 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7294 ;;; gnus-art.el ends here