1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
33 (defvar w3m-minor-mode-map))
48 (autoload 'gnus-msg-mail "gnus-msg" nil t)
49 (autoload 'gnus-button-mailto "gnus-msg")
50 (autoload 'gnus-button-reply "gnus-msg" nil t)
51 (autoload 'parse-time-string "parse-time" nil nil)
53 (defgroup gnus-article nil
55 :link '(custom-manual "(gnus)Article Buffer")
58 (defgroup gnus-article-treat nil
59 "Treating article parts."
60 :link '(custom-manual "(gnus)Article Hiding")
63 (defgroup gnus-article-hiding nil
64 "Hiding article parts."
65 :link '(custom-manual "(gnus)Article Hiding")
68 (defgroup gnus-article-highlight nil
69 "Article highlighting."
70 :link '(custom-manual "(gnus)Article Highlighting")
74 (defgroup gnus-article-signature nil
76 :link '(custom-manual "(gnus)Article Signature")
79 (defgroup gnus-article-headers nil
81 :link '(custom-manual "(gnus)Hiding Headers")
84 (defgroup gnus-article-washing nil
85 "Special commands on articles."
86 :link '(custom-manual "(gnus)Article Washing")
89 (defgroup gnus-article-emphasis nil
90 "Fontisizing articles."
91 :link '(custom-manual "(gnus)Article Fontisizing")
94 (defgroup gnus-article-saving nil
96 :link '(custom-manual "(gnus)Saving Articles")
99 (defgroup gnus-article-mime nil
100 "Worshiping the MIME wonder."
101 :link '(custom-manual "(gnus)Using MIME")
102 :group 'gnus-article)
104 (defgroup gnus-article-buttons nil
105 "Pushable buttons in the article buffer."
106 :link '(custom-manual "(gnus)Article Buttons")
107 :group 'gnus-article)
109 (defgroup gnus-article-various nil
110 "Other article options."
111 :link '(custom-manual "(gnus)Misc Article")
112 :group 'gnus-article)
114 (defcustom gnus-ignored-headers
117 (concat "^" header ":"))
118 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
119 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
120 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
121 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
122 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
123 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
124 "X-Attribution" "X-Originating-IP" "Delivered-To"
125 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
126 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
127 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
128 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
129 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
130 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
131 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
132 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
133 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
134 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
135 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
136 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
137 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
138 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
139 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
140 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
141 "List-[A-Za-z]+" "X-Listprocessor-Version"
142 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
143 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
144 "X-Received" "Content-length" "X-precedence"
145 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
146 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
147 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
148 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
149 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
150 "X-Content-length" "X-Posting-Agent" "Original-Received"
151 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
152 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
153 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
154 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
155 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
156 "*All headers that start with this regexp will be hidden.
157 This variable can also be a list of regexps of headers to be ignored.
158 If `gnus-visible-headers' is non-nil, this variable will be ignored."
159 :type '(choice :custom-show nil
162 :group 'gnus-article-hiding)
164 (defcustom gnus-visible-headers
165 "^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:"
166 "*All headers that do not match this regexp will be hidden.
167 This variable can also be a list of regexp of headers to remain visible.
168 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
169 :type '(repeat :value-to-internal (lambda (widget value)
170 (custom-split-regexp-maybe value))
171 :match (lambda (widget value)
173 (widget-editable-list-match widget value)))
175 :group 'gnus-article-hiding)
177 (defcustom gnus-sorted-header-list
178 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
179 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
180 "*This variable is a list of regular expressions.
181 If it is non-nil, headers that match the regular expressions will
182 be placed first in the article buffer in the sequence specified by
184 :type '(repeat regexp)
185 :group 'gnus-article-hiding)
187 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
188 "Headers that are only to be displayed if they have interesting data.
189 Possible values in this list are:
191 'empty Headers with no content.
192 'newsgroups Newsgroup identical to Gnus group.
193 'to-address To identical to To-address.
194 'to-list To identical to To-list.
195 'cc-list CC identical to To-list.
196 'followup-to Followup-to identical to Newsgroups.
197 'reply-to Reply-to identical to From.
198 'date Date less than four days old.
199 'long-to To and/or Cc longer than 1024 characters.
200 'many-to Multiple To and/or Cc."
201 :type '(set (const :tag "Headers with no content." empty)
202 (const :tag "Newsgroups identical to Gnus group." newsgroups)
203 (const :tag "To identical to To-address." to-address)
204 (const :tag "To identical to To-list." to-list)
205 (const :tag "CC identical to To-list." cc-list)
206 (const :tag "Followup-to identical to Newsgroups." followup-to)
207 (const :tag "Reply-to identical to From." reply-to)
208 (const :tag "Date less than four days old." date)
209 (const :tag "To and/or Cc longer than 1024 characters." long-to)
210 (const :tag "Multiple To and/or Cc headers." many-to))
211 :group 'gnus-article-hiding)
213 (defcustom gnus-article-skip-boring nil
214 "Skip over text that is not worth reading.
215 By default, if you set this t, then Gnus will display citations and
216 signatures, but will never scroll down to show you a page consisting
217 only of boring text. Boring text is controlled by
218 `gnus-article-boring-faces'."
221 :group 'gnus-article-hiding)
223 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
224 "Regexp matching signature separator.
225 This can also be a list of regexps. In that case, it will be checked
226 from head to tail looking for a separator. Searches will be done from
227 the end of the buffer."
228 :type '(repeat string)
229 :group 'gnus-article-signature)
231 (defcustom gnus-signature-limit nil
232 "Provide a limit to what is considered a signature.
233 If it is a number, no signature may not be longer (in characters) than
234 that number. If it is a floating point number, no signature may be
235 longer (in lines) than that number. If it is a function, the function
236 will be called without any parameters, and if it returns nil, there is
237 no signature in the buffer. If it is a string, it will be used as a
238 regexp. If it matches, the text in question is not a signature."
239 :type '(choice (integer :value 200)
241 (function :value fun)
242 (regexp :value ".*"))
243 :group 'gnus-article-signature)
245 (defcustom gnus-hidden-properties '(invisible t intangible t)
246 "Property list to use for hiding text."
248 :group 'gnus-article-hiding)
250 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
251 ;; frames in a session.
252 (defcustom gnus-article-x-face-command
253 (if (featurep 'xemacs)
254 (if (or (gnus-image-type-available-p 'xface)
255 (gnus-image-type-available-p 'pbm))
256 'gnus-display-x-face-in-from
257 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
258 (if (gnus-image-type-available-p 'pbm)
259 'gnus-display-x-face-in-from
260 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
262 "*String or function to be executed to display an X-Face header.
263 If it is a string, the command will be executed in a sub-shell
264 asynchronously. The compressed face will be piped to this command."
265 :type `(choice string
266 (function-item gnus-display-x-face-in-from)
270 :group 'gnus-article-washing)
272 (defcustom gnus-article-x-face-too-ugly nil
273 "Regexp matching posters whose face shouldn't be shown automatically."
274 :type '(choice regexp (const nil))
275 :group 'gnus-article-washing)
277 (defcustom gnus-article-banner-alist nil
278 "Banner alist for stripping.
280 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
282 :type '(repeat (cons symbol regexp))
283 :group 'gnus-article-washing)
285 (gnus-define-group-parameter
288 "Alist of regexps (to match group names) and banner."
289 :variable-group gnus-article-washing
291 '(choice :tag "Banner"
293 (const :tag "Remove signature" signature)
294 (symbol :tag "Item in `gnus-article-banner-alist'" none)
296 (const :tag "None" nil))
298 "If non-nil, specify how to remove `banners' from articles.
300 Symbol `signature' means to remove signatures delimited by
301 `gnus-signature-separator'. Any other symbol is used to look up a
302 regular expression to match the banner in `gnus-article-banner-alist'.
303 A string is used as a regular expression to match the banner
306 (defcustom gnus-article-address-banner-alist nil
307 "Alist of mail addresses and banners.
308 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
309 to match a mail address in the From: header, BANNER is one of a symbol
310 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
311 If ADDRESS matches author's mail address, it will remove things like
312 advertisements. For example:
314 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
318 (regexp :tag "Address")
319 (choice :tag "Banner" :value nil
320 (const :tag "Remove signature" signature)
321 (symbol :tag "Item in `gnus-article-banner-alist'" none)
323 (const :tag "None" nil))))
325 :group 'gnus-article-washing)
327 (defmacro gnus-emphasis-custom-with-format (&rest body)
329 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
330 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
333 (defun gnus-emphasis-custom-value-to-external (value)
334 (gnus-emphasis-custom-with-format
335 (if (consp (car value))
336 (list (format format (car (car value)) (cdr (car value)))
338 (if (nth 1 value) 2 3)
342 (defun gnus-emphasis-custom-value-to-internal (value)
343 (gnus-emphasis-custom-with-format
344 (let ((regexp (concat "\\`"
345 (format (regexp-quote format)
346 "\\([^()]+\\)" "\\([^()]+\\)")
349 (if (string-match regexp (setq pattern (car value)))
350 (list (cons (match-string 1 pattern) (match-string 2 pattern))
355 (defcustom gnus-emphasis-alist
357 '(("\\*" "\\*" bold nil 2)
360 ("_/" "/_" underline-italic)
361 ("_\\*" "\\*_" underline-bold)
362 ("\\*/" "/\\*" bold-italic)
363 ("_\\*/" "/\\*_" underline-bold-italic))))
365 (gnus-emphasis-custom-with-format
366 (mapcar (lambda (spec)
367 (list (format format (car spec) (cadr spec))
370 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
372 '(;; I've never seen anyone use this strikethru convention whereas I've
373 ;; several times seen it triggered by normal text. --Stef
374 ;; Miles suggests that this form is sometimes used but for italics,
375 ;; so maybe we should map it to `italic'.
376 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
377 ;; 2 3 gnus-emphasis-strikethru)
378 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
379 2 3 gnus-emphasis-underline))))
380 "*Alist that says how to fontify certain phrases.
381 Each item looks like this:
383 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
385 The first element is a regular expression to be matched. The second
386 is a number that says what regular expression grouping used to find
387 the entire emphasized word. The third is a number that says what
388 regexp grouping should be displayed and highlighted. The fourth
389 is the face used for highlighting."
393 :format "%[Customizing Style%]\n%v"
395 (group :tag "Default"
396 :value ("" 0 0 default)
399 (let ((value (widget-get
400 (cadr (widget-get (widget-get widget :parent)
403 (if (not (eq (nth 2 value) 'default))
407 (gnus-emphasis-custom-value-to-external value))))
408 (widget-group-value-create widget))
410 (integer :format "Match group: %v")
411 (integer :format "Emphasize group: %v")
414 :value (("_" . "_") nil default)
416 (regexp :format "Start regexp: %v")
417 (regexp :format "End regexp: %v"))
418 (boolean :format "Show start and end patterns: %[%v%]\n"
419 :on " On " :off " Off ")
421 :get (lambda (symbol)
422 (mapcar 'gnus-emphasis-custom-value-to-internal
423 (default-value symbol)))
424 :set (lambda (symbol value)
425 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
427 :group 'gnus-article-emphasis)
429 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
430 "A regexp to describe whitespace which should not be emphasized.
431 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
432 The former avoids underlining of leading and trailing whitespace,
433 and the latter avoids underlining any whitespace at all."
435 :group 'gnus-article-emphasis
438 (defface gnus-emphasis-bold '((t (:bold t)))
439 "Face used for displaying strong emphasized text (*word*)."
440 :group 'gnus-article-emphasis)
442 (defface gnus-emphasis-italic '((t (:italic t)))
443 "Face used for displaying italic emphasized text (/word/)."
444 :group 'gnus-article-emphasis)
446 (defface gnus-emphasis-underline '((t (:underline t)))
447 "Face used for displaying underlined emphasized text (_word_)."
448 :group 'gnus-article-emphasis)
450 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
451 "Face used for displaying underlined bold emphasized text (_*word*_)."
452 :group 'gnus-article-emphasis)
454 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
455 "Face used for displaying underlined italic emphasized text (_/word/_)."
456 :group 'gnus-article-emphasis)
458 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
459 "Face used for displaying bold italic emphasized text (/*word*/)."
460 :group 'gnus-article-emphasis)
462 (defface gnus-emphasis-underline-bold-italic
463 '((t (:bold t :italic t :underline t)))
464 "Face used for displaying underlined bold italic emphasized text.
465 Example: (_/*word*/_)."
466 :group 'gnus-article-emphasis)
468 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
469 '((t (:strikethru t)))
470 '((t (:strike-through t))))
471 "Face used for displaying strike-through text (-word-)."
472 :group 'gnus-article-emphasis)
474 (defface gnus-emphasis-highlight-words
475 '((t (:background "black" :foreground "yellow")))
476 "Face used for displaying highlighted words."
477 :group 'gnus-article-emphasis)
479 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
480 "Format for display of Date headers in article bodies.
481 See `format-time-string' for the possible values.
483 The variable can also be function, which should return a complete Date
484 header. The function is called with one argument, the time, which can
485 be fed to `format-time-string'."
486 :type '(choice string symbol)
487 :link '(custom-manual "(gnus)Article Date")
488 :group 'gnus-article-washing)
490 (defcustom gnus-save-all-headers t
491 "*If non-nil, don't remove any headers before saving."
492 :group 'gnus-article-saving
495 (defcustom gnus-prompt-before-saving 'always
496 "*This variable says how much prompting is to be done when saving articles.
497 If it is nil, no prompting will be done, and the articles will be
498 saved to the default files. If this variable is `always', each and
499 every article that is saved will be preceded by a prompt, even when
500 saving large batches of articles. If this variable is neither nil not
501 `always', there the user will be prompted once for a file name for
502 each invocation of the saving commands."
503 :group 'gnus-article-saving
504 :type '(choice (item always)
505 (item :tag "never" nil)
506 (sexp :tag "once" :format "%t\n" :value t)))
508 (defcustom gnus-saved-headers gnus-visible-headers
509 "Headers to keep if `gnus-save-all-headers' is nil.
510 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
511 If that variable is nil, however, all headers that match this regexp
512 will be kept while the rest will be deleted before saving."
513 :group 'gnus-article-saving
516 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
517 "A function to save articles in your favourite format.
518 The function must be interactively callable (in other words, it must
519 be an Emacs command).
521 Gnus provides the following functions:
523 * gnus-summary-save-in-rmail (Rmail format)
524 * gnus-summary-save-in-mail (Unix mail format)
525 * gnus-summary-save-in-folder (MH folder)
526 * gnus-summary-save-in-file (article format)
527 * gnus-summary-save-body-in-file (article body)
528 * gnus-summary-save-in-vm (use VM's folder format)
529 * gnus-summary-write-to-file (article format -- overwrite)."
530 :group 'gnus-article-saving
531 :type '(radio (function-item gnus-summary-save-in-rmail)
532 (function-item gnus-summary-save-in-mail)
533 (function-item gnus-summary-save-in-folder)
534 (function-item gnus-summary-save-in-file)
535 (function-item gnus-summary-save-body-in-file)
536 (function-item gnus-summary-save-in-vm)
537 (function-item gnus-summary-write-to-file)))
539 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
540 "A function generating a file name to save articles in Rmail format.
541 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
542 :group 'gnus-article-saving
545 (defcustom gnus-mail-save-name 'gnus-plain-save-name
546 "A function generating a file name to save articles in Unix mail format.
547 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
548 :group 'gnus-article-saving
551 (defcustom gnus-folder-save-name 'gnus-folder-save-name
552 "A function generating a file name to save articles in MH folder.
553 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
554 :group 'gnus-article-saving
557 (defcustom gnus-file-save-name 'gnus-numeric-save-name
558 "A function generating a file name to save articles in article format.
559 The function is called with NEWSGROUP, HEADERS, and optional
561 :group 'gnus-article-saving
564 (defcustom gnus-split-methods
565 '((gnus-article-archive-name)
566 (gnus-article-nndoc-name))
567 "*Variable used to suggest where articles are to be saved.
568 For instance, if you would like to save articles related to Gnus in
569 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
570 you could set this variable to something like:
572 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
573 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
575 This variable is an alist where the where the key is the match and the
576 value is a list of possible files to save in if the match is non-nil.
578 If the match is a string, it is used as a regexp match on the
579 article. If the match is a symbol, that symbol will be funcalled
580 from the buffer of the article to be saved with the newsgroup as the
581 parameter. If it is a list, it will be evaled in the same buffer.
583 If this form or function returns a string, this string will be used as
584 a possible file name; and if it returns a non-nil list, that list will
585 be used as possible file names."
586 :group 'gnus-article-saving
587 :type '(repeat (choice (list :value (fun) function)
588 (cons :value ("" "") regexp (repeat string))
591 (defcustom gnus-page-delimiter "^\^L"
592 "*Regexp describing what to use as article page delimiters.
593 The default value is \"^\^L\", which is a form linefeed at the
594 beginning of a line."
596 :group 'gnus-article-various)
598 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
599 "*The format specification for the article mode line.
600 See `gnus-summary-mode-line-format' for a closer description.
602 The following additional specs are available:
604 %w The article washing status.
605 %m The number of MIME parts in the article."
607 :group 'gnus-article-various)
609 (defcustom gnus-article-mode-hook nil
610 "*A hook for Gnus article mode."
612 :group 'gnus-article-various)
614 (when (featurep 'xemacs)
615 ;; Extracted from gnus-xmas-define in order to preserve user settings
616 (when (fboundp 'turn-off-scroll-in-place)
617 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
618 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
619 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
621 (defcustom gnus-article-menu-hook nil
622 "*Hook run after the creation of the article mode menu."
624 :group 'gnus-article-various)
626 (defcustom gnus-article-prepare-hook nil
627 "*A hook called after an article has been prepared in the article buffer."
629 :group 'gnus-article-various)
631 (make-obsolete-variable 'gnus-article-hide-pgp-hook
632 "This variable is obsolete in Gnus 5.10.")
634 (defcustom gnus-article-button-face 'bold
635 "Face used for highlighting buttons in the article buffer.
637 An article button is a piece of text that you can activate by pressing
638 `RET' or `mouse-2' above it."
640 :group 'gnus-article-buttons)
642 (defcustom gnus-article-mouse-face 'highlight
643 "Face used for mouse highlighting in the article buffer.
645 Article buttons will be displayed in this face when the cursor is
648 :group 'gnus-article-buttons)
650 (defcustom gnus-signature-face 'gnus-signature
651 "Face used for highlighting a signature in the article buffer.
652 Obsolete; use the face `gnus-signature' for customizations instead."
654 :group 'gnus-article-highlight
655 :group 'gnus-article-signature)
657 (defface gnus-signature
660 "Face used for highlighting a signature in the article buffer."
661 :group 'gnus-article-highlight
662 :group 'gnus-article-signature)
663 ;; backward-compatibility alias
664 (put 'gnus-signature-face 'face-alias 'gnus-signature)
666 (defface gnus-header-from
669 (:foreground "spring green"))
672 (:foreground "red3"))
675 "Face used for displaying from headers."
676 :group 'gnus-article-headers
677 :group 'gnus-article-highlight)
678 ;; backward-compatibility alias
679 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
681 (defface gnus-header-subject
684 (:foreground "SeaGreen3"))
687 (:foreground "red4"))
689 (:bold t :italic t)))
690 "Face used for displaying subject headers."
691 :group 'gnus-article-headers
692 :group 'gnus-article-highlight)
693 ;; backward-compatibility alias
694 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
696 (defface gnus-header-newsgroups
699 (:foreground "yellow" :italic t))
702 (:foreground "MidnightBlue" :italic t))
705 "Face used for displaying newsgroups headers.
706 In the default setup this face is only used for crossposted
708 :group 'gnus-article-headers
709 :group 'gnus-article-highlight)
710 ;; backward-compatibility alias
711 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
713 (defface gnus-header-name
716 (:foreground "SeaGreen"))
719 (:foreground "maroon"))
722 "Face used for displaying header names."
723 :group 'gnus-article-headers
724 :group 'gnus-article-highlight)
725 ;; backward-compatibility alias
726 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
728 (defface gnus-header-content
731 (:foreground "forest green" :italic t))
734 (:foreground "indianred4" :italic t))
736 (:italic t))) "Face used for displaying header content."
737 :group 'gnus-article-headers
738 :group 'gnus-article-highlight)
739 ;; backward-compatibility alias
740 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
742 (defcustom gnus-header-face-alist
743 '(("From" nil gnus-header-from)
744 ("Subject" nil gnus-header-subject)
745 ("Newsgroups:.*," nil gnus-header-newsgroups)
746 ("" gnus-header-name gnus-header-content))
747 "*Controls highlighting of article headers.
749 An alist of the form (HEADER NAME CONTENT).
751 HEADER is a regular expression which should match the name of a
752 header and NAME and CONTENT are either face names or nil.
754 The name of each header field will be displayed using the face
755 specified by the first element in the list where HEADER matches
756 the header name and NAME is non-nil. Similarly, the content will
757 be displayed by the first non-nil matching CONTENT face."
758 :group 'gnus-article-headers
759 :group 'gnus-article-highlight
760 :type '(repeat (list (regexp :tag "Header")
762 (item :tag "skip" nil)
763 (face :value default))
764 (choice :tag "Content"
765 (item :tag "skip" nil)
766 (face :value default)))))
768 (defcustom gnus-article-decode-hook
769 '(article-decode-charset article-decode-encoded-words
770 article-decode-group-name article-decode-idna-rhs)
771 "*Hook run to decode charsets in articles."
772 :group 'gnus-article-headers
775 (defcustom gnus-display-mime-function 'gnus-display-mime
776 "Function to display MIME articles."
777 :group 'gnus-article-mime
780 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
781 "Function used to decode headers.")
783 (defvar gnus-article-dumbquotes-map
803 "Table for MS-to-Latin1 translation.")
805 (defcustom gnus-ignored-mime-types nil
806 "List of MIME types that should be ignored by Gnus."
808 :group 'gnus-article-mime
809 :type '(repeat regexp))
811 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
812 "List of MIME types that should not be given buttons when rendered inline.
813 See also `gnus-buttonized-mime-types' which may override this variable.
814 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
816 :group 'gnus-article-mime
817 :type '(repeat regexp))
819 (defcustom gnus-buttonized-mime-types nil
820 "List of MIME types that should be given buttons when rendered inline.
821 If set, this variable overrides `gnus-unbuttonized-mime-types'.
822 To see e.g. security buttons you could set this to
823 `(\"multipart/signed\")'.
824 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
826 :group 'gnus-article-mime
827 :type '(repeat regexp))
829 (defcustom gnus-inhibit-mime-unbuttonizing nil
830 "If non-nil, all MIME parts get buttons.
831 When nil (the default value), then some MIME parts do not get buttons,
832 as described by the variables `gnus-buttonized-mime-types' and
833 `gnus-unbuttonized-mime-types'."
835 :group 'gnus-article-mime
838 (defcustom gnus-body-boundary-delimiter "_"
839 "String used to delimit header and body.
840 This variable is used by `gnus-article-treat-body-boundary' which can
841 be controlled by `gnus-treat-body-boundary'."
843 :group 'gnus-article-various
844 :type '(choice (item :tag "None" :value nil)
847 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
849 "Defines the location of the faces database.
850 For information on obtaining this database of pretty pictures, please
851 see http://www.cs.indiana.edu/picons/ftp/index.html"
853 :type '(repeat directory)
854 :link '(url-link :tag "download"
855 "http://www.cs.indiana.edu/picons/ftp/index.html")
856 :link '(custom-manual "(gnus)Picons")
859 (defun gnus-picons-installed-p ()
860 "Say whether picons are installed on your machine."
861 (let ((installed nil))
862 (dolist (database gnus-picon-databases)
863 (when (file-exists-p database)
867 (defcustom gnus-article-mime-part-function nil
868 "Function called with a MIME handle as the argument.
869 This is meant for people who want to do something automatic based
870 on parts -- for instance, adding Vcard info to a database."
871 :group 'gnus-article-mime
874 (defcustom gnus-mime-multipart-functions nil
875 "An alist of MIME types to functions to display them."
877 :group 'gnus-article-mime
880 (defcustom gnus-article-date-lapsed-new-header nil
881 "Whether the X-Sent and Date headers can coexist.
882 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
883 either replace the old \"Date:\" header (if this variable is nil), or
884 be added below it (otherwise)."
886 :group 'gnus-article-headers
889 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
890 "Function called with a MIME handle as the argument.
891 This is meant for people who want to view first matched part.
892 For `undisplayed-alternative' (default), the first undisplayed
893 part or alternative part is used. For `undisplayed', the first
894 undisplayed part is used. For a function, the first part which
895 the function return t is used. For nil, the first part is
898 :group 'gnus-article-mime
900 (item :tag "first" :value nil)
901 (item :tag "undisplayed" :value undisplayed)
902 (item :tag "undisplayed or alternative"
903 :value undisplayed-alternative)
906 (defcustom gnus-mime-action-alist
907 '(("save to file" . gnus-mime-save-part)
908 ("save and strip" . gnus-mime-save-part-and-strip)
909 ("delete part" . gnus-mime-delete-part)
910 ("display as text" . gnus-mime-inline-part)
911 ("view the part" . gnus-mime-view-part)
912 ("pipe to command" . gnus-mime-pipe-part)
913 ("toggle display" . gnus-article-press-button)
914 ("toggle display" . gnus-article-view-part-as-charset)
915 ("view as type" . gnus-mime-view-part-as-type)
916 ("view internally" . gnus-mime-view-part-internally)
917 ("view externally" . gnus-mime-view-part-externally))
918 "An alist of actions that run on the MIME attachment."
919 :group 'gnus-article-mime
920 :type '(repeat (cons (string :tag "name")
924 ;;; The treatment variables
927 (defvar gnus-part-display-hook nil
928 "Hook called on parts that are to receive treatment.")
930 (defvar gnus-article-treat-custom
931 '(choice (const :tag "Off" nil)
933 (const :tag "Header" head)
934 (const :tag "Last" last)
935 (integer :tag "Less")
936 (repeat :tag "Groups" regexp)
937 (sexp :tag "Predicate")))
939 (defvar gnus-article-treat-head-custom
940 '(choice (const :tag "Off" nil)
941 (const :tag "Header" head)))
943 (defvar gnus-article-treat-types '("text/plain")
946 (defvar gnus-inhibit-treatment nil
947 "Whether to inhibit treatment.")
949 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
950 "Highlight the signature.
951 Valid values are nil, t, `head', `last', an integer or a predicate.
952 See Info node `(gnus)Customizing Articles'."
953 :group 'gnus-article-treat
954 :link '(custom-manual "(gnus)Customizing Articles")
955 :type gnus-article-treat-custom)
956 (put 'gnus-treat-highlight-signature 'highlight t)
958 (defcustom gnus-treat-buttonize 100000
960 Valid values are nil, t, `head', `last', an integer or a predicate.
961 See Info node `(gnus)Customizing Articles'."
962 :group 'gnus-article-treat
963 :link '(custom-manual "(gnus)Customizing Articles")
964 :type gnus-article-treat-custom)
965 (put 'gnus-treat-buttonize 'highlight t)
967 (defcustom gnus-treat-buttonize-head 'head
968 "Add buttons to the head.
969 Valid values are nil, t, `head', `last', an integer or a predicate.
970 See Info node `(gnus)Customizing Articles' for details."
971 :group 'gnus-article-treat
972 :link '(custom-manual "(gnus)Customizing Articles")
973 :type gnus-article-treat-head-custom)
974 (put 'gnus-treat-buttonize-head 'highlight t)
976 (defcustom gnus-treat-emphasize
977 (and (or window-system
979 (>= (string-to-number emacs-version) 21))
982 Valid values are nil, t, `head', `last', an integer or a predicate.
983 See Info node `(gnus)Customizing Articles' for details."
984 :group 'gnus-article-treat
985 :link '(custom-manual "(gnus)Customizing Articles")
986 :type gnus-article-treat-custom)
987 (put 'gnus-treat-emphasize 'highlight t)
989 (defcustom gnus-treat-strip-cr nil
990 "Remove carriage returns.
991 Valid values are nil, t, `head', `last', an integer or a predicate.
992 See Info node `(gnus)Customizing Articles' for details."
994 :group 'gnus-article-treat
995 :link '(custom-manual "(gnus)Customizing Articles")
996 :type gnus-article-treat-custom)
998 (defcustom gnus-treat-unsplit-urls nil
999 "Remove newlines from within URLs.
1000 Valid values are nil, t, `head', `last', an integer or a predicate.
1001 See Info node `(gnus)Customizing Articles' for details."
1003 :group 'gnus-article-treat
1004 :link '(custom-manual "(gnus)Customizing Articles")
1005 :type gnus-article-treat-custom)
1007 (defcustom gnus-treat-leading-whitespace nil
1008 "Remove leading whitespace in headers.
1009 Valid values are nil, t, `head', `last', an integer or a predicate.
1010 See Info node `(gnus)Customizing Articles' for details."
1012 :group 'gnus-article-treat
1013 :link '(custom-manual "(gnus)Customizing Articles")
1014 :type gnus-article-treat-custom)
1016 (defcustom gnus-treat-hide-headers 'head
1018 Valid values are nil, t, `head', `last', an integer or a predicate.
1019 See Info node `(gnus)Customizing Articles' for details."
1020 :group 'gnus-article-treat
1021 :link '(custom-manual "(gnus)Customizing Articles")
1022 :type gnus-article-treat-head-custom)
1024 (defcustom gnus-treat-hide-boring-headers nil
1025 "Hide boring headers.
1026 Valid values are nil, t, `head', `last', an integer or a predicate.
1027 See Info node `(gnus)Customizing Articles' for details."
1028 :group 'gnus-article-treat
1029 :link '(custom-manual "(gnus)Customizing Articles")
1030 :type gnus-article-treat-head-custom)
1032 (defcustom gnus-treat-hide-signature nil
1033 "Hide the signature.
1034 Valid values are nil, t, `head', `last', an integer or a predicate.
1035 See Info node `(gnus)Customizing Articles' for details."
1036 :group 'gnus-article-treat
1037 :link '(custom-manual "(gnus)Customizing Articles")
1038 :type gnus-article-treat-custom)
1040 (defcustom gnus-treat-fill-article nil
1042 Valid values are nil, t, `head', `last', an integer or a predicate.
1043 See Info node `(gnus)Customizing Articles' for details."
1044 :group 'gnus-article-treat
1045 :link '(custom-manual "(gnus)Customizing Articles")
1046 :type gnus-article-treat-custom)
1048 (defcustom gnus-treat-hide-citation nil
1050 Valid values are nil, t, `head', `last', an integer or a predicate.
1051 See Info node `(gnus)Customizing Articles' for details."
1052 :group 'gnus-article-treat
1053 :link '(custom-manual "(gnus)Customizing Articles")
1054 :type gnus-article-treat-custom)
1056 (defcustom gnus-treat-hide-citation-maybe nil
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-list-identifiers 'head
1065 "Strip list identifiers from `gnus-list-identifiers`.
1066 Valid values are nil, t, `head', `last', an integer or a predicate.
1067 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 (make-obsolete-variable 'gnus-treat-strip-pgp
1074 "This option is obsolete in Gnus 5.10.")
1076 (defcustom gnus-treat-strip-pem nil
1077 "Strip PEM signatures.
1078 Valid values are nil, t, `head', `last', an integer or a predicate.
1079 See Info node `(gnus)Customizing Articles' for details."
1080 :group 'gnus-article-treat
1081 :link '(custom-manual "(gnus)Customizing Articles")
1082 :type gnus-article-treat-custom)
1084 (defcustom gnus-treat-strip-banner t
1085 "Strip banners from articles.
1086 The banner to be stripped is specified in the `banner' group parameter.
1087 Valid values are nil, t, `head', `last', an integer or a predicate.
1088 See Info node `(gnus)Customizing Articles' for details."
1089 :group 'gnus-article-treat
1090 :link '(custom-manual "(gnus)Customizing Articles")
1091 :type gnus-article-treat-custom)
1093 (defcustom gnus-treat-highlight-headers 'head
1094 "Highlight the headers.
1095 Valid values are nil, t, `head', `last', an integer or a predicate.
1096 See Info node `(gnus)Customizing Articles' for details."
1097 :group 'gnus-article-treat
1098 :link '(custom-manual "(gnus)Customizing Articles")
1099 :type gnus-article-treat-head-custom)
1100 (put 'gnus-treat-highlight-headers 'highlight t)
1102 (defcustom gnus-treat-highlight-citation t
1103 "Highlight cited text.
1104 Valid values are nil, t, `head', `last', an integer or a predicate.
1105 See Info node `(gnus)Customizing Articles' for details."
1106 :group 'gnus-article-treat
1107 :link '(custom-manual "(gnus)Customizing Articles")
1108 :type gnus-article-treat-custom)
1109 (put 'gnus-treat-highlight-citation 'highlight t)
1111 (defcustom gnus-treat-date-ut nil
1112 "Display the Date in UT (GMT).
1113 Valid values are nil, t, `head', `last', an integer or a predicate.
1114 See Info node `(gnus)Customizing Articles' for details."
1115 :group 'gnus-article-treat
1116 :link '(custom-manual "(gnus)Customizing Articles")
1117 :type gnus-article-treat-head-custom)
1119 (defcustom gnus-treat-date-local nil
1120 "Display the Date in the local timezone.
1121 Valid values are nil, t, `head', `last', an integer or a predicate.
1122 See Info node `(gnus)Customizing Articles' for details."
1123 :group 'gnus-article-treat
1124 :link '(custom-manual "(gnus)Customizing Articles")
1125 :type gnus-article-treat-head-custom)
1127 (defcustom gnus-treat-date-english nil
1128 "Display the Date in a format that can be read aloud in English.
1129 Valid values are nil, t, `head', `last', an integer or a predicate.
1130 See Info node `(gnus)Customizing Articles' for details."
1132 :group 'gnus-article-treat
1133 :link '(custom-manual "(gnus)Customizing Articles")
1134 :type gnus-article-treat-head-custom)
1136 (defcustom gnus-treat-date-lapsed nil
1137 "Display the Date header in a way that says how much time has elapsed.
1138 Valid values are nil, t, `head', `last', an integer or a predicate.
1139 See Info node `(gnus)Customizing Articles' for details."
1140 :group 'gnus-article-treat
1141 :link '(custom-manual "(gnus)Customizing Articles")
1142 :type gnus-article-treat-head-custom)
1144 (defcustom gnus-treat-date-original nil
1145 "Display the date in the original timezone.
1146 Valid values are nil, t, `head', `last', an integer or a predicate.
1147 See Info node `(gnus)Customizing Articles' for details."
1148 :group 'gnus-article-treat
1149 :link '(custom-manual "(gnus)Customizing Articles")
1150 :type gnus-article-treat-head-custom)
1152 (defcustom gnus-treat-date-iso8601 nil
1153 "Display the date in the ISO8601 format.
1154 Valid values are nil, t, `head', `last', an integer or a predicate.
1155 See Info node `(gnus)Customizing Articles' for details."
1157 :group 'gnus-article-treat
1158 :link '(custom-manual "(gnus)Customizing Articles")
1159 :type gnus-article-treat-head-custom)
1161 (defcustom gnus-treat-date-user-defined nil
1162 "Display the date in a user-defined format.
1163 The format is defined by the `gnus-article-time-format' variable.
1164 Valid values are nil, t, `head', `last', an integer or a predicate.
1165 See Info node `(gnus)Customizing Articles' for details."
1166 :group 'gnus-article-treat
1167 :link '(custom-manual "(gnus)Customizing Articles")
1168 :type gnus-article-treat-head-custom)
1170 (defcustom gnus-treat-strip-headers-in-body t
1171 "Strip the X-No-Archive header line from the beginning of the body.
1172 Valid values are nil, t, `head', `last', an integer or a predicate.
1173 See Info node `(gnus)Customizing Articles' for details."
1175 :group 'gnus-article-treat
1176 :link '(custom-manual "(gnus)Customizing Articles")
1177 :type gnus-article-treat-custom)
1179 (defcustom gnus-treat-strip-trailing-blank-lines nil
1180 "Strip trailing blank lines.
1181 Valid values are nil, t, `head', `last', an integer or a predicate.
1182 See Info node `(gnus)Customizing Articles' for details."
1183 :group 'gnus-article-treat
1184 :link '(custom-manual "(gnus)Customizing Articles")
1185 :type gnus-article-treat-custom)
1187 (defcustom gnus-treat-strip-leading-blank-lines nil
1188 "Strip leading blank lines.
1189 Valid values are nil, t, `head', `last', an integer or a predicate.
1190 See Info node `(gnus)Customizing Articles' for details."
1191 :group 'gnus-article-treat
1192 :link '(custom-manual "(gnus)Customizing Articles")
1193 :type gnus-article-treat-custom)
1195 (defcustom gnus-treat-strip-multiple-blank-lines nil
1196 "Strip multiple blank lines.
1197 Valid values are nil, t, `head', `last', an integer or a predicate.
1198 See Info node `(gnus)Customizing Articles' for details."
1199 :group 'gnus-article-treat
1200 :link '(custom-manual "(gnus)Customizing Articles")
1201 :type gnus-article-treat-custom)
1203 (defcustom gnus-treat-unfold-headers 'head
1204 "Unfold folded header lines.
1205 Valid values are nil, t, `head', `last', an integer or a predicate.
1206 See Info node `(gnus)Customizing Articles' for details."
1208 :group 'gnus-article-treat
1209 :link '(custom-manual "(gnus)Customizing Articles")
1210 :type gnus-article-treat-custom)
1212 (defcustom gnus-treat-fold-headers nil
1214 Valid values are nil, t, `head', `last', an integer or a predicate.
1215 See Info node `(gnus)Customizing Articles' for details."
1217 :group 'gnus-article-treat
1218 :link '(custom-manual "(gnus)Customizing Articles")
1219 :type gnus-article-treat-custom)
1221 (defcustom gnus-treat-fold-newsgroups 'head
1222 "Fold the Newsgroups and Followup-To headers.
1223 Valid values are nil, t, `head', `last', an integer or a predicate.
1224 See Info node `(gnus)Customizing Articles' for details."
1226 :group 'gnus-article-treat
1227 :link '(custom-manual "(gnus)Customizing Articles")
1228 :type gnus-article-treat-custom)
1230 (defcustom gnus-treat-overstrike t
1231 "Treat overstrike highlighting.
1232 Valid values are nil, t, `head', `last', an integer or a predicate.
1233 See Info node `(gnus)Customizing Articles' for details."
1234 :group 'gnus-article-treat
1235 :link '(custom-manual "(gnus)Customizing Articles")
1236 :type gnus-article-treat-custom)
1237 (put 'gnus-treat-overstrike 'highlight t)
1239 (make-obsolete-variable 'gnus-treat-display-xface
1240 'gnus-treat-display-x-face)
1242 (defcustom gnus-treat-display-x-face
1243 (and (not noninteractive)
1244 (or (and (fboundp 'image-type-available-p)
1245 (image-type-available-p 'xbm)
1246 (string-match "^0x" (shell-command-to-string "uncompface"))
1247 (executable-find "icontopbm"))
1248 (and (featurep 'xemacs)
1251 "Display X-Face headers.
1252 Valid values are nil, t, `head', `last', an integer or a predicate.
1253 See Info node `(gnus)Customizing Articles' and Info node
1254 `(gnus)X-Face' for details."
1255 :group 'gnus-article-treat
1257 :link '(custom-manual "(gnus)Customizing Articles")
1258 :link '(custom-manual "(gnus)X-Face")
1259 :type gnus-article-treat-head-custom
1260 :set (lambda (symbol value)
1263 (cond ((or (boundp symbol) (get symbol 'saved-value))
1265 ((boundp 'gnus-treat-display-xface)
1267 ** gnus-treat-display-xface is an obsolete variable;\
1268 use gnus-treat-display-x-face instead")
1269 (default-value 'gnus-treat-display-xface))
1270 ((get 'gnus-treat-display-xface 'saved-value)
1272 ** gnus-treat-display-xface is an obsolete variable;\
1273 use gnus-treat-display-x-face instead")
1274 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1277 (put 'gnus-treat-display-x-face 'highlight t)
1279 (defcustom gnus-treat-display-face
1280 (and (not noninteractive)
1281 (or (and (fboundp 'image-type-available-p)
1282 (image-type-available-p 'png))
1283 (and (featurep 'xemacs)
1286 "Display Face headers.
1287 Valid values are nil, t, `head', `last', an integer or a predicate.
1288 See Info node `(gnus)Customizing Articles' and Info node
1289 `(gnus)X-Face' for details."
1290 :group 'gnus-article-treat
1292 :link '(custom-manual "(gnus)Customizing Articles")
1293 :link '(custom-manual "(gnus)X-Face")
1294 :type gnus-article-treat-head-custom)
1295 (put 'gnus-treat-display-face 'highlight t)
1297 (defcustom gnus-treat-display-smileys
1298 (if (or (and (featurep 'xemacs)
1300 (and (fboundp 'image-type-available-p)
1301 (image-type-available-p 'pbm)))
1304 Valid values are nil, t, `head', `last', an integer or a predicate.
1305 See Info node `(gnus)Customizing Articles' and Info node
1306 `(gnus)Smileys' for details."
1307 :group 'gnus-article-treat
1309 :link '(custom-manual "(gnus)Customizing Articles")
1310 :link '(custom-manual "(gnus)Smileys")
1311 :type gnus-article-treat-custom)
1312 (put 'gnus-treat-display-smileys 'highlight t)
1314 (defcustom gnus-treat-from-picon
1315 (if (and (gnus-image-type-available-p 'xpm)
1316 (gnus-picons-installed-p))
1318 "Display picons in the From header.
1319 Valid values are nil, t, `head', `last', an integer or a predicate.
1320 See Info node `(gnus)Customizing Articles' and Info node
1321 `(gnus)Picons' for details."
1323 :group 'gnus-article-treat
1325 :link '(custom-manual "(gnus)Customizing Articles")
1326 :link '(custom-manual "(gnus)Picons")
1327 :type gnus-article-treat-head-custom)
1328 (put 'gnus-treat-from-picon 'highlight t)
1330 (defcustom gnus-treat-mail-picon
1331 (if (and (gnus-image-type-available-p 'xpm)
1332 (gnus-picons-installed-p))
1334 "Display picons in To and Cc headers.
1335 Valid values are nil, t, `head', `last', an integer or a predicate.
1336 See Info node `(gnus)Customizing Articles' and Info node
1337 `(gnus)Picons' for details."
1339 :group 'gnus-article-treat
1341 :link '(custom-manual "(gnus)Customizing Articles")
1342 :link '(custom-manual "(gnus)Picons")
1343 :type gnus-article-treat-head-custom)
1344 (put 'gnus-treat-mail-picon 'highlight t)
1346 (defcustom gnus-treat-newsgroups-picon
1347 (if (and (gnus-image-type-available-p 'xpm)
1348 (gnus-picons-installed-p))
1350 "Display picons in the Newsgroups and Followup-To headers.
1351 Valid values are nil, t, `head', `last', an integer or a predicate.
1352 See Info node `(gnus)Customizing Articles' and Info node
1353 `(gnus)Picons' for details."
1355 :group 'gnus-article-treat
1357 :link '(custom-manual "(gnus)Customizing Articles")
1358 :link '(custom-manual "(gnus)Picons")
1359 :type gnus-article-treat-head-custom)
1360 (put 'gnus-treat-newsgroups-picon 'highlight t)
1362 (defcustom gnus-treat-body-boundary
1363 (if (or gnus-treat-newsgroups-picon
1364 gnus-treat-mail-picon
1365 gnus-treat-from-picon)
1367 "Draw a boundary at the end of the headers.
1368 Valid values are nil and `head'.
1369 See Info node `(gnus)Customizing Articles' for details."
1371 :group 'gnus-article-treat
1372 :link '(custom-manual "(gnus)Customizing Articles")
1373 :type gnus-article-treat-head-custom)
1375 (defcustom gnus-treat-capitalize-sentences nil
1376 "Capitalize sentence-starting words.
1377 Valid values are nil, t, `head', `last', an integer or a predicate.
1378 See Info node `(gnus)Customizing Articles' for details."
1380 :group 'gnus-article-treat
1381 :link '(custom-manual "(gnus)Customizing Articles")
1382 :type gnus-article-treat-custom)
1384 (defcustom gnus-treat-wash-html nil
1386 Valid values are nil, t, `head', `last', an integer or a predicate.
1387 See Info node `(gnus)Customizing Articles' for details."
1389 :group 'gnus-article-treat
1390 :link '(custom-manual "(gnus)Customizing Articles")
1391 :type gnus-article-treat-custom)
1393 (defcustom gnus-treat-fill-long-lines nil
1395 Valid values are nil, t, `head', `last', an integer or a predicate.
1396 See Info node `(gnus)Customizing Articles' for details."
1397 :group 'gnus-article-treat
1398 :link '(custom-manual "(gnus)Customizing Articles")
1399 :type gnus-article-treat-custom)
1401 (defcustom gnus-treat-play-sounds nil
1403 Valid values are nil, t, `head', `last', an integer or a predicate.
1404 See Info node `(gnus)Customizing Articles' for details."
1406 :group 'gnus-article-treat
1407 :link '(custom-manual "(gnus)Customizing Articles")
1408 :type gnus-article-treat-custom)
1410 (defcustom gnus-treat-translate nil
1411 "Translate articles from one language to another.
1412 Valid values are nil, t, `head', `last', an integer or a predicate.
1413 See Info node `(gnus)Customizing Articles' for details."
1415 :group 'gnus-article-treat
1416 :link '(custom-manual "(gnus)Customizing Articles")
1417 :type gnus-article-treat-custom)
1419 (defcustom gnus-treat-x-pgp-sig nil
1421 To automatically treat X-PGP-Sig, set it to head.
1422 Valid values are nil, t, `head', `last', an integer or a predicate.
1423 See Info node `(gnus)Customizing Articles' for details."
1425 :group 'gnus-article-treat
1426 :group 'mime-security
1427 :link '(custom-manual "(gnus)Customizing Articles")
1428 :type gnus-article-treat-custom)
1430 (defvar gnus-article-encrypt-protocol-alist
1431 '(("PGP" . mml2015-self-encrypt)))
1433 ;; Set to nil if more than one protocol added to
1434 ;; gnus-article-encrypt-protocol-alist.
1435 (defcustom gnus-article-encrypt-protocol "PGP"
1436 "The protocol used for encrypt articles.
1437 It is a string, such as \"PGP\". If nil, ask user."
1440 :group 'mime-security)
1442 (defvar gnus-article-wash-function nil
1443 "Function used for converting HTML into text.")
1445 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1446 (mm-coding-system-p 'utf-8)
1447 (executable-find idna-program))
1448 "Whether IDNA decoding of headers is used when viewing messages.
1449 This requires GNU Libidn, and by default only enabled if it is found."
1451 :group 'gnus-article-headers
1454 (defcustom gnus-article-over-scroll nil
1455 "If non-nil, allow scrolling the article buffer even when there no more text."
1457 :group 'gnus-article
1460 ;;; Internal variables
1462 (defvar gnus-english-month-names
1463 '("January" "February" "March" "April" "May" "June" "July" "August"
1464 "September" "October" "November" "December"))
1466 (defvar article-goto-body-goes-to-point-min-p nil)
1467 (defvar gnus-article-wash-types nil)
1468 (defvar gnus-article-emphasis-alist nil)
1469 (defvar gnus-article-image-alist nil)
1471 (defvar gnus-article-mime-handle-alist-1 nil)
1472 (defvar gnus-treatment-function-alist
1473 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1474 (gnus-treat-strip-banner gnus-article-strip-banner)
1475 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1476 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1477 (gnus-treat-buttonize gnus-article-add-buttons)
1478 (gnus-treat-fill-article gnus-article-fill-cited-article)
1479 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1480 (gnus-treat-strip-cr gnus-article-remove-cr)
1481 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1482 (gnus-treat-date-ut gnus-article-date-ut)
1483 (gnus-treat-date-local gnus-article-date-local)
1484 (gnus-treat-date-english gnus-article-date-english)
1485 (gnus-treat-date-original gnus-article-date-original)
1486 (gnus-treat-date-user-defined gnus-article-date-user)
1487 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1488 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1489 (gnus-treat-display-x-face gnus-article-display-x-face)
1490 (gnus-treat-display-face gnus-article-display-face)
1491 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1492 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1493 (gnus-treat-hide-signature gnus-article-hide-signature)
1494 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1495 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1496 (gnus-treat-strip-pem gnus-article-hide-pem)
1497 (gnus-treat-from-picon gnus-treat-from-picon)
1498 (gnus-treat-mail-picon gnus-treat-mail-picon)
1499 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1500 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1501 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1502 (gnus-treat-strip-trailing-blank-lines
1503 gnus-article-remove-trailing-blank-lines)
1504 (gnus-treat-strip-leading-blank-lines
1505 gnus-article-strip-leading-blank-lines)
1506 (gnus-treat-strip-multiple-blank-lines
1507 gnus-article-strip-multiple-blank-lines)
1508 (gnus-treat-overstrike gnus-article-treat-overstrike)
1509 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1510 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1511 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1512 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1513 (gnus-treat-display-smileys gnus-treat-smiley)
1514 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1515 (gnus-treat-wash-html gnus-article-wash-html)
1516 (gnus-treat-emphasize gnus-article-emphasize)
1517 (gnus-treat-hide-citation gnus-article-hide-citation)
1518 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1519 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1520 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1521 (gnus-treat-play-sounds gnus-earcon-display)))
1523 (defvar gnus-article-mime-handle-alist nil)
1524 (defvar article-lapsed-timer nil)
1525 (defvar gnus-article-current-summary nil)
1527 (defvar gnus-article-mode-syntax-table
1528 (let ((table (copy-syntax-table text-mode-syntax-table)))
1529 ;; This causes the citation match run O(2^n).
1530 ;; (modify-syntax-entry ?- "w" table)
1531 (modify-syntax-entry ?> ")<" table)
1532 (modify-syntax-entry ?< "(>" table)
1533 ;; make M-. in article buffers work for `foo' strings
1534 (modify-syntax-entry ?' " " table)
1535 (modify-syntax-entry ?` " " table)
1537 "Syntax table used in article mode buffers.
1538 Initialized from `text-mode-syntax-table.")
1540 (defvar gnus-save-article-buffer nil)
1542 (defvar gnus-article-mode-line-format-alist
1543 (nconc '((?w (gnus-article-wash-status) ?s)
1544 (?m (gnus-article-mime-part-status) ?s))
1545 gnus-summary-mode-line-format-alist))
1547 (defvar gnus-number-of-articles-to-be-saved nil)
1549 (defvar gnus-inhibit-hiding nil)
1551 (defvar gnus-article-edit-mode nil)
1553 ;;; Macros for dealing with the article buffer.
1555 (defmacro gnus-with-article-headers (&rest forms)
1557 (set-buffer gnus-article-buffer)
1559 (let ((inhibit-read-only t)
1560 (inhibit-point-motion-hooks t)
1561 (case-fold-search t))
1562 (article-narrow-to-head)
1565 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1566 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1568 (defmacro gnus-with-article-buffer (&rest forms)
1570 (set-buffer gnus-article-buffer)
1571 (let ((inhibit-read-only t))
1574 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1575 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1577 (defun gnus-article-goto-header (header)
1578 "Go to HEADER, which is a regular expression."
1579 (re-search-forward (concat "^\\(" header "\\):") nil t))
1581 (defsubst gnus-article-hide-text (b e props)
1582 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1583 (gnus-add-text-properties-when 'article-type nil b e props)
1584 (when (memq 'intangible props)
1586 (max (1- b) (point-min))
1587 b 'intangible (cddr (memq 'intangible props)))))
1589 (defsubst gnus-article-unhide-text (b e)
1590 "Remove hidden text properties from region between B and E."
1591 (remove-text-properties b e gnus-hidden-properties)
1592 (when (memq 'intangible gnus-hidden-properties)
1593 (put-text-property (max (1- b) (point-min))
1594 b 'intangible nil)))
1596 (defun gnus-article-hide-text-type (b e type)
1597 "Hide text of TYPE between B and E."
1598 (gnus-add-wash-type type)
1599 (gnus-article-hide-text
1600 b e (cons 'article-type (cons type gnus-hidden-properties))))
1602 (defun gnus-article-unhide-text-type (b e type)
1603 "Unhide text of TYPE between B and E."
1604 (gnus-delete-wash-type type)
1605 (remove-text-properties
1606 b e (cons 'article-type (cons type gnus-hidden-properties)))
1607 (when (memq 'intangible gnus-hidden-properties)
1608 (put-text-property (max (1- b) (point-min))
1609 b 'intangible nil)))
1611 (defun gnus-article-hide-text-of-type (type)
1612 "Hide text of TYPE in the current buffer."
1614 (let ((b (point-min))
1616 (while (setq b (text-property-any b e 'article-type type))
1617 (add-text-properties b (incf b) gnus-hidden-properties)))))
1619 (defun gnus-article-delete-text-of-type (type)
1620 "Delete text of TYPE in the current buffer."
1622 (let ((b (point-min)))
1623 (while (setq b (text-property-any b (point-max) 'article-type type))
1625 b (or (text-property-not-all b (point-max) 'article-type type)
1628 (defun gnus-article-delete-invisible-text ()
1629 "Delete all invisible text in the current buffer."
1631 (let ((b (point-min)))
1632 (while (setq b (text-property-any b (point-max) 'invisible t))
1634 b (or (text-property-not-all b (point-max) 'invisible t)
1637 (defun gnus-article-text-type-exists-p (type)
1638 "Say whether any text of type TYPE exists in the buffer."
1639 (text-property-any (point-min) (point-max) 'article-type type))
1641 (defsubst gnus-article-header-rank ()
1642 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1643 (let ((list gnus-sorted-header-list)
1646 (if (looking-at (car list))
1648 (setq list (cdr list))
1652 (defun article-hide-headers (&optional arg delete)
1653 "Hide unwanted headers and possibly sort them as well."
1655 ;; This function might be inhibited.
1656 (unless gnus-inhibit-hiding
1657 (let ((inhibit-read-only nil)
1658 (case-fold-search t)
1659 (max (1+ (length gnus-sorted-header-list)))
1660 (inhibit-point-motion-hooks t)
1661 (cur (current-buffer))
1662 ignored visible beg)
1664 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1665 ;; group parameters, so we should go to the summary buffer.
1668 (progn (set-buffer gnus-summary-buffer) t)
1670 (setq ignored (when (not gnus-visible-headers)
1671 (cond ((stringp gnus-ignored-headers)
1672 gnus-ignored-headers)
1673 ((listp gnus-ignored-headers)
1674 (mapconcat 'identity
1675 gnus-ignored-headers
1677 visible (cond ((stringp gnus-visible-headers)
1678 gnus-visible-headers)
1679 ((and gnus-visible-headers
1680 (listp gnus-visible-headers))
1681 (mapconcat 'identity
1682 gnus-visible-headers
1686 ;; First we narrow to just the headers.
1687 (article-narrow-to-head)
1688 ;; Hide any "From " lines at the beginning of (mail) articles.
1689 (while (looking-at "From ")
1692 (delete-region (point-min) (point)))
1693 ;; Then treat the rest of the header lines.
1694 ;; Then we use the two regular expressions
1695 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1696 ;; select which header lines is to remain visible in the
1698 (while (re-search-forward "^[^ \t:]*:" nil t)
1700 ;; Mark the rank of the header.
1702 (point) (1+ (point)) 'message-rank
1703 (if (or (and visible (looking-at visible))
1705 (not (looking-at ignored))))
1706 (gnus-article-header-rank)
1709 (message-sort-headers-1)
1710 (when (setq beg (text-property-any
1711 (point-min) (point-max) 'message-rank (+ 2 max)))
1712 ;; We delete the unwanted headers.
1713 (gnus-add-wash-type 'headers)
1714 (add-text-properties (point-min) (+ 5 (point-min))
1715 '(article-type headers dummy-invisible t))
1716 (delete-region beg (point-max))))))))
1718 (defun article-hide-boring-headers (&optional arg)
1719 "Toggle hiding of headers that aren't very interesting.
1720 If given a negative prefix, always show; if given a positive prefix,
1722 (interactive (gnus-article-hidden-arg))
1723 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1724 (not gnus-show-all-headers))
1727 (let ((inhibit-read-only t)
1728 (list gnus-boring-article-headers)
1729 (inhibit-point-motion-hooks t)
1731 (article-narrow-to-head)
1733 (setq elem (pop list))
1734 (goto-char (point-min))
1736 ;; Hide empty headers.
1738 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1740 (gnus-article-hide-text-type
1744 (if (re-search-forward "^[^ \t]" nil t)
1748 ;; Hide boring Newsgroups header.
1749 ((eq elem 'newsgroups)
1750 (when (gnus-string-equal
1751 (gnus-fetch-field "newsgroups")
1752 (gnus-group-real-name
1753 (if (boundp 'gnus-newsgroup-name)
1756 (gnus-article-hide-header "newsgroups")))
1757 ((eq elem 'to-address)
1758 (let ((to (message-fetch-field "to"))
1760 (gnus-parameter-to-address
1761 (if (boundp 'gnus-newsgroup-name)
1762 gnus-newsgroup-name ""))))
1763 (when (and to to-address
1766 ;; only one address in To
1767 (nth 1 (mail-extract-address-components to))
1769 (gnus-article-hide-header "to"))))
1771 (let ((to (message-fetch-field "to"))
1773 (gnus-parameter-to-list
1774 (if (boundp 'gnus-newsgroup-name)
1775 gnus-newsgroup-name ""))))
1776 (when (and to to-list
1779 ;; only one address in To
1780 (nth 1 (mail-extract-address-components to))
1782 (gnus-article-hide-header "to"))))
1784 (let ((cc (message-fetch-field "cc"))
1786 (gnus-parameter-to-list
1787 (if (boundp 'gnus-newsgroup-name)
1788 gnus-newsgroup-name ""))))
1789 (when (and cc to-list
1792 ;; only one address in CC
1793 (nth 1 (mail-extract-address-components cc))
1795 (gnus-article-hide-header "cc"))))
1796 ((eq elem 'followup-to)
1797 (when (gnus-string-equal
1798 (message-fetch-field "followup-to")
1799 (message-fetch-field "newsgroups"))
1800 (gnus-article-hide-header "followup-to")))
1801 ((eq elem 'reply-to)
1802 (if (gnus-group-find-parameter
1803 gnus-newsgroup-name 'broken-reply-to)
1804 (gnus-article-hide-header "reply-to")
1805 (let ((from (message-fetch-field "from"))
1806 (reply-to (message-fetch-field "reply-to")))
1813 (lambda (x) (downcase (cadr x)))
1814 (mail-extract-address-components from t))
1817 (lambda (x) (downcase (cadr x)))
1818 (mail-extract-address-components reply-to t))
1820 (gnus-article-hide-header "reply-to")))))
1822 (let ((date (message-fetch-field "date")))
1824 (< (days-between (current-time-string) date)
1826 (gnus-article-hide-header "date"))))
1828 (let ((to (message-fetch-field "to"))
1829 (cc (message-fetch-field "cc")))
1830 (when (> (length to) 1024)
1831 (gnus-article-hide-header "to"))
1832 (when (> (length cc) 1024)
1833 (gnus-article-hide-header "cc"))))
1837 (goto-char (point-min))
1838 (while (re-search-forward "^to:" nil t)
1839 (setq to-count (1+ to-count)))
1840 (when (> to-count 1)
1841 (while (> to-count 0)
1842 (goto-char (point-min))
1844 (re-search-forward "^to:" nil nil to-count)
1846 (narrow-to-region (point) (point-max))
1847 (gnus-article-hide-header "to"))
1848 (setq to-count (1- to-count))))
1849 (goto-char (point-min))
1850 (while (re-search-forward "^cc:" nil t)
1851 (setq cc-count (1+ cc-count)))
1852 (when (> cc-count 1)
1853 (while (> cc-count 0)
1854 (goto-char (point-min))
1856 (re-search-forward "^cc:" nil nil cc-count)
1858 (narrow-to-region (point) (point-max))
1859 (gnus-article-hide-header "cc"))
1860 (setq cc-count (1- cc-count)))))))))))))
1862 (defun gnus-article-hide-header (header)
1864 (goto-char (point-min))
1865 (when (re-search-forward (concat "^" header ":") nil t)
1866 (gnus-article-hide-text-type
1870 (if (re-search-forward "^[^ \t]" nil t)
1875 (defvar gnus-article-normalized-header-length 40
1876 "Length of normalized headers.")
1878 (defun article-normalize-headers ()
1879 "Make all header lines 40 characters long."
1881 (let ((inhibit-read-only t)
1885 (article-narrow-to-head)
1888 ((< (setq column (- (gnus-point-at-eol) (point)))
1889 gnus-article-normalized-header-length)
1891 (insert (make-string
1892 (- gnus-article-normalized-header-length column)
1894 ((> column gnus-article-normalized-header-length)
1895 (gnus-put-text-property
1897 (forward-char gnus-article-normalized-header-length)
1904 (forward-line 1))))))
1906 (defun article-treat-dumbquotes ()
1907 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1908 Note that this function guesses whether a character is a sm*rtq**t* or
1909 not, so it should only be used interactively.
1911 Sm*rtq**t*s are M****s***'s unilateral extension to the
1912 iso-8859-1 character map in an attempt to provide more quoting
1913 characters. If you see something like \\222 or \\264 where
1914 you're expecting some kind of apostrophe or quotation mark, then
1917 (article-translate-strings gnus-article-dumbquotes-map))
1919 (defun article-translate-characters (from to)
1920 "Translate all characters in the body of the article according to FROM and TO.
1921 FROM is a string of characters to translate from; to is a string of
1922 characters to translate to."
1924 (when (article-goto-body)
1925 (let ((inhibit-read-only t)
1926 (x (make-string 225 ?x))
1928 (while (< (incf i) (length x))
1931 (while (< i (length from))
1932 (aset x (aref from i) (aref to i))
1934 (translate-region (point) (point-max) x)))))
1936 (defun article-translate-strings (map)
1937 "Translate all string in the body of the article according to MAP.
1938 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1940 (when (article-goto-body)
1941 (let ((inhibit-read-only t)
1943 (while (setq elem (pop map))
1945 (while (search-forward (car elem) nil t)
1946 (replace-match (cadr elem)))))))))
1948 (defun article-treat-overstrike ()
1949 "Translate overstrikes into bold text."
1952 (when (article-goto-body)
1953 (let ((inhibit-read-only t))
1954 (while (search-forward "\b" nil t)
1955 (let ((next (char-after))
1956 (previous (char-after (- (point) 2))))
1957 ;; We do the boldification/underlining by hiding the
1958 ;; overstrikes and putting the proper text property
1962 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1963 (put-text-property (point) (1+ (point)) 'face 'bold))
1965 (gnus-article-hide-text-type
1966 (1- (point)) (1+ (point)) 'overstrike)
1968 (- (point) 2) (1- (point)) 'face 'underline))
1970 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1972 (point) (1+ (point)) 'face 'underline)))))))))
1974 (defun gnus-article-treat-unfold-headers ()
1975 "Unfold folded message headers.
1976 Only the headers that fit into the current window width will be
1979 (gnus-with-article-headers
1983 (mail-header-narrow-to-field)
1984 (let ((header (buffer-string)))
1987 (goto-char (point-min))
1988 (while (re-search-forward "\n[\t ]" nil t)
1989 (replace-match " " t t)))
1990 (setq length (- (point-max) (point-min) 1)))
1991 (when (< length (window-width))
1992 (while (re-search-forward "\n[\t ]" nil t)
1993 (replace-match " " t t)))
1994 (goto-char (point-max)))))))
1996 (defun gnus-article-treat-fold-headers ()
1997 "Fold message headers."
1999 (gnus-with-article-headers
2002 (mail-header-narrow-to-field)
2003 (mail-header-fold-field)
2004 (goto-char (point-max))))))
2006 (defun gnus-treat-smiley ()
2007 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2009 (gnus-with-article-buffer
2010 (if (memq 'smiley gnus-article-wash-types)
2011 (gnus-delete-images 'smiley)
2013 (let ((images (smiley-region (point) (point-max))))
2015 (gnus-add-wash-type 'smiley)
2016 (dolist (image images)
2017 (gnus-add-image 'smiley image)))))))
2019 (defun gnus-article-remove-images ()
2020 "Remove all images from the article buffer."
2022 (gnus-with-article-buffer
2023 (dolist (elem gnus-article-image-alist)
2024 (gnus-delete-images (car elem)))))
2026 (defun gnus-article-treat-fold-newsgroups ()
2027 "Unfold folded message headers.
2028 Only the headers that fit into the current window width will be
2031 (gnus-with-article-headers
2032 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2034 (mail-header-narrow-to-field)
2035 (while (re-search-forward ", *" nil t)
2036 (replace-match ", " t t))
2037 (mail-header-fold-field)
2038 (goto-char (point-max))))))
2040 (defun gnus-article-treat-body-boundary ()
2041 "Place a boundary line at the end of the headers."
2043 (when (and gnus-body-boundary-delimiter
2044 (> (length gnus-body-boundary-delimiter) 0))
2045 (gnus-with-article-headers
2046 (goto-char (point-max))
2047 (let ((start (point)))
2048 (insert "X-Boundary: ")
2049 (gnus-add-text-properties start (point) '(invisible t intangible t))
2051 (while (>= (1- (window-width)) (length str))
2052 (setq str (concat str gnus-body-boundary-delimiter)))
2053 (substring str 0 (1- (window-width))))
2055 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2057 (defun article-fill-long-lines ()
2058 "Fill lines that are wider than the window width."
2061 (let ((inhibit-read-only t)
2062 (width (window-width (get-buffer-window (current-buffer)))))
2065 (let ((adaptive-fill-mode nil)) ;Why? -sm
2068 (when (>= (current-column) (min fill-column width))
2069 (narrow-to-region (min (1+ (point)) (point-max))
2070 (gnus-point-at-bol))
2071 (let ((goback (point-marker)))
2072 (fill-paragraph nil)
2073 (goto-char (marker-position goback)))
2075 (forward-line 1)))))))
2077 (defun article-capitalize-sentences ()
2078 "Capitalize the first word in each sentence."
2081 (let ((inhibit-read-only t)
2082 (paragraph-start "^[\n\^L]"))
2086 (forward-sentence)))))
2088 (defun article-remove-cr ()
2089 "Remove trailing CRs and then translate remaining CRs into LFs."
2092 (let ((inhibit-read-only t))
2093 (goto-char (point-min))
2094 (while (re-search-forward "\r+$" nil t)
2095 (replace-match "" t t))
2096 (goto-char (point-min))
2097 (while (search-forward "\r" nil t)
2098 (replace-match "\n" t t)))))
2100 (defun article-remove-trailing-blank-lines ()
2101 "Remove all trailing blank lines from the article."
2104 (let ((inhibit-read-only t))
2105 (goto-char (point-max))
2109 (while (and (not (bobp))
2110 (looking-at "^[ \t]*$")
2111 (not (gnus-annotation-in-region-p
2112 (point) (gnus-point-at-eol))))
2117 (defun article-display-face ()
2118 "Display any Face headers in the header."
2120 (let ((wash-face-p buffer-read-only))
2121 (gnus-with-article-headers
2122 ;; When displaying parts, this function can be called several times on
2123 ;; the same article, without any intended toggle semantic (as typing `W
2124 ;; D d' would have). So face deletion must occur only when we come from
2125 ;; an interactive command, that is when the *Article* buffer is
2127 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2128 (gnus-delete-images 'face)
2129 (let (face faces from)
2130 (save-current-buffer
2131 (when (and wash-face-p
2132 (gnus-buffer-live-p gnus-original-article-buffer)
2133 (not (re-search-forward "^Face:[\t ]*" nil t)))
2134 (set-buffer gnus-original-article-buffer))
2136 (mail-narrow-to-head)
2137 (while (gnus-article-goto-header "Face")
2138 (push (mail-header-field-value) faces))))
2140 (goto-char (point-min))
2141 (let ((from (gnus-article-goto-header "from"))
2146 (insert "[no `from' set]\n"))
2148 (when (setq png (gnus-convert-face-to-png (pop faces)))
2149 (setq image (gnus-create-image png 'png t))
2151 (gnus-add-wash-type 'face)
2152 (gnus-add-image 'face image)
2153 (gnus-put-image image nil 'face))))))))))
2155 (defun article-display-x-face (&optional force)
2156 "Look for an X-Face header and display it if present."
2157 (interactive (list 'force))
2158 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2159 (gnus-with-article-headers
2160 ;; Delete the old process, if any.
2161 (when (process-status "article-x-face")
2162 (delete-process "article-x-face"))
2163 ;; See the comment in `article-display-face'.
2164 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2165 ;; We have already displayed X-Faces, so we remove them
2167 (gnus-delete-images 'xface)
2169 (let (x-faces from face)
2170 (save-current-buffer
2171 (when (and wash-face-p
2172 (gnus-buffer-live-p gnus-original-article-buffer)
2173 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2174 ;; If type `W f', use gnus-original-article-buffer,
2175 ;; otherwise use the current buffer because displaying
2176 ;; RFC822 parts calls this function too.
2177 (set-buffer gnus-original-article-buffer))
2179 (mail-narrow-to-head)
2180 (while (gnus-article-goto-header "X-Face")
2181 (push (mail-header-field-value) x-faces))
2182 (setq from (message-fetch-field "from"))))
2183 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2184 ;; single external face.
2185 (when (stringp gnus-article-x-face-command)
2186 (setq x-faces (list (car x-faces))))
2188 gnus-article-x-face-command
2190 ;; Check whether this face is censored.
2191 (not gnus-article-x-face-too-ugly)
2193 (not (string-match gnus-article-x-face-too-ugly
2195 (while (setq face (pop x-faces))
2196 ;; We display the face.
2197 (cond ((stringp gnus-article-x-face-command)
2198 ;; The command is a string, so we interpret the command
2199 ;; as a, well, command, and fork it off.
2200 (let ((process-connection-type nil))
2201 (gnus-set-process-query-on-exit-flag
2203 "article-x-face" nil shell-file-name
2204 shell-command-switch gnus-article-x-face-command)
2208 (process-send-region "article-x-face"
2209 (point-min) (point-max)))
2210 (process-send-eof "article-x-face")))
2211 ((functionp gnus-article-x-face-command)
2212 ;; The command is a lisp function, so we call it.
2213 (funcall gnus-article-x-face-command face))
2215 (error "%s is not a function"
2216 gnus-article-x-face-command))))))))))
2218 (defun article-decode-mime-words ()
2219 "Decode all MIME-encoded words in the article."
2222 (set-buffer gnus-article-buffer)
2223 (let ((inhibit-point-motion-hooks t)
2224 (inhibit-read-only t)
2225 (mail-parse-charset gnus-newsgroup-charset)
2226 (mail-parse-ignored-charsets
2227 (save-excursion (set-buffer gnus-summary-buffer)
2228 gnus-newsgroup-ignored-charsets)))
2229 (mail-decode-encoded-word-region (point-min) (point-max)))))
2231 (defun article-decode-charset (&optional prompt)
2232 "Decode charset-encoded text in the article.
2233 If PROMPT (the prefix), prompt for a coding system to use."
2235 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2236 (inhibit-read-only t)
2237 (mail-parse-charset gnus-newsgroup-charset)
2238 (mail-parse-ignored-charsets
2239 (save-excursion (condition-case nil
2240 (set-buffer gnus-summary-buffer)
2242 gnus-newsgroup-ignored-charsets))
2243 ct cte ctl charset format)
2246 (article-narrow-to-head)
2247 (setq ct (message-fetch-field "Content-Type" t)
2248 cte (message-fetch-field "Content-Transfer-Encoding" t)
2249 ctl (and ct (ignore-errors
2250 (mail-header-parse-content-type ct)))
2253 (mm-read-coding-system "Charset to decode: "))
2255 (mail-content-type-get ctl 'charset)))
2256 format (and ctl (mail-content-type-get ctl 'format)))
2258 (setq cte (mail-header-strip cte)))
2259 (if (and ctl (not (string-match "/" (car ctl))))
2261 (goto-char (point-max)))
2264 (narrow-to-region (point) (point-max))
2265 (when (and (eq mail-parse-charset 'gnus-decoded)
2266 (eq (mm-body-7-or-8) '8bit))
2267 ;; The text code could have been decoded.
2268 (setq charset mail-parse-charset))
2269 (when (and (or (not ctl)
2270 (equal (car ctl) "text/plain"))
2271 (not format)) ;; article with format will decode later.
2273 charset (and cte (intern (downcase
2274 (gnus-strip-whitespace cte))))
2277 (defun article-decode-encoded-words ()
2278 "Remove encoded-word encoding from headers."
2279 (let ((inhibit-point-motion-hooks t)
2280 (mail-parse-charset gnus-newsgroup-charset)
2281 (mail-parse-ignored-charsets
2282 (save-excursion (condition-case nil
2283 (set-buffer gnus-summary-buffer)
2285 gnus-newsgroup-ignored-charsets))
2286 (inhibit-read-only t))
2288 (article-narrow-to-head)
2289 (funcall gnus-decode-header-function (point-min) (point-max)))))
2291 (defun article-decode-group-name ()
2292 "Decode group names in `Newsgroups:'."
2293 (let ((inhibit-point-motion-hooks t)
2294 (inhibit-read-only t)
2295 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2296 (when (and (or gnus-group-name-charset-method-alist
2297 gnus-group-name-charset-group-alist)
2298 (gnus-buffer-live-p gnus-original-article-buffer))
2300 (article-narrow-to-head)
2301 (with-current-buffer gnus-original-article-buffer
2302 (goto-char (point-min)))
2303 (while (re-search-forward
2304 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2305 (replace-match (save-match-data
2306 (gnus-decode-newsgroups
2307 ;; XXX how to use data in article buffer?
2308 (with-current-buffer gnus-original-article-buffer
2310 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2313 gnus-newsgroup-name method))
2315 (goto-char (point-min))
2316 (with-current-buffer gnus-original-article-buffer
2317 (goto-char (point-min)))
2318 (while (re-search-forward
2319 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2320 (replace-match (save-match-data
2321 (gnus-decode-newsgroups
2322 ;; XXX how to use data in article buffer?
2323 (with-current-buffer gnus-original-article-buffer
2325 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2328 gnus-newsgroup-name method))
2331 (autoload 'idna-to-unicode "idna")
2333 (defun article-decode-idna-rhs ()
2334 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2337 (let ((inhibit-point-motion-hooks t)
2338 (inhibit-read-only t))
2339 (article-narrow-to-head)
2340 (goto-char (point-min))
2341 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2343 (when (save-match-data
2344 (and (setq ace (match-string 1))
2346 (and (re-search-backward "^[^ \t]" nil t)
2347 (looking-at "From\\|To\\|Cc")))
2348 (setq unicode (idna-to-unicode ace))))
2349 (unless (string= ace unicode)
2350 (replace-match unicode nil nil nil 1)))))))))
2352 (defun article-de-quoted-unreadable (&optional force read-charset)
2353 "Translate a quoted-printable-encoded article.
2354 If FORCE, decode the article whether it is marked as quoted-printable
2356 If READ-CHARSET, ask for a coding system."
2357 (interactive (list 'force current-prefix-arg))
2359 (let ((inhibit-read-only t) type charset)
2360 (if (gnus-buffer-live-p gnus-original-article-buffer)
2361 (with-current-buffer gnus-original-article-buffer
2363 (gnus-fetch-field "content-transfer-encoding"))
2364 (let* ((ct (gnus-fetch-field "content-type"))
2367 (mail-header-parse-content-type ct)))))
2368 (setq charset (and ctl
2369 (mail-content-type-get ctl 'charset)))
2370 (if (stringp charset)
2371 (setq charset (intern (downcase charset)))))))
2373 (setq charset (mm-read-coding-system "Charset: " charset)))
2375 (setq charset gnus-newsgroup-charset))
2377 (and type (let ((case-fold-search t))
2378 (string-match "quoted-printable" type))))
2380 (quoted-printable-decode-region
2381 (point) (point-max) (mm-charset-to-coding-system charset))))))
2383 (defun article-de-base64-unreadable (&optional force read-charset)
2384 "Translate a base64 article.
2385 If FORCE, decode the article whether it is marked as base64 not.
2386 If READ-CHARSET, ask for a coding system."
2387 (interactive (list 'force current-prefix-arg))
2389 (let ((inhibit-read-only t) type charset)
2390 (if (gnus-buffer-live-p gnus-original-article-buffer)
2391 (with-current-buffer gnus-original-article-buffer
2393 (gnus-fetch-field "content-transfer-encoding"))
2394 (let* ((ct (gnus-fetch-field "content-type"))
2397 (mail-header-parse-content-type ct)))))
2398 (setq charset (and ctl
2399 (mail-content-type-get ctl 'charset)))
2400 (if (stringp charset)
2401 (setq charset (intern (downcase charset)))))))
2403 (setq charset (mm-read-coding-system "Charset: " charset)))
2405 (setq charset gnus-newsgroup-charset))
2407 (and type (let ((case-fold-search t))
2408 (string-match "base64" type))))
2411 (narrow-to-region (point) (point-max))
2412 (base64-decode-region (point-min) (point-max))
2413 (mm-decode-coding-region
2414 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2419 (defun article-decode-HZ ()
2420 "Translate a HZ-encoded article."
2424 (let ((inhibit-read-only t))
2425 (rfc1843-decode-region (point-min) (point-max)))))
2427 (defun article-unsplit-urls ()
2428 "Remove the newlines that some other mailers insert into URLs."
2431 (let ((inhibit-read-only t))
2432 (goto-char (point-min))
2433 (while (re-search-forward
2434 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2435 (replace-match "\\1\\3" t)))
2436 (when (interactive-p)
2437 (gnus-treat-article nil))))
2440 (defun article-wash-html (&optional read-charset)
2441 "Format an HTML article.
2442 If READ-CHARSET, ask for a coding system."
2445 (let ((inhibit-read-only t)
2447 (when (gnus-buffer-live-p gnus-original-article-buffer)
2448 (with-current-buffer gnus-original-article-buffer
2449 (let* ((ct (gnus-fetch-field "content-type"))
2452 (mail-header-parse-content-type ct)))))
2453 (setq charset (and ctl
2454 (mail-content-type-get ctl 'charset)))
2455 (when (stringp charset)
2456 (setq charset (intern (downcase charset)))))))
2458 (setq charset (mm-read-coding-system "Charset: " charset)))
2460 (setq charset gnus-newsgroup-charset))
2462 (save-window-excursion
2464 (narrow-to-region (point) (point-max))
2465 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2466 (entry (assq func mm-text-html-washer-alist)))
2468 (setq func (cdr entry)))
2473 (apply (car func) (cdr func))))))))))
2475 (defun gnus-article-wash-html-with-w3 ()
2476 "Wash the current buffer with w3."
2478 (let ((w3-strict-width (window-width))
2479 (url-standalone-mode t)
2480 (url-gateway-unplugged t)
2481 (w3-honor-stylesheets nil))
2483 (w3-region (point-min) (point-max))
2486 (defun gnus-article-wash-html-with-w3m ()
2487 "Wash the current buffer with emacs-w3m."
2490 (narrow-to-region (point) (point-max))
2491 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2492 w3m-force-redisplay)
2493 (w3m-region (point-min) (point-max)))
2494 (when (and mm-inline-text-html-with-w3m-keymap
2495 (boundp 'w3m-minor-mode-map)
2497 (add-text-properties
2498 (point-min) (point-max)
2499 (list 'keymap w3m-minor-mode-map
2500 ;; Put the mark meaning this part was rendered by emacs-w3m.
2501 'mm-inline-text-html-with-w3m t)))))
2503 (defun article-hide-list-identifiers ()
2504 "Remove list identifies from the Subject header.
2505 The `gnus-list-identifiers' variable specifies what to do."
2507 (let ((inhibit-point-motion-hooks t)
2508 (regexp (if (consp gnus-list-identifiers)
2509 (mapconcat 'identity gnus-list-identifiers " *\\|")
2510 gnus-list-identifiers))
2511 (inhibit-read-only t))
2515 (article-narrow-to-head)
2516 (goto-char (point-min))
2517 (while (re-search-forward
2518 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2520 (delete-region (match-beginning 2) (match-end 0))
2521 (beginning-of-line))
2522 (when (re-search-forward
2523 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2524 (delete-region (match-beginning 1) (match-end 1))))))))
2526 (defun article-hide-pem (&optional arg)
2527 "Toggle hiding of any PEM headers and signatures in the current article.
2528 If given a negative prefix, always show; if given a positive prefix,
2530 (interactive (gnus-article-hidden-arg))
2531 (unless (gnus-article-check-hidden-text 'pem arg)
2533 (let ((inhibit-read-only t) end)
2534 (goto-char (point-min))
2535 ;; Hide the horrendously ugly "header".
2536 (when (and (search-forward
2537 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2539 (setq end (1+ (match-beginning 0))))
2540 (gnus-add-wash-type 'pem)
2541 (gnus-article-hide-text-type
2543 (if (search-forward "\n\n" nil t)
2547 ;; Hide the trailer as well
2548 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2550 (gnus-article-hide-text-type
2551 (match-beginning 0) (match-end 0) 'pem)))))))
2553 (defun article-strip-banner ()
2554 "Strip the banners specified by the `banner' group parameter and by
2555 `gnus-article-address-banner-alist'."
2559 (let ((inhibit-point-motion-hooks t))
2560 (when (gnus-parameter-banner gnus-newsgroup-name)
2561 (article-really-strip-banner
2562 (gnus-parameter-banner gnus-newsgroup-name)))
2563 (when gnus-article-address-banner-alist
2564 (article-really-strip-banner
2565 (let ((from (save-restriction
2567 (article-narrow-to-head)
2568 (mail-fetch-field "from"))))
2571 (caar (mail-header-parse-addresses from))))
2573 (dolist (pair gnus-article-address-banner-alist)
2574 (when (string-match (car pair) from)
2575 (throw 'found (cdr pair)))))))))))))
2577 (defun article-really-strip-banner (banner)
2578 "Strip the banner specified by the argument."
2581 (let ((inhibit-point-motion-hooks t)
2582 (gnus-signature-limit nil)
2583 (inhibit-read-only t))
2586 ((eq banner 'signature)
2587 (when (gnus-article-narrow-to-signature)
2590 (delete-region (point) (point-max))))
2592 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2593 (while (re-search-forward banner nil t)
2594 (delete-region (match-beginning 0) (match-end 0)))))
2596 (while (re-search-forward banner nil t)
2597 (delete-region (match-beginning 0) (match-end 0)))))))))
2599 (defun article-babel ()
2600 "Translate article using an online translation service."
2604 (set-buffer gnus-article-buffer)
2605 (when (article-goto-body)
2606 (let* ((inhibit-read-only t)
2609 (orig (buffer-substring start end))
2610 (trans (babel-as-string orig)))
2612 (narrow-to-region start end)
2613 (delete-region start end)
2616 (defun article-hide-signature (&optional arg)
2617 "Hide the signature in the current article.
2618 If given a negative prefix, always show; if given a positive prefix,
2620 (interactive (gnus-article-hidden-arg))
2621 (unless (gnus-article-check-hidden-text 'signature arg)
2624 (let ((inhibit-read-only t))
2625 (when (gnus-article-narrow-to-signature)
2626 (gnus-article-hide-text-type
2627 (point-min) (point-max) 'signature))))))
2628 (gnus-set-mode-line 'article))
2630 (defun article-strip-headers-in-body ()
2631 "Strip offensive headers from bodies."
2635 (let ((case-fold-search t))
2636 (when (looking-at "x-no-archive:")
2637 (gnus-delete-line)))))
2639 (defun article-strip-leading-blank-lines ()
2640 "Remove all blank lines from the beginning of the article."
2643 (let ((inhibit-point-motion-hooks t)
2644 (inhibit-read-only t))
2645 (when (article-goto-body)
2646 (while (and (not (eobp))
2647 (looking-at "[ \t]*$"))
2648 (gnus-delete-line))))))
2650 (defun article-narrow-to-head ()
2651 "Narrow the buffer to the head of the message.
2652 Point is left at the beginning of the narrowed-to region."
2654 (goto-char (point-min))
2655 (if (search-forward "\n\n" nil 1)
2658 (goto-char (point-min)))
2660 (defun article-goto-body ()
2661 "Place point at the start of the body."
2662 (goto-char (point-min))
2664 ;; This variable is only bound when dealing with separate
2666 (article-goto-body-goes-to-point-min-p
2668 ((search-forward "\n\n" nil t)
2671 (goto-char (point-max))
2674 (defun article-strip-multiple-blank-lines ()
2675 "Replace consecutive blank lines with one empty line."
2678 (let ((inhibit-point-motion-hooks t)
2679 (inhibit-read-only t))
2680 ;; First make all blank lines empty.
2682 (while (re-search-forward "^[ \t]+$" nil t)
2683 (unless (gnus-annotation-in-region-p
2684 (match-beginning 0) (match-end 0))
2685 (replace-match "" nil t)))
2686 ;; Then replace multiple empty lines with a single empty line.
2688 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2689 (unless (gnus-annotation-in-region-p
2690 (match-beginning 0) (match-end 0))
2691 (delete-region (match-beginning 1) (match-end 1)))))))
2693 (defun article-strip-leading-space ()
2694 "Remove all white space from the beginning of the lines in the article."
2697 (let ((inhibit-point-motion-hooks t)
2698 (inhibit-read-only t))
2700 (while (re-search-forward "^[ \t]+" nil t)
2701 (replace-match "" t t)))))
2703 (defun article-strip-trailing-space ()
2704 "Remove all white space from the end of the lines in the article."
2707 (let ((inhibit-point-motion-hooks t)
2708 (inhibit-read-only t))
2710 (while (re-search-forward "[ \t]+$" nil t)
2711 (replace-match "" t t)))))
2713 (defun article-strip-blank-lines ()
2714 "Strip leading, trailing and multiple blank lines."
2716 (article-strip-leading-blank-lines)
2717 (article-remove-trailing-blank-lines)
2718 (article-strip-multiple-blank-lines))
2720 (defun article-strip-all-blank-lines ()
2721 "Strip all blank lines."
2724 (let ((inhibit-point-motion-hooks t)
2725 (inhibit-read-only t))
2727 (while (re-search-forward "^[ \t]*\n" nil t)
2728 (replace-match "" t t)))))
2730 (defun gnus-article-narrow-to-signature ()
2731 "Narrow to the signature; return t if a signature is found, else nil."
2732 (let ((inhibit-point-motion-hooks t))
2733 (when (gnus-article-search-signature)
2735 ;; Check whether we have some limits to what we consider
2736 ;; to be a signature.
2737 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2738 (list gnus-signature-limit)))
2740 (while (setq limit (pop limits))
2741 (if (or (and (integerp limit)
2742 (< (- (point-max) (point)) limit))
2744 (< (count-lines (point) (point-max)) limit))
2745 (and (functionp limit)
2747 (and (stringp limit)
2748 (not (re-search-forward limit nil t))))
2749 () ; This limit did not succeed.
2753 (narrow-to-region (point) (point-max))
2756 (defun gnus-article-search-signature ()
2757 "Search the current buffer for the signature separator.
2758 Put point at the beginning of the signature separator."
2759 (let ((cur (point)))
2760 (goto-char (point-max))
2761 (if (if (stringp gnus-signature-separator)
2762 (re-search-backward gnus-signature-separator nil t)
2763 (let ((seps gnus-signature-separator))
2765 (not (re-search-backward (car seps) nil t)))
2772 (defun gnus-article-hidden-arg ()
2773 "Return the current prefix arg as a number, or 0 if no prefix."
2774 (list (if current-prefix-arg
2775 (prefix-numeric-value current-prefix-arg)
2778 (defun gnus-article-check-hidden-text (type arg)
2779 "Return nil if hiding is necessary.
2780 Arg can be nil or a number. nil and positive means hide, negative
2781 means show, 0 means toggle."
2784 (let ((hide (gnus-article-hidden-text-p type)))
2790 (gnus-article-show-hidden-text type)
2793 (if (eq hide 'hidden)
2795 (gnus-article-show-hidden-text type)
2799 (defun gnus-article-hidden-text-p (type)
2800 "Say whether the current buffer contains hidden text of type TYPE."
2801 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2803 (not (get-text-property pos 'invisible))
2804 (not (get-text-property pos 'dummy-invisible)))
2806 (text-property-any (1+ pos) (point-max) 'article-type type)))
2811 (defun gnus-article-show-hidden-text (type &optional dummy)
2812 "Show all hidden text of type TYPE.
2813 Originally it is hide instead of DUMMY."
2814 (let ((inhibit-read-only t)
2815 (inhibit-point-motion-hooks t))
2816 (gnus-remove-text-properties-when
2818 (point-min) (point-max)
2819 (cons 'article-type (cons type
2820 gnus-hidden-properties)))
2821 (gnus-delete-wash-type type)))
2823 (defconst article-time-units
2824 `((year . ,(* 365.25 24 60 60))
2825 (week . ,(* 7 24 60 60))
2826 (day . ,(* 24 60 60))
2830 "Mapping from time units to seconds.")
2832 (defun gnus-article-forward-header ()
2833 "Move point to the start of the next header.
2834 If the current header is a continuation header, this can be several
2839 (if (looking-at "[ \t]+[^ \t]")
2843 (defun article-date-ut (&optional type highlight)
2844 "Convert DATE date to universal time in the current article.
2845 If TYPE is `local', convert to local time; if it is `lapsed', output
2846 how much time has lapsed since DATE. For `lapsed', the value of
2847 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2848 should replace the \"Date:\" one, or should be added below it."
2849 (interactive (list 'ut t))
2850 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2851 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
2855 (article-lapsed-timer
2859 (case-fold-search t)
2860 (inhibit-read-only t)
2861 (inhibit-point-motion-hooks t)
2862 pos date bface eface)
2866 (goto-char (point-min))
2867 (while (or (setq date (get-text-property (setq pos (point))
2869 (when (setq pos (next-single-property-change
2870 (point) 'original-date))
2871 (setq date (get-text-property pos 'original-date))
2873 (narrow-to-region pos (or (text-property-any pos (point-max)
2876 (goto-char (point-min))
2877 (when (re-search-forward tdate-regexp nil t)
2878 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2879 eface (get-text-property (1- (gnus-point-at-eol)) 'face)))
2880 (goto-char (point-min))
2882 ;; Delete any old Date headers.
2883 (while (re-search-forward date-regexp nil t)
2885 (delete-region (gnus-point-at-bol)
2887 (gnus-article-forward-header)
2889 (delete-region (gnus-point-at-bol)
2891 (gnus-article-forward-header)
2894 (setq pos (point))))
2895 (when (and (not pos)
2896 (re-search-forward tdate-regexp nil t))
2898 (gnus-goto-char pos)
2899 (insert (article-make-date-line date (or type 'ut)))
2905 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2906 (put-text-property (match-beginning 1) (1+ (match-end 1))
2908 (put-text-property (match-beginning 2) (match-end 2)
2910 (put-text-property (point-min) (1- (point-max)) 'original-date date)
2911 (goto-char (point-max))
2914 (defun article-make-date-line (date type)
2915 "Return a DATE line of TYPE."
2916 (unless (memq type '(local ut original user iso8601 lapsed english))
2917 (error "Unknown conversion type: %s" type))
2919 (let ((time (date-to-time date)))
2921 ;; Convert to the local timezone.
2923 (let ((tz (car (current-time-zone time))))
2924 (format "Date: %s %s%02d%02d" (current-time-string time)
2925 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2926 (/ (% (abs tz) 3600) 60))))
2927 ;; Convert to Universal Time.
2930 (current-time-string
2931 (let* ((e (parse-time-string date))
2932 (tm (apply 'encode-time e))
2934 (ls (- (cadr tm) (car (current-time-zone time)))))
2935 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2936 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2939 ;; Get the original date from the article.
2940 ((eq type 'original)
2941 (concat "Date: " (if (string-match "\n+$" date)
2942 (substring date 0 (match-beginning 0))
2944 ;; Let the user define the format.
2946 (let ((format (or (condition-case nil
2947 (with-current-buffer gnus-summary-buffer
2948 gnus-article-time-format)
2950 gnus-article-time-format)))
2951 (if (functionp format)
2952 (funcall format time)
2953 (concat "Date: " (format-time-string format time)))))
2956 (let ((tz (car (current-time-zone time))))
2959 (format-time-string "%Y%m%dT%H%M%S" time)
2960 (format "%s%02d%02d"
2961 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2962 (/ (% (abs tz) 3600) 60)))))
2963 ;; Do an X-Sent lapsed format.
2965 ;; If the date is seriously mangled, the timezone functions are
2966 ;; liable to bug out, so we ignore all errors.
2967 (let* ((now (current-time))
2968 (real-time (subtract-time now time))
2969 (real-sec (and real-time
2970 (+ (* (float (car real-time)) 65536)
2972 (sec (and real-time (abs real-sec)))
2982 ;; This is a bit convoluted, but basically we go
2983 ;; through the time units for years, weeks, etc,
2984 ;; and divide things to see whether that results
2985 ;; in positive answers.
2988 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2989 ;; The (remaining) seconds are too few to
2990 ;; be divided into this time unit.
2992 ;; It's big enough, so we output it.
2993 (setq sec (- sec (* num (cdr unit))))
2995 (concat (if prev ", " "") (int-to-string
2997 " " (symbol-name (car unit))
2998 (if (> num 1) "s" ""))
3000 article-time-units "")
3001 ;; If dates are odd, then it might appear like the
3002 ;; article was sent in the future.
3005 " in the future"))))))
3006 ;; Display the date in proper English
3008 (let ((dtime (decode-time time)))
3011 (number-to-string (nth 3 dtime))
3012 (let ((digit (% (nth 3 dtime) 10)))
3014 ((memq (nth 3 dtime) '(11 12 13)) "th")
3020 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3022 (number-to-string (nth 5 dtime))
3024 (format "%02d" (nth 2 dtime))
3026 (format "%02d" (nth 1 dtime)))))))
3028 (format "Date: %s (from Gnus)" date))))
3030 (defun article-date-local (&optional highlight)
3031 "Convert the current article date to the local timezone."
3032 (interactive (list t))
3033 (article-date-ut 'local highlight))
3035 (defun article-date-english (&optional highlight)
3036 "Convert the current article date to something that is proper English."
3037 (interactive (list t))
3038 (article-date-ut 'english highlight))
3040 (defun article-date-original (&optional highlight)
3041 "Convert the current article date to what it was originally.
3042 This is only useful if you have used some other date conversion
3043 function and want to see what the date was before converting."
3044 (interactive (list t))
3045 (article-date-ut 'original highlight))
3047 (defun article-date-lapsed (&optional highlight)
3048 "Convert the current article date to time lapsed since it was sent."
3049 (interactive (list t))
3050 (article-date-ut 'lapsed highlight))
3052 (defun article-update-date-lapsed ()
3053 "Function to be run from a timer to update the lapsed time line."
3055 (let (deactivate-mark)
3060 (set-buffer (window-buffer w))
3061 (when (eq major-mode 'gnus-article-mode)
3062 (let ((mark (point-marker)))
3063 (goto-char (point-min))
3064 (when (re-search-forward "^X-Sent:" nil t)
3065 (article-date-lapsed t))
3066 (goto-char (marker-position mark))
3067 (move-marker mark nil))))
3070 (defun gnus-start-date-timer (&optional n)
3071 "Start a timer to update the X-Sent header in the article buffers.
3072 The numerical prefix says how frequently (in seconds) the function
3077 (gnus-stop-date-timer)
3078 (setq article-lapsed-timer
3079 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
3081 (defun gnus-stop-date-timer ()
3082 "Stop the X-Sent timer."
3084 (when article-lapsed-timer
3085 (nnheader-cancel-timer article-lapsed-timer)
3086 (setq article-lapsed-timer nil)))
3088 (defun article-date-user (&optional highlight)
3089 "Convert the current article date to the user-defined format.
3090 This format is defined by the `gnus-article-time-format' variable."
3091 (interactive (list t))
3092 (article-date-ut 'user highlight))
3094 (defun article-date-iso8601 (&optional highlight)
3095 "Convert the current article date to ISO8601."
3096 (interactive (list t))
3097 (article-date-ut 'iso8601 highlight))
3099 (defmacro gnus-article-save-original-date (&rest forms)
3100 "Save the original date as a text property and evaluate FORMS."
3101 `(let* ((case-fold-search t)
3103 (goto-char (point-min))
3104 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3107 (date (when (and start
3108 (re-search-forward "[\t ]*\n\\([^\t ]\\|\\'\\)"
3110 (buffer-substring-no-properties start
3111 (match-beginning 0)))))
3112 (goto-char (point-max))
3113 (skip-chars-backward "\n")
3114 (put-text-property (point-min) (point) 'original-date date)
3116 (goto-char (point-max))
3117 (skip-chars-backward "\n")
3118 (put-text-property (point-min) (point) 'original-date date)))
3120 ;; (defun article-show-all ()
3121 ;; "Show all hidden text in the article buffer."
3124 ;; (let ((inhibit-read-only t))
3125 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3127 (defun article-remove-leading-whitespace ()
3128 "Remove excessive whitespace from all headers."
3132 (let ((inhibit-read-only t))
3133 (article-narrow-to-head)
3134 (goto-char (point-min))
3135 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3136 (delete-region (match-beginning 1) (match-end 1)))))))
3138 (defun article-emphasize (&optional arg)
3139 "Emphasize text according to `gnus-emphasis-alist'."
3140 (interactive (gnus-article-hidden-arg))
3141 (unless (gnus-article-check-hidden-text 'emphasis arg)
3145 (with-current-buffer gnus-summary-buffer
3146 gnus-article-emphasis-alist)
3148 gnus-emphasis-alist))
3149 (inhibit-read-only t)
3150 (props (append '(article-type emphasis)
3151 gnus-hidden-properties))
3152 regexp elem beg invisible visible face)
3155 (while (setq elem (pop alist))
3157 (setq regexp (car elem)
3158 invisible (nth 1 elem)
3159 visible (nth 2 elem)
3161 (while (re-search-forward regexp nil t)
3162 (when (and (match-beginning visible) (match-beginning invisible))
3163 (gnus-article-hide-text
3164 (match-beginning invisible) (match-end invisible) props)
3165 (gnus-article-unhide-text-type
3166 (match-beginning visible) (match-end visible) 'emphasis)
3167 (gnus-put-overlay-excluding-newlines
3168 (match-beginning visible) (match-end visible) 'face face)
3169 (gnus-add-wash-type 'emphasis)
3170 (goto-char (match-end invisible)))))))))
3172 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3173 "Setup newsgroup emphasis alist."
3174 (unless gnus-article-emphasis-alist
3175 (let ((name (and gnus-newsgroup-name
3176 (gnus-group-real-name gnus-newsgroup-name))))
3177 (make-local-variable 'gnus-article-emphasis-alist)
3178 (setq gnus-article-emphasis-alist
3180 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3181 (while (setq elem (pop alist))
3182 (when (and name (string-match (car elem) name))
3184 highlight (copy-sequence (cdr elem)))))
3186 (copy-sequence highlight-words)
3187 (if gnus-newsgroup-name
3188 (copy-sequence (gnus-group-find-parameter
3189 gnus-newsgroup-name 'highlight-words t)))
3190 gnus-emphasis-alist)))))
3193 (defvar gnus-summary-article-menu)
3194 (defvar gnus-summary-post-menu))
3196 ;;; Saving functions.
3198 (defun gnus-article-save (save-buffer file &optional num)
3199 "Save the currently selected article."
3200 (unless gnus-save-all-headers
3201 ;; Remove headers according to `gnus-saved-headers'.
3202 (let ((gnus-visible-headers
3203 (or gnus-saved-headers gnus-visible-headers))
3204 (gnus-article-buffer save-buffer))
3206 (set-buffer save-buffer)
3207 (article-hide-headers 1 t))))
3208 (save-window-excursion
3209 (if (not gnus-default-article-saver)
3210 (error "No default saver is defined")
3211 ;; !!! Magic! The saving functions all save
3212 ;; `gnus-save-article-buffer' (or so they think), but we
3213 ;; bind that variable to our save-buffer.
3214 (set-buffer gnus-article-buffer)
3215 (let* ((gnus-save-article-buffer save-buffer)
3218 ((not gnus-prompt-before-saving) 'default)
3219 ((eq gnus-prompt-before-saving 'always) nil)
3221 (gnus-number-of-articles-to-be-saved
3222 (when (eq gnus-prompt-before-saving t)
3224 (set-buffer gnus-article-current-summary)
3225 (funcall gnus-default-article-saver filename)))))
3227 (defun gnus-read-save-file-name (prompt &optional filename
3228 function group headers variable)
3230 (funcall function group headers (symbol-value variable)))
3235 ((eq filename 'default)
3241 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3244 (if (and gnus-number-of-articles-to-be-saved
3245 (> gnus-number-of-articles-to-be-saved 1))
3246 (format "these %d articles"
3247 gnus-number-of-articles-to-be-saved)
3250 ;; Let the split methods have their say.
3252 ;; No split name was found.
3255 (concat prompt " (default "
3256 (file-name-nondirectory default-name) ") ")
3257 (file-name-directory default-name)
3259 ;; A single group name is returned.
3260 ((stringp split-name)
3262 (funcall function split-name headers
3263 (symbol-value variable)))
3265 (concat prompt " (default "
3266 (file-name-nondirectory default-name) ") ")
3267 (file-name-directory default-name)
3269 ;; A single split name was found
3270 ((= 1 (length split-name))
3271 (let* ((name (expand-file-name
3273 gnus-article-save-directory))
3274 (dir (cond ((file-directory-p name)
3275 (file-name-as-directory name))
3276 ((file-exists-p name) name)
3277 (t gnus-article-save-directory))))
3279 (concat prompt " (default " name ") ")
3281 ;; A list of splits was found.
3283 (setq split-name (nreverse split-name))
3285 (let ((file-name-history
3286 (nconc split-name file-name-history)))
3290 (concat prompt " (`M-p' for defaults) ")
3291 gnus-article-save-directory
3293 gnus-article-save-directory)))
3294 (car (push result file-name-history)))))))
3295 ;; Create the directory.
3296 (gnus-make-directory (file-name-directory file))
3297 ;; If we have read a directory, we append the default file name.
3298 (when (file-directory-p file)
3299 (setq file (expand-file-name (file-name-nondirectory
3301 (file-name-as-directory file))))
3302 ;; Possibly translate some characters.
3303 (nnheader-translate-file-chars file))))))
3304 (gnus-make-directory (file-name-directory result))
3305 (set variable result)))
3307 (defun gnus-article-archive-name (group)
3308 "Return the first instance of an \"Archive-name\" in the current buffer."
3309 (let ((case-fold-search t))
3310 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3311 (nnheader-concat gnus-article-save-directory
3312 (match-string 1)))))
3314 (defun gnus-article-nndoc-name (group)
3315 "If GROUP is an nndoc group, return the name of the parent group."
3316 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3317 (gnus-group-get-parameter group 'save-article-group)))
3319 (defun gnus-summary-save-in-rmail (&optional filename)
3320 "Append this article to Rmail file.
3321 Optional argument FILENAME specifies file name.
3322 Directory to save to is default to `gnus-article-save-directory'."
3323 (setq filename (gnus-read-save-file-name
3324 "Save %s in rmail file:" filename
3325 gnus-rmail-save-name gnus-newsgroup-name
3326 gnus-current-headers 'gnus-newsgroup-last-rmail))
3327 (gnus-eval-in-buffer-window gnus-save-article-buffer
3331 (gnus-output-to-rmail filename))))
3334 (defun gnus-summary-save-in-mail (&optional filename)
3335 "Append this article to Unix mail file.
3336 Optional argument FILENAME specifies file name.
3337 Directory to save to is default to `gnus-article-save-directory'."
3338 (setq filename (gnus-read-save-file-name
3339 "Save %s in Unix mail file:" filename
3340 gnus-mail-save-name gnus-newsgroup-name
3341 gnus-current-headers 'gnus-newsgroup-last-mail))
3342 (gnus-eval-in-buffer-window gnus-save-article-buffer
3346 (if (and (file-readable-p filename)
3347 (file-regular-p filename)
3348 (mail-file-babyl-p filename))
3349 (rmail-output-to-rmail-file filename t)
3350 (gnus-output-to-mail filename)))))
3353 (defun gnus-summary-save-in-file (&optional filename overwrite)
3354 "Append this article to file.
3355 Optional argument FILENAME specifies file name.
3356 Directory to save to is default to `gnus-article-save-directory'."
3357 (setq filename (gnus-read-save-file-name
3358 "Save %s in file:" filename
3359 gnus-file-save-name gnus-newsgroup-name
3360 gnus-current-headers 'gnus-newsgroup-last-file))
3361 (gnus-eval-in-buffer-window gnus-save-article-buffer
3365 (when (and overwrite
3366 (file-exists-p filename))
3367 (delete-file filename))
3368 (gnus-output-to-file filename))))
3371 (defun gnus-summary-write-to-file (&optional filename)
3372 "Write this article to a file, overwriting it if the file exists.
3373 Optional argument FILENAME specifies file name.
3374 The directory to save in defaults to `gnus-article-save-directory'."
3375 (gnus-summary-save-in-file nil t))
3377 (defun gnus-summary-save-body-in-file (&optional filename)
3378 "Append this article body to a file.
3379 Optional argument FILENAME specifies file name.
3380 The directory to save in defaults to `gnus-article-save-directory'."
3381 (setq filename (gnus-read-save-file-name
3382 "Save %s body in file:" filename
3383 gnus-file-save-name gnus-newsgroup-name
3384 gnus-current-headers 'gnus-newsgroup-last-file))
3385 (gnus-eval-in-buffer-window gnus-save-article-buffer
3389 (when (article-goto-body)
3390 (narrow-to-region (point) (point-max)))
3391 (gnus-output-to-file filename))))
3394 (defun gnus-summary-save-in-pipe (&optional command)
3395 "Pipe this article to subprocess."
3397 (cond ((and (eq command 'default)
3398 gnus-last-shell-command)
3399 gnus-last-shell-command)
3404 "Shell command on %s: "
3405 (if (and gnus-number-of-articles-to-be-saved
3406 (> gnus-number-of-articles-to-be-saved 1))
3407 (format "these %d articles"
3408 gnus-number-of-articles-to-be-saved)
3410 gnus-last-shell-command))))
3411 (when (string-equal command "")
3412 (if gnus-last-shell-command
3413 (setq command gnus-last-shell-command)
3414 (error "A command is required")))
3415 (gnus-eval-in-buffer-window gnus-article-buffer
3418 (shell-command-on-region (point-min) (point-max) command nil)))
3419 (setq gnus-last-shell-command command))
3421 (defmacro gnus-read-string (prompt &optional initial-contents history
3423 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3424 (if (and (featurep 'xemacs)
3425 (< emacs-minor-version 2))
3426 `(read-string ,prompt ,initial-contents ,history)
3427 `(read-string ,prompt ,initial-contents ,history ,default-value)))
3429 (defun gnus-summary-pipe-to-muttprint (&optional command)
3430 "Pipe this article to muttprint."
3431 (setq command (gnus-read-string
3432 "Print using command: " gnus-summary-muttprint-program
3433 nil gnus-summary-muttprint-program))
3434 (gnus-summary-save-in-pipe command))
3436 ;;; Article file names when saving.
3438 (defun gnus-capitalize-newsgroup (newsgroup)
3439 "Capitalize NEWSGROUP name."
3440 (when (not (zerop (length newsgroup)))
3441 (concat (char-to-string (upcase (aref newsgroup 0)))
3442 (substring newsgroup 1))))
3444 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3445 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3446 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3447 Otherwise, it is like ~/News/news/group/num."
3450 (concat (if (gnus-use-long-file-name 'not-save)
3451 (gnus-capitalize-newsgroup newsgroup)
3452 (gnus-newsgroup-directory-form newsgroup))
3453 "/" (int-to-string (mail-header-number headers)))
3454 gnus-article-save-directory)))
3456 (string-equal (file-name-directory default)
3457 (file-name-directory last-file))
3458 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3460 (or last-file default))))
3462 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3463 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3464 If variable `gnus-use-long-file-name' is non-nil, it is
3465 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3468 (concat (if (gnus-use-long-file-name 'not-save)
3470 (gnus-newsgroup-directory-form newsgroup))
3471 "/" (int-to-string (mail-header-number headers)))
3472 gnus-article-save-directory)))
3474 (string-equal (file-name-directory default)
3475 (file-name-directory last-file))
3476 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3478 (or last-file default))))
3480 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3481 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3482 If variable `gnus-use-long-file-name' is non-nil, it is
3483 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3486 (if (gnus-use-long-file-name 'not-save)
3489 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3491 gnus-article-save-directory)))
3493 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3494 "Generate file name from sender."
3495 (let ((from (mail-header-from headers)))
3497 (if (and from (string-match "\\([^ <]+\\)@" from))
3498 (match-string 1 from)
3500 gnus-article-save-directory)))
3502 (defun article-verify-x-pgp-sig ()
3505 (if (gnus-buffer-live-p gnus-original-article-buffer)
3506 (let ((sig (with-current-buffer gnus-original-article-buffer
3507 (gnus-fetch-field "X-PGP-Sig")))
3511 (mml2015-clear-verify-function))
3513 (insert-buffer-substring gnus-original-article-buffer)
3514 (setq items (split-string sig))
3515 (message-narrow-to-head)
3516 (let ((inhibit-point-motion-hooks t)
3517 (case-fold-search t))
3518 ;; Don't verify multiple headers.
3519 (setq headers (mapconcat (lambda (header)
3521 (mail-fetch-field header)
3523 (split-string (nth 1 items) ",") "")))
3524 (delete-region (point-min) (point-max))
3525 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3526 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3531 (if (looking-at "^-")
3534 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3535 (insert "Version: " (car items) "\n\n")
3536 (insert (mapconcat 'identity (cddr items) "\n"))
3537 (insert "\n-----END PGP SIGNATURE-----\n")
3538 (let ((mm-security-handle (list (format "multipart/signed"))))
3539 (mml2015-clean-buffer)
3540 (let ((coding-system-for-write (or gnus-newsgroup-charset
3542 (funcall (mml2015-clear-verify-function)))
3544 (or (mm-handle-multipart-ctl-parameter
3545 mm-security-handle 'gnus-details)
3546 (mm-handle-multipart-ctl-parameter
3547 mm-security-handle 'gnus-info)))))
3549 (let ((inhibit-read-only t) bface eface)
3551 (message-narrow-to-head)
3552 (goto-char (point-max))
3554 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3555 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3556 (message-remove-header "X-Gnus-PGP-Verify")
3557 (if (re-search-forward "^X-PGP-Sig:" nil t)
3559 (goto-char (point-max)))
3560 (narrow-to-region (point) (point))
3561 (insert "X-Gnus-PGP-Verify: " info "\n")
3562 (goto-char (point-min))
3565 (if (not (looking-at "^[ \t]"))
3569 (goto-char (point-min))
3570 (when (looking-at "\\([^:]+\\): *")
3571 (put-text-property (match-beginning 1) (1+ (match-end 1))
3573 (put-text-property (match-end 0) (point-max)
3574 'face eface)))))))))
3576 (defun article-verify-cancel-lock ()
3577 "Verify Cancel-Lock header."
3579 (if (gnus-buffer-live-p gnus-original-article-buffer)
3580 (canlock-verify gnus-original-article-buffer)))
3587 (setq afunc (car func)
3590 gfunc (intern (format "gnus-%s" func))))
3592 (when (fboundp afunc)
3593 `(lambda (&optional interactive &rest args)
3594 ,(documentation afunc t)
3595 (interactive (list t))
3597 (set-buffer gnus-article-buffer)
3599 (call-interactively ',afunc)
3600 (apply ',afunc args))))))))
3601 '(article-hide-headers
3602 article-verify-x-pgp-sig
3603 article-verify-cancel-lock
3604 article-hide-boring-headers
3605 article-treat-overstrike
3606 article-fill-long-lines
3607 article-capitalize-sentences
3609 article-remove-leading-whitespace
3610 article-display-x-face
3611 article-display-face
3612 article-de-quoted-unreadable
3613 article-de-base64-unreadable
3616 article-unsplit-urls
3617 article-hide-list-identifiers
3618 article-strip-banner
3621 article-hide-signature
3622 article-strip-headers-in-body
3623 article-remove-trailing-blank-lines
3624 article-strip-leading-blank-lines
3625 article-strip-multiple-blank-lines
3626 article-strip-leading-space
3627 article-strip-trailing-space
3628 article-strip-blank-lines
3629 article-strip-all-blank-lines
3631 article-date-english
3632 article-date-iso8601
3633 article-date-original
3635 article-decode-mime-words
3636 article-decode-charset
3637 article-decode-encoded-words
3641 article-treat-dumbquotes
3642 article-normalize-headers
3643 ;; (article-show-all . gnus-article-show-all-headers)
3647 ;;; Gnus article mode
3650 (put 'gnus-article-mode 'mode-class 'special)
3652 (set-keymap-parent gnus-article-mode-map widget-keymap)
3654 (gnus-define-keys gnus-article-mode-map
3655 " " gnus-article-goto-next-page
3656 "\177" gnus-article-goto-prev-page
3657 [delete] gnus-article-goto-prev-page
3658 [backspace] gnus-article-goto-prev-page
3659 "\C-c^" gnus-article-refer-article
3660 "h" gnus-article-show-summary
3661 "s" gnus-article-show-summary
3662 "\C-c\C-m" gnus-article-mail
3663 "?" gnus-article-describe-briefly
3664 "e" gnus-summary-edit-article
3665 "<" beginning-of-buffer
3667 "\C-c\C-i" gnus-info-find-node
3669 "R" gnus-article-reply-with-original
3670 "F" gnus-article-followup-with-original
3671 "\C-hk" gnus-article-describe-key
3672 "\C-hc" gnus-article-describe-key-briefly
3674 "\C-d" gnus-article-read-summary-keys
3675 "\M-*" gnus-article-read-summary-keys
3676 "\M-#" gnus-article-read-summary-keys
3677 "\M-^" gnus-article-read-summary-keys
3678 "\M-g" gnus-article-read-summary-keys)
3680 (substitute-key-definition
3681 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3683 (defun gnus-article-make-menu-bar ()
3684 (unless (boundp 'gnus-article-commands-menu)
3685 (gnus-summary-make-menu-bar))
3686 (gnus-turn-off-edit-menu 'article)
3687 (unless (boundp 'gnus-article-article-menu)
3689 gnus-article-article-menu gnus-article-mode-map ""
3691 ["Scroll forwards" gnus-article-goto-next-page t]
3692 ["Scroll backwards" gnus-article-goto-prev-page t]
3693 ["Show summary" gnus-article-show-summary t]
3694 ["Fetch Message-ID at point" gnus-article-refer-article t]
3695 ["Mail to address at point" gnus-article-mail t]
3696 ["Send a bug report" gnus-bug t]))
3699 gnus-article-treatment-menu gnus-article-mode-map ""
3700 ;; Fixme: this should use :active (and maybe :visible).
3702 ["Hide headers" gnus-article-hide-headers t]
3703 ["Hide signature" gnus-article-hide-signature t]
3704 ["Hide citation" gnus-article-hide-citation t]
3705 ["Treat overstrike" gnus-article-treat-overstrike t]
3706 ["Remove carriage return" gnus-article-remove-cr t]
3707 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3708 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3709 ["Remove base64" gnus-article-de-base64-unreadable t]
3710 ["Treat html" gnus-article-wash-html t]
3711 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3712 ["Decode HZ" gnus-article-decode-HZ t]))
3714 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3716 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3718 (gnus-run-hooks 'gnus-article-menu-hook)))
3720 (defun gnus-article-mode ()
3721 "Major mode for displaying an article.
3723 All normal editing commands are switched off.
3725 The following commands are available in addition to all summary mode
3727 \\<gnus-article-mode-map>
3728 \\[gnus-article-next-page]\t Scroll the article one page forwards
3729 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3730 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3731 \\[gnus-article-show-summary]\t Display the summary buffer
3732 \\[gnus-article-mail]\t Send a reply to the address near point
3733 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3734 \\[gnus-info-find-node]\t Go to the Gnus info node"
3736 (kill-all-local-variables)
3737 (gnus-simplify-mode-line)
3738 (setq mode-name "Article")
3739 (setq major-mode 'gnus-article-mode)
3740 (make-local-variable 'minor-mode-alist)
3741 (use-local-map gnus-article-mode-map)
3742 (when (gnus-visual-p 'article-menu 'menu)
3743 (gnus-article-make-menu-bar)
3744 (when gnus-summary-tool-bar-map
3745 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3746 (gnus-update-format-specifications nil 'article-mode)
3747 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3748 (set (make-local-variable 'gnus-page-broken) nil)
3749 (make-local-variable 'gnus-button-marker-list)
3750 (make-local-variable 'gnus-article-current-summary)
3751 (make-local-variable 'gnus-article-mime-handles)
3752 (make-local-variable 'gnus-article-decoded-p)
3753 (make-local-variable 'gnus-article-mime-handle-alist)
3754 (make-local-variable 'gnus-article-wash-types)
3755 (make-local-variable 'gnus-article-image-alist)
3756 (make-local-variable 'gnus-article-charset)
3757 (make-local-variable 'gnus-article-ignored-charsets)
3758 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3759 (set (make-local-variable 'nobreak-char-display) nil)
3760 (gnus-set-default-directory)
3761 (buffer-disable-undo)
3762 (setq buffer-read-only t)
3763 (set-syntax-table gnus-article-mode-syntax-table)
3764 (mm-enable-multibyte)
3765 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3767 (defun gnus-article-setup-buffer ()
3768 "Initialize the article buffer."
3769 (let* ((name (if gnus-single-article-buffer "*Article*"
3770 (concat "*Article " gnus-newsgroup-name "*")))
3772 (progn (string-match "\\*Article" name)
3773 (concat " *Original Article"
3774 (substring name (match-end 0))))))
3775 (setq gnus-article-buffer name)
3776 (setq gnus-original-article-buffer original)
3777 (setq gnus-article-mime-handle-alist nil)
3778 ;; This might be a variable local to the summary buffer.
3779 (unless gnus-single-article-buffer
3781 (set-buffer gnus-summary-buffer)
3782 (setq gnus-article-buffer name)
3783 (setq gnus-original-article-buffer original)
3784 (gnus-set-global-variables)))
3785 (gnus-article-setup-highlight-words)
3786 ;; Init original article buffer.
3788 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3789 (mm-enable-multibyte)
3790 (setq major-mode 'gnus-original-article-mode)
3791 (make-local-variable 'gnus-original-article))
3792 (if (and (get-buffer name)
3793 (with-current-buffer name
3794 (if gnus-article-edit-mode
3795 (if (y-or-n-p "Article mode edit in progress; discard? ")
3797 (set-buffer-modified-p nil)
3798 (gnus-kill-buffer name)
3801 (error "Action aborted"))
3805 (set (make-local-variable 'gnus-article-edit-mode) nil)
3806 (when gnus-article-mime-handles
3807 (mm-destroy-parts gnus-article-mime-handles)
3808 (setq gnus-article-mime-handles nil))
3809 ;; Set it to nil in article-buffer!
3810 (setq gnus-article-mime-handle-alist nil)
3811 (buffer-disable-undo)
3812 (setq buffer-read-only t)
3813 ;; This list just keeps growing if we don't reset it.
3814 (setq gnus-button-marker-list nil)
3815 (unless (eq major-mode 'gnus-article-mode)
3816 (gnus-article-mode))
3819 (set-buffer (gnus-get-buffer-create name))
3821 (make-local-variable 'gnus-summary-buffer)
3822 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3823 (current-buffer)))))
3825 ;; Set article window start at LINE, where LINE is the number of lines
3826 ;; from the head of the article.
3827 (defun gnus-article-set-window-start (&optional line)
3829 (gnus-get-buffer-window gnus-article-buffer t)
3831 (set-buffer gnus-article-buffer)
3832 (goto-char (point-min))
3835 (gnus-message 6 "Moved to bookmark")
3836 (search-forward "\n\n" nil t)
3840 (defun gnus-article-prepare (article &optional all-headers header)
3841 "Prepare ARTICLE in article mode buffer.
3842 ARTICLE should either be an article number or a Message-ID.
3843 If ARTICLE is an id, HEADER should be the article headers.
3844 If ALL-HEADERS is non-nil, no headers are hidden."
3846 ;; Make sure we start in a summary buffer.
3847 (unless (eq major-mode 'gnus-summary-mode)
3848 (set-buffer gnus-summary-buffer))
3849 (setq gnus-summary-buffer (current-buffer))
3850 (let* ((gnus-article (if header (mail-header-number header) article))
3851 (summary-buffer (current-buffer))
3852 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3853 (group gnus-newsgroup-name)
3856 (gnus-article-setup-buffer)
3857 (set-buffer gnus-article-buffer)
3858 ;; Deactivate active regions.
3859 (when (and (boundp 'transient-mark-mode)
3860 transient-mark-mode)
3861 (setq mark-active nil))
3862 (if (not (setq result (let ((inhibit-read-only t))
3863 (gnus-request-article-this-buffer
3865 ;; There is no such article.
3867 (when (and (numberp article)
3868 (not (memq article gnus-newsgroup-sparse)))
3869 (setq gnus-article-current
3870 (cons gnus-newsgroup-name article))
3871 (set-buffer gnus-summary-buffer)
3872 (setq gnus-current-article article)
3873 (if (and (memq article gnus-newsgroup-undownloaded)
3874 (not (gnus-online (gnus-find-method-for-group
3875 gnus-newsgroup-name))))
3877 (gnus-summary-set-agent-mark article)
3878 (message "Message marked for downloading"))
3879 (gnus-summary-mark-article article gnus-canceled-mark)
3880 (unless (memq article gnus-newsgroup-sparse)
3881 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3882 (if (or (eq result 'pseudo)
3883 (eq result 'nneething))
3886 (set-buffer summary-buffer)
3887 (push article gnus-newsgroup-history)
3888 (setq gnus-last-article gnus-current-article
3889 gnus-current-article 0
3890 gnus-current-headers nil
3891 gnus-article-current nil)
3892 (if (eq result 'nneething)
3893 (gnus-configure-windows 'summary)
3894 (gnus-configure-windows 'article))
3895 (gnus-set-global-variables))
3896 (let ((gnus-article-mime-handle-alist-1
3897 gnus-article-mime-handle-alist))
3898 (gnus-set-mode-line 'article)))
3899 ;; The result from the `request' was an actual article -
3900 ;; or at least some text that is now displayed in the
3902 (when (and (numberp article)
3903 (not (eq article gnus-current-article)))
3904 ;; Seems like a new article has been selected.
3905 ;; `gnus-current-article' must be an article number.
3907 (set-buffer summary-buffer)
3908 (push article gnus-newsgroup-history)
3909 (setq gnus-last-article gnus-current-article
3910 gnus-current-article article
3911 gnus-current-headers
3912 (gnus-summary-article-header gnus-current-article)
3913 gnus-article-current
3914 (cons gnus-newsgroup-name gnus-current-article))
3915 (unless (vectorp gnus-current-headers)
3916 (setq gnus-current-headers nil))
3917 (gnus-summary-goto-subject gnus-current-article)
3918 (when (gnus-summary-show-thread)
3919 ;; If the summary buffer really was folded, the
3920 ;; previous goto may not actually have gone to
3921 ;; the right article, but the thread root instead.
3923 (gnus-summary-goto-subject gnus-current-article))
3924 (gnus-run-hooks 'gnus-mark-article-hook)
3925 (gnus-set-mode-line 'summary)
3926 (when (gnus-visual-p 'article-highlight 'highlight)
3927 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3928 ;; Set the global newsgroup variables here.
3929 (gnus-set-global-variables)
3930 (setq gnus-have-all-headers
3931 (or all-headers gnus-show-all-headers))))
3933 (gnus-configure-windows 'article))
3934 (when (or (numberp article)
3936 (gnus-article-prepare-display)
3938 (goto-char (point-min))
3939 (when gnus-break-pages
3940 (gnus-narrow-to-page)))
3941 (let ((gnus-article-mime-handle-alist-1
3942 gnus-article-mime-handle-alist))
3943 (gnus-set-mode-line 'article))
3947 (set-window-point (get-buffer-window (current-buffer)) (point))
3948 (gnus-configure-windows 'article)
3952 (defun gnus-article-prepare-display ()
3953 "Make the current buffer look like a nice article."
3954 ;; Hooks for getting information from the article.
3955 ;; This hook must be called before being narrowed.
3956 (let ((gnus-article-buffer (current-buffer))
3958 (inhibit-read-only t))
3959 (unless (eq major-mode 'gnus-article-mode)
3960 (gnus-article-mode))
3961 (setq buffer-read-only nil
3962 gnus-article-wash-types nil
3963 gnus-article-image-alist nil)
3964 (gnus-run-hooks 'gnus-tmp-internal-hook)
3965 (when gnus-display-mime-function
3966 (funcall gnus-display-mime-function))
3967 (gnus-run-hooks 'gnus-article-prepare-hook)))
3970 ;;; Gnus MIME viewing functions
3973 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3974 "Format of the MIME buttons.
3976 Valid specifiers include:
3978 %T MIME type, along with additional info
3979 %n The `name' parameter
3980 %d The description, if any
3981 %l The length of the encoded part
3982 %p The part identifier number
3983 %e Dots if the part isn't displayed
3985 General format specifiers can also be used. See Info node
3986 `(gnus)Formatting Variables'.")
3988 (defvar gnus-mime-button-line-format-alist
3989 '((?t gnus-tmp-type ?s)
3990 (?T gnus-tmp-type-long ?s)
3991 (?n gnus-tmp-name ?s)
3992 (?d gnus-tmp-description ?s)
3994 (?l gnus-tmp-length ?d)
3995 (?e gnus-tmp-dots ?s)))
3997 (defvar gnus-mime-button-commands
3998 '((gnus-article-press-button "\r" "Toggle Display")
3999 (gnus-mime-view-part "v" "View Interactively...")
4000 (gnus-mime-view-part-as-type "t" "View As Type...")
4001 (gnus-mime-view-part-as-charset "C" "View As charset...")
4002 (gnus-mime-save-part "o" "Save...")
4003 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4004 (gnus-mime-delete-part "d" "Delete part")
4005 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4006 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4007 (gnus-mime-view-part-internally "E" "View Internally")
4008 (gnus-mime-view-part-externally "e" "View Externally")
4009 (gnus-mime-print-part "p" "Print")
4010 (gnus-mime-pipe-part "|" "Pipe To Command...")
4011 (gnus-mime-action-on-part "." "Take action on the part...")))
4013 (defun gnus-article-mime-part-status ()
4014 (if gnus-article-mime-handle-alist-1
4015 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4017 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4020 (defvar gnus-mime-button-map
4021 (let ((map (make-sparse-keymap)))
4022 (unless (>= (string-to-number emacs-version) 21)
4023 ;; XEmacs doesn't care.
4024 (set-keymap-parent map gnus-article-mode-map))
4025 (define-key map gnus-mouse-2 'gnus-article-push-button)
4026 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4027 (dolist (c gnus-mime-button-commands)
4028 (define-key map (cadr c) (car c)))
4032 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4034 ,@(mapcar (lambda (c)
4035 (vector (caddr c) (car c) :enable t))
4036 gnus-mime-button-commands)))
4039 (define-compiler-macro popup-menu (&whole form
4040 menu &optional position prefix)
4041 (if (and (fboundp 'popup-menu)
4042 (not (memq 'popup-menu (assoc "lmenu" load-history))))
4044 ;; Gnus is probably running under Emacs 20.
4045 `(let* ((menu (cdr ,menu))
4046 (response (x-popup-menu
4048 (cons "" (mapcar (lambda (c)
4049 (cons (caddr c) (car c)))
4052 (call-interactively (nth 3 (assq response menu))))))))
4054 (defun gnus-mime-button-menu (event prefix)
4055 "Construct a context-sensitive menu of MIME commands."
4056 (interactive "e\nP")
4057 (save-window-excursion
4058 (let ((pos (event-start event)))
4059 (select-window (posn-window pos))
4060 (goto-char (posn-point pos))
4061 (gnus-article-check-buffer)
4062 (popup-menu gnus-mime-button-menu nil prefix))))
4064 (defun gnus-mime-view-all-parts (&optional handles)
4065 "View all the MIME parts."
4067 (save-current-buffer
4068 (set-buffer gnus-article-buffer)
4069 (let ((handles (or handles gnus-article-mime-handles))
4070 (mail-parse-charset gnus-newsgroup-charset)
4071 (mail-parse-ignored-charsets
4072 (with-current-buffer gnus-summary-buffer
4073 gnus-newsgroup-ignored-charsets)))
4075 (mm-remove-parts handles)
4076 (goto-char (point-min))
4077 (or (search-forward "\n\n") (goto-char (point-max)))
4078 (let ((inhibit-read-only t))
4079 (delete-region (point) (point-max))
4080 (mm-display-parts handles))))))
4082 (defun gnus-mime-save-part-and-strip ()
4083 "Save the MIME part under point then replace it with an external body."
4085 (gnus-article-check-buffer)
4086 (when (gnus-group-read-only-p)
4087 (error "The current group does not support deleting of parts"))
4088 (when (mm-complicated-handles gnus-article-mime-handles)
4090 The current article has a complicated MIME structure, giving up..."))
4091 (when (gnus-yes-or-no-p "\
4092 Deleting parts may malfunction or destroy the article; continue? ")
4093 (let* ((data (get-text-property (point) 'gnus-data))
4095 (handles gnus-article-mime-handles))
4096 (setq file (and data (mm-save-part data)))
4098 (with-current-buffer (mm-handle-buffer data)
4100 (insert "Content-Type: " (mm-handle-media-type data))
4101 (mml-insert-parameter-string (cdr (mm-handle-type data))
4104 (insert "Content-ID: " (message-make-message-id) "\n")
4105 (insert "Content-Transfer-Encoding: binary\n")
4108 (cdr (mm-make-handle nil
4109 `("message/external-body"
4110 (access-type . "LOCAL-FILE")
4112 (set-buffer gnus-summary-buffer)
4113 (gnus-article-edit-article
4116 (let ((mail-parse-charset (or gnus-article-charset
4117 ',gnus-newsgroup-charset))
4118 (mail-parse-ignored-charsets
4119 (or gnus-article-ignored-charsets
4120 ',gnus-newsgroup-ignored-charsets))
4121 (mbl mml-buffer-list))
4122 (setq mml-buffer-list nil)
4123 (insert-buffer-substring gnus-original-article-buffer)
4124 (mime-to-mml ',handles)
4125 (setq gnus-article-mime-handles nil)
4126 (let ((mbl1 mml-buffer-list))
4127 (setq mml-buffer-list mbl)
4128 (set (make-local-variable 'mml-buffer-list) mbl1))
4129 (gnus-make-local-hook 'kill-buffer-hook)
4130 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4131 `(lambda (no-highlight)
4132 (let ((mail-parse-charset (or gnus-article-charset
4133 ',gnus-newsgroup-charset))
4134 (message-options message-options)
4135 (message-options-set-recipient)
4136 (mail-parse-ignored-charsets
4137 (or gnus-article-ignored-charsets
4138 ',gnus-newsgroup-ignored-charsets)))
4140 (mml-destroy-buffers)
4141 (remove-hook 'kill-buffer-hook
4142 'mml-destroy-buffers t)
4143 (kill-local-variable 'mml-buffer-list))
4144 (gnus-summary-edit-article-done
4145 ,(or (mail-header-references gnus-current-headers) "")
4146 ,(gnus-group-read-only-p)
4147 ,gnus-summary-buffer no-highlight)))))))
4149 (defun gnus-mime-delete-part ()
4150 "Delete the MIME part under point.
4151 Replace it with some information about the removed part."
4153 (gnus-article-check-buffer)
4154 (when (gnus-group-read-only-p)
4155 (error "The current group does not support deleting of parts"))
4156 (when (mm-complicated-handles gnus-article-mime-handles)
4158 The current article has a complicated MIME structure, giving up..."))
4159 (when (gnus-yes-or-no-p "\
4160 Deleting parts may malfunction or destroy the article; continue? ")
4161 (let* ((data (get-text-property (point) 'gnus-data))
4162 (handles gnus-article-mime-handles)
4166 (mail-decode-encoded-word-string (or (mm-handle-description data)
4169 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4171 (type (mm-handle-media-type data)))
4173 (error "No MIME part under point"))
4174 (with-current-buffer (mm-handle-buffer data)
4175 (let ((bsize (format "%s" (buffer-size))))
4180 "| The following attachment has been deleted:\n"
4182 "| Type: " type "\n"
4183 "| Filename: " filename "\n"
4184 "| Size (encoded): " bsize " Byte\n"
4185 "| Description: " description "\n"
4188 (cdr (mm-make-handle
4189 nil `("text/plain") nil nil
4191 (format "Deleted attachment (%s bytes)" bsize))))))
4192 (set-buffer gnus-summary-buffer)
4193 ;; FIXME: maybe some of the following code (borrowed from
4194 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4195 (gnus-article-edit-article
4198 (let ((mail-parse-charset (or gnus-article-charset
4199 ',gnus-newsgroup-charset))
4200 (mail-parse-ignored-charsets
4201 (or gnus-article-ignored-charsets
4202 ',gnus-newsgroup-ignored-charsets))
4203 (mbl mml-buffer-list))
4204 (setq mml-buffer-list nil)
4205 (insert-buffer-substring gnus-original-article-buffer)
4206 (mime-to-mml ',handles)
4207 (setq gnus-article-mime-handles nil)
4208 (let ((mbl1 mml-buffer-list))
4209 (setq mml-buffer-list mbl)
4210 (set (make-local-variable 'mml-buffer-list) mbl1))
4211 (gnus-make-local-hook 'kill-buffer-hook)
4212 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4213 `(lambda (no-highlight)
4214 (let ((mail-parse-charset (or gnus-article-charset
4215 ',gnus-newsgroup-charset))
4216 (message-options message-options)
4217 (message-options-set-recipient)
4218 (mail-parse-ignored-charsets
4219 (or gnus-article-ignored-charsets
4220 ',gnus-newsgroup-ignored-charsets)))
4222 (mml-destroy-buffers)
4223 (remove-hook 'kill-buffer-hook
4224 'mml-destroy-buffers t)
4225 (kill-local-variable 'mml-buffer-list))
4226 (gnus-summary-edit-article-done
4227 ,(or (mail-header-references gnus-current-headers) "")
4228 ,(gnus-group-read-only-p)
4229 ,gnus-summary-buffer no-highlight)))))
4230 ;; Not in `gnus-mime-save-part-and-strip':
4231 (gnus-article-edit-done)
4232 (gnus-summary-expand-window)
4233 (gnus-summary-show-article))
4235 (defun gnus-mime-save-part ()
4236 "Save the MIME part under point."
4238 (gnus-article-check-buffer)
4239 (let ((data (get-text-property (point) 'gnus-data)))
4241 (mm-save-part data))))
4243 (defun gnus-mime-pipe-part ()
4244 "Pipe the MIME part under point to a process."
4246 (gnus-article-check-buffer)
4247 (let ((data (get-text-property (point) 'gnus-data)))
4249 (mm-pipe-part data))))
4251 (defun gnus-mime-view-part ()
4252 "Interactively choose a viewing method for the MIME part under point."
4254 (gnus-article-check-buffer)
4255 (let ((data (get-text-property (point) 'gnus-data)))
4257 (setq gnus-article-mime-handles
4259 gnus-article-mime-handles (setq data (copy-sequence data))))
4260 (mm-interactively-view-part data))))
4262 (defun gnus-mime-view-part-as-type-internal ()
4263 (gnus-article-check-buffer)
4264 (let* ((name (mail-content-type-get
4265 (mm-handle-type (get-text-property (point) 'gnus-data))
4267 (def-type (and name (mm-default-file-encoding name))))
4268 (and def-type (cons def-type 0))))
4270 (defun gnus-mime-view-part-as-type (&optional mime-type)
4271 "Choose a MIME media type, and view the part as such."
4274 (setq mime-type (completing-read
4275 "View as MIME type: "
4276 (mapcar #'list (mailcap-mime-types))
4278 (gnus-mime-view-part-as-type-internal))))
4279 (gnus-article-check-buffer)
4280 (let ((handle (get-text-property (point) 'gnus-data)))
4283 (mm-make-handle (mm-handle-buffer handle)
4284 (cons mime-type (cdr (mm-handle-type handle)))
4285 (mm-handle-encoding handle)
4286 (mm-handle-undisplayer handle)
4287 (mm-handle-disposition handle)
4288 (mm-handle-description handle)
4290 (mm-handle-id handle)))
4291 (setq gnus-article-mime-handles
4292 (mm-merge-handles gnus-article-mime-handles handle))
4293 (gnus-mm-display-part handle))))
4296 (require 'jka-compr))
4298 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4299 ;; emacs can do that itself.
4301 (defun gnus-mime-jka-compr-maybe-uncompress ()
4302 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4303 The uncompress method used is derived from `buffer-file-name'."
4304 (when (and (fboundp 'jka-compr-installed-p)
4305 (jka-compr-installed-p))
4306 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4308 (let ((basename (file-name-nondirectory buffer-file-name))
4309 (args (jka-compr-info-uncompress-args info))
4310 (prog (jka-compr-info-uncompress-program info))
4311 (message (jka-compr-info-uncompress-message info))
4312 (err-file (jka-compr-make-temp-name)))
4314 (message "%s %s..." message basename))
4316 (unless (memq (apply 'call-process-region
4317 (point-min) (point-max)
4319 t (list t err-file) nil
4321 jka-compr-acceptable-retval-list)
4322 (jka-compr-error prog args basename message err-file))
4323 (jka-compr-delete-temp-file err-file)))))))
4325 (defun gnus-mime-copy-part (&optional handle)
4326 "Put the MIME part under point into a new buffer.
4327 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4330 (gnus-article-check-buffer)
4331 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4332 (contents (and handle (mm-get-part handle)))
4334 (file-name-nondirectory
4336 (mail-content-type-get (mm-handle-type handle) 'name)
4337 (mail-content-type-get (mm-handle-disposition handle)
4340 (buffer (and base (generate-new-buffer base))))
4342 (switch-to-buffer buffer)
4344 ;; We do it this way to make `normal-mode' set the appropriate mode.
4347 (setq buffer-file-name (expand-file-name base))
4348 (gnus-mime-jka-compr-maybe-uncompress)
4350 (setq buffer-file-name nil))
4351 (goto-char (point-min)))))
4353 (defun gnus-mime-print-part (&optional handle filename)
4354 "Print the MIME part under point."
4355 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4356 (gnus-article-check-buffer)
4357 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4358 (contents (and handle (mm-get-part handle)))
4359 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4360 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4365 (mm-save-part-to-file handle file)
4366 (call-process shell-file-name nil
4367 (generate-new-buffer " *mm*")
4369 shell-command-switch
4371 printer file (mm-handle-type handle))))
4375 (gnus-print-buffer))
4376 (ps-despool filename)))))
4378 (defun gnus-mime-inline-part (&optional handle arg)
4379 "Insert the MIME part under point into the current buffer."
4380 (interactive (list nil current-prefix-arg))
4381 (gnus-article-check-buffer)
4382 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4385 (inhibit-read-only t))
4387 (if (and (not arg) (mm-handle-undisplayer handle))
4388 (mm-remove-part handle)
4389 (setq contents (mm-get-part handle))
4392 (setq charset (or (mail-content-type-get
4393 (mm-handle-type handle) 'charset)
4394 gnus-newsgroup-charset)))
4396 (if (mm-handle-undisplayer handle)
4397 (mm-remove-part handle))
4400 gnus-summary-show-article-charset-alist))
4401 (mm-read-coding-system "Charset: "))))
4403 (if (mm-handle-undisplayer handle)
4404 (mm-remove-part handle))))
4409 (setq charset (mm-charset-to-coding-system
4411 (not (eq charset 'ascii)))
4412 (mm-decode-coding-string contents charset)
4413 (mm-string-to-multibyte contents)))
4416 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4417 "Insert the MIME part under point into the current buffer using the
4419 (interactive (list nil current-prefix-arg))
4420 (gnus-article-check-buffer)
4421 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4424 (inhibit-read-only t))
4426 (if (mm-handle-undisplayer handle)
4427 (mm-remove-part handle))
4428 (let ((gnus-newsgroup-charset
4430 gnus-summary-show-article-charset-alist))
4431 (mm-read-coding-system "Charset: ")))
4432 (gnus-newsgroup-ignored-charsets 'gnus-all))
4433 (gnus-article-press-button)))))
4435 (defun gnus-mime-view-part-externally (&optional handle)
4436 "View the MIME part under point with an external viewer."
4438 (gnus-article-check-buffer)
4439 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4440 (mm-user-display-methods nil)
4441 (mm-inlined-types nil)
4442 (mail-parse-charset gnus-newsgroup-charset)
4443 (mail-parse-ignored-charsets
4444 (save-excursion (set-buffer gnus-summary-buffer)
4445 gnus-newsgroup-ignored-charsets)))
4447 (if (mm-handle-undisplayer handle)
4448 (mm-remove-part handle)
4449 (mm-display-part handle)))))
4451 (defun gnus-mime-view-part-internally (&optional handle)
4452 "View the MIME part under point with an internal viewer.
4453 If no internal viewer is available, use an external viewer."
4455 (gnus-article-check-buffer)
4456 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4457 (mm-inlined-types '(".*"))
4458 (mm-inline-large-images t)
4459 (mail-parse-charset gnus-newsgroup-charset)
4460 (mail-parse-ignored-charsets
4461 (save-excursion (set-buffer gnus-summary-buffer)
4462 gnus-newsgroup-ignored-charsets))
4463 (inhibit-read-only t))
4465 (if (mm-handle-undisplayer handle)
4466 (mm-remove-part handle)
4467 (mm-display-part handle)))))
4469 (defun gnus-mime-action-on-part (&optional action)
4470 "Do something with the MIME attachment at \(point\)."
4472 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4473 (gnus-article-check-buffer)
4474 (let ((action-pair (assoc action gnus-mime-action-alist)))
4476 (funcall (cdr action-pair)))))
4478 (defun gnus-article-part-wrapper (n function)
4479 (save-current-buffer
4480 (set-buffer gnus-article-buffer)
4481 (when (> n (length gnus-article-mime-handle-alist))
4482 (error "No such part"))
4483 (gnus-article-goto-part n)
4484 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4485 (funcall function handle))))
4487 (defun gnus-article-pipe-part (n)
4488 "Pipe MIME part N, which is the numerical prefix."
4490 (gnus-article-part-wrapper n 'mm-pipe-part))
4492 (defun gnus-article-save-part (n)
4493 "Save MIME part N, which is the numerical prefix."
4495 (gnus-article-part-wrapper n 'mm-save-part))
4497 (defun gnus-article-interactively-view-part (n)
4498 "View MIME part N interactively, which is the numerical prefix."
4500 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4502 (defun gnus-article-copy-part (n)
4503 "Copy MIME part N, which is the numerical prefix."
4505 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4507 (defun gnus-article-view-part-as-charset (n)
4508 "View MIME part N using a specified charset.
4509 N is the numerical prefix."
4511 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4513 (defun gnus-article-view-part-externally (n)
4514 "View MIME part N externally, which is the numerical prefix."
4516 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4518 (defun gnus-article-inline-part (n)
4519 "Inline MIME part N, which is the numerical prefix."
4521 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4523 (defun gnus-article-mime-match-handle-first (condition)
4525 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4526 (while (setq ihandle (pop alist))
4528 ((functionp condition)
4529 (funcall condition (cdr ihandle)))
4530 ((eq condition 'undisplayed)
4531 (not (or (mm-handle-undisplayer (cdr ihandle))
4532 (equal (mm-handle-media-type (cdr ihandle))
4533 "multipart/alternative"))))
4534 ((eq condition 'undisplayed-alternative)
4535 (not (mm-handle-undisplayer (cdr ihandle))))
4537 (gnus-article-goto-part (car ihandle))
4538 (or (not n) (< (car ihandle) n)))
4539 (setq n (car ihandle))))
4543 (defun gnus-article-view-part (&optional n)
4544 "View MIME part N, which is the numerical prefix."
4546 (save-current-buffer
4547 (set-buffer gnus-article-buffer)
4548 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4549 gnus-article-mime-match-handle-function)))
4550 (when (> n (length gnus-article-mime-handle-alist))
4551 (error "No such part"))
4552 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4553 (when (gnus-article-goto-part n)
4554 (if (equal (car handle) "multipart/alternative")
4555 (gnus-article-press-button)
4556 (when (eq (gnus-mm-display-part handle) 'internal)
4557 (gnus-set-window-start)))))))
4559 (defsubst gnus-article-mime-total-parts ()
4560 (if (bufferp (car gnus-article-mime-handles))
4562 (1- (length gnus-article-mime-handles))))
4564 (defun gnus-mm-display-part (handle)
4565 "Display HANDLE and fix MIME button."
4566 (let ((id (get-text-property (point) 'gnus-part))
4568 (inhibit-read-only t))
4571 (let ((window (selected-window))
4572 (mail-parse-charset gnus-newsgroup-charset)
4573 (mail-parse-ignored-charsets
4574 (if (gnus-buffer-live-p gnus-summary-buffer)
4576 (set-buffer gnus-summary-buffer)
4577 gnus-newsgroup-ignored-charsets)
4581 (let ((win (gnus-get-buffer-window (current-buffer) t))
4584 (select-window win))
4587 (if (mm-handle-displayed-p handle)
4588 ;; This will remove the part.
4589 (mm-display-part handle)
4591 (narrow-to-region (point)
4592 (if (eobp) (point) (1+ (point))))
4593 (mm-display-part handle)
4594 ;; We narrow to the part itself and
4595 ;; then call the treatment functions.
4596 (goto-char (point-min))
4598 (narrow-to-region (point) (point-max))
4601 (gnus-article-mime-total-parts)
4602 (mm-handle-media-type handle)))))
4603 (if (window-live-p window)
4604 (select-window window)))))
4607 (gnus-insert-mime-button
4608 handle id (list (mm-handle-displayed-p handle)))
4609 (goto-char point))))
4611 (defun gnus-article-goto-part (n)
4612 "Go to MIME part N."
4613 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4615 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4616 (let ((gnus-tmp-name
4617 (or (mail-content-type-get (mm-handle-type handle) 'name)
4618 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4619 (mail-content-type-get (mm-handle-type handle) 'url)
4621 (gnus-tmp-type (mm-handle-media-type handle))
4622 (gnus-tmp-description
4623 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4626 (if (if displayed (car displayed)
4627 (mm-handle-displayed-p handle))
4629 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4631 gnus-tmp-type-long b e)
4632 (when (string-match ".*/" gnus-tmp-name)
4633 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4634 (setq gnus-tmp-type-long (concat gnus-tmp-type
4635 (and (not (equal gnus-tmp-name ""))
4636 (concat "; " gnus-tmp-name))))
4637 (unless (equal gnus-tmp-description "")
4638 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4643 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4644 `(,@(gnus-local-map-property gnus-mime-button-map)
4645 gnus-callback gnus-mm-display-part
4646 gnus-part ,gnus-tmp-id
4647 article-type annotation
4650 ;; Exclude a newline.
4653 (widget-convert-button
4656 :action 'gnus-widget-press-button
4657 :button-keymap gnus-mime-button-map
4659 (lambda (widget/window &optional overlay pos)
4660 ;; Needed to properly clear the message due to a bug in
4661 ;; wid-edit (XEmacs only).
4662 (if (boundp 'help-echo-owns-message)
4663 (setq help-echo-owns-message t))
4665 "%S: %s the MIME part; %S: more options"
4666 (aref gnus-mouse-2 0)
4667 ;; XEmacs will get a single widget arg; Emacs 21 will get
4668 ;; window, overlay, position.
4669 (if (mm-handle-displayed-p
4671 (with-current-buffer (gnus-overlay-buffer overlay)
4672 (widget-get (widget-at (gnus-overlay-start overlay))
4674 (widget-get widget/window :mime-handle)))
4676 (aref gnus-down-mouse-3 0))))))
4678 (defun gnus-widget-press-button (elems el)
4679 (goto-char (widget-get elems :from))
4680 (gnus-article-press-button))
4682 (defvar gnus-displaying-mime nil)
4684 (defun gnus-display-mime (&optional ihandles)
4685 "Display the MIME parts."
4687 (save-selected-window
4688 (let ((window (get-buffer-window gnus-article-buffer))
4691 (select-window window)
4692 ;; We have to do this since selecting the window
4693 ;; may change the point. So we set the window point.
4694 (set-window-point window point)))
4695 (let* ((handles (or ihandles
4696 (mm-dissect-buffer nil gnus-article-loose-mime)
4697 (and gnus-article-emulate-mime
4699 (inhibit-read-only t) handle name type b e display)
4700 (when (and (not ihandles)
4701 (not gnus-displaying-mime))
4702 ;; Top-level call; we clean up.
4703 (when gnus-article-mime-handles
4704 (mm-destroy-parts gnus-article-mime-handles)
4705 (setq gnus-article-mime-handle-alist nil));; A trick.
4706 (setq gnus-article-mime-handles handles)
4707 ;; We allow users to glean info from the handles.
4708 (when gnus-article-mime-part-function
4709 (gnus-mime-part-function handles)))
4711 (or (not (stringp (car handles)))
4714 (when (and (not ihandles)
4715 (not gnus-displaying-mime))
4716 ;; Clean up for mime parts.
4718 (delete-region (point) (point-max)))
4719 (let ((gnus-displaying-mime t))
4720 (gnus-mime-display-part handles)))
4723 (narrow-to-region (point) (point-max))
4724 (gnus-treat-article nil 1 1)
4727 ;; Highlight the headers.
4731 (narrow-to-region (point-min) (point))
4732 (gnus-article-save-original-date
4733 (gnus-treat-article 'head)))))))))
4735 (defcustom gnus-mime-display-multipart-as-mixed nil
4736 "Display \"multipart\" parts as \"multipart/mixed\".
4738 If t, it overrides nil values of
4739 `gnus-mime-display-multipart-alternative-as-mixed' and
4740 `gnus-mime-display-multipart-related-as-mixed'."
4741 :group 'gnus-article-mime
4744 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4745 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4747 :group 'gnus-article-mime
4750 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4751 "Display \"multipart/related\" parts as \"multipart/mixed\".
4753 If displaying \"text/html\" is discouraged \(see
4754 `mm-discouraged-alternatives'\) images or other material inside a
4755 \"multipart/related\" part might be overlooked when this variable is nil."
4757 :group 'gnus-article-mime
4760 (defun gnus-mime-display-part (handle)
4763 ((not (stringp (car handle)))
4764 (gnus-mime-display-single handle))
4765 ;; User-defined multipart
4766 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4767 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4769 ;; multipart/alternative
4770 ((and (equal (car handle) "multipart/alternative")
4771 (not (or gnus-mime-display-multipart-as-mixed
4772 gnus-mime-display-multipart-alternative-as-mixed)))
4773 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4774 (push (cons id handle) gnus-article-mime-handle-alist)
4775 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4776 ;; multipart/related
4777 ((and (equal (car handle) "multipart/related")
4778 (not (or gnus-mime-display-multipart-as-mixed
4779 gnus-mime-display-multipart-related-as-mixed)))
4780 ;;;!!!We should find the start part, but we just default
4781 ;;;!!!to the first part.
4782 ;;(gnus-mime-display-part (cadr handle))
4783 ;;;!!! Most multipart/related is an HTML message plus images.
4784 ;;;!!! Unfortunately we are unable to let W3 display those
4785 ;;;!!! included images, so we just display it as a mixed multipart.
4786 ;;(gnus-mime-display-mixed (cdr handle))
4787 ;;;!!! No, w3 can display everything just fine.
4788 (gnus-mime-display-part (cadr handle)))
4789 ((equal (car handle) "multipart/signed")
4790 (gnus-add-wash-type 'signed)
4791 (gnus-mime-display-security handle))
4792 ((equal (car handle) "multipart/encrypted")
4793 (gnus-add-wash-type 'encrypted)
4794 (gnus-mime-display-security handle))
4795 ;; Other multiparts are handled like multipart/mixed.
4797 (gnus-mime-display-mixed (cdr handle)))))
4799 (defun gnus-mime-part-function (handles)
4800 (if (stringp (car handles))
4801 (mapcar 'gnus-mime-part-function (cdr handles))
4802 (funcall gnus-article-mime-part-function handles)))
4804 (defun gnus-mime-display-mixed (handles)
4805 (mapcar 'gnus-mime-display-part handles))
4807 (defun gnus-mime-display-single (handle)
4808 (let ((type (mm-handle-media-type handle))
4809 (ignored gnus-ignored-mime-types)
4816 (when (string-match (pop ignored) type)
4817 (throw 'ignored nil)))
4818 (if (and (setq not-attachment
4819 (and (not (mm-inline-override-p handle))
4820 (or (not (mm-handle-disposition handle))
4821 (equal (car (mm-handle-disposition handle))
4823 (mm-attachment-override-p handle))))
4824 (mm-automatic-display-p handle)
4826 (mm-inlinable-p handle)
4827 (mm-inlined-p handle))
4828 (mm-automatic-external-display-p type)))
4830 (when (equal (mm-handle-media-supertype handle) "text")
4832 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4834 (push (cons id handle) gnus-article-mime-handle-alist)
4835 (when (or (not display)
4836 (not (gnus-unbuttonized-mime-type-p type)))
4837 ;(gnus-article-insert-newline)
4838 (gnus-insert-mime-button
4839 handle id (list (or display (and not-attachment text))))
4840 (gnus-article-insert-newline)
4841 ;(gnus-article-insert-newline)
4842 ;; Remember modify the number of forward lines.
4850 (let ((mail-parse-charset gnus-newsgroup-charset)
4851 (mail-parse-ignored-charsets
4852 (save-excursion (condition-case ()
4853 (set-buffer gnus-summary-buffer)
4855 gnus-newsgroup-ignored-charsets)))
4856 (mm-display-part handle t))
4857 (goto-char (point-max)))
4858 ((and text not-attachment)
4862 (gnus-article-insert-newline)
4863 (mm-insert-inline handle (mm-get-part handle))
4864 (goto-char (point-max))))
4868 (narrow-to-region beg (point))
4871 (gnus-article-mime-total-parts)
4872 (mm-handle-media-type handle)))))))))
4874 (defun gnus-unbuttonized-mime-type-p (type)
4875 "Say whether TYPE is to be unbuttonized."
4876 (unless gnus-inhibit-mime-unbuttonizing
4878 (let ((types gnus-unbuttonized-mime-types))
4880 (when (string-match (pop types) type)
4881 (throw 'found t)))))
4883 (let ((types gnus-buttonized-mime-types))
4885 (when (string-match (pop types) type)
4886 (throw 'found t)))))))))
4888 (defun gnus-article-insert-newline ()
4889 "Insert a newline, but mark it as undeletable."
4890 (gnus-put-text-property
4891 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4893 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4894 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4897 handle (inhibit-read-only t) from props begend not-pref)
4898 (save-window-excursion
4901 (narrow-to-region (car ibegend)
4904 (goto-char (car ibegend))
4907 (delete-region (point-min) (point-max))
4908 (mm-remove-parts handles))
4909 (setq begend (list (point-marker)))
4911 (unless (setq not-pref (cadr (member preferred ihandles)))
4912 (setq not-pref (car ihandles)))
4915 (not (gnus-unbuttonized-mime-type-p
4916 "multipart/alternative")))
4917 (gnus-add-text-properties
4920 (insert (format "%d. " id))
4924 (unless ,(not ibegend)
4925 (setq gnus-article-mime-handle-alist
4926 ',gnus-article-mime-handle-alist))
4927 (gnus-mime-display-alternative
4928 ',ihandles ',not-pref ',begend ,id))
4929 ,@(gnus-local-map-property gnus-mime-button-map)
4930 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4931 face ,gnus-article-button-face
4934 (widget-convert-button 'link from (point)
4935 :action 'gnus-widget-press-button
4936 :button-keymap gnus-widget-button-keymap)
4938 (while (setq handle (pop handles))
4939 (gnus-add-text-properties
4942 (insert (format "(%c) %-18s"
4943 (if (equal handle preferred) ?* ? )
4944 (mm-handle-media-type handle)))
4948 (unless ,(not ibegend)
4949 (setq gnus-article-mime-handle-alist
4950 ',gnus-article-mime-handle-alist))
4951 (gnus-mime-display-alternative
4952 ',ihandles ',handle ',begend ,id))
4953 ,@(gnus-local-map-property gnus-mime-button-map)
4954 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4955 face ,gnus-article-button-face
4958 (widget-convert-button 'link from (point)
4959 :action 'gnus-widget-press-button
4960 :button-keymap gnus-widget-button-keymap)
4964 (if (stringp (car preferred))
4965 (gnus-display-mime preferred)
4966 (let ((mail-parse-charset gnus-newsgroup-charset)
4967 (mail-parse-ignored-charsets
4968 (save-excursion (set-buffer gnus-summary-buffer)
4969 gnus-newsgroup-ignored-charsets)))
4970 (mm-display-part preferred)
4974 (narrow-to-region (car begend) (point-max))
4976 nil (length gnus-article-mime-handle-alist)
4977 (gnus-article-mime-total-parts)
4978 (mm-handle-media-type handle))))))
4979 (goto-char (point-max))
4980 (setcdr begend (point-marker)))))
4982 (goto-char point))))
4984 (defconst gnus-article-wash-status-strings
4985 (let ((alist '((cite "c" "Possible hidden citation text"
4986 " " "All citation text visible")
4987 (headers "h" "Hidden headers"
4988 " " "All headers visible.")
4989 (pgp "p" "Encrypted or signed message status hidden"
4990 " " "No hidden encryption nor digital signature status")
4991 (signature "s" "Signature has been hidden"
4992 " " "Signature is visible")
4993 (overstrike "o" "Overstrike (^H) characters applied"
4994 " " "No overstrike characters applied")
4995 (emphasis "e" "/*_Emphasis_*/ characters applied"
4996 " " "No /*_emphasis_*/ characters applied")))
4998 (dolist (entry alist result)
4999 (let ((key (nth 0 entry))
5000 (on (copy-sequence (nth 1 entry)))
5001 (on-help (nth 2 entry))
5002 (off (copy-sequence (nth 3 entry)))
5003 (off-help (nth 4 entry)))
5004 (put-text-property 0 1 'help-echo on-help on)
5005 (put-text-property 0 1 'help-echo off-help off)
5006 (push (list key on off) result))))
5007 "Alist of strings describing wash status in the mode line.
5008 Each entry has the form (KEY ON OF), where the KEY is a symbol
5009 representing the particular washing function, ON is the string to use
5010 in the article mode line when the washing function is active, and OFF
5011 is the string to use when it is inactive.")
5013 (defun gnus-article-wash-status-entry (key value)
5014 (let ((entry (assoc key gnus-article-wash-status-strings)))
5015 (if value (nth 1 entry) (nth 2 entry))))
5017 (defun gnus-article-wash-status ()
5018 "Return a string which display status of article washing."
5020 (set-buffer gnus-article-buffer)
5021 (let ((cite (memq 'cite gnus-article-wash-types))
5022 (headers (memq 'headers gnus-article-wash-types))
5023 (boring (memq 'boring-headers gnus-article-wash-types))
5024 (pgp (memq 'pgp gnus-article-wash-types))
5025 (pem (memq 'pem gnus-article-wash-types))
5026 (signed (memq 'signed gnus-article-wash-types))
5027 (encrypted (memq 'encrypted gnus-article-wash-types))
5028 (signature (memq 'signature gnus-article-wash-types))
5029 (overstrike (memq 'overstrike gnus-article-wash-types))
5030 (emphasis (memq 'emphasis gnus-article-wash-types)))
5032 (gnus-article-wash-status-entry 'cite cite)
5033 (gnus-article-wash-status-entry 'headers (or headers boring))
5034 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5035 (gnus-article-wash-status-entry 'signature signature)
5036 (gnus-article-wash-status-entry 'overstrike overstrike)
5037 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5039 (defun gnus-add-wash-type (type)
5040 "Add a washing of TYPE to the current status."
5041 (add-to-list 'gnus-article-wash-types type))
5043 (defun gnus-delete-wash-type (type)
5044 "Add a washing of TYPE to the current status."
5045 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5047 (defun gnus-add-image (category image)
5048 "Add IMAGE of CATEGORY to the list of displayed images."
5049 (let ((entry (assq category gnus-article-image-alist)))
5051 (setq entry (list category))
5052 (push entry gnus-article-image-alist))
5053 (nconc entry (list image))))
5055 (defun gnus-delete-images (category)
5056 "Delete all images in CATEGORY."
5057 (let ((entry (assq category gnus-article-image-alist)))
5058 (dolist (image (cdr entry))
5059 (gnus-remove-image image category))
5060 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5061 (gnus-delete-wash-type category)))
5063 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5065 (defun gnus-article-maybe-hide-headers ()
5066 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5067 Provided for backwards compatibility."
5068 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5069 (not (save-excursion (set-buffer gnus-summary-buffer)
5070 gnus-have-all-headers)))
5071 (not gnus-inhibit-hiding))
5072 (gnus-article-hide-headers)))
5076 (defun gnus-output-to-file (file-name)
5077 "Append the current article to a file named FILE-NAME."
5078 (let ((artbuf (current-buffer)))
5080 (insert-buffer-substring artbuf)
5081 ;; Append newline at end of the buffer as separator, and then
5083 (goto-char (point-max))
5085 (let ((file-name-coding-system nnmail-pathname-coding-system))
5086 (mm-append-to-file (point-min) (point-max) file-name))
5089 (defun gnus-narrow-to-page (&optional arg)
5090 "Narrow the article buffer to a page.
5091 If given a numerical ARG, move forward ARG pages."
5093 (setq arg (if arg (prefix-numeric-value arg) 0))
5095 (set-buffer gnus-article-buffer)
5096 (goto-char (point-min))
5098 ;; Remove any old next/prev buttons.
5099 (when (gnus-visual-p 'page-marker)
5100 (let ((inhibit-read-only t))
5101 (gnus-remove-text-with-property 'gnus-prev)
5102 (gnus-remove-text-with-property 'gnus-next)))
5105 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5107 (re-search-forward page-delimiter nil 'move arg)))
5108 (goto-char (match-end 0))
5110 (goto-char (point-min))
5111 (setq gnus-page-broken
5112 (and (re-search-forward page-delimiter nil t) t))))
5113 (when gnus-page-broken
5116 (if (re-search-forward page-delimiter nil 'move)
5119 (when (and (gnus-visual-p 'page-marker)
5120 (> (point-min) (save-restriction (widen) (point-min))))
5122 (goto-char (point-min))
5123 (gnus-insert-prev-page-button)))
5124 (when (and (gnus-visual-p 'page-marker)
5125 (< (point-max) (save-restriction (widen) (point-max))))
5127 (goto-char (point-max))
5128 (gnus-insert-next-page-button))))))
5130 ;; Article mode commands
5132 (defun gnus-article-goto-next-page ()
5133 "Show the next page of the article."
5135 (when (gnus-article-next-page)
5136 (goto-char (point-min))
5137 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5140 (defun gnus-article-goto-prev-page ()
5141 "Show the previous page of the article."
5144 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5145 (gnus-article-prev-page nil)))
5147 ;; This is cleaner but currently breaks `gnus-pick-mode':
5149 ;; (defun gnus-article-goto-next-page ()
5150 ;; "Show the next page of the article."
5152 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5153 ;; (gnus-summary-next-page)))
5155 ;; (defun gnus-article-goto-prev-page ()
5156 ;; "Show the next page of the article."
5158 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5159 ;; (gnus-summary-prev-page)))
5161 (defun gnus-article-next-page (&optional lines)
5162 "Show the next page of the current article.
5163 If end of article, return non-nil. Otherwise return nil.
5164 Argument LINES specifies lines to be scrolled up."
5166 (move-to-window-line -1)
5169 (and (pos-visible-in-window-p) ;Not continuation line.
5170 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5171 ;; Nothing in this page.
5172 (if (or (not gnus-page-broken)
5177 (eobp)))) ;Real end-of-buffer?
5179 (when gnus-article-over-scroll
5180 (gnus-article-next-page-1 lines))
5182 (gnus-narrow-to-page 1) ;Go to next page.
5184 ;; More in this page.
5185 (gnus-article-next-page-1 lines)
5188 (defmacro gnus-article-beginning-of-window ()
5189 "Move point to the beginning of the window.
5190 In Emacs, the point is placed at the line number which `scroll-margin'
5192 (if (featurep 'xemacs)
5193 '(move-to-window-line 0)
5194 '(move-to-window-line
5195 (min (max 0 scroll-margin)
5196 (max 1 (- (window-height)
5197 (if mode-line-format 1 0)
5198 (if (and (boundp 'header-line-format)
5199 (symbol-value 'header-line-format))
5202 (defun gnus-article-next-page-1 (lines)
5203 (when (and (not (featurep 'xemacs))
5206 (numberp (symbol-value 'scroll-margin))
5207 (> (symbol-value 'scroll-margin) 0))
5208 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5209 ;; too many number of lines if `scroll-margin' is set as two or greater.
5210 (setq lines (min lines
5211 (max 0 (- (count-lines (window-start) (point-max))
5212 (symbol-value 'scroll-margin))))))
5214 (let ((scroll-in-place nil))
5217 ;; Long lines may cause an end-of-buffer error.
5218 (goto-char (point-max))))
5219 (gnus-article-beginning-of-window))
5221 (defun gnus-article-prev-page (&optional lines)
5222 "Show previous page of current article.
5223 Argument LINES specifies lines to be scrolled down."
5225 (move-to-window-line 0)
5226 (if (and gnus-page-broken
5228 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5230 (gnus-narrow-to-page -1) ;Go to previous page.
5231 (goto-char (point-max))
5235 (let ((scroll-in-place nil))
5236 (scroll-down lines))
5237 (beginning-of-buffer
5238 (goto-char (point-min))))
5239 (gnus-article-beginning-of-window))))
5241 (defun gnus-article-only-boring-p ()
5242 "Decide whether there is only boring text remaining in the article.
5243 Something \"interesting\" is a word of at least two letters that does
5244 not have a face in `gnus-article-boring-faces'."
5245 (when (and gnus-article-skip-boring
5246 (boundp 'gnus-article-boring-faces)
5247 (symbol-value 'gnus-article-boring-faces))
5250 (while (re-search-forward "\\b\\w\\w" nil t)
5252 (when (not (gnus-intersection
5253 (gnus-faces-at (point))
5254 (symbol-value 'gnus-article-boring-faces)))
5255 (throw 'only-boring nil)))
5256 (throw 'only-boring t)))))
5258 (defun gnus-article-refer-article ()
5259 "Read article specified by message-id around point."
5262 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5263 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5264 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5265 (let ((msg-id (concat "<" (match-string 0) ">")))
5266 (set-buffer gnus-summary-buffer)
5267 (gnus-summary-refer-article msg-id))
5268 (error "No references around point"))))
5270 (defun gnus-article-show-summary ()
5271 "Reconfigure windows to show summary buffer."
5273 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5274 (error "There is no summary buffer for this article buffer")
5275 (gnus-article-set-globals)
5276 (gnus-configure-windows 'article)
5277 (gnus-summary-goto-subject gnus-current-article)
5278 (gnus-summary-position-point)))
5280 (defun gnus-article-describe-briefly ()
5281 "Describe article mode commands briefly."
5283 (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")))
5285 (defun gnus-article-summary-command ()
5286 "Execute the last keystroke in the summary buffer."
5288 (let ((obuf (current-buffer))
5289 (owin (current-window-configuration))
5291 (switch-to-buffer gnus-article-current-summary 'norecord)
5292 (setq func (lookup-key (current-local-map) (this-command-keys)))
5293 (call-interactively func)
5295 (set-window-configuration owin)
5296 (set-window-point (get-buffer-window (current-buffer)) (point))))
5298 (defun gnus-article-summary-command-nosave ()
5299 "Execute the last keystroke in the summary buffer."
5302 (pop-to-buffer gnus-article-current-summary 'norecord)
5303 (setq func (lookup-key (current-local-map) (this-command-keys)))
5304 (call-interactively func)))
5306 (defun gnus-article-check-buffer ()
5307 "Beep if not in an article buffer."
5308 (unless (equal major-mode 'gnus-article-mode)
5309 (error "Command invoked outside of a Gnus article buffer")))
5311 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5312 "Read a summary buffer key sequence and execute it from the article buffer."
5314 (gnus-article-check-buffer)
5316 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5317 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5318 "=" "^" "\M-^" "|"))
5324 '("n" "Gn" "p" "Gp"))
5327 (set-buffer gnus-article-current-summary)
5328 (let (gnus-pick-mode)
5329 (push (or key last-command-event) unread-command-events)
5330 (setq keys (if (featurep 'xemacs)
5331 (events-to-keys (read-key-sequence nil))
5332 (read-key-sequence nil)))))
5336 (if (or (member keys nosaves)
5337 (member keys nosave-but-article)
5338 (member keys nosave-in-article))
5340 (save-window-excursion
5341 (pop-to-buffer gnus-article-current-summary 'norecord)
5342 ;; We disable the pick minor mode commands.
5343 (let (gnus-pick-mode)
5344 (setq func (lookup-key (current-local-map) keys))))
5348 (unless (member keys nosave-in-article)
5349 (set-buffer gnus-article-current-summary))
5350 (call-interactively func)
5351 (setq new-sum-point (point)))
5352 (when (member keys nosave-but-article)
5353 (pop-to-buffer gnus-article-buffer 'norecord)))
5354 ;; These commands should restore window configuration.
5355 (let ((obuf (current-buffer))
5356 (owin (current-window-configuration))
5358 win func in-buffer selected new-sum-start new-sum-hscroll)
5359 (cond (not-restore-window
5360 (pop-to-buffer gnus-article-current-summary 'norecord))
5361 ((setq win (get-buffer-window gnus-article-current-summary))
5362 (select-window win))
5364 (switch-to-buffer gnus-article-current-summary 'norecord)))
5365 (setq in-buffer (current-buffer))
5366 ;; We disable the pick minor mode commands.
5367 (if (and (setq func (let (gnus-pick-mode)
5368 (lookup-key (current-local-map) keys)))
5371 (call-interactively func)
5372 (when (eq win (selected-window))
5373 (setq new-sum-point (point)
5374 new-sum-start (window-start win)
5375 new-sum-hscroll (window-hscroll win)))
5376 (when (eq in-buffer (current-buffer))
5377 (setq selected (gnus-summary-select-article))
5379 (unless not-restore-window
5380 (set-window-configuration owin))
5381 (when (eq selected 'old)
5383 (set-window-start (get-buffer-window (current-buffer))
5385 (set-window-point (get-buffer-window (current-buffer))
5387 (when (and (not not-restore-window)
5389 (set-window-point win new-sum-point)
5390 (set-window-start win new-sum-start)
5391 (set-window-hscroll win new-sum-hscroll))))
5392 (set-window-configuration owin)
5395 (defun gnus-article-describe-key (key)
5396 "Display documentation of the function invoked by KEY. KEY is a string."
5397 (interactive "kDescribe key: ")
5398 (gnus-article-check-buffer)
5399 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5401 (set-buffer gnus-article-current-summary)
5402 (let (gnus-pick-mode)
5403 (if (featurep 'xemacs)
5405 (push (elt key 0) unread-command-events)
5406 (setq key (events-to-keys
5407 (read-key-sequence "Describe key: "))))
5408 (setq unread-command-events
5410 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5411 (string-to-list key)))
5412 (setq key (read-key-sequence "Describe key: "))))
5414 (describe-key key)))
5416 (defun gnus-article-describe-key-briefly (key &optional insert)
5417 "Display documentation of the function invoked by KEY. KEY is a string."
5418 (interactive "kDescribe key: \nP")
5419 (gnus-article-check-buffer)
5420 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5422 (set-buffer gnus-article-current-summary)
5423 (let (gnus-pick-mode)
5424 (if (featurep 'xemacs)
5426 (push (elt key 0) unread-command-events)
5427 (setq key (events-to-keys
5428 (read-key-sequence "Describe key: "))))
5429 (setq unread-command-events
5431 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5432 (string-to-list key)))
5433 (setq key (read-key-sequence "Describe key: "))))
5434 (describe-key-briefly key insert))
5435 (describe-key-briefly key insert)))
5437 (defun gnus-article-reply-with-original (&optional wide)
5438 "Start composing a reply mail to the current message.
5439 The text in the region will be yanked. If the region isn't active,
5440 the entire article will be yanked."
5442 (let ((article (cdr gnus-article-current))
5444 (if (not (gnus-mark-active-p))
5445 (with-current-buffer gnus-summary-buffer
5446 (gnus-summary-reply (list (list article)) wide))
5447 (setq contents (buffer-substring (point) (mark t)))
5448 ;; Deactivate active regions.
5449 (when (and (boundp 'transient-mark-mode)
5450 transient-mark-mode)
5451 (setq mark-active nil))
5452 (with-current-buffer gnus-summary-buffer
5454 (list (list article contents)) wide)))))
5456 (defun gnus-article-followup-with-original ()
5457 "Compose a followup to the current article.
5458 The text in the region will be yanked. If the region isn't active,
5459 the entire article will be yanked."
5461 (let ((article (cdr gnus-article-current))
5463 (if (not (gnus-mark-active-p))
5464 (with-current-buffer gnus-summary-buffer
5465 (gnus-summary-followup (list (list article))))
5466 (setq contents (buffer-substring (point) (mark t)))
5467 ;; Deactivate active regions.
5468 (when (and (boundp 'transient-mark-mode)
5469 transient-mark-mode)
5470 (setq mark-active nil))
5471 (with-current-buffer gnus-summary-buffer
5472 (gnus-summary-followup
5473 (list (list article contents)))))))
5475 (defun gnus-article-hide (&optional arg force)
5476 "Hide all the gruft in the current article.
5477 This means that signatures, cited text and (some) headers will be
5479 If given a prefix, show the hidden text instead."
5480 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5481 (gnus-article-hide-headers arg)
5482 (gnus-article-hide-list-identifiers arg)
5483 (gnus-article-hide-citation-maybe arg force)
5484 (gnus-article-hide-signature arg))
5486 (defun gnus-article-maybe-highlight ()
5487 "Do some article highlighting if article highlighting is requested."
5488 (when (gnus-visual-p 'article-highlight 'highlight)
5489 (gnus-article-highlight-some)))
5491 (defun gnus-check-group-server ()
5492 ;; Make sure the connection to the server is alive.
5493 (unless (gnus-server-opened
5494 (gnus-find-method-for-group gnus-newsgroup-name))
5495 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5496 (gnus-request-group gnus-newsgroup-name t)))
5499 (autoload 'nneething-get-file-name "nneething"))
5501 (defun gnus-request-article-this-buffer (article group)
5502 "Get an article and insert it into this buffer."
5503 (let (do-update-line sparse-header)
5507 (gnus-kill-all-overlays)
5508 (setq group (or group gnus-newsgroup-name))
5510 ;; Using `gnus-request-article' directly will insert the article into
5511 ;; `nntp-server-buffer' - so we'll save some time by not having to
5512 ;; copy it from the server buffer into the article buffer.
5514 ;; We only request an article by message-id when we do not have the
5515 ;; headers for it, so we'll have to get those.
5516 (when (stringp article)
5517 (gnus-read-header article))
5519 ;; If the article number is negative, that means that this article
5520 ;; doesn't belong in this newsgroup (possibly), so we find its
5521 ;; message-id and request it by id instead of number.
5522 (when (and (numberp article)
5524 (get-buffer gnus-summary-buffer)
5525 (gnus-buffer-exists-p gnus-summary-buffer))
5527 (set-buffer gnus-summary-buffer)
5528 (let ((header (gnus-summary-article-header article)))
5531 ((memq article gnus-newsgroup-sparse)
5532 ;; This is a sparse gap article.
5533 (setq do-update-line article)
5534 (setq article (mail-header-id header))
5535 (setq sparse-header (gnus-read-header article))
5536 (setq gnus-newsgroup-sparse
5537 (delq article gnus-newsgroup-sparse)))
5539 ;; It's a real article.
5540 (setq article (mail-header-id header)))
5542 ;; It is an extracted pseudo-article.
5543 (setq article 'pseudo)
5544 (gnus-request-pseudo-article header))))
5546 (let ((method (gnus-find-method-for-group
5547 gnus-newsgroup-name)))
5548 (when (and (eq (car method) 'nneething)
5550 (let ((dir (nneething-get-file-name
5551 (mail-header-id header))))
5552 (when (and (stringp dir)
5553 (file-directory-p dir))
5554 (setq article 'nneething)
5555 (gnus-group-enter-directory dir))))))))
5558 ;; Refuse to select canceled articles.
5559 ((and (numberp article)
5561 (get-buffer gnus-summary-buffer)
5562 (gnus-buffer-exists-p gnus-summary-buffer)
5563 (eq (cdr (save-excursion
5564 (set-buffer gnus-summary-buffer)
5565 (assq article gnus-newsgroup-reads)))
5566 gnus-canceled-mark))
5568 ;; We first check `gnus-original-article-buffer'.
5569 ((and (get-buffer gnus-original-article-buffer)
5572 (set-buffer gnus-original-article-buffer)
5573 (and (equal (car gnus-original-article) group)
5574 (eq (cdr gnus-original-article) article))))
5575 (insert-buffer-substring gnus-original-article-buffer)
5577 ;; Check the backlog.
5578 ((and gnus-keep-backlog
5579 (gnus-backlog-request-article group article (current-buffer)))
5581 ;; Check asynchronous pre-fetch.
5582 ((gnus-async-request-fetched-article group article (current-buffer))
5583 (gnus-async-prefetch-next group article gnus-summary-buffer)
5584 (when (and (numberp article) gnus-keep-backlog)
5585 (gnus-backlog-enter-article group article (current-buffer)))
5588 ((and gnus-use-cache
5590 (gnus-cache-request-article article group))
5592 ;; Check the agent cache.
5593 ((gnus-agent-request-article article group)
5595 ;; Get the article and put into the article buffer.
5596 ((or (stringp article)
5598 (let ((gnus-override-method gnus-override-method)
5599 (methods (and (stringp article)
5600 gnus-refer-article-method))
5601 (backend (car (gnus-find-method-for-group
5602 gnus-newsgroup-name)))
5604 (inhibit-read-only t))
5605 (if (or (not (listp methods))
5606 (and (symbolp (car methods))
5607 (assq (car methods) nnoo-definition-alist)))
5608 (setq methods (list methods)))
5609 (when (and (null gnus-override-method)
5611 (setq gnus-override-method (pop methods)))
5613 (when (eq gnus-override-method 'current)
5614 (setq gnus-override-method
5615 (with-current-buffer gnus-summary-buffer
5616 gnus-current-select-method)))
5618 (gnus-kill-all-overlays)
5619 (let ((gnus-newsgroup-name group))
5620 (gnus-check-group-server))
5622 ((gnus-request-article article group (current-buffer))
5623 (when (numberp article)
5624 (gnus-async-prefetch-next group article
5625 gnus-summary-buffer)
5626 (when gnus-keep-backlog
5627 (gnus-backlog-enter-article
5628 group article (current-buffer))))
5629 (setq result 'article))
5631 (setq gnus-override-method (pop methods)))
5632 ((not (string-match "^400 "
5633 (nnheader-get-report backend)))
5634 ;; If we get 400 server disconnect, reconnect and
5635 ;; retry; otherwise, assume the article has expired.
5636 (setq result 'done))))
5637 (and (eq result 'article) 'article)))
5641 ;; Associate this article with the current summary buffer.
5642 (setq gnus-article-current-summary gnus-summary-buffer)
5644 ;; Take the article from the original article buffer
5645 ;; and place it in the buffer it's supposed to be in.
5646 (when (and (get-buffer gnus-article-buffer)
5647 (equal (buffer-name (current-buffer))
5648 (buffer-name (get-buffer gnus-article-buffer))))
5650 (if (get-buffer gnus-original-article-buffer)
5651 (set-buffer gnus-original-article-buffer)
5652 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5653 (buffer-disable-undo)
5654 (setq major-mode 'gnus-original-article-mode)
5655 (setq buffer-read-only t))
5656 (let ((inhibit-read-only t))
5658 (insert-buffer-substring gnus-article-buffer))
5659 (setq gnus-original-article (cons group article)))
5662 (run-hooks 'gnus-article-decode-hook)
5663 ;; Mark article as decoded or not.
5664 (setq gnus-article-decoded-p gnus-article-decode-hook))
5666 ;; Update sparse articles.
5667 (when (and do-update-line
5668 (or (numberp article)
5670 (let ((buf (current-buffer)))
5671 (set-buffer gnus-summary-buffer)
5672 (gnus-summary-update-article do-update-line sparse-header)
5673 (gnus-summary-goto-subject do-update-line nil t)
5674 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5676 (set-buffer buf))))))
5682 (defcustom gnus-article-edit-mode-hook nil
5683 "Hook run in article edit mode buffers."
5684 :group 'gnus-article-various
5687 (defvar gnus-article-edit-done-function nil)
5689 (defvar gnus-article-edit-mode-map nil)
5690 (defvar gnus-article-edit-mode nil)
5692 ;; Should we be using derived.el for this?
5693 (unless gnus-article-edit-mode-map
5694 (setq gnus-article-edit-mode-map (make-keymap))
5695 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5697 (gnus-define-keys gnus-article-edit-mode-map
5698 "\C-c?" describe-mode
5699 "\C-c\C-c" gnus-article-edit-done
5700 "\C-c\C-k" gnus-article-edit-exit
5701 "\C-c\C-f\C-t" message-goto-to
5702 "\C-c\C-f\C-o" message-goto-from
5703 "\C-c\C-f\C-b" message-goto-bcc
5704 ;;"\C-c\C-f\C-w" message-goto-fcc
5705 "\C-c\C-f\C-c" message-goto-cc
5706 "\C-c\C-f\C-s" message-goto-subject
5707 "\C-c\C-f\C-r" message-goto-reply-to
5708 "\C-c\C-f\C-n" message-goto-newsgroups
5709 "\C-c\C-f\C-d" message-goto-distribution
5710 "\C-c\C-f\C-f" message-goto-followup-to
5711 "\C-c\C-f\C-m" message-goto-mail-followup-to
5712 "\C-c\C-f\C-k" message-goto-keywords
5713 "\C-c\C-f\C-u" message-goto-summary
5714 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5715 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5716 "\C-c\C-b" message-goto-body
5717 "\C-c\C-i" message-goto-signature
5719 "\C-c\C-t" message-insert-to
5720 "\C-c\C-n" message-insert-newsgroups
5721 "\C-c\C-o" message-sort-headers
5722 "\C-c\C-e" message-elide-region
5723 "\C-c\C-v" message-delete-not-region
5724 "\C-c\C-z" message-kill-to-signature
5725 "\M-\r" message-newline-and-reformat
5726 "\C-c\C-a" mml-attach-file
5727 "\C-a" message-beginning-of-line
5729 "\M-;" comment-region)
5731 (gnus-define-keys (gnus-article-edit-wash-map
5732 "\C-c\C-w" gnus-article-edit-mode-map)
5733 "f" gnus-article-edit-full-stops))
5736 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5738 ["Fetch To" message-insert-to t]
5739 ["Fetch Newsgroups" message-insert-newsgroups t]
5741 ["To" message-goto-to t]
5742 ["From" message-goto-from t]
5743 ["Subject" message-goto-subject t]
5744 ["Cc" message-goto-cc t]
5745 ["Reply-To" message-goto-reply-to t]
5746 ["Summary" message-goto-summary t]
5747 ["Keywords" message-goto-keywords t]
5748 ["Newsgroups" message-goto-newsgroups t]
5749 ["Followup-To" message-goto-followup-to t]
5750 ["Mail-Followup-To" message-goto-mail-followup-to t]
5751 ["Distribution" message-goto-distribution t]
5752 ["Body" message-goto-body t]
5753 ["Signature" message-goto-signature t]))
5755 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5756 "Major mode for editing articles.
5757 This is an extended text-mode.
5759 \\{gnus-article-edit-mode-map}"
5760 (make-local-variable 'gnus-article-edit-done-function)
5761 (make-local-variable 'gnus-prev-winconf)
5762 (set (make-local-variable 'font-lock-defaults)
5763 '(message-font-lock-keywords t))
5764 (set (make-local-variable 'mail-header-separator) "")
5765 (set (make-local-variable 'gnus-article-edit-mode) t)
5766 (easy-menu-add message-mode-field-menu message-mode-map)
5768 (setq buffer-read-only nil)
5769 (buffer-enable-undo)
5772 (defun gnus-article-edit (&optional force)
5773 "Edit the current article.
5774 This will have permanent effect only in mail groups.
5775 If FORCE is non-nil, allow editing of articles even in read-only
5778 (when (and (not force)
5779 (gnus-group-read-only-p))
5780 (error "The current newsgroup does not support article editing"))
5781 (gnus-article-date-original)
5782 (gnus-article-edit-article
5784 `(lambda (no-highlight)
5786 (gnus-summary-edit-article-done
5787 ,(or (mail-header-references gnus-current-headers) "")
5788 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5790 (defun gnus-article-edit-article (start-func exit-func)
5791 "Start editing the contents of the current article buffer."
5792 (let ((winconf (current-window-configuration)))
5793 (set-buffer gnus-article-buffer)
5794 (let ((message-auto-save-directory
5795 ;; Don't associate the article buffer with a draft file.
5797 (gnus-article-edit-mode))
5798 (funcall start-func)
5799 (set-buffer-modified-p nil)
5800 (gnus-configure-windows 'edit-article)
5801 (setq gnus-article-edit-done-function exit-func)
5802 (setq gnus-prev-winconf winconf)
5803 (gnus-message 6 "C-c C-c to end edits")))
5805 (defun gnus-article-edit-done (&optional arg)
5806 "Update the article edits and exit."
5808 (let ((func gnus-article-edit-done-function)
5809 (buf (current-buffer))
5810 (start (window-start))
5812 (winconf gnus-prev-winconf))
5813 (widen) ;; Widen it in case that users narrowed the buffer.
5816 ;; The cache and backlog have to be flushed somewhat.
5817 (when gnus-keep-backlog
5818 (gnus-backlog-remove-article
5819 (car gnus-article-current) (cdr gnus-article-current)))
5820 ;; Flush original article as well.
5822 (when (get-buffer gnus-original-article-buffer)
5823 (set-buffer gnus-original-article-buffer)
5824 (setq gnus-original-article nil)))
5825 (when gnus-use-cache
5826 (gnus-cache-update-article
5827 (car gnus-article-current) (cdr gnus-article-current)))
5828 ;; We remove all text props from the article buffer.
5829 (kill-all-local-variables)
5830 (gnus-set-text-properties (point-min) (point-max) nil)
5832 (set-window-configuration winconf)
5834 (set-window-start (get-buffer-window buf) start)
5835 (set-window-point (get-buffer-window buf) (point)))
5836 (gnus-summary-show-article))
5838 (defun gnus-article-edit-exit ()
5839 "Exit the article editing without updating."
5841 (when (or (not (buffer-modified-p))
5842 (yes-or-no-p "Article modified; kill anyway? "))
5843 (let ((curbuf (current-buffer))
5845 (window-start (window-start)))
5847 (if (gnus-buffer-live-p gnus-original-article-buffer)
5848 (insert-buffer-substring gnus-original-article-buffer))
5849 (let ((winconf gnus-prev-winconf))
5850 (kill-all-local-variables)
5852 (set-window-configuration winconf)
5853 ;; Tippy-toe some to make sure that point remains where it was.
5854 (save-current-buffer
5856 (set-window-start (get-buffer-window (current-buffer)) window-start)
5858 (gnus-summary-show-article)))
5860 (defun gnus-article-edit-full-stops ()
5861 "Interactively repair spacing at end of sentences."
5864 (goto-char (point-min))
5865 (search-forward-regexp "^$" nil t)
5866 (let ((case-fold-search nil))
5867 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5870 ;;; Article highlights
5873 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5875 ;;; Internal Variables:
5877 (defcustom gnus-button-url-regexp
5878 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5879 "\\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:]]\\)"
5880 "\\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\\)\\)")
5881 "Regular expression that matches URLs."
5882 :group 'gnus-article-buttons
5885 (defcustom gnus-button-valid-fqdn-regexp
5886 message-valid-fqdn-regexp
5887 "Regular expression that matches a valid FQDN."
5889 :group 'gnus-article-buttons
5892 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5893 (defcustom gnus-button-valid-localpart-regexp
5894 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*"
5895 "Regular expression that matches a localpart of mail addresses or MIDs."
5897 :group 'gnus-article-buttons
5900 (defcustom gnus-button-man-handler 'manual-entry
5901 "Function to use for displaying man pages.
5902 The function must take at least one argument with a string naming the
5905 :type '(choice (function-item :tag "Man" manual-entry)
5906 (function-item :tag "Woman" woman)
5907 (function :tag "Other"))
5908 :group 'gnus-article-buttons)
5910 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5911 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5912 If the default site is too slow, try to find a CTAN mirror, see
5913 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5914 the variable `gnus-button-handle-ctan'."
5916 :group 'gnus-article-buttons
5917 :link '(custom-manual "(gnus)Group Parameters")
5918 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5919 (const "http://tug.ctan.org/tex-archive/")
5920 (const "http://www.dante.de/CTAN/")
5921 (string :tag "Other")))
5923 (defcustom gnus-button-ctan-handler 'browse-url
5924 "Function to use for displaying CTAN links.
5925 The function must take one argument, the string naming the URL."
5927 :type '(choice (function-item :tag "Browse Url" browse-url)
5928 (function :tag "Other"))
5929 :group 'gnus-article-buttons)
5931 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5932 "Bogus strings removed from CTAN URLs."
5934 :group 'gnus-article-buttons
5935 :type '(choice (const "^/?tex-archive/\\|/")
5936 (regexp :tag "Other")))
5938 (defcustom gnus-button-ctan-directory-regexp
5940 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
5941 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
5942 "languages" "macros" "nonfree" "obsolete" "support" "systems"
5943 "tds" "tools" "usergrps" "web") t)
5944 "Regular expression for ctan directories.
5945 It should match all directories in the top level of `gnus-ctan-url'."
5947 :group 'gnus-article-buttons
5950 (defcustom gnus-button-mid-or-mail-regexp
5951 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
5952 gnus-button-valid-fqdn-regexp
5954 "Regular expression that matches a message ID or a mail address."
5956 :group 'gnus-article-buttons
5959 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5960 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5961 Strings like this can be either a message ID or a mail address. If it is one
5962 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5963 message ID or a mail address, respectively. If this variable is set to the
5964 symbol `ask', always query the user what do do. If it is a function, this
5965 function will be called with the string as it's only argument. The function
5966 must return `mid', `mail', `invalid' or `ask'."
5968 :group 'gnus-article-buttons
5969 :type '(choice (function-item :tag "Heuristic function"
5970 gnus-button-mid-or-mail-heuristic)
5975 (defcustom gnus-button-mid-or-mail-heuristic-alist
5976 '((-10.0 . ".+\\$.+@")
5979 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5980 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5981 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5982 (-1.0 . "^[^a-z]+@")
5984 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5985 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5986 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5987 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5990 (-1.0 . "^[0-9][0-9]")
5992 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5993 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5994 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5995 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5997 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5998 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6001 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6003 ;; compensation for TDMA dated mail addresses:
6004 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6006 (-20.0 . "\\.fsf@") ;; Gnus
6009 (-20.0 . "_-_") ;; Subject change in thread
6011 (-20.0 . "\\.ln@") ;; leafnode
6012 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6013 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6015 ;; (5.0 . "") ;; $local_part_len <= 7
6016 (10.0 . "^[^0-9]+@")
6017 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6018 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6021 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6023 (0.5 . "^[A-Z][a-z]")
6024 (0.5 . "^[A-Z][a-z][a-z]")
6025 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6026 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6027 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6029 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6030 address. The REGEXP is processed with `case-fold-search' set to nil."
6032 :group 'gnus-article-buttons
6033 :type '(repeat (cons (number :tag "Rate")
6034 (regexp :tag "Regexp"))))
6036 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6037 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6038 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6039 address, `ask' if unsure and `invalid' if the string is invalid."
6040 (let ((case-fold-search nil)
6041 (list gnus-button-mid-or-mail-heuristic-alist)
6042 (result 0) rate regexp lpartlen elem)
6044 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6045 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6046 ;; Certain special cases...
6049 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6050 "^[0-9]+\\.[0-9]+@compuserve\\|"
6051 "@public\\.gmane\\.org")
6053 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6054 (setq result 'mail))
6055 (when (string-match "@.*@\\| " mid-or-mail)
6056 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6057 (setq result 'invalid))
6058 ;; Nothing more to do, if result is not a number here...
6059 (when (numberp result)
6061 (setq elem (car list)
6065 (when (string-match regexp mid-or-mail)
6066 (setq result (+ result rate))
6068 9 "`%s' matched `%s', rate `%s', result `%s'."
6069 mid-or-mail regexp rate result)))
6070 (when (<= lpartlen 7)
6071 (setq result (+ result 5.0))
6072 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6073 mid-or-mail result))
6074 (when (>= lpartlen 12)
6075 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6077 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6078 ;; Long local part should contain realname if e-mail address,
6079 ;; too many digits: message-id.
6080 ;; $score -= 5.0 + 0.1 * $local_part_len;
6081 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6082 (setq result (+ result rate))
6084 9 "Many digits in `%s', rate `%s', result `%s'."
6085 mid-or-mail rate result))
6086 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6088 ;; Too few vowels [^aeiouy]{4,}.*\@
6089 (setq result (+ result -5.0))
6091 9 "Few vowels in `%s', rate `%s', result `%s'."
6092 mid-or-mail -5.0 result))
6094 (setq result (+ result 5.0))
6096 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6097 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6098 ;; Maybe we should make this a customizable alist: (condition . 'result)
6100 ((symbolp result) result)
6101 ;; Now convert number into proper results:
6102 ((< result -10.0) 'mid)
6103 ((> result 10.0) 'mail)
6106 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6107 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6108 (url-mid (concat "news" ":" mid-or-mail))
6109 (url-mailto (concat "mailto" ":" mid-or-mail)))
6110 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6111 (when (fboundp pref)
6113 ;; get rid of surrounding angles...
6115 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6116 (if (or (eq 'mid guessed) (eq 'mail guessed))
6120 (save-window-excursion
6121 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6124 (cond ((eq pref 'mid)
6125 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6126 (gnus-button-handle-news url-mid))
6128 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6129 (gnus-url-mailto url-mailto))
6130 (t (gnus-message 3 "Invalid string.")))))
6132 (defun gnus-button-handle-custom (url)
6133 "Follow a Custom URL."
6134 (customize-apropos (gnus-url-unhex-string url)))
6136 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6138 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6141 (defun gnus-button-handle-describe-function (url)
6142 "Call `describe-function' when pushing the corresponding URL button."
6145 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6147 (defun gnus-button-handle-describe-variable (url)
6148 "Call `describe-variable' when pushing the corresponding URL button."
6151 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6153 (defun gnus-button-handle-symbol (url)
6154 "Display help on variable or function.
6155 Calls `describe-variable' or `describe-function'."
6156 (let ((sym (intern url)))
6158 ((fboundp sym) (describe-function sym))
6159 ((boundp sym) (describe-variable sym))
6160 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6162 (defun gnus-button-handle-describe-key (url)
6163 "Call `describe-key' when pushing the corresponding URL button."
6165 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6166 (keys (ignore-errors (eval `(kbd ,key-string)))))
6169 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6171 (defun gnus-button-handle-apropos (url)
6172 "Call `apropos' when pushing the corresponding URL button."
6173 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6175 (defun gnus-button-handle-apropos-command (url)
6176 "Call `apropos' when pushing the corresponding URL button."
6178 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6180 (defun gnus-button-handle-apropos-variable (url)
6181 "Call `apropos' when pushing the corresponding URL button."
6183 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6184 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6186 (defun gnus-button-handle-apropos-documentation (url)
6187 "Call `apropos' when pushing the corresponding URL button."
6189 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6190 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6192 (defun gnus-button-handle-library (url)
6193 "Call `locate-library' when pushing the corresponding URL button."
6194 (gnus-message 9 "url=`%s'" url)
6195 (let* ((lib (locate-library url))
6196 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6198 (gnus-message 1 "Cannot locale library `%s'." url)
6199 (find-file-read-only file))))
6201 (defun gnus-button-handle-ctan (url)
6202 "Call `browse-url' when pushing a CTAN URL button."
6204 gnus-button-ctan-handler
6207 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6209 (defcustom gnus-button-tex-level 5
6210 "*Integer that says how many TeX-related buttons Gnus will show.
6211 The higher the number, the more buttons will appear and the more false
6212 positives are possible. Note that you can set this variable local to
6213 specific groups. Setting it higher in TeX groups is probably a good idea.
6214 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6215 how to set variables in specific groups."
6217 :group 'gnus-article-buttons
6218 :link '(custom-manual "(gnus)Group Parameters")
6221 (defcustom gnus-button-man-level 5
6222 "*Integer that says how many man-related buttons Gnus will show.
6223 The higher the number, the more buttons will appear and the more false
6224 positives are possible. Note that you can set this variable local to
6225 specific groups. Setting it higher in Unix groups is probably a good idea.
6226 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6227 how to set variables in specific groups."
6229 :group 'gnus-article-buttons
6230 :link '(custom-manual "(gnus)Group Parameters")
6233 (defcustom gnus-button-emacs-level 5
6234 "*Integer that says how many emacs-related buttons Gnus will show.
6235 The higher the number, the more buttons will appear and the more false
6236 positives are possible. Note that you can set this variable local to
6237 specific groups. Setting it higher in Emacs or Gnus related groups is
6238 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6239 `gnus-parameters' on how to set variables in specific groups."
6241 :group 'gnus-article-buttons
6242 :link '(custom-manual "(gnus)Group Parameters")
6245 (defcustom gnus-button-message-level 5
6246 "*Integer that says how many buttons for news or mail messages will appear.
6247 The higher the number, the more buttons will appear and the more false
6248 positives are possible."
6249 ;; mail addresses, MIDs, URLs for news, ...
6251 :group 'gnus-article-buttons
6254 (defcustom gnus-button-browse-level 5
6255 "*Integer that says how many buttons for browsing will appear.
6256 The higher the number, the more buttons will appear and the more false
6257 positives are possible."
6258 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6260 :group 'gnus-article-buttons
6263 (defcustom gnus-button-alist
6264 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6265 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6266 ((concat "\\b\\(nntp\\|news\\):\\("
6267 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6268 0 t gnus-button-handle-news 2)
6269 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6270 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6271 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6272 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6273 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6274 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6275 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6276 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6277 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6278 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6279 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6280 ;; RFC 2368 (The mailto URL scheme)
6281 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6282 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6283 ("\\bmailto:\\([^ \n\t]+\\)"
6284 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6286 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6287 gnus-button-ctan-directory-regexp
6288 "[^][>)!;:,'\n\t ]+\\)")
6289 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6290 ((concat "\\btex-archive/\\("
6291 gnus-button-ctan-directory-regexp
6292 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6293 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6296 gnus-button-ctan-directory-regexp
6297 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6298 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6299 ;; This is info (home-grown style) <info://foo/bar+baz>
6300 ("\\binfo://\\([^'\">\n\t ]+\\)"
6301 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6302 ;; Info GNOME style <info:foo#bar_baz>
6303 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6304 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6305 ;; Info KDE style <info:(foo)bar baz>
6306 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6307 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6308 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6309 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6310 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6311 ;; Info links like `C-h i d m CC Mode RET'
6312 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6314 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6315 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6316 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6317 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6318 ;; Emacs help commands
6319 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6320 ;; regexp doesn't match arguments containing ` '.
6321 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6322 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6323 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6324 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6325 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6326 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6327 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6328 ;; The following entries may lead to many false positives so don't enable
6329 ;; them by default (use a high button level).
6330 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6331 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6332 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6333 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6334 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6335 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6336 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6337 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6338 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6339 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6340 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6341 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6342 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6343 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6344 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6345 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6346 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6347 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6348 ;; Unlike the other regexps we really have to require quoting
6349 ;; here to determine where it ends.
6350 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6351 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6352 ("<URL: *\\([^<>]*\\)>"
6353 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6354 ;; RFC 2396 (2.4.3., delims) ...
6355 ("\"URL: *\\([^\"]*\\)\""
6356 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6357 ;; RFC 2396 (2.4.3., delims) ...
6358 ("\"URL: *\\([^\"]*\\)\""
6359 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6361 (gnus-button-url-regexp
6362 0 (>= gnus-button-browse-level 0) browse-url 0)
6364 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6365 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6366 gnus-button-handle-man 1)
6367 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6368 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6369 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6370 gnus-button-handle-man 1)
6371 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6372 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6373 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6374 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6375 ;; MID or mail: To avoid too many false positives we don't try to catch
6376 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6377 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6378 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6379 ;; so that non-ambiguous entries (see above) match first.
6380 (gnus-button-mid-or-mail-regexp
6381 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6382 "*Alist of regexps matching buttons in article bodies.
6384 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6385 REGEXP: is the string (case insensitive) matching text around the button (can
6386 also be Lisp expression evaluating to a string),
6387 BUTTON: is the number of the regexp grouping actually matching the button,
6388 FORM: is a Lisp expression which must eval to true for the button to
6390 CALLBACK: is the function to call when the user push this button, and each
6391 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6393 CALLBACK can also be a variable, in that case the value of that
6394 variable it the real callback function."
6395 :group 'gnus-article-buttons
6396 :type '(repeat (list (choice regexp variable sexp)
6397 (integer :tag "Button")
6399 (function :tag "Callback")
6402 (integer :tag "Regexp group")))))
6404 (defcustom gnus-header-button-alist
6405 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6406 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6407 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6408 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6409 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6410 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6411 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6412 0 (>= gnus-button-browse-level 0) browse-url 0)
6413 ("^Subject:" gnus-button-url-regexp
6414 0 (>= gnus-button-browse-level 0) browse-url 0)
6415 ("^[^:]+:" gnus-button-url-regexp
6416 0 (>= gnus-button-browse-level 0) browse-url 0)
6417 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6418 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6419 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6420 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6421 "*Alist of headers and regexps to match buttons in article heads.
6423 This alist is very similar to `gnus-button-alist', except that each
6424 alist has an additional HEADER element first in each entry:
6426 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6428 HEADER is a regexp to match a header. For a fuller explanation, see
6429 `gnus-button-alist'."
6430 :group 'gnus-article-buttons
6431 :group 'gnus-article-headers
6432 :type '(repeat (list (regexp :tag "Header")
6433 (choice regexp variable)
6434 (integer :tag "Button")
6436 (function :tag "Callback")
6439 (integer :tag "Regexp group")))))
6441 (defvar gnus-button-regexp nil)
6442 (defvar gnus-button-marker-list nil)
6443 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6445 (defvar gnus-button-last nil)
6446 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6450 (defun gnus-article-push-button (event)
6451 "Check text under the mouse pointer for a callback function.
6452 If the text under the mouse pointer has a `gnus-callback' property,
6453 call it with the value of the `gnus-data' text property."
6455 (set-buffer (window-buffer (posn-window (event-start event))))
6456 (let* ((pos (posn-point (event-start event)))
6457 (data (get-text-property pos 'gnus-data))
6458 (fun (get-text-property pos 'gnus-callback)))
6461 (funcall fun data))))
6463 (defun gnus-article-press-button ()
6464 "Check text at point for a callback function.
6465 If the text at point has a `gnus-callback' property,
6466 call it with the value of the `gnus-data' text property."
6468 (let ((data (get-text-property (point) 'gnus-data))
6469 (fun (get-text-property (point) 'gnus-callback)))
6471 (funcall fun data))))
6473 (defun gnus-article-highlight (&optional force)
6474 "Highlight current article.
6475 This function calls `gnus-article-highlight-headers',
6476 `gnus-article-highlight-citation',
6477 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6478 do the highlighting. See the documentation for those functions."
6479 (interactive (list 'force))
6480 (gnus-article-highlight-headers)
6481 (gnus-article-highlight-citation force)
6482 (gnus-article-highlight-signature)
6483 (gnus-article-add-buttons force)
6484 (gnus-article-add-buttons-to-head))
6486 (defun gnus-article-highlight-some (&optional force)
6487 "Highlight current article.
6488 This function calls `gnus-article-highlight-headers',
6489 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6490 do the highlighting. See the documentation for those functions."
6491 (interactive (list 'force))
6492 (gnus-article-highlight-headers)
6493 (gnus-article-highlight-signature)
6494 (gnus-article-add-buttons))
6496 (defun gnus-article-highlight-headers ()
6497 "Highlight article headers as specified by `gnus-header-face-alist'."
6500 (set-buffer gnus-article-buffer)
6502 (let ((alist gnus-header-face-alist)
6503 (inhibit-read-only t)
6504 (case-fold-search t)
6505 (inhibit-point-motion-hooks t)
6506 entry regexp header-face field-face from hpoints fpoints)
6507 (article-narrow-to-head)
6508 (while (setq entry (pop alist))
6509 (goto-char (point-min))
6510 (setq regexp (concat "^\\("
6511 (if (string-equal "" (nth 0 entry))
6515 header-face (nth 1 entry)
6516 field-face (nth 2 entry))
6517 (while (and (re-search-forward regexp nil t)
6521 (unless (search-forward ":" nil t)
6523 (when (and header-face
6524 (not (memq (point) hpoints)))
6525 (push (point) hpoints)
6526 (gnus-put-text-property from (point) 'face header-face))
6527 (when (and field-face
6528 (not (memq (setq from (point)) fpoints)))
6530 (if (re-search-forward "^[^ \t]" nil t)
6532 (goto-char (point-max)))
6533 (gnus-put-text-property from (point) 'face field-face))))))))
6535 (defun gnus-article-highlight-signature ()
6536 "Highlight the signature in an article.
6537 It does this by highlighting everything after
6538 `gnus-signature-separator' using the face `gnus-signature'."
6541 (set-buffer gnus-article-buffer)
6542 (let ((inhibit-read-only t)
6543 (inhibit-point-motion-hooks t))
6545 (when (and gnus-signature-face
6546 (gnus-article-narrow-to-signature))
6547 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6548 'face gnus-signature-face)
6550 (gnus-article-search-signature)
6551 (let ((start (match-beginning 0))
6552 (end (set-marker (make-marker) (1+ (match-end 0)))))
6553 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6556 (defun gnus-button-in-region-p (b e prop)
6557 "Say whether PROP exists in the region."
6558 (text-property-not-all b e prop nil))
6560 (defun gnus-article-add-buttons (&optional force)
6561 "Find external references in the article and make buttons of them.
6562 \"External references\" are things like Message-IDs and URLs, as
6563 specified by `gnus-button-alist'."
6564 (interactive (list 'force))
6566 (set-buffer gnus-article-buffer)
6567 (let ((inhibit-read-only t)
6568 (inhibit-point-motion-hooks t)
6569 (case-fold-search t)
6570 (alist gnus-button-alist)
6572 ;; Remove all old markers.
6573 (let (marker entry new-list)
6574 (while (setq marker (pop gnus-button-marker-list))
6575 (if (or (< marker (point-min)) (>= marker (point-max)))
6576 (push marker new-list)
6578 (when (setq entry (gnus-button-entry))
6579 (put-text-property (match-beginning (nth 1 entry))
6580 (match-end (nth 1 entry))
6581 'gnus-callback nil))
6582 (set-marker marker nil)))
6583 (setq gnus-button-marker-list new-list))
6584 ;; We skip the headers.
6587 (while (setq entry (pop alist))
6588 (setq regexp (eval (car entry)))
6590 (while (re-search-forward regexp nil t)
6591 (let* ((start (and entry (match-beginning (nth 1 entry))))
6592 (end (and entry (match-end (nth 1 entry))))
6593 (from (match-beginning 0)))
6594 (when (and (or (eq t (nth 2 entry))
6595 (eval (nth 2 entry)))
6596 (not (gnus-button-in-region-p
6597 start end 'gnus-callback)))
6598 ;; That optional form returned non-nil, so we add the
6600 (gnus-article-add-button
6601 start end 'gnus-button-push
6602 (car (push (set-marker (make-marker) from)
6603 gnus-button-marker-list))))))))))
6605 ;; Add buttons to the head of an article.
6606 (defun gnus-article-add-buttons-to-head ()
6607 "Add buttons to the head of the article."
6610 (set-buffer gnus-article-buffer)
6612 (let ((inhibit-read-only t)
6613 (inhibit-point-motion-hooks t)
6614 (case-fold-search t)
6615 (alist gnus-header-button-alist)
6617 (article-narrow-to-head)
6619 ;; Each alist entry.
6620 (setq entry (car alist)
6622 (goto-char (point-min))
6623 (while (re-search-forward (car entry) nil t)
6624 ;; Each header matching the entry.
6625 (setq beg (match-beginning 0))
6626 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6627 (match-beginning 0))
6630 (while (re-search-forward (eval (nth 1 entry)) end t)
6631 ;; Each match within a header.
6632 (let* ((entry (cdr entry))
6633 (start (match-beginning (nth 1 entry)))
6634 (end (match-end (nth 1 entry)))
6635 (form (nth 2 entry)))
6636 (goto-char (match-end 0))
6638 (gnus-article-add-button
6639 start end (nth 3 entry)
6640 (buffer-substring (match-beginning (nth 4 entry))
6641 (match-end (nth 4 entry)))))))
6642 (goto-char end)))))))
6644 ;;; External functions:
6646 (defun gnus-article-add-button (from to fun &optional data)
6647 "Create a button between FROM and TO with callback FUN and data DATA."
6648 (when gnus-article-button-face
6649 (gnus-overlay-put (gnus-make-overlay from to)
6650 'face gnus-article-button-face))
6651 (gnus-add-text-properties
6653 (nconc (and gnus-article-mouse-face
6654 (list gnus-mouse-face-prop gnus-article-mouse-face))
6655 (list 'gnus-callback fun)
6656 (and data (list 'gnus-data data))))
6657 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6658 :button-keymap gnus-widget-button-keymap))
6660 ;;; Internal functions:
6662 (defun gnus-article-set-globals ()
6664 (set-buffer gnus-summary-buffer)
6665 (gnus-set-global-variables)))
6667 (defun gnus-signature-toggle (end)
6669 (set-buffer gnus-article-buffer)
6670 (let ((inhibit-read-only t)
6671 (inhibit-point-motion-hooks t))
6672 (if (text-property-any end (point-max) 'article-type 'signature)
6674 (gnus-delete-wash-type 'signature)
6675 (gnus-remove-text-properties-when
6676 'article-type 'signature end (point-max)
6677 (cons 'article-type (cons 'signature
6678 gnus-hidden-properties))))
6679 (gnus-add-wash-type 'signature)
6680 (gnus-add-text-properties-when
6681 'article-type nil end (point-max)
6682 (cons 'article-type (cons 'signature
6683 gnus-hidden-properties)))))
6684 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6685 (gnus-set-mode-line 'article))))
6687 (defun gnus-button-entry ()
6688 ;; Return the first entry in `gnus-button-alist' matching this place.
6689 (let ((alist gnus-button-alist)
6692 (setq entry (pop alist))
6693 (if (looking-at (eval (car entry)))
6698 (defun gnus-button-push (marker)
6699 ;; Push button starting at MARKER.
6702 (let* ((entry (gnus-button-entry))
6703 (inhibit-point-motion-hooks t)
6705 (args (mapcar (lambda (group)
6706 (let ((string (match-string group)))
6707 (gnus-set-text-properties
6708 0 (length string) nil string)
6715 (fboundp (symbol-value fun)))
6716 (apply (symbol-value fun) args))
6718 (gnus-message 1 "You must define `%S' to use this button"
6719 (cons fun args)))))))
6721 (defun gnus-parse-news-url (url)
6722 (let (scheme server port group message-id articles)
6725 (goto-char (point-min))
6726 (when (looking-at "\\([A-Za-z]+\\):")
6727 (setq scheme (match-string 1))
6728 (goto-char (match-end 0)))
6729 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
6730 (setq server (match-string 1))
6731 (setq port (if (stringp (match-string 3))
6732 (string-to-number (match-string 3))
6734 (goto-char (match-end 0)))
6737 ((looking-at "\\(.*@.*\\)")
6738 (setq message-id (match-string 1)))
6739 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6740 (setq group (match-string 1)
6741 articles (split-string (match-string 2) "-")))
6742 ((looking-at "\\([^/]+\\)/?")
6743 (setq group (match-string 1)))
6745 (error "Unknown news URL syntax"))))
6746 (list scheme server port group message-id articles)))
6748 (defun gnus-button-handle-news (url)
6750 (destructuring-bind (scheme server port group message-id articles)
6751 (gnus-parse-news-url url)
6755 (set-buffer gnus-summary-buffer)
6757 (let ((gnus-refer-article-method
6758 (nconc (list (list 'nntp server))
6759 gnus-refer-article-method))
6760 (nntp-port-number (or port "nntp")))
6761 (gnus-message 7 "Fetching %s with %s"
6762 message-id gnus-refer-article-method)
6763 (gnus-summary-refer-article message-id))
6764 (gnus-summary-refer-article message-id))))
6766 (gnus-button-fetch-group url)))))
6768 (defun gnus-button-handle-man (url)
6770 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6771 (when (eq gnus-button-man-handler 'woman)
6772 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
6773 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6774 (funcall gnus-button-man-handler url))
6776 (defun gnus-button-handle-info-url (url)
6777 "Fetch an info URL."
6778 (setq url (mm-subst-char-in-string ?+ ?\ url))
6780 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6781 (gnus-info-find-node
6782 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6784 ")" (gnus-url-unhex-string (match-string 2 url)))))
6785 ((string-match "([^)\"]+)[^\"]+" url)
6787 (gnus-replace-in-string
6788 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6789 (gnus-info-find-node url))
6790 (t (error "Can't parse %s" url))))
6792 (defun gnus-button-handle-info-url-gnome (url)
6793 "Fetch GNOME style info URL."
6794 (setq url (mm-subst-char-in-string ?_ ?\ url))
6795 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6796 (gnus-info-find-node
6798 (gnus-url-unhex-string
6799 (match-string 1 url))
6801 (or (gnus-url-unhex-string
6802 (match-string 2 url))
6804 (error "Can't parse %s" url)))
6806 (defun gnus-button-handle-info-url-kde (url)
6807 "Fetch KDE style info URL."
6808 (gnus-info-find-node (gnus-url-unhex-string url)))
6810 (defun gnus-button-handle-info-keystrokes (url)
6811 "Call `info' when pushing the corresponding URL button."
6812 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6817 (defun gnus-button-message-id (message-id)
6820 (set-buffer gnus-summary-buffer)
6821 (gnus-summary-refer-article message-id)))
6823 (defun gnus-button-fetch-group (address)
6824 "Fetch GROUP specified by ADDRESS."
6825 (if (not (string-match "[:/]" address))
6826 ;; This is just a simple group url.
6827 (gnus-group-read-ephemeral-group address gnus-select-method)
6830 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6832 (error "Can't parse %s" address)
6833 (gnus-group-read-ephemeral-group
6834 (match-string 4 address)
6835 `(nntp ,(match-string 1 address)
6836 (nntp-address ,(match-string 1 address))
6837 (nntp-port-number ,(if (match-end 3)
6838 (match-string 3 address)
6841 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
6843 (defun gnus-url-parse-query-string (query &optional downcase)
6844 (let (retval pairs cur key val)
6845 (setq pairs (split-string query "&"))
6847 (setq cur (car pairs)
6849 (if (not (string-match "=" cur))
6851 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6852 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6854 (setq key (downcase key)))
6855 (setq cur (assoc key retval))
6857 (setcdr cur (cons val (cdr cur)))
6858 (setq retval (cons (list key val) retval)))))
6861 (defun gnus-url-mailto (url)
6862 ;; Send mail to someone
6863 (when (string-match "mailto:/*\\(.*\\)" url)
6864 (setq url (substring url (match-beginning 1) nil)))
6865 (let (to args subject func)
6866 (setq args (gnus-url-parse-query-string
6867 (if (string-match "^\\?" url)
6869 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6870 (concat "to=" (match-string 1 url) "&"
6871 (match-string 2 url))
6872 (concat "to=" url)))
6874 subject (cdr-safe (assoc "subject" args)))
6877 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6880 (message-position-on-field (caar args)))
6881 (insert (gnus-replace-in-string
6882 (mapconcat 'identity (reverse (cdar args)) ", ")
6884 (setq args (cdr args)))
6887 (message-goto-subject))))
6889 (defun gnus-button-embedded-url (address)
6890 "Activate ADDRESS with `browse-url'."
6891 (browse-url (gnus-strip-whitespace address)))
6893 ;;; Next/prev buttons in the article buffer.
6895 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6896 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6898 (defvar gnus-prev-page-map
6899 (let ((map (make-sparse-keymap)))
6900 (unless (>= emacs-major-version 21)
6901 ;; XEmacs doesn't care.
6902 (set-keymap-parent map gnus-article-mode-map))
6903 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6904 (define-key map "\r" 'gnus-button-prev-page)
6907 (defvar gnus-next-page-map
6908 (let ((map (make-sparse-keymap)))
6909 (unless (>= emacs-major-version 21)
6910 ;; XEmacs doesn't care.
6911 (set-keymap-parent map gnus-article-mode-map))
6912 (define-key map gnus-mouse-2 'gnus-button-next-page)
6913 (define-key map "\r" 'gnus-button-next-page)
6916 (defun gnus-insert-prev-page-button ()
6918 (inhibit-read-only t))
6920 gnus-prev-page-line-format nil
6921 `(,@(gnus-local-map-property gnus-prev-page-map)
6923 gnus-callback gnus-article-button-prev-page
6924 article-type annotation))
6925 (widget-convert-button
6927 ;; Exclude a newline.
6930 :action 'gnus-button-prev-page
6931 :button-keymap gnus-prev-page-map)))
6933 (defun gnus-button-next-page (&optional args more-args)
6934 "Go to the next page."
6936 (let ((win (selected-window)))
6937 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6938 (gnus-article-next-page)
6939 (select-window win)))
6941 (defun gnus-button-prev-page (&optional args more-args)
6942 "Go to the prev page."
6944 (let ((win (selected-window)))
6945 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6946 (gnus-article-prev-page)
6947 (select-window win)))
6949 (defun gnus-insert-next-page-button ()
6951 (inhibit-read-only t))
6952 (gnus-eval-format gnus-next-page-line-format nil
6953 `(,@(gnus-local-map-property gnus-next-page-map)
6955 gnus-callback gnus-article-button-next-page
6956 article-type annotation))
6957 (widget-convert-button
6959 ;; Exclude a newline.
6962 :action 'gnus-button-next-page
6963 :button-keymap gnus-next-page-map)))
6965 (defun gnus-article-button-next-page (arg)
6966 "Go to the next page."
6968 (let ((win (selected-window)))
6969 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6970 (gnus-article-next-page)
6971 (select-window win)))
6973 (defun gnus-article-button-prev-page (arg)
6974 "Go to the prev page."
6976 (let ((win (selected-window)))
6977 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6978 (gnus-article-prev-page)
6979 (select-window win)))
6981 (defvar gnus-decode-header-methods
6982 '(mail-decode-encoded-word-region)
6983 "List of methods used to decode headers.
6985 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6986 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
6987 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6988 whose names match REGEXP.
6991 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6992 mail-decode-encoded-word-region
6993 (\"chinese\" . rfc1843-decode-region))
6996 (defvar gnus-decode-header-methods-cache nil)
6998 (defun gnus-multi-decode-header (start end)
6999 "Apply the functions from `gnus-encoded-word-methods' that match."
7000 (unless (and gnus-decode-header-methods-cache
7001 (eq gnus-newsgroup-name
7002 (car gnus-decode-header-methods-cache)))
7003 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7006 (nconc gnus-decode-header-methods-cache (list x))
7007 (if (and gnus-newsgroup-name
7008 (string-match (car x) gnus-newsgroup-name))
7009 (nconc gnus-decode-header-methods-cache
7011 gnus-decode-header-methods))
7012 (let ((xlist gnus-decode-header-methods-cache))
7015 (narrow-to-region start end)
7017 (funcall (pop xlist) (point-min) (point-max))))))
7020 ;;; Treatment top-level handling.
7023 (defun gnus-treat-article (condition &optional part-number total-parts type)
7024 (let ((length (- (point-max) (point-min)))
7025 (alist gnus-treatment-function-alist)
7026 (article-goto-body-goes-to-point-min-p t)
7030 (let ((list gnus-article-treat-types))
7032 (when (string-match (pop list) type)
7033 (throw 'found t)))))))
7034 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7036 (gnus-run-hooks 'gnus-part-display-hook)
7037 (dolist (elem alist)
7040 (when (gnus-buffer-live-p gnus-summary-buffer)
7041 (set-buffer gnus-summary-buffer))
7042 (symbol-value (car elem))))
7043 (when (and (or (consp val)
7045 (gnus-treat-predicate val)
7046 (or (not (get (car elem) 'highlight))
7049 (funcall (cadr elem)))))))
7051 ;; Dynamic variables.
7053 (defvar part-number)
7054 (defvar total-parts)
7059 (defun gnus-treat-predicate (val)
7066 (stringp (car val)))
7067 (apply 'gnus-or (mapcar `(lambda (s)
7068 (string-match s ,(or gnus-newsgroup-name "")))
7071 (let ((pred (pop val)))
7074 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7076 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7078 (not (gnus-treat-predicate (car val))))
7080 (equal (car val) type))
7082 (error "%S is not a valid predicate" pred)))))
7088 (eq part-number total-parts))
7092 (error "%S is not a valid value" val))))
7094 (defun gnus-article-encrypt-body (protocol &optional n)
7095 "Encrypt the article body."
7098 (or gnus-article-encrypt-protocol
7099 (completing-read "Encrypt protocol: "
7100 gnus-article-encrypt-protocol-alist
7102 current-prefix-arg))
7103 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7105 (error "Can't find the encrypt protocol %s" protocol))
7106 (if (member gnus-newsgroup-name '("nndraft:delayed"
7109 (error "Can't encrypt the article in group %s"
7110 gnus-newsgroup-name))
7111 (gnus-summary-iterate n
7113 (set-buffer gnus-summary-buffer)
7114 (let ((mail-parse-charset gnus-newsgroup-charset)
7115 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7116 (summary-buffer gnus-summary-buffer)
7118 (gnus-set-global-variables)
7119 (when (gnus-group-read-only-p)
7120 (error "The current newsgroup does not support article encrypt"))
7121 (gnus-summary-show-article t)
7123 (or (mail-header-references gnus-current-headers) ""))
7124 (set-buffer gnus-article-buffer)
7125 (let* ((inhibit-read-only t)
7127 (mapcar (lambda (field)
7128 (and (save-restriction
7129 (message-narrow-to-head)
7130 (goto-char (point-min))
7131 (search-forward field nil t))
7133 (message-narrow-to-field)
7135 (delete-region (point-min) (point-max))
7137 '("Content-Type:" "Content-Transfer-Encoding:"
7138 "Content-Disposition:"))))
7139 (message-narrow-to-head)
7140 (message-remove-header "MIME-Version")
7141 (goto-char (point-max))
7142 (setq point (point))
7143 (insert (apply 'concat headers))
7145 (narrow-to-region point (point-max))
7146 (let ((message-options message-options))
7147 (message-options-set 'message-sender user-mail-address)
7148 (message-options-set 'message-recipients user-mail-address)
7149 (message-options-set 'message-sign-encrypt 'not)
7151 (goto-char (point-min))
7152 (insert "MIME-Version: 1.0\n")
7154 (gnus-summary-edit-article-done
7155 references nil summary-buffer t))
7156 (when gnus-keep-backlog
7157 (gnus-backlog-remove-article
7158 (car gnus-article-current) (cdr gnus-article-current)))
7160 (when (get-buffer gnus-original-article-buffer)
7161 (set-buffer gnus-original-article-buffer)
7162 (setq gnus-original-article nil)))
7163 (when gnus-use-cache
7164 (gnus-cache-update-article
7165 (car gnus-article-current) (cdr gnus-article-current))))))))
7167 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7168 "The following specs can be used:
7169 %t The security MIME type
7172 %D Details if button is pressed")
7174 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7175 "The following specs can be used:
7176 %t The security MIME type
7179 %D Details if button is pressed")
7181 (defvar gnus-mime-security-button-line-format-alist
7182 '((?t gnus-tmp-type ?s)
7183 (?i gnus-tmp-info ?s)
7184 (?d gnus-tmp-details ?s)
7185 (?D gnus-tmp-pressed-details ?s)))
7187 (defvar gnus-mime-security-button-map
7188 (let ((map (make-sparse-keymap)))
7189 (unless (>= (string-to-number emacs-version) 21)
7190 (set-keymap-parent map gnus-article-mode-map))
7191 (define-key map gnus-mouse-2 'gnus-article-push-button)
7192 (define-key map "\r" 'gnus-article-press-button)
7195 (defvar gnus-mime-security-details-buffer nil)
7197 (defvar gnus-mime-security-button-pressed nil)
7199 (defvar gnus-mime-security-show-details-inline t
7200 "If non-nil, show details in the article buffer.")
7202 (defun gnus-mime-security-verify-or-decrypt (handle)
7203 (mm-remove-parts (cdr handle))
7204 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7205 point (inhibit-read-only t))
7207 (goto-char (car region)))
7209 (narrow-to-region (point) (point))
7210 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7211 (let* ((mm-verify-option 'known)
7212 (mm-decrypt-option 'known)
7213 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7214 (unless (eq nparts (cdr handle))
7215 (mm-destroy-parts (cdr handle))
7216 (setcdr handle nparts))))
7217 (setq point (point))
7218 (gnus-mime-display-security handle)
7219 (goto-char (point-max)))
7221 (delete-region (point) (cdr region))
7222 (set-marker (car region) nil)
7223 (set-marker (cdr region) nil))
7226 (defun gnus-mime-security-show-details (handle)
7227 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7229 (gnus-message 5 "No details.")
7230 (if gnus-mime-security-show-details-inline
7231 (let ((gnus-mime-security-button-pressed
7232 (not (get-text-property (point) 'gnus-mime-details)))
7233 (gnus-mime-security-button-line-format
7234 (get-text-property (point) 'gnus-line-format))
7235 (inhibit-read-only t))
7237 (while (eq (get-text-property (point) 'gnus-line-format)
7238 gnus-mime-security-button-line-format)
7242 (narrow-to-region (point) (point))
7243 (gnus-insert-mime-security-button handle))
7244 (delete-region (point)
7245 (or (text-property-not-all
7248 gnus-mime-security-button-line-format)
7251 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7252 (with-current-buffer gnus-mime-security-details-buffer
7255 (setq gnus-mime-security-details-buffer
7256 (gnus-get-buffer-create "*MIME Security Details*")))
7257 (with-current-buffer gnus-mime-security-details-buffer
7259 (goto-char (point-min)))
7260 (pop-to-buffer gnus-mime-security-details-buffer)))))
7262 (defun gnus-mime-security-press-button (handle)
7264 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7265 (gnus-mime-security-show-details handle)
7266 (gnus-mime-security-verify-or-decrypt handle))))
7268 (defun gnus-insert-mime-security-button (handle &optional displayed)
7269 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7272 (or (nth 2 (assoc protocol mm-verify-function-alist))
7273 (nth 2 (assoc protocol mm-decrypt-function-alist))
7275 (if (equal (car handle) "multipart/signed")
7276 " Signed" " Encrypted")
7279 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7282 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7283 gnus-tmp-pressed-details
7285 (setq gnus-tmp-details
7286 (if gnus-tmp-details
7287 (concat "\n" gnus-tmp-details)
7289 (setq gnus-tmp-pressed-details
7290 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7295 gnus-mime-security-button-line-format
7296 gnus-mime-security-button-line-format-alist
7297 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7298 gnus-callback gnus-mime-security-press-button
7299 gnus-line-format ,gnus-mime-security-button-line-format
7300 gnus-mime-details ,gnus-mime-security-button-pressed
7301 article-type annotation
7304 ;; Exclude a newline.
7307 (widget-convert-button
7310 :action 'gnus-widget-press-button
7311 :button-keymap gnus-mime-security-button-map
7313 (lambda (widget/window &optional overlay pos)
7314 ;; Needed to properly clear the message due to a bug in
7315 ;; wid-edit (XEmacs only).
7316 (when (boundp 'help-echo-owns-message)
7317 (setq help-echo-owns-message t))
7320 (aref gnus-mouse-2 0))))))
7322 (defun gnus-mime-display-security (handle)
7324 (narrow-to-region (point) (point))
7325 (unless (gnus-unbuttonized-mime-type-p (car handle))
7326 (gnus-insert-mime-security-button handle))
7327 (gnus-mime-display-mixed (cdr handle))
7330 (unless (gnus-unbuttonized-mime-type-p (car handle))
7331 (let ((gnus-mime-security-button-line-format
7332 gnus-mime-security-button-end-line-format))
7333 (gnus-insert-mime-security-button handle)))
7334 (mm-set-handle-multipart-parameter
7336 (cons (set-marker (make-marker) (point-min))
7337 (set-marker (make-marker) (point-max))))))
7343 (run-hooks 'gnus-art-load-hook)
7345 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7346 ;;; gnus-art.el ends here